00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #if !defined(ENGINE_H)
00023 #define ENGINE_H
00024
00025 #include "freemheg.h"
00026 #include "Root.h"
00027 #include "Ingredients.h"
00028 #include "BaseClasses.h"
00029 #include "Groups.h"
00030 #include "Visible.h"
00031 #include "Actions.h"
00032 #include "Link.h"
00033 #include <QString>
00034 #include <QRect>
00035 #include <QRegion>
00036 #include <QList>
00037 #include <QStack>
00038 #include <QQueue>
00039 #include <QTime>
00040
00041 class MHDLADisplay;
00042
00043
00044 class MHAsynchEvent {
00045 public:
00046 MHRoot *pEventSource;
00047 enum EventType eventType;
00048 MHUnion eventData;
00049 };
00050
00051
00052
00053
00054 class MHPSEntry {
00055 public:
00056 MHPSEntry() {}
00057 MHOctetString m_FileName;
00058 MHOwnPtrSequence <MHUnion> m_Data;
00059 };
00060
00061
00062 class MHExternContent {
00063 public:
00064 QString m_FileName;
00065 MHIngredient *m_pRequester;
00066 QTime m_time;
00067 };
00068
00069 class MHInteractible;
00070
00071 class MHEngine: public MHEG {
00072 public:
00073 MHEngine(MHContext *context);
00074 virtual ~MHEngine();
00075
00076 virtual void SetBooting() { m_fBooting = true; }
00077
00078 virtual void DrawDisplay(QRegion toDraw);
00079
00080 void BootApplication(const char *fileName);
00081 void TransitionToScene(const MHObjectRef &);
00082 bool Launch(const MHObjectRef &target, bool fIsSpawn=false);
00083 void Spawn(const MHObjectRef &target) { Launch(target, true); }
00084 void Quit();
00085
00086
00087
00088
00089 MHRoot *FindObject(const MHObjectRef &objr, bool failOnNotFound = true);
00090
00091
00092 void EventTriggered(MHRoot *pSource, enum EventType ev)
00093 { EventTriggered(pSource, ev , MHUnion()); }
00094 void EventTriggered(MHRoot *pSource, enum EventType, const MHUnion &evData);
00095
00096
00097 void AddActions(const MHActionSequence &actions);
00098
00099
00100 void AddToDisplayStack(MHVisible *pVis);
00101 void RemoveFromDisplayStack(MHVisible *pVis);
00102 void Redraw(QRegion region);
00103
00104 void BringToFront(const MHRoot *pVis);
00105 void SendToBack(const MHRoot *pVis);
00106 void PutBefore(const MHRoot *pVis, const MHRoot *pRef);
00107 void PutBehind(const MHRoot *pVis, const MHRoot *pRef);
00108 void LockScreen() { CurrentApp()->m_nLockCount++; }
00109 void UnlockScreen();
00110
00111
00112
00113 virtual int RunAll(void);
00114
00115
00116 void RunActions();
00117
00118 virtual void GenerateUserAction(int nCode);
00119 virtual void EngineEvent(int nCode);
00120
00121
00122 void RequestExternalContent(MHIngredient *pRequester);
00123 void CancelExternalContentRequest(MHIngredient *pRequester);
00124
00125
00126 bool LoadStorePersistent(bool fIsLoad, const MHOctetString &fileName, const MHSequence<MHObjectRef *> &variables);
00127
00128
00129 void AddLink(MHLink *pLink);
00130 void RemoveLink(MHLink *pLink);
00131
00132 bool InTransition() { return m_fInTransition; }
00133
00134 bool GetEngineSupport(const MHOctetString &feature);
00135
00136
00137 int GetDefaultCharSet();
00138 void GetDefaultBGColour(MHColour &colour);
00139 void GetDefaultTextColour(MHColour &colour);
00140 void GetDefaultButtonRefColour(MHColour &colour);
00141 void GetDefaultHighlightRefColour(MHColour &colour);
00142 void GetDefaultSliderRefColour(MHColour &colour);
00143 int GetDefaultTextCHook();
00144 int GetDefaultStreamCHook();
00145 int GetDefaultBitmapCHook();
00146
00147 void GetDefaultFontAttrs(MHOctetString &str);
00148 void SetInputRegister(int nReg);
00149
00150 MHOctetString &GetGroupId() { return m_CurrentGroupId; }
00151 MHContext *GetContext() { return m_Context; }
00152
00153 QString GetPathName(const MHOctetString &str);
00154
00155 static const char *MHEGEngineProviderIdString;
00156
00157
00158 MHInteractible *GetInteraction(void) { return m_Interacting; }
00159 void SetInteraction(MHInteractible *p) { m_Interacting = p; }
00160
00161 int GetTuneInfo() { return CurrentApp() ? CurrentApp()->m_tuneinfo : 0; }
00162 void SetTuneInfo(int tuneinfo) { if (CurrentApp()) CurrentApp()->m_tuneinfo = tuneinfo; }
00163
00164 protected:
00165 void CheckLinks(const MHObjectRef &sourceRef, enum EventType ev, const MHUnion &un);
00166 MHGroup *ParseProgram(QByteArray &text);
00167 void DrawRegion(QRegion toDraw, int nStackPos);
00168
00169 QRegion m_redrawRegion;
00170
00171
00172 QStack<MHApplication*> m_ApplicationStack;
00173 MHApplication *CurrentApp() {
00174 if (m_ApplicationStack.isEmpty())
00175 return NULL;
00176 else
00177 return m_ApplicationStack.top();
00178 }
00179 MHScene *CurrentScene() { return CurrentApp() == NULL ? NULL : CurrentApp()->m_pCurrentScene; }
00180
00181
00182
00183
00184 QStack<MHElemAction*> m_ActionStack;
00185
00186
00187
00188 QQueue<MHAsynchEvent*> m_EventQueue;
00189
00190
00191 QList<MHLink*> m_LinkTable;
00192
00193
00194
00195 QList<MHExternContent*> m_ExternContentTable;
00196 void CheckContentRequests();
00197
00198 MHOwnPtrSequence <MHPSEntry> m_PersistentStore;
00199
00200 bool m_fInTransition;
00201
00202
00203
00204 MHOctetString m_CurrentGroupId;
00205
00206 MHContext *m_Context;
00207 bool m_fBooting;
00208
00209 MHInteractible *m_Interacting;
00210 };
00211
00212 #endif