home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / gcc / !GCC / patches / DeskLib / h / Event < prev    next >
Encoding:
Text File  |  1994-10-03  |  7.0 KB  |  183 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Event.h
  12.     Author:  Copyright © 1992 Jason Williams (for code by John Winters)
  13.     Version: 1.01 (14 Jul 1993)
  14.     Purpose: High-level WIMP event dispatch to a hierarchy of user event
  15.              handling functions.
  16.     Mods:    14 July 1993 - Added Event_Initialise3
  17. */
  18.  
  19.  
  20. #ifndef __dl_event_h
  21. #define __dl_event_h
  22.  
  23. #ifndef __dl_core_h
  24. #include "Core.h"
  25. #endif
  26.  
  27. #ifndef __dl_wimp_h
  28. #include "Wimp.h"
  29. #endif
  30.  
  31.  
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35.  
  36. /*  NOTES
  37.  *  =====
  38.  *
  39.  *  Event supplies a set of high-level functions for proper handling of WIMP
  40.  *  events.
  41.  *  It polls the WIMP for you, and then passes the resulting event to one of
  42.  *  your designated handler routines. Events are cascaded down through your
  43.  *  handlers until one of them returns TRUE, indicating that the event has
  44.  *  been successfully dealt with. This allows you to have application-wide
  45.  *  defaults for certain event types, with occasional overrides of that
  46.  *  default for specific windows or icons.
  47.  *
  48.  *  Handlers can be registered for the following (priority-ordered) things:
  49.  *
  50.  *    Specific window, specific icon, specific event.
  51.  *    Specific window, specific icon, any event.
  52.  *    Specific window, any icon, specific event.
  53.  *    Specific window, any icon, any event.
  54.  *    Any window, specific event.
  55.  *    Any window, any event.
  56.  *
  57.  *  When an non window-related event occurs, the order is as follows:
  58.  *
  59.  *    Any window, specific event.
  60.  *    Any window, any event.
  61.  *
  62.  *  A set of default handlers is also provided (handlers.c): You can copy
  63.  *  the code for the handlers you need into your own program as a base event
  64.  *  handling system.
  65.  *
  66.  *  Any event which has no registered handlers will automatically be masked
  67.  *  out in subsequent Wimp_Polls. (Except for "Quit" messages)
  68.  *
  69.  *  NULL events are treated (slightly) specially compared to other events.
  70.  *  After registering handler(s) for NULL events they will be turned on.
  71.  *  (They will NOT be turned on if you request a handler for ALL events. To
  72.  *  enable NULL events, you must specifically register a handler for
  73.  *  event_NULL events.)
  74.  *  As a default, Wimp_Poll will be used, but functions are supplied for
  75.  *  you to set a minimum return time (as in Wimp_PollIdle) if NULL events
  76.  *  are wanted less frequently
  77.  *  TWO options for NULL event handling are open to you:
  78.  *    Each NULL event is passed to ALL registered handlers,
  79.  *      (To allow you to do important things as often as possible)
  80.  *    Each handler gets one NULL event in turn, in a round-robin fashion.
  81.  *      (To allow you to multitask several "subtask" functions alongside
  82.  *       each other with ease)
  83.  */
  84.  
  85.  
  86.  
  87. /* user event_handler function */
  88. typedef BOOL (*event_handler) (event_pollblock *poll_block, void *reference);
  89.  
  90. extern event_pollmask event_mask;   /* Mask used by event_ FNs for Wimp_Poll */
  91. extern int event_taskhandle;        /* WIMP task-handle of this application  */
  92. extern unsigned int event_wimpversion;   /* Wimp version number * 100        */
  93. extern char event_taskname[40];          /* Application name                 */
  94. extern event_pollblock event_lastevent;  /* Last event received by event_()  */
  95.  
  96.  
  97. /* Event_Claim ------------------------------------------------------------
  98.  * Call this function to claim an event. This attaches the given handler
  99.  * function to the given event for all future event processing.
  100.  *    eventtype should be event_ANY  - to handle all events, or
  101.  *              an event type        - to handle a specific event
  102.  *    window    should be event_ANY  - if not window-specific, or
  103.  *              a window handle      - to attach ONLY to that window
  104.  *    icon      should be event_ANY  - if not icon-specific, or
  105.  *              an icon handle       - to attach ONLY to that icon
  106.  *              (NOTE: if icon != event_ANY, window MUST be defined)
  107.  *
  108.  *    handler   is the address of your handler function
  109.  *    reference is a handle for any user-data you want passed to the
  110.  *              function whenever it is called.
  111.  */
  112. extern BOOL Event_Claim(event_type eventtype,
  113.                         window_handle window,  icon_handle icon,
  114.                         event_handler handler, void *reference);
  115.  
  116.  
  117. /* Event_Release ----------------------------------------------------------
  118.  * This will release your claim on an event, removing the given handler
  119.  * from further usage.
  120.  * The parameters passed in should be the same as those passed to
  121.  * Event_Claim.
  122.  */
  123. extern BOOL Event_Release(event_type event,
  124.                           window_handle  window, icon_handle icon,
  125.                           event_handler handler, void *reference);
  126.  
  127.  
  128. /* Event_ReleaseWindow ----------------------------------------------------
  129.  * This is similar to Event_Release, but rather than delinking ONE handler
  130.  * it delinks ALL handlers attached to the given window. This should be done
  131.  * if you close/delete the window using low-level routines. (It is done
  132.  * automatically if you use Window_ calls to remove the window)
  133.  */
  134. extern void Event_ReleaseWindow(window_handle window);
  135.  
  136.  
  137.  
  138. /* Event_Process ----------------------------------------------------------
  139.  * Call this to process a Wimp_Poll event. It will cascade the event down
  140.  * through the event-handler hierarchy until one of your event handlers
  141.  * returns TRUE to indicate succesful handling of the message.
  142.  * NOTE that Event_Poll calls Wimp_Poll and Event_Process for you.
  143.  */
  144. extern void Event_Process(event_pollblock *event);
  145.  
  146.  
  147. /* Event_Poll -------------------------------------------------------------
  148.  * Main event poll routine. Use as in:
  149.  * while (TRUE)
  150.  *   Event_Poll();
  151.  */
  152. extern void Event_Poll(void);
  153.  
  154.  
  155. /* Event_Initialise -------------------------------------------------------
  156.  * Call this once to initialise the Wimp and the event manager
  157.  * **** This call is obsolescent, and should only be used if you still need
  158.  *      RISC OS 2 compatability - see Event_InitialisePlus, below.
  159.  */
  160. extern void Event_Initialise(char *taskname);
  161.  
  162.  
  163. /* Event_Initialise3 ------------------------------------------------------
  164.  * Extended version of Event_Initialise which allows the wimp version
  165.  * number to be set and the list of acceptable messages to be passed
  166.  *
  167.  * This function should only be used for version numbers of 300 or greater
  168.  * (i.e. for tasks which will only run on RISC OS 3 or later versions).
  169.  */
  170. extern void Event_Initialise3(char *taskname, int version, int *messages);
  171.  
  172.  
  173. /* Event_CloseDown --------------------------------------------------------
  174.  * Call this to CloseDown (quit) the application
  175.  */
  176. extern void Event_CloseDown(void);
  177.  
  178. #ifdef __cplusplus
  179.            }
  180. #endif
  181.  
  182. #endif
  183.