2025-06-27 00:32:57 +08:00
|
|
|
|
#include "mywin_inc.h"
|
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
WIN_RecordStruct *WIN_CreatRecord(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))RECORD_DefaultMsgLoop;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
WIN_RecordStruct *ret = mymalloc(sizeof(WIN_RecordStruct));
|
|
|
|
|
|
// <20><><EFBFBD>ø<EFBFBD><C3B8><EFBFBD><EFBFBD>Ĺ<EFBFBD><C4B9>캯<EFBFBD><ECBAAF>
|
|
|
|
|
|
if (ret) {
|
|
|
|
|
|
mymemset(ret, 0, sizeof(WIN_RecordStruct));
|
|
|
|
|
|
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 {
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
|
|
|
|
|
((WIN_WindowStruct *)ret)->winType = "WIN_RecordStruct";
|
|
|
|
|
|
((WIN_WindowStruct *)ret)->bkcolor = 0x0;
|
|
|
|
|
|
((WIN_WindowStruct *)ret)->color = 0xffffaa;
|
|
|
|
|
|
((WIN_WindowStruct *)ret)->keyChid = 1; // <20><>Ϊ<EFBFBD>Ӵ<EFBFBD><D3B4>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
ret->color_light = 0xffffff;
|
|
|
|
|
|
ret->color_dark = 0x808080;
|
|
|
|
|
|
ret->msg_x_size = x_size * 4 / 5; // ÿ<><C3BF><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
|
|
|
|
|
ret->font_size = 16; // Ĭ<><C4AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return ret;
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// <20>õ<EFBFBD><C3B5><EFBFBD>Ϣ<EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
int RECORD_GetMsgYSize(WIN_RecordStruct *box);
|
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>msg_type='s',<2C><><EFBFBD>͵<EFBFBD><CDB5><EFBFBD>Ϣ<EFBFBD><CFA2>msg_type='r',<2C><><EFBFBD>յ<EFBFBD><D5B5><EFBFBD>Ϣ
|
|
|
|
|
|
int RECORD_AddMsg(WIN_RecordStruct *box, char msg_type, char *msg) {
|
|
|
|
|
|
int len = strlen(msg) + 1;
|
|
|
|
|
|
if (len >= RECORD_MAX_MSG_LEN)
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
|
|
if (box->msg_used < RECORD_MAX_MSG_NUM) {
|
|
|
|
|
|
mymemcpy(box->msgs[box->msg_end].msg, msg, len);
|
|
|
|
|
|
box->msgs[box->msg_end].msg_type = msg_type;
|
|
|
|
|
|
box->msg_used++;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
mymemcpy(box->msgs[box->msg_end].msg, msg, len);
|
|
|
|
|
|
box->msgs[box->msg_end].msg_type = msg_type;
|
|
|
|
|
|
box->msg_start++;
|
|
|
|
|
|
if (box->msg_start >= RECORD_MAX_MSG_NUM)
|
|
|
|
|
|
box->msg_start = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
// <20>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ֿ<EFBFBD><D6BF>Ĵ<EFBFBD>С
|
|
|
|
|
|
int txt_x_size = len * box->font_size / 2;
|
|
|
|
|
|
box->msgs[box->msg_end].x_size = txt_x_size;
|
|
|
|
|
|
box->msgs[box->msg_end].y_size = box->font_size;
|
|
|
|
|
|
while (txt_x_size > box->msg_x_size) {
|
|
|
|
|
|
txt_x_size -= box->msg_x_size;
|
|
|
|
|
|
box->msgs[box->msg_end].y_size += box->font_size;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (box->msgs[box->msg_end].x_size > box->msg_x_size)
|
|
|
|
|
|
box->msgs[box->msg_end].x_size = box->msg_x_size;
|
|
|
|
|
|
box->msgs[box->msg_end].y_size += 8;
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>β<EFBFBD><CEB2>ָ<EFBFBD><D6B8>
|
|
|
|
|
|
box->msg_end++;
|
|
|
|
|
|
if (box->msg_end >= RECORD_MAX_MSG_NUM)
|
|
|
|
|
|
box->msg_end = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// <20><>ʾ<EFBFBD><CABE><EFBFBD>µ<EFBFBD><C2B5><EFBFBD>Ϣ
|
|
|
|
|
|
int all_y_size = RECORD_GetMsgYSize(box);
|
|
|
|
|
|
if (all_y_size > ((WIN_WindowStruct *)box)->y_size) {
|
|
|
|
|
|
box->y_off = ((WIN_WindowStruct *)box)->y_size - all_y_size;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƕ<EFBFBD><C7B6>˴<EFBFBD><CBB4><EFBFBD>ʱˢ<CAB1><CBA2>
|
|
|
|
|
|
// if (WIN_FindTopWin(WIN_GetBaseWindow())==((WIN_WindowStruct
|
|
|
|
|
|
//*)box)->baseWin)
|
|
|
|
|
|
{
|
|
|
|
|
|
WIN_SetInvalidWhenTop((WIN_WindowStruct *)box);
|
|
|
|
|
|
}
|
|
|
|
|
|
return 0;
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// <20>õ<EFBFBD><C3B5><EFBFBD>Ϣ<EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD>
|
|
|
|
|
|
int RECORD_GetMsgYSize(WIN_RecordStruct *box) {
|
|
|
|
|
|
int y_size = 0;
|
|
|
|
|
|
for (int i = 0; i < box->msg_used; i++) {
|
|
|
|
|
|
y_size += box->msgs[i].y_size;
|
|
|
|
|
|
}
|
|
|
|
|
|
return y_size;
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>box->msg_start<72><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB>ֵ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD>Ϣ<EFBFBD>ṹ<EFBFBD><E1B9B9>
|
|
|
|
|
|
Record_MsgStruct *RECORD_GetMsgByIndexOffset(WIN_RecordStruct *box,
|
|
|
|
|
|
int index_offset) {
|
|
|
|
|
|
if (index_offset > box->msg_used - 1)
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
if (index_offset < -box->msg_used)
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
int index = 0;
|
|
|
|
|
|
if (index_offset >= 0)
|
|
|
|
|
|
index = box->msg_start;
|
|
|
|
|
|
if (index_offset < 0)
|
|
|
|
|
|
index = box->msg_end;
|
|
|
|
|
|
|
|
|
|
|
|
return &box->msgs[(index + index_offset) % box->msg_used];
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// <20><>ƫ<EFBFBD><C6AB>ֵ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB>
|
|
|
|
|
|
int RECORD_GetMsgIndexOffsetByOffset(WIN_RecordStruct *box, int offset,
|
|
|
|
|
|
int *box_offset) {
|
|
|
|
|
|
int msg_y_size = RECORD_GetMsgYSize(box);
|
|
|
|
|
|
int y_size = ((WIN_WindowStruct *)box)->y_size;
|
|
|
|
|
|
if (msg_y_size + offset < 0)
|
|
|
|
|
|
return -1; // ƫ<><C6AB>ֵ<EFBFBD><D6B5><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȣ<EFBFBD><C8A3>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
if (offset > 0)
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
|
|
int sum_y_size = 0;
|
|
|
|
|
|
int index = 0;
|
|
|
|
|
|
while (1) {
|
|
|
|
|
|
Record_MsgStruct *msg = RECORD_GetMsgByIndexOffset(box, index);
|
|
|
|
|
|
if (msg == 0)
|
|
|
|
|
|
return -1; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
|
sum_y_size += msg->y_size;
|
|
|
|
|
|
if (offset + sum_y_size < 0)
|
|
|
|
|
|
index++;
|
|
|
|
|
|
else {
|
|
|
|
|
|
*box_offset = offset + sum_y_size - msg->y_size;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return index;
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
void RECORD_DefaultPaint(WIN_RecordStruct *box) {
|
|
|
|
|
|
int x = 0;
|
|
|
|
|
|
int y = 0;
|
|
|
|
|
|
int x_size = ((WIN_WindowStruct *)box)->x_size;
|
|
|
|
|
|
int y_size = ((WIN_WindowStruct *)box)->y_size;
|
|
|
|
|
|
|
|
|
|
|
|
WIN_PaintBackGround((WIN_WindowStruct *)box);
|
|
|
|
|
|
u32 font_size = WIN_SetFontSize(box->font_size);
|
|
|
|
|
|
|
|
|
|
|
|
WIN_SetLcdColor(((WIN_WindowStruct *)box)->color);
|
|
|
|
|
|
|
|
|
|
|
|
int box_off = 0;
|
|
|
|
|
|
int index = RECORD_GetMsgIndexOffsetByOffset(box, box->y_off, &box_off);
|
|
|
|
|
|
if (index != -1) {
|
|
|
|
|
|
while (1) {
|
|
|
|
|
|
Record_MsgStruct *msg = RECORD_GetMsgByIndexOffset(box, index);
|
|
|
|
|
|
if (msg) {
|
|
|
|
|
|
if (msg->msg_type == 'r') {
|
|
|
|
|
|
WIN_SetLcdColor(((WIN_WindowStruct *)box)->color);
|
|
|
|
|
|
WIN_DrawTxtAtRect(msg->msg, 2, box_off + 1, msg->x_size,
|
|
|
|
|
|
msg->y_size - 6);
|
|
|
|
|
|
|
|
|
|
|
|
WIN_SetLcdColor(((WIN_WindowStruct *)box)->bkcolor);
|
|
|
|
|
|
// WIN_DrawRect (0,box_off,msg->x_size,msg->y_size-3);
|
|
|
|
|
|
WIN_FillRectByColorAlpha(0, box_off, msg->x_size, msg->y_size - 3,
|
|
|
|
|
|
16);
|
|
|
|
|
|
} else if (msg->msg_type == 's') {
|
|
|
|
|
|
WIN_SetLcdColor(((WIN_WindowStruct *)box)->color);
|
|
|
|
|
|
WIN_DrawTxtAtRect(msg->msg, x_size + 2 - msg->x_size, box_off + 1,
|
|
|
|
|
|
msg->x_size, msg->y_size - 6);
|
|
|
|
|
|
|
|
|
|
|
|
WIN_SetLcdColor(((WIN_WindowStruct *)box)->bkcolor);
|
|
|
|
|
|
// WIN_DrawRect
|
|
|
|
|
|
// (x_size-msg->x_size,box_off,msg->x_size,msg->y_size-3);
|
|
|
|
|
|
WIN_FillRectByColorAlpha(x_size - msg->x_size, box_off, msg->x_size,
|
|
|
|
|
|
msg->y_size - 3, 16);
|
|
|
|
|
|
}
|
|
|
|
|
|
box_off += msg->y_size;
|
|
|
|
|
|
} else
|
|
|
|
|
|
break;
|
|
|
|
|
|
index++;
|
|
|
|
|
|
if (box_off > y_size)
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>Ʊ߿<C6B1>
|
|
|
|
|
|
if (box->press)
|
|
|
|
|
|
WIN_SetLcdColor(box->color_light);
|
|
|
|
|
|
else
|
|
|
|
|
|
WIN_SetLcdColor(box->color_dark);
|
|
|
|
|
|
|
|
|
|
|
|
WIN_DrawRect(0, 0, ((WIN_WindowStruct *)box)->x_size,
|
|
|
|
|
|
((WIN_WindowStruct *)box)->y_size);
|
|
|
|
|
|
WIN_SetFontSize(font_size);
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
void RECORD_DefaultMsgLoop(WIN_RecordStruct *box, WIN_MsgStruct *msg) {
|
|
|
|
|
|
WIN_MoveStruct *m = 0;
|
|
|
|
|
|
WIN_KeyStruct *k = 0;
|
|
|
|
|
|
switch (msg->msg) {
|
|
|
|
|
|
case WIN_MSG_PAINT:
|
|
|
|
|
|
RECORD_DefaultPaint(box);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case WIN_MSG_KEY:
|
|
|
|
|
|
k = msg->data.p;
|
|
|
|
|
|
if (k->shortPress & KEY_VALUE_DOWN) {
|
|
|
|
|
|
} else if (k->shortPress & KEY_VALUE_UP) {
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case WIN_MSG_MOVE:
|
|
|
|
|
|
m = msg->data.p;
|
|
|
|
|
|
switch (m->moveType) {
|
|
|
|
|
|
case MOVE_DATA_MOVED: {
|
|
|
|
|
|
box->y_off += m->y_move;
|
|
|
|
|
|
int msg_y_size = RECORD_GetMsgYSize(box);
|
|
|
|
|
|
if (box->y_off > 0)
|
|
|
|
|
|
box->y_off = 0;
|
|
|
|
|
|
else if (box->y_off < -msg_y_size)
|
|
|
|
|
|
box->y_off = -msg_y_size;
|
|
|
|
|
|
WIN_SetInvalid((WIN_WindowStruct *)box);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
case MOVE_DATA_TOUCHIN:
|
|
|
|
|
|
box->press = 1;
|
|
|
|
|
|
WIN_SetInvalid((WIN_WindowStruct *)box);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case MOVE_DATA_TOUCHOUT:
|
|
|
|
|
|
case MOVE_DATA_MOVEOUT:
|
|
|
|
|
|
box->press = 0;
|
|
|
|
|
|
WIN_SetInvalid((WIN_WindowStruct *)box);
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
WIN_DefaultMsgLoop((WIN_WindowStruct *)box, msg);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
WIN_RecordStruct *RECORD_DrawRecord(WIN_WindowStruct *base, int x, int y,
|
|
|
|
|
|
int x_size, int y_size) {
|
|
|
|
|
|
WIN_RecordStruct *box = WIN_CreatRecord(base, 0, x, y, x_size, y_size);
|
2025-06-27 00:32:57 +08:00
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
// <20><><EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>
|
|
|
|
|
|
WIN_SetBackPic((WIN_WindowStruct *)box);
|
2025-06-27 00:32:57 +08:00
|
|
|
|
|
2025-07-06 18:46:13 +08:00
|
|
|
|
WIN_ShowWindow((WIN_WindowStruct *)box);
|
|
|
|
|
|
return box;
|
|
|
|
|
|
}
|