home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / yacl-012.zip / ui / event.h < prev    next >
C/C++ Source or Header  |  1995-04-08  |  7KB  |  192 lines

  1.  
  2.  
  3. #ifndef _event_h_
  4. #define _event_h_
  5.  
  6.  
  7.  
  8.  
  9.  
  10. /*
  11.  *
  12.  *          Copyright (C) 1994, M. A. Sridhar
  13.  *  
  14.  *
  15.  *     This software is Copyright M. A. Sridhar, 1994. You are free
  16.  *     to copy, modify or distribute this software  as you see fit,
  17.  *     and to use  it  for  any  purpose, provided   this copyright
  18.  *     notice and the following   disclaimer are included  with all
  19.  *     copies.
  20.  *
  21.  *                        DISCLAIMER
  22.  *
  23.  *     The author makes no warranties, either expressed or implied,
  24.  *     with respect  to  this  software, its  quality, performance,
  25.  *     merchantability, or fitness for any particular purpose. This
  26.  *     software is distributed  AS IS.  The  user of this  software
  27.  *     assumes all risks  as to its quality  and performance. In no
  28.  *     event shall the author be liable for any direct, indirect or
  29.  *     consequential damages, even if the  author has been  advised
  30.  *     as to the possibility of such damages.
  31.  *
  32.  */
  33.  
  34.  
  35.  
  36.  
  37. // Authors:   M. A. Sridhar
  38. //            N. Bhowmik
  39.  
  40.  
  41. // This  class represents a YACL event.   An event may   be thought of as a
  42. // message  from one object  to  another.   It  therefore  encapsulates all
  43. // relevant  information for  communication  between  objects. An  event is
  44. // characterized  by  its  origin, type  and  destination,  the  origin and
  45. // destination being any VisualObject.  The type is further categorized  to
  46. // be hard or soft. A hard event is any event  captured from the underlying
  47. // system, i.e., one that represents the occurance  of a physical event.  A
  48. // soft event on  the  other hand   denotes  a conceptual event.  An  event
  49. // contains additional information like the point of occurance, key pressed
  50. // (if any), in order to make a message more informative.
  51. // 
  52. // The Event class includes an instance variable _nativeEvent, which is a
  53. // pointer to the platform-specific event (an MSG under Windows, and an
  54. // XEvent under X) which was translated to this high-level event. The
  55. // _nativeEvent can be used for platform-dependent processing if necessary.
  56.  
  57.  
  58. #if defined(__GNUC__)
  59. #pragma interface
  60. #endif
  61.  
  62. #include "ui/rectangl.h"
  63.  
  64. class CL_EXPORT UI_VisualObject;
  65.  
  66. enum UI_EventCategory {Event_Hard,Event_Soft};
  67. enum UI_EventType { // All these are sent from the controller.
  68.     Event_None = 0,
  69.  
  70.     // --------------------- Hard Events -----------------------
  71.  
  72.                               // ------------- Mouse events ------------
  73.     Event_MouseMove, 
  74.     Event_LButtonPress,
  75.     Event_MButtonPress,       
  76.     Event_RButtonPress,     
  77.     Event_LButtonRelease,   
  78.     Event_MButtonRelease,   
  79.     Event_RButtonRelease,   
  80.     Event_LButtonDblClk,
  81.     Event_MButtonDblClk,       
  82.     Event_RButtonDblClk,
  83.     
  84.                               // ------------- Scrolling events -----
  85.     Event_Scroll,             // Continuous scroll
  86.     Event_FinishScroll,       // End of continuous scroll
  87.     Event_ScrollToBegin,      // Scroll to the beginning of the interval
  88.     Event_ScrollToEnd,        // Scroll to the end of the interval
  89.     Event_ScrollForwardLine,
  90.     Event_ScrollBackwardLine,
  91.     Event_ScrollForwardPage,
  92.     Event_ScrollBackwardPage,
  93.     Event_ScrollToPosition,   // For this event, the param field contains
  94.                               // the position to scroll to
  95.     
  96.                               // -------------  Keyboard events ------
  97.     Event_KeyTyped,
  98.     Event_KeyDown,
  99.     Event_KeyUp,
  100.     
  101.                               // --------------- View events -----------    
  102.     Event_GetFocus,          
  103.     Event_LoseFocus,         
  104.     Event_Paint,              // View is exposed: needs painting
  105.     Event_GraphicsExpose,
  106.     Event_Reconfigure,        // View is moved or resized: curPos contains
  107.                               // the new shape rectangle
  108.     Event_ViewEnter,          // Mouse enters this view
  109.     Event_ViewLeave,          // Mouse leaves this view
  110.     Event_Iconify,
  111.     Event_Deiconify,
  112.     Event_FullScreen,         // Sent when the window is maximized
  113.  
  114.     // ------------------------ Soft Events ---------------------
  115.  
  116.     Event_FirstSoftEvent,     // Used only for deciding event category
  117.                               // New soft events must be added AFTER this!
  118.     Event_ChildCreated,       // A SimpleVObject creation event.
  119.     Event_CloseDown,          // Close down a visualobject if it is ready
  120.     Event_MakeInterface,      // 
  121.     Event_Quit,               // Unequivocal destroy. 
  122.     Event_Select,             // The recipient of the event has changed in
  123.                               // some way; e.g., the recipient is a
  124.                               // button, and it has been clicked, or it is a
  125.                               // menu item that has been selected
  126.     Event_Other
  127.         
  128. }; // End  event enumeration
  129.  
  130.  
  131.  
  132.  
  133.  
  134. class CL_EXPORT UI_Event: public CL_Object {
  135.  
  136. public:
  137.  
  138.     UI_Event (UI_EventType type,UI_VisualObject* origin,
  139.               UI_VisualObject* dest = NULL,
  140.               void* nativeEvent = NULL);
  141.     // If dest == NULL, it is set to origin
  142.     
  143.     UI_Event (const UI_Event&);
  144.  
  145.     ~UI_Event ();
  146.  
  147.     UI_VisualObject* Origin () const {return _origin;};
  148.  
  149.     UI_VisualObject* Destination () const {return _dest;};
  150.  
  151.     UI_EventType Type () const {return _type;} ;
  152.  
  153.     UI_EventCategory Category () const {return _category;};
  154.   
  155.     void SetDestination (UI_VisualObject* ); 
  156.  
  157.     void operator= (const UI_Event& );
  158.  
  159.     void operator= (const CL_Object& o)
  160.         {*this = (const UI_Event&) o;};
  161.  
  162.     void operator= (const CL_String&)
  163.         {NotImplemented ("Operator= (CL_String)");};
  164.  
  165.     //
  166.     //-------------------Attributes-------------------
  167.     //
  168.  
  169.     UI_Rectangle   curPos;    // Position of the event. The meaning of
  170.                               // this inst var depends on the kind of
  171.                               // event.
  172.     ulong          duration;
  173.     char           key;       // ASCII value of key pressed if any
  174.     ulong          param;     // Additional info if any
  175.     bool           _shiftKey; // Was the shift key pressed?
  176.     bool           _metaKey;  // Was the meta (alt) key pressed?
  177.     bool           _ctrlKey;  // Was the control key pressed?
  178.     void*          _nativeEvent; // Pointer to actual event structure
  179.                                  // received from underlying system
  180.     
  181. protected:
  182.     
  183.     UI_VisualObject* _origin;    // View where event occured 
  184.     UI_VisualObject* _dest;      // View for whom event is intended
  185.     UI_EventType     _type;
  186.     UI_EventCategory _category;
  187.  
  188.     friend class UI_Controller;
  189. };
  190.  
  191. #endif
  192.