MythTV  master
Groups.h
Go to the documentation of this file.
1 /* Groups.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
18  Or, point your browser to http://www.gnu.org/copyleft/gpl.html
19 
20 */
21 
22 
23 #if !defined(GROUPCLASS_H)
24 #define GROUPCLASS_H
25 #include <QString>
26 #include <QDateTime>
27 #include <QList>
28 
29 #include "Root.h"
30 #include "Ingredients.h"
31 #include "BaseClasses.h"
32 #include "BaseActions.h"
33 
34 class MHVisible;
35 
36 // Group Class and the two derived classes.
37 
38 //
39 class MHTimer {
40  public:
42  QTime m_Time;
43 };
44 
45 class MHGroup : public MHRoot
46 {
47  public:
48  MHGroup() = default;
49  virtual ~MHGroup();
50  void PrintMe(FILE *fd, int nTabs) const override; // MHRoot
51 
52  void Preparation(MHEngine *engine) override; // MHRoot
53  void Activation(MHEngine *engine) override; // MHRoot
54  void Deactivation(MHEngine *engine) override; // MHRoot
55  void Destruction(MHEngine *engine) override; // MHRoot
56 
57  MHRoot *FindByObjectNo(int n) override; // MHRoot
58 
59  // Actions.
60  void SetTimer(int nTimerId, bool fAbsolute, int nMilliSecs, MHEngine *) override; // MHRoot
61  // This isn't an MHEG action as such but is used as part of the implementation of "Clone"
62  void MakeClone(MHRoot *pTarget, MHRoot *pRef, MHEngine *engine) override; // MHRoot
63 
64  protected:
65  // Set this up from the parse tree.
66  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHRoot
67  // Standard ID, Standard version, Object information aren't recorded.
68  int m_nOrigGCPriority {127};
71  bool m_fIsApp {false};
72  friend class MHEngine;
73 
74  // Timers are an attribute of the scene class in the standard but have been moved
75  // to the group in UK MHEG. We record the time that the group starts running so
76  // we know how to calculate absolute times.
77  QTime m_StartTime;
78  QList<MHTimer*> m_Timers;
79  int CheckTimers(MHEngine *engine); // Checks the timers and fires any relevant events. Returns the millisecs to the
80  // next event or zero if there aren't any.
81  int m_nLastId {0}; // Highest numbered ingredient. Used to make new ids for clones.
82 
83  friend class MHEGEngine;
84 };
85 
86 class MHScene : public MHGroup
87 {
88  public:
89  MHScene() = default;
90  // Set this up from the parse tree.
91  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHGroup
92  const char *ClassName() override // MHRoot
93  { return "Scene"; }
94  void PrintMe(FILE *fd, int nTabs) const override; // MHGroup
95  void Activation(MHEngine *engine) override; // MHGroup
96 
97  // Actions.
98  void SetInputRegister(int nReg, MHEngine *engine) override; // MHRoot
99  protected:
100  int m_nEventReg {0};
101  int m_nSceneCoordX {0};
102  int m_nSceneCoordY {0};
103 
104  // TODO: In UK MHEG 1.06 the aspect ratio is optional and if not specified "the
105  // scene has no aspect ratio".
108  bool m_fMovingCursor {false};
109  // We don't use the Next-Scenes info at the moment.
110 // MHSceneSeq m_NextScenes; // Preload info for next scenes.
111  friend class MHEngine;
112 };
113 
114 
115 class MHApplication : public MHGroup
116 {
117  public:
118  MHApplication() { m_fIsApp = true; }
119  virtual ~MHApplication();
120  const char *ClassName() override // MHRoot
121  { return "Application"; }
122  // Set this up from the parse tree.
123  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHGroup
124  void PrintMe(FILE *fd, int nTabs) const override; // MHGroup
125  bool IsShared() override // MHRoot
126  { return true; } // The application is "shared".
127  void Activation(MHEngine *engine) override; // MHGroup
128  protected:
130  // Default attributes.
131  int m_nCharSet {0};
133  int m_nTextCHook {0};
134  int m_nIPCHook {0};
135  int m_nStrCHook {0};
136  int m_nBitmapCHook {0};
140  int m_tuneinfo {0};
141 
142  // Internal attributes and additional state
143  int m_nLockCount {0}; // Count for locking the screen
144  // Display stack. Visible items with the lowest item in the stack first.
145  // Later items may obscure earlier.
147  int FindOnStack(const MHRoot *pVis); // Returns the index on the stack or -1 if it's not there.
148 
150  bool m_fRestarting {false};
151  QString m_Path; // Path from the root directory to this application. Either the null string or
152  // a string of the form /a/b/c .
153 
154  friend class MHEngine;
155 };
156 
157 class MHLaunch: public MHElemAction
158 {
159  public:
160  MHLaunch(): MHElemAction(":Launch") {}
161  void Perform(MHEngine *engine) override; // MHElemAction
162 };
163 
164 // Quit the application.
165 class MHQuit: public MHElemAction
166 {
167  public:
168  MHQuit(): MHElemAction(":Quit") {}
169  void Perform(MHEngine *engine) override; // MHElemAction
170 };
171 
172 // SendEvent - generate an event
174 {
175  public:
177  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
178  void Perform(MHEngine *engine) override; // MHElemAction
179  void PrintArgs(FILE *fd, int nTabs) const override; // MHElemAction
180  protected:
182  enum EventType m_EventType; // Event type
183  MHParameter m_EventData; // Optional - Null means not specified. Can only be bool, int or string.
184 };
185 
187 {
188  public:
190  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
191  void Perform(MHEngine *engine) override; // MHElemAction
192  protected:
193  void PrintArgs(FILE *fd, int nTabs) const override; // MHElemAction
195  // A new timer may not be specified in which case this cancels the timer.
196  // If the timer is specified the "absolute" flag is optional.
200 };
201 
202 class MHSpawn: public MHElemAction
203 {
204  public:
205  MHSpawn(): MHElemAction(":Spawn") {}
206  void Perform(MHEngine *engine) override; // MHElemAction
207 };
208 
209 // Read and Store persistent - read and save data to persistent store.
211 {
212  public:
213  MHPersistent(const char *name, bool fIsLoad): MHElemAction(name), m_fIsLoad(fIsLoad) {}
214  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
215  void Perform(MHEngine *engine) override; // MHElemAction
216  protected:
217  void PrintArgs(FILE *fd, int nTabs) const override; // MHElemAction
218  bool m_fIsLoad;
222 };
223 
224 
225 // TransitionTo - move to a new scene.
227 {
228  public:
229  MHTransitionTo();
230  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
231  void Perform(MHEngine *engine) override; // MHElemAction
232  protected:
233  void PrintArgs(FILE *fd, int nTabs) const override; // MHElemAction
237 };
238 
239 // Lock and unlock functions.
241 {
242  public:
243  MHLockScreen(): MHElemAction(":LockScreen") {}
244  void Perform(MHEngine *engine) override; // MHElemAction
245 };
246 
248 {
249  public:
250  MHUnlockScreen(): MHElemAction(":UnlockScreen") {}
251  void Perform(MHEngine *engine) override; // MHElemAction
252 };
253 
255 {
256  public:
257  MHGetEngineSupport(): MHElemAction(":GetEngineSupport") {}
258  void Initialise(MHParseNode *p, MHEngine *engine) override; // MHElemAction
259  void Perform(MHEngine *engine) override; // MHElemAction
260  protected:
261  void PrintArgs(FILE *fd, int /*nTabs*/) const override // MHElemAction
262  { m_Feature.PrintMe(fd, 0); m_Answer.PrintMe(fd, 0); }
265 };
266 
267 // Actions added in UK MHEG profile.
269 {
270  public:
271  MHSetInputRegister(): MHActionInt(":SetInputRegister") {}
272  void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg) override // MHActionInt
273  { pTarget->SetInputRegister(nArg, engine); };
274 };
275 
276 
277 #endif
int m_nTransitionEffect
Definition: Groups.h:236
const char * ClassName() override
Definition: Groups.h:120
void Activation(MHEngine *engine) override
Definition: Groups.cpp:789
Definition: Groups.h:39
QTime m_Time
Definition: Groups.h:42
void Deactivation(MHEngine *engine) override
Definition: Groups.cpp:305
QList< MHTimer * > m_Timers
Definition: Groups.h:78
const char * ClassName() override
Definition: Groups.h:92
MHObjectRef m_Answer
Definition: Groups.h:264
void CallAction(MHEngine *engine, MHRoot *pTarget, int nArg) override
Definition: Groups.h:272
void PrintMe(FILE *fd, int nTabs) const
MHParameter m_EventData
Definition: Groups.h:183
MHOwnPtrSequence< MHObjectRef > m_Variables
Definition: Groups.h:220
int m_tuneinfo
Definition: Groups.h:140
void Perform(MHEngine *engine) override
Definition: Groups.cpp:1042
friend class MHEGEngine
Definition: Groups.h:83
void Perform(MHEngine *engine) override
Definition: Groups.cpp:1003
void Perform(MHEngine *engine) override
Definition: Groups.cpp:1030
void PrintMe(FILE *fd, int nTabs) const
MHColour m_BGColour
Definition: Groups.h:132
MHSpawn()
Definition: Groups.h:205
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:723
MHLaunch()
Definition: Groups.h:160
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:963
MHQuit()
Definition: Groups.h:168
void Perform(MHEngine *engine) override
Definition: Groups.cpp:834
int m_nBitmapCHook
Definition: Groups.h:136
MHColour m_TextColour
Definition: Groups.h:132
MHScene * m_pCurrentScene
Definition: Groups.h:149
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:441
MHGenericObjectRef m_EventSource
Definition: Groups.h:181
MHOctetString m_FontAttrs
Definition: Groups.h:139
int CheckTimers(MHEngine *engine)
Definition: Groups.cpp:389
MHOwnPtrSequence< MHIngredient > m_Items
Definition: Groups.h:70
void MakeClone(MHRoot *pTarget, MHRoot *pRef, MHEngine *engine) override
Definition: Groups.cpp:425
void PrintArgs(FILE *fd, int) const override
Definition: Groups.h:261
void Perform(MHEngine *engine) override
Definition: Groups.cpp:946
void PrintMe(FILE *fd, int nTabs) const override
Definition: Groups.cpp:764
int m_nCharSet
Definition: Groups.h:131
MHGroup()=default
MHGenericInteger m_TimerValue
Definition: Groups.h:198
MHPersistent(const char *name, bool fIsLoad)
Definition: Groups.h:213
MHSendEvent()
Definition: Groups.h:176
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:854
void Perform(MHEngine *engine) override
Definition: Groups.cpp:1026
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:48
int FindOnStack(const MHRoot *pVis)
Definition: Groups.cpp:710
int m_nLockCount
Definition: Groups.h:143
MHUnlockScreen()
Definition: Groups.h:250
MHFontBody m_Font
Definition: Groups.h:138
MHRoot * FindByObjectNo(int n) override
Definition: Groups.cpp:330
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:1035
int m_nLastId
Definition: Groups.h:81
void PrintMe(FILE *fd, int nTabs) const override
Definition: Groups.cpp:572
MHSetTimer()
Definition: Groups.h:189
bool IsShared() override
Definition: Groups.h:125
int m_nIPCHook
Definition: Groups.h:134
void PrintArgs(FILE *fd, int nTabs) const override
Definition: Groups.cpp:876
Definition: Groups.h:165
void PrintArgs(FILE *fd, int nTabs) const override
Definition: Groups.cpp:985
MHGenericInteger m_TimerId
Definition: Groups.h:194
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:916
void Perform(MHEngine *engine) override
Definition: Groups.cpp:894
void Preparation(MHEngine *engine) override
Definition: Groups.cpp:258
bool m_fIsApp
Definition: Groups.h:71
bool m_fMovingCursor
Definition: Groups.h:108
int m_nStrCHook
Definition: Groups.h:135
void PrintArgs(FILE *fd, int nTabs) const override
Definition: Groups.cpp:821
MHGenericOctetString m_Feature
Definition: Groups.h:263
virtual ~MHGroup()
Definition: Groups.cpp:40
enum EventType m_EventType
Definition: Groups.h:182
QTime m_StartTime
Definition: Groups.h:77
int m_nTextCHook
Definition: Groups.h:133
const char * name
Definition: ParseText.cpp:328
Definition: Root.h:43
MHObjectRef m_Succeeded
Definition: Groups.h:219
Definition: Groups.h:86
int FILE
Definition: mythburn.py:110
MHActionSequence m_OnRestart
Definition: Groups.h:129
virtual ~MHApplication()
Definition: Groups.cpp:436
int m_nTimerId
Definition: Groups.h:41
void Perform(MHEngine *engine) override
Definition: Groups.cpp:1010
int m_nEventReg
Definition: Groups.h:100
void Perform(MHEngine *engine) override
Definition: Groups.cpp:1020
bool m_fIsLoad
Definition: Groups.h:218
MHActionSequence m_StartUp
Definition: Groups.h:69
MHColour m_ButtonRefColour
Definition: Groups.h:132
MHActionSequence m_OnSpawnCloseDown
Definition: Groups.h:129
void PrintArgs(FILE *fd, int nTabs) const override
Definition: Groups.cpp:932
int m_nSceneCoordX
Definition: Groups.h:101
MHLockScreen()
Definition: Groups.h:243
void Destruction(MHEngine *engine) override
Definition: Groups.cpp:319
bool m_fIsTagged
Definition: Groups.h:234
void SetInputRegister(int nReg, MHEngine *engine) override
Definition: Groups.cpp:801
Definition: Groups.h:45
void Perform(MHEngine *engine) override
Definition: Groups.cpp:1016
MHActionSequence m_CloseDown
Definition: Groups.h:69
MHApplication()
Definition: Groups.h:118
void Activation(MHEngine *engine) override
Definition: Groups.cpp:692
void SetTimer(int nTimerId, bool fAbsolute, int nMilliSecs, MHEngine *) override
Definition: Groups.cpp:351
MHSequence< MHVisible * > m_DisplayStack
Definition: Groups.h:146
MHGenericBoolean m_AbsFlag
Definition: Groups.h:199
MHColour m_HighlightRefColour
Definition: Groups.h:132
MHScene()=default
void PrintMe(FILE *fd, int nTabs) const override
Definition: Groups.cpp:217
EventType
Definition: Root.h:33
int m_nAspectRatioW
Definition: Groups.h:106
int m_nLineArtCHook
Definition: Groups.h:137
bool m_fRestarting
Definition: Groups.h:150
MHGenericOctetString m_FileName
Definition: Groups.h:221
int m_nSceneCoordY
Definition: Groups.h:102
enum MHSetTimer::@9 m_TimerType
void Initialise(MHParseNode *p, MHEngine *engine) override
Definition: Groups.cpp:808
int m_nConnectionTag
Definition: Groups.h:235
QString m_Path
Definition: Groups.h:151
int m_nOrigGCPriority
Definition: Groups.h:68
void Activation(MHEngine *engine) override
Definition: Groups.cpp:275
int m_nAspectRatioH
Definition: Groups.h:107
MHColour m_SliderRefColour
Definition: Groups.h:132