GlsMenu
gls_menu.h
Go to the documentation of this file.
1 
41 #if !defined( GLS_MENU_H )
42 # define GLS_MENU_H
43 
44 # ifdef WIN32
45 # pragma warning( disable : 4786 )
46 # endif
47 
48 # include "gls_menu_data_group.h"
49 # include <string>
50 
51 class GlsMenuActionGroup;
52 
53 //----------------------------------------------------------------------------
57 //----------------------------------------------------------------------------
58 class GlsMenu : public GlsMenuDataGroup
59 {
60 public:
61  //------------------------------------------------------------------------
67  //------------------------------------------------------------------------
68  virtual void Hide();
69 
70  //------------------------------------------------------------------------
76  //------------------------------------------------------------------------
77  virtual void Show();
78 
79 protected:
80  //------------------------------------------------------------------------
90  //------------------------------------------------------------------------
91  GlsMenu(
92  const std::string& name,
93  GlsMenuDictionary& dataDict,
94  GlsMenuAction::HandlerCont_t& actionHandlers );
95 
96  //------------------------------------------------------------------------
100  //------------------------------------------------------------------------
101  virtual ~GlsMenu();
102 
103 private:
106 
109 
110 }; // end GlsMenu
111 
112 //----------------------------------------------------------------------------
124 //----------------------------------------------------------------------------
125 template<class MenuItem_t, class MenuItemId_t>
126 class GlsMenu_T : public GlsMenu
127 {
128 public:
129  typedef MenuItem_t Item_t;
130  typedef MenuItemId_t ItemId_t;
132 
133  //------------------------------------------------------------------------
137  //------------------------------------------------------------------------
139  const std::string& name,
140  GlsMenuDictionary& dataDict,
141  GlsMenuAction::HandlerCont_t& actionHandlers )
142  :
143 
144  GlsMenu( name, dataDict, actionHandlers )
145  , _menuItems( new ItemGroup_t( "Items", dataDict, actionHandlers ) )
146  {
147  _attr.Add( _menuItems );
148  }
149 
150  //------------------------------------------------------------------------
154  //------------------------------------------------------------------------
155  virtual ~GlsMenu_T() {}
156 
157  //------------------------------------------------------------------------
163  //------------------------------------------------------------------------
164  ItemGroup_t* Items() const
165  {
166  return _menuItems;
167  }
168 
169  //------------------------------------------------------------------------
178  //------------------------------------------------------------------------
179  MenuItem_t* Item( const ItemId_t& itemId ) const
180  {
181  std::stringstream itemName;
182  itemName << itemId;
183  MenuItem_t* menuItem = _menuItems->Item( itemName.str() );
184 
185  return menuItem;
186  }
187 
188  //------------------------------------------------------------------------
194  //------------------------------------------------------------------------
195  void SelectItem( const ItemId_t& itemId )
196  {
197  std::stringstream itemName;
198  itemName << itemId;
199  MenuItem_t* menuItem = _menuItems->Item( itemName.str() );
200  if( menuItem )
201  menuItem->Select();
202  }
203 
204 private:
206  ItemGroup_t* _menuItems;
207 
208 }; // end GlsMenu_T
209 
210 #endif // GLS_MENU_H
virtual ~GlsMenu_T()
Definition: gls_menu.h:155
ItemGroup_t * _menuItems
Container of menu items within the menu.
Definition: gls_menu.h:206
virtual void Hide()
GlsMenuDictionary _attr
The dictionary of attributes for the group attribute.
virtual void Add(disti::DistiAttributeBase *attr)
MenuItemId_t ItemId_t
Definition: gls_menu.h:130
virtual ~GlsMenu()
ItemGroup_t * Items() const
Definition: gls_menu.h:164
GlsMenu(const std::string &name, GlsMenuDictionary &dataDict, GlsMenuAction::HandlerCont_t &actionHandlers)
std::map< std::string, ActionHandler_t * > HandlerCont_t
This file defines classes for groups of menu meta-data.
GlsMenuActionGroup * _onHideActions
Group of actions to execute when menu is hidden.
Definition: gls_menu.h:108
GlsMenuHandlerGroup_T< MenuItem_t > ItemGroup_t
Definition: gls_menu.h:131
void SelectItem(const ItemId_t &itemId)
Definition: gls_menu.h:195
MenuItem_t Item_t
Definition: gls_menu.h:129
virtual void Show()
GlsMenu_T(const std::string &name, GlsMenuDictionary &dataDict, GlsMenuAction::HandlerCont_t &actionHandlers)
Definition: gls_menu.h:138
MenuItem_t * Item(const ItemId_t &itemId) const
Definition: gls_menu.h:179
GlsMenuActionGroup * _onShowActions
Group of actions to execute when menu is shown.
Definition: gls_menu.h:105
T * Item(const std::string &name) const