Crystal Space: csutil/event.h Source File (Crystal Space Public API Reference)

| ## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# 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   CS_CONST_METHOD 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> &reg,
    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> &reg, 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> &reg, 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> &reg, 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> &reg, 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 CS_DEPRECATED_METHOD static int GetX(const iEvent *event)
    00171   { return csJoystickEventHelper::GetAxis(event, 0); }
    00173   CS_PURE_METHOD CS_DEPRECATED_METHOD static int GetY(const iEvent *event)
    00174   { return csJoystickEventHelper::GetAxis(event, 1); }
    00176   CS_PURE_METHOD static int GetAxis(const iEvent *event, uint);
    00178   CS_PURE_METHOD static uint GetNumAxes(const iEvent *);
    00180   CS_PURE_METHOD static uint GetButton(const iEvent *event);
    00182   CS_PURE_METHOD static bool GetButtonState(const iEvent *event);
    00184   CS_PURE_METHOD static uint32 GetButtonMask(const iEvent *event);
    00186   static void GetModifiers(const iEvent *event, csKeyModifiers& modifiers)
    00187   { csKeyEventHelper::GetModifiers(event, modifiers); }
    00189   CS_PURE_METHOD static uint32 GetModifiers(const iEvent *event)
    00190   {
    00191     csKeyModifiers modifiers;
    00192     csKeyEventHelper::GetModifiers(event, modifiers);
    00193     return csKeyEventHelper::GetModifiersBits(modifiers);
    00194   }
    00196   static bool GetEventData (const iEvent* event, csJoystickEventData& data);
    00197 };
    00198
    00206 class CS_CRYSTALSPACE_EXPORT csInputEventHelper
    00207 {
    00208 public:
    00210   CS_PURE_METHOD static uint GetButton (iEventNameRegistry *,
    00211         const iEvent *event);
    00213   CS_PURE_METHOD static bool GetButtonState (iEventNameRegistry *,
    00214         const iEvent *event);
    00215 };
    00216
    00224 class CS_CRYSTALSPACE_EXPORT csCommandEventHelper
    00225 {
    00226 public:
    00228   static csEvent *NewEvent (csTicks, csEventID name, bool Broadcast,
    00229     intptr_t info = 0);
    00230
    00232   CS_PURE_METHOD static uint GetCode(const iEvent *event);
    00234   CS_PURE_METHOD static intptr_t GetInfo(const iEvent *event);
    00236   static bool GetEventData (const iEvent* event, csCommandEventData& data);
    00237 };
    00238
    00241 struct iEventQueue;
    00242 struct iObjectRegistry;
    00243
    00244 namespace CS
    00245 {
    00246
    00252 csHandlerID CS_CRYSTALSPACE_EXPORT RegisterWeakListener (iEventQueue *q,
    00253   iEventHandler *listener, csRef<iEventHandler> &handler);
    00254 csHandlerID CS_CRYSTALSPACE_EXPORT RegisterWeakListener (iEventQueue *q,
    00255   iEventHandler *listener, const csEventID &ename, csRef<iEventHandler> &handler);
    00256 csHandlerID CS_CRYSTALSPACE_EXPORT RegisterWeakListener (iEventQueue *q,
    00257   iEventHandler *listener, const csEventID ename[], csRef<iEventHandler> &handler);
    00258
    00263 void CS_CRYSTALSPACE_EXPORT RemoveWeakListener (iEventQueue *q,
    00264   csRef<iEventHandler> &handler);
    00265
    00266 } // namespace CS
    00267
    00270 #endif // __CS_CSUTIL_EVENT_H__