guiMenuBar.h

Engine/source/gui/editor/guiMenuBar.h

More...

Classes:

Detailed Description

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _GUIMENUBAR_H_
 25#define _GUIMENUBAR_H_
 26
 27#ifndef _GUITICKCTRL_H_
 28#include "gui/shiny/guiTickCtrl.h"
 29#endif
 30
 31#ifndef _POPUPMENU_H_
 32#include "gui/editor/popupMenu.h"
 33#endif
 34
 35class GuiMenuBar;
 36class WindowInputGenerator;
 37
 38//------------------------------------------------------------------------------
 39class GuiMenuBar : public GuiTickCtrl //  Was: GuiControl
 40{
 41   typedef GuiTickCtrl Parent; //  Was: GuiControl Parent;
 42public:
 43
 44   struct MenuEntry
 45   {
 46      U32 pos;
 47      RectI bounds;
 48
 49      bool visible;
 50
 51      S32 bitmapIndex;
 52      bool drawBitmapOnly;
 53
 54      bool drawBorder;
 55
 56      StringTableEntry text;
 57      PopupMenu* popupMenu;
 58   };
 59
 60   Vector<MenuEntry> mMenuList;
 61
 62   MenuEntry *mouseDownMenu;
 63   MenuEntry *mouseOverMenu;
 64
 65   MenuItem* mouseDownSubmenu; //  Stores the menu item that is a submenu that has been selected
 66   MenuItem* mouseOverSubmenu; //  Stores the menu item that is a submenu that has been highlighted
 67
 68   bool menuBarDirty;
 69   U32 mCurAcceleratorIndex;
 70   Point2I maxBitmapSize;
 71
 72   S32 mCheckmarkBitmapIndex; // Index in the bitmap array to use for the check mark image
 73
 74   S32 mPadding;
 75   S32 mHorizontalMargin; // Left and right margin around the text of each menu
 76   S32 mVerticalMargin;   // Top and bottom margin around the text of each menu
 77   S32 mBitmapMargin;     // Margin between a menu's bitmap and text
 78
 79   U32 mMenubarHeight;
 80
 81   bool mMouseInMenu;
 82   
 83   GuiMenuBar();
 84
 85   void onRemove();
 86   bool onWake();
 87   void onSleep();
 88
 89   virtual void addObject(SimObject* object);
 90
 91   MenuEntry *findHitMenu(Point2I mousePoint);
 92
 93   void onPreRender();
 94   void onRender(Point2I offset, const RectI &updateRect);
 95
 96   void checkMenuMouseMove(const GuiEvent &event);
 97   void onMouseMove(const GuiEvent &event);
 98   void onMouseEnter(const GuiEvent &event);
 99   void onMouseLeave(const GuiEvent &event);
100   void onMouseDown(const GuiEvent &event);
101   void onMouseDragged(const GuiEvent &event);
102   void onMouseUp(const GuiEvent &event);
103   
104   void onAction();
105   void closeMenu();
106   void buildWindowAcceleratorMap( WindowInputGenerator &inputGenerator );
107   void removeWindowAcceleratorMap( WindowInputGenerator &inputGenerator );
108   void acceleratorKeyPress(U32 index);
109
110   //  Added to support 'ticks'
111   void processTick();
112
113   void insert(SimObject* pObject, S32 pos);
114
115   static void initPersistFields();
116
117   U32 getMenuListCount() { return mMenuList.size(); }
118
119   PopupMenu* getMenu(U32 index);
120   PopupMenu* findMenu(String barTitle);
121
122   DECLARE_CONOBJECT(GuiMenuBar);
123   DECLARE_CALLBACK( void, onMouseInMenu, ( bool hasLeftMenu ));
124   DECLARE_CALLBACK( void, onMenuSelect, ( S32 menuId, const char* menuText ));
125   DECLARE_CALLBACK( void, onMenuItemSelect, ( S32 menuId, const char* menuText, S32 menuItemId, const char* menuItemText  ));
126};
127
128#endif
129