home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / powergui / thread / userevt / userevt.hpp < prev   
Text File  |  1996-10-29  |  5KB  |  112 lines

  1. #ifndef _USEREVT_
  2. #define _USEREVT_
  3. /***************************************************************
  4. * FILE NAME: userevt.hpp                                       *
  5. *                                                              *
  6. * DESCRIPTION:                                                 *
  7. *   This file contains the declaration(s) of the class(es):    *
  8. *     UserEvent   - Portable user-defined event class.         *
  9. *     UserHandler - Handler for UserEvents.                    *
  10. *                                                              *
  11. * COPYRIGHT:                                                   *
  12. *   Licensed Materials - Property of Solution Frameworks       *
  13. *   Copyright (C) 1996, Solution Frameworks                    *
  14. *   All Rights Reserved                                        *
  15. ***************************************************************/
  16. #ifndef _IEVENT_
  17.   #include <ievent.hpp>
  18. #endif
  19. #ifndef _IHANDLER_
  20.   #include <ihandler.hpp>
  21. #endif
  22.  
  23. /*------------------------ UserEvent ---------------------------
  24. | Objects of this class represent "user-defined" events (i.e., |
  25. | WM_USER events).                                             |
  26. |                                                              |
  27. | You can provide these attributes when you construct a        |
  28. | UserEvent:                                                   |
  29. |   o an ID (which is ultimately added to WM_USER)             |                
  30. |   o event parameter 1                                        |                
  31. |   o event parameter 2                                        |                
  32. |                                                              |                
  33. | Within a handler, you construct the UserEvent from the       |
  34. | IEvent received in your dispatchHandlerEvent function.       |                                
  35. |                                                              |
  36. | See UserHandler, below.                                      |
  37. --------------------------------------------------------------*/
  38. class UserEvent : public IEvent {
  39. public:
  40.   UserEvent ( unsigned int            id  = 0,
  41.               const IEventParameter1 &mp1 = 0,
  42.               const IEventParameter2 &mp2 = 0 );
  43.  
  44.   UserEvent ( const IEvent &genericEvent );
  45.  
  46.   ~UserEvent ( );
  47.  
  48. /*----------------------- userEventId --------------------------
  49. | This function returns the user-defined event id for this     |
  50. | event object.  Typically, you call this from within your     |
  51. | UserHandler-derived classes' handleUserEvent override to     |
  52. | determine the particular user-defined event that has         |
  53. | occurred.                                                    |       
  54. --------------------------------------------------------------*/
  55. unsigned long
  56.   userEventId ( ) const;
  57.  
  58. /*---------------------- postTo/sendTo -------------------------
  59. | You use these functions to post or send the user-defined     |
  60. | event object to a given window handle.                       |
  61. --------------------------------------------------------------*/
  62. void
  63.   postTo ( const IWindow       &window ) const,
  64.   postTo ( const IWindowHandle &window ) const;
  65.  
  66. unsigned long
  67.   sendTo ( const IWindow       &window ) const,
  68.   sendTo ( const IWindowHandle &window ) const;
  69.  
  70. /*-------------------------- baseId ----------------------------
  71. | This function returns the "base" id for all user-defined     |
  72. | events.  Essentially, it is a portable alias for "WM_USER."  |
  73. --------------------------------------------------------------*/
  74. static unsigned long
  75.   baseId ( );
  76. }; // class UserEvent
  77.  
  78. /*----------------------- UserHandler --------------------------
  79. | This is the abstract base class for handlers of user-defined |
  80. | events.  You create handlers for such events by deriving     |
  81. | from this class and overriding the handleUserEvent function. |
  82. |                                                              |
  83. | The base class provides support for intercepting a range     |
  84. | of user-defined event identifiers.  You provide the range
  85. | of identifiers to the constructor.  These identifiers are    |
  86. | added to UserEvent::baseId() to determine the event          |
  87. | identifiers that get handled.  The default is to handle      |
  88. | just UserEvent::baseId().                                    |
  89. --------------------------------------------------------------*/
  90. class UserHandler : public IHandler {
  91.  
  92. protected:
  93.   UserHandler ( unsigned long id = 0 );
  94.   UserHandler ( unsigned long low, unsigned long high );
  95.  
  96.   ~UserHandler ( );
  97.  
  98. virtual Boolean
  99.   handleUserEvent( UserEvent &event ) = 0;
  100.  
  101.  
  102. virtual Boolean
  103.   dispatchHandlerEvent ( IEvent &event );
  104.  
  105. private:
  106. unsigned long
  107.   low,
  108.   high;
  109. }; // class UserHandler
  110.  
  111. #endif // _USEREVT_
  112.