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