00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #if !defined(_XRB_INPUT_EVENTS_HPP_)
00012 #define _XRB_INPUT_EVENTS_HPP_
00013
00014 #include "xrb.hpp"
00015
00016 #include "xrb_event.hpp"
00017
00018 namespace Xrb
00019 {
00020
00022 class EventInput : public Event
00023 {
00024 public:
00025
00027 EventInput (Float time, EventType event_type)
00028 :
00029 Event(time, event_type)
00030 { }
00032 virtual ~EventInput () = 0;
00033
00037 virtual bool IsInputEvent () const { return true; }
00038 };
00039
00046 class EventKey : public EventInput
00047 {
00048 public:
00049
00052 EventKey (Key::Code code, Key::Modifier modifier, Float time, EventType event_type);
00056 virtual ~EventKey () = 0;
00057
00061 virtual bool IsKeyEvent () const { return true; }
00064 Key::Code KeyCode () const { return m_code; }
00067 Key::Modifier KeyModifier () const { return m_modifier; }
00071 inline bool IsEitherAltKeyPressed () const
00072 {
00073 return (m_modifier & Key::MOD_ALT) != 0;
00074 }
00078 inline bool IsEitherControlKeyPressed () const
00079 {
00080 return (m_modifier & Key::MOD_CTRL) != 0;
00081 }
00085 inline bool IsEitherShiftKeyPressed () const
00086 {
00087 return (m_modifier & Key::MOD_SHIFT) != 0;
00088 }
00092 char ModifiedAscii () const { return m_modified_ascii; }
00097 virtual bool IsKeyDownEvent () const { return false; }
00102 virtual bool IsKeyUpEvent () const { return false; }
00107 virtual bool IsKeyRepeatEvent () const { return false; }
00108
00109 private:
00110
00111
00112 Key::Code m_code;
00113
00114 Key::Modifier m_modifier;
00115
00116 char m_modified_ascii;
00117 };
00118
00124 class EventKeyDown : public EventKey
00125 {
00126 public:
00127
00130 EventKeyDown (
00131 Key::Code code,
00132 Key::Modifier modifier,
00133 Float time)
00134 :
00135 EventKey(code, modifier, time, KEYDOWN)
00136 { }
00139 virtual ~EventKeyDown () { }
00140
00144 virtual bool IsKeyDownEvent () const { return true; }
00145 };
00146
00152 class EventKeyUp : public EventKey
00153 {
00154 public:
00155
00158 EventKeyUp (
00159 Key::Code code,
00160 Key::Modifier modifier,
00161 Float time)
00162 :
00163 EventKey(code, modifier, time, KEYUP)
00164 { }
00167 virtual ~EventKeyUp () { }
00168
00172 virtual bool IsKeyUpEvent () const { return true; }
00173 };
00174
00182 class EventKeyRepeat : public EventKey
00183 {
00184 public:
00185
00188 EventKeyRepeat (
00189 Key::Code code,
00190 Key::Modifier modifier,
00191 Float const time)
00192 :
00193 EventKey(code, modifier, time, KEYREPEAT)
00194 { }
00197 virtual ~EventKeyRepeat () { }
00198
00202 virtual bool IsKeyRepeatEvent () const { return true; }
00203 };
00204
00211 class EventMouse : public EventInput
00212 {
00213 public:
00214
00217 EventMouse (
00218 ScreenCoordVector2 const &position,
00219 Key::Modifier modifier,
00220 Float time,
00221 EventType event_type);
00224 virtual ~EventMouse () = 0;
00225
00229 virtual bool IsMouseEvent () const { return true; }
00232 ScreenCoordVector2 const &Position () const { return m_position; }
00236 inline bool IsEitherAltKeyPressed () const
00237 {
00238 return (m_modifier & Key::MOD_ALT) != 0;
00239 }
00243 inline bool IsEitherControlKeyPressed () const
00244 {
00245 return (m_modifier & Key::MOD_CTRL) != 0;
00246 }
00250 inline bool IsEitherShiftKeyPressed () const
00251 {
00252 return (m_modifier & Key::MOD_SHIFT) != 0;
00253 }
00257 inline bool IsCapsLockOn () const
00258 {
00259 return (m_modifier & Key::MOD_CAPS) != 0;
00260 }
00264 inline bool IsNumLockOn () const
00265 {
00266 return (m_modifier & Key::MOD_NUM) != 0;
00267 }
00268
00269 private:
00270
00271
00272 ScreenCoordVector2 m_position;
00273
00274 Key::Modifier m_modifier;
00275 };
00276
00284 class EventMouseButton : public EventMouse
00285 {
00286 public:
00287
00290 EventMouseButton (
00291 Key::Code button_code,
00292 ScreenCoordVector2 const &position,
00293 Key::Modifier modifier,
00294 Float time,
00295 EventType event_type);
00298 virtual ~EventMouseButton () = 0;
00299
00302 Key::Code ButtonCode () const { return m_button_code; }
00306 virtual bool IsMouseButtonEvent () const { return true; }
00311 virtual bool IsMouseButtonDownEvent () const { return false; }
00316 virtual bool IsMouseButtonUpEvent () const { return false; }
00317
00318 private:
00319
00320 Key::Code m_button_code;
00321 };
00322
00328 class EventMouseButtonDown : public EventMouseButton
00329 {
00330 public:
00331
00334 EventMouseButtonDown (
00335 Key::Code button_code,
00336 ScreenCoordVector2 const &position,
00337 Key::Modifier modifier,
00338 Float time)
00339 :
00340 EventMouseButton(button_code, position, modifier, time, MOUSEBUTTONDOWN)
00341 { }
00344 virtual ~EventMouseButtonDown () { }
00345
00349 virtual bool IsMouseButtonDownEvent () const { return true; }
00350 };
00351
00357 class EventMouseButtonUp : public EventMouseButton
00358 {
00359 public:
00360
00363 EventMouseButtonUp (
00364 Key::Code button_code,
00365 ScreenCoordVector2 const &position,
00366 Key::Modifier modifier,
00367 Float time)
00368 :
00369 EventMouseButton(button_code, position, modifier, time, MOUSEBUTTONUP)
00370 { }
00373 virtual ~EventMouseButtonUp () { }
00374
00378 virtual bool IsMouseButtonUpEvent () const { return true; }
00379 };
00380
00386 class EventMouseWheel : public EventMouseButton
00387 {
00388 public:
00389
00392 EventMouseWheel (
00393 Key::Code button_code,
00394 ScreenCoordVector2 const &position,
00395 Key::Modifier modifier,
00396 Float time)
00397 :
00398 EventMouseButton(button_code, position, modifier, time, MOUSEWHEEL)
00399 { }
00402 virtual ~EventMouseWheel () { }
00403 };
00404
00413 class EventMouseMotion : public EventMouse
00414 {
00415 public:
00416
00419 EventMouseMotion (
00420 bool is_left_mouse_button_pressed,
00421 bool is_middle_mouse_button_pressed,
00422 bool is_right_mouse_button_pressed,
00423 ScreenCoordVector2 const &position,
00424 ScreenCoordVector2 const &delta,
00425 Key::Modifier modifier,
00426 Float time);
00427 virtual ~EventMouseMotion () { }
00428
00432 virtual bool IsMouseMotionEvent () const { return true; }
00435 ScreenCoordVector2 const &Delta () const { return m_delta; }
00439 bool IsLeftMouseButtonPressed () const { return m_is_left_mouse_button_pressed; }
00443 bool IsMiddleMouseButtonPressed () const { return m_is_middle_mouse_button_pressed; }
00447 bool IsRightMouseButtonPressed () const { return m_is_right_mouse_button_pressed; }
00448
00449 private:
00450
00451 bool m_is_left_mouse_button_pressed;
00452 bool m_is_middle_mouse_button_pressed;
00453 bool m_is_right_mouse_button_pressed;
00454
00455 ScreenCoordVector2 m_delta;
00456 };
00457
00461 class EventJoy : public EventInput
00462 {
00463 public:
00464
00467 EventJoy (Float time, EventType event_type) : EventInput(time, event_type) { }
00470 virtual ~EventJoy () = 0;
00471
00475 virtual bool IsJoyEvent () const { return true; }
00476 };
00477
00480 class EventQuit : public Event
00481 {
00482 public:
00483
00484 EventQuit (Float time) : Event(time, QUIT) { }
00485 };
00486
00487 }
00488
00489 #endif // !defined(_XRB_INPUT_EVENTS_HPP_)
00490