Introduction !DrWimpC Features DrWimpC library Examples


!ColPick


The !ColPick Example Illustrates ... Source Files and Functions Used

Automatic creation of the bar window, info box. Automatic creation of the bar menu from a message file. The use of the DrWimpC Colour Picker functions.

!ColPick Overview.

Wimp Lib Actions

  • Colour Picker
  • Menu Selection
  • Redraw

Standard User Files.


.

Overview



!ColPick has a single window that is opened when the applicaton is started, and when SELECT is clicked with the mouse pointer over the !ColPick icon on the icon bar. The window is called main and is defined in the Templates2 file. The main window, info box and a bar menu are loaded and created automatically.

Globally used data items are grouped together into the colpick_app_data structure, whose definition is placed in a header file which is stored in the application's header directory.

The application opens a window defined in a template file in the centre of the screen. The window consists of a plotted circle and some explanatory text. The colour of the circle can be changed using a colour picker dialogue which is opened either by clicking SELECT with the mouse pointer over the window, or from the bar menu Colour submenu option.

[Top]

Application Data






static colpick_app_data cd;

The three colour values of red, green and blue, used in the colour picker dialogue to select the colour of the circle are grouped into a data structure, colpick_app_data. An instance of this structure is statically declared at the beginning of drw_uw_init.


void drw_u_setup_uwdata(drw_uw_data *uwd)


Sets the appdata field to the address of the colpick_app_data structure.

[Back to the Function List]
[Top]


void drw_uw_init(drw_uw_data *uwd)


This function carries out initialisation actions, setting the initial colour of the circle and attaching the colour picker dialogue to the Colour item of the bar menu.

[Back to the Function List]
[Top]


void drw_u_colourpickerrgb(int red, int green, int blue, int none)


This function is called when the colour pciker dialogue is concluded successfully by the user action of pressing the <RETURN> key, or clicking on the OK mouse button. The new colour element values are recorded and the window redrawn to update tthe circle's colour.

[Back to the Function List]
[Top]


void drw_u_overmenuarrow(wimp_menu **nextsubmenu, int parentmenuitem, int x, int y)


This is a very useful function allowing your application to make last minute changes before a submenu is opened, or even return a pointer to a different sub menu to be opened instead of the one supplied to the function (this is why the first parameter is a pointer to a pointer type). In this example, all that is done is to open the RGB colour picker selection dialogue, note the defined handle wSUBMENUCOLOURPICKER (=4) for detecting the colour pciker dialogue).

[Back to the Function List]
[Top]


void drw_u_mouseclick(wimp_w window, wimp_i icon, wimp_mouse_state button, int workx, int worky)


When the DrWimpC library receives a mouse click event for one of your application's windows, or iconbar icon, control is passed to this function so that your application can respond to the mouse click. !ColPick simply opens the colour picker dialogue, using the CMYK model (the seventh parameter of drw_wimp_opencolourpickermodel() indicates which model (extenstion data type) to use).

[Back to the Function List]
[Top]


void drw_u_redraw(wimp_draw *r, int printing, int page)


When the DrWimpC library receives a redraw event for one of your application's windows control is passed to this function so that your application can redraw any objects that fall into the area of the rectangle passed to the function. Here, the foreground colour is set using the currenltly selected colour values and the full circle redrawn in the window.

[Back to the Function List]
[Top]