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

📄 guistyle_menu_horizontalchild.c

📁 IT projecotr reference design.
💻 C
字号:
/*****************************************************************************
**             TEXAS INSTRUMENTS PROPRIETARY INFORMATION
**
**  (c) Copyright, Texas Instruments Incorporated, 2006.
**      All Rights Reserved.
**
**  Property of Texas Instruments Incorporated. Restricted Rights -
**  Use, duplication, or disclosure is subject to restrictions set
**  forth in TI's program license agreement and associated documentation.
******************************************************************************/

#include "common.h"
#include "osd.h"
#include "guiStyle.h"
#include "guiStyle_sub.h"

/* This function initializes the menu according to the menu style */
int08 guiStyle_menu_HorizontalChild_OnStart( GUI_OPEN_MENU *menu, GUIMSG *msg )
{
    uint08 window;
    GUIMSG msg2;

    if( menu == NULL )
        return FAIL;

    if( menu->itemId == OSD_ERR_ID_INVALID )
    {
        /* set the focus on the first item */
        menu->itemId = guiStyle_sub_GetFirstItem( menu->menuId, menu->hiddenItemList );
    }
    
    /* call any menu specific initialization */
    gui_AppAction_OnStart( menu->menuId, msg );

    /* highlight the first item */
    if( menu->itemId != OSD_ERR_ID_INVALID )
    {
        if( gui_AppAction_GetHighlightWindow( menu->menuId, &window ) != PASS )
        {
            window = OSD_ERR_WINNUM_INVALID;
        }
        guiStyle_item_Highlight( menu->itemId, window, TRUE );
        msg2.type = GUIMSG_CHANGEITEMFOCUS;
        msg2.data = NULL;
        gui_AppAction_GuiMsg( menu->menuId, menu->itemId, &msg2 );
    }
    return PASS;
}

/* This function performs any necessary cleanup when the menu closes, including deallocating the hiddenItemList if used */
int08 guiStyle_menu_HorizontalChild_OnClose( GUI_OPEN_MENU *menu )
{
    if( menu == NULL )
        return FAIL;

    gui_AppAction_OnClose( menu->menuId );
    guiStyle_sub_RemoveHiddenItemList( menu );
    
    return PASS;
}

/* implement navigation for RIGHT and LEFT */
int08 guiStyle_menu_HorizontalChild_GuiMsg( GUI_OPEN_MENU *menu, GUIMSG *msg )
{
    int16 newId;
    uint08 window;

    if( msg == NULL || menu == NULL )
        return FAIL;

    switch( msg->type )
    {
        case GUIMSG_LEFT:        
            newId = guiStyle_sub_GetPreviousItem( menu->itemId, menu->hiddenItemList, FALSE );
            
            if( newId == OSD_ERR_ID_INVALID )
            {
                /* If we are on the left-most item and the left key is received, close the menu */
                guiStyle_CloseMenu( menu->menuId );
            }
            else if( newId != OSD_ERR_ID_INVALID )
            {
                if( gui_AppAction_GetHighlightWindow( menu->menuId, &window ) != PASS )
                {
                    window = OSD_ERR_WINNUM_INVALID;
                }
                guiStyle_item_Highlight( menu->itemId, window, FALSE );
                guiStyle_item_Highlight( newId, window, TRUE );
                
                menu->itemId = newId;
                
                msg->type = GUIMSG_CHANGEITEMFOCUS;
                msg->data = NULL;
                gui_AppAction_GuiMsg( menu->menuId, menu->itemId, msg );
            }
            break;
            
        case GUIMSG_RIGHT:
            newId = guiStyle_sub_GetNextItem( menu->itemId, menu->hiddenItemList, TRUE );
            
            if( newId != OSD_ERR_ID_INVALID )
            {
                if( gui_AppAction_GetHighlightWindow( menu->menuId, &window ) != PASS )
                {
                    window = OSD_ERR_WINNUM_INVALID;
                }
                guiStyle_item_Highlight( menu->itemId, window, FALSE );
                guiStyle_item_Highlight( newId, window, TRUE );
                
                menu->itemId = newId;
                
                msg->type = GUIMSG_CHANGEITEMFOCUS;
                msg->data = NULL;
                gui_AppAction_GuiMsg( menu->menuId, menu->itemId, msg );
            }
            break;
            
        
        case GUIMSG_SELECT:          
        case GUIMSG_UP:
        case GUIMSG_DOWN:
        case GUIMSG_STRING:
        case GUIMSG_VALUE:
            guiStyle_item_GuiMsg( menu, msg );
            break;
            
        default:
            break;
    }
    return PASS;   
}

/* This function takes the menu's current state (selected item, etc) and refreshes the
 * OSD item display */
int08 guiStyle_menu_HorizontalChild_Redraw( GUI_OPEN_MENU *menu )
{
    if( menu == NULL )
        return FAIL;

    /* call any menu specific redraw */
    gui_AppAction_Redraw( menu->menuId, NULL );

    return PASS;
}

int08 guiStyle_menu_HorizontalChild_HideItem( GUI_OPEN_MENU *menu, int16 itemId, BOOL hide )
{
    int16 nextItemId;

    if( hide != TRUE )
        return FALSE;
        
    if( itemId == menu->itemId )
    {
        /* set the focus on the next item */
        nextItemId = guiStyle_sub_GetNextItem( menu->itemId, menu->hiddenItemList, TRUE );
    }    
    
    if( OSD_DisableItemDisplay(itemId) != PASS )
       return FAIL;
    
    if( itemId == menu->itemId )
    {
        menu->itemId = nextItemId;
    }
    
    return PASS;
}

int08 guiStyle_menu_HorizontalChild_HideItemGrayOut( GUI_OPEN_MENU *menu, int16 itemId, BOOL hide )
{
    uint08 window;
    int16 newId;
    GUIMSG msg;

    /* graying out items is allowed while the menu is displayed */
    if( hide == TRUE )
    {
        if( guiStyle_sub_IsHiddenItem( menu->hiddenItemList, itemId ) == TRUE )
            return FAIL;
        if( guiStyle_sub_AddHiddenItem( menu, itemId ) != PASS )
            return FAIL;
        if( guiStyle_item_GrayOut( itemId, TRUE ) != PASS )
            return FAIL;
        if( itemId == menu->itemId )
        {
            /* set the focus on the next item */
            newId = guiStyle_sub_GetNextItem( menu->itemId, menu->hiddenItemList, TRUE );
            
            /* if we have successfully selected the next item, highlight it */
            if( newId != OSD_ERR_ID_INVALID )
            {
                if( gui_AppAction_GetHighlightWindow( menu->menuId, &window ) != PASS )
                {
                    window = OSD_ERR_WINNUM_INVALID;
                }
                guiStyle_item_Highlight( menu->itemId, window, FALSE );
                guiStyle_item_Highlight( newId, window, TRUE );

                menu->itemId = newId;
                
                msg.type = GUIMSG_CHANGEITEMFOCUS;
                msg.data = NULL;
                gui_AppAction_GuiMsg( menu->menuId, menu->itemId, &msg );
            }
            else
                return FAIL;
        }
              
    }
    else
    {
        /* method 1 */
        /*
        if( guiStyle_sub_RemoveHiddenItem( menu, itemId ) != PASS )
            return FAIL;
        if( guiStyle_item_GrayOut( itemId, FALSE ) != PASS )
            return FAIL;
        */    
        /* method 2 */
        if( OSD_DisplayMenu( menu->menuId, FALSE ) != PASS )
            return FAIL;
        if( OSD_LoadMenu( menu->menuId, FALSE ) != PASS )
            return FAIL;
        
        guiStyle_menu_Redraw( menu );
        
        if( OSD_DisplayMenu( menu->menuId, TRUE ) != PASS )
            return FAIL;
    }

    return PASS;
}

⌨️ 快捷键说明

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