WidgetWindow.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * Copyright © 2011-2020 Frictional Games
  3. *
  4. * This file is part of Amnesia: A Machine For Pigs.
  5. *
  6. * Amnesia: A Machine For Pigs is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. * Amnesia: A Machine For Pigs is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with Amnesia: A Machine For Pigs. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. #ifndef HPL_WIDGET_WINDOW_H
  19. #define HPL_WIDGET_WINDOW_H
  20. #include <list>
  21. #include <vector>
  22. #include "gui/Widget.h"
  23. namespace hpl {
  24. class cGuiSkinFont;
  25. class cWidgetButton;
  26. class cWidgetWindow : public iWidget
  27. {
  28. public:
  29. cWidgetWindow(cGuiSet *apSet, cGuiSkin *apSkin, tWidgetWindowButtonFlag alFlags = 0);
  30. virtual ~cWidgetWindow();
  31. void SetStatic(bool abX);
  32. bool GetStatic(){return mbStatic;}
  33. void SetDrawLabel(bool abX);
  34. void SetCloseButtonDisablesWindow(bool abX){mbCloseButtonDisablesWindow = abX;}
  35. bool GetCloseButtonDisablesWindow(){ return mbCloseButtonDisablesWindow;}
  36. void SetEscapeKeyClosesWindow(bool abX) { mbCloseOnEscapeKey = abX; }
  37. bool GetEscapeKeyClosesWindow() { return mbCloseOnEscapeKey; }
  38. protected:
  39. /////////////////////////
  40. // Window Button Callbacks
  41. bool ButtonPressed(iWidget* apWidget, const cGuiMessageData& aData);
  42. kGuiCallbackDeclarationEnd(ButtonPressed);
  43. /////////////////////////
  44. // Implemented functions
  45. void OnInit();
  46. void OnLoadGraphics();
  47. void OnAttachChild(iWidget *apChild);
  48. void OnChangeSize();
  49. void OnDraw(float afTimeStep, cGuiClipRegion *apClipRegion);
  50. bool OnMouseMove(const cGuiMessageData& aData);
  51. bool OnMouseDown(const cGuiMessageData& aData);
  52. bool OnMouseUp(const cGuiMessageData& aData);
  53. bool OnMouseEnter(const cGuiMessageData& aData);
  54. bool OnMouseLeave(const cGuiMessageData& aData);
  55. bool OnKeyPress(const cGuiMessageData& aData);
  56. bool OnGotFocus(const cGuiMessageData& aData);
  57. bool OnLostFocus(const cGuiMessageData& aData);
  58. void OnChildGotFocus(iWidget* apChild, const cGuiMessageData& aData);
  59. void OnChildLostFocus(iWidget* apChild, const cGuiMessageData& aData);
  60. /////////////////////////
  61. // Data
  62. cGuiSkinFont *mpLabelFont;
  63. cWidgetButton* mvButtons[1];
  64. cGuiGfxElement *mpGfxBackground;
  65. cGuiGfxElement *mpGfxLabel;
  66. cGuiGfxElement *mvGfxBorders[4];
  67. cGuiGfxElement *mvGfxCorners[4];
  68. cGuiGfxElement *mpGfxButtonCross;
  69. cVector3f mvLabelTextOffset;
  70. tWidgetWindowButtonFlag mlFlags;
  71. bool mbStatic;
  72. bool mbCloseButtonDisablesWindow;
  73. bool mbCloseOnEscapeKey;
  74. bool mbDrawLabel;
  75. bool mbFocused;
  76. cVector3f mvRelMousePos;
  77. bool mbMoving;
  78. iWidget* mpPrevAttention;
  79. cWidgetWindow* mpPrevTopMostWindow;
  80. float mfButtonSize;
  81. bool mbDrawBordersOutside;
  82. };
  83. };
  84. #endif // HPL_WIDGET_H