GuiPopUp.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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_GUI_POP_UP_H
  19. #define HPL_GUI_POP_UP_H
  20. #include "gui/GuiTypes.h"
  21. namespace hpl {
  22. class cGuiSet;
  23. class cGuiSkin;
  24. class cWidgetWindow;
  25. class iGuiPopUp
  26. {
  27. public:
  28. iGuiPopUp(cGuiSet *apSet, bool abAddCloseButton, const cVector2f& avPopUpSize);
  29. virtual ~iGuiPopUp();
  30. void AddOnDestroyCallback(void *apCallbackObject, tGuiCallbackFunc apCallback);
  31. void SetKillOnEscapeKey(bool abX);
  32. bool GetKillOnEscapeKey();
  33. void SetNextFocusWidget(iWidget *apNewFocused) { mpNewFocused = apNewFocused; mbFocusChanged = apNewFocused != NULL; }
  34. cGuiSet * GetGuiSet() { return mpSet; }
  35. protected:
  36. bool Window_OnClose(iWidget* apWidget, const cGuiMessageData& aData);
  37. kGuiCallbackDeclarationEnd(Window_OnClose);
  38. virtual void OnCloseSpecific() {}
  39. void SelfDestruct();
  40. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  41. // Use this func to safely execute callbacks (makes sure right attention and focus widgets are set after destroying popup)
  42. bool RunCallback(void* apObj, tGuiCallbackFunc apCallback,
  43. iWidget* apWidget, const cGuiMessageData& aData, bool abRunFocusChangeChecks);
  44. void SetUpDefaultFocus(iWidget* apWidget);
  45. cGuiSet *mpSet;
  46. cGuiSkin *mpSkin;
  47. cWidgetWindow* mpWindow;
  48. void* mpDestroyCallbackObject;
  49. tGuiCallbackFunc mpDestroyCallback;
  50. bool mbAttChanged;
  51. iWidget* mpNewAttention;
  52. bool mbFocusChanged;
  53. iWidget* mpNewFocused;
  54. bool mbDefaultUIFocusChanged;
  55. iWidget* mpNewDefaultUIFocus;
  56. };
  57. };
  58. #endif // HPL_GUI_POP_UP_H