Crazy Eddies GUI System  0.7.9
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
CEGUIMenuBase.h
1 /***********************************************************************
2  filename: CEGUIMenuBase.h
3  created: 5/4/2005
4  author: Tomas Lindquist Olsen (based on code by Paul D Turner)
5 
6  purpose: Interface to base class for MenuBase widget
7 *************************************************************************/
8 /***************************************************************************
9  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  * OTHER DEALINGS IN THE SOFTWARE.
29  ***************************************************************************/
30 #ifndef _CEGUIMenuBase_h_
31 #define _CEGUIMenuBase_h_
32 
33 #include "../CEGUIBase.h"
34 #include "../CEGUIWindow.h"
35 #include "CEGUIMenuBaseProperties.h"
36 #include "CEGUIItemListBase.h"
37 
38 
39 #if defined(_MSC_VER)
40 # pragma warning(push)
41 # pragma warning(disable : 4251)
42 #endif
43 
44 
45 // Start of CEGUI namespace section
46 namespace CEGUI
47 {
48 
53 class CEGUIEXPORT MenuBase : public ItemListBase
54 {
55 public:
56  static const String EventNamespace;
57 
58 
59  /*************************************************************************
60  Event name constants
61  *************************************************************************/
62  // generated internally by Window
67  static const String EventPopupOpened;
72  static const String EventPopupClosed;
73 
74 
75  /*************************************************************************
76  Accessor type functions
77  *************************************************************************/
85  float getItemSpacing(void) const
86  {
87  return d_itemSpacing;
88  }
89 
90 
98  bool isMultiplePopupsAllowed(void) const
99  {
100  return d_allowMultiplePopups;
101  }
102 
110  bool getAutoCloseNestedPopups(void) const
111  {
112  return d_autoCloseNestedPopups;
113  }
114 
122  MenuItem* getPopupMenuItem(void) const
123  {
124  return d_popupItem;
125  }
126 
127 
128  /*************************************************************************
129  Manipulators
130  *************************************************************************/
135  void setItemSpacing(float spacing)
136  {
137  d_itemSpacing = spacing;
138  handleUpdatedItemData();
139  }
140 
141 
149  void changePopupMenuItem(MenuItem* item);
150 
151 
156  void setAllowMultiplePopups(bool setting);
157 
162  void setAutoCloseNestedPopups(bool setting)
163  {
164  d_autoCloseNestedPopups = setting;
165  }
170  void setPopupMenuItemClosing();
171 
172 
173  /*************************************************************************
174  Construction and Destruction
175  *************************************************************************/
180  MenuBase(const String& type, const String& name);
181 
182 
187  virtual ~MenuBase(void);
188 
189 
190 protected:
191  /*************************************************************************
192  New Event Handlers
193  *************************************************************************/
198  virtual void onPopupOpened(WindowEventArgs& e);
199 
200 
205  virtual void onPopupClosed(WindowEventArgs& e);
206 
207  // overridden from base
208  virtual void onChildRemoved(WindowEventArgs& e);
209  virtual void onHidden(WindowEventArgs& e);
210  /*************************************************************************
211  Implementation Functions
212  *************************************************************************/
223  virtual bool testClassName_impl(const String& class_name) const
224  {
225  if (class_name == "MenuBase") return true;
226 
227  return ItemListBase::testClassName_impl(class_name);
228  }
229 
230 
231  /*************************************************************************
232  Implementation Data
233  *************************************************************************/
235 
239 
240 
241 private:
242  /*************************************************************************
243  Static Properties for this class
244  *************************************************************************/
245  static MenuBaseProperties::ItemSpacing d_itemSpacingProperty;
246  static MenuBaseProperties::AllowMultiplePopups d_allowMultiplePopupsProperty;
247  static MenuBaseProperties::AutoCloseNestedPopups d_autoCloseNestedPopupsProperty;
248 
249  /*************************************************************************
250  Private methods
251  *************************************************************************/
252  void addMenuBaseProperties(void);
253 };
254 
255 } // End of CEGUI namespace section
256 
257 
258 #if defined(_MSC_VER)
259 # pragma warning(pop)
260 #endif
261 
262 #endif // end of guard _CEGUIMenuBase_h_