afxEventCatchAll.cpp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  2. // Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
  3. // Copyright (C) 2015 Faust Logic, Inc.
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to
  7. // deal in the Software without restriction, including without limitation the
  8. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9. // sell copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. // IN THE SOFTWARE.
  22. //
  23. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  24. #include "afx/arcaneFX.h"
  25. #include "gui/3d/guiTSControl.h"
  26. class afxEventCatchAll : public GuiControl
  27. {
  28. typedef GuiControl Parent;
  29. public:
  30. /* C */ afxEventCatchAll() { }
  31. virtual void getCursor(GuiCursor *&cursor, bool &showCursor, const GuiEvent &lastGuiEvent);
  32. virtual void onMouseUp(const GuiEvent&);
  33. virtual void onMouseDown(const GuiEvent&);
  34. virtual void onMouseMove(const GuiEvent&);
  35. virtual void onMouseDragged(const GuiEvent&);
  36. virtual void onMouseEnter(const GuiEvent&);
  37. virtual void onMouseLeave(const GuiEvent&);
  38. virtual bool onMouseWheelUp(const GuiEvent&);
  39. virtual bool onMouseWheelDown(const GuiEvent&);
  40. virtual void onRightMouseDown(const GuiEvent&);
  41. virtual void onRightMouseUp(const GuiEvent&);
  42. virtual void onRightMouseDragged(const GuiEvent&);
  43. DECLARE_CONOBJECT(afxEventCatchAll);
  44. DECLARE_CATEGORY("AFX");
  45. };
  46. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  47. IMPLEMENT_CONOBJECT(afxEventCatchAll);
  48. ConsoleDocClass( afxEventCatchAll,
  49. "@brief A simple but useful GUI control that propagates all events to its parent "
  50. "control.\n\n"
  51. "afxEventCatchAll is useful when you want certain events to be handled by its parent "
  52. "afxTSCtrl and not get consumed by certain non-interactive controls like a text "
  53. "HUD.\n\n"
  54. "@ingroup afxGUI\n"
  55. "@ingroup AFX\n"
  56. );
  57. void afxEventCatchAll::getCursor(GuiCursor *&cursor, bool &showCursor, const GuiEvent &lastGuiEvent)
  58. {
  59. GuiTSCtrl* parent = dynamic_cast<GuiTSCtrl*>(getParent());
  60. if (parent) parent->getCursor(cursor, showCursor, lastGuiEvent);
  61. }
  62. void afxEventCatchAll::onMouseUp(const GuiEvent& evt)
  63. {
  64. GuiTSCtrl* parent = dynamic_cast<GuiTSCtrl*>(getParent());
  65. if (parent) parent->onMouseUp(evt);
  66. }
  67. void afxEventCatchAll::onMouseDown(const GuiEvent& evt)
  68. {
  69. GuiTSCtrl* parent = dynamic_cast<GuiTSCtrl*>(getParent());
  70. if (parent) parent->onMouseDown(evt);
  71. }
  72. void afxEventCatchAll::onMouseMove(const GuiEvent& evt)
  73. {
  74. GuiTSCtrl* parent = dynamic_cast<GuiTSCtrl*>(getParent());
  75. if (parent) parent->onMouseMove(evt);
  76. }
  77. void afxEventCatchAll::onMouseDragged(const GuiEvent& evt)
  78. {
  79. GuiTSCtrl* parent = dynamic_cast<GuiTSCtrl*>(getParent());
  80. if (parent) parent->onMouseDragged(evt);
  81. }
  82. void afxEventCatchAll::onMouseEnter(const GuiEvent& evt)
  83. {
  84. GuiTSCtrl* parent = dynamic_cast<GuiTSCtrl*>(getParent());
  85. if (parent) parent->onMouseEnter(evt);
  86. }
  87. void afxEventCatchAll::onMouseLeave(const GuiEvent& evt)
  88. {
  89. GuiTSCtrl* parent = dynamic_cast<GuiTSCtrl*>(getParent());
  90. if (parent) parent->onMouseLeave(evt);
  91. }
  92. bool afxEventCatchAll::onMouseWheelUp(const GuiEvent& evt)
  93. {
  94. GuiTSCtrl* parent = dynamic_cast<GuiTSCtrl*>(getParent());
  95. return (parent) ? parent->onMouseWheelUp(evt) : false;
  96. }
  97. bool afxEventCatchAll::onMouseWheelDown(const GuiEvent& evt)
  98. {
  99. GuiTSCtrl* parent = dynamic_cast<GuiTSCtrl*>(getParent());
  100. return (parent) ? parent->onMouseWheelDown(evt) : false;
  101. }
  102. void afxEventCatchAll::onRightMouseDown(const GuiEvent& evt)
  103. {
  104. GuiTSCtrl* parent = dynamic_cast<GuiTSCtrl*>(getParent());
  105. if (parent) parent->onRightMouseDown(evt);
  106. }
  107. void afxEventCatchAll::onRightMouseUp(const GuiEvent& evt)
  108. {
  109. GuiTSCtrl* parent = dynamic_cast<GuiTSCtrl*>(getParent());
  110. if (parent) parent->onRightMouseUp(evt);
  111. }
  112. void afxEventCatchAll::onRightMouseDragged(const GuiEvent& evt)
  113. {
  114. GuiTSCtrl* parent = dynamic_cast<GuiTSCtrl*>(getParent());
  115. if (parent) parent->onRightMouseDragged(evt);
  116. }
  117. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//