2025-06-27 00:32:57 +08:00
|
|
|
|
#include "mywin_inc.h"
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// <20><>Ϣ<EFBFBD>Ի<EFBFBD><D4BB>̳<F2A3ACBC><CCB3><EFBFBD>MYWIN<49><4E><EFBFBD><EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
#define WIN_MSGBOX_TYPE "WIN_MsgboxStruct"
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// <20>ڶ<EFBFBD><DAB6>д<EFBFBD><D0B4><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>Ϣ<EFBFBD>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
WIN_MsgboxStruct *WIN_CreatMsgbox(WIN_WindowStruct *base,
|
|
|
|
|
void (*msgLoop)(struct _WIN_WindowStruct *win,
|
|
|
|
|
WIN_MsgStruct *msg),
|
|
|
|
|
int x, int y, int x_size, int y_size) {
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣѭ<CFA2><D1AD>
|
|
|
|
|
if (msgLoop == 0) {
|
|
|
|
|
msgLoop = (void (*)(struct _WIN_WindowStruct *win,
|
|
|
|
|
WIN_MsgStruct *msg))MSGBOX_defaultMsgLoop;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WIN_MsgboxStruct *ret = mymalloc(sizeof(WIN_MsgboxStruct));
|
|
|
|
|
// <20><><EFBFBD>ø<EFBFBD><C3B8><EFBFBD><EFBFBD>Ĺ<EFBFBD><C4B9>캯<EFBFBD><ECBAAF>
|
|
|
|
|
if (ret) {
|
|
|
|
|
mymemset(ret, 0, sizeof(WIN_MsgboxStruct));
|
|
|
|
|
if (0 == WIN_CreatWindowExt((WIN_WindowStruct *)ret, base, msgLoop, x, y,
|
|
|
|
|
x_size, y_size)) {
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
|
|
|
|
|
myfree(ret);
|
|
|
|
|
ret = 0;
|
|
|
|
|
} else {
|
|
|
|
|
((WIN_WindowStruct *)ret)->winType = WIN_MSGBOX_TYPE;
|
|
|
|
|
((WIN_WindowStruct *)ret)->intercept = 1; // <20><>Ϊ<EFBFBD>Ӵ<EFBFBD><D3B4>ڣ<EFBFBD><DAA3>ӹܰ<D3B9><DCB0><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
((WIN_WindowStruct *)ret)->color = 0xffffff;
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>
|
|
|
|
|
ret->key = "ȷ<EFBFBD><EFBFBD>";
|
|
|
|
|
ret->msg = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>Ϣ";
|
|
|
|
|
ret->title = "<EFBFBD><EFBFBD>ʾ";
|
|
|
|
|
ret->titleTxtColor = 0xc2ae9b;
|
|
|
|
|
ret->titleRectColor = 0;
|
|
|
|
|
ret->tipRectColor = 0x342f2a;
|
|
|
|
|
ret->butRectColor = 0x221f18;
|
|
|
|
|
ret->y_step = 30;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ret;
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><F2A3ACB8><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD>ߴ<EFBFBD>
|
|
|
|
|
WIN_MsgboxStruct *WIN_CreatMsgboxAuto(
|
|
|
|
|
WIN_WindowStruct *base,
|
|
|
|
|
void (*msgLoop)(struct _WIN_WindowStruct *win, WIN_MsgStruct *msg),
|
|
|
|
|
char *msg) {
|
|
|
|
|
int x, y;
|
|
|
|
|
int txt_xsize = 0;
|
|
|
|
|
int txt_ysize = 0;
|
|
|
|
|
WIN_GetTxtRectSize(msg, &txt_xsize, &txt_ysize);
|
|
|
|
|
txt_xsize += 4 + WIN_GetFontWidth();
|
|
|
|
|
txt_ysize += 4 + WIN_GetFontHight() * 5;
|
|
|
|
|
if (base) {
|
|
|
|
|
if (txt_xsize > base->x_size)
|
|
|
|
|
txt_xsize = base->x_size;
|
|
|
|
|
txt_ysize +=
|
|
|
|
|
(txt_xsize / base->x_size) *
|
|
|
|
|
WIN_GetFontHight(); // <20><><EFBFBD>г<EFBFBD><D0B3><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB>Сʱ<D0A1><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>г<EFBFBD><D0B3><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB>С
|
|
|
|
|
if (txt_ysize > base->y_size)
|
|
|
|
|
txt_ysize = base->y_size;
|
|
|
|
|
x = (base->x_size - txt_xsize) / 2;
|
|
|
|
|
y = (base->y_size - txt_ysize) / 2;
|
|
|
|
|
} else {
|
|
|
|
|
if (txt_xsize > WIN_GetBaseWindow()->x_size)
|
|
|
|
|
txt_xsize = WIN_GetBaseWindow()->x_size;
|
|
|
|
|
txt_ysize +=
|
|
|
|
|
(txt_xsize / WIN_GetBaseWindow()->x_size) *
|
|
|
|
|
WIN_GetFontHight(); // <20><><EFBFBD>г<EFBFBD><D0B3><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB>Сʱ<D0A1><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>г<EFBFBD><D0B3><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB>С
|
|
|
|
|
if (txt_ysize > WIN_GetBaseWindow()->y_size)
|
|
|
|
|
txt_ysize = WIN_GetBaseWindow()->y_size;
|
|
|
|
|
x = (WIN_GetBaseWindow()->x_size - txt_xsize) / 2;
|
|
|
|
|
y = (WIN_GetBaseWindow()->y_size - txt_ysize) / 2;
|
|
|
|
|
}
|
|
|
|
|
WIN_MsgboxStruct *msgbox =
|
|
|
|
|
WIN_CreatMsgbox(base, msgLoop, x, y, txt_xsize, txt_ysize);
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|
|
|
|
WIN_SetBackPic((WIN_WindowStruct *)msgbox);
|
|
|
|
|
return msgbox;
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// <20><>Ϣ<EFBFBD>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|
|
|
|
void MSGBOX_SetTitle(WIN_MsgboxStruct *msgbox, char *title) {
|
|
|
|
|
msgbox->title = title;
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// <20><>Ϣ<EFBFBD>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void MSGBOX_SetMsg(WIN_MsgboxStruct *msgbox, char *msg) { msgbox->msg = msg; }
|
2025-06-27 00:32:57 +08:00
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// <20><>Ϣ<EFBFBD>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ð<EFBFBD><C3B0><EFBFBD>
|
|
|
|
|
void MSGBOX_SetKey(WIN_MsgboxStruct *msgbox, char *key) { msgbox->key = key; }
|
2025-06-27 00:32:57 +08:00
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
void MSGBOX_SetKey2(WIN_MsgboxStruct *msgbox, char *key) { msgbox->key2 = key; }
|
2025-06-27 00:32:57 +08:00
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ
|
|
|
|
|
void MSGBOX_AddItem(WIN_MsgboxStruct *msgbox, char *item) {
|
|
|
|
|
if (msgbox->itemNum < POPUP_ITEM_MAXNUM) {
|
|
|
|
|
mymemcpy(msgbox->items[msgbox->itemNum], item, strlen(item) + 1);
|
|
|
|
|
msgbox->itemNum++;
|
|
|
|
|
}
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// <20><>Ϣ<EFBFBD><CFA2><EFBFBD>Ļ<EFBFBD><C4BB>ƺ<EFBFBD><C6BA><EFBFBD>
|
|
|
|
|
void MSGBOX_DefaultPaint(WIN_MsgboxStruct *msgbox) {
|
|
|
|
|
int x = 0;
|
|
|
|
|
int y = 0;
|
|
|
|
|
int x_size = ((WIN_WindowStruct *)msgbox)->x_size;
|
|
|
|
|
int y_size = WIN_GetFontHight() * 2;
|
|
|
|
|
|
|
|
|
|
WIN_PaintBackGround((WIN_WindowStruct *)msgbox);
|
|
|
|
|
|
|
|
|
|
WIN_SetFontMode(WIN_DRAWMODE_ALONE);
|
|
|
|
|
// <20><><EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD>
|
|
|
|
|
WIN_SetLcdColor(msgbox->titleRectColor);
|
|
|
|
|
WIN_FillRectByColorAlpha(x, y, x_size, y_size, 16);
|
|
|
|
|
WIN_SetLcdColor(msgbox->titleTxtColor);
|
|
|
|
|
WIN_DrawTxtHCenterAt(msgbox->title, x_size / 2,
|
|
|
|
|
y + y_size / 2 - WIN_GetFontHight() / 2);
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
y = y + y_size;
|
|
|
|
|
y_size =
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->y_size - y_size - WIN_GetFontHight() * 2;
|
|
|
|
|
WIN_SetLcdColor(msgbox->tipRectColor);
|
|
|
|
|
WIN_FillRectByColorAlpha(x, y, x_size, y_size, 16);
|
|
|
|
|
WIN_SetLcdColor(((WIN_WindowStruct *)msgbox)->color);
|
|
|
|
|
// WIN_DrawTxtHCenterAt
|
|
|
|
|
// (msgbox->msg,LCD_GetWindowSizeX()/2,y+y_size/2-WIN_GetFontHight()/2);
|
|
|
|
|
WIN_DrawTxtCenterAtRect(msgbox->msg, x, y, x_size, y_size);
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>ư<EFBFBD>ť
|
|
|
|
|
y += y_size;
|
|
|
|
|
y_size = WIN_GetFontHight() * 2;
|
|
|
|
|
if (msgbox->press == 1) {
|
|
|
|
|
WIN_SetLcdColor(msgbox->tipRectColor);
|
|
|
|
|
} else {
|
|
|
|
|
WIN_SetLcdColor(msgbox->butRectColor);
|
|
|
|
|
}
|
|
|
|
|
WIN_FillRectByColorAlpha(x, y, x_size, y_size, 16);
|
|
|
|
|
WIN_SetLcdColor(((WIN_WindowStruct *)msgbox)->color);
|
|
|
|
|
if ((msgbox->key) && (msgbox->key2 == 0)) {
|
|
|
|
|
WIN_DrawTxtHCenterAt(msgbox->key, ((WIN_WindowStruct *)msgbox)->x_size / 2,
|
|
|
|
|
y + y_size / 2 - WIN_GetFontHight() / 2);
|
|
|
|
|
} else {
|
|
|
|
|
WIN_DrawTxtHCenterAt(msgbox->key, ((WIN_WindowStruct *)msgbox)->x_size / 4,
|
|
|
|
|
y + y_size / 2 - WIN_GetFontHight() / 2);
|
|
|
|
|
WIN_DrawTxtHCenterAt(msgbox->key2,
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->x_size * 3 / 4,
|
|
|
|
|
y + y_size / 2 - WIN_GetFontHight() / 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>Ʊ߿<C6B1>
|
|
|
|
|
WIN_SetLcdColor(((WIN_WindowStruct *)msgbox)->bkcolor);
|
|
|
|
|
WIN_DrawRect(0, 0, ((WIN_WindowStruct *)msgbox)->x_size,
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->y_size);
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// <20><>Ϣ<EFBFBD><CFA2>ѡ<EFBFBD><D1A1>ʱ<EFBFBD>Ļ<EFBFBD><C4BB>ƺ<EFBFBD><C6BA><EFBFBD>
|
|
|
|
|
void MSGBOX_SelectPaint(WIN_MsgboxStruct *msgbox) {
|
|
|
|
|
int x = 0;
|
|
|
|
|
int y = 0;
|
|
|
|
|
int x_size = ((WIN_WindowStruct *)msgbox)->x_size;
|
|
|
|
|
int y_size = WIN_GetFontHight() * 2;
|
|
|
|
|
|
|
|
|
|
WIN_PaintBackGround((WIN_WindowStruct *)msgbox);
|
|
|
|
|
|
|
|
|
|
WIN_SetFontMode(WIN_DRAWMODE_ALONE);
|
|
|
|
|
// <20><><EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD>
|
|
|
|
|
WIN_SetLcdColor(msgbox->titleRectColor);
|
|
|
|
|
WIN_FillRectByColorAlpha(x, y, x_size, y_size, 16);
|
|
|
|
|
WIN_SetLcdColor(msgbox->titleTxtColor);
|
|
|
|
|
WIN_DrawTxtHCenterAt(msgbox->title, x_size / 2,
|
|
|
|
|
y + y_size / 2 - WIN_GetFontHight() / 2);
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
y = y + y_size;
|
|
|
|
|
y_size =
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->y_size - y_size - WIN_GetFontHight() * 2;
|
|
|
|
|
// <20><><EFBFBD>ư<EFBFBD><EFBFBD><CDB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
WIN_SetLcdColor(msgbox->tipRectColor);
|
|
|
|
|
WIN_FillRectByColorAlpha(x, y, x_size, y_size, 16);
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ѡ<EFBFBD>п<EFBFBD>
|
|
|
|
|
WIN_SetLcdColor(0xa100a1);
|
|
|
|
|
WIN_FillRectByColorAlpha(x, y + msgbox->index * msgbox->y_step, x_size,
|
|
|
|
|
msgbox->y_step, 16);
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
WIN_SetLcdColor(((WIN_WindowStruct *)msgbox)->color);
|
|
|
|
|
for (int i = 0; i < msgbox->itemNum; i++) {
|
|
|
|
|
WIN_DrawTxtHCenterAt(msgbox->items[i], x + x_size / 2,
|
|
|
|
|
y + i * msgbox->y_step + msgbox->y_step / 2 -
|
|
|
|
|
WIN_GetFontHight() / 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>ư<EFBFBD>ť
|
|
|
|
|
y += y_size;
|
|
|
|
|
y_size = WIN_GetFontHight() * 2;
|
|
|
|
|
if (msgbox->press == 1) {
|
|
|
|
|
WIN_SetLcdColor(msgbox->tipRectColor);
|
|
|
|
|
} else {
|
|
|
|
|
WIN_SetLcdColor(msgbox->butRectColor);
|
|
|
|
|
}
|
|
|
|
|
WIN_FillRectByColorAlpha(x, y, x_size, y_size, 16);
|
|
|
|
|
WIN_SetLcdColor(((WIN_WindowStruct *)msgbox)->color);
|
|
|
|
|
if ((msgbox->key) && (msgbox->key2 == 0)) {
|
|
|
|
|
WIN_DrawTxtHCenterAt(msgbox->key, ((WIN_WindowStruct *)msgbox)->x_size / 2,
|
|
|
|
|
y + y_size / 2 - WIN_GetFontHight() / 2);
|
|
|
|
|
} else {
|
|
|
|
|
WIN_DrawTxtHCenterAt(msgbox->key, ((WIN_WindowStruct *)msgbox)->x_size / 4,
|
|
|
|
|
y + y_size / 2 - WIN_GetFontHight() / 2);
|
|
|
|
|
WIN_DrawTxtHCenterAt(msgbox->key2,
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->x_size * 3 / 4,
|
|
|
|
|
y + y_size / 2 - WIN_GetFontHight() / 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>Ʊ߿<C6B1>
|
|
|
|
|
WIN_SetLcdColor(((WIN_WindowStruct *)msgbox)->bkcolor);
|
|
|
|
|
WIN_DrawRect(0, 0, ((WIN_WindowStruct *)msgbox)->x_size,
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->y_size);
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void MSGBOX_defaultMsgLoop(WIN_MsgboxStruct *msgbox, WIN_MsgStruct *msg) {
|
|
|
|
|
WIN_MoveStruct *m = 0;
|
|
|
|
|
WIN_KeyStruct *k = 0;
|
|
|
|
|
switch (msg->msg) {
|
|
|
|
|
case WIN_MSG_PAINT:
|
|
|
|
|
MSGBOX_DefaultPaint(msgbox);
|
|
|
|
|
break;
|
|
|
|
|
case WIN_MSG_INIT:
|
|
|
|
|
break;
|
|
|
|
|
case WIN_MSG_KEY:
|
|
|
|
|
k = msg->data.p;
|
|
|
|
|
// <20>յ<EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD>ؼ<F2B7B5BB>
|
|
|
|
|
if ((k->shortPress & KEY_VALUE_ENTER) || (k->shortPress & KEY_VALUE_HOME)) {
|
|
|
|
|
if (k->shortPress & KEY_VALUE_ENTER) {
|
|
|
|
|
WIN_SetBlockWinReturn(0, 0, 0);
|
|
|
|
|
} else if (k->shortPress & KEY_VALUE_HOME) {
|
|
|
|
|
WIN_SetBlockWinReturn(1, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->deleteWindow((WIN_WindowStruct *)msgbox);
|
|
|
|
|
} else if ((k->firstPress & KEY_VALUE_ENTER) ||
|
|
|
|
|
(k->firstPress & KEY_VALUE_HOME)) {
|
|
|
|
|
msgbox->press = 1;
|
|
|
|
|
WIN_SetInvalidRect(
|
|
|
|
|
(WIN_WindowStruct *)msgbox, 0,
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->y_size - WIN_GetFontHight() * 2,
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->x_size, WIN_GetFontHight() * 2);
|
|
|
|
|
} else if ((k->unPress & KEY_VALUE_ENTER) ||
|
|
|
|
|
(k->unPress & KEY_VALUE_HOME)) {
|
|
|
|
|
msgbox->press = 0;
|
|
|
|
|
WIN_SetInvalidRect(
|
|
|
|
|
(WIN_WindowStruct *)msgbox, 0,
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->y_size - WIN_GetFontHight() * 2,
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->x_size, WIN_GetFontHight() * 2);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case WIN_MSG_TOUCH:
|
|
|
|
|
break;
|
|
|
|
|
case WIN_MSG_CHID:
|
|
|
|
|
break;
|
|
|
|
|
case WIN_MSG_DELETE:
|
|
|
|
|
break;
|
|
|
|
|
case WIN_MSG_TIMER:
|
|
|
|
|
// <20><>ʱ<EFBFBD><CAB1>ʱ<EFBFBD>䵽
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->deleteWindow((WIN_WindowStruct *)msgbox);
|
|
|
|
|
break;
|
|
|
|
|
case WIN_MSG_MOVE:
|
|
|
|
|
m = msg->data.p;
|
|
|
|
|
switch (m->moveType) {
|
|
|
|
|
case MOVE_DATA_MOVEIN:
|
|
|
|
|
break;
|
|
|
|
|
case MOVE_DATA_MOVED:
|
|
|
|
|
break;
|
|
|
|
|
case MOVE_DATA_LONG:
|
|
|
|
|
break;
|
|
|
|
|
case MOVE_DATA_MOVEOUT:
|
|
|
|
|
case MOVE_DATA_OUTSIDE:
|
|
|
|
|
msgbox->press = 0;
|
|
|
|
|
WIN_SetInvalidRect(
|
|
|
|
|
(WIN_WindowStruct *)msgbox, 0,
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->y_size - WIN_GetFontHight() * 2,
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->x_size, WIN_GetFontHight() * 2);
|
|
|
|
|
break;
|
|
|
|
|
case MOVE_DATA_TOUCHOUT:
|
|
|
|
|
if (msgbox->press) {
|
|
|
|
|
int x_size = ((WIN_WindowStruct *)msgbox)->x_size;
|
|
|
|
|
if (m->x_move < x_size / 2) {
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7>
|
|
|
|
|
WIN_SetBlockWinReturn(msgbox->index, 0, 0);
|
|
|
|
|
} else {
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>
|
|
|
|
|
WIN_SetBlockWinReturn(-1, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->deleteWindow((WIN_WindowStruct *)msgbox);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case MOVE_DATA_TOUCHIN:
|
|
|
|
|
msgbox->press = 1;
|
|
|
|
|
WIN_SetInvalidRect(
|
|
|
|
|
(WIN_WindowStruct *)msgbox, 0,
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->y_size - WIN_GetFontHight() * 2,
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->x_size, WIN_GetFontHight() * 2);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
WIN_DefaultMsgLoop((WIN_WindowStruct *)msgbox, msg);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
WIN_DefaultMsgLoop((WIN_WindowStruct *)msgbox, msg);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// <20><>Ϣ<EFBFBD><CFA2>ѡ<EFBFBD><D1A1>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void MSGBOX_SelectMsgLoop(WIN_MsgboxStruct *msgbox, WIN_MsgStruct *msg) {
|
|
|
|
|
WIN_MoveStruct *m = 0;
|
|
|
|
|
WIN_KeyStruct *k = 0;
|
|
|
|
|
switch (msg->msg) {
|
|
|
|
|
case WIN_MSG_PAINT:
|
|
|
|
|
MSGBOX_SelectPaint(msgbox);
|
|
|
|
|
break;
|
|
|
|
|
case WIN_MSG_INIT:
|
|
|
|
|
break;
|
|
|
|
|
case WIN_MSG_KEY:
|
|
|
|
|
k = msg->data.p;
|
|
|
|
|
// ѡ<><D1A1><EFBFBD><EFBFBD>Ŀ
|
|
|
|
|
if (k->shortPress & KEY_VALUE_DOWN) {
|
|
|
|
|
if (msgbox->index < msgbox->itemNum - 1)
|
|
|
|
|
msgbox->index++;
|
|
|
|
|
else
|
|
|
|
|
msgbox->index = 0;
|
|
|
|
|
WIN_SetInvalid((WIN_WindowStruct *)msgbox);
|
|
|
|
|
} else if (k->shortPress & KEY_VALUE_UP) {
|
|
|
|
|
if (msgbox->index > 0)
|
|
|
|
|
msgbox->index--;
|
|
|
|
|
else
|
|
|
|
|
msgbox->index = msgbox->itemNum - 1;
|
|
|
|
|
WIN_SetInvalid((WIN_WindowStruct *)msgbox);
|
|
|
|
|
}
|
|
|
|
|
// <20>յ<EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD>ؼ<F2B7B5BB>
|
|
|
|
|
else if ((k->shortPress & KEY_VALUE_ENTER) ||
|
|
|
|
|
(k->shortPress & KEY_VALUE_HOME)) {
|
|
|
|
|
if (k->shortPress & KEY_VALUE_ENTER) {
|
|
|
|
|
WIN_SetBlockWinReturn(msgbox->index, 0, 0);
|
|
|
|
|
} else if (k->shortPress & KEY_VALUE_HOME) {
|
|
|
|
|
WIN_SetBlockWinReturn(-1, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->deleteWindow((WIN_WindowStruct *)msgbox);
|
|
|
|
|
} else if ((k->firstPress & KEY_VALUE_ENTER) ||
|
|
|
|
|
(k->firstPress & KEY_VALUE_HOME)) {
|
|
|
|
|
msgbox->press = 1;
|
|
|
|
|
WIN_SetInvalidRect(
|
|
|
|
|
(WIN_WindowStruct *)msgbox, 0,
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->y_size - WIN_GetFontHight() * 2,
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->x_size, WIN_GetFontHight() * 2);
|
|
|
|
|
} else if ((k->unPress & KEY_VALUE_ENTER) ||
|
|
|
|
|
(k->unPress & KEY_VALUE_HOME)) {
|
|
|
|
|
msgbox->press = 0;
|
|
|
|
|
WIN_SetInvalidRect(
|
|
|
|
|
(WIN_WindowStruct *)msgbox, 0,
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->y_size - WIN_GetFontHight() * 2,
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->x_size, WIN_GetFontHight() * 2);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case WIN_MSG_TOUCH:
|
|
|
|
|
break;
|
|
|
|
|
case WIN_MSG_CHID:
|
|
|
|
|
break;
|
|
|
|
|
case WIN_MSG_DELETE:
|
|
|
|
|
break;
|
|
|
|
|
case WIN_MSG_TIMER:
|
|
|
|
|
// <20><>ʱ<EFBFBD><CAB1>ʱ<EFBFBD>䵽
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->deleteWindow((WIN_WindowStruct *)msgbox);
|
|
|
|
|
break;
|
|
|
|
|
case WIN_MSG_MOVE:
|
|
|
|
|
m = msg->data.p;
|
|
|
|
|
switch (m->moveType) {
|
|
|
|
|
case MOVE_DATA_MOVEIN:
|
|
|
|
|
break;
|
|
|
|
|
case MOVE_DATA_MOVED:
|
|
|
|
|
break;
|
|
|
|
|
case MOVE_DATA_LONG:
|
|
|
|
|
break;
|
|
|
|
|
case MOVE_DATA_MOVEOUT:
|
|
|
|
|
case MOVE_DATA_OUTSIDE:
|
|
|
|
|
msgbox->press = 0;
|
|
|
|
|
WIN_SetInvalidRect(
|
|
|
|
|
(WIN_WindowStruct *)msgbox, 0,
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->y_size - WIN_GetFontHight() * 2,
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->x_size, WIN_GetFontHight() * 2);
|
|
|
|
|
break;
|
|
|
|
|
case MOVE_DATA_TOUCHOUT:
|
|
|
|
|
if (msgbox->press) {
|
|
|
|
|
int y_start = WIN_GetFontHight() * 2;
|
|
|
|
|
int y_end =
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->y_size - WIN_GetFontHight() * 2;
|
|
|
|
|
|
|
|
|
|
if (m->y_move > y_end) {
|
|
|
|
|
int x_size = ((WIN_WindowStruct *)msgbox)->x_size;
|
|
|
|
|
if (m->x_move < x_size / 2) {
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7>
|
|
|
|
|
WIN_SetBlockWinReturn(msgbox->index, 0, 0);
|
|
|
|
|
} else {
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>
|
|
|
|
|
WIN_SetBlockWinReturn(-1, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
((WIN_WindowStruct *)msgbox)
|
|
|
|
|
->deleteWindow((WIN_WindowStruct *)msgbox);
|
|
|
|
|
} else if (m->y_move > y_start) {
|
|
|
|
|
msgbox->index = (m->y_move - y_start) / msgbox->y_step;
|
|
|
|
|
WIN_SetInvalid((WIN_WindowStruct *)msgbox);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case MOVE_DATA_TOUCHIN:
|
|
|
|
|
msgbox->press = 1;
|
|
|
|
|
WIN_SetInvalidRect(
|
|
|
|
|
(WIN_WindowStruct *)msgbox, 0,
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->y_size - WIN_GetFontHight() * 2,
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->x_size, WIN_GetFontHight() * 2);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
WIN_DefaultMsgLoop((WIN_WindowStruct *)msgbox, msg);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
WIN_DefaultMsgLoop((WIN_WindowStruct *)msgbox, msg);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>
|
|
|
|
|
int MSGBOX_Tips(WIN_WindowStruct *base, char *title, char *msg, char *key) {
|
|
|
|
|
WIN_MsgboxStruct *msgbox = WIN_CreatMsgboxAuto(base, 0, msg);
|
|
|
|
|
if (title)
|
|
|
|
|
MSGBOX_SetTitle(msgbox, title);
|
|
|
|
|
if (msg)
|
|
|
|
|
MSGBOX_SetMsg(msgbox, msg);
|
|
|
|
|
if (key)
|
|
|
|
|
MSGBOX_SetKey(msgbox, key);
|
|
|
|
|
WIN_ShowWindow((WIN_WindowStruct *)msgbox);
|
|
|
|
|
return WIN_RunBlock((WIN_WindowStruct *)msgbox);
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD>ѯ<EFBFBD>ʿ<CABF><F2A3ACB0><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><30>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1
|
|
|
|
|
int MSGBOX_Inquiry(WIN_WindowStruct *base, char *title, char *msg, char *key,
|
|
|
|
|
char *key2) {
|
|
|
|
|
WIN_MsgboxStruct *msgbox = WIN_CreatMsgboxAuto(base, 0, msg);
|
|
|
|
|
if (title)
|
|
|
|
|
MSGBOX_SetTitle(msgbox, title);
|
|
|
|
|
if (msg)
|
|
|
|
|
MSGBOX_SetMsg(msgbox, msg);
|
|
|
|
|
if (key)
|
|
|
|
|
MSGBOX_SetKey(msgbox, key);
|
|
|
|
|
if (key2)
|
|
|
|
|
MSGBOX_SetKey2(msgbox, key2);
|
|
|
|
|
|
|
|
|
|
WIN_ShowWindow((WIN_WindowStruct *)msgbox);
|
|
|
|
|
return WIN_RunBlock((WIN_WindowStruct *)msgbox);
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>,<2C><>һ<EFBFBD><D2BB>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6>˳<EFBFBD>
|
|
|
|
|
int MSGBOX_TipsTime(WIN_WindowStruct *base, char *title, char *msg, char *key,
|
|
|
|
|
u32 ms) {
|
|
|
|
|
WIN_MsgboxStruct *msgbox = WIN_CreatMsgboxAuto(base, 0, msg);
|
|
|
|
|
if (title)
|
|
|
|
|
MSGBOX_SetTitle(msgbox, title);
|
|
|
|
|
if (msg)
|
|
|
|
|
MSGBOX_SetMsg(msgbox, msg);
|
|
|
|
|
if (key)
|
|
|
|
|
MSGBOX_SetKey(msgbox, key);
|
|
|
|
|
WIN_CreatTimer((WIN_WindowStruct *)msgbox, ms);
|
|
|
|
|
WIN_ShowWindow((WIN_WindowStruct *)msgbox);
|
|
|
|
|
return WIN_RunBlock((WIN_WindowStruct *)msgbox);
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><F2A3ACB0><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-1
|
|
|
|
|
int MSGBOX_Select(WIN_WindowStruct *base, char *title, char **item, int itemNum,
|
|
|
|
|
char *key, char *key2) {
|
|
|
|
|
int x, y, x_size, y_size;
|
|
|
|
|
int txt_lenMax = 0;
|
|
|
|
|
WIN_MsgboxStruct *msgbox =
|
|
|
|
|
WIN_CreatMsgbox(base,
|
|
|
|
|
(void (*)(struct _WIN_WindowStruct *win,
|
|
|
|
|
WIN_MsgStruct *msg))MSGBOX_SelectMsgLoop,
|
|
|
|
|
x, y, x_size, y_size);
|
|
|
|
|
if (title)
|
|
|
|
|
MSGBOX_SetTitle(msgbox, title);
|
|
|
|
|
|
|
|
|
|
if (key)
|
|
|
|
|
MSGBOX_SetKey(msgbox, key);
|
|
|
|
|
if (key2)
|
|
|
|
|
MSGBOX_SetKey2(msgbox, key2);
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>ͬʱ<CDAC><CAB1>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>
|
|
|
|
|
for (int i = 0; i < itemNum; i++) {
|
|
|
|
|
int len = strlen(item[i]);
|
|
|
|
|
MSGBOX_AddItem(msgbox, item[i]);
|
|
|
|
|
if (txt_lenMax < len)
|
|
|
|
|
txt_lenMax = len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>㴰<EFBFBD>ڳߴ<DAB3>
|
|
|
|
|
x_size = txt_lenMax * WIN_GetFontWidth() / 2 + 4 + WIN_GetFontWidth();
|
|
|
|
|
y_size = msgbox->itemNum * msgbox->y_step + WIN_GetFontHight() * 4;
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾλ<CABE><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD>
|
|
|
|
|
if (base) {
|
|
|
|
|
if (x_size > base->x_size)
|
|
|
|
|
x_size = base->x_size;
|
|
|
|
|
y_size +=
|
|
|
|
|
(x_size / base->x_size) *
|
|
|
|
|
WIN_GetFontHight(); // <20><><EFBFBD>г<EFBFBD><D0B3><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB>Сʱ<D0A1><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>г<EFBFBD><D0B3><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB>С
|
|
|
|
|
if (y_size > base->y_size)
|
|
|
|
|
y_size = base->y_size;
|
|
|
|
|
x = (base->x_size - x_size) / 2;
|
|
|
|
|
y = (base->y_size - y_size) / 2;
|
|
|
|
|
} else {
|
|
|
|
|
if (x_size > WIN_GetBaseWindow()->x_size)
|
|
|
|
|
x_size = WIN_GetBaseWindow()->x_size;
|
|
|
|
|
y_size +=
|
|
|
|
|
(x_size / WIN_GetBaseWindow()->x_size) *
|
|
|
|
|
WIN_GetFontHight(); // <20><><EFBFBD>г<EFBFBD><D0B3><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB>Сʱ<D0A1><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>г<EFBFBD><D0B3><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB>С
|
|
|
|
|
if (y_size > WIN_GetBaseWindow()->y_size)
|
|
|
|
|
y_size = WIN_GetBaseWindow()->y_size;
|
|
|
|
|
x = (WIN_GetBaseWindow()->x_size - x_size) / 2;
|
|
|
|
|
y = (WIN_GetBaseWindow()->y_size - y_size) / 2;
|
|
|
|
|
}
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->x = x;
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->y = y;
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->x_size = x_size;
|
|
|
|
|
((WIN_WindowStruct *)msgbox)->y_size = y_size;
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|
|
|
|
WIN_SetBackPic((WIN_WindowStruct *)msgbox);
|
|
|
|
|
|
|
|
|
|
WIN_ShowWindow((WIN_WindowStruct *)msgbox);
|
|
|
|
|
return WIN_RunBlock((WIN_WindowStruct *)msgbox);
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|