📄 mmiresources.c
字号:
/*******************************************************************************
$Function:
$Description:
$Returns:
$Arguments:
$History
*******************************************************************************/
void resources_restoreColour(void)
{
dspl_SetFgdColour( oldFgdCol);
dspl_SetBgdColour( oldBgdCol);
}
/*******************************************************************************
$Function:
$Description:
$Returns:
$Arguments:
$History
GW 28/11/02 -
*******************************************************************************/
void resources_restoreMnuColour(void)
{
dspl_SetFgdColour( oldmnuFgdCol);
dspl_SetBgdColour( oldmnuBgdCol);
}
/*******************************************************************************
$Function:
$Description:
$Returns:
$Arguments:
$History
GW 28/11/02 -
*******************************************************************************/
void getDisplayData(int txtId,int *colDisplayType, int *colType, int *colFgdSelect)
{
*colFgdSelect = NO_COL;
/**/
switch (txtId)
{
default:
*colFgdSelect = NO_COL;
break;
case TxtIdleScreenBackground:
*colDisplayType = COLOUR_IDLE;
*colType = COL_TYPE_SCREEN;
*colFgdSelect = BGD_COL;
break;
case TxtIdleScreenSoftKey:
*colDisplayType = COLOUR_IDLE;
*colType = COL_TYPE_SK;
*colFgdSelect = FGD_COL;
break;
case TxtIdleScreenText:
*colDisplayType = COLOUR_IDLE;
*colType = COL_TYPE_SCREEN;
*colFgdSelect = FGD_COL;
break;
case TxtIdleScreenNetworkName:
*colDisplayType = COLOUR_IDLE;
*colType = COL_TYPE_SCREEN;
*colFgdSelect = FGD_COL;
break;
case TxtGeneralBackground:
*colDisplayType = COLOUR_LIST_MAIN;
*colType = COL_TYPE_SCREEN;
*colFgdSelect = BGD_COL;
break;
case TxtMenuSoftKeyForeground:
*colDisplayType = COLOUR_LIST_MAIN;
*colType = COL_TYPE_SK;
*colFgdSelect = FGD_COL;
break;
case TxtMenuSoftKeyBackground:
*colDisplayType = COLOUR_LIST_MAIN;
*colType = COL_TYPE_SK;
*colFgdSelect = BGD_COL;
break;
case TxtSubMenuHeadingText:
*colDisplayType = COLOUR_LIST_SUBMENU;
*colType = COL_TYPE_TITLE;
*colFgdSelect = FGD_COL;
break;
case TxtSubMenuHeadingBackground:
*colDisplayType = COLOUR_LIST_SUBMENU;
*colType = COL_TYPE_TITLE;
*colFgdSelect = BGD_COL;
break;
case TxtSubMenuTextForeground:
*colDisplayType = COLOUR_LIST_SUBMENU;
*colType = COL_TYPE_SCREEN;
*colFgdSelect = FGD_COL;
break;
case TxtSubMenuTextBackground:
*colDisplayType = COLOUR_LIST_SUBMENU;
*colType = COL_TYPE_SCREEN;
*colFgdSelect = BGD_COL;
break;
case TxtSubMenuSelectionBar:
*colDisplayType = COLOUR_LIST_SUBMENU;
*colType = COL_TYPE_HL;
*colFgdSelect = BGD_COL;
break;
case TxtPopUpTextForeground:
*colDisplayType = COLOUR_POPUP;
*colType = COL_TYPE_SCREEN;
*colFgdSelect = FGD_COL;
break;
case TxtPopUpTextBackground:
*colDisplayType = COLOUR_POPUP;
*colType = COL_TYPE_SCREEN;
*colFgdSelect = BGD_COL;
break;
}
/**/
}
/*******************************************************************************
$Function:
$Description:
$Returns:
$Arguments:
$History
*******************************************************************************/
//This is called to set the colour of menu items controlled by the text id's
int resources_getColourFromText(int txtId)
{
U32 col;
switch (txtId)
{
case TxtColourBlack: col = COL_Black; break;
case TxtColourBlue: col = COL_Blue; break;
case TxtColourCyan: col = COL_Cyan; break;
case TxtColourGreen: col = COL_Green; break;
case TxtColourMagenta: col = COL_Magenta; break;
case TxtColourYellow: col = COL_Yellow; break;
case TxtColourRed: col = COL_Red; break;
case TxtColourWhite: col = COL_White; break;
case TxtColourPink: col = COL_Pink; break;// 0x00FF4040; break;
case TxtColourOrange: col = COL_Orange; break;
case TxtColourLightBlue: col = COL_LightBlue; break;// 0x004040FF; break;
case TxtColourLightGreen: col = COL_LightGreen; break;// 0x0040FF40; break;
case TxtColourPaleYellow: col = COL_PaleYellow; break;// 0x00FFFF40; break;
case TxtColourTransparent: col = COL_Transparent; break;
default: col = NO_COLOUR_DEFINED;
}
return (col);
}
/*******************************************************************************
$Function:
$Description:
$Returns:
$Arguments:
$History
GW 28/11/02 -
*******************************************************************************/
void resources_setColourMnuItem( int txtId)
{
U32 col = NO_COLOUR_DEFINED;
int colType;
int colFgdSelect = FALSE;
int colDisplayType;
U32 fgd,bgd;
col = resources_getColourFromText(txtId);
if (col == NO_COLOUR_DEFINED)
{
getDisplayData(txtId, &colDisplayType, &colType,&colFgdSelect);
getDataColour(colDisplayType, colType, &fgd, &bgd);
switch (colFgdSelect)
{
case FGD_COL: col = fgd; break;
case BGD_COL: col = bgd; break;
default: break;
}
}
if (col != NO_COLOUR_DEFINED)
{
if (col!=COL_Transparent)
{
dspl_SetFgdColour( col );
dspl_SetBgdColour( (~col) & 0x00FFFFFF );
}
else
{
dspl_SetFgdColour( COL_Black );
dspl_SetBgdColour( COL_Magenta );
}
}
}
/*******************************************************************************
$Function:
$Description:
$Returns:
$Arguments:
$History
*******************************************************************************/
int res_getTitleHeight( void )
{
if (Mmi_getCurrentLanguage() != CHINESE_LANGUAGE)
{
return(TITLE_HEIGHT_LATIN);
}
else
{
return(TITLE_HEIGHT_CHINESE);
}
}
/*Function added for SPr 1442*/
/*******************************************************************************
$Function: string_len_in_bytes
$Description: internal function which returns th length of a string in bytes
$Returns: length of string
$Arguments: string, maximum possibel length, whether unicode or not
*******************************************************************************/
int string_len_in_bytes(char* string, int max_len, int unicode)
{ int i;
int length=0;
/* if unicode, nee to check for double-NULL termination*/
if (string[0] == 0x80 || unicode== TRUE)
{
for(i=0; i < max_len; i+=2)
{ if (string[i] == 0 && string[i+1]==0)
{ length = i;
break;
}
}
return length;
}
else/*just use standard function*/
{ return strlen(string);
}
}
#ifdef LSCREEN
#define TRUNC_LENGTH 3 /*... at end of string in D-sample*/
#else
#define TRUNC_LENGTH 1/* . at end of string in c-sample*/
#endif
/*Function added for SPr 1442*/
/*******************************************************************************
$Function: resources_truncate_to_screen_width
$Description: Copies and truncates the input string to the passed screen width
and puts it into the output string.
Note: this function only works for Unicode strings which have a unicode
tag at the beginning, or if the unicode parameter is set to TRUE.
If the input length is zero, then this function calculates
the actual length of the input string.
$Returns: length of truncated string
$Arguments: input sctring and it's length, ouput string and it's length,
screen width desired (pixels), unicode flag (TRUE/FALSE)
*******************************************************************************/
//GW #1541 16/01/03 - Modified code to first test if string will fit and return string if it does.
int resources_truncate_to_screen_width(char* IpStr, int IpLen, char* OpStr, int OpLen,
int ScreenWidth, BOOL unicode)
{
int start_position = 0;
#ifdef LSCREEN
char* ellipse_str = "...";
#else
char* ellipse_str = ".";
#endif
int ellipsis_len = dspl_GetTextExtent(ellipse_str, 0);
int i;
int j;
int calc_input_len = 0;
int no_of_chars = 0;
memset(OpStr, 0, OpLen);
/*if input string length 0, we calculate the string len ourselves*/
if (IpLen == 0)
{ calc_input_len = string_len_in_bytes(IpStr, 256, unicode);
}
else
{ calc_input_len = IpLen;
} /*Test for string alrady fitting */
if (dspl_GetTextExtent(IpStr, 0) < ScreenWidth)
{
for (i=0; i<OpLen && i<calc_input_len; )
{ //if length of string less that width of screen
//if unicode copy two chars
if (IpStr[0] == 0x80 || unicode == TRUE)
{
OpStr[i] = IpStr[i];
OpStr[i+1] = IpStr[i+1];
i+=2;
}
else
{ OpStr[i] = IpStr[i];
i++;
}
}
return string_len_in_bytes(OpStr, OpLen, unicode);
}
/*SPR 1541, use function dspl_GetNcharToFit rather than loop to work
out how many chars will fit in line*/
no_of_chars = dspl_GetNcharToFit (IpStr, ScreenWidth - ellipsis_len);
/*copy characters*/
if (no_of_chars < OpLen)
memcpy(OpStr, IpStr, no_of_chars);
else
memcpy(OpStr, IpStr, OpLen);
/*SPR 1541, end*/
TRACE_EVENT_P1("trunc string len:%d", dspl_GetTextExtent(OpStr, 0));
/*we need to add the ellipsis if we've truncated the string*/
if(string_len_in_bytes(OpStr, OpLen, unicode) < calc_input_len)
{ /*if unicode*/
if (OpStr[0] == 0x80|| unicode == TRUE)
{
if (string_len_in_bytes(OpStr, OpLen, TRUE) < (OpLen -2*TRUNC_LENGTH+2))
{ start_position = string_len_in_bytes(OpStr, OpLen, unicode);
}
else
{ start_position = OpLen - 2*TRUNC_LENGTH+2;}
TRACE_EVENT_P1("Adding chars at %d", start_position);
for(j=start_position; j < start_position+2*TRUNC_LENGTH; j+=2)
{ OpStr[j] = 0;
OpStr[j + 1] = '.';
}
/*add NULL termination*/
OpStr[start_position+ 2*TRUNC_LENGTH] = NULL;
OpStr[start_position+ 2*TRUNC_LENGTH+1] = NULL;
}
else /*if ASCII*/
{ if (strlen(OpStr) < (OpLen -(TRUNC_LENGTH+1)))
{ start_position = string_len_in_bytes(OpStr, OpLen, FALSE);
}
else
{ start_position = OpLen - TRUNC_LENGTH;}
memcpy(&OpStr[start_position], ellipse_str, TRUNC_LENGTH);
}
}
TRACE_EVENT_P1("trunc string len post ellipsis:%d", dspl_GetTextExtent(OpStr, 0));
return string_len_in_bytes(OpStr, OpLen, unicode);
}
/*******************************************************************************
$Function:
$Description:
$Returns:
$Arguments:
$History
GW 28/11/02 -
*******************************************************************************/
int colMenuSelected(MfwMnu* mnu, MfwMnuItem* mnuItem)
{
T_MFW_HND win = mfw_parent(mfw_header());
int mnuId;
int colDisplayType;
int colType;
int colFgdSelect = FALSE;
int mnuColour;
int storedMenuId;
//GW Read the stored menu Id from generic procedure
storedMenuId = MmiBook_getStoredOption();
mnuId = (int)mnuItem->str;
mnuColour=resources_getColourFromText(mnuId);
getDisplayData(storedMenuId, &colDisplayType, &colType,&colFgdSelect);
setDataColour(colDisplayType, colType, colFgdSelect,mnuColour);
info_screen(win, TxtColour, TxtSelected, 0);
// API/GW - Saved the selected colour so the flash file structure after selected
flash_data_write(colourFileDir, colourFileName, colArray, sizeof(colArray));
return(0);
}
/*******************************************************************************
$Function: set_SIMToolkit_title_string
$Description: Changes the value of the SAT main menu entry title.
$Returns:
$Arguments: New SAT Title.
*******************************************************************************/
void res_set_SIMToolkit_title_string(char* SAT_string)
{
SIMToolKitString = SAT_string;
}
/*******************************************************************************
End of File
*******************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -