guiWindowCtrl.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _GUIWINDOWCTRL_H_
  23. #define _GUIWINDOWCTRL_H_
  24. #ifndef _GUITEXTCTRL_H_
  25. #include "gui/guiTextCtrl.h"
  26. #endif
  27. /// @addtogroup gui_container_group Containers
  28. ///
  29. /// @ingroup gui_group Gui System
  30. /// @{
  31. class GuiWindowCtrl : public GuiControl
  32. {
  33. private:
  34. typedef GuiControl Parent;
  35. bool mResizeWidth;
  36. bool mResizeHeight;
  37. bool mCanMove;
  38. bool mCanClose;
  39. bool mCanMinimize;
  40. bool mCanMaximize;
  41. bool mPressClose;
  42. bool mPressMinimize;
  43. bool mPressMaximize;
  44. Point2I mMinSize;
  45. StringTableEntry mCloseCommand;
  46. S32 mTitleHeight;
  47. S32 mResizeRightWidth;
  48. S32 mResizeBottomHeight;
  49. bool mMouseMovingWin;
  50. bool mMouseResizeWidth;
  51. bool mMouseResizeHeight;
  52. bool mMinimized;
  53. bool mMaximized;
  54. Point2I mMouseDownPosition;
  55. RectI mOrigBounds;
  56. RectI mStandardBounds;
  57. RectI mCloseButton;
  58. RectI mMinimizeButton;
  59. RectI mMaximizeButton;
  60. S32 mMinimizeIndex;
  61. S32 mTabIndex;
  62. void PositionButtons(void);
  63. protected:
  64. enum BitmapIndices
  65. {
  66. BmpClose,
  67. BmpMaximize,
  68. BmpNormal,
  69. BmpMinimize,
  70. BmpCount
  71. };
  72. enum {
  73. BorderTopLeftKey = 12,
  74. BorderTopRightKey,
  75. BorderTopKey,
  76. BorderTopLeftNoKey,
  77. BorderTopRightNoKey,
  78. BorderTopNoKey,
  79. BorderLeft,
  80. BorderRight,
  81. BorderBottomLeft,
  82. BorderBottom,
  83. BorderBottomRight,
  84. NumBitmaps
  85. };
  86. enum BitmapStates
  87. {
  88. BmpDefault = 0,
  89. BmpHilite,
  90. BmpDisabled,
  91. BmpStates
  92. };
  93. RectI *mBitmapBounds; //bmp is [3*n], bmpHL is [3*n + 1], bmpNA is [3*n + 2]
  94. TextureHandle mTextureHandle;
  95. public:
  96. GuiWindowCtrl();
  97. DECLARE_CONOBJECT(GuiWindowCtrl);
  98. static void initPersistFields();
  99. bool onWake();
  100. void onSleep();
  101. bool isMinimized(S32 &index);
  102. virtual void getCursor(GuiCursor *&cursor, bool &showCursor, const GuiEvent &lastGuiEvent);
  103. void setFont(S32 fntTag);
  104. GuiControl* findHitControl(const Point2I &pt, S32 initialLayer = -1);
  105. void resize(const Point2I &newPosition, const Point2I &newExtent);
  106. void onTouchDown(const GuiEvent &event);
  107. void onTouchDragged(const GuiEvent &event);
  108. void onTouchUp(const GuiEvent &event);
  109. //only cycle tabs through the current window, so overwrite the method
  110. GuiControl* findNextTabable(GuiControl *curResponder, bool firstCall = true);
  111. GuiControl* findPrevTabable(GuiControl *curResponder, bool firstCall = true);
  112. bool onKeyDown(const GuiEvent &event);
  113. S32 getTabIndex(void) { return mTabIndex; }
  114. void selectWindow(void);
  115. void onRender(Point2I offset, const RectI &updateRect);
  116. };
  117. /// @}
  118. #endif //_GUI_WINDOW_CTRL_H