Imagine++
Events.h
1 // ===========================================================================
2 // Imagine++ Libraries
3 // Copyright (C) Imagine
4 // For detailed information: http://imagine.enpc.fr/software
5 // ===========================================================================
6 
7 #ifndef IMAGINE_GRAPHICS_EVENTS_H
8 #define IMAGINE_GRAPHICS_EVENTS_H
9 
10 #include "Types.h"
11 
12 namespace Imagine {
15 
17  enum KeyCode {
18  KEY_BACK=16777219, KEY_TAB=16777217,
19  KEY_RETURN=16777220, KEY_NUMPAD_ENTER=16777221,
20  KEY_ESCAPE=16777216,
21  KEY_INSERT=16777222, KEY_DELETE=16777223,
22  KEY_HOME=16777232, KEY_END=16777233,
23  KEY_PAGEUP=16777238, KEY_PAGEDOWN,
24  KEY_LEFT=16777234, KEY_UP, KEY_RIGHT, KEY_DOWN,
25  KEY_SHIFT=16777248, KEY_CONTROL=16777249,
26  KEY_CMD=16777299, KEY_ALT=16777251,
27  KEY_PRINT=16777225, KEY_SCROLL=16777254,
28  KEY_PAUSE=16777224, KEY_MENU=16777301,
29  KEY_F1=16777264, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6,
30  KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12,
31  KEY_NUMLOCK=16777253
32  };
33 
34  // =============== Events ==========================
43  enum EventType {
44  EVT_NONE = 0,
45  EVT_BUT_ON = 2,
46  EVT_BUT_OFF = 3,
47  EVT_MOTION = 5,
48  EVT_KEY_ON,
49  EVT_KEY_OFF
50  };
59  enum EventState {
60  EVS_NONE =0,
61  EVS_SHIFT =(1<<0),
62  EVS_CONTROL=(1<<1),
63  EVS_ALT =(1<<2)
64  };
69  struct Event {
75  int button;
77  int key;
83  int subWin;
84  };
93  void milliSleep(int msec);
94 
95  // I/O control functions
96 
104  int getMouse(int& x, int& y);
112  inline int getMouse(IntPoint2& p) { return getMouse(p.x(), p.y()); }
126  int getKey(bool ignoreModifier=true);
134  int click();
141  int anyClick();
150  int anyClick(Window &win, int &subWin);
164  int anyGetKey(Window &win, int &subWin, bool ignoreModifier=true);
174  int anyGetMouse(int &x, int&y, Window &win, int &subWin);
184  inline int anyGetMouse(IntPoint2 &p, Window &win, int &subWin)
185  { return anyGetMouse(p.x(), p.y(), win, subWin); }
201  void getEvent(int ms, Event &ev);
209  void flushEvents();
218  void unGetEvent(const Event &ev);
219 
221 } /* namespace Imagine */
222 
223 #endif /* IMAGINE_GRAPHICS_EVENTS_H */
IntPoint2 pix
Mouse position (only for EVT_BUT_ON, EVT_BUT_OFF and EVT_MOTION).
Definition: Events.h:73
int anyClick()
Mouse click in any window.
void milliSleep(int msec)
...
Window win
Window.
Definition: Events.h:81
int subWin
SubWindow.
Definition: Events.h:83
EventState
Event State.
Definition: Events.h:59
int button
Pressed mouse button (1,2,3) if any.
Definition: Events.h:75
void flushEvents()
Flush events.
void unGetEvent(const Event &ev)
Unget event.
int key
Pressed key code if any (only for EVT_KEY_ON and EVT_KEY_OFF).
Definition: Events.h:77
WindowInternal * Window
Handle to a display window.
Definition: Types.h:48
void getEvent(int ms, Event &ev)
Get event.
int anyGetKey(Window &win, int &subWin, bool ignoreModifier=true)
Key press in any window.
int getKey(bool ignoreModifier=true)
Key press in active window.
EventType
Event type.
Definition: Events.h:43
EventType type
Event type.
Definition: Events.h:71
EventState state
Keyboard and mouse state (bitfield) just before event occured.
Definition: Events.h:79
KeyCode
Keyboard codes.
Definition: Events.h:17
Event info.
Definition: Events.h:69
const T & x() const
Read alias.
Definition: FVector.h:104
Imagine++ namespace.
Definition: Array.h:7
int getMouse(int &x, int &y)
Mouse click in active window (returning position).
int click()
Mouse click in active window.
const T & y() const
Read alias.
Definition: FVector.h:118
int anyGetMouse(int &x, int &y, Window &win, int &subWin)
Mouse click in any window (returning window and position).