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

📄 guistyle_item_checkbox.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 field with two entries.  List index 0 = unchecked. 
 * List index 1 = checked */
int08 guiStyle_item_Checkbox_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 with 2 entries we find in the item, set 0 or 1 */
        if( fieldType == LIST )
        {
            listSize = 0;
            OSD_GetListSize( fieldId, &listSize );
            if( listSize == 2 )
            {
                /* Set the index value */
                if( index == 0 )
                    OSD_SetListIndex( fieldId, 0 );   /* unchecked */
                else
                    OSD_SetListIndex( fieldId, 1 );   /* checked */         
            }          
        }    
        fieldId = OSD_GetNextFieldID( fieldId );
    }
   
    return PASS;
}

int08 guiStyle_item_Checkbox_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 with 2 entires to determine and current index */
        if( fieldType == LIST )
        {
            listSize = 0;
            OSD_GetListSize( fieldId, &listSize );
            if( listSize == 2 )
            {
                OSD_GetListIndex( fieldId, &index );
                break;
            }                           
        }    
        fieldId = OSD_GetNextFieldID( fieldId );
    }
    
    if( fieldId == OSD_ERR_ID_INVALID )
        return FAIL;

    switch( msg->type )
    {      
        case GUIMSG_SELECT:
            if( index == 0 )
            {
                index = 1;
                msg->type = GUIMSG_ASSERT;
                msg->data = &index;
            }
            else
            {
                index = 0;
                msg->type = GUIMSG_DEASSERT;
                msg->data = &index;
            }                

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

        case GUIMSG_LEFT:
        case GUIMSG_DOWN:              
        case GUIMSG_RIGHT:
        case GUIMSG_UP:            
        case GUIMSG_STRING:
        case GUIMSG_VALUE:
            // pass the message as is
            gui_AppAction_GuiMsg( menu->menuId, menu->itemId, msg );
            break;

        default:
            break;
    }    
    
    return PASS;    
}

⌨️ 快捷键说明

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