2025-06-27 00:32:57 +08:00
|
|
|
|
#include "mywin_inc.h"
|
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
#define WIN_LIST_TYPE "WIN_ListStruct"
|
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// <20>ڶ<EFBFBD><DAB6>д<EFBFBD><D0B4><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
WIN_ListStruct *WIN_CreatList(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))LIST_DefaultMsgLoop;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
WIN_ListStruct *ret = mymalloc(sizeof(WIN_ListStruct));
|
|
|
|
|
|
// <20><><EFBFBD>ø<EFBFBD><C3B8><EFBFBD><EFBFBD>Ĺ<EFBFBD><C4B9>캯<EFBFBD><ECBAAF>
|
|
|
|
|
|
if (ret) {
|
|
|
|
|
|
mymemset(ret, 0, sizeof(WIN_ListStruct));
|
|
|
|
|
|
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_LIST_TYPE;
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>б<EFBFBD>
|
|
|
|
|
|
ret->itemHeigh = WIN_GetFontHight();
|
|
|
|
|
|
ret->list_y = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return ret;
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Ŀ
|
|
|
|
|
|
void LIST_SetItem(WIN_ListStruct *list, char **item, int itemNum) {
|
|
|
|
|
|
if (list->button) {
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>ù<EFBFBD><C3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0>
|
|
|
|
|
|
for (int i = 0; i < list->itemNum; i++) {
|
|
|
|
|
|
((WIN_WindowStruct *)(list->button[i]))
|
|
|
|
|
|
->deleteWindow((WIN_WindowStruct *)(list->button[i]));
|
|
|
|
|
|
}
|
|
|
|
|
|
myfree(list->button);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
list->item = item;
|
|
|
|
|
|
list->itemNum = itemNum;
|
|
|
|
|
|
list->button = mymalloc(sizeof(WIN_ButtonStruct *) * list->itemNum);
|
|
|
|
|
|
mymemset(list->button, 0, sizeof(WIN_ButtonStruct *) * list->itemNum);
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>ť
|
|
|
|
|
|
for (int i = 0; i < list->itemNum; i++) {
|
|
|
|
|
|
list->button[i] = WIN_CreatButton(
|
|
|
|
|
|
(WIN_WindowStruct *)list, 0, 0, list->list_y + i * list->itemHeigh,
|
|
|
|
|
|
((WIN_WindowStruct *)list)->x_size, list->itemHeigh);
|
|
|
|
|
|
BUTTON_SetKeyString(list->button[i], list->item[i]);
|
|
|
|
|
|
}
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD>Ŀ<EFBFBD>ĸ߶<C4B8>
|
|
|
|
|
|
void LIST_SetItemHeight(WIN_ListStruct *list, int height) {
|
|
|
|
|
|
list->itemHeigh = height;
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>Y<EFBFBD>᷽<EFBFBD><E1B7BD><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>
|
|
|
|
|
|
void LIST_SetYOrigin(WIN_ListStruct *list, int ori) { list->list_y = ori; }
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>Y<EFBFBD>᷽<EFBFBD><E1B7BD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
void LIST_SetYMove(WIN_ListStruct *list, int move) {
|
|
|
|
|
|
list->list_y += move;
|
|
|
|
|
|
int temp =
|
|
|
|
|
|
((WIN_WindowStruct *)list)->y_size - list->itemHeigh * list->itemNum;
|
|
|
|
|
|
if (list->list_y < temp) {
|
|
|
|
|
|
list->list_y = temp;
|
|
|
|
|
|
} else if (list->list_y > 0) {
|
|
|
|
|
|
list->list_y = 0;
|
|
|
|
|
|
}
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// Ĭ<>ϻ<EFBFBD><CFBB>ƺ<EFBFBD><C6BA><EFBFBD>
|
|
|
|
|
|
void LIST_DefaultPaint(WIN_ListStruct *list) {
|
|
|
|
|
|
int x = 0;
|
|
|
|
|
|
int y = 0;
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// Ĭ<><C4AC><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
void LIST_DefaultMsgLoop(WIN_ListStruct *list, WIN_MsgStruct *msg) {
|
|
|
|
|
|
WIN_MoveStruct *m = 0;
|
|
|
|
|
|
switch (msg->msg) {
|
|
|
|
|
|
case WIN_MSG_PAINT:
|
|
|
|
|
|
LIST_DefaultPaint(list);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case WIN_MSG_INIT:
|
|
|
|
|
|
break;
|
|
|
|
|
|
case WIN_MSG_KEY:
|
|
|
|
|
|
break;
|
|
|
|
|
|
case WIN_MSG_TOUCH:
|
|
|
|
|
|
break;
|
|
|
|
|
|
case WIN_MSG_CHID:
|
|
|
|
|
|
break;
|
|
|
|
|
|
case WIN_MSG_DELETE:
|
|
|
|
|
|
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:
|
|
|
|
|
|
break;
|
|
|
|
|
|
case MOVE_DATA_TOUCHOUT:
|
|
|
|
|
|
break;
|
|
|
|
|
|
case MOVE_DATA_TOUCHIN:
|
|
|
|
|
|
WIN_SetInvalid((WIN_WindowStruct *)list);
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
WIN_DefaultMsgLoop((WIN_WindowStruct *)list, msg);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
WIN_DefaultMsgLoop((WIN_WindowStruct *)list, msg);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|