2025-06-27 00:32:57 +08:00
|
|
|
|
#include "mywin_user_menu.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define WIN_MENU_TYPE "WIN_MenuStruct"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WIN_MenuStruct *WIN_CreatMenu (WIN_WindowStruct *base,
|
|
|
|
|
void (*msgLoop)(struct _WIN_WindowStruct *win,WIN_MsgStruct *msg),
|
|
|
|
|
int x,int y,int x_size,int y_size)
|
|
|
|
|
{
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣѭ<CFA2><D1AD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
if (msgLoop==0)
|
|
|
|
|
{
|
|
|
|
|
msgLoop=(void (*)(struct _WIN_WindowStruct *win,WIN_MsgStruct *msg))MENU_DefaultMsgLoop;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WIN_MenuStruct *ret=mymalloc (sizeof ( WIN_MenuStruct));
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><><EFBFBD>ø<EFBFBD><C3B8><EFBFBD><EFBFBD>Ĺ<EFBFBD><C4B9>캯<EFBFBD><ECBAAF>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
if (ret)
|
|
|
|
|
{
|
|
|
|
|
mymemset (ret,0,sizeof ( WIN_MenuStruct));
|
|
|
|
|
if (0==WIN_CreatTouchEx((WIN_TouchWinStruct *)ret,base,msgLoop,x,y,x_size,y_size))
|
|
|
|
|
{
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
myfree (ret);
|
|
|
|
|
ret=0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
((WIN_WindowStruct *)ret)->winType=WIN_MENU_TYPE;
|
|
|
|
|
((WIN_WindowStruct *)ret)->color=0xaabbcc;
|
|
|
|
|
|
|
|
|
|
ret->bar=WIN_CreatScrollbar((WIN_WindowStruct *)ret,0,20,45,x_size-40,y_size-90);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
void MENU_SetTitle (WIN_MenuStruct *menu,char *img,char *txt)
|
|
|
|
|
{
|
|
|
|
|
menu->title.img=img;
|
|
|
|
|
mymemcpy (menu->title.txt,txt,strlen(txt)+1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MENU_SetMaxItem(WIN_MenuStruct *menu,int itemNum)
|
|
|
|
|
{
|
|
|
|
|
SCROLLBAR_SetItemNum(menu->bar,itemNum);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ
|
2025-06-27 00:32:57 +08:00
|
|
|
|
void MENU_AddItem (WIN_MenuStruct *menu,char *img,char *txt)
|
|
|
|
|
{
|
|
|
|
|
SCROLLBAR_AddItem(menu->bar,txt,img);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int MENU_GetAllItemNum(WIN_MenuStruct *menu)
|
|
|
|
|
{
|
|
|
|
|
return menu->bar->itemNum;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *MENU_GetItem(WIN_MenuStruct *menu,int index)
|
|
|
|
|
{
|
|
|
|
|
if(index>=0&&index<menu->bar->itemNum)
|
|
|
|
|
return menu->bar->items[index].txt;
|
|
|
|
|
else return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *MENU_GetSelectItem(WIN_MenuStruct *menu)
|
|
|
|
|
{
|
|
|
|
|
return MENU_GetItem(menu,menu->bar->index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int MENU_GetIndex(WIN_MenuStruct *menu)
|
|
|
|
|
{
|
|
|
|
|
return menu->bar->index;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><>ʾһ<CABE><D2BB>item<65>ṹ<EFBFBD><E1B9B9>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
2025-06-27 00:32:57 +08:00
|
|
|
|
void MENU_PaintItem (MENU_ItemStruct *item,int x,int y,int x_size,int y_size)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
int txt_xsize=WIN_GetFontWidth()*strlen(item->txt)/2;
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
int img_xsize=0; //ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߴ<EFBFBD>
|
|
|
|
|
int img_ysize=0; //ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߴ<EFBFBD>
|
|
|
|
|
int img_x=0; //ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int img_y=0; //ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
|
|
|
|
|
if (item->img)
|
|
|
|
|
{
|
|
|
|
|
WIN_PicStruct *pic=WIN_GetPic(item->img);
|
|
|
|
|
WIN_DrawPic(pic,x,y+(y_size-pic->ysize)/2,pic->xsize,pic->ysize);
|
|
|
|
|
img_xsize+=pic->xsize+WIN_GetFontWidth()/2;
|
|
|
|
|
}
|
|
|
|
|
int txt_x=x+img_xsize;
|
|
|
|
|
if (item->txt[0])
|
|
|
|
|
{
|
|
|
|
|
WIN_DrawTxtAt (item->txt,txt_x,y+y_size/2-WIN_GetFontHight()/2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//Ĭ<>ϻ<EFBFBD><CFBB>ƺ<EFBFBD><C6BA><EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
void MENU_DefaultPaint (WIN_MenuStruct *menu)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
int x=0;
|
|
|
|
|
int y=0;
|
|
|
|
|
int x_size=((WIN_WindowStruct *)menu)->x_size;
|
|
|
|
|
int y_size=((WIN_WindowStruct *)menu)->y_size;
|
|
|
|
|
|
|
|
|
|
WIN_PaintBackGround ((WIN_WindowStruct *)menu);
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><><EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
WIN_SetLcdColor (((WIN_WindowStruct *)menu)->color);
|
|
|
|
|
MENU_PaintItem (&menu->title,x+25,y,x_size/2,40);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//Ĭ<><C4AC><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
void MENU_DefaultMsgLoop (WIN_MenuStruct *menu,WIN_MsgStruct *msg)
|
|
|
|
|
{
|
|
|
|
|
WIN_MoveStruct *m=0;
|
|
|
|
|
WIN_KeyStruct *k=0;
|
|
|
|
|
switch (msg->msg)
|
|
|
|
|
{
|
|
|
|
|
case WIN_MSG_PAINT:
|
|
|
|
|
MENU_DefaultPaint(menu);
|
|
|
|
|
break;
|
|
|
|
|
case WIN_MSG_INIT:
|
|
|
|
|
{
|
|
|
|
|
int x_size=((WIN_WindowStruct *)menu)->x_size;
|
|
|
|
|
int y_size=((WIN_WindowStruct *)menu)->y_size;
|
|
|
|
|
menu->key_back=WIN_CreatButton(((WIN_WindowStruct *)menu),0,x_size-65,y_size-30,65,30);
|
2025-07-05 19:47:28 +08:00
|
|
|
|
BUTTON_SetKeyString(menu->key_back,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case WIN_MSG_KEY:
|
|
|
|
|
k=msg->data.p;
|
2025-07-05 19:47:28 +08:00
|
|
|
|
if (k->shortPress&KEY_VALUE_UP)//<2F>̰<EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
{
|
|
|
|
|
// MENU_IndexSub (menu);
|
|
|
|
|
}
|
|
|
|
|
else if (k->shortPress&KEY_VALUE_DOWN)
|
|
|
|
|
{
|
|
|
|
|
// MENU_IndexAdd (menu);
|
|
|
|
|
}
|
|
|
|
|
if (k->shortPress&KEY_VALUE_HOME)
|
|
|
|
|
{
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
((WIN_WindowStruct *)menu)->deleteWindow((WIN_WindowStruct *)menu);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (k->shortPress)
|
|
|
|
|
{
|
|
|
|
|
WIN_SetInvalid ((WIN_WindowStruct *)menu);
|
|
|
|
|
}
|
|
|
|
|
break;//case WIN_MSG_KEY:
|
|
|
|
|
case WIN_MSG_MOVE:
|
|
|
|
|
m=msg->data.p;
|
|
|
|
|
switch (m->moveType)
|
|
|
|
|
{
|
|
|
|
|
case MOVE_DATA_MOVED:
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case MOVE_DATA_TOUCHIN:
|
|
|
|
|
break;
|
|
|
|
|
case MOVE_DATA_TOUCHOUT:
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case WIN_MSG_CHID:
|
|
|
|
|
switch (msg->data.v)
|
|
|
|
|
{
|
|
|
|
|
case CHID_DELETE:
|
|
|
|
|
break;
|
|
|
|
|
case CHID_USER:
|
|
|
|
|
{
|
|
|
|
|
if (msg->srcWin==menu->key_back)
|
|
|
|
|
{
|
|
|
|
|
if (msg->data2.v==BUTTON_PRESSED)
|
|
|
|
|
{
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
((WIN_WindowStruct *)menu)->deleteWindow((WIN_WindowStruct *)menu);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
WIN_DefaultMsgLoop((WIN_WindowStruct *)menu,msg);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|