Example #1
0
void MHVisible::Initialise(MHParseNode *p, MHEngine *engine)
{
    MHPresentable::Initialise(p, engine);
    // Original box size - two integer arguments.
    MHParseNode *pOriginalBox = p->GetNamedArg(C_ORIGINAL_BOX_SIZE);

    if (! pOriginalBox)
    {
        p->Failure("OriginalBoxSize missing");
    }
    else
    {
        m_nOriginalBoxWidth = pOriginalBox->GetArgN(0)->GetIntValue();
        m_nOriginalBoxHeight = pOriginalBox->GetArgN(1)->GetIntValue();
    }

    // Original position - two integer arguments.  Optional
    MHParseNode *pOriginalPos = p->GetNamedArg(C_ORIGINAL_POSITION);

    if (pOriginalPos)
    {
        m_nOriginalPosX = pOriginalPos->GetArgN(0)->GetIntValue();
        m_nOriginalPosY = pOriginalPos->GetArgN(1)->GetIntValue();
    }

    // OriginalPalette ref - optional.
    MHParseNode *pOriginalPaletteRef = p->GetNamedArg(C_ORIGINAL_PALETTE_REF);

    if (pOriginalPaletteRef)
    {
        m_OriginalPaletteRef.Initialise(pOriginalPaletteRef->GetArgN(0), engine);
    }
}
Example #2
0
void MHInteractible::Initialise(MHParseNode *p, MHEngine *engine)
{
    // Engine Resp - optional
    MHParseNode *pEngineResp = p->GetNamedArg(C_ENGINE_RESP);

    if (pEngineResp)
    {
        m_fEngineResp = pEngineResp->GetArgN(0)->GetBoolValue();
    }

    // Highlight colour.
    MHParseNode *phlCol = p->GetNamedArg(C_HIGHLIGHT_REF_COLOUR);

    if (phlCol)
    {
        m_highlightRefColour.Initialise(phlCol->GetArgN(0), engine);
    }
    else
    {
        engine->GetDefaultHighlightRefColour(m_highlightRefColour);
    }

    m_fHighlightStatus = false;
    m_fInteractionStatus = false;
}
Example #3
0
void MHListGroup::Initialise(MHParseNode *p, MHEngine *engine)
{
    MHTokenGroup::Initialise(p, engine);
    MHParseNode *pPositions = p->GetNamedArg(C_POSITIONS);

    if (pPositions)
    {
        for (int i = 0; i < pPositions->GetArgCount(); i++)
        {
            MHParseNode *pPos = pPositions->GetArgN(i);
            QPoint pos(pPos->GetSeqN(0)->GetIntValue(), pPos->GetSeqN(1)->GetIntValue());
            m_Positions.Append(pos);
        }
    }

    MHParseNode *pWrap = p->GetNamedArg(C_WRAP_AROUND);

    if (pWrap)
    {
        m_fWrapAround = pWrap->GetArgN(0)->GetBoolValue();
    }

    MHParseNode *pMultiple = p->GetNamedArg(C_WRAP_AROUND);

    if (pMultiple)
    {
        m_fMultipleSelection = pMultiple->GetArgN(0)->GetBoolValue();
    }
}
Example #4
0
void MHStream::Initialise(MHParseNode *p, MHEngine *engine)
{
    MHPresentable::Initialise(p, engine);
    MHParseNode *pMultiplex = p->GetNamedArg(C_MULTIPLEX);
    if (pMultiplex) {
        for (int i = 0; i < pMultiplex->GetArgCount(); i++) {
            MHParseNode *pItem = pMultiplex->GetArgN(i);
            if (pItem->GetTagNo() == C_AUDIO) {
                MHAudio *pAudio = new MHAudio;
                m_Multiplex.Append(pAudio);
                pAudio->Initialise(pItem, engine);
            }
            else if (pItem->GetTagNo() == C_VIDEO) {
                MHVideo *pVideo = new MHVideo;
                m_Multiplex.Append(pVideo);
                pVideo->Initialise(pItem, engine);
            }
            else if (pItem->GetTagNo() == C_RTGRAPHICS) {
                MHRTGraphics *pRtGraph = new MHRTGraphics;
                m_Multiplex.Append(pRtGraph);
                pRtGraph->Initialise(pItem, engine);
            }
            // Ignore unknown items
        }
    }
    MHParseNode *pStorage = p->GetNamedArg(C_STORAGE);
    if (pStorage) m_nStorage = (enum Storage) pStorage->GetArgN(0)->GetEnumValue();
    MHParseNode *pLooping = p->GetNamedArg(C_LOOPING);
    if (pLooping) m_nLooping = pLooping->GetArgN(0)->GetIntValue();
}
Example #5
0
void MHSetColour::Initialise(MHParseNode *p, MHEngine *engine)
{
    MHElemAction::Initialise(p, engine);
    if (p->GetArgCount() > 1) {
        MHParseNode *pIndexed = p->GetNamedArg(C_NEW_COLOUR_INDEX);
        MHParseNode *pAbsolute = p->GetNamedArg(C_NEW_ABSOLUTE_COLOUR);
        if (pIndexed) { m_ColourType = CT_Indexed; m_Indexed.Initialise(pIndexed->GetArgN(0), engine); }
        else if (pAbsolute) { m_ColourType = CT_Absolute; m_Absolute.Initialise(pAbsolute->GetArgN(0), engine); }
    }
}
Example #6
0
void MHBitmap::Initialise(MHParseNode *p, MHEngine *engine)
{
    MHVisible::Initialise(p, engine);
    // Tiling - optional
    MHParseNode *pTiling = p->GetNamedArg(C_TILING);
    if (pTiling) m_fTiling = pTiling->GetArgN(0)->GetBoolValue();
    // Transparency - optional
    MHParseNode *pTransparency = p->GetNamedArg(C_ORIGINAL_TRANSPARENCY);
    if (pTransparency) m_nOrigTransparency = pTransparency->GetArgN(0)->GetIntValue();
    m_pContent = engine->GetContext()->CreateBitmap(m_fTiling);
}
void MHSetData::Initialise(MHParseNode *p, MHEngine *engine)
{
    MHElemAction::Initialise(p, engine); // Target
    MHParseNode *pContent = p->GetArgN(1);

    if (pContent->m_nNodeType == MHParseNode::PNSeq)
    {
        // Referenced content.
        m_fIsIncluded = false;
        m_fSizePresent = m_fCCPriorityPresent = false;
        m_Referenced.Initialise(pContent->GetSeqN(0), engine);

        if (pContent->GetSeqCount() > 1)
        {
            MHParseNode *pArg = pContent->GetSeqN(1);

            if (pArg->m_nNodeType == MHParseNode::PNTagged && pArg->GetTagNo() == C_NEW_CONTENT_SIZE)
            {
                MHParseNode *pVal = pArg->GetArgN(0);

                // It may be NULL as a place-holder
                if (pVal->m_nNodeType == MHParseNode::PNInt)
                {
                    m_fSizePresent = true;
                    m_ContentSize.Initialise(pVal, engine);
                }
            }
        }

        if (pContent->GetSeqCount() > 2)
        {
            MHParseNode *pArg = pContent->GetSeqN(2);

            if (pArg->m_nNodeType == MHParseNode::PNTagged && pArg->GetTagNo() == C_NEW_CONTENT_CACHE_PRIO)
            {
                MHParseNode *pVal = pArg->GetArgN(0);

                if (pVal->m_nNodeType == MHParseNode::PNInt)
                {
                    m_fCCPriorityPresent = true;
                    m_CCPriority.Initialise(pVal, engine);
                }
            }
        }
    }
    else
    {
        m_Included.Initialise(pContent, engine);
        m_fIsIncluded = true;
    }
}
Example #8
0
void MHBooleanVar::Initialise(MHParseNode *p, MHEngine *engine)
{
    MHVariable::Initialise(p, engine);
    // Original value should be a bool.
    MHParseNode *pInitial = p->GetNamedArg(C_ORIGINAL_VALUE);
    if (pInitial) m_fOriginalValue = pInitial->GetArgN(0)->GetBoolValue();
}
Example #9
0
void MHOctetStrVar::Initialise(MHParseNode *p, MHEngine *engine)
{
    MHVariable::Initialise(p, engine);
    // Original value should be a string.
    MHParseNode *pInitial = p->GetNamedArg(C_ORIGINAL_VALUE);
    if (pInitial) pInitial->GetArgN(0)->GetStringValue(m_OriginalValue);
}
Example #10
0
void MHIntegerVar::Initialise(MHParseNode *p, MHEngine *engine)
{
    MHVariable::Initialise(p, engine);
    // Original value should be an int.
    MHParseNode *pInitial = p->GetNamedArg(C_ORIGINAL_VALUE);
    if (pInitial) m_nOriginalValue = pInitial->GetArgN(0)->GetIntValue();
}
Example #11
0
void MHVideo::Initialise(MHParseNode *p, MHEngine *engine)
{
    MHVisible::Initialise(p, engine);
    MHParseNode *pComponentTagNode = p->GetNamedArg(C_COMPONENT_TAG);
    if (pComponentTagNode) m_nComponentTag = pComponentTagNode->GetArgN(0)->GetIntValue();
    MHParseNode *pTerm = p->GetNamedArg(C_TERMINATION);
    if (pTerm) m_Termination = (enum Termination)pTerm->GetEnumValue();
}
Example #12
0
void MHAudio::Initialise(MHParseNode *p, MHEngine *engine)
{
    MHPresentable::Initialise(p, engine);
    MHParseNode *pComponentTagNode =  p->GetNamedArg(C_COMPONENT_TAG);
    if (pComponentTagNode) m_nComponentTag = pComponentTagNode->GetArgN(0)->GetIntValue();
    MHParseNode *pOrigVol = p->GetNamedArg(C_ORIGINAL_VOLUME);
    if (pOrigVol) m_nOriginalVol = pOrigVol->GetIntValue();
}
Example #13
0
void MHTokenGroup::Initialise(MHParseNode *p, MHEngine *engine)
{
    MHPresentable::Initialise(p, engine);
    MHParseNode *pMovements = p->GetNamedArg(C_MOVEMENT_TABLE);

    if (pMovements)
    {
        for (int i = 0; i < pMovements->GetArgCount(); i++)
        {
            MHMovement *pMove = new MHMovement;
            m_MovementTable.Append(pMove);
            pMove->Initialise(pMovements->GetArgN(i), engine);
        }
    }

    MHParseNode *pTokenGrp = p->GetNamedArg(C_TOKEN_GROUP_ITEMS);

    if (pTokenGrp)
    {
        for (int i = 0; i < pTokenGrp->GetArgCount(); i++)
        {
            MHTokenGroupItem *pToken = new MHTokenGroupItem;
            m_TokenGrpItems.Append(pToken);
            pToken->Initialise(pTokenGrp->GetArgN(i), engine);
        }
    }

    MHParseNode *pNoToken = p->GetNamedArg(C_NO_TOKEN_ACTION_SLOTS);

    if (pNoToken)
    {
        for (int i = 0; i < pNoToken->GetArgCount(); i++)
        {
            MHParseNode *pAct = pNoToken->GetArgN(i);
            MHActionSequence *pActions = new MHActionSequence;
            m_NoTokenActionSlots.Append(pActions);

            // The action slot entry may be NULL.
            if (pAct->m_nNodeType != MHParseNode::PNNull)
            {
                pActions->Initialise(pAct, engine);
            }
        }
    }
}
Example #14
0
void MHContentRefVar::Initialise(MHParseNode *p, MHEngine *engine)
{
    MHVariable::Initialise(p, engine);
    // Original value should be a content reference.
    MHParseNode *pInitial = p->GetNamedArg(C_ORIGINAL_VALUE);
    // and this should be a ContentRef node.
    MHParseNode *pArg = pInitial->GetNamedArg(C_CONTENT_REFERENCE);
    m_OriginalValue.Initialise(pArg->GetArgN(0), engine);
}
Example #15
0
void MHLineArt::Initialise(MHParseNode *p, MHEngine *engine)
{
    MHVisible::Initialise(p, engine);
    // Bordered bounding box - optional
    MHParseNode *pBBBox = p->GetNamedArg(C_BORDERED_BOUNDING_BOX);

    if (pBBBox)
    {
        m_fBorderedBBox = pBBBox->GetArgN(0)->GetBoolValue();
    }

    // Original line width
    MHParseNode *pOlw = p->GetNamedArg(C_ORIGINAL_LINE_WIDTH);

    if (pOlw)
    {
        m_nOriginalLineWidth = pOlw->GetArgN(0)->GetIntValue();
    }

    // Original line style.  This is an integer not an enum.
    MHParseNode *pOls = p->GetNamedArg(C_ORIGINAL_LINE_STYLE);

    if (pOls)
    {
        m_OriginalLineStyle = pOls->GetArgN(0)->GetIntValue();
    }

    // Line colour.
    MHParseNode *pOrlc = p->GetNamedArg(C_ORIGINAL_REF_LINE_COLOUR);

    if (pOrlc)
    {
        m_OrigLineColour.Initialise(pOrlc->GetArgN(0), engine);
    }

    // Fill colour
    MHParseNode *pOrfc = p->GetNamedArg(C_ORIGINAL_REF_FILL_COLOUR);

    if (pOrfc)
    {
        m_OrigFillColour.Initialise(pOrfc->GetArgN(0), engine);
    }
}
Example #16
0
void MHIngredient::Initialise(MHParseNode *p, MHEngine *engine)
{
    MHRoot::Initialise(p, engine);
    MHParseNode *pIA = p->GetNamedArg(C_INITIALLY_ACTIVE);

    if (pIA)
    {
        m_fInitiallyActive = pIA->GetArgN(0)->GetBoolValue();
    }

    MHParseNode *pCHook = p->GetNamedArg(C_CONTENT_HOOK);

    if (pCHook)
    {
        m_nContentHook = pCHook->GetArgN(0)->GetIntValue();
    }

    MHParseNode *pOrigContent = p->GetNamedArg(C_ORIGINAL_CONTENT);

    if (pOrigContent)
    {
        MHParseNode *pArg = pOrigContent->GetArgN(0);

        // Either a string - included content.
        if (pArg->m_nNodeType == MHParseNode::PNString)
        {
            m_ContentType = IN_IncludedContent;
            pArg->GetStringValue(m_OrigIncludedContent);
        }
        else   // or a sequence - referenced content.
        {
            // In the text version this is tagged with :ContentRef
            m_ContentType = IN_ReferencedContent;
            m_OrigContentRef.Initialise(pArg->GetArgN(0), engine);
            MHParseNode *pContentSize = pArg->GetNamedArg(C_CONTENT_SIZE);

            if (pContentSize)
            {
                m_nOrigContentSize = pContentSize->GetArgN(0)->GetIntValue();
            }

            MHParseNode *pCCPrio = pArg->GetNamedArg(C_CONTENT_CACHE_PRIORITY);

            if (pCCPrio)
            {
                m_nOrigCCPrio = pCCPrio->GetArgN(0)->GetIntValue();
            }
        }
    }

    MHParseNode *pShared = p->GetNamedArg(C_SHARED);

    if (pShared)
    {
        m_fShared = pShared->GetArgN(0)->GetBoolValue();
    }
}
Example #17
0
void MHObjectRefVar::Initialise(MHParseNode *p, MHEngine *engine)
{
    MHVariable::Initialise(p, engine);
    // Original value should be an object reference.
    MHParseNode *pInitial = p->GetNamedArg(C_ORIGINAL_VALUE);
    // and this should be a ObjRef node.
    if (pInitial) {
        MHParseNode *pArg = pInitial->GetNamedArg(C_OBJECT_REFERENCE);
        if (pArg) m_OriginalValue.Initialise(pArg->GetArgN(0), engine);
    }
}
Example #18
0
void MHProgram::Initialise(MHParseNode *p, MHEngine *engine)
{
    MHIngredient::Initialise(p, engine);
    MHParseNode *pCmdNode = p->GetNamedArg(C_NAME);

    if (pCmdNode)
    {
        pCmdNode->GetArgN(0)->GetStringValue(m_Name);    // Program name
    }

    MHParseNode *pAvail = p->GetNamedArg(C_INITIALLY_AVAILABLE);

    if (pAvail)
    {
        m_fInitiallyAvailable = pAvail->GetArgN(0)->GetBoolValue();
    }

    // The MHEG Standard says that InitiallyAvailable is mandatory and should be false.
    // That doesn't seem to be the case in some MHEG programs so we force it here.
    m_fInitiallyActive = false;
}
Example #19
0
void MHScene::Initialise(MHParseNode *p, MHEngine *engine)
{
    MHGroup::Initialise(p, engine);
    // Event register.
    MHParseNode *pInputEventReg = p->GetNamedArg(C_INPUT_EVENT_REGISTER);

    if (pInputEventReg)
    {
        m_nEventReg = pInputEventReg->GetArgN(0)->GetIntValue();
    }

    // Co-ordinate system
    MHParseNode *pSceneCoords = p->GetNamedArg(C_SCENE_COORDINATE_SYSTEM);

    if (pSceneCoords)
    {
        m_nSceneCoordX = pSceneCoords->GetArgN(0)->GetIntValue();
        m_nSceneCoordY = pSceneCoords->GetArgN(1)->GetIntValue();
    }

    // Aspect ratio
    MHParseNode *pAspectRatio = p->GetNamedArg(C_ASPECT_RATIO);

    if (pAspectRatio)
    {
        // Is the binary encoded as a sequence or a pair of arguments?
        m_nAspectRatioW = pAspectRatio->GetArgN(0)->GetIntValue();
        m_nAspectRatioH = pAspectRatio->GetArgN(1)->GetIntValue();
    }

    // Moving cursor
    MHParseNode *pMovingCursor = p->GetNamedArg(C_MOVING_CURSOR);

    if (pMovingCursor)
    {
        pMovingCursor->GetArgN(0)->GetBoolValue();
    }

    // Next scene sequence: this is just a hint and isn't implemented
}
Example #20
0
void MHSlider::Initialise(MHParseNode *p, MHEngine *engine)
{
    MHVisible::Initialise(p, engine);
    MHInteractible::Initialise(p, engine);
    //
    MHParseNode *pOrientation = p->GetNamedArg(C_ORIENTATION);

    if (pOrientation)
    {
        m_orientation = (enum SliderOrientation)pOrientation->GetArgN(0)->GetEnumValue();
    }

    // This is not optional.

    MHParseNode *pMin = p->GetNamedArg(C_MIN_VALUE);

    if (pMin)
    {
        orig_min_value = pMin->GetArgN(0)->GetIntValue();
    }
    else
    {
        orig_min_value = 1;
    }

    MHParseNode *pMax = p->GetNamedArg(C_MAX_VALUE);

    if (pMax)
    {
        orig_max_value = pMax->GetArgN(0)->GetIntValue();
    }
    else
    {
        orig_max_value = orig_min_value - 1;    // Unset
    }

    MHParseNode *pInit = p->GetNamedArg(C_INITIAL_VALUE);

    if (pInit)
    {
        initial_value = pInit->GetArgN(0)->GetIntValue();
    }
    else
    {
        initial_value = orig_min_value;    // Default is min_value
    }

    MHParseNode *pPortion = p->GetNamedArg(C_INITIAL_PORTION);

    if (pPortion)
    {
        initial_portion = pPortion->GetArgN(0)->GetIntValue();
    }
    else
    {
        initial_portion = orig_min_value - 1;    // Unset
    }

    MHParseNode *pStep = p->GetNamedArg(C_STEP_SIZE);

    if (pStep)
    {
        orig_step_size = pStep->GetArgN(0)->GetIntValue();
    }
    else
    {
        orig_step_size = 1;    // Unset
    }

    MHParseNode *pStyle = p->GetNamedArg(C_SLIDER_STYLE);

    if (pStyle)
    {
        m_style = (enum SliderStyle)pStyle->GetArgN(0)->GetEnumValue();
    }
    else
    {
        m_style = SliderNormal;
    }

    MHParseNode *pslCol = p->GetNamedArg(C_SLIDER_REF_COLOUR);

    if (pslCol)
    {
        m_sliderRefColour.Initialise(pslCol->GetArgN(0), engine);
    }
    else
    {
        engine->GetDefaultSliderRefColour(m_sliderRefColour);
    }
}
Example #21
0
void MHText::Initialise(MHParseNode *p, MHEngine *engine)
{
    MHVisible::Initialise(p, engine);
    // Font and attributes.
    MHParseNode *pFontBody = p->GetNamedArg(C_ORIGINAL_FONT);

    if (pFontBody)
    {
        m_OrigFont.Initialise(pFontBody->GetArgN(0), engine);
    }

    MHParseNode *pFontAttrs = p->GetNamedArg(C_FONT_ATTRIBUTES);

    if (pFontAttrs)
    {
        pFontAttrs->GetArgN(0)->GetStringValue(m_OriginalFontAttrs);
    }

    // Colours
    MHParseNode *pTextColour = p->GetNamedArg(C_TEXT_COLOUR);

    if (pTextColour)
    {
        m_OriginalTextColour.Initialise(pTextColour->GetArgN(0), engine);
    }

    MHParseNode *pBGColour = p->GetNamedArg(C_BACKGROUND_COLOUR);

    if (pBGColour)
    {
        m_OriginalBgColour.Initialise(pBGColour->GetArgN(0), engine);
    }

    // Character set
    MHParseNode *pChset = p->GetNamedArg(C_CHARACTER_SET);

    if (pChset)
    {
        m_nCharSet = pChset->GetArgN(0)->GetIntValue();
    }

    // Justification
    MHParseNode *pHJust = p->GetNamedArg(C_HORIZONTAL_JUSTIFICATION);

    if (pHJust)
    {
        m_HorizJ = (enum Justification)pHJust->GetArgN(0)->GetEnumValue();
    }

    MHParseNode *pVJust = p->GetNamedArg(C_VERTICAL_JUSTIFICATION);

    if (pVJust)
    {
        m_VertJ = (enum Justification)pVJust->GetArgN(0)->GetEnumValue();
    }

    // Line orientation
    MHParseNode *pLineO = p->GetNamedArg(C_LINE_ORIENTATION);

    if (pLineO)
    {
        m_LineOrientation = (enum LineOrientation)pLineO->GetArgN(0)->GetEnumValue();
    }

    // Start corner
    MHParseNode *pStartC = p->GetNamedArg(C_START_CORNER);

    if (pStartC)
    {
        m_StartCorner = (enum StartCorner)pStartC->GetArgN(0)->GetEnumValue();
    }

    // Text wrapping
    MHParseNode *pTextWrap = p->GetNamedArg(C_TEXT_WRAPPING);

    if (pTextWrap)
    {
        m_fTextWrap = pTextWrap->GetArgN(0)->GetBoolValue();
    }

    m_pDisplay = engine->GetContext()->CreateText();
    m_fNeedsRedraw = true;
}
Example #22
0
void MHApplication::Initialise(MHParseNode *p, MHEngine *engine)
{
    MHGroup::Initialise(p, engine);
    // OnSpawnCloseDown
    MHParseNode *pOnSpawn = p->GetNamedArg(C_ON_SPAWN_CLOSE_DOWN);

    if (pOnSpawn)
    {
        m_OnSpawnCloseDown.Initialise(pOnSpawn, engine);
    }

    // OnRestart
    MHParseNode *pOnRestart = p->GetNamedArg(C_ON_RESTART);

    if (pOnRestart)
    {
        m_OnRestart.Initialise(pOnRestart, engine);
    }

    // Default attributes.  These are encoded in a group in binary.
    MHParseNode *pDefattrs = p->GetNamedArg(C_DEFAULT_ATTRIBUTES);

    // but in the text form they're encoded in the Application block.
    if (pDefattrs == NULL)
    {
        pDefattrs = p;
    }

    MHParseNode *pCharSet = pDefattrs->GetNamedArg(C_CHARACTER_SET);

    if (pCharSet)
    {
        m_nCharSet = pCharSet->GetArgN(0)->GetIntValue();
    }

    // Colours
    MHParseNode *pBGColour = pDefattrs->GetNamedArg(C_BACKGROUND_COLOUR);

    if (pBGColour)
    {
        m_BGColour.Initialise(pBGColour->GetArgN(0), engine);
    }

    MHParseNode *pTextColour = pDefattrs->GetNamedArg(C_TEXT_COLOUR);

    if (pTextColour)
    {
        m_TextColour.Initialise(pTextColour->GetArgN(0), engine);
    }

    MHParseNode *pButtonRefColour = pDefattrs->GetNamedArg(C_BUTTON_REF_COLOUR);

    if (pButtonRefColour)
    {
        m_ButtonRefColour.Initialise(pButtonRefColour->GetArgN(0), engine);
    }

    MHParseNode *pHighlightRefColour = pDefattrs->GetNamedArg(C_HIGHLIGHT_REF_COLOUR);

    if (pHighlightRefColour)
    {
        m_HighlightRefColour.Initialise(pHighlightRefColour->GetArgN(0), engine);
    }

    MHParseNode *pSliderRefColour = pDefattrs->GetNamedArg(C_SLIDER_REF_COLOUR);

    if (pSliderRefColour)
    {
        m_SliderRefColour.Initialise(pSliderRefColour->GetArgN(0), engine);
    }

    // Content hooks
    MHParseNode *pTextCHook = pDefattrs->GetNamedArg(C_TEXT_CONTENT_HOOK);

    if (pTextCHook)
    {
        m_nTextCHook = pTextCHook->GetArgN(0)->GetIntValue();
    }

    MHParseNode *pIPCHook = pDefattrs->GetNamedArg(C_IP_CONTENT_HOOK);

    if (pIPCHook)
    {
        m_nIPCHook = pIPCHook->GetArgN(0)->GetIntValue();
    }

    MHParseNode *pStrCHook = pDefattrs->GetNamedArg(C_STREAM_CONTENT_HOOK);

    if (pStrCHook)
    {
        m_nStrCHook = pStrCHook->GetArgN(0)->GetIntValue();
    }

    MHParseNode *pBitmapCHook = pDefattrs->GetNamedArg(C_BITMAP_CONTENT_HOOK);

    if (pBitmapCHook)
    {
        m_nBitmapCHook = pBitmapCHook->GetArgN(0)->GetIntValue();
    }

    MHParseNode *pLineArtCHook = pDefattrs->GetNamedArg(C_LINE_ART_CONTENT_HOOK);

    if (pLineArtCHook)
    {
        m_nLineArtCHook = pLineArtCHook->GetArgN(0)->GetIntValue();
    }

    // Font.  This is a little tricky.  There are two attributes both called Font.
    // In the binary notation the font here is encoded as 42 whereas the text form
    // finds the first occurrence of :Font in the table and returns 13.
    MHParseNode *pFont = pDefattrs->GetNamedArg(C_FONT2);

    if (pFont == NULL)
    {
        pFont = pDefattrs->GetNamedArg(C_FONT);
    }

    if (pFont)
    {
        m_Font.Initialise(pFont->GetArgN(0), engine);
    }

    // Font attributes.
    MHParseNode *pFontAttrs = pDefattrs->GetNamedArg(C_FONT_ATTRIBUTES);

    if (pFontAttrs)
    {
        pFontAttrs->GetArgN(0)->GetStringValue(m_FontAttrs);
    }
}
Example #23
0
void MHGroup::Initialise(MHParseNode *p, MHEngine *engine)
{
    engine->GetGroupId().Copy(""); // Set to empty before we start (just in case).
    MHRoot::Initialise(p, engine);

    // Must be an external reference with an object number of zero.
    if (m_ObjectReference.m_nObjectNo != 0 || m_ObjectReference.m_GroupId.Size() == 0)
    {
        MHERROR("Object reference for a group object must be zero and external");
    }

    // Set the group id for the rest of the group to this.
    engine->GetGroupId().Copy(m_ObjectReference.m_GroupId);
    // Some of the information is irrelevant.
    //  MHParseNode *pStdId = p->GetNamedArg(C_STANDARD_IDENTIFIER);
    //  MHParseNode *pStdVersion = p->GetNamedArg(C_STANDARD_VERSION);
    //  MHParseNode *pObjectInfo = p->GetNamedArg(C_OBJECT_INFORMATION);

    MHParseNode *pOnStartUp = p->GetNamedArg(C_ON_START_UP);

    if (pOnStartUp)
    {
        m_StartUp.Initialise(pOnStartUp, engine);
    }

    MHParseNode *pOnCloseDown = p->GetNamedArg(C_ON_CLOSE_DOWN);

    if (pOnCloseDown)
    {
        m_CloseDown.Initialise(pOnCloseDown, engine);
    }

    MHParseNode *pOriginalGCPrio = p->GetNamedArg(C_ORIGINAL_GC_PRIORITY);

    if (pOriginalGCPrio)
    {
        m_nOrigGCPriority = pOriginalGCPrio->GetArgN(0)->GetIntValue();
    }

    // Ignore the other stuff at the moment.
    MHParseNode *pItems = p->GetNamedArg(C_ITEMS);

    if (pItems == NULL)
    {
        p->Failure("Missing :Items block");
        return;
    }

    for (int i = 0; i < pItems->GetArgCount(); i++)
    {
        MHParseNode *pItem = pItems->GetArgN(i);
        MHIngredient *pIngredient = NULL;

        try
        {
            // Generate the particular kind of ingredient.
            switch (pItem->GetTagNo())
            {
                case C_RESIDENT_PROGRAM:
                    pIngredient = new MHResidentProgram;
                    break;
                case C_REMOTE_PROGRAM:
                    pIngredient = new MHRemoteProgram;
                    break;
                case C_INTERCHANGED_PROGRAM:
                    pIngredient = new MHInterChgProgram;
                    break;
                case C_PALETTE:
                    pIngredient = new MHPalette;
                    break;
                case C_FONT:
                    pIngredient = new MHFont;
                    break;
                case C_CURSOR_SHAPE:
                    pIngredient = new MHCursorShape;
                    break;
                case C_BOOLEAN_VARIABLE:
                    pIngredient = new MHBooleanVar;
                    break;
                case C_INTEGER_VARIABLE:
                    pIngredient = new MHIntegerVar;
                    break;
                case C_OCTET_STRING_VARIABLE:
                    pIngredient = new MHOctetStrVar;
                    break;
                case C_OBJECT_REF_VARIABLE:
                    pIngredient = new MHObjectRefVar;
                    break;
                case C_CONTENT_REF_VARIABLE:
                    pIngredient = new MHContentRefVar;
                    break;
                case C_LINK:
                    pIngredient = new MHLink;
                    break;
                case C_STREAM:
                    pIngredient = new MHStream;
                    break;
                case C_BITMAP:
                    pIngredient = new MHBitmap;
                    break;
                case C_LINE_ART:
                    pIngredient = new MHLineArt;
                    break;
                case C_DYNAMIC_LINE_ART:
                    pIngredient = new MHDynamicLineArt;
                    break;
                case C_RECTANGLE:
                    pIngredient = new MHRectangle;
                    break;
                case C_HOTSPOT:
                    pIngredient = new MHHotSpot;
                    break;
                case C_SWITCH_BUTTON:
                    pIngredient = new MHSwitchButton;
                    break;
                case C_PUSH_BUTTON:
                    pIngredient = new MHPushButton;
                    break;
                case C_TEXT:
                    pIngredient = new MHText;
                    break;
                case C_ENTRY_FIELD:
                    pIngredient = new MHEntryField;
                    break;
                case C_HYPER_TEXT:
                    pIngredient = new MHHyperText;
                    break;
                case C_SLIDER:
                    pIngredient = new MHSlider;
                    break;
                case C_TOKEN_GROUP:
                    pIngredient = new MHTokenGroup;
                    break;
                case C_LIST_GROUP:
                    pIngredient = new MHListGroup;
                    break;
                default:
                    MHLOG(MHLogWarning, QString("Unknown ingredient %1").arg(pItem->GetTagNo()));
                    // Future proofing: ignore any ingredients that we don't know about.
                    // Obviously these can only arise in the binary coding.
            }

            if (pIngredient)
            {
                // Initialise it from its argments.
                pIngredient->Initialise(pItem, engine);

                // Remember the highest numbered ingredient
                if (pIngredient->m_ObjectReference.m_nObjectNo > m_nLastId)
                {
                    m_nLastId = pIngredient->m_ObjectReference.m_nObjectNo;
                }

                // Add it to the ingedients of this group.
                m_Items.Append(pIngredient);
            }
        }
        catch (...)
        {
            delete(pIngredient);
            throw;
        }
    }
}