guiPopupMenuCtrl.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. #pragma once
  23. #ifndef GUI_POPUP_MENU_CTRL_H
  24. #define GUI_POPUP_MENU_CTRL_H
  25. #ifndef _GUITEXTLISTCTRL_H_
  26. #include "gui/controls/guiTextListCtrl.h"
  27. #endif
  28. #ifndef _GUIMENUBAR_H_
  29. #include "gui/editor/guiMenuBar.h"
  30. #endif
  31. #ifndef _POPUPMENU_H_
  32. #include "platform/menus/popupMenu.h"
  33. #endif
  34. class GuiPopupMenuBackgroundCtrl;
  35. class GuiPopupMenuTextListCtrl : public GuiTextListCtrl
  36. {
  37. friend class GuiPopupMenuBackgroundCtrl;
  38. friend class PopupMenu;
  39. private:
  40. typedef GuiTextListCtrl Parent;
  41. GuiPopupMenuBackgroundCtrl* mBackground;
  42. public:
  43. bool isSubMenu; // Indicates that this text list is in a submenu
  44. Point2I maxBitmapSize;
  45. GuiMenuBar* mMenuBar;
  46. PopupMenu* mPopup;
  47. S32 mLastHighlightedMenuIdx;
  48. GuiPopupMenuTextListCtrl();
  49. // GuiControl overloads:
  50. bool onKeyDown(const GuiEvent &event);
  51. void onMouseDown(const GuiEvent &event);
  52. void onMouseUp(const GuiEvent &event);
  53. void onRenderCell(Point2I offset, Point2I cell, bool selected, bool mouseOver);
  54. virtual void onCellHighlighted(Point2I cell); // Added
  55. };
  56. class GuiPopupMenuBackgroundCtrl : public GuiControl
  57. {
  58. typedef GuiControl Parent;
  59. public:
  60. GuiPopupMenuBackgroundCtrl();
  61. void onMouseDown(const GuiEvent &event);
  62. void onMouseUp(const GuiEvent &event);
  63. void onMouseMove(const GuiEvent &event);
  64. void onMouseDragged(const GuiEvent &event);
  65. void close();
  66. void clearPopups();
  67. S32 findPopupMenu(PopupMenu* menu);
  68. Vector<PopupMenu*> mPopups;
  69. GuiMenuBar* mMenuBarCtrl;
  70. };
  71. #endif