|
||||||||||||
|
||||||||||||
| DrWimpC Program Initialisation. | ||||||||||||
| 4. The DrWimpC Library Initialisation Sequence. | ||||||||||||
| This section describes the order of initialisation of the DrWimpC library including when your application's initialisation functions are called (both those defined as template functions and the user function drw_uw_init()). The drw_app() function is a wrapper function to allow the drw_u_lib_init(), drw_u_templates_register(), the internal drw_u_set_app_name() and drw_u_setup_uwdata() functions for each application be used successfully by the shared library version of the DrWimpC library. For interest it may be worth a quick look the source code for the drw_app() function from the DrWimpC library. As you see it has the usual form of a RISC OS wimp application - of if (initialisation is successful) then poll for and process wimp events until the application is quit, then call the close down procedures. The taskhandle is the returned value from the DrWimpC library's call to swi Wimp_Initialise. | ||||||||||||
|
/* Title: drwapppt.c */ #include <stddef.h> #include <stdlib.h> #include <stdio.h> #include <locale.h> extern int drw_initialise(int argc, char *argv[], drw_ulib_init_fn ulibinitfn, drw_utpltes_register_fn utpltesregfn, drw_usetappname_fn usetappname, drw_setuwdata_fn usetuwdatafn, char *open_lib_debug_file, wimp_t *taskhandle) { struct lconv *mylconv; setlocale(LC_ALL, ""); mylconv = localeconv(); return drw_wimp_init(argc, argv, (void *)mylconv, ulibinitfn, utpltesregfn, usetappname, usetuwdatafn, open_lib_debug_file, taskhandle); } extern void drw_app(int argc, char *argv[], drw_ulib_init_fn ulibinitfn, drw_utpltes_register_fn utpltesregfn, drw_usetappname_fn usetappname, drw_setuwdata_fn usetuwdatafn, char *open_lib_debug_file) { wimp_t taskhandle; if (drw_initialise(argc, argv, ulibinitfn, utpltesregfn, usetappname, usetuwdatafn, open_lib_debug_file, &taskhandle)) { while (drw_poll()) ; } drw_wimp_closedown(taskhandle); } |
||||||||||||
|
The DrWimpC library initialisation starts with the call to drw_wimp_init() in drw_initialise(). Its order of processing is: a. Allocate space for the DrWimpC global data structure (pointed by the global pwd) on the malloc heap ,and initialise it.and the user wimp data structure(pointed to by pwd->uwd) for the application. b. Read the dcdefaults file and use it to set default values in the user wimp data structure. c. Get the DrWimpC libmsgs file if one exists in the application's resources directory, otherwise use the internal ones. d. Store the application's full directory path name on the malloc heap and point uwdata.fullappdirname to it. (uses the value of DRWAPP$DIR which is set to Obey$Dir early in the !Run file). e. Call drw_u_setup_uwdata() - defined in drwapp.c - so an application can adjust any defaults, etc before they are used in the DrWimpC library e.g. the wimp_messages list in the user wimp data structure.
f1 Allocate the wimp block (pointed to by pwd->wimpb and pwd->wb) on the malloc heap with size pwd->uwd->memforwimpblock. f2. Allocate the internal work buffers (pwd->stdwkbuffer, pwd->worvar and pwd->wmessageout with size pwd->uwd->maxobjsize. f3. If autoscroll is to be used, read the default sprites for the mouse pointer, etc. f4. Calls drw_u_set_app_name and allocates space for and stores the application's leaf name on the malloc heap, pointed to by pwd->uwd->appdirname. f5. Allocate and initialise the template and user function pointer arrays from the malloc heap, with minimum size of 202 entries.. f6. Read the application's 'Messages' file from the application's Rresources (and territory) directory if stored inside it, otherwise the DrWimpC library looks in the main application directory for a file called 'Messages'. If the file is found, it is opened and its handle stored in pwd->uwd.appmsgs.msghandle so your application can read its messages using the handle. f7. |
||||||||||||
| Previous: The User Wimp Data Structure Continued. | ||||||||||||