⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ig_render.cpp

📁 这是DVD中伺服部分的核心代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
 * @retval
 *      FALSE - No button in the selected state.
 *      TRUE  - A button is in the selected state.
 */
BOOLEAN IGIsButtonSelected(IG_HANDLE handle)
{
    if ((PVOID)IG_HANDLE_VALUE != handle)
    {
        return (FALSE);
    }

    /* take the semaphore */
    OS_SemTake(IGInfo.ICSLock, OS_WAIT_FOREVER);

    /* is there a valid ICS */
    if (NULL != IGInfo.ICS)
    {
        /* is there an active page */
        if (NULL != IGInfo.ActivePage)
        {
            /* is there a currently selected button */
            if (NULL != IGInfo.SelectedButton)
            {
                OS_SemGive(IGInfo.ICSLock);
                return (TRUE);
            }
        }
    }

    /* give the semaphore back */
    OS_SemGive(IGInfo.ICSLock);

    return (FALSE);
}

/**
 * IGGetStreamAndUIModel -- Return the Stream and UI Model for the current ICS.
 *
 * @param handle            - handle to the IG module
 * @param pStreamAndUIModel - receives the status
 *
 * @retval
 *      IG_STATUS_SUCCESS - the returned information is valid
 *      IG_STATUS_ERROR   - there was no ICS, returned information is NOT valid
 */
IG_STATUS IGGetStreamAndUIModel(IG_HANDLE handle, BYTE *pStreamAndUIModel)
{
    IG_STATUS status;

    if ((PVOID)IG_HANDLE_VALUE != handle)
    {
        return (IG_STATUS_INVALID_HANDLE);
    }

    /* take the semaphore */
    OS_SemTake(IGInfo.ICSLock, OS_WAIT_FOREVER);

    if (IG_STATE_RUNNING == IGInfo.CurrentState)
    {
        if (NULL != IGInfo.ICS)
        {
            *pStreamAndUIModel = IGInfo.ICS->StreamAndUIModel;
            status = IG_STATUS_SUCCESS;
        }
        else
        {
            status = IG_STATUS_ERROR;
        }
    }
    else
    {
        status = IG_STATUS_ERROR;
    }

    /* give the semaphore back */
    OS_SemGive(IGInfo.ICSLock);

    return (status);
}

/**
 * IGButtonUp - A button was pushed by the user, notify IG and send up a new button if a new button is selected
 *
 * @param IG_HANDLE handle - handle to the IG module
 *
 * @return IG_STATUS
 */
IG_STATUS IGButtonUp(IG_HANDLE handle)
{
    BUTTON *Button;
    int BogIndex;

    if ((PVOID)IG_HANDLE_VALUE != handle)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGButtonUp(): IG_STATUS_INVALID_HANDLE\n"));
        return IG_STATUS_INVALID_HANDLE;
    }

    if (IG_STATE_RUNNING != IGInfo.CurrentState)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGButtonUp(): IG_STATUS_NOT_RUNNING\n"));
        return IG_STATUS_NOT_RUNNING;
    }

    DBGPRINT(DBG_ON(DBG_TRACE), ("IGButtonUp()\n"));

    /* take the semaphore */
    OS_SemTake(IGInfo.ICSLock, OS_WAIT_FOREVER);

    if (NULL == IGInfo.ICS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGButtonUp(): No Current ICS is valid\n"));
        OS_SemGive(IGInfo.ICSLock);
        return IG_STATUS_ERROR;
    }

    if (NULL == IGInfo.ActivePage)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGButtonUp(): no active page in IG\n"));
        OS_SemGive(IGInfo.ICSLock);
        return IG_STATUS_ICS_VALID_ERROR;
    }

    /* are we in a popup menu */
    if (IsPopup())
    {
        if (FALSE == IGInfo.fPopupEnabled)
        {
            OS_SemGive(IGInfo.ICSLock);
            return IG_STATUS_SUCCESS;
        }
    }

    /* is there a button selected right now? */
    if (NULL == IGInfo.SelectedButton)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGButtonUp(): no selected button in IG\n"));
        OS_SemGive(IGInfo.ICSLock);
        return IG_STATUS_ICS_VALID_ERROR;
    }

    if (1 == IGInfo.SelectionTimedout)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGButtonUp(): Selection Timeout Fired\n"));
        OS_SemGive(IGInfo.ICSLock);
        return IG_STATUS_ERROR;
    }

    /* we have a button, look "up" and see if anything is there */
    if (IGInfo.SelectedButton->UpperButtonIDRef == IGInfo.SelectedButton->ButtonID)
    {
        DBGPRINT(DBG_ON(DBG_TRACE), ("IGButtonUp(): Button selection is same, ignoring %d\n", IGInfo.SelectedButton->ButtonID));

        /* give the semaphore back */
        OS_SemGive(IGInfo.ICSLock);
        return IG_STATUS_SUCCESS;
    }
    else if (IGInfo.SelectedButton->UpperButtonIDRef > MAX_BUTTONID_VALUE)
    {
        DBGPRINT(DBG_ON(DBG_TRACE), ("IGButtonUp(): ButtonID value for UP is higher then max button value\n"));

        /* give the semaphore back */
        OS_SemGive(IGInfo.ICSLock);
        return IG_STATUS_SUCCESS;
    }
    else
    {
        /* find the neighbor button in the BOG's on the page */
        if (IG_STATUS_SUCCESS == IGFindButtonInBogsByID(IGInfo.ActivePage, IGInfo.SelectedButton->UpperButtonIDRef, &Button, &BogIndex))
        {
            /* spec says the disabled state indicates the button is not available for user interaction (section 8.8.4.6.1) */
            if (BUTTON_DISABLED != Button->ButtonState)
            {
                /* make the current button just enabled now */
                IGInfo.SelectedButton->ButtonState = BUTTON_ENABLED;
                IGInfo.SelectedButton->CurrentDisplayObjectIDRef = IGInfo.SelectedButton->NormalStartObjectIDRef;

                /* render the first image of the button */
                OS_SemTake(IGInfo.BlitLock, OS_WAIT_FOREVER);
                IGGraphicsRenderButton(IGInfo.SelectedButton, 0);
                OS_SemGive(IGInfo.BlitLock);

                /* use the new button */
                IGInfo.SelectedButton = Button;
                IGToPEButtonSelect(IGInfo.SelectedButton);

                if (IGInfo.SelectedButton->AutoActionFlag)
                {
                    IGInfo.SelectedButton->ButtonState = BUTTON_ACTIVE;

                    /* send PE activation message */
                    ACTIVATION_INFO *Info = (ACTIVATION_INFO *)OS_MemAlloc(sizeof(ACTIVATION_INFO));
                    if (Info != NULL)
                    {
                        Info->Page = IGInfo.ActivePage;
                        Info->Button = IGInfo.SelectedButton;
                        Info->ICS = IGInfo.ICS;
                    }
                    else
                    {
                        DBGPRINT(DBG_ON(DBG_ERROR), ("IGButtonUp(): failed to get memory for autoaction\n"));
                    }

                    IGToPEButtonActivate(IGInfo.SelectedButton, Info);
                }
                else
                {
                    IGInfo.SelectedButton = Button;
                    IGInfo.SelectedButton->ButtonState = BUTTON_SELECTED;
                    IGInfo.SelectedButton->CurrentDisplayObjectIDRef = IGInfo.SelectedButton->SelectedStartObjectIDRef;
                    DBGPRINT(DBG_ON(DBG_TRACE), ("IGButtonUp(): Make Button %d selected\n", IGInfo.SelectedButton->ButtonID));

                    /* render the first image of the button */
                    OS_SemTake(IGInfo.BlitLock, OS_WAIT_FOREVER);
                    IGGraphicsRenderButton(IGInfo.SelectedButton, 0);
                    OS_SemGive(IGInfo.BlitLock);

                    /* visible */
                    OS_TimerSet(IGInfo.TimerFlip, 1);
                    OS_TaskYield();
                }
            }
            else
            {
                DBGPRINT(DBG_ON(DBG_ERROR), ("IGButtonUp(): Attempted to move to disabled button\n"));
            }
        }
    }

    /* give the semaphore back */
    OS_SemGive(IGInfo.ICSLock);

    return IG_STATUS_SUCCESS;
}



/**
 * IGButtonDown - A button was pushed by the user, notify IG and send up a new button if a new button is selected
 *
 * @param IG_HANDLE handle - handle to the IG module
 *
 * @return IG_STATUS
 */
IG_STATUS IGButtonDown(IG_HANDLE handle)
{
    BUTTON *Button;
    int BogIndex;

    if ((PVOID)IG_HANDLE_VALUE != handle)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGButtonDown(): Return IG_STATUS_INVALID_HANDLE\n"));
        return IG_STATUS_INVALID_HANDLE;
    }

    if (IG_STATE_RUNNING != IGInfo.CurrentState)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGButtonDown(): Return IG_STATUS_NOT_RUNNING\n"));
        return IG_STATUS_NOT_RUNNING;
    }

    DBGPRINT(DBG_ON(DBG_TRACE), ("IGButtonDown()\n"));

    /* take the semaphore */
    OS_SemTake(IGInfo.ICSLock, OS_WAIT_FOREVER);

    if (NULL == IGInfo.ICS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGButtonDown(): No Current ICS is valid\n"));
        OS_SemGive(IGInfo.ICSLock);
        return IG_STATUS_ERROR;
    }

    if (NULL == IGInfo.ActivePage)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGButtonDown(): no active page in IG\n"));
        OS_SemGive(IGInfo.ICSLock);
        return IG_STATUS_ICS_VALID_ERROR;
    }

    /* are we in a popup menu */
    if (IsPopup())
    {
        if (FALSE == IGInfo.fPopupEnabled)
        {
            OS_SemGive(IGInfo.ICSLock);
            return IG_STATUS_SUCCESS;
        }
    }

    /* is there a button selected right now? */
    if (NULL == IGInfo.SelectedButton)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGButtonDown(): no selected button in IG\n"));
        OS_SemGive(IGInfo.ICSLock);
        return IG_STATUS_ICS_VALID_ERROR;
    }

    if (1 == IGInfo.SelectionTimedout)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IGButtonDown(): Selection Timeout Fired\n"));
        OS_SemGive(IGInfo.ICSLock);
        return IG_STATUS_ERROR;
    }

    /* we have a button, look "up" and see if anything is there */
    if (IGInfo.SelectedButton->LowerButtonIDRef == IGInfo.SelectedButton->ButtonID)
    {
        DBGPRINT(DBG_ON(DBG_TRACE), ("IGButtonDown(): Button selection is same, ignoring %d\n", IGInfo.SelectedButton->ButtonID));
        OS_SemGive(IGInfo.ICSLock);
        return IG_STATUS_SUCCESS;
    }
    else if (IGInfo.SelectedButton->LowerButtonIDRef > MAX_BUTTONID_VALUE)
    {
        DBGPRINT(DBG_ON(DBG_TRACE), ("IGButtonDown(): ButtonID value for Down is higher then max button value\n"));
        OS_SemGive(IGInfo.ICSLock);
        return IG_STATUS_SUCCESS;
    }
    else
    {
        /* find the neighbor button in the BOG's on the page */
        if (IG_STATUS_SUCCESS == IGFindButtonInBogsByID(IGInfo.ActivePage, IGInfo.SelectedButton->LowerButtonIDRef, &Button, &BogIndex))
        {
            if (BUTTON_DISABLED != Button->ButtonState)
            {
                /* make the current button just enabled now */
                IGInfo.SelectedButton->ButtonState = BUTTON_ENABLED;
                IGInfo.SelectedButton->CurrentDisplayObjectIDRef = IGInfo.SelectedButton->NormalStartObjectIDRef;

                /* render the first image of the button */
                OS_SemTake(IGInfo.BlitLock, OS_WAIT_FOREVER);
                IGGraphicsRenderButton(IGInfo.SelectedButton, 0);
                OS_SemGive(IGInfo.BlitLock);

                /* use the new button */
                IGInfo.SelectedButton = Button;
                IGToPEButtonSelect(IGInfo.SelectedButton);

                /* check for auto action */
                if (IGInfo.SelectedButton->AutoActionFlag)
                {
                    IGInfo.SelectedButton->ButtonState = BUTTON_ACTIVE;

                    /* send PE activation message */
                    ACTIVATION_INFO *Info = (ACTIVATION_INFO *)OS_MemAlloc(sizeof(ACTIVATION_INFO));
                    if (Info != NULL)
                    {
                        Info->Page = IGInfo.ActivePage;
                        Info->Button = IGInfo.SelectedButton;
                        Info->ICS = IGInfo.ICS;
                    }
                    else
                    {
                        DBGPRINT(DBG_ON(DBG_TRACE), ("IGButtonDown(): failed to get memory for auto action\n"));
                    }

                    IGToPEButtonActivate(IGInfo.SelectedButton, Info);
                }
                else
                {
                    IGInfo.SelectedButton->ButtonState = BUTTON_SELECTED;
                    IGInfo.SelectedButton->CurrentDisplayObjectIDRef = IGInfo.SelectedButton->SelectedStartObjectIDRef;
                    DBGPRINT(DBG_ON(DBG_TRACE), ("IGButtonDown(): Make Button %d selected\n", IGInfo.SelectedButton->ButtonID));

                    /* render the first image of the button */
                    OS_SemTake(IGInfo.BlitLock, OS_WAIT_FOREVER);
                    IGG

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -