GlsMenu
1.5.4
Main Page
Namespaces
Data Structures
Files
File List
Globals
gls_menu_item.h
Go to the documentation of this file.
1
41
#if !defined( GLS_MENUITEM_H )
42
# define GLS_MENUITEM_H
43
44
# ifdef WIN32
45
# pragma warning( disable : 4786 )
46
# endif
47
48
# include <string>
49
50
# include "
gls_bool_expression.h
"
51
# include "gls_color.h"
52
# include "
gls_menu_action.h
"
53
# include "
gls_menu_data_group.h
"
54
55
//----------------------------------------------------------------------------
56
//----------------------------------------------------------------------------
77
//----------------------------------------------------------------------------
78
//----------------------------------------------------------------------------
79
class
GlsMenuItemState
:
public
GlsMenuDataGroup
80
{
81
public
:
82
//------------------------------------------------------------------------
93
//------------------------------------------------------------------------
94
GlsMenuItemState
(
95
const
std::string& label,
96
GlsMenuDictionary
& dataDict,
97
GlsMenuAction::HandlerCont_t
& actionHandlers );
98
99
//------------------------------------------------------------------------
103
//------------------------------------------------------------------------
104
virtual
~GlsMenuItemState
();
105
106
//------------------------------------------------------------------------
110
//------------------------------------------------------------------------
111
virtual
bool
Active
()
const
{
return
_active
(); }
112
113
//------------------------------------------------------------------------
117
//------------------------------------------------------------------------
118
const
disti::glsColor&
Color
()
const
;
119
120
//------------------------------------------------------------------------
124
//------------------------------------------------------------------------
125
virtual
std::string
Label
()
const
;
126
127
//------------------------------------------------------------------------
131
//------------------------------------------------------------------------
132
virtual
bool
Visible
()
const
{
return
_visible
(); }
133
134
//------------------------------------------------------------------------
141
//------------------------------------------------------------------------
142
virtual
void
Select
();
143
144
//------------------------------------------------------------------------
150
//------------------------------------------------------------------------
151
void
CheckTimers
();
152
153
protected
:
155
GlsMenuActionGroup
*
_actions
;
156
158
GlsBoolExpression
_active
;
159
161
std::string
_colorName
;
162
164
GlsBoolExpression
_visible
;
165
167
GlsMenuDictionary
&
_dataDict
;
168
170
GlsMenuHandlerGroup_T<GlsMenuTimer>
*
_timers
;
171
172
};
// end GlsMenuItemState
173
174
//----------------------------------------------------------------------------
175
//----------------------------------------------------------------------------
185
//----------------------------------------------------------------------------
186
//----------------------------------------------------------------------------
187
template
<
class
State_t>
188
class
GlsMenuItem_T
:
public
GlsMenuHandlerGroup_T
<State_t>
189
{
190
public
:
191
typedef
GlsMenuHandlerGroup_T<State_t>
BaseClass
;
192
193
//------------------------------------------------------------------------
206
//------------------------------------------------------------------------
207
GlsMenuItem_T
(
208
const
std::string& name,
209
GlsMenuDictionary
& dataDict,
210
GlsMenuAction::HandlerCont_t
& actionHandlers )
211
:
212
213
GlsMenuHandlerGroup_T
<State_t>( name, dataDict, actionHandlers, false )
214
,
_currentState
( 0 )
215
{}
216
217
//------------------------------------------------------------------------
221
//------------------------------------------------------------------------
222
virtual
~GlsMenuItem_T
() {}
223
224
//------------------------------------------------------------------------
232
//------------------------------------------------------------------------
233
State_t*
State
()
234
{
235
_currentState
= 0;
236
237
for
( GlsMenuDictionary::iterator stateIt =
BaseClass::_attr
.Begin();
238
stateIt !=
BaseClass::_attr
.End();
239
++stateIt )
240
{
241
State_t* state =
dynamic_cast<
State_t*
>
( *stateIt );
242
243
if
( state )
244
{
245
state->CheckTimers();
246
247
if
( state->Visible() )
248
{
249
_currentState
= state;
250
break
;
251
}
252
}
253
}
254
return
_currentState
;
255
}
256
257
//------------------------------------------------------------------------
262
//------------------------------------------------------------------------
263
void
Select
()
264
{
265
if
(
_currentState
)
266
_currentState
->Select();
267
}
268
269
protected
:
270
State_t*
_currentState
;
271
272
};
// end GlsMenuItem
273
274
#endif // GLS_MENUITEM_H
GlsMenuDictionary
Definition:
gls_menu_dictionary.h:65
GlsMenuItem_T::GlsMenuItem_T
GlsMenuItem_T(const std::string &name, GlsMenuDictionary &dataDict, GlsMenuAction::HandlerCont_t &actionHandlers)
Definition:
gls_menu_item.h:207
GlsMenuItem_T::_currentState
State_t * _currentState
Definition:
gls_menu_item.h:270
GlsMenuItemState::_active
GlsBoolExpression _active
Whether the state is active or not.
Definition:
gls_menu_item.h:158
GlsMenuItemState::Color
const disti::glsColor & Color() const
GlsMenuItem_T::Select
void Select()
Definition:
gls_menu_item.h:263
GlsMenuItemState::Select
virtual void Select()
GlsMenuItemState::Visible
virtual bool Visible() const
Definition:
gls_menu_item.h:132
GlsMenuDataGroup::_attr
GlsMenuDictionary _attr
The dictionary of attributes for the group attribute.
Definition:
gls_menu_data_group.h:100
GlsMenuItemState::Label
virtual std::string Label() const
GlsMenuItemState::GlsMenuItemState
GlsMenuItemState(const std::string &label, GlsMenuDictionary &dataDict, GlsMenuAction::HandlerCont_t &actionHandlers)
GlsMenuItem_T::State
State_t * State()
Definition:
gls_menu_item.h:233
GlsMenuAction::HandlerCont_t
std::map< std::string, ActionHandler_t * > HandlerCont_t
Definition:
gls_menu_action.h:78
GlsMenuItem_T::BaseClass
GlsMenuHandlerGroup_T< State_t > BaseClass
Definition:
gls_menu_item.h:191
GlsBoolExpression
Definition:
gls_bool_expression.h:78
gls_menu_data_group.h
This file defines classes for groups of menu meta-data.
GlsMenuItem_T::~GlsMenuItem_T
virtual ~GlsMenuItem_T()
Definition:
gls_menu_item.h:222
GlsMenuItemState::_visible
GlsBoolExpression _visible
Visibility of the menu item state.
Definition:
gls_menu_item.h:164
GlsMenuDataGroup
Definition:
gls_menu_data_group.h:61
GlsMenuItemState
Definition:
gls_menu_item.h:79
GlsMenuItemState::_actions
GlsMenuActionGroup * _actions
Actions to execute when the menu item state is selected.
Definition:
gls_menu_item.h:155
GlsMenuItemState::_colorName
std::string _colorName
Current color name of the menu item state.
Definition:
gls_menu_item.h:161
GlsMenuItemState::_timers
GlsMenuHandlerGroup_T< GlsMenuTimer > * _timers
Container of timers associated with the state.
Definition:
gls_menu_item.h:170
GlsMenuItemState::~GlsMenuItemState
virtual ~GlsMenuItemState()
GlsMenuItemState::_dataDict
GlsMenuDictionary & _dataDict
Meta-data dictionary used for expanding the values of variables.
Definition:
gls_menu_item.h:167
GlsMenuActionGroup
Definition:
gls_menu_action.h:177
GlsMenuItemState::Active
virtual bool Active() const
Definition:
gls_menu_item.h:111
gls_menu_action.h
This file defines menu action (callback) meta-data classes.
gls_bool_expression.h
This file defines a class that provides a string-based boolean expression parser and evaluator...
GlsMenuItemState::CheckTimers
void CheckTimers()
GlsMenuItem_T
Definition:
gls_menu_item.h:188
GlsMenuHandlerGroup_T< GlsMenuTimer >
gls_menu_item.h
Generated by
1.8.10