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

📄 guistyle_item_list.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"

/* This item style requires a list item.  When a list index is passed,
 * that index is applied to every list in the item. */
int08 guiStyle_item_List_SetListIndex( int16 itemId, uint08 index )
{
    int16 fieldId;
    OSDFIELDTYPE fieldType;
    uint08 listSize;
    
    /* search thru the fields for all lists in the item */
    fieldId = OSD_GetFirstFieldID( itemId );
    if( fieldId == OSD_ERR_ID_INVALID )
        return FAIL;
    
    while( fieldId != OSD_ERR_ID_INVALID )
    {
        if( OSD_GetFieldType( fieldId, &fieldType ) != PASS )
            return FAIL;
            
        /* for all lists we find in the item, set the passed index */
        if( fieldType == LIST )
        {
            listSize = 0;
            OSD_GetListSize( fieldId, &listSize );
            if( index < listSize )
            {
                /* Set the index value */
                OSD_SetListIndex( fieldId, index );            
            }          
        }    
        fieldId = OSD_GetNextFieldID( fieldId );
    }
   
    return PASS;
}

int08 guiStyle_item_List_GuiMsg( GUI_OPEN_MENU *menu, GUIMSG *msg )
{
    int16 fieldId;
    OSDFIELDTYPE fieldType;
    uint08 listSize;
    uint08 index;

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

    /* search thru the fields for the first list in the item */
    fieldId = OSD_GetFirstFieldID( menu->itemId );
    if( fieldId == OSD_ERR_ID_INVALID )
        return FAIL;

    while( fieldId != OSD_ERR_ID_INVALID )
    {
        if( OSD_GetFieldType( fieldId, &fieldType ) != PASS )
            return FAIL;
            
        /* use the first list to determine list size and current index */
        if( fieldType == LIST )
        {
            /* Get the list size and current index value */
            listSize = 0;
            OSD_GetListSize( fieldId, &listSize );
            OSD_GetListIndex( fieldId, &index );   
            break;              
        }    
        fieldId = OSD_GetNextFieldID( fieldId );
    }
    
    if( fieldId == OSD_ERR_ID_INVALID )
        return FAIL;

    switch( msg->type )
    {
        case GUIMSG_LEFT:
        case GUIMSG_DOWN:            
            if( index == 0 )
                index += listSize - 1;
            else
                index--;
            
            msg->type = GUIMSG_DEC;
            msg->data = &index;
            break;
            
        case GUIMSG_RIGHT:
        case GUIMSG_UP:         
            index++;
            index %= listSize;
            
            msg->type = GUIMSG_INC;
            msg->data = &index;
            break;
        
        case GUIMSG_SELECT:
            msg->type = GUIMSG_ASSERT;
            msg->data = &index;
            break;
            
        case GUIMSG_STRING:
        case GUIMSG_VALUE:
            // pass the message as is
            break;

        default:
            break;
    }    

    if( gui_AppAction_GuiMsg( menu->menuId, menu->itemId, msg ) != PASS )
    {
        /* if no item handler installed, update the display */
        guiStyle_item_SetListIndex( menu->itemId, index );
    }
    return PASS;    
}

⌨️ 快捷键说明

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