guiMenuBar.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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 _GUIMENUBAR_H_
  23. #define _GUIMENUBAR_H_
  24. #ifndef _GUITICKCTRL_H_
  25. #include "gui/shiny/guiTickCtrl.h"
  26. #endif
  27. #ifndef _POPUPMENU_H_
  28. #include "gui/editor/popupMenu.h"
  29. #endif
  30. class GuiMenuBar;
  31. class WindowInputGenerator;
  32. //------------------------------------------------------------------------------
  33. class GuiMenuBar : public GuiTickCtrl // Was: GuiControl
  34. {
  35. typedef GuiTickCtrl Parent; // Was: GuiControl Parent;
  36. public:
  37. struct MenuEntry
  38. {
  39. U32 pos;
  40. RectI bounds;
  41. bool visible;
  42. S32 bitmapIndex;
  43. bool drawBitmapOnly;
  44. bool drawBorder;
  45. StringTableEntry text;
  46. PopupMenu* popupMenu;
  47. };
  48. Vector<MenuEntry> mMenuList;
  49. MenuEntry *mouseDownMenu;
  50. MenuEntry *mouseOverMenu;
  51. MenuItem* mouseDownSubmenu; // Stores the menu item that is a submenu that has been selected
  52. MenuItem* mouseOverSubmenu; // Stores the menu item that is a submenu that has been highlighted
  53. bool menuBarDirty;
  54. U32 mCurAcceleratorIndex;
  55. Point2I maxBitmapSize;
  56. S32 mCheckmarkBitmapIndex; // Index in the bitmap array to use for the check mark image
  57. S32 mPadding;
  58. S32 mHorizontalMargin; // Left and right margin around the text of each menu
  59. S32 mVerticalMargin; // Top and bottom margin around the text of each menu
  60. S32 mBitmapMargin; // Margin between a menu's bitmap and text
  61. U32 mMenubarHeight;
  62. bool mMouseInMenu;
  63. GuiMenuBar();
  64. void onRemove();
  65. bool onWake();
  66. void onSleep();
  67. virtual void addObject(SimObject* object);
  68. MenuEntry *findHitMenu(Point2I mousePoint);
  69. void onPreRender();
  70. void onRender(Point2I offset, const RectI &updateRect);
  71. void checkMenuMouseMove(const GuiEvent &event);
  72. void onMouseMove(const GuiEvent &event);
  73. void onMouseEnter(const GuiEvent &event);
  74. void onMouseLeave(const GuiEvent &event);
  75. void onMouseDown(const GuiEvent &event);
  76. void onMouseDragged(const GuiEvent &event);
  77. void onMouseUp(const GuiEvent &event);
  78. void onAction();
  79. void closeMenu();
  80. void buildWindowAcceleratorMap( WindowInputGenerator &inputGenerator );
  81. void removeWindowAcceleratorMap( WindowInputGenerator &inputGenerator );
  82. void acceleratorKeyPress(U32 index);
  83. // Added to support 'ticks'
  84. void processTick();
  85. void insert(SimObject* pObject, S32 pos);
  86. static void initPersistFields();
  87. U32 getMenuListCount() { return mMenuList.size(); }
  88. PopupMenu* getMenu(U32 index);
  89. PopupMenu* findMenu(String barTitle);
  90. DECLARE_CONOBJECT(GuiMenuBar);
  91. DECLARE_CALLBACK( void, onMouseInMenu, ( bool hasLeftMenu ));
  92. DECLARE_CALLBACK( void, onMenuSelect, ( S32 menuId, const char* menuText ));
  93. DECLARE_CALLBACK( void, onMenuItemSelect, ( S32 menuId, const char* menuText, S32 menuItemId, const char* menuItemText ));
  94. };
  95. #endif