📄 mfw_mnu.c
字号:
txt = (char*)MmiRsrcGetText((int)txt);
checkPredraw(mnu,mi,&txt,&icn); /* ES!! */
dspl_Clear(ax,ay,(U16)(ax+aw-1),(U16)(ay+ah-1));
/*
zy 2003-02-20 display title icon
*/
/* 2004/06 sunsj modify for picture manage */
DRAW_ICON_LOCATION(ICON_MENUUP, ax, ay);
//dspl_BitBlt(ax, ay, menuup[currentTheme].area.sx, menuup[currentTheme].area.sy, 0, (void*)menuup[currentTheme].icons, 0);
/*
end of zy 2003-02-20
*/
if( dspl_get_char_type()==DSPL_TYPE_ASCII )
{
strncpy(tt,txt,64); /* text in RAM ! */
checkStatus(mnu,ma,mi,tt); /* process this text */
t = tt;
nLines = ah / th; /* text lines in menu area */
for( t2 = t, tLines = 1; *t2; t2++ )
{
if( *t2 == '\n' )
{
tLines++; /* number of item lines */
*t2 = 0; /* make each line a string */
}
}
if( tLines > nLines )
tLines = nLines;
nLines = 0;
while( nLines < tLines )
{
tl = (U16) dspl_str_length(t);
//2004-03-29 Sunny modify
//tw = dspl_GetTextExtent(t,tl);
tw = get_StringWidth(t);
if( tw > aw )
{
tl = dspl_GetMaxTextLen(t,aw);
//2004-03-29 Sunny modify
//tw = dspl_GetTextExtent(t,tl);
tw = get_StringWidth(t);
}
save = *(t + tl);
*(t + tl) = '\0'; /* clip this line */
if( (ma->mode & MNU_ALIGN) == MNU_CENTER )
x = (U16) (ax + (aw - tw) / 2);
else if( (ma->mode & MNU_ALIGN) == MNU_RIGHT )
x = (U16) (ax + aw - tw);
else
x = ax; /* MNU_LEFT (default) */
/*
zy 2003-02-20 english text
*/
// dspl_TextOut(x,(U16)(ay+nLines*th),DSPL_TXTATTR_CURRENT_MODE,t);
drawcolorclarity(x,(U16)(ay+nLines*th),t, 0xffffff);
/*
end of zy change 2003-02-20
*/
*(t + tl) = save; /* restore clipped line */
t += dspl_str_length(t) + 1; /* next line of item */
nLines++;
if( nLines < tLines )
*(t-1) = '\n'; /* restore CR in item */
}
}
else
{
if( (ma->mode & MNU_ALIGN) == MNU_CENTER )
x = (U16) (ax + (aw - tw) / 2);
else if( (ma->mode & MNU_ALIGN) == MNU_RIGHT )
x = (U16) (ax + aw - tw);
else
x = ax; /* MNU_LEFT (default) */
/*
zy 2003-02-20 add chinese language
*/
drawcolorclarity(x,(U16)ay,txt, 0xffffff);
// dspl_TextOut(x,(U16)ay,DSPL_TXTATTR_CURRENT_MODE,txt);
/*
end of zy change 2003-02-20
*/
}
if( icn != NULL )
{ /* show associated icon */
/*
zy change because we need display 120X128 in idle screen,
but we only need display 120X124 in menu avoid softkey display few so we have to
control display at 0,18,120,124
*/
// dspl_BitBlt(icn->area.px,icn->area.py,
// icn->area.sx,icn->area.sy,
// 0,icn->icons,0);
dspl_BitBlt(0,18,
120,124,
0,icn->icons,0);
/*
end of zy 2003-02-20
*/
}
if( oldFont != (U8) -1 )
dspl_SelectFontbyID(oldFont); /* restore previous font */
checkPostdraw(mnu,mi); /* ES!! */
}
/*2003/10/21,talcon,实现二级菜单中跑马灯的效果*/
static int trunMeneText(char* strDest,char* strOrig,const U16 nIndex,const int areaWidth)
{
int nRet = 0;
int nTextWidth;
int nInterval = 1;
char *p = strOrig;
int ncharLen = wstrlen(strOrig);
char *pEnd, *pBegin = strDest;
USHORT chr; //jhxu82add
if( *(unsigned char*)strOrig == 0x80 )
{
nInterval = 2;
*pBegin++ = *strOrig;
p++;
}
//nTextWidth = dspl_GetTextExtent(strOrig,(U16)dspl_str_length(strOrig));
nTextWidth = get_StringWidth(strOrig);
if( nTextWidth <= areaWidth )
{
memcpy(strDest,strOrig,ncharLen + nInterval);
return 0;//nRet;jhxu82 modify
}
p += nIndex * nInterval;//jhxu82add
if(nInterval ==2)
*strDest++ = 0x80;
nTextWidth = 0;
/*memcpy(pBegin,p + nIndex * nInterval, ncharLen - nIndex * nInterval + nInterval);
pEnd = pBegin + (ncharLen-1) - nIndex * nInterval;*/
while( 1 )
{
//nTextWidth = wstrBitlen(strDest) * 8;//= dspl_GetTextExtent(strDest,(U16)dspl_str_length(strDest));
/*nTextWidth = get_StringWidth(strDest);jhxu82
if( nTextWidth <= areaWidth )*/
if(nInterval ==2)
{
chr = ( (*p & 0x00ff) << 8) | (*(p+1) & 0x00ff);
//break;
}
else
{
chr = *p;
//return 1;
}
/* *(--pEnd) = 0;
if( nInterval == 2 )*/
if(chr == 0)/*the end if string*/
return 0;
nTextWidth += get_CharWidth(chr);
if(nTextWidth > areaWidth)
break;
*strDest ++ =*p++;
if(nInterval ==2)
{
*strDest ++ =*p++;
//*(--pEnd) = 0;
}
nRet ++;
}
return 1;//nRet;jhxu82
}//end trunMeneText
/*************************************
$Description:计算menu item 的行数
****************************************/
U8 getListMnuLines(MfwMnu *mnu)
{
MfwMnuAttr *ma = mnu->curAttr;
MfwIcnAttr* icnTitleBar = GET_ICONATTR(ICON_MENUTITLE, 0);//(MfwIcnAttr*)&titleicons[0];/* 2004/06 sunsj modify for icon manage */
return(ma->area->sy - icnTitleBar->area.sy - icnTitleBar->area.py - MNULIST_ITEM_TOPOFFSET)/MNULIST_ITEM_HEIGHT;
}//end getListMnuLines
/*************************************
$Description:计算menu item 区域的Y起始坐标
****************************************/
U8 getListMnuPosY(MfwMnu *mnu)
{
MfwMnuAttr *ma = mnu->curAttr;
MfwIcnAttr* icnTitleBar = GET_ICONATTR(ICON_MENUTITLE, 0);//(MfwIcnAttr*)&titleicons[0];/* 2004/06 sunsj modify for icon manage */
return icnTitleBar->area.sy + icnTitleBar->area.py + MNULIST_ITEM_TOPOFFSET;
}//end getListMnuPosY
static void drawListMenu (MfwMnu *mnu)
{
char *txt;
U8 nTextLen,nTextHgt;
int nPosX,nPosY;
U8 nLines;//menu list 区域所能容纳menu item的行数
U8 nLineFirst,nLineEnd;//需要更新的起始行和结束行;
U8 nLineCurr;//当前选中的行
U8 nLineStep;
U8 i;
MfwMnuAttr *ma = mnu->curAttr;
if( MenuBrowseAction==BrowseInit )
{
MenuBrowseAction = BrowseNew;
}
/*******caculate nLines ,nLineCurr,nLineFist,nLineEnd***************/
nLines = getListMnuLines(mnu);
nLineCurr = mnu->lCursor[(int)mnu->level];
nLineFirst = nLineCurr - nLineCurr%nLines;
nLineEnd = nLineFirst + nLines -1;
if( nLineEnd >= ma->nItems )
nLineEnd = ma->nItems - 1;
nLineStep = 1;
switch( MenuBrowseAction )
{
U8 temp;
case BrowseUp:
temp = getVisibleByStep(mnu,ma,nLineCurr+1,1);
if( temp < nLineFirst || temp> nLineEnd )
{
MenuBrowseAction = BrowseNew;
break;
}
nLineEnd = temp;
nLineFirst = nLineCurr;
nLineStep = nLineEnd - nLineCurr;
break;
case BrowseDown:
temp = getVisibleByStep(mnu,ma,nLineCurr-1,-1);
if( temp < nLineFirst || temp> nLineEnd )
{
MenuBrowseAction = BrowseNew;
break;
}
nLineFirst = temp;
nLineEnd = nLineCurr;
nLineStep = nLineCurr - nLineFirst;
break;
}
/***end caculate nLines ,nLineCurr,nLineFist,nLineEnd***************/
/**************draw title bar and title***************/
if( MenuBrowseAction == BrowseNew )
{
MfwIcnAttr* icnTitleBar = GET_ICONATTR(ICON_MENUTITLE, 0);//(MfwIcnAttr*)&titleicons[0];/* 2004/06 sunsj modify for icon manage */
#if(MAIN_LCD_SIZE==4)
UINT32 color = dspl_SetBkgColor(MNULIST_BKGCOLOR);
dspl_Clear(ma->area->px,ma->area->py,ma->area->px + ma->area->sx, ma->area->py + ma->area->sy);
dspl_SetBkgColor(color);
#endif
#if(MAIN_LCD_SIZE==3)
draw_softkeybar_updown_arrow();//jhxu720
if(phonebook_search_flag==TRUE)
nPosX=0;
else
DRAW_ICON(ICON_MENULISTBKGICONS);
DRAW_ICON_SEL(ICON_MENUTITLE, 0);
DRAW_ICON_SEL(ICON_MENUTITLE, ma->titleicon);
//DRAW_ICON_SEL(ICON_CURRENTBAR,0);
//draw title on right
txt = GetMenuTitleString( mnu, ma ); //获得菜单标题;
nPosX = icnTitleBar->area.sx + icnTitleBar->area.px - get_StringWidth((char *)txt);
nPosX -=2;
if(nPosX < icnTitleBar->area.px)
nPosX = icnTitleBar->area.sx;
nPosY = icnTitleBar->area.py + (icnTitleBar->area.sy - dspl_GetFontHeight())/2;
if(nPosY < icnTitleBar->area.py)
nPosY = icnTitleBar->area.sy;
if(txt)
dspl_TextOut_NoNewline(nPosX, nPosY,DSPL_TXTATTR_TRANSPARENT, (char *)txt);
#endif
#if(MAIN_LCD_SIZE==4)
//draw title bar
DRAW_ICON_SEL(ICON_MENUTITLE, 0);
//draw title icon
DRAW_ICON_SEL(ICON_MENUTITLE, ma->titleicon);
//drawIconByIcnAttr((MfwIcnAttr*)(icontable[ICON_MENUTITLE].icon+ma->titleicon)/*(MfwIcnAttr*)&titleicons[ma->titleicon]*/,0);/* 2004/06 sunsj modify for icon manage */
//draw memu list background
//drawIconByIcnAttr((MfwIcnAttr*)&mnulistbkgicons[0],0);
//draw title on right
if( (ma->mode & MNU_NOTITLE) == 0 )//2004/05/25 yhf modify for game title
{
txt = GetMenuTitleString( mnu, ma ); //获得菜单标题;
nPosX = icnTitleBar->area.sx + icnTitleBar->area.px - get_StringWidth((char *)txt);
nPosX -=2;
if( nPosX < icnTitleBar->area.px )
nPosX = icnTitleBar->area.sx;
/* 2004/05/14 yhf modify */
else if( nPosX > MNULIST_TITLE_POSX )
nPosX = MNULIST_TITLE_POSX ; //菜单标题位置
nPosY = icnTitleBar->area.py + (icnTitleBar->area.sy - dspl_GetFontHeight())/2;
if( nPosY < icnTitleBar->area.py )
nPosY = icnTitleBar->area.sy;
if( txt )
dspl_TextOut_NoNewline(nPosX, nPosY,DSPL_TXTATTR_WHITE_EDGE, (char *)txt);//菜单标题
#if ( MAIN_LCD_SIZE==2 )
if( txt )
dspl_TextOut_NoNewline(nPosX, nPosY,DSPL_TXTATTR_TRANSPARENT, (char *)txt);
#endif
}
#endif
}
//end draw title bar and title
/*********draw menu item *****************/
nPosY = getListMnuPosY(mnu);
for( i = nLineFirst;i <=nLineEnd; i+=nLineStep )
{
drawListMenuItem(mnu,i,nLines,
nPosY,
NULL);
}
/*******end draw menu item *****************/
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
| STATE : code ROUTINE : drawFreeMenu |
+--------------------------------------------------------------------+
PURPOSE : draws menu in overlapped mode
*/
static void drawFreeMenu (MfwMnu *mnu)
{
// ES!! to be revised
//kk needs font entry
int nFontHeight;
int i, x;
int nIdx;
int nTextLen;
MfwIcnAttr * icn;
MfwMnuAttr *wa; /* working attribute */
wa = mnu->curAttr;
dspl_Clear(wa->area->px,wa->area->py,
(U16)(wa->area->sx+wa->area->px-1),
(U16)(wa->area->sy+wa->area->py-1));
nFontHeight = dspl_GetFontHeight();
//2004-03-29 Sunny modify
/*nTextLen = dspl_GetTextExtent(wa->items[mnu->lCursor[mnu->level]].str,
(U16)dspl_str_length(wa->items[mnu->lCursor[mnu->level]].str));*/
nTextLen = get_StringWidth(wa->items[mnu->lCursor[mnu->level]].str);
if( (wa->mode & MNU_ALIGN) == MNU_CENTER )
x = wa->area->px + (wa->area->sx - nTextLen) / 2;
else if( (wa->mode & MNU_ALIGN) == MNU_RIGHT )
x = wa->area->px + wa->area->sx - nTextLen;
else
x = wa->area->px;
dspl_TextOut((U16)x,(U16)(wa->area->py+wa->area->sy-nFontHeight),DSPL_TXTATTR_CURRENT_MODE,
wa->items[mnu->lCursor[mnu->level]].str);
for( i = 0; i < wa->nItems; i++ )
{
nIdx = (mnu->lCursor[mnu->level] + i + 1) % wa->nItems;
icn = wa->items[nIdx].icon;
if( icn != NULL )
dspl_BitBlt(icn->area.px,icn->area.py,
icn->area.sx,icn->area.sy,
0/*icn->usIndex*/,icn->icons,0);
}
}
/************zy Mobile Innovation add this function for draw listicon menu**************/
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
| STATE : code ROUTINE : drawListIconMenu |
+--------------------------------------------------------------------+
PURPOSE : draws menu in ListIcon mode
*/
static void drawListIconMenu (MfwMnu *mnu)
{
MfwMnuAttr *ma; /* menu attributes */
U16 fh, fw; /* font height & width */
U16 ax, ay, aw, ah; /* menu area dimensions */
U16 x;
int nLines;
int nFirstLine, nEndLine,nMenuItemCounts,nLineStep; //ganchh 2002/9/9
int i;
int nIdx;
int nTextLen;
MfwIcnAttr * icn;
int fit;
char *txt; /* item text */
static char tempLine [64]; /* for inverting */
U8 oldFont = -1; /* save previous font */
char t [64]; /* temp item string */
UBYTE temp;
int UniHeight = 16;//zhonghz,12
MfwMnuAttr *attr; /* menu attributes by ST */
UINT32 oldcolor;
int iconIdx;
UINT32 itemUnselect;
if( !mnu->useDefLang ) /*Show ASCII characters if string defined*/
{
temp = dspl_get_char_type();
dspl_set_char_type(DSPL_TYPE_ASCII);
}
ma = mnu->curAttr;
if( ma->font
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -