home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / dreamscape / source / Dreamscape / Headers / low-level / h / tboxevent < prev    next >
Encoding:
Text File  |  1996-09-04  |  3.9 KB  |  105 lines

  1.  
  2. /* low-level.h.tboxevent
  3.  *
  4.  * Dreamscape - C++ class library for RISC OS
  5.  * Copyright (c) 1996 Mark Seaborn <mseaborn@argonet.co.uk>
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU Library General Public
  9.  * License as published by the Free Software Foundation; either
  10.  * version 2 of the License, or (at your option) any later version.
  11.  * See the Dreamscape documentation for more information.
  12.  */
  13.  
  14. #ifndef dreamscape_tboxevent_H
  15. #define dreamscape_tboxevent_H
  16.  
  17. #include "bool.h"
  18.  
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22.  
  23. typedef void (dscape_tboxevent_s_handler)(const struct toolbox_action *event,
  24.         const struct toolbox_block *ids);
  25. typedef bool (dscape_tboxevent_handler)(const struct toolbox_action *event,
  26.         const struct toolbox_block *ids, void *handle);
  27. #define dscape_tboxevent_any_object ((struct toolbox_o_ *) 0)
  28. #define dscape_tboxevent_any_component ((int) -1)
  29. #define dscape_tboxevent_match_self (1<<0)
  30. #define dscape_tboxevent_match_parent (1<<1)
  31. #define dscape_tboxevent_match_ancestor (1<<2)
  32.  
  33. void dscape_tboxevent_dispatch_event(const struct toolbox_action *event,
  34.     const struct toolbox_block *ids);
  35.  
  36. /* simple handlers, registered on an event */
  37. void dscape_tboxevent_register_s_handler(int id,
  38.     dscape_tboxevent_s_handler *function);
  39. void dscape_tboxevent_deregister_s_handler(int id,
  40.     dscape_tboxevent_s_handler *function);
  41.  
  42. /* object handlers, registered on an event and an object */
  43. void dscape_tboxevent_register_o_handler(int id, struct toolbox_o_ *object,
  44.     unsigned object_matches, dscape_tboxevent_handler *function,
  45.     void *handle);
  46. void dscape_tboxevent_deregister_o_handler(int id, struct toolbox_o_ *object,
  47.     unsigned object_matches, dscape_tboxevent_handler *function,
  48.     void *handle);
  49.  
  50. /* gadget handlers, registered on an event, an object and a component */
  51. void dscape_tboxevent_register_c_handler(int id, struct toolbox_o_ *object,
  52.     unsigned object_matches, int component, unsigned component_matches,
  53.     dscape_tboxevent_handler *function, void *handle);
  54. void dscape_tboxevent_deregister_c_handler(int id, struct toolbox_o_ *object,
  55.     unsigned object_matches, int component, unsigned component_matches,
  56.     dscape_tboxevent_handler *function, void *handle);
  57.  
  58. #ifdef __cplusplus
  59. }
  60.  
  61. typedef struct toolbox_o_ *toolbox_o;
  62. struct toolbox_action;
  63. struct toolbox_block;
  64.  
  65. class ToolboxEventHandler {
  66. public:
  67.   typedef dscape_tboxevent_s_handler SHandler;
  68.   typedef dscape_tboxevent_handler Handler;
  69.   enum { any_object = 0, any_component = -1,
  70.      match_object = 1<<0,  match_parent = 1<<1, match_ancestor = 1<<2 };
  71.  
  72.   static void dispatch_event(const toolbox_action *event,
  73.         const toolbox_block *ids)
  74.     { dscape_tboxevent_dispatch_event(event, ids); }
  75.  
  76.   static void register_handler(int id, SHandler *function)
  77.     { dscape_tboxevent_register_s_handler(id, function); }
  78.   static void deregister_handler(int id, SHandler *function)
  79.     { dscape_tboxevent_deregister_s_handler(id, function); }
  80.  
  81.   static void register_handler(int id, toolbox_o object,
  82.         unsigned object_matches, Handler *function, void *handle)
  83.     { dscape_tboxevent_register_o_handler(id, object, object_matches,
  84.         function, handle); }
  85.   static void deregister_handler(int id, toolbox_o object,
  86.         unsigned object_matches, Handler *function, void *handle)
  87.     { dscape_tboxevent_deregister_o_handler(id, object, object_matches,
  88.         function, handle); }
  89.  
  90.   static void register_handler(int id, toolbox_o object,
  91.         unsigned object_matches, int component,
  92.         unsigned component_matches, Handler *function, void *handle)
  93.     { dscape_tboxevent_register_c_handler(id, object, object_matches,
  94.         component, component_matches, function, handle); }
  95.   static void deregister_handler(int id, toolbox_o object,
  96.         unsigned object_matches, int component,
  97.         unsigned component_matches, Handler *function, void *handle)
  98.     { dscape_tboxevent_deregister_c_handler(id, object, object_matches,
  99.         component, component_matches, function, handle); }
  100. };
  101.  
  102. #endif
  103.  
  104. #endif
  105.