// Return the value, looking up any indirect ref. public int GetValue(MHEngine engine) { if (m_fIsDirect) { return(m_nDirect); } else { MHUnion result = new MHUnion(); MHRoot pBase = engine.FindObject(m_Indirect); pBase.GetVariableValue(result, engine); // From my reading of the MHEG documents implicit conversion is only // performed when assigning variables. Nevertheless the Channel 4 // Teletext assumes that implicit conversion takes place here as well. if (result.Type == MHUnion.U_String) { // Implicit conversion of string to integer. return(Convert.ToInt32(result.String.ToString())); } else { result.CheckType(MHUnion.U_Int); return(result.Int); } } }
public MHRoot FindObject(MHObjectRef oRef, bool failOnNotFound) { // It should match either the application or the scene. MHGroup pSearch = null; MHGroup pScene = CurrentScene(); MHGroup pApp = CurrentApp(); if (pScene != null && GetPathName(pScene.ObjectIdentifier.GroupId) == GetPathName(oRef.GroupId)) { pSearch = pScene; } else if (pApp != null && GetPathName(pApp.ObjectIdentifier.GroupId) == GetPathName(oRef.GroupId)) { pSearch = pApp; } if (pSearch != null) { MHRoot pItem = pSearch.FindByObjectNo(oRef.ObjectNo); if (pItem != null) { return(pItem); } } if (failOnNotFound) { // I've seen at least one case where MHEG code has quite deliberately referred to // an object that may or may not exist at a particular time. // Another case was a call to CallActionSlot with an object reference variable // that had been initialised to zero. Logging.Log(Logging.MHLogWarning, "Reference " + oRef.ObjectNo + " not found"); throw new MHEGException("FindObject failed"); } return(null); // If we don't generate an error. }
// Return the value, looking up any indirect ref. public void GetValue(MHOctetString str, MHEngine engine) { if (m_fIsDirect) { str.Copy(m_Direct); } else { MHUnion result = new MHUnion(); MHRoot pBase = engine.FindObject(m_Indirect); pBase.GetVariableValue(result, engine); // From my reading of the MHEG documents implicit conversion is only // performed when assigning variables. Nevertheless the Channel 4 // Teletext assumes that implicit conversion takes place here as well. if (result.Type == MHUnion.U_Int) { // Implicit conversion of string to integer. MHOctetString s = new MHOctetString("" + result.Int); str.Copy(s); } else { result.CheckType(MHUnion.U_String); str.Copy(result.String); } } }
public void PutBefore(MHRoot p, MHRoot pRef) { int nPos = CurrentApp().FindOnStack(p); if (nPos == -1) { return; // If it's not there do nothing } MHVisible pVis = (MHVisible)p; // Can now safely cast it. int nRef = CurrentApp().FindOnStack(pRef); if (nRef == -1) { return; // If the reference visible isn't there do nothing. } CurrentApp().DisplayStack.RemoveAt(nPos); if (nRef >= nPos) { nRef--; // The position of the reference may have shifted } CurrentApp().DisplayStack.InsertAt(pVis, nRef + 1); // Redraw the area occupied by the moved item. We might be able to reduce // the area to be redrawn by looking at the way it is affected by other items // in the stack. We could also see whether it's currently active. Redraw(pVis.GetVisibleArea()); // Request a redraw }
public void EventTriggered(MHRoot pSource, int ev, MHUnion evData) { Logging.Log(Logging.MHLogLinks, "Event - " + MHLink.EventTypeToString(ev) + " from " + pSource.ObjectIdentifier.Printable()); switch (ev) { case MHRoot.EventFirstItemPresented: case MHRoot.EventHeadItems: case MHRoot.EventHighlightOff: case MHRoot.EventHighlightOn: case MHRoot.EventIsAvailable: case MHRoot.EventIsDeleted: case MHRoot.EventIsDeselected: case MHRoot.EventIsRunning: case MHRoot.EventIsSelected: case MHRoot.EventIsStopped: case MHRoot.EventItemDeselected: case MHRoot.EventItemSelected: case MHRoot.EventLastItemPresented: case MHRoot.EventTailItems: case MHRoot.EventTestEvent: case MHRoot.EventTokenMovedFrom: case MHRoot.EventTokenMovedTo: // Synchronous events. Fire any links that are waiting. // The UK MHEG describes this as the preferred interpretation. We are checking the link // at the time we generate the event rather than queuing the synchronous events until // this elementary action is complete. That matters if we are processing an elementary action // which will activate or deactivate links. CheckLinks(pSource.ObjectIdentifier, ev, evData); break; case MHRoot.EventAnchorFired: case MHRoot.EventAsyncStopped: case MHRoot.EventContentAvailable: case MHRoot.EventCounterTrigger: case MHRoot.EventCursorEnter: case MHRoot.EventCursorLeave: case MHRoot.EventEngineEvent: case MHRoot.EventEntryFieldFull: case MHRoot.EventInteractionCompleted: case MHRoot.EventStreamEvent: case MHRoot.EventStreamPlaying: case MHRoot.EventStreamStopped: case MHRoot.EventTimerFired: case MHRoot.EventUserInput: case MHRoot.EventFocusMoved: // UK MHEG. Generated by HyperText class case MHRoot.EventSliderValueChanged: // UK MHEG. Generated by Slider class { // Asynchronous events. Add to the event queue. MHAsynchEvent pEvent = new MHAsynchEvent(); pEvent.EventSource = pSource; pEvent.EventType = ev; pEvent.EventData = evData; m_EventQueue.Add(pEvent); } break; } }
public void SendToBack(MHRoot p) { int nPos = CurrentApp().FindOnStack(p); if (nPos == -1) { return; // If it's not there do nothing } MHVisible pVis = (MHVisible)p; // Can now safely cast it. CurrentApp().DisplayStack.RemoveAt(nPos); // Remove it from its present posn CurrentApp().DisplayStack.InsertAt(pVis, 0); // Put it on the bottom. Redraw(pVis.GetVisibleArea()); // Request a redraw }
// Functions to alter the Z-order. public void BringToFront(MHRoot p) { int nPos = CurrentApp().FindOnStack(p); if (nPos == -1) { return; // If it's not there do nothing } MHVisible pVis = (MHVisible)p; // Can now safely cast it. CurrentApp().DisplayStack.RemoveAt(nPos); // Remove it from its present posn CurrentApp().DisplayStack.Append((MHVisible)pVis); // Push it on the top. Redraw(pVis.GetVisibleArea()); // Request a redraw }
// Return the value, looking up any indirect ref. public void GetValue(MHContentRef reference, MHEngine engine) { if (m_fIsDirect) { reference.Copy(m_Direct); } else { MHUnion result = new MHUnion(); MHRoot pBase = engine.FindObject(m_Indirect); pBase.GetVariableValue(result, engine); result.CheckType(MHUnion.U_ContentRef); reference.Copy(result.ContentRef); } }
// Return the value, looking up any indirect ref. public bool GetValue(MHEngine engine) { if (m_fIsDirect) { return(m_fDirect); } else { MHUnion result = new MHUnion(); MHRoot pBase = engine.FindObject(m_Indirect); pBase.GetVariableValue(result, engine); result.CheckType(MHUnion.U_Bool); return(result.Bool); } }
public void PutBehind(MHRoot p, MHRoot pRef) { int nPos = CurrentApp().FindOnStack(p); if (nPos == -1) { return; // If it's not there do nothing } int nRef = CurrentApp().FindOnStack(pRef); if (nRef == -1) { return; // If the reference visible isn't there do nothing. } MHVisible pVis = (MHVisible)p; // Can now safely cast it. CurrentApp().DisplayStack.RemoveAt(nPos); if (nRef >= nPos) { nRef--; // The position of the reference may have shifted } CurrentApp().DisplayStack.InsertAt((MHVisible)pVis, nRef); // Shift the reference and anything above up. Redraw(pVis.GetVisibleArea()); // Request a redraw }
public virtual void GetBoxSize(MHRoot pWidthDest, MHRoot HeightDest) { InvalidAction("GetBoxSize"); }
public virtual void PutBefore(MHRoot pRef, MHEngine engine) { InvalidAction("PutBefore"); }
public virtual void GetListSize(MHRoot pResult, MHEngine engine) { InvalidAction("GetListSize"); }
public virtual void GetPosition(MHRoot pXPosN, MHRoot pYPosN) { InvalidAction("GetPosition"); }
public virtual void DelItem(MHRoot pItem, MHEngine engine) { InvalidAction("GetCellItem"); }
public virtual void GetFirstItem(MHRoot pResult, MHEngine engine) { InvalidAction("GetFirstItem"); }
// Actions on ListGroups public virtual void AddItem(int nIndex, MHRoot pItem, MHEngine engine) { InvalidAction("GetCellItem"); }
// Called when an event is triggered. Either queues the event or finds a link that matches. public void EventTriggered(MHRoot pSource, int eventType) { EventTriggered(pSource, eventType, new MHUnion()); }
public virtual void GetFillColour(MHRoot pResult) { InvalidAction("GetFillColour"); }
public virtual void GetLineWidth(MHRoot pResult) { InvalidAction("GetLineWidth"); }
public virtual void PutBehind(MHRoot pRef, MHEngine engine) { InvalidAction("PutBehind"); }
public virtual void GetBitmapDecodeOffset(MHRoot pXOffset, MHRoot pYOffset) { InvalidAction("GetBitmapDecodeOffset"); }
// This isn't an MHEG action as such but is used as part of the implementation of "Clone" public virtual void MakeClone(MHRoot target, MHRoot reference, MHEngine engine) { InvalidAction("MakeClone"); }
public virtual void GetLineStyle(MHRoot pResult) { InvalidAction("GetLineStyle"); }
// Actions on Text objects public virtual void GetTextData(MHRoot pDestination, MHEngine engine) { InvalidAction("GetTextData"); }
public virtual void GetVideoDecodeOffset(MHRoot pXOffset, MHRoot pYOffset, MHEngine engine) { InvalidAction("GetVideoDecodeOffset"); }
public virtual void GetTokenPosition(MHRoot pResult, MHEngine engine) { InvalidAction("GetTokenPosition"); }