csutil/event.h
Go to the documentation of this file.00001 /* 00002 Event system related helpers 00003 Copyright (C) 2003 by Jorrit Tyberghein 00004 (C) 2003 by Frank Richter 00005 (C) 2005 by Adam D. Bradley <artdodge@cs.bu.edu> 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Library General Public License for more details. 00016 00017 You should have received a copy of the GNU Library General Public 00018 License along with this library; if not, write to the Free 00019 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00020 */ 00021 00022 #ifndef __CS_CSUTIL_EVENT_H__ 00023 #define __CS_CSUTIL_EVENT_H__ 00024 00025 #include "csextern.h" 00026 #include "iutil/event.h" 00027 #include "iutil/eventhandlers.h" 00028 00041 class CS_CRYSTALSPACE_EXPORT csKeyEventHelper 00042 { 00043 public: 00045 CS_PURE_METHOD static utf32_char GetRawCode (const iEvent* event); 00047 CS_PURE_METHOD static utf32_char GetCookedCode (const iEvent* event); 00049 static void GetModifiers (const iEvent* event, csKeyModifiers& modifiers); 00051 CS_PURE_METHOD static csKeyEventType GetEventType (const iEvent* event); 00056 CS_PURE_METHOD static bool GetAutoRepeat (const iEvent* event); 00058 CS_PURE_METHOD static csKeyCharType GetCharacterType (const iEvent* event); 00060 static bool GetEventData (const iEvent* event, csKeyEventData& data); 00066 static uint32 GetModifiersBits ( 00067 const csKeyModifiers& modifiers); 00072 CS_PURE_METHOD static uint32 GetModifiersBits (const iEvent* event); 00080 static void GetModifiers (uint32 mask, csKeyModifiers& modifiers); 00081 }; 00084 /* forward declaration */ 00085 class csEvent; 00086 00092 class CS_CRYSTALSPACE_EXPORT csMouseEventHelper 00093 { 00094 public: 00096 00097 static csEvent *NewEvent (csRef<iEventNameRegistry> ®, 00098 csTicks, csEventID name, csMouseEventType etype, int x, int y, 00099 uint32 AxesChanged, uint button, bool buttonstate, uint32 buttonMask, 00100 uint32 modifiers); 00101 static csEvent *NewEvent (csRef<iEventNameRegistry> ®, csTicks, 00102 csEventID name, uint8 n, csMouseEventType etype, int x, int y, 00103 uint32 axesChanged, uint button, bool buttonstate, uint32 buttonMask, 00104 uint32 modifiers); 00105 static csEvent *NewEvent (csRef<iEventNameRegistry> ®, csTicks, 00106 csEventID name, uint8 n, csMouseEventType etype, const int32 *axes, 00107 uint8 numAxes, uint32 axesChanged, uint button, bool buttonstate, 00108 uint32 buttonMask, uint32 modifiers); 00110 00112 CS_PURE_METHOD static csMouseEventType GetEventType (const iEvent* event); 00114 CS_PURE_METHOD static uint GetNumber(const iEvent *event); 00116 CS_PURE_METHOD static int GetX(const iEvent *event) 00117 { return csMouseEventHelper::GetAxis(event, 0); } 00119 CS_PURE_METHOD static int GetY(const iEvent *event) 00120 { return csMouseEventHelper::GetAxis(event, 1); } 00122 CS_PURE_METHOD static int GetAxis(const iEvent *event, uint axis); 00124 CS_PURE_METHOD static uint GetNumAxes(const iEvent *event); 00126 CS_PURE_METHOD static uint GetButton(const iEvent *event); 00128 CS_PURE_METHOD static bool GetButtonState(const iEvent *event); 00130 CS_PURE_METHOD static uint32 GetButtonMask(const iEvent *event); 00132 CS_PURE_METHOD static void GetModifiers(const iEvent *event, 00133 csKeyModifiers& modifiers) 00134 { csKeyEventHelper::GetModifiers(event, modifiers); } 00136 CS_PURE_METHOD static uint32 GetModifiers(const iEvent *event) 00137 { 00138 csKeyModifiers modifiers; 00139 csKeyEventHelper::GetModifiers(event, modifiers); 00140 return csKeyEventHelper::GetModifiersBits(modifiers); 00141 } 00143 static bool GetEventData (const iEvent* event, 00144 csMouseEventData& data); 00145 }; 00146 00154 class CS_CRYSTALSPACE_EXPORT csJoystickEventHelper 00155 { 00156 public: 00158 00159 static csEvent *NewEvent (csRef<iEventNameRegistry> ®, csTicks, 00160 csEventID name, int n, int x, int y, uint32 axesChanged, uint button, 00161 bool buttonState, uint32 buttonMask, uint32 modifiers); 00162 static csEvent *NewEvent (csRef<iEventNameRegistry> ®, csTicks, 00163 csEventID name, int n, const int32* axes, uint8 numAxes, uint32 axesChanged, 00164 uint button, bool buttonState, uint32 buttonMask, uint32 modifiers); 00166 00168 CS_PURE_METHOD static uint GetNumber(const iEvent *event); 00170 CS_PURE_METHOD static int GetAxis(const iEvent *event, uint); 00172 CS_PURE_METHOD static uint GetNumAxes(const iEvent *); 00174 CS_PURE_METHOD static uint GetButton(const iEvent *event); 00176 CS_PURE_METHOD static bool GetButtonState(const iEvent *event); 00178 CS_PURE_METHOD static uint32 GetButtonMask(const iEvent *event); 00180 static void GetModifiers(const iEvent *event, csKeyModifiers& modifiers) 00181 { csKeyEventHelper::GetModifiers(event, modifiers); } 00183 CS_PURE_METHOD static uint32 GetModifiers(const iEvent *event) 00184 { 00185 csKeyModifiers modifiers; 00186 csKeyEventHelper::GetModifiers(event, modifiers); 00187 return csKeyEventHelper::GetModifiersBits(modifiers); 00188 } 00190 static bool GetEventData (const iEvent* event, csJoystickEventData& data); 00191 }; 00192 00200 class CS_CRYSTALSPACE_EXPORT csInputEventHelper 00201 { 00202 public: 00204 CS_PURE_METHOD static uint GetButton (iEventNameRegistry *, 00205 const iEvent *event); 00207 CS_PURE_METHOD static bool GetButtonState (iEventNameRegistry *, 00208 const iEvent *event); 00209 }; 00210 00218 class CS_CRYSTALSPACE_EXPORT csCommandEventHelper 00219 { 00220 public: 00222 static csEvent *NewEvent (csTicks, csEventID name, bool Broadcast, 00223 intptr_t info = 0); 00224 00226 CS_PURE_METHOD static uint GetCode(const iEvent *event); 00228 CS_PURE_METHOD static intptr_t GetInfo(const iEvent *event); 00230 static bool GetEventData (const iEvent* event, csCommandEventData& data); 00231 }; 00232 00235 struct iEventQueue; 00236 struct iObjectRegistry; 00237 00238 namespace CS 00239 { 00240 00246 csHandlerID CS_CRYSTALSPACE_EXPORT RegisterWeakListener (iEventQueue *q, 00247 iEventHandler *listener, csRef<iEventHandler> &handler); 00248 csHandlerID CS_CRYSTALSPACE_EXPORT RegisterWeakListener (iEventQueue *q, 00249 iEventHandler *listener, const csEventID &ename, csRef<iEventHandler> &handler); 00250 csHandlerID CS_CRYSTALSPACE_EXPORT RegisterWeakListener (iEventQueue *q, 00251 iEventHandler *listener, const csEventID ename[], csRef<iEventHandler> &handler); 00252 00257 void CS_CRYSTALSPACE_EXPORT RemoveWeakListener (iEventQueue *q, 00258 csRef<iEventHandler> &handler); 00259 00260 } // namespace CS 00261 00264 #endif // __CS_CSUTIL_EVENT_H__
Generated for Crystal Space 1.2 by doxygen 1.4.7