guiFormCtrl.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 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/core/guiControl.h"
  26. #endif
  27. #ifndef _GUI_PANEL_H_
  28. #include "gui/containers/guiPanel.h"
  29. #endif
  30. #ifndef _GUIMENUBAR_H_
  31. #include "gui/editor/guiMenuBar.h"
  32. #endif
  33. #ifndef _GUICANVAS_H_
  34. #include "gui/core/guiCanvas.h"
  35. #endif
  36. #include "console/console.h"
  37. #include "console/consoleTypes.h"
  38. class GuiMenuBar;
  39. /// @addtogroup gui_container_group Containers
  40. ///
  41. /// @ingroup gui_group Gui System
  42. /// @{
  43. class GuiFormCtrl : public GuiPanel
  44. {
  45. private:
  46. typedef GuiPanel Parent;
  47. Resource<GFont> mFont;
  48. String mCaption;
  49. bool mCanMove;
  50. bool mUseSmallCaption;
  51. String mSmallCaption;
  52. StringTableEntry mContentLibrary;
  53. StringTableEntry mContent;
  54. Point2I mThumbSize;
  55. bool mHasMenu;
  56. GuiMenuBar* mMenuBar;
  57. bool mMouseMovingWin;
  58. Point2I mMouseDownPosition;
  59. RectI mOrigBounds;
  60. RectI mStandardBounds;
  61. RectI mCloseButton;
  62. RectI mMinimizeButton;
  63. RectI mMaximizeButton;
  64. bool mMouseOver;
  65. bool mDepressed;
  66. static bool _setHasMenu( void *object, const char *index, const char *data );
  67. protected:
  68. /// @name Callbacks
  69. /// @{
  70. DECLARE_CALLBACK( void, onResize, () );
  71. /// @}
  72. public:
  73. GuiFormCtrl();
  74. virtual ~GuiFormCtrl();
  75. void setCaption( const char* caption ) { mCaption = caption; }
  76. void setHasMenu( bool value );
  77. bool resize(const Point2I &newPosition, const Point2I &newExtent);
  78. void onRender(Point2I offset, const RectI &updateRect);
  79. bool onWake();
  80. void onSleep();
  81. virtual void addObject( SimObject *object );
  82. virtual void removeObject( SimObject* object );
  83. virtual bool acceptsAsChild( SimObject* object ) const;
  84. void onMouseDown(const GuiEvent &event);
  85. void onMouseUp(const GuiEvent &event);
  86. void onMouseMove(const GuiEvent &event);
  87. void onMouseLeave(const GuiEvent &event);
  88. void onMouseEnter(const GuiEvent &event);
  89. U32 getMenuBarID();
  90. static void initPersistFields();
  91. DECLARE_CONOBJECT(GuiFormCtrl);
  92. };
  93. /// @}
  94. #endif