GlsMenu
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_menu_data_group.h
"
51
#include "
gls_menu_action.h
"
52
#include "
gls_bool_expression.h
"
53
#include "gls_color.h"
54
#include "
gls_menu_action.h
"
55
56
57
//----------------------------------------------------------------------------
58
//----------------------------------------------------------------------------
79
//----------------------------------------------------------------------------
80
//----------------------------------------------------------------------------
81
class
GlsMenuItemState
:
public
GlsMenuDataGroup
82
{
83
public
:
84
85
//------------------------------------------------------------------------
96
//------------------------------------------------------------------------
97
GlsMenuItemState
(
98
const
std::string& label,
99
GlsMenuDictionary
& dataDict,
100
GlsMenuAction::HandlerCont_t
& actionHandlers);
101
102
//------------------------------------------------------------------------
106
//------------------------------------------------------------------------
107
virtual
~GlsMenuItemState
();
108
109
//------------------------------------------------------------------------
113
//------------------------------------------------------------------------
114
virtual
bool
Active
()
const
{
return
_active
(); }
115
116
//------------------------------------------------------------------------
120
//------------------------------------------------------------------------
121
const
disti::glsColor&
Color
()
const
;
122
123
//------------------------------------------------------------------------
127
//------------------------------------------------------------------------
128
virtual
std::string
Label
()
const
;
129
130
//------------------------------------------------------------------------
134
//------------------------------------------------------------------------
135
virtual
bool
Visible
()
const
{
return
_visible
(); }
136
137
//------------------------------------------------------------------------
144
//------------------------------------------------------------------------
145
virtual
void
Select
();
146
147
//------------------------------------------------------------------------
153
//------------------------------------------------------------------------
154
void
CheckTimers
();
155
156
protected
:
158
GlsMenuActionGroup
*
_actions
;
159
161
GlsBoolExpression
_active
;
162
164
std::string
_colorName
;
165
167
GlsBoolExpression
_visible
;
168
170
GlsMenuDictionary
&
_dataDict
;
171
173
GlsMenuHandlerGroup_T<GlsMenuTimer>
*
_timers
;
174
175
176
};
// end GlsMenuItemState
177
178
179
//----------------------------------------------------------------------------
180
//----------------------------------------------------------------------------
190
//----------------------------------------------------------------------------
191
//----------------------------------------------------------------------------
192
template
<
class
State_t>
193
class
GlsMenuItem_T
:
public
GlsMenuHandlerGroup_T
<State_t>
194
{
195
public
:
196
typedef
GlsMenuHandlerGroup_T<State_t>
BaseClass
;
197
198
//------------------------------------------------------------------------
211
//------------------------------------------------------------------------
212
GlsMenuItem_T
(
213
const
std::string& name,
214
GlsMenuDictionary
& dataDict,
215
GlsMenuAction::HandlerCont_t
& actionHandlers) :
216
217
GlsMenuHandlerGroup_T
<State_t>(name, dataDict, actionHandlers, false),
218
_currentState
(0)
219
{}
220
221
//------------------------------------------------------------------------
225
//------------------------------------------------------------------------
226
virtual
~GlsMenuItem_T
() {}
227
228
//------------------------------------------------------------------------
236
//------------------------------------------------------------------------
237
State_t*
State
()
238
{
239
_currentState
= 0;
240
241
for
(GlsMenuDictionary::iterator stateIt =
BaseClass::_attr
.Begin();
242
stateIt !=
BaseClass::_attr
.End();
243
++stateIt)
244
{
245
State_t* state =
dynamic_cast<
State_t*
>
(*stateIt);
246
247
if
(state)
248
{
249
state->CheckTimers();
250
251
if
(state->Visible())
252
{
253
_currentState
= state;
254
break
;
255
}
256
}
257
}
258
return
_currentState
;
259
}
260
261
//------------------------------------------------------------------------
266
//------------------------------------------------------------------------
267
void
Select
()
268
{
269
if
(
_currentState
)
270
_currentState
->Select();
271
}
272
273
274
protected
:
275
State_t*
_currentState
;
276
277
};
// end GlsMenuItem
278
279
280
281
#endif // GLS_MENUITEM_H
282
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:212
GlsMenuItem_T::_currentState
State_t * _currentState
Definition:
gls_menu_item.h:275
GlsMenuItemState::_active
GlsBoolExpression _active
Whether the state is active or not.
Definition:
gls_menu_item.h:161
GlsMenuItemState::Color
const disti::glsColor & Color() const
GlsMenuItem_T::Select
void Select()
Definition:
gls_menu_item.h:267
GlsMenuItemState::Select
virtual void Select()
GlsMenuItemState::Visible
virtual bool Visible() const
Definition:
gls_menu_item.h:135
GlsMenuDataGroup::_attr
GlsMenuDictionary _attr
The dictionary of attributes for the group attribute.
Definition:
gls_menu_data_group.h:103
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:237
GlsMenuAction::HandlerCont_t
std::map< std::string, ActionHandler_t * > HandlerCont_t
Definition:
gls_menu_action.h:79
GlsMenuItem_T::BaseClass
GlsMenuHandlerGroup_T< State_t > BaseClass
Definition:
gls_menu_item.h:196
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:226
GlsMenuItemState::_visible
GlsBoolExpression _visible
Visibility of the menu item state.
Definition:
gls_menu_item.h:167
GlsMenuDataGroup
Definition:
gls_menu_data_group.h:62
GlsMenuItemState
Definition:
gls_menu_item.h:81
GlsMenuItemState::_actions
GlsMenuActionGroup * _actions
Actions to execute when the menu item state is selected.
Definition:
gls_menu_item.h:158
GlsMenuItemState::_colorName
std::string _colorName
Current color name of the menu item state.
Definition:
gls_menu_item.h:164
GlsMenuItemState::_timers
GlsMenuHandlerGroup_T< GlsMenuTimer > * _timers
Container of timers associated with the state.
Definition:
gls_menu_item.h:173
GlsMenuItemState::~GlsMenuItemState
virtual ~GlsMenuItemState()
GlsMenuItemState::_dataDict
GlsMenuDictionary & _dataDict
Meta-data dictionary used for expanding the values of variables.
Definition:
gls_menu_item.h:170
GlsMenuActionGroup
Definition:
gls_menu_action.h:183
GlsMenuItemState::Active
virtual bool Active() const
Definition:
gls_menu_item.h:114
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:193
GlsMenuHandlerGroup_T< GlsMenuTimer >
gls_menu_item.h
Generated by
1.8.10