📄 guistyle_sub.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 <stdio.h>
#include "common.h"
#include "osd.h"
#include "rta_mem.h"
#include "guiStyle.h"
#include "guiStyle_sub.h"
extern uint32 ID_StyleMemPool;
/* allocate memory for a new menu */
int08 guiStyle_sub_AddTopMenuStruct( GUI_OPEN_MENU **guiTopMenu )
{
GUI_OPEN_MENU *newTopMenu;
if( guiTopMenu == NULL )
return FAIL;
if( RTA_MemRequest( ID_StyleMemPool, sizeof( GUI_OPEN_MENU ), (void **)&newTopMenu ) == PASS )
{
newTopMenu->previousMenu = *guiTopMenu;
newTopMenu->menuId = OSD_ERR_ID_INVALID;
newTopMenu->itemId = OSD_ERR_ID_INVALID;
newTopMenu->hiddenItemList = NULL;
*guiTopMenu = newTopMenu;
}
else
{
/*printf("\r\nMem pool %d full: GUI unable to allocate open menu list", ID_StyleMemPool ); */
return FAIL;
}
return PASS;
}
/* deallocate memory for a new menu */
int08 guiStyle_sub_RemoveOpenMenuStruct( GUI_OPEN_MENU **guiTopMenu, GUI_OPEN_MENU *menu )
{
GUI_OPEN_MENU *temp; /* used to search thru link list */
GUI_OPEN_MENU *temp2; /* used to store previous item in link list */
if( guiTopMenu == NULL || menu == NULL )
return FAIL;
temp = *guiTopMenu;
temp2 = temp;
while( temp != NULL )
{
if( temp == menu )
{
if( temp == *guiTopMenu )
{
*guiTopMenu = temp->previousMenu;
}
else
{
temp2->previousMenu = temp->previousMenu;
}
if( RTA_MemRelease( temp ) != PASS )
{
/*printf("\r\nProblem releasing memory in GUI open menu list" ); */
return FAIL;
}
else
{
return PASS;
}
}
temp2 = temp;
temp = temp->previousMenu;
}
return FAIL;
}
/************************************************************
* This functions implements the following features:
*
* - if the item is the first in the menu, select the last item
* - if the item has a non-navigable style, skip it
************************************************************/
int16 guiStyle_sub_GetPreviousItem( int16 itemId, GUI_STYLE_HIDDEN_ITEM *hiddenItemList, BOOL wrap )
{
int16 newId, tempId;
uint08 i, j;
uint16 styleId;
newId = OSD_GetPreviousItemID( itemId );
for( i=0; i<GUI_STYLE_MAXITEMS && newId != itemId; i++ )
{
/* check if it is the first item and wrap around */
if( newId == OSD_ERR_ID_INVALID )
{
if( wrap == FALSE )
return OSD_ERR_ID_INVALID;
/* find the last item */
tempId = itemId;
for( j=0; j<GUI_STYLE_MAXITEMS && tempId!=OSD_ERR_ID_INVALID; j++ )
{
newId=tempId;
tempId = OSD_GetNextItemID( newId );
}
}
/* if there are no valid items, break */
if( newId == OSD_ERR_ID_INVALID )
{
break;
}
/* check if the item can be selected based on its style ID */
OSD_GetItemStyle( newId, &styleId );
if( styleId >= MIST_ITEM_GENERIC_NAVIGABLE )
{
if( guiStyle_sub_IsHiddenItem( hiddenItemList, newId ) == FALSE )
break;
}
newId = OSD_GetPreviousItemID( newId );
}
if( newId != OSD_ERR_ID_INVALID && newId != itemId )
{
return newId;
}
return OSD_ERR_ID_INVALID;
}
/************************************************************
* This functions implements the following features:
*
* - if the item is the last in the menu, select the first item
* - if the item has a non-navigable style, skip it
************************************************************/
int16 guiStyle_sub_GetNextItem( int16 itemId, GUI_STYLE_HIDDEN_ITEM *hiddenItemList, BOOL wrap )
{
int16 newId, tempId;
uint08 i, j;
uint16 styleId;
newId = OSD_GetNextItemID( itemId );
for( i=0; i<GUI_STYLE_MAXITEMS && newId != itemId; i++ )
{
/* check if it is the first item and wrap around */
if( newId == OSD_ERR_ID_INVALID )
{
if( wrap == FALSE )
return OSD_ERR_ID_INVALID;
/* find the last item */
tempId = itemId;
for( j=0; j<GUI_STYLE_MAXITEMS && tempId!=OSD_ERR_ID_INVALID; j++ )
{
newId=tempId;
tempId = OSD_GetPreviousItemID( newId );
}
}
/* if there are no valid items, break */
if( newId == OSD_ERR_ID_INVALID )
{
break;
}
/* check if the item can be selected based on its style ID */
OSD_GetItemStyle( newId, &styleId );
if( styleId >= MIST_ITEM_GENERIC_NAVIGABLE )
{
if( guiStyle_sub_IsHiddenItem( hiddenItemList, newId ) == FALSE )
break;
}
newId = OSD_GetNextItemID( newId );
}
if( newId != OSD_ERR_ID_INVALID && newId != itemId )
{
return newId;
}
return OSD_ERR_ID_INVALID;
}
/******************************************************
*This function returns the first navigable item.
*
*****************************************************/
int16 guiStyle_sub_GetFirstItem( int16 menuId, GUI_STYLE_HIDDEN_ITEM *hiddenItemList )
{
int16 itemId;
uint08 i;
uint16 styleId;
itemId = OSD_GetFirstMenuItemID( menuId );
for( i=0; i<GUI_STYLE_MAXITEMS && itemId!=OSD_ERR_ID_INVALID; i++ )
{
OSD_GetItemStyle( itemId, &styleId );
if( styleId >= MIST_ITEM_GENERIC_NAVIGABLE )
{
if( guiStyle_sub_IsHiddenItem( hiddenItemList, itemId ) == FALSE )
return itemId;
}
itemId = OSD_GetNextItemID( itemId );
}
return OSD_ERR_ID_INVALID;
}
/******************************************************
*This function adds an entry to a menu's list of currently
* disabled items
*
*****************************************************/
int08 guiStyle_sub_AddHiddenItem( GUI_OPEN_MENU *menu, int16 itemId )
{
GUI_STYLE_HIDDEN_ITEM *newHiddenItem;
if( menu == NULL )
return FAIL;
if( RTA_MemRequest( ID_StyleMemPool, sizeof( GUI_STYLE_HIDDEN_ITEM ), (void **)&newHiddenItem ) == PASS )
{
newHiddenItem->next = menu->hiddenItemList;
menu->hiddenItemList = newHiddenItem;
newHiddenItem->itemId = itemId;
}
else
{
/*printf("\r\nMem pool %d full: GUI unable to allocate hidden item list", ID_StyleMemPool ); */
return FAIL;
}
return PASS;
}
/******************************************************
*This function removes an entry from a menu's list of
* currently disabled items
*
*****************************************************/
int08 guiStyle_sub_RemoveHiddenItem( GUI_OPEN_MENU *menu, int16 itemId )
{
GUI_STYLE_HIDDEN_ITEM *temp; /* used to search thru link list */
GUI_STYLE_HIDDEN_ITEM *temp2; /* used to store previous item in link list */
if( menu == NULL )
return FAIL;
temp = menu->hiddenItemList;
temp2 = temp;
while( temp != NULL )
{
if( temp->itemId == itemId )
{
if( temp == menu->hiddenItemList )
{
menu->hiddenItemList = temp->next;
}
else
{
temp2->next = temp->next;
}
if( RTA_MemRelease( temp ) != PASS )
{
/*printf("\r\nProblem releasing memory in GUI hidden item list" ); */
return FAIL;
}
else
{
return PASS;
}
}
temp2 = temp;
temp = temp->next;
}
return FAIL;
}
/******************************************************
*This function removes all entries from a menu's list of
* currently disabled items. This should be
* called whenever closing a menu that uses the hidden item list.
*
*****************************************************/
int08 guiStyle_sub_RemoveHiddenItemList( GUI_OPEN_MENU *menu )
{
GUI_STYLE_HIDDEN_ITEM *temp; /* used to search thru link list */
if( menu == NULL )
return FAIL;
while( menu->hiddenItemList != NULL )
{
temp = menu->hiddenItemList;
menu->hiddenItemList = menu->hiddenItemList->next;
if( RTA_MemRelease( temp ) != PASS )
{
/*printf("\r\nProblem releasing memory in GUI hidden item list" ); */
return FAIL;
}
}
return PASS;
}
/******************************************************
*This function returns whether an itemId is currently
* in the hidden items list
*
*****************************************************/
BOOL guiStyle_sub_IsHiddenItem( GUI_STYLE_HIDDEN_ITEM *hiddenItemList, int16 itemId )
{
while( hiddenItemList != NULL )
{
if( hiddenItemList->itemId == itemId )
{
return TRUE;
}
hiddenItemList = hiddenItemList->next;
}
return FALSE;
}
/******************************************************
*This function creates a dynamic field string from a number.
*
*****************************************************/
int08 guiStyle_sub_IntToDynamicTextString( int32 value, uint16 *string, BOOL hex )
{
uint08 i;
uint08 stringBuf[6];
int08 numchars;
if( hex == TRUE )
numchars = snprintf((char *)stringBuf, 6, "%X", value);
else
numchars = snprintf((char *)stringBuf, 6, "%d", value);
if ( numchars <= 4 )
{
for( i=0; i<6 && stringBuf[i]!=0; i++ )
string[i] = stringBuf[i];
}
if( i < 6 )
string[i] = 0;
else
string[5] = 0;
return numchars;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -