Introduction !DrWimpC Features DrWimpC library Examples


!Clocker


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

Automatic creation of the bar window. Enabling and acting on null events.

!Clocker Overview.

Wimp Lib Actions

  • Null Events

Standard User Files.


.

Overview



!Clocker has a single window that is opened when the application is started, and when SELECT is clicked with the mouse pointer over the !Clocker icon on the icon bar. The window is called main and is defined in the Templates file. The main window, info box and a standard bar menu (consisting of the three standard items of Info, Help and Quit) are loaded and created automatically.

The application opens a small window defined in a template file in the centre of the screen. The window consists of five indirected sprite icons representing a digital clock display. Null events are used to update this display once a second with the current time. The time is read from the CMOS clock (soft copy) using OS_Word 14 into a buffer, and converted for display using OS_Convert_Date_and_Time.

[Top]

Application Data




static int dots;

This integer is used to keep track of whether a single or double dot separator should appear in the digital display. It is declared with static linkage at the start of file drwUwinit, and is passed to other functions via the appdata pointer in the standard user wimp data structure.


static char digit[4];

Also declared at the start of drwUwinit, represents each of the values in the digits in the display. Each value is used as the name of a sprite in file Sprites in the application directory, and the names of the indirected sprite in the display's icons is set according to the each value.

[Back to the Function List]
[Top]


void drw_u_null(void)


The drw_uw_init function enables null events, causing the DrWimp C library to pass control to this function on receipt of a null event. This function updates the digital display by setting the name of the indirected sprite for icon number 2 to either :0 or :1 - showing a single or double dot sprite which gives the flashing dot effect. clocker_gettime() is then called to update the internal data representing the display.

[Back to the Function List]
[Top]


void clocker_gettime(void)


This function reads the CMOS clock, converts it into a 24 hours and minutes string, and updates the digits string and the icons of the digital display.

[Back to the Function List]
[Top]


void drw_u_setup_uwdata(drw_uw_data *uwd)


All that is required here is to set the appdata field to the address of the integer dots for use in drw_u_null.

[Back to the Function List]
[Top]


void drw_uw_init(drw_uw_data *uwd)


This function carries out initialisation actions, initialising dots and digits to 0, and putting a single dot sprite name into icon 2. Using drw_wimp_puticontext works here because the icon data block is a union of the various structures that describe the icon data according to each icon type, so for an indirected sprite, setting the text is setting the sprite name. The digit string is then initially set up with a call to clocker_gettime. Finally null events are enabled by setting the null event flag bit in the flag word of the DrWimpC library global structure indicating that drw_u_null should be called when a null event is received.

[Back to the Function List]
[Top]


void drw_uw_poll(void)


Calls drw_wimp_pollidle with a one second interval so that with null events enabled, control is passed to drw_u_null at each second, instead of the usual drw_wimp_poll which returns control to your application at every null event.

[Back to the Function List]
[Top]