Integrated Templates

wxDev-C++

<  Previous   <           = Home =             > Next >

Integrated Templates

    wxDev-C++ uses a template system to allow the user to more easily create specific projects. By this point you've encountered templates without knowing it. When you select FileNew, Project on the IDE menu, the project type options listed in the dialog box (e.g. Console application, wxWidgets frame, etc.) are preset templates.

new project dialog

Templates usually include two components:
  1. A set of source files  - These source files contains the minimal amount of code needed to build the application
  2. Project file - A preset project file (extension .dev) containing all of the compiler and linker options necessary to build the application.
Templates are usually stored within the Templates subdirectory under the wxDev-C++ installation directory. Let's look at a simple example of a template from that directory.

Templates\2-ConsoleApp.dev
[Template]
ver=3
Name=Console Application
IconIndex=1
Description=A console application (MSDOS window)
Catagory=Basic
[Project]
UnitCount=1
Name=Console App
ProfilesCount=2
ProfileIndex=0


[Unit0]
CName=main.c
CppName=main.cpp
C=consoleapp_c.txt
Cpp=consoleapp_cpp.txt

[Profile0]
ProfileName=Mingw 3.4.2
Type=1
ObjFiles=
Includes=
Libs=
PrivateResource=
ResourceIncludes=
MakeIncludes=
Compiler=
CppCompiler=
Linker=
PreprocDefines=
CompilerSettings=0000000000000000000000
Icon=
ExeOutput=Output\MingW
ObjectOutput=Objects\MingW
OverrideOutput=0
OverrideOutputName=
HostApplication=
CommandLine=
UseCustomMakefile=0
CustomMakefile=
IncludeVersionInfo=0
SupportXPThemes=0
CompilerSet=0
compilerType=0

[Profile1]
ProfileName=MS VC++ 2005
Type=1
ObjFiles=
Includes=
Libs=
PrivateResource=
ResourceIncludes=
MakeIncludes=
Compiler=
CppCompiler=
Linker=
PreprocDefines=
CompilerSettings=000000000000010000000000000000000000
Icon=
ExeOutput=Output\MSVC++2005
ObjectOutput=Objects\MSVC++2005
OverrideOutput=0
OverrideOutputName=
HostApplication=
CommandLine=
UseCustomMakefile=0
CustomMakefile=
IncludeVersionInfo=0
SupportXPThemes=0
CompilerSet=1
compilerType=1


    The template above sets up a generic console project (i.e. a DOS shell application).  In the [Project] section, one source code unit and two compiler profiles are defined.  The source code unit is further specified as consisting of a C++ skeleton code which is derived from the file consoleapp_cpp.txt and renamed as file main.cpp. The two profiles are further specified as a MingW gcc and a MS VC++ 2005 compiler profile.

    Using a text editor, you can easily create your own templates for use with wxDev-C++. However, wxDev-C++ can also automatically create templates for you based on your existing projects. For example, let's say that you frequently like to use the Boost, wxWidgets, and SQLite libraries in your projects.  You'd like to create a Boost/wx/Lite (let's call it "BWL") template that sets up all of the includes, switches, and base code so that whenever you create a new project, you can have the template handle the basic setup and jump right into the main programming. Here's how to create your BWL template:

  1. Create the most basic project you can that correctly compiles, links, and executes using the Boost, wxWidgets, and SQLite libraries.
  2. On the File menu select New and then Template. A new template window appears. New template
  3. In the Template Info tab, you can specify the name, description, type, and icons associated with this template.
  4. In the Files tab, you can select which files of the current project you want to include in the template. Whenever you create new projects with this template, those files (and their contents) will be generated in the new project.
  5. In the Extras tab, you can specify extra compiler and linker switches/parameters that you wish to include in the template for new projects.
    Once you've filled out all of the necessary information for your new template, hit the Create button and save the template with a unique name (e.g. BWL-template.dev).

    To test your new template, close the current project and try to create a new project (File, New, Project). Your BWL template should appear as an option in the list and can be used like any other.