Rapicorn - Experimental UI Toolkit - Source Code
13.07.0
|
00001 // Licensed GNU LGPL v3 or later: http://www.gnu.org/licenses/lgpl.html 00002 #ifndef __RAPICORN_EVENT_HH__ 00003 #define __RAPICORN_EVENT_HH__ 00004 00005 #include <ui/primitives.hh> 00006 00007 namespace Rapicorn { 00008 00009 enum ModifierState { 00010 MOD_0 = 0, 00011 MOD_SHIFT = 1 << 0, 00012 MOD_CAPS_LOCK = 1 << 1, 00013 MOD_CONTROL = 1 << 2, 00014 MOD_ALT = 1 << 3, 00015 MOD_MOD1 = MOD_ALT, 00016 MOD_MOD2 = 1 << 4, 00017 MOD_MOD3 = 1 << 5, 00018 MOD_MOD4 = 1 << 6, 00019 MOD_MOD5 = 1 << 7, 00020 MOD_BUTTON1 = 1 << 8, 00021 MOD_BUTTON2 = 1 << 9, 00022 MOD_BUTTON3 = 1 << 10, 00023 MOD_KEY_MASK = (MOD_SHIFT | MOD_CONTROL | MOD_ALT), 00024 MOD_MASK = 0x07ff, 00025 }; 00026 00027 enum KeyValue { 00028 #include <ui/keysymbols.hh> 00029 }; 00030 00031 enum ActivateKeyType { 00032 ACTIVATE_NONE = 0, 00033 ACTIVATE_FOCUS, 00034 ACTIVATE_DEFAULT 00035 }; 00036 00037 unichar key_value_to_unichar (uint32 keysym); 00038 bool key_value_is_modifier (uint32 keysym); 00039 bool key_value_is_accelerator (uint32 keysym); 00040 FocusDirType key_value_to_focus_dir (uint32 keysym); 00041 bool key_value_is_focus_dir (uint32 keysym); 00042 ActivateKeyType key_value_to_activation (uint32 keysym); 00043 bool key_value_is_cancellation (uint32 keysym); 00044 00045 typedef enum { 00046 EVENT_NONE, 00047 MOUSE_ENTER, 00048 MOUSE_MOVE, 00049 MOUSE_LEAVE, 00050 BUTTON_PRESS, 00051 BUTTON_2PRESS, 00052 BUTTON_3PRESS, 00053 BUTTON_CANCELED, 00054 BUTTON_RELEASE, 00055 BUTTON_2RELEASE, 00056 BUTTON_3RELEASE, 00057 FOCUS_IN, 00058 FOCUS_OUT, 00059 KEY_PRESS, 00060 KEY_CANCELED, 00061 KEY_RELEASE, 00062 SCROLL_UP, /* button4 */ 00063 SCROLL_DOWN, /* button5 */ 00064 SCROLL_LEFT, /* button6 */ 00065 SCROLL_RIGHT, /* button7 */ 00066 CANCEL_EVENTS, 00067 WIN_SIZE, 00068 WIN_DELETE, 00069 WIN_DESTROY, 00070 EVENT_LAST 00071 } EventType; 00072 const char* string_from_event_type (EventType etype); 00073 00074 struct EventContext; 00075 class Event : public Deletable { 00076 RAPICORN_CLASS_NON_COPYABLE (Event); 00077 protected: 00078 explicit Event (EventType, const EventContext&); 00079 public: 00080 virtual ~Event(); 00081 const EventType type; 00082 uint32 time; 00083 bool synthesized; 00084 ModifierState modifiers; 00085 ModifierState key_state; /* modifiers & MOD_KEY_MASK */ 00086 double x, y; 00087 }; 00088 typedef Event EventMouse; 00089 class EventButton : public Event { 00090 protected: 00091 explicit EventButton (EventType, const EventContext&, uint); 00092 public: 00093 virtual ~EventButton(); 00094 /* button press/release */ 00095 uint button; /* 1, 2, 3 */ 00096 }; 00097 typedef Event EventScroll; 00098 typedef Event EventFocus; 00099 class EventKey : public Event { 00100 protected: 00101 explicit EventKey (EventType, const EventContext&, uint32, const String &); 00102 public: 00103 virtual ~EventKey(); 00104 /* key press/release */ 00105 uint32 key; /* of type KeyValue */ 00106 String key_name; 00107 }; 00108 struct EventWinSize : public Event { 00109 protected: 00110 explicit EventWinSize (EventType, const EventContext&, double, double, bool); 00111 public: 00112 virtual ~EventWinSize(); 00113 double width, height; 00114 bool intermediate; 00115 }; 00116 typedef Event EventWinDelete; 00117 typedef Event EventWinDestroy; 00118 struct EventContext { 00119 uint32 time; 00120 bool synthesized; 00121 ModifierState modifiers; 00122 double x, y; 00123 explicit EventContext (); 00124 explicit EventContext (const Event&); 00125 EventContext& operator= (const Event&); 00126 }; 00127 00128 Event* create_event_transformed (const Event &event, 00129 const Affine &affine); 00130 Event* create_event_cancellation (const EventContext &econtext); 00131 EventMouse* create_event_mouse (EventType type, 00132 const EventContext &econtext); 00133 EventButton* create_event_button (EventType type, 00134 const EventContext &econtext, 00135 uint button); 00136 EventScroll* create_event_scroll (EventType type, 00137 const EventContext &econtext); 00138 EventFocus* create_event_focus (EventType type, 00139 const EventContext &econtext); 00140 EventKey* create_event_key (EventType type, 00141 const EventContext &econtext, 00142 uint32 key, 00143 const char *name); 00144 EventWinSize* create_event_win_size (const EventContext &econtext, 00145 double width, 00146 double height, 00147 bool intermediate); 00148 EventWinDelete* create_event_win_delete (const EventContext &econtext); 00149 EventWinDestroy* create_event_win_destroy (const EventContext &econtext); 00150 00151 } // Rapicorn 00152 00153 #endif /* __RAPICORN_EVENT_HH__ */