📄 mfw_mnu.c
字号:
if (txt[0] != 0x80)
dspl_ScrText (txtXpos, yPos, txt, 0);
else
dspl_TextOut(txtXpos, yPos, DSPL_TXTATTR_CURRENT_MODE, txt );
areaLeft->px = xPos;
areaLeft->sx = mnuArea->sx;
areaLeft->py = yPos+sy;
areaLeft->sy = mnuArea->sy-sy;
#ifdef MFW_DEBUG_DISPLAY_SIZE
dspl_DrawRect(xPos,yPos,(xPos+mnuArea->sx-1),(yPos+sy-1));
#endif
resources_restoreMnuColour();
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
| STATE : code ROUTINE : drawPageMenu |
+--------------------------------------------------------------------+
PURPOSE : draws menu in page mode
GW 05/10/01 - Changed single value 'lng' to 2 values indicating if ID's should be
used (useStrID) and if the strings are ascii or unicode (uesDefLang).
*/
void fastCopyBitmap(int startX, int startY, // start position of bitmap
int bmpSx, int bmpSy, //size of bitmap
char* srcBitmap,
int posX, int posY, // start of area to be copied into
int sx, int sy, // size of area to be copied into
U32 bgd_col, int bmptype);
static void drawPageMenu (MfwMnu *mnu)
{
MfwMnuAttr *ma; /* menu attributes */
U16 th, tw, tl; /* text height, width, len */
U16 ax, ay, aw, ah, x; /* menu area dimensions */
int tLines; /* lines in item text */
int nLines; /* lines in menu area */
char *txt, *t2, save; /* item text & clip saver */
MfwIcnAttr * icn; /* item icon */
U8 oldFont = -1; /* save previous font */
MfwMnuItem *mi; /* current item */
char tt [64], *t; /* temp item string */
ma = mnu->curAttr;
if (ma->font != (U8) -1)
oldFont = dspl_SelectFontbyID(ma->font); /* setup font */
ax = ma->area->px; ay = ma->area->py;
aw = ma->area->sx; ah = ma->area->sy;
mi = ma->items + mnu->lCursor[mnu->level];
icn = mi->icon;
txt = mi->str;
resources_setColour(ma->mnuColour);
if ((ma->mode & MNU_HDRFORMAT_STR)==0) /* header is a text ID */
txt = (char*)MmiRsrcGetText((int)txt);
checkPredraw(mnu,mi,&txt,&icn); /* ES!! */
{
MfwRect areaLeft;
mnuDrawHeader(ma,&areaLeft,txt);
ax = areaLeft.px; ay = areaLeft.py;
aw = areaLeft.sx; ah = areaLeft.sy;
}
if ((dspl_getDisplayType()==DSPL_COLOUR) && (ma->bgdBitmap != NULL))
{
MfwRect *bmpArea = &ma->bgdBitmap->area;
if ((ma->bgdBitmap->icons != NULL) && (bmpArea->sx >0) && (bmpArea->sy >0))
{
fastCopyBitmap( (int)bmpArea->px, (int)bmpArea->py, (int)bmpArea->sx, (int)bmpArea->sy,
ma->bgdBitmap->icons,
(int)ax,(int)ay, (int)aw, (int)ah,
dspl_GetBgdColour(),
ma->bgdBitmap->icnType);
}
else
{
dspl_Clear(ax,ay,(U16)(ax+aw-1),(U16)(ay+ah-1));
}
}
else
{
dspl_Clear(ax,ay,(U16)(ax+aw-1),(U16)(ay+ah-1));
}
if (icn != NULL)
{ /* show associated icon */
dspl_BitBlt2(icn->area.px,icn->area.py,
icn->area.sx,icn->area.sy,
icn->icons,0,icn->icnType);
}
if (oldFont != (U8) -1)
dspl_SelectFontbyID(oldFont); /* restore previous font */
checkPostdraw(mnu,mi); /* ES!! */
#ifdef MFW_DEBUG_DISPLAY_SIZE
dspl_DrawRect(ax,ay,(ax+aw-1),(ay+ah-1));
#endif
resources_restoreColour();
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
| STATE : code ROUTINE : drawListMenu |
+--------------------------------------------------------------------+
PURPOSE : draws menu in list mode
GW 05/10/01 - Changed single value 'lng' to 2 values indicating if ID's should be
used (useStrID) and if the strings are ascii or unicode (uesDefLang).
*/
#define MAX_STR_CHAR 64
static void drawListMenu (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 i;
int nIdx;
int nTextLen;
MfwIcnAttr * icn;
int fit;
char *txtStr; /* item text */
char txt[MAX_STR_CHAR];
U8 oldFont = -1; /* save previous font */
UBYTE temp;
int UniHeight = 12;
int simpleScrolling;
int status; /* SPR#998 - SH - Status for each menu item */
const USHORT checkbox_width = 7; /* SPR#998 - SH - Checkbox width in pixels */
const USHORT checkbox_height = 7; /* SPR#998 - SH - Checkbox height in pixels */
const USHORT checkbox_spacing_left = 1; /* SPR#998 - SH - Gap between left edge of menu and checkbox */
const USHORT checkbox_spacing_right = 2; /* SPR#998 - SH - Gap between right edge of checkbox and menu text */
USHORT checkbox_x; /* SPR#998 - SH - X position of checkbox */
USHORT checkbox_y; /* SPR#998 - SH - Y position of checkbox */
TIME_TRACE_EVENT("drawListMenu() start");
ma = mnu->curAttr;
/* SPR#1983 - SH - Ignore language type now */
if (ma->font != (U8) -1)
oldFont = dspl_SelectFontbyID(ma->font); /* setup font */
fh = dspl_GetFontHeight();
fw = dspl_GetTextExtent("X",1); // ES!! only for normal fonts !
//Display header info (if required)
if ((ma->hdrId != 0) && (dspl_getDisplayType()==DSPL_COLOUR))
{
MfwRect areaLeft;
char *hdrStr;
if ((ma->mode & MNU_HDRFORMAT_STR)==0) /* header is a text ID */
hdrStr = MmiRsrcGetText(ma->hdrId);
else
hdrStr = (char*)(ma->hdrId);
mnuDrawHeader(ma,&areaLeft,hdrStr);
ax = areaLeft.px; ay = areaLeft.py;
aw = areaLeft.sx; ah = areaLeft.sy;
}
else
{
ax = ma->area->px; ay = ma->area->py;
aw = ma->area->sx; ah = ma->area->sy;
}
resources_setColour(ma->mnuColour);
dspl_Clear(ax,ay,(U16)(aw+ax-1),(U16)(ah+ay-1));
nLines = ah / fh;
mnu->nLines = nLines; //Store the number of lines we are drawing for scrolling up/down
{
// TRACE_EVENT_P5(" ax:%d ay:%d aw:%d ah:%d lines:%d",ax,ay,aw,ah, nLines);
}
if ((!mnu->scrollMode)||(countVisible(mnu,ma,ma->nItems)<=nLines)) /* Simple scrolling */
simpleScrolling = TRUE;
else
simpleScrolling = FALSE;
if (simpleScrolling)
{
nIdx = (countVisible(mnu,ma,mnu->lCursor[mnu->level])/nLines)*nLines;
}
else
{
int count=mnu->lShift[mnu->level];
int index= mnu->lCursor[mnu->level]+1;
int nVisibles = countVisible(mnu,ma,ma->nItems);
while (ma->items[index-1].flagFunc(mnu,ma,&(ma->items[index-1])) & MNU_ITEM_HIDE)
{
index++;
}
while (count>0){
if (index<=0)
index = ma->nItems-1;
else
index--;
if (!(ma->items[index].flagFunc(mnu,ma,&(ma->items[index]))& MNU_ITEM_HIDE))
count--;
}
if (nVisibles<nLines)
nLines = nVisibles;
nIdx = index;
}
for (i = 0; i < nLines; nIdx++) /* ES!! not so nice... */
{
if (nIdx >= ma->nItems)
{
if (simpleScrolling)
break;
else
nIdx=0;
}
if (ma->items[nIdx].flagFunc(mnu,ma,&(ma->items[nIdx]))
& MNU_ITEM_HIDE)
continue;
if (mnu->useStrID) /* use language handler */
txtStr = (char*)MmiRsrcGetText((int)ma->items[nIdx].str); //JVJE
else
txtStr = ma->items[nIdx].str;
icn = ma->items[nIdx].icon;
checkPredraw(mnu,ma->items+nIdx,&txtStr,&icn); /* ES!! */
memcpy(txt,txtStr,MAX_STR_CHAR);
status = checkStatus(mnu,ma,ma->items+nIdx,txt); /* SPR#998 - SH - Store the resulting status */
if ((mnu->useStrID) &&
((ma->mode & MNU_DISPLAY) == MNU_LIST_COLOUR))
{
resources_setColourMnuItem( (int)ma->items[nIdx].str );
}
nTextLen = dspl_GetTextExtent(txt,(U16)dspl_str_length(txt));
/* SPR#998 - SH - If list is a checkbox list, include space for checkbox in width */
if (status==MNU_ITEM_CHECKED || status==MNU_ITEM_UNCHECKED)
{
nTextLen+=(checkbox_spacing_left+checkbox_width+checkbox_spacing_right);
}
/* end of SPR#998 */
if ((ma->mode & MNU_ALIGN) == MNU_CENTER)
x = (U16) (ax + (aw - nTextLen) / 2);
else if ((ma->mode & MNU_ALIGN) == MNU_RIGHT)
x = (U16) (ax + aw - nTextLen);
else
x = (U16) (ax + fw); /* MNU_LEFT (default) */
if ((ma->mode & MNU_ITEMSEL) == MNU_CUR_LINE)
x =ax;
/* SPR#998 - SH - Draw checkboxes if required */
if (status==MNU_ITEM_CHECKED || status==MNU_ITEM_UNCHECKED)
{
checkbox_x = x+checkbox_spacing_left;
checkbox_y = ay+i*fh+(fh-checkbox_height)/2;
if (status==MNU_ITEM_CHECKED)
{
/* NOTE: for some reason, a filled rect must have x2, y2 +1 of the same size
* of unfilled rect...compare parameters here and below */
dspl_DrawFilledRect(checkbox_x, checkbox_y, checkbox_x+checkbox_width+1,
checkbox_y+checkbox_height+1);
}
else
{
dspl_DrawRect(checkbox_x, checkbox_y, checkbox_x+checkbox_width,
checkbox_y+checkbox_height);
}
x+=(checkbox_spacing_left+checkbox_width+checkbox_spacing_right); /* Text box now starts just to the right of checkbox */
}
/* end of SPR#998 */
{
#ifdef NO_ASCIIZ
/*MC, use universal height rather than smaller chinese font height*/
/*MC, SPR1526, send whole string to dspl_TextOut, rather than missing out unicode tag*/
/* SPR#1983 - SH - If unicode is set, send text as unicode */
if (txt[0] == 0x80 || mnu->textDCS==MNU_LIST_LANGUAGE_UNICODE)
dspl_TextOut(x,(U16)ay+i*fh/*MC, 1319*/,DSPL_TXTATTR_UNICODE,txt);
else
#endif
dspl_TextOut(x,(U16)(ay+i*fh),DSPL_TXTATTR_CURRENT_MODE,txt);
}
if (nIdx == mnu->lCursor[mnu->level])
{
if ((ma->mode & MNU_ITEMSEL) == MNU_FRAMED)
dspl_DrawRect(ax,(U16)(ay+i*fh),(U16)(aw-2+ax),
(U16)(fh-1+ay+i*fh));
else if ((ma->mode & MNU_ITEMSEL) == MNU_CUR_ARROW)
dspl_TextOut(ax,(U16)(ay+i*fh),DSPL_TXTATTR_CURRENT_MODE,">");
else if ((ma->mode & MNU_ITEMSEL) == MNU_CUR_STAR)
dspl_TextOut(ax,(U16)(ay+i*fh),DSPL_TXTATTR_CURRENT_MODE,"*");
else if ((ma->mode & MNU_ITEMSEL) == MNU_CUR_BLOCK)
dspl_TextOut(ax,(U16)(ay+i*fh),
DSPL_TXTATTR_CURRENT_MODE|DSPL_TXTATTR_INVERS," ");
else if ((ma->mode & MNU_ITEMSEL) == MNU_CUR_LINE)
{
if (dspl_getDisplayType()==DSPL_BW)
{
dspl_DrawFilledColRect(x,ay+i*fh,aw,ay+(i+1)*fh,0x00FFFFFF);
#ifdef NO_ASCIIZ
/* SPR#1983 - SH - If unicode is set, send text as unicode */
if (txt[0] == 0x80 || mnu->textDCS==MNU_LIST_LANGUAGE_UNICODE)
dspl_TextOut(x,(U16)ay+i*fh/*MC, 1319*/,DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,txt);
else
#endif
{
dspl_TextOut(x,(U16)(ay+i*fh),DSPL_TXTATTR_CURRENT_MODE|DSPL_TXTATTR_INVERS,txt);
}
}
else
{
resources_setHLColour(ma->mnuColour);
dspl_DrawFilledBgdRect(x,ay+i*fh,aw,ay+(i+1)*fh);
#ifdef NO_ASCIIZ
/* SPR#1983 - SH - If unicode is set, send text as unicode */
if (txt[0] == 0x80 || mnu->textDCS==MNU_LIST_LANGUAGE_UNICODE)
{
dspl_TextOut(x,(U16)ay+i*fh/*MC, 1319*/,DSPL_TXTATTR_UNICODE,txt);
}
else
#endif
{
dspl_TextOut(x,(U16)(ay+i*fh),DSPL_TXTATTR_CURRENT_MODE,txt);
}
resources_restoreMnuColour();
}
}
if (icn != NULL && icn->nIcons > nIdx)
{
dspl_BitBlt2(icn->area.px,icn->area.py,
icn->area.sx,icn->area.sy,
icn->icons,(U16)nIdx,0);
}
}
i++;
checkPostdraw(mnu,ma->items+nIdx); /* ES!! */
}
if (oldFont != (U8) -1)
dspl_SelectFontbyID(oldFont); /* restore previous font */
/* SPR#1983 - SH - No longer have to change text type back */
resources_restoreColour();
#ifdef MFW_DEBUG_DISPLAY_SIZE
dspl_DrawRect(ax,ay,(ax+aw-1),(ay+ah-1));
#endif
TIME_TRACE_EVENT("drawListMenu() end");
}
/*
+--------------------------------------------------------------------+
| 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();
nTextLen = dspl_GetTextExtent(wa->items[mnu->lCursor[mnu->level]].str,
(U16)dspl_str_length(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);
}
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
| STATE : code ROUTINE : mnuCommand |
+--------------------------------------------------------------------+
PURPOSE : handle mfw windows command
*/
static int mnuCommand (U32 cmd, void *h)
{
switch (cmd)
{
case MfwCmdDelete: /* delete me */
if (!h)
return 0;
mnuDelete(h);
return 1;
case MfwCmdUpdate: /* repaint */
if (!h || ((MfwHdr *) h)->type != MfwTypMnu)
return 0;
mnuUpdate(((MfwHdr *) h)->data);
return 1;
default:
break;
}
return 0;
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
| STATE : code ROUTINE : mnuScrollMode |
+--------------------------------------------------------------------+
PURPOSE : handle mfw windows command
*/
void mnuScrollMode (MfwHnd menu,U8 mode)
{
MfwMnu *mnu;
if ((mnu = mfwControl(menu)) == 0)
return;
mnu->scrollMode = mode;
}
void mnuInitDataItem(MfwMnuItem* mnuItem)
{
mnuItem->icon = 0;
mnuItem->exta = 0;
mnuItem->menu = 0;
mnuItem->func = 0;
mnuItem->str = NULL;
mnuItem->flagFunc = 0;
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
| STATE : code ROUTINE : mnuIdentify |
+--------------------------------------------------------------------+
PURPOSE : SPR998 - SH - Identify menu option. Returns the index of the option, or -1
if option is not found.
*/
int mnuIdentify(struct MfwMnuAttrTag *attr, struct MfwMnuItemTag *item)
{
int index;
int currentOption;
/* Identify current menu option */
currentOption = -1;
for (index=0; index < attr->nItems; index++)
{
if (&attr->items[index]==item)
currentOption = index;
}
return currentOption;
}
MMI_TRACE_P1(char* str, int err)
{
TRACE_EVENT_P2("%s:%d",str,err);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -