Information for Programming

with

wxWidgets

 

bullet

Style of Programming:  The programming style when creating a program with a graphical user interface (GUI) is quite different than console (or text-based) programs like those that use cin and cout for input and output.  Console-style programs typically use a call-and-return architecture (i.e., a main program with calls to functions) as shown in the diagram below on the left.  GUI-based programs typically use an event-driven, callback architecture, where the system classes contain the main program event loop and the interface (GUI) is constructed at initialization, and responds afterwards to user-generated events, as demonstrated in the diagram below on the right.

System Classes

main()
func311()
func312()
func3()
func22()
func1()
func2()
func21()
func31()

 

 

 

 

 

 

 

 

 

 

 

main()
evtHandler1
constructor
GUI Class
evtHandler3
evtHandler4
evtHandler2
App Class
close()
init()
constructor

bullet

General Program Structure:  Because most of the "action" in an event-driven program is done in response to user events (e.g., mouse clicks, key presses, scrollbar movement, etc.), it is common for the event handlers to comprise the bulk of the "application", that is, what the programmer writes to accomplish the task at hand.

 

bullet

Resources:  To develop a GUI-based application, you need a set of graphical controls (or widgets as they are often called) such as buttons, check boxes, scrollbars, text fields, menus, etc.  You could write these controls yourself using C++ or some other programming language, but generally you will use a GUI toolkit (or library) that someone has already written for that purpose.  Common toolkits are Microsoft Foundation Classes (MFC), Motif, Tcl, AWT, Swing, Qt, or wxWidgets.  Keep in mind that whatever toolkit you choose has to work your application programming language and operating system--these restrictions will limit your choices somewhat.  Most of the toolkits referenced above work on both linux and Windows, except MFC (Windows only) and Motif (linux traditionally).  Tcl, AWT and Swing are compatible with Java.  MFC, Motif, Tcl, Qt, and wxWidgets work with C++.

While not necessary, a helpful addition to a GUI toolkit, is a GUI Development application.  This app helps the programmer build user interfaces in a drag-an-drop or WYSIWYG fashion.  This can be an enormous help in productivity, and such a tool is well worth the time invested, if you intend to build more than just a toy GUI.  With GUI programming being more pervasive than ever, it is getting common to see GUI development built into the programming environment.  As such, you can find GUI development capabilities in Visual Studio for C#, JBuilder for Java, Borland's C++ integrated development environment (IDE) , and several other IDEs both commercial and freeware.

 
bullet

GUI-Development Libraries:  In CS1220, we have chosen to introduce to you the wxWidgets toolkit.  We have selected wxWidgets, because it commonly -used, "industrial strength", freely available, well-supported, well-written, and compatible with C++ in both the Windows and linux O/Ss.

 
bullet

GUI Building Applications:  Another positive for choosing wxWidgets is that there is a GUI development application called DialogBocks that is compatible with wxWidgets, and that there is a personal use edition of this software that is well-documented and freely available.