📄 guistyle_item_sliderwithtext.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 implements the OSD API calls for adjusting the
* display on items with sliders and dynamic text. */
int08 guiStyle_item_SliderWithText_SetSingleValue( int16 itemId, int32 value, int32 min, int32 max )
{
int16 fieldId;
OSDFIELDTYPE fieldType;
uint16 steps;
uint16 string[6];
/* check that everything is in range to avoid divide by zero */
if( max < min )
return FAIL;
if( value > max || value < min )
return FAIL;
/* search thru the fields for all Dynamic Text and Winsliders 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;
/* if we found the Dynamic Text, display the argument value appropriately */
if( fieldType == DYNA_TEXT )
{
/* convert the argument value directly into a unicode string and display */
guiStyle_sub_IntToDynamicTextString( value, string, FALSE );
if( OSD_GetLanguageDirection( OSD_GetLanguage()) )
{
/* use default font style instead of arabic font style for RTL language */
OSD_SetDynaTextStringSpecial( fieldId, string, STYL_STYLE_2, TRUE );
}
else
{
OSD_SetDynaTextString( fieldId, string );
}
}
/* if we found a Winslider or Charslider, display the argument value appropriately */
if( fieldType == SLIDER_WIN || fieldType == SLIDER_CHAR )
{
/* Display the value as a percentage of the slider */
OSD_GetSliderSteps( fieldId, &steps );
/* the 'number of steps' for Winsliders does not include the zero position */
/* this adjustment makes Winsliders consistent with Charsliders */
if( fieldType == SLIDER_WIN )
steps += 1;
if( max == min )
OSD_SetSliderValue( fieldId, steps/2 );
else if( steps != 0 )
OSD_SetSliderValue( fieldId, ((value-min)*(steps-1))/(max - min) );
}
fieldId = OSD_GetNextFieldID( fieldId );
}
return PASS;
}
int08 guiStyle_item_SliderWithText_GuiMsg( GUI_OPEN_MENU *menu, GUIMSG *msg )
{
int16 fieldId;
OSDFIELDTYPE fieldType;
uint16 value;
uint16 steps;
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 == SLIDER_WIN || fieldType == SLIDER_CHAR )
{
/* Get the list size and current index value */
steps = 0;
value = 0;
OSD_GetSliderSteps( fieldId, &steps );
OSD_GetSliderValue( fieldId, &value );
break;
}
fieldId = OSD_GetNextFieldID( fieldId );
}
if( fieldId == OSD_ERR_ID_INVALID )
return FAIL;
switch( msg->type )
{
case GUIMSG_LEFT:
if( value > 0 )
value--;
msg->type = GUIMSG_DEC;
msg->data = &value;
break;
case GUIMSG_DOWN:
msg->type = GUIMSG_DEC_Y;
msg->data = &value;
break;
case GUIMSG_RIGHT:
if( value < steps )
value++;
msg->type = GUIMSG_INC;
msg->data = &value;
break;
case GUIMSG_UP:
msg->type = GUIMSG_INC_Y;
msg->data = &value;
break;
case GUIMSG_SELECT:
msg->type = GUIMSG_ASSERT;
msg->data = &value;
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_SliderWithText_SetSingleValue( menu->itemId, value, 0, steps );
}
return PASS;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -