Crazy Eddie's GUI System 0.8.7
Loading...
Searching...
No Matches
widgets/MenuItem.h
1/***********************************************************************
2 created: 2/4/2005
3 author: Tomas Lindquist Olsen (based on code by Paul D Turner)
4
5 purpose: Interface to base class for MenuItem widget
6*************************************************************************/
7/***************************************************************************
8 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining
11 * a copy of this software and associated documentation files (the
12 * "Software"), to deal in the Software without restriction, including
13 * without limitation the rights to use, copy, modify, merge, publish,
14 * distribute, sublicense, and/or sell copies of the Software, and to
15 * permit persons to whom the Software is furnished to do so, subject to
16 * the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be
19 * included in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * OTHER DEALINGS IN THE SOFTWARE.
28 ***************************************************************************/
29#ifndef _CEGUIMenuItem_h_
30#define _CEGUIMenuItem_h_
31
32#include "../Base.h"
33#include "../Window.h"
34#include "./ItemEntry.h"
35
36#if defined(_MSC_VER)
37# pragma warning(push)
38# pragma warning(disable : 4251)
39#endif
40
41// Start of CEGUI namespace section
42namespace CEGUI
43{
44
49class CEGUIEXPORT MenuItem : public ItemEntry
50{
51public:
52 static const String EventNamespace;
53 static const String WidgetTypeName;
54
55 /*************************************************************************
56 Event name constants
57 *************************************************************************/
58 // generated internally by Window
63 static const String EventClicked;
64
65
66 /*************************************************************************
67 Accessor type functions
68 *************************************************************************/
76 bool isHovering(void) const
77 {
78 return d_hovering;
79 }
80
81
89 bool isPushed(void) const
90 {
91 return d_pushed;
92 }
93
94
99 bool isOpened(void) const
100 {
101 return d_opened;
102 }
103
108 bool isPopupClosing(void) const
109 {
110 return d_popupClosing;
111 }
112
117 bool hasAutoPopup(void) const
118 {
119 return d_autoPopupTimeout > 0.0f;
120 }
121
126 float getAutoPopupTimeout(void) const
127 {
128 return d_autoPopupTimeout;
129 }
130
136 {
137 d_autoPopupTimeout = time;
138 }
139
148 {
149 return d_popup;
150 }
151
156 const UVector2& getPopupOffset(void) const
157 {
158 return d_popupOffset;
159 }
160
166 {
167 d_popupOffset = popupOffset;
168 }
169
170 /*************************************************************************
171 Manipulators
172 *************************************************************************/
184
185
193 void openPopupMenu(bool notify = true);
194
195
206 void closePopupMenu(bool notify = true);
207
208
216 bool togglePopupMenu(void);
217
223
229 /*************************************************************************
230 Construction and Destruction
231 *************************************************************************/
236 MenuItem(const String& type, const String& name);
237
238
243 virtual ~MenuItem(void);
244
245
246protected:
247 /*************************************************************************
248 New Event Handlers
249 *************************************************************************/
255
256
257 /*************************************************************************
258 Overridden event handlers
259 *************************************************************************/
266 virtual void updateSelf(float elapsed);
267
268
269 /*************************************************************************
270 Implementation Functions
271 *************************************************************************/
283
284
293
294
306
307 /*************************************************************************
308 Implementation Data
309 *************************************************************************/
310 bool d_pushed;
312 bool d_opened;
317
319
321
323
324private:
325
326 /*************************************************************************
327 Private methods
328 *************************************************************************/
329 void addMenuItemProperties(void);
330
334 virtual void addChild_impl(Element* element);
335};
336
337} // End of CEGUI namespace section
338
339#if defined(_MSC_VER)
340# pragma warning(pop)
341#endif
342
343#endif // end of guard _CEGUIMenuItem_h_
A positioned and sized rectangular node in a tree graph.
Definition Element.h:246
Base class for item type widgets.
Definition widgets/ItemEntry.h:77
Base class for menu items.
Definition widgets/MenuItem.h:50
static const String EventClicked
Definition widgets/MenuItem.h:63
virtual ~MenuItem(void)
Destructor for MenuItem objects.
UVector2 d_popupOffset
current offset for popup placement.
Definition widgets/MenuItem.h:322
static const String EventNamespace
Namespace for global events.
Definition widgets/MenuItem.h:52
static const String WidgetTypeName
Window factory name.
Definition widgets/MenuItem.h:53
virtual void onCaptureLost(WindowEventArgs &e)
Handler called when this window loses capture of mouse inputs.
void openPopupMenu(bool notify=true)
Opens the PopupMenu.
void setPopupOffset(const UVector2 &popupOffset)
sets the current offset for popup placement.
Definition widgets/MenuItem.h:165
bool d_popupOpening
true when the d_popupTimerTimeElapsed timer is running to open the popup (the menu item is hovered)
Definition widgets/MenuItem.h:314
void closePopupMenu(bool notify=true)
Closes the PopupMenu.
bool togglePopupMenu(void)
Toggles the PopupMenu.
void setPopupMenu(PopupMenu *popup)
Set the popup menu for this item.
virtual void onMouseButtonUp(MouseEventArgs &e)
Handler called when a mouse button has been released within this window's area.
void closeAllMenuItemPopups()
Recursive function that closes all popups down the hierarcy starting with this one.
void startPopupOpening(void)
starts the opening timer for the popup, which will open it if the timer is enabled.
bool isPopupClosing(void) const
Returns true if the menu item popup is closing or not.
Definition widgets/MenuItem.h:108
virtual void updateSelf(float elapsed)
Perform actual update processing for this Window.
bool isHovering(void) const
return true if user is hovering over this widget (or it's pushed and user is not over it for highligh...
Definition widgets/MenuItem.h:76
void setPopupMenu_impl(PopupMenu *popup, bool add_as_child=true)
Set the popup menu for this item.
bool d_opened
true when the menu item's popup menu is in its opened state.
Definition widgets/MenuItem.h:312
MenuItem(const String &type, const String &name)
Constructor for MenuItem objects.
PopupMenu * d_popup
PopupMenu that this item displays when activated.
Definition widgets/MenuItem.h:318
bool d_popupClosing
true when the d_popupTimerTimeElapsed timer is running to close the popup (another menu item of our c...
Definition widgets/MenuItem.h:313
bool d_pushed
true when widget is pushed
Definition widgets/MenuItem.h:310
float d_autoPopupTimeout
the time in seconds, to wait before opening / closing the popup if the mouse is over the item / over ...
Definition widgets/MenuItem.h:315
bool d_popupWasClosed
Used internally to determine if a popup was just closed on a Clicked event.
Definition widgets/MenuItem.h:320
virtual void onClicked(WindowEventArgs &e)
handler invoked internally when the MenuItem is clicked.
virtual void onTextChanged(WindowEventArgs &e)
Handler called when the window's text is changed.
bool hasAutoPopup(void) const
Returns true if the menu item popup is closed or opened automatically if hovering with the mouse.
Definition widgets/MenuItem.h:117
virtual void onMouseButtonDown(MouseEventArgs &e)
Handler called when a mouse button has been depressed within this window's area.
virtual void onMouseMove(MouseEventArgs &e)
Handler called when the mouse cursor has been moved within this window's area.
void setAutoPopupTimeout(float time)
Sets the time, which has to elapse before the popup window is opened/closed if the hovering state cha...
Definition widgets/MenuItem.h:135
void startPopupClosing(void)
starts the closing timer for the popup, which will close it if the timer is enabled.
float getAutoPopupTimeout(void) const
Returns the time, which has to elapse before the popup window is opened/closed if the hovering state ...
Definition widgets/MenuItem.h:126
float d_autoPopupTimeElapsed
the current time, which is already elapsed if the timer is running (d_popupClosing or d_popupOpening ...
Definition widgets/MenuItem.h:316
void updateInternalState(const Vector2f &mouse_pos)
Update the internal state of the widget with the mouse at the given position.
virtual void onMouseLeaves(MouseEventArgs &e)
Handler called when the mouse cursor is no longer over this window's surface area....
bool isPushed(void) const
Return true if the button widget is in the pushed state.
Definition widgets/MenuItem.h:89
bool d_hovering
true when the button is in 'hover' state and requires the hover rendering.
Definition widgets/MenuItem.h:311
PopupMenu * getPopupMenu(void) const
Get the PopupMenu that is currently attached to this MenuItem.
Definition widgets/MenuItem.h:147
const UVector2 & getPopupOffset(void) const
Returns the current offset for popup placement.
Definition widgets/MenuItem.h:156
bool isOpened(void) const
Returns true if the popup menu attached to the menu item is open.
Definition widgets/MenuItem.h:99
EventArgs based class that is used for objects passed to input event handlers concerning mouse input.
Definition InputEvent.h:281
Base class for popup menus.
Definition widgets/PopupMenu.h:52
String class used within the GUI system.
Definition String.h:64
base class for properties able to do native set/get
Definition TypedProperty.h:50
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition InputEvent.h:252
Main namespace for Crazy Eddie's GUI Library.
Definition arch_overview.dox:1