An important way of learning to use a function library like the DrWimpC library is to see examples of code using it. At the time of writing, fifteen example programs are provided with the DrWimpC archive, and so far, six of them are documented here (!Clocker, !ColPick, !Create, !Draw, !MultiPane and !Slider). Most are translations and conversions of the examples provided with the BASIC Drwimp library, so you can compare the two. There is also one example showing the DrWimpC facility to have resuable template definitions along with their supporting code library (!bar2).
A good way to use investigate the examples is to load !DrWimpC, <SELECT> all the example programs in the Examples directory and load them into !DrWimpC by dragging the selection to the !DrWimpC icon bar icon. You can then select an example from the table below for explanatory notes, and use the !DrWimpC menu system to select the application from the application list sub menu, and load source files used by the example into a source editor, and if convenient use the function list obtained by use of the Source File Action Menu FN List action to navigate to each functions used by the example.
Example Programs' Automatically Created and Loaded Bar Icon, Window, Menu and Info Box.
Many of the example applications make use of the DrWimpC library facilities provided by the Application Details dialogue to specify icon bar options and window template definitions and files so that the DrwimpC creates and loads icon bar icon, window, menu and info box on the application's behalf. This means code to do this does not need to be in each example, unlike the equivalent BASIC examples.
Application Header files.
Many of the example applications need to pass data around the application for use in the response to various user actions. The functions in a C wimp application are typically stored in a number of source files. For example, the colour picker example !ColPick records the three RGB colour elements red, green and blue returned from the colour picker dialogue used to select the colour of a circle in the !ColPick window. These three values are first initialised, then used in the response to a mouse click, and a menu option, to open a colour picker dialogue, and finally to redraw the circle in the selected colour. So, these values must be available to the code in the initialistion function, colour selection, and redraw functions which are in different source files.
It is convenient to group all such items into a single structure and then pass, or make available, to the functions a pointer to the structure so that each function can access the data it requires. Since the structure will contain different data items for each application a generic pointer type is used - void * to do this by means of the user wimp application data pointer.
In order to reference the structure's data an application needs to know what the structure pointed to looks like. This is where application header files are useful.
The definition of the structure is placed in a header file which is stored in the application's h directory inside a sub directory named after the application. This means that the header file can be referred to using the application's path system variable. In the case of !ColPick there is a sub directory named ColPick, created in the main application directory, and a directory h inside this. Then, the path name is ColPick$Path, and the include statement for the header file in the source files is #include "ColPick/ColPickh", where ColPickh is the name of the header file. Using the application path variable gives a standard way of referring to an application header file throughout an application. When !DrWimpC generates the link program's command line in a make file it adds the path name <application name>: to the list of include paths, and during a make or build action.
Of course, you can put any other definitions in the header file and access them using the same method throughout your application.