guiFormCtrl.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 _GUIFORMCTRL_H_
  23. #define _GUIFORMCTRL_H_
  24. #ifndef _GUICONTROL_H_
  25. #include "gui/guiControl.h"
  26. #endif
  27. #ifndef _GUICANVAS_H_
  28. #include "gui/guiCanvas.h"
  29. #endif
  30. #include "graphics/dgl.h"
  31. #include "console/console.h"
  32. #include "console/consoleTypes.h"
  33. class GuiMenuBar;
  34. /// Collapsable pane control.
  35. ///
  36. /// This class wraps a single child control and displays a header with caption
  37. /// above it. If you click the header it will collapse or expand. The control
  38. /// resizes itself based on its collapsed/expanded size.
  39. ///
  40. /// In the GUI editor, if you just want the header you can make collapsable
  41. /// false. The caption field lets you set the caption. It expects a bitmap
  42. /// (from the GuiControlProfile) that contains two images - the first is
  43. /// displayed when the control is expanded and the second is displayed when
  44. /// it is collapsed. The header is sized based off of the first image.
  45. class GuiFormCtrl : public GuiControl
  46. {
  47. private:
  48. typedef GuiControl Parent;
  49. Resource<GFont> mFont;
  50. StringTableEntry mCaption;
  51. bool mCanMove;
  52. bool mUseSmallCaption;
  53. StringTableEntry mSmallCaption;
  54. StringTableEntry mContentLibrary;
  55. StringTableEntry mContent;
  56. Point2I mThumbSize;
  57. bool mHasMenu;
  58. GuiMenuBar* mMenuBar;
  59. bool mMouseMovingWin;
  60. Point2I mMouseDownPosition;
  61. RectI mOrigBounds;
  62. RectI mStandardBounds;
  63. RectI mCloseButton;
  64. RectI mMinimizeButton;
  65. RectI mMaximizeButton;
  66. bool mMouseOver;
  67. bool mDepressed;
  68. public:
  69. GuiFormCtrl();
  70. virtual ~GuiFormCtrl();
  71. void setCaption(const char* caption);
  72. void resize(const Point2I &newPosition, const Point2I &newExtent);
  73. void onRender(Point2I offset, const RectI &updateRect);
  74. // DAW: Called when the GUI theme changes and a bitmap arrary may need updating
  75. // void onThemeChange();
  76. U32 getMenuBarID();
  77. bool onAdd();
  78. bool onWake();
  79. void onSleep();
  80. virtual void addObject(SimObject *newObj );
  81. void onTouchDragged(const GuiEvent &event);
  82. void onTouchDown(const GuiEvent &event);
  83. void onTouchUp(const GuiEvent &event);
  84. void onTouchMove(const GuiEvent &event);
  85. void onTouchLeave(const GuiEvent &event);
  86. void onTouchEnter(const GuiEvent &event);
  87. static void initPersistFields();
  88. DECLARE_CONOBJECT(GuiFormCtrl);
  89. };
  90. #endif