MythTV
0.27pre
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Groups
Pages
libs
libmythfreemheg
TokenGroup.h
Go to the documentation of this file.
1
/* TokenGroup.h
2
3
Copyright (C) David C. J. Matthews 2004 dm at prolingua.co.uk
4
5
This program is free software; you can redistribute it and/or
6
modify it under the terms of the GNU General Public License
7
as published by the Free Software Foundation; either version 2
8
of the License, or (at your option) any later version.
9
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
14
15
You should have received a copy of the GNU General Public License
16
along with this program; if not, write to the Free Software
17
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
Or, point your browser to http://www.gnu.org/copyleft/gpl.html
19
20
*/
21
22
23
#if !defined(TOKENGROUP_H)
24
#define TOKENGROUP_H
25
26
#include "
Presentable.h
"
27
// Dependencies
28
#include "
Ingredients.h
"
29
#include "
Root.h
"
30
#include "
BaseClasses.h
"
31
#include "
BaseActions.h
"
32
#include "
Actions.h
"
33
34
#include <QPoint>
35
#include <QList>
36
37
class
MHEngine
;
38
39
class
MHTokenGroupItem
40
{
41
public
:
42
MHTokenGroupItem
() {}
43
void
Initialise
(
MHParseNode
*
p
,
MHEngine
*engine);
44
void
PrintMe
(
FILE
*fd,
int
nTabs)
const
;
45
MHObjectRef
m_Object
;
46
MHOwnPtrSequence <MHActionSequence>
m_ActionSlots
;
47
};
48
49
class
MHMovement
50
{
51
public
:
52
void
Initialise
(
MHParseNode
*
p
,
MHEngine
*engine);
53
void
PrintMe
(
FILE
*fd,
int
nTabs)
const
;
54
MHSequence <int>
m_Movement
;
55
};
56
57
// TokenGroup. The standard defines a TokenManager class but that is incorporated in
58
// this class.
59
class
MHTokenGroup
:
public
MHPresentable
60
{
61
public
:
62
MHTokenGroup
();
63
virtual
const
char
*
ClassName
() {
return
"TokenGroup"
; }
64
virtual
void
Initialise
(
MHParseNode
*
p
,
MHEngine
*engine);
65
virtual
void
PrintMe
(
FILE
*fd,
int
nTabs)
const
;
66
67
virtual
void
Activation
(
MHEngine
*engine);
68
virtual
void
Deactivation
(
MHEngine
*engine);
69
70
// Actions
71
virtual
void
CallActionSlot
(
int
n
,
MHEngine
*engine);
72
virtual
void
Move
(
int
n
,
MHEngine
*engine);
73
virtual
void
MoveTo
(
int
n
,
MHEngine
*engine) {
TransferToken
(n, engine); }
74
virtual
void
GetTokenPosition
(
MHRoot
*pResult,
MHEngine
*) { pResult->
SetVariableValue
(
m_nTokenPosition
); }
75
76
protected
:
77
void
PrintContents
(
FILE
*fd,
int
nTabs)
const
;
78
void
TransferToken
(
int
newPos,
MHEngine
*engine);
79
80
MHOwnPtrSequence <MHMovement>
m_MovementTable
;
81
MHOwnPtrSequence <MHTokenGroupItem>
m_TokenGrpItems
;
82
MHOwnPtrSequence <MHActionSequence>
m_NoTokenActionSlots
;
83
84
// Internal attributes
85
int
m_nTokenPosition
;
86
};
87
88
// Items in the list group consist of a Visible and a "selected" flag.
89
// For simplicity we don't check that we have a Visible and instead use virtual functions
90
// which only work on visibles.
91
class
MHListItem
{
92
public
:
93
MHListItem
(
MHRoot
*pVis):
m_pVisible
(pVis),
m_fSelected
(
false
) {}
94
MHRoot
*
m_pVisible
;
95
bool
m_fSelected
;
96
};
97
98
class
MHListGroup
:
public
MHTokenGroup
99
{
100
public
:
101
MHListGroup
();
102
~MHListGroup
();
103
virtual
const
char
*
ClassName
() {
return
"ListGroup"
; }
104
virtual
void
Initialise
(
MHParseNode
*
p
,
MHEngine
*engine);
105
virtual
void
PrintMe
(
FILE
*fd,
int
nTabs)
const
;
106
virtual
void
Preparation
(
MHEngine
*engine);
107
virtual
void
Destruction
(
MHEngine
*engine);
108
virtual
void
Activation
(
MHEngine
*engine);
109
virtual
void
Deactivation
(
MHEngine
*engine);
110
111
// Actions
112
virtual
void
AddItem
(
int
nIndex,
MHRoot
*pItem,
MHEngine
*engine);
113
virtual
void
DelItem
(
MHRoot
*pItem,
MHEngine
*engine);
114
virtual
void
GetCellItem
(
int
nCell,
const
MHObjectRef
&itemDest,
MHEngine
*engine);
115
virtual
void
GetListItem
(
int
nCell,
const
MHObjectRef
&itemDest,
MHEngine
*engine);
116
virtual
void
GetItemStatus
(
int
nCell,
const
MHObjectRef
&itemDest,
MHEngine
*engine);
117
virtual
void
SelectItem
(
int
nCell,
MHEngine
*engine);
118
virtual
void
DeselectItem
(
int
nCell,
MHEngine
*engine);
119
virtual
void
ToggleItem
(
int
nCell,
MHEngine
*engine);
120
virtual
void
ScrollItems
(
int
nCell,
MHEngine
*engine);
121
virtual
void
SetFirstItem
(
int
nCell,
MHEngine
*engine);
122
virtual
void
GetFirstItem
(
MHRoot
*pResult,
MHEngine
*) { pResult->
SetVariableValue
(
m_nFirstItem
); }
123
virtual
void
GetListSize
(
MHRoot
*pResult,
MHEngine
*) { pResult->
SetVariableValue
((
int
)(
m_ItemList
.size())); }
124
125
protected
:
126
// MHEG Internal attributes.
127
void
Update
(
MHEngine
*engine);
128
void
Select
(
int
nIndex,
MHEngine
*engine);
129
void
Deselect
(
int
nIndex,
MHEngine
*engine);
130
int
AdjustIndex
(
int
nIndex);
// Added in the MHEG corrigendum
131
132
// Exchanged attributes
133
MHSequence <QPoint>
m_Positions
;
134
bool
m_fWrapAround
,
m_fMultipleSelection
;
135
//Internal attributes
136
QList<MHListItem*>
m_ItemList
;
// Items found by looking up the object refs
137
int
m_nFirstItem
;
// First item displayed - N.B. MHEG indexes from 1.
138
bool
m_fFirstItemDisplayed
,
m_fLastItemDisplayed
;
139
int
m_nLastCount
,
m_nLastFirstItem
;
140
};
141
142
// Call action slot.
143
class
MHCallActionSlot
:
public
MHActionInt
144
{
145
public
:
146
MHCallActionSlot
():
MHActionInt
(
":CallActionSlot"
) {}
147
virtual
void
CallAction
(
MHEngine
*engine,
MHRoot
*pTarget,
int
nArg) { pTarget->
CallActionSlot
(nArg, engine); }
148
};
149
150
// Move - move the token in a token group according to the movement table.
151
class
MHMove
:
public
MHActionInt
152
{
153
public
:
154
MHMove
():
MHActionInt
(
":Move"
) {}
155
virtual
void
CallAction
(
MHEngine
*engine,
MHRoot
*pTarget,
int
nArg) { pTarget->
Move
(nArg, engine); }
156
};
157
158
// MoveTo - move the token to a particular slot.
159
class
MHMoveTo
:
public
MHActionInt
160
{
161
public
:
162
MHMoveTo
():
MHActionInt
(
":MoveTo"
) {}
163
virtual
void
CallAction
(
MHEngine
*engine,
MHRoot
*pTarget,
int
nArg) { pTarget->
MoveTo
(nArg, engine); }
164
};
165
166
class
MHGetTokenPosition
:
public
MHActionObjectRef
{
167
public
:
168
MHGetTokenPosition
():
MHActionObjectRef
(
":GetTokenPosition"
) {}
169
virtual
void
CallAction
(
MHEngine
*engine,
MHRoot
*pTarget,
MHRoot
*pArg) { pTarget->
GetTokenPosition
(pArg, engine); }
170
};
171
172
class
MHAddItem
:
public
MHElemAction
{
173
public
:
174
MHAddItem
():
MHElemAction
(
":AddItem"
) {}
175
virtual
void
Initialise
(
MHParseNode
*
p
,
MHEngine
*engine);
176
virtual
void
PrintArgs
(
FILE
*fd,
int
)
const
;
177
virtual
void
Perform
(
MHEngine
*engine);
178
protected
:
179
MHGenericInteger
m_Index
;
180
MHGenericObjectRef
m_Item
;
181
182
};
183
184
class
MHDelItem
:
public
MHActionGenericObjectRef
{
185
public
:
186
MHDelItem
():
MHActionGenericObjectRef
(
":DelItem"
) {}
187
virtual
void
CallAction
(
MHEngine
*engine,
MHRoot
*pTarget,
MHRoot
*pObj) { pTarget->
DelItem
(pObj, engine); }
188
};
189
190
// Base class for a few actions.
191
class
MHGetListActionData
:
public
MHElemAction
{
192
public
:
193
MHGetListActionData
(
const
char
*
name
):
MHElemAction
(name) {}
194
virtual
void
Initialise
(
MHParseNode
*
p
,
MHEngine
*engine);
195
virtual
void
PrintArgs
(
FILE
*fd,
int
)
const
;
196
protected
:
197
MHGenericInteger
m_Index
;
198
MHObjectRef
m_Result
;
199
};
200
201
class
MHGetCellItem
:
public
MHGetListActionData
{
202
public
:
203
MHGetCellItem
():
MHGetListActionData
(
":GetCellItem"
) {}
204
virtual
void
Perform
(
MHEngine
*engine) {
Target
(engine)->
GetCellItem
(
m_Index
.
GetValue
(engine),
m_Result
, engine); }
205
};
206
207
class
MHGetListItem
:
public
MHGetListActionData
{
208
public
:
209
MHGetListItem
():
MHGetListActionData
(
":GetListItem"
) {}
210
virtual
void
Perform
(
MHEngine
*engine) {
Target
(engine)->
GetListItem
(
m_Index
.
GetValue
(engine),
m_Result
, engine); }
211
};
212
213
class
MHGetItemStatus
:
public
MHGetListActionData
{
214
public
:
215
MHGetItemStatus
():
MHGetListActionData
(
":GetItemStatus"
) {}
216
virtual
void
Perform
(
MHEngine
*engine) {
Target
(engine)->
GetItemStatus
(
m_Index
.
GetValue
(engine),
m_Result
, engine); }
217
};
218
219
class
MHSelectItem
:
public
MHActionInt
{
220
public
:
221
MHSelectItem
():
MHActionInt
(
":SelectItem"
) {}
222
virtual
void
CallAction
(
MHEngine
*engine,
MHRoot
*
/*pTarget*/
,
int
nArg) {
Target
(engine)->
SelectItem
(nArg, engine); }
223
};
224
225
class
MHDeselectItem
:
public
MHActionInt
{
226
public
:
227
MHDeselectItem
():
MHActionInt
(
":DeselectItem"
) {}
228
virtual
void
CallAction
(
MHEngine
*engine,
MHRoot
*
/*pTarget*/
,
int
nArg) {
Target
(engine)->
DeselectItem
(nArg, engine); }
229
};
230
231
class
MHToggleItem
:
public
MHActionInt
{
232
public
:
233
MHToggleItem
():
MHActionInt
(
":ToggleItem"
) {}
234
virtual
void
CallAction
(
MHEngine
*engine,
MHRoot
*
/*pTarget*/
,
int
nArg) {
Target
(engine)->
ToggleItem
(nArg, engine); }
235
};
236
237
class
MHScrollItems
:
public
MHActionInt
{
238
public
:
239
MHScrollItems
():
MHActionInt
(
":ScrollItems"
) {}
240
virtual
void
CallAction
(
MHEngine
*engine,
MHRoot
*
/*pTarget*/
,
int
nArg) {
Target
(engine)->
ScrollItems
(nArg, engine); }
241
};
242
243
class
MHSetFirstItem
:
public
MHActionInt
{
244
public
:
245
MHSetFirstItem
():
MHActionInt
(
":SetFirstItem"
) {}
246
virtual
void
CallAction
(
MHEngine
*engine,
MHRoot
*
/*pTarget*/
,
int
nArg) {
Target
(engine)->
SetFirstItem
(nArg, engine); }
247
};
248
249
class
MHGetFirstItem
:
public
MHActionObjectRef
{
250
public
:
251
MHGetFirstItem
():
MHActionObjectRef
(
":GetFirstItem"
) {}
252
virtual
void
CallAction
(
MHEngine
*engine,
MHRoot
*
/*pTarget*/
,
MHRoot
*pArg) {
Target
(engine)->
GetFirstItem
(pArg, engine); }
253
};
254
255
class
MHGetListSize
:
public
MHActionObjectRef
{
256
public
:
257
MHGetListSize
():
MHActionObjectRef
(
":GetListSize"
) {}
258
virtual
void
CallAction
(
MHEngine
*engine,
MHRoot
*
/*pTarget*/
,
MHRoot
*pArg) {
Target
(engine)->
GetListSize
(pArg, engine); }
259
};
260
261
#endif
Generated on Thu Jun 20 2013 07:00:13 for MythTV by
1.8.1.2