Crazy Eddie's GUI System  0.8.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
widgets/MenuItem.h
1 /***********************************************************************
2  filename: CEGUIMenuItem.h
3  created: 2/4/2005
4  author: Tomas Lindquist Olsen (based on code by Paul D Turner)
5 
6  purpose: Interface to base class for MenuItem 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 _CEGUIMenuItem_h_
31 #define _CEGUIMenuItem_h_
32 
33 #include "../Base.h"
34 #include "../Window.h"
35 #include "./ItemEntry.h"
36 
37 #if defined(_MSC_VER)
38 # pragma warning(push)
39 # pragma warning(disable : 4251)
40 #endif
41 
42 // Start of CEGUI namespace section
43 namespace CEGUI
44 {
45 
50 class CEGUIEXPORT MenuItem : public ItemEntry
51 {
52 public:
53  static const String EventNamespace;
54  static const String WidgetTypeName;
55 
56  /*************************************************************************
57  Event name constants
58  *************************************************************************/
59  // generated internally by Window
64  static const String EventClicked;
65 
66 
67  /*************************************************************************
68  Accessor type functions
69  *************************************************************************/
77  bool isHovering(void) const
78  {
79  return d_hovering;
80  }
81 
82 
90  bool isPushed(void) const
91  {
92  return d_pushed;
93  }
94 
95 
100  bool isOpened(void) const
101  {
102  return d_opened;
103  }
104 
109  bool isPopupClosing(void) const
110  {
111  return d_popupClosing;
112  }
113 
118  bool hasAutoPopup(void) const
119  {
120  return d_autoPopupTimeout > 0.0f;
121  }
122 
127  float getAutoPopupTimeout(void) const
128  {
129  return d_autoPopupTimeout;
130  }
131 
136  void setAutoPopupTimeout(float time)
137  {
138  d_autoPopupTimeout = time;
139  }
140 
148  PopupMenu* getPopupMenu(void) const
149  {
150  return d_popup;
151  }
152 
157  const UVector2& getPopupOffset(void) const
158  {
159  return d_popupOffset;
160  }
161 
166  void setPopupOffset(const UVector2& popupOffset)
167  {
168  d_popupOffset = popupOffset;
169  }
170 
171  /*************************************************************************
172  Manipulators
173  *************************************************************************/
184  void setPopupMenu(PopupMenu* popup);
185 
186 
194  void openPopupMenu(bool notify = true);
195 
196 
207  void closePopupMenu(bool notify = true);
208 
209 
217  bool togglePopupMenu(void);
218 
223  void startPopupClosing(void);
224 
229  void startPopupOpening(void);
230  /*************************************************************************
231  Construction and Destruction
232  *************************************************************************/
237  MenuItem(const String& type, const String& name);
238 
239 
244  virtual ~MenuItem(void);
245 
246 
247 protected:
248  /*************************************************************************
249  New Event Handlers
250  *************************************************************************/
255  virtual void onClicked(WindowEventArgs& e);
256 
257 
258  /*************************************************************************
259  Overridden event handlers
260  *************************************************************************/
261  virtual void onMouseMove(MouseEventArgs& e);
262  virtual void onMouseButtonDown(MouseEventArgs& e);
263  virtual void onMouseButtonUp(MouseEventArgs& e);
264  virtual void onCaptureLost(WindowEventArgs& e);
265  virtual void onMouseLeaves(MouseEventArgs& e);
266  virtual void onTextChanged(WindowEventArgs& e);
267  virtual void updateSelf(float elapsed);
268 
269 
270  /*************************************************************************
271  Implementation Functions
272  *************************************************************************/
283  void updateInternalState(const Vector2f& mouse_pos);
284 
285 
293  void closeAllMenuItemPopups();
294 
295 
306  void setPopupMenu_impl(PopupMenu* popup, bool add_as_child = true);
307 
308  /*************************************************************************
309  Implementation Data
310  *************************************************************************/
311  bool d_pushed;
312  bool d_hovering;
313  bool d_opened;
318 
320 
322 
324 
325 private:
326 
327  /*************************************************************************
328  Private methods
329  *************************************************************************/
330  void addMenuItemProperties(void);
331 
335  virtual void addChild_impl(Element* element);
336 };
337 
338 } // End of CEGUI namespace section
339 
340 #if defined(_MSC_VER)
341 # pragma warning(pop)
342 #endif
343 
344 #endif // end of guard _CEGUIMenuItem_h_