What are wxWidgets?
wxWidgets is an open source library of graphical user interface (GUI) objects for developing cross-platform applications. It is designed for use with C++, but bindings have been written for other languages, including Python, Perl, Ruby and C#. It is free for personal and commercial use and is one of the most complete GUI toolkits available. Because wxWidgets uses the platform SDK whenever possible, applications which use it have the same look and feel as the operating system they are running on. In this workshop, we take a quick look at how to hit the ground running when developing cross-platform interfaces with wxWidgets and we’ll use the open source Dev-C++ IDE for the examples.
A quick start with Dev-C++
Dev-C++ is one of the most popular C++ IDE’s available today. This is largely due to the fact that it is an open source development tool. It comes complete with the Mingw GNU compiler and has “plugin packs” for dozens of freely available libraries, including 3D graphics, animation, networking, OpenGL, databases, audio, video and much more. The latest version of Dev-C++ is available from bloodshed.net and, at the time of writing, is 5.0 Beta 9.2 (otherwise known as version 4.9.9.2). It is recommended that the default location be used when installing Dev-C++ (eg: c:\Dev-cpp) as it can behave unpredictably when located in a directory containing a space (eg: Program Files).
After installing Dev-C++, launch the IDE and run through the setup wizard to complete the installation. This will take a few minutes if you choose to use the autocomplete function, as Dev-C++ will create a cache of all its standard libraries before continuing to launch the IDE. After this is complete, you will need to install the wxWidgets library. The simplest way of doing this is to use the web update feature, available from the tools menu. Before wxWidgets can be installed, however, there are a few dependencies that must be resolved. First download the list of available updates and then select Compression from the category group drop-down box. Check zlib and click the download selected button.
Once the download is complete, it will be installed automatically. Repeat this process for the Image Manipulation group, this time selecting libtiff, libpng and libjpg before clicking the download selected button. Last but not least, select wxWidgets from the category group drop-down box. Check the boxes next to wxWidgets and click the download selected button. If you wish to use the Unicode version, be sure to select it instead. There are also standard and Unicode libraries for contributed code which that only be installed after wxWidgets is installed.

The web update feature of Dec-C++ can be used to
install the wxWidgets library and allits dependencies.
Once all the wxWidgets libraries are installed, select New->Project from the File menu and click the GUI Toolkits tab. There you will see an icon for the wxWidgets template, allowing you to instantly create a wxWidgets form application that will compile on Linux, Mac OS and Windows! Hitting F9 will compile and run the sample template, showing a resizable window complete with menu and status bars. The first thing you may notice about wxWidgets so far is that it is very slow to compile. Quick inspection of the executable will also reveal a file size of nearly 3MB. These facts may be somewhat off-putting at first, but it is worth keeping in mind that there are a lot of libraries being statically linked, and these allow the program to be cross-platform. Unlike Java, Mono or .NET, there is no runtime environment that needs to be installed. Instead, the runtime is built-in. If you are planning on developing a suite of applications, then it is possible to dynamically link the wxWidgets libraries. Plus it is possible to trim the executables down to about 2MB by tweaking the configuration settings. For now, however, let’s assume that a 3MB exe file is an acceptable alternative to a 30MB+ runtime environment.
An even quicker start with wxDevcpp
At this point we have a freeware IDE and the outer shell of a cross-platform GUI application, which isn’t a bad start for a few minutes of downloading and running GUI installers! Cursory inspection of the sample source code will reveal the wxWidgets framework to be fairly intuitive. For instance, the following snippet of ten lines is all that’s used to build standard menu and status bars.
wxMenu *FileMenu = new wxMenu;
wxMenuBar *MenuBar = new wxMenuBar;
FileMenu->Append(ID_MAINWIN_QUIT, _(“&Quit”));
MenuBar->Append(FileMenu, _(“&File”));
SetMenuBar(MenuBar);
CreateStatusBar(2);
SetStatusText(_(“Hello World!”));
There are also over 60 example applications that come with the wxWidgets and wxWidgets_contrib libraries, so perusing them is a good start to familiarising oneself with the framework. The fact that wxWidgets is a GUI library, however, means that it can be laborious building an interface from scratch by setting the XY co-ordinates of each control. There is a commercial application called wxDesigner that allows you to use a WYSIWYG interface for designing dialogs and forms and it will create source code for the application in a range of languages (eg: C++, C#, Python, Perl and XML). Alternatively, there is also a special build of Dev-C++ available that integrates both wxWidgets and a specialised visual forms editor. Known as wxDevcpp, this IDE is available for download from wxdsgn.sourceforge.net. The benefit of using wxDevcpp is that you get everything in a single installation package with the added benefit of a WYSIWYG dialog editor all under the one roof. The downside is that you may not be using the latest versions of the wxWidgets library, as the form designer is intimately linked with the wxWidgets version that comes with the installer.

The wxWidgets GUI template in Dev-C++ includes a menu bar and status bar, and will compile under Windows, Linux, and MacOS.

A new application using the wsDevcpp
frame template requires some additional
window properties to be specified.
Note that it is possible, however, to have both Dev-C++ and wxDevcpp installed, allowing you to design the interface in one before tweaking the application in the other. Note also that it is possible to use the Web update feature in wxDevcpp, although there is no guarantee that the form designer will support any features that have been updated since the build date of the IDE.
Write to the Editor at Technology and Business
* All fields are mandatory.