InputHandler.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. GWEN
  3. Copyright (c) 2010 Facepunch Studios
  4. See license in Gwen.h
  5. */
  6. #pragma once
  7. #ifndef GWEN_INPUTHANDLER_H
  8. #define GWEN_INPUTHANDLER_H
  9. #include <queue>
  10. #include "Gwen/Gwen.h"
  11. namespace Gwen
  12. {
  13. namespace Controls
  14. {
  15. class Base;
  16. }
  17. namespace Key
  18. {
  19. const unsigned char Invalid = 0;
  20. const unsigned char Return = 1;
  21. const unsigned char Backspace = 2;
  22. const unsigned char Delete = 3;
  23. const unsigned char Left = 4;
  24. const unsigned char Right = 5;
  25. const unsigned char Shift = 6;
  26. const unsigned char Tab = 7;
  27. const unsigned char Space = 8;
  28. const unsigned char Home = 9;
  29. const unsigned char End = 10;
  30. const unsigned char Control = 11;
  31. const unsigned char Up = 12;
  32. const unsigned char Down = 13;
  33. const unsigned char Escape = 14;
  34. const unsigned char Alt = 15;
  35. const unsigned char Count = 16;
  36. } // namespace Key
  37. namespace Input
  38. {
  39. namespace Message
  40. {
  41. enum
  42. {
  43. Copy,
  44. Paste,
  45. Cut,
  46. Undo,
  47. Redo,
  48. SelectAll
  49. };
  50. };
  51. // For use in panels
  52. bool GWEN_EXPORT IsKeyDown(int iKey);
  53. bool GWEN_EXPORT IsLeftMouseDown();
  54. bool GWEN_EXPORT IsRightMouseDown();
  55. Gwen::Point GWEN_EXPORT GetMousePosition();
  56. inline bool IsShiftDown() { return IsKeyDown(Gwen::Key::Shift); }
  57. inline bool IsControlDown() { return IsKeyDown(Gwen::Key::Control); }
  58. // Does copy, paste etc
  59. bool GWEN_EXPORT DoSpecialKeys(Controls::Base* pCanvas, Gwen::UnicodeChar chr);
  60. bool GWEN_EXPORT HandleAccelerator(Controls::Base* pCanvas, Gwen::UnicodeChar chr);
  61. // Send input to canvas for study
  62. void GWEN_EXPORT OnMouseMoved(Controls::Base* pCanvas, int x, int y, int deltaX, int deltaY);
  63. bool GWEN_EXPORT OnMouseClicked(Controls::Base* pCanvas, int iButton, bool bDown);
  64. bool GWEN_EXPORT OnKeyEvent(Controls::Base* pCanvas, int iKey, bool bDown);
  65. void GWEN_EXPORT OnCanvasThink(Controls::Base* pControl);
  66. }; // namespace Input
  67. } // namespace Gwen
  68. #endif