Crazy Eddie's GUI System
0.8.7
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
42
namespace
CEGUI
43
{
44
49
class
CEGUIEXPORT
MenuItem
:
public
ItemEntry
50
{
51
public
:
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
135
void
setAutoPopupTimeout
(
float
time)
136
{
137
d_autoPopupTimeout = time;
138
}
139
147
PopupMenu
*
getPopupMenu
(
void
)
const
148
{
149
return
d_popup;
150
}
151
156
const
UVector2
&
getPopupOffset
(
void
)
const
157
{
158
return
d_popupOffset;
159
}
160
165
void
setPopupOffset
(
const
UVector2
& popupOffset)
166
{
167
d_popupOffset = popupOffset;
168
}
169
170
/*************************************************************************
171
Manipulators
172
*************************************************************************/
183
void
setPopupMenu
(
PopupMenu
* popup);
184
185
193
void
openPopupMenu
(
bool
notify =
true
);
194
195
206
void
closePopupMenu
(
bool
notify =
true
);
207
208
216
bool
togglePopupMenu
(
void
);
217
222
void
startPopupClosing
(
void
);
223
228
void
startPopupOpening
(
void
);
229
/*************************************************************************
230
Construction and Destruction
231
*************************************************************************/
236
MenuItem
(
const
String
& type,
const
String
& name);
237
238
243
virtual
~MenuItem
(
void
);
244
245
246
protected
:
247
/*************************************************************************
248
New Event Handlers
249
*************************************************************************/
254
virtual
void
onClicked
(
WindowEventArgs
& e);
255
256
257
/*************************************************************************
258
Overridden event handlers
259
*************************************************************************/
260
virtual
void
onMouseMove
(
MouseEventArgs
& e);
261
virtual
void
onMouseButtonDown
(
MouseEventArgs
& e);
262
virtual
void
onMouseButtonUp
(
MouseEventArgs
& e);
263
virtual
void
onCaptureLost
(
WindowEventArgs
& e);
264
virtual
void
onMouseLeaves
(
MouseEventArgs
& e);
265
virtual
void
onTextChanged
(
WindowEventArgs
& e);
266
virtual
void
updateSelf
(
float
elapsed);
267
268
269
/*************************************************************************
270
Implementation Functions
271
*************************************************************************/
282
void
updateInternalState
(
const
Vector2f
& mouse_pos);
283
284
292
void
closeAllMenuItemPopups
();
293
294
305
void
setPopupMenu_impl
(
PopupMenu
* popup,
bool
add_as_child =
true
);
306
307
/*************************************************************************
308
Implementation Data
309
*************************************************************************/
310
bool
d_pushed
;
311
bool
d_hovering
;
312
bool
d_opened
;
313
bool
d_popupClosing
;
314
bool
d_popupOpening
;
315
float
d_autoPopupTimeout
;
316
float
d_autoPopupTimeElapsed
;
317
318
PopupMenu
*
d_popup
;
319
320
bool
d_popupWasClosed
;
321
322
UVector2
d_popupOffset
;
323
324
private
:
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_
CEGUI::Element
A positioned and sized rectangular node in a tree graph.
Definition:
Element.h:246
CEGUI::ItemEntry
Base class for item type widgets.
Definition:
widgets/ItemEntry.h:77
CEGUI::MenuItem
Base class for menu items.
Definition:
widgets/MenuItem.h:50
CEGUI::MenuItem::EventClicked
static const String EventClicked
Definition:
widgets/MenuItem.h:63
CEGUI::MenuItem::~MenuItem
virtual ~MenuItem(void)
Destructor for MenuItem objects.
CEGUI::MenuItem::d_popupOffset
UVector2 d_popupOffset
current offset for popup placement.
Definition:
widgets/MenuItem.h:322
CEGUI::MenuItem::EventNamespace
static const String EventNamespace
Namespace for global events.
Definition:
widgets/MenuItem.h:52
CEGUI::MenuItem::WidgetTypeName
static const String WidgetTypeName
Window factory name.
Definition:
widgets/MenuItem.h:53
CEGUI::MenuItem::onCaptureLost
virtual void onCaptureLost(WindowEventArgs &e)
Handler called when this window loses capture of mouse inputs.
CEGUI::MenuItem::openPopupMenu
void openPopupMenu(bool notify=true)
Opens the PopupMenu.
CEGUI::MenuItem::setPopupOffset
void setPopupOffset(const UVector2 &popupOffset)
sets the current offset for popup placement.
Definition:
widgets/MenuItem.h:165
CEGUI::MenuItem::d_popupOpening
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
CEGUI::MenuItem::closePopupMenu
void closePopupMenu(bool notify=true)
Closes the PopupMenu.
CEGUI::MenuItem::togglePopupMenu
bool togglePopupMenu(void)
Toggles the PopupMenu.
CEGUI::MenuItem::setPopupMenu
void setPopupMenu(PopupMenu *popup)
Set the popup menu for this item.
CEGUI::MenuItem::onMouseButtonUp
virtual void onMouseButtonUp(MouseEventArgs &e)
Handler called when a mouse button has been released within this window's area.
CEGUI::MenuItem::closeAllMenuItemPopups
void closeAllMenuItemPopups()
Recursive function that closes all popups down the hierarcy starting with this one.
CEGUI::MenuItem::startPopupOpening
void startPopupOpening(void)
starts the opening timer for the popup, which will open it if the timer is enabled.
CEGUI::MenuItem::isPopupClosing
bool isPopupClosing(void) const
Returns true if the menu item popup is closing or not.
Definition:
widgets/MenuItem.h:108
CEGUI::MenuItem::updateSelf
virtual void updateSelf(float elapsed)
Perform actual update processing for this Window.
CEGUI::MenuItem::isHovering
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
CEGUI::MenuItem::setPopupMenu_impl
void setPopupMenu_impl(PopupMenu *popup, bool add_as_child=true)
Set the popup menu for this item.
CEGUI::MenuItem::d_opened
bool d_opened
true when the menu item's popup menu is in its opened state.
Definition:
widgets/MenuItem.h:312
CEGUI::MenuItem::MenuItem
MenuItem(const String &type, const String &name)
Constructor for MenuItem objects.
CEGUI::MenuItem::d_popup
PopupMenu * d_popup
PopupMenu that this item displays when activated.
Definition:
widgets/MenuItem.h:318
CEGUI::MenuItem::d_popupClosing
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
CEGUI::MenuItem::d_pushed
bool d_pushed
true when widget is pushed
Definition:
widgets/MenuItem.h:310
CEGUI::MenuItem::d_autoPopupTimeout
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
CEGUI::MenuItem::d_popupWasClosed
bool d_popupWasClosed
Used internally to determine if a popup was just closed on a Clicked event.
Definition:
widgets/MenuItem.h:320
CEGUI::MenuItem::onClicked
virtual void onClicked(WindowEventArgs &e)
handler invoked internally when the MenuItem is clicked.
CEGUI::MenuItem::getPopupMenu
PopupMenu * getPopupMenu(void) const
Get the PopupMenu that is currently attached to this MenuItem.
Definition:
widgets/MenuItem.h:147
CEGUI::MenuItem::onTextChanged
virtual void onTextChanged(WindowEventArgs &e)
Handler called when the window's text is changed.
CEGUI::MenuItem::hasAutoPopup
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
CEGUI::MenuItem::onMouseButtonDown
virtual void onMouseButtonDown(MouseEventArgs &e)
Handler called when a mouse button has been depressed within this window's area.
CEGUI::MenuItem::onMouseMove
virtual void onMouseMove(MouseEventArgs &e)
Handler called when the mouse cursor has been moved within this window's area.
CEGUI::MenuItem::setAutoPopupTimeout
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
CEGUI::MenuItem::startPopupClosing
void startPopupClosing(void)
starts the closing timer for the popup, which will close it if the timer is enabled.
CEGUI::MenuItem::getAutoPopupTimeout
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
CEGUI::MenuItem::d_autoPopupTimeElapsed
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
CEGUI::MenuItem::updateInternalState
void updateInternalState(const Vector2f &mouse_pos)
Update the internal state of the widget with the mouse at the given position.
CEGUI::MenuItem::onMouseLeaves
virtual void onMouseLeaves(MouseEventArgs &e)
Handler called when the mouse cursor is no longer over this window's surface area....
CEGUI::MenuItem::isPushed
bool isPushed(void) const
Return true if the button widget is in the pushed state.
Definition:
widgets/MenuItem.h:89
CEGUI::MenuItem::d_hovering
bool d_hovering
true when the button is in 'hover' state and requires the hover rendering.
Definition:
widgets/MenuItem.h:311
CEGUI::MenuItem::getPopupOffset
const UVector2 & getPopupOffset(void) const
Returns the current offset for popup placement.
Definition:
widgets/MenuItem.h:156
CEGUI::MenuItem::isOpened
bool isOpened(void) const
Returns true if the popup menu attached to the menu item is open.
Definition:
widgets/MenuItem.h:99
CEGUI::MouseEventArgs
EventArgs based class that is used for objects passed to input event handlers concerning mouse input.
Definition:
InputEvent.h:281
CEGUI::PopupMenu
Base class for popup menus.
Definition:
widgets/PopupMenu.h:52
CEGUI::String
String class used within the GUI system.
Definition:
String.h:64
CEGUI::Vector2< UDim >
CEGUI::WindowEventArgs
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition:
InputEvent.h:252
CEGUI
Main namespace for Crazy Eddie's GUI Library.
Definition:
arch_overview.dox:1
cegui
include
CEGUI
widgets
MenuItem.h
Generated by
1.9.1