📄 guistyle_item_radio.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. It will uncheck all other adjacent radio buttons */
int08 guiStyle_item_Radio_SetListIndex( int16 itemId, uint08 index )
{
int16 currentItemId;
int16 tempItemId;
int16 fieldId;
OSDFIELDTYPE fieldType;
uint08 listSize;
uint16 styleId;
uint08 i;
OSD_GetItemStyle( itemId, &styleId );
/* because this function is shared by the '_button' style, we need to convert the itemstyle IDs */
if( styleId == MIST_ITEM_RADIOSTART_BUTTON )
styleId = MIST_ITEM_RADIOSTART;
if( styleId == MIST_ITEM_RADIOMIDDLE_BUTTON )
styleId = MIST_ITEM_RADIOMIDDLE;
if( styleId == MIST_ITEM_RADIOEND_BUTTON )
styleId = MIST_ITEM_RADIOEND;
/* if item is not a radio button, return false. (this should never happen if guiStyle_item_lut is correct) */
if( styleId != MIST_ITEM_RADIOSTART && styleId != MIST_ITEM_RADIOMIDDLE && styleId != MIST_ITEM_RADIOEND )
return FALSE;
/* set currentItemId equal to the beginning of the radio button list */
currentItemId = itemId;
tempItemId = OSD_GetPreviousItemID( currentItemId );
while( tempItemId != OSD_ERR_ID_INVALID )
{
OSD_GetItemStyle( tempItemId, &styleId );
if( styleId == MIST_ITEM_RADIOSTART )
{
currentItemId = tempItemId;
break;
}
if( styleId != MIST_ITEM_RADIOMIDDLE && styleId != MIST_ITEM_RADIOEND )
{
break;
}
currentItemId = tempItemId;
tempItemId = OSD_GetPreviousItemID( currentItemId );
}
OSD_GetItemStyle( currentItemId, &styleId );
for( i=0; i<GUI_STYLE_MAXITEMS && currentItemId != OSD_ERR_ID_INVALID; i++ )
{
/* search thru the fields for all lists in the item */
fieldId = OSD_GetFirstFieldID( currentItemId );
if( fieldId == OSD_ERR_ID_INVALID )
return FAIL;
while( fieldId != OSD_ERR_ID_INVALID )
{
if( OSD_GetFieldType( fieldId, &fieldType ) != PASS )
break;
/* 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 )
{
/* Check only the radio button item specified by itemId */
if( currentItemId == itemId && index == TRUE )
OSD_SetListIndex( fieldId, 1 ); /* checked */
else
OSD_SetListIndex( fieldId, 0 ); /* unchecked */
}
}
fieldId = OSD_GetNextFieldID( fieldId );
}
if( styleId == MIST_ITEM_RADIOEND )
break;
currentItemId = OSD_GetNextItemID( currentItemId );
OSD_GetItemStyle( currentItemId, &styleId );
if( styleId != MIST_ITEM_RADIOSTART && styleId != MIST_ITEM_RADIOMIDDLE && styleId != MIST_ITEM_RADIOEND )
break;
}
return PASS;
}
int08 guiStyle_item_Radio_GuiMsg( GUI_OPEN_MENU *menu, GUIMSG *msg )
{
int16 item;
if( msg == NULL || menu == NULL )
return FAIL;
switch( msg->type )
{
case GUIMSG_SELECT:
item = menu->itemId;
msg->type = GUIMSG_ASSERT;
msg->data = &item;
if( gui_AppAction_GuiMsg( menu->menuId, menu->itemId, msg ) != PASS )
{
/* if no item handler installed, update the display */
guiStyle_item_SetListIndex( menu->itemId, TRUE );
}
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 + -