PageRenderTime 53ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/libs/libmythfreemheg/Root.h

https://github.com/neuros/neuroslink-mythtv-0.21.0-fixes18722
C Header | 213 lines | 129 code | 31 blank | 53 comment | 0 complexity | c6268a6fbe4a9d3f23748576b0268219 MD5 | raw file
Possible License(s): CC-BY-SA-3.0, GPL-2.0, LGPL-2.0, LGPL-2.1
  1. /* Root.h
  2. Copyright (C) David C. J. Matthews 2004 dm at prolingua.co.uk
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. Or, point your browser to http://www.gnu.org/copyleft/gpl.html
  15. */
  16. #if !defined(ROOTCLASS_H)
  17. #define ROOTCLASS_H
  18. #include "BaseClasses.h"
  19. #include "BaseActions.h"
  20. class MHParseNode;
  21. class MHLink;
  22. class MHIngredient;
  23. class MHEngine;
  24. #include <qpointarray.h>
  25. enum EventType { EventIsAvailable = 1, EventContentAvailable, EventIsDeleted, EventIsRunning, EventIsStopped,
  26. EventUserInput, EventAnchorFired, EventTimerFired, EventAsyncStopped, EventInteractionCompleted,
  27. EventTokenMovedFrom, EventTokenMovedTo, EventStreamEvent, EventStreamPlaying, EventStreamStopped,
  28. EventCounterTrigger, EventHighlightOn, EventHighlightOff, EventCursorEnter, EventCursorLeave,
  29. EventIsSelected, EventIsDeselected, EventTestEvent, EventFirstItemPresented, EventLastItemPresented,
  30. EventHeadItems, EventTailItems, EventItemSelected, EventItemDeselected, EventEntryFieldFull,
  31. EventEngineEvent,
  32. // The next two events are added in UK MHEG.
  33. EventFocusMoved, EventSliderValueChanged };
  34. class MHRoot
  35. {
  36. public:
  37. MHRoot(): m_fAvailable(false), m_fRunning(false) {}
  38. MHRoot(const MHRoot &/*ref*/): m_fAvailable(false), m_fRunning(false) {}
  39. virtual ~MHRoot() {}
  40. // Initialise - set up the item from the parse tree.
  41. virtual void Initialise(MHParseNode *p, MHEngine *engine); // Set this up from the parse tree.
  42. // Print this item.
  43. virtual void PrintMe(FILE *fd, int nTabs) const;
  44. // Test for shared status.
  45. virtual bool IsShared() { return false; }
  46. // MHEG Actions.
  47. // Preparation - sets up the run-time representation. Sets m_fAvailable and generates IsAvailable event.
  48. virtual void Preparation(MHEngine *engine);
  49. // Activation - starts running the object. Sets m_fRunning and generates IsRunning event.
  50. virtual void Activation(MHEngine *engine);
  51. // Deactivation - stops running the object. Clears m_fRunning
  52. virtual void Deactivation(MHEngine *engine);
  53. // Destruction - deletes the run-time representation. Clears m_fAvailable.
  54. virtual void Destruction(MHEngine *engine);
  55. // Prepare the content - This action is added in the corrigendum to the standard.
  56. virtual void ContentPreparation(MHEngine *) {}
  57. // Return an object with a given object number. In the root class this returns this object
  58. // if it matches. Group and Stream classes also search their components.
  59. virtual MHRoot *FindByObjectNo(int n);
  60. // Actions. The default behaviour if a sub-class doesn't override them is to fail.
  61. // Actions on Root class
  62. virtual bool GetAvailabilityStatus() { return m_fAvailable; }
  63. virtual bool GetRunningStatus() { return m_fRunning; }
  64. // Actions on Groups
  65. virtual void SetTimer(int/*nTimerId*/, bool/*fAbsolute*/, int /*nMilliSecs*/, MHEngine *) { InvalidAction("SetTimer"); }
  66. // This isn't an MHEG action as such but is used as part of the implementation of "Clone"
  67. virtual void MakeClone(MHRoot* /*pTarget*/, MHRoot* /*pRef*/, MHEngine *) { InvalidAction("MakeClone"); }
  68. virtual void SetInputRegister(int /*nReg*/, MHEngine *) { InvalidAction("SetInputRegister"); }
  69. // Actions on Ingredients.
  70. virtual void SetData(const MHOctetString &/*included*/, MHEngine *) { InvalidAction("SetData"); }
  71. virtual void SetData(const MHContentRef &/*referenced*/, bool /*fSizeGiven*/, int /*size*/, bool /*fCCGiven*/, int /*cc*/, MHEngine *)
  72. { InvalidAction("SetData"); }
  73. virtual void Preload(MHEngine *) { InvalidAction("Preload"); }
  74. virtual void Unload(MHEngine *) { InvalidAction("Unload"); }
  75. // The UK MHEG profile only requires cloning for Text, Bitmap and Rectangle.
  76. virtual MHIngredient *Clone(MHEngine *) { InvalidAction("Clone"); return NULL; }
  77. // Actions on Presentables. The Run/Stop actions on presentables and the Activate/Deactivate actions
  78. // on Links have identical effects. They could be merged.
  79. virtual void Run(MHEngine *) { InvalidAction("Run"); }
  80. virtual void Stop(MHEngine *) { InvalidAction("Stop"); }
  81. // Actions on variables.
  82. virtual void TestVariable(int /*nOp*/, const MHUnion &/*parm*/, MHEngine *) { InvalidAction("TestVariable"); }
  83. virtual void GetVariableValue(MHUnion &, MHEngine *) { InvalidAction("GetVariableValue"); }
  84. virtual void SetVariableValue(const MHUnion &) { InvalidAction("SetVariableValue"); }
  85. // Actions on Text objects
  86. virtual void GetTextData(MHRoot */*pDestination*/, MHEngine *) { InvalidAction("GetTextData"); }
  87. virtual void SetBackgroundColour(const MHColour &/*colour*/, MHEngine *) { InvalidAction("SetBackgroundColour"); }
  88. virtual void SetTextColour(const MHColour &/*colour*/, MHEngine *) { InvalidAction("SetTextColour"); }
  89. virtual void SetFontAttributes(const MHOctetString &/*fontAttrs*/, MHEngine *) { InvalidAction("SetFontAttributes"); }
  90. // Actions on Links
  91. virtual void Activate(bool /*f*/, MHEngine *) { InvalidAction("Activate/Deactivate"); } // Activate/Deactivate
  92. // Actions on Programs.
  93. virtual void CallProgram(bool /*fIsFork*/, const MHObjectRef &/*success*/,
  94. const MHSequence<MHParameter *> &/*args*/, MHEngine *) { InvalidAction("CallProgram"); }
  95. // Actions on TokenGroups
  96. virtual void CallActionSlot(int, MHEngine *) { InvalidAction("CallActionSlot"); }
  97. virtual void Move(int, MHEngine *) { InvalidAction("Move"); }
  98. virtual void MoveTo(int, MHEngine *) { InvalidAction("MoveTo"); }
  99. virtual void GetTokenPosition(MHRoot */*pResult*/, MHEngine *) { InvalidAction("GetTokenPosition"); }
  100. // Actions on ListGroups
  101. virtual void AddItem(int /*nIndex*/, MHRoot */*pItem*/, MHEngine *) { InvalidAction("GetCellItem"); }
  102. virtual void DelItem(MHRoot */*pItem*/, MHEngine *) { InvalidAction("GetCellItem"); }
  103. virtual void GetCellItem(int /*nCell*/, const MHObjectRef &/*itemDest*/, MHEngine *) { InvalidAction("GetCellItem"); }
  104. virtual void GetListItem(int /*nCell*/, const MHObjectRef &/*itemDest*/, MHEngine *) { InvalidAction("GetCellItem"); }
  105. virtual void GetItemStatus(int /*nCell*/, const MHObjectRef &/*itemDest*/, MHEngine *) { InvalidAction("GetItemStatus"); }
  106. virtual void SelectItem(int /*nCell*/, MHEngine *) { InvalidAction("SelectItem"); }
  107. virtual void DeselectItem(int /*nCell*/, MHEngine *) { InvalidAction("DeselectItem"); }
  108. virtual void ToggleItem(int /*nCell*/, MHEngine *) { InvalidAction("ToggleItem"); }
  109. virtual void ScrollItems(int /*nCell*/, MHEngine *) { InvalidAction("ScrollItems"); }
  110. virtual void SetFirstItem(int /*nCell*/, MHEngine *) { InvalidAction("SetFirstItem"); }
  111. virtual void GetFirstItem(MHRoot */*pResult*/, MHEngine *) { InvalidAction("GetFirstItem"); }
  112. virtual void GetListSize(MHRoot */*pResult*/, MHEngine *) { InvalidAction("GetListSize"); }
  113. // Actions on Visibles.
  114. virtual void SetPosition(int /*nXPosition*/, int /*nYPosition*/, MHEngine *) { InvalidAction("SetPosition"); }
  115. virtual void GetPosition(MHRoot */*pXPosN*/, MHRoot */*pYPosN*/) { InvalidAction("GetPosition"); }
  116. virtual void SetBoxSize(int /*nWidth*/, int /*nHeight*/, MHEngine *) { InvalidAction("SetBoxSize"); }
  117. virtual void GetBoxSize(MHRoot */*pWidthDest*/, MHRoot */*HeightDest*/) { InvalidAction("GetBoxSize"); }
  118. virtual void SetPaletteRef(const MHObjectRef /*newPalette*/, MHEngine *) { InvalidAction("SetPaletteRef"); }
  119. virtual void BringToFront(MHEngine *) { InvalidAction("BringToFront"); }
  120. virtual void SendToBack(MHEngine *) { InvalidAction("SendToBack"); }
  121. virtual void PutBefore(const MHRoot */*pRef*/, MHEngine *) { InvalidAction("PutBefore"); }
  122. virtual void PutBehind(const MHRoot */*pRef*/, MHEngine *) { InvalidAction("PutBehind"); }
  123. virtual void ResetPosition() { InvalidAction("ResetPosition"); } // Used internally by ListGroup
  124. // Actions on LineArt
  125. virtual void SetFillColour(const MHColour &/*colour*/, MHEngine *) { InvalidAction("SetFillColour"); }
  126. virtual void SetLineColour(const MHColour &/*colour*/, MHEngine *) { InvalidAction("SetLineColour"); }
  127. virtual void SetLineWidth(int /*nWidth*/, MHEngine *) { InvalidAction("SetLineWidth"); }
  128. virtual void SetLineStyle(int /*nStyle*/, MHEngine *) { InvalidAction("SetLineStyle"); }
  129. // Actions on Bitmaps
  130. virtual void SetTransparency(int /*nTransPerCent*/, MHEngine *) { InvalidAction("SetTransparency"); }
  131. virtual void ScaleBitmap(int /*xScale*/, int /*yScale*/, MHEngine *) { InvalidAction("ScaleBitmap"); }
  132. virtual void SetBitmapDecodeOffset(int /*newXOffset*/, int /*newYOffset*/, MHEngine *) { InvalidAction("SetBitmapDecodeOffset"); }
  133. virtual void GetBitmapDecodeOffset(MHRoot */*pXOffset*/, MHRoot */*pYOffset*/) { InvalidAction("GetBitmapDecodeOffset"); }
  134. // Actions on Dynamic Line Art
  135. virtual void Clear() { InvalidAction(""); }
  136. virtual void GetLineWidth(MHRoot */*pResult*/) { InvalidAction("GetLineWidth"); }
  137. virtual void GetLineStyle(MHRoot */*pResult*/) { InvalidAction("GetLineStyle"); }
  138. virtual void GetLineColour(MHRoot */*pResult*/) { InvalidAction("GetLineColour"); }
  139. virtual void GetFillColour(MHRoot */*pResult*/) { InvalidAction("GetFillColour"); }
  140. virtual void DrawArcSector(bool /*fIsSector*/, int /*x*/, int /*y*/, int /*width*/, int /*height*/, int /*start*/, int /*arc*/, MHEngine *) { InvalidAction("DrawArc/Sector"); }
  141. virtual void DrawLine(int /*x1*/, int /*y1*/, int /*x2*/, int /*y2*/, MHEngine *) { InvalidAction("DrawLine"); }
  142. virtual void DrawOval(int /*x1*/, int /*y1*/, int /*width*/, int /*height*/, MHEngine *) { InvalidAction("DrawOval"); }
  143. virtual void DrawRectangle(int /*x1*/, int /*y1*/, int /*x2*/, int /*y2*/, MHEngine *) { InvalidAction("DrawRectangle"); }
  144. virtual void DrawPoly(bool /*fIsPolygon*/, const QPointArray &/*points*/, MHEngine *) { InvalidAction("DrawPoly(gon/line)"); }
  145. // Actions on Video streams.
  146. virtual void ScaleVideo(int /*xScale*/, int /*yScale*/, MHEngine *) { InvalidAction("ScaleVideo"); }
  147. virtual void SetVideoDecodeOffset(int /*newXOffset*/, int /*newYOffset*/, MHEngine *) { InvalidAction("SetVideoDecodeOffset"); }
  148. virtual void GetVideoDecodeOffset(MHRoot * /*pXOffset*/, MHRoot */*pYOffset*/, MHEngine *) { InvalidAction("GetVideoDecodeOffset"); }
  149. protected:
  150. void InvalidAction(const char *actionName);
  151. public:
  152. MHObjectRef m_ObjectReference; // Identifier of this object.
  153. virtual const char *ClassName() = 0; // For debugging messages.
  154. protected:
  155. bool m_fAvailable; // Set once Preparation has completed.
  156. bool m_fRunning; // Set once Activation has completed.
  157. friend class MHEngine;
  158. };
  159. // Get Availability Status - Does the object exist and is it available?.
  160. class MHGetAvailabilityStatus: public MHElemAction
  161. {
  162. public:
  163. MHGetAvailabilityStatus(): MHElemAction(":GetAvailabilityStatus") {}
  164. virtual void Initialise(MHParseNode *p, MHEngine *engine);
  165. virtual void Perform(MHEngine *engine);
  166. protected:
  167. virtual void PrintArgs(FILE *fd, int /*nTabs*/) const { m_ResultVar.PrintMe(fd, 0); }
  168. MHObjectRef m_ResultVar;
  169. };
  170. // Get Running Status - Is the object running?.
  171. class MHGetRunningStatus: public MHActionObjectRef
  172. {
  173. public:
  174. MHGetRunningStatus(): MHActionObjectRef(":GetRunningStatus") {}
  175. virtual void CallAction(MHEngine *, MHRoot *pTarget, MHRoot *pResult) { pResult->SetVariableValue(pTarget->GetRunningStatus());}
  176. };
  177. #endif