2025-06-27 00:32:57 +08:00
|
|
|
|
#include "mywin_inc.h"
|
|
|
|
|
#include "mywin_user_timeset.h"
|
|
|
|
|
#include "date.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define WIN_TIMESETBOX_TYPE "WIN_TimeSetboxStruct"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WIN_TimeSetboxStruct *WIN_CreatTimeSetbox (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))TIMESETBOX_defaultMsgLoop;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WIN_TimeSetboxStruct *ret=mymalloc (sizeof ( WIN_TimeSetboxStruct));
|
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_TimeSetboxStruct));
|
|
|
|
|
if (0==WIN_CreatWindowExt((WIN_WindowStruct *)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_TIMESETBOX_TYPE;
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>
|
|
|
|
|
ret->title="ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
2025-06-27 00:32:57 +08:00
|
|
|
|
date_rtc_get_date (&ret->year,&ret->mounth,&ret->date);
|
|
|
|
|
date_rtc_get_time (&ret->hour,&ret->min,&ret->sec);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
void TIMESETBOX_Add (WIN_TimeSetboxStruct *timesetbox)
|
|
|
|
|
{
|
|
|
|
|
if (timesetbox->index==0)
|
|
|
|
|
{
|
|
|
|
|
if (timesetbox->year<date_get_year_max()) timesetbox->year++;
|
|
|
|
|
else timesetbox->year=date_get_year_min();
|
|
|
|
|
}
|
|
|
|
|
else if (timesetbox->index==1)
|
|
|
|
|
{
|
|
|
|
|
if (timesetbox->mounth<12) timesetbox->mounth++;
|
|
|
|
|
else timesetbox->mounth=1;
|
|
|
|
|
}
|
|
|
|
|
else if (timesetbox->index==2)
|
|
|
|
|
{
|
|
|
|
|
if (timesetbox->date<date_get_month_day_max(timesetbox->year,timesetbox->mounth)) timesetbox->date++;
|
|
|
|
|
else timesetbox->date=1;
|
|
|
|
|
}
|
|
|
|
|
else if (timesetbox->index==3)
|
|
|
|
|
{
|
|
|
|
|
if (timesetbox->hour<23) timesetbox->hour++;
|
|
|
|
|
else timesetbox->hour=0;
|
|
|
|
|
}
|
|
|
|
|
else if (timesetbox->index==4)
|
|
|
|
|
{
|
|
|
|
|
if (timesetbox->min<59) timesetbox->min++;
|
|
|
|
|
else timesetbox->min=0;
|
|
|
|
|
}
|
|
|
|
|
else if (timesetbox->index==5)
|
|
|
|
|
{
|
|
|
|
|
if (timesetbox->sec<59) timesetbox->sec++;
|
|
|
|
|
else timesetbox->sec=0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
void TIMESETBOX_Sub (WIN_TimeSetboxStruct *timesetbox)
|
|
|
|
|
{
|
|
|
|
|
if (timesetbox->index==0)
|
|
|
|
|
{
|
|
|
|
|
if (timesetbox->year>date_get_year_min()) timesetbox->year--;
|
|
|
|
|
else timesetbox->year=date_get_year_max();
|
|
|
|
|
}
|
|
|
|
|
else if (timesetbox->index==1)
|
|
|
|
|
{
|
|
|
|
|
if (timesetbox->mounth>1) timesetbox->mounth--;
|
|
|
|
|
else timesetbox->mounth=12;
|
|
|
|
|
}
|
|
|
|
|
else if (timesetbox->index==2)
|
|
|
|
|
{
|
|
|
|
|
if (timesetbox->date>1) timesetbox->date--;
|
|
|
|
|
else timesetbox->date=date_get_month_day_max(timesetbox->year,timesetbox->mounth);
|
|
|
|
|
}
|
|
|
|
|
else if (timesetbox->index==3)
|
|
|
|
|
{
|
|
|
|
|
if (timesetbox->hour>0) timesetbox->hour--;
|
|
|
|
|
else timesetbox->hour=23;
|
|
|
|
|
}
|
|
|
|
|
else if (timesetbox->index==4)
|
|
|
|
|
{
|
|
|
|
|
if (timesetbox->min>0) timesetbox->min--;
|
|
|
|
|
else timesetbox->min=59;
|
|
|
|
|
}
|
|
|
|
|
else if (timesetbox->index==5)
|
|
|
|
|
{
|
|
|
|
|
if (timesetbox->sec>0) timesetbox->sec--;
|
|
|
|
|
else timesetbox->sec=59;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><>Ϣ<EFBFBD><CFA2><EFBFBD>Ļ<EFBFBD><C4BB>ƺ<EFBFBD><C6BA><EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
void TIMESETBOX_DefaultPaint (WIN_TimeSetboxStruct *timesetbox)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
int x=0;
|
|
|
|
|
int y=0;
|
|
|
|
|
int x_size=((WIN_WindowStruct *)timesetbox)->x_size;
|
|
|
|
|
int y_size=((WIN_WindowStruct *)timesetbox)->y_size;
|
|
|
|
|
char txt_buff[20]={0};
|
|
|
|
|
|
|
|
|
|
WIN_PaintBackGround ((WIN_WindowStruct *)timesetbox);
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><><EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
WIN_SetFontMode(WIN_DRAWMODE_ALONE);
|
|
|
|
|
WIN_SetLcdColor(((WIN_WindowStruct *)timesetbox)->color);
|
|
|
|
|
WIN_DrawTxtHCenterAt (timesetbox->title,x_size/2,y);
|
|
|
|
|
y+=WIN_GetFontHight();
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ѡ<EFBFBD>п<EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
int rect_y_step=y_size/4;
|
|
|
|
|
int rect_x=10;
|
|
|
|
|
int rect_y=y+rect_y_step-WIN_GetFontHight()/2;
|
|
|
|
|
int rect_xsize=(x_size-20)/3;
|
|
|
|
|
int rect_ysize=WIN_GetFontHight();
|
|
|
|
|
WIN_SetLcdColor(0x00ff0080);
|
|
|
|
|
if (timesetbox->index<3)
|
|
|
|
|
{
|
|
|
|
|
rect_x+=rect_xsize*timesetbox->index;
|
|
|
|
|
WIN_FillRectByColor (rect_x,rect_y,rect_xsize,rect_ysize);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rect_y+=rect_y_step;
|
|
|
|
|
rect_x+=rect_xsize*(timesetbox->index-3);
|
|
|
|
|
WIN_FillRectByColor (rect_x,rect_y,rect_xsize,rect_ysize);
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><>ʾ<EFBFBD>ı<EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
WIN_SetLcdColor(((WIN_WindowStruct *)timesetbox)->color);
|
2025-07-05 19:47:28 +08:00
|
|
|
|
sprintf (txt_buff,"%04d <20><> %02d <20><> %02d <20><>",timesetbox->year,timesetbox->mounth,timesetbox->date );
|
2025-06-27 00:32:57 +08:00
|
|
|
|
WIN_DrawTxtHCenterAt (txt_buff,x_size/2,y+rect_y_step-WIN_GetFontHight()/2);
|
2025-07-05 19:47:28 +08:00
|
|
|
|
sprintf (txt_buff,"%02d ʱ %02d <20><> %02d <20><>",timesetbox->hour,timesetbox->min,timesetbox->sec );
|
2025-06-27 00:32:57 +08:00
|
|
|
|
WIN_DrawTxtHCenterAt (txt_buff,x_size/2,y+rect_y_step-WIN_GetFontHight()/2+rect_y_step);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
void TIMESETBOX_defaultMsgLoop (WIN_TimeSetboxStruct *timesetbox,WIN_MsgStruct *msg)
|
|
|
|
|
{
|
|
|
|
|
WIN_MoveStruct *m=0;
|
|
|
|
|
WIN_KeyStruct *k=0;
|
|
|
|
|
switch (msg->msg)
|
|
|
|
|
{
|
|
|
|
|
case WIN_MSG_PAINT:
|
|
|
|
|
TIMESETBOX_DefaultPaint(timesetbox);
|
|
|
|
|
break;
|
|
|
|
|
case WIN_MSG_INIT:
|
|
|
|
|
break;
|
|
|
|
|
case WIN_MSG_KEY:
|
|
|
|
|
k=msg->data.p;
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F>յ<EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD>ؼ<F2B7B5BB>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
if (k->shortPress&KEY_VALUE_UP)
|
|
|
|
|
{
|
|
|
|
|
TIMESETBOX_Add (timesetbox);
|
|
|
|
|
}
|
|
|
|
|
else if (k->shortPress&KEY_VALUE_DOWN)
|
|
|
|
|
{
|
|
|
|
|
TIMESETBOX_Sub (timesetbox);
|
|
|
|
|
}
|
|
|
|
|
else if (k->shortPress&KEY_VALUE_ENTER)
|
|
|
|
|
{
|
|
|
|
|
if (timesetbox->index<5) timesetbox->index++;
|
|
|
|
|
else timesetbox->index=0;
|
|
|
|
|
}
|
|
|
|
|
if (k->shortPress)
|
|
|
|
|
{
|
|
|
|
|
WIN_SetInvalidRect ((WIN_WindowStruct *)timesetbox,0,16,((WIN_WindowStruct *)timesetbox)->x_size,((WIN_WindowStruct *)timesetbox)->y_size-16);
|
|
|
|
|
}
|
|
|
|
|
if (k->shortPress&KEY_VALUE_HOME)
|
|
|
|
|
{
|
2025-07-05 19:47:28 +08:00
|
|
|
|
MSGBOX_TipsTime ((WIN_WindowStruct *)timesetbox,"<EFBFBD><EFBFBD>ʾ","<EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>","ȷ<EFBFBD><EFBFBD>",5000);
|
2025-06-27 00:32:57 +08:00
|
|
|
|
((WIN_WindowStruct *)timesetbox)->deleteWindow((WIN_WindowStruct *)timesetbox);
|
|
|
|
|
}
|
|
|
|
|
else if (k->longPress&KEY_VALUE_ENTER)
|
|
|
|
|
{
|
|
|
|
|
date_rtc_set_date (timesetbox->year,timesetbox->mounth,timesetbox->date);
|
|
|
|
|
date_rtc_set_time (timesetbox->hour,timesetbox->min,timesetbox->sec);
|
2025-07-05 19:47:28 +08:00
|
|
|
|
MSGBOX_TipsTime ((WIN_WindowStruct *)timesetbox,"<EFBFBD><EFBFBD>ʾ","<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѱ<EFBFBD><EFBFBD><EFBFBD>","ȷ<EFBFBD><EFBFBD>",5000);
|
2025-06-27 00:32:57 +08:00
|
|
|
|
((WIN_WindowStruct *)timesetbox)->deleteWindow((WIN_WindowStruct *)timesetbox);
|
|
|
|
|
}
|
|
|
|
|
break;//case WIN_MSG_KEY:
|
|
|
|
|
case WIN_MSG_TOUCH:
|
|
|
|
|
break;
|
|
|
|
|
case WIN_MSG_CHID:
|
|
|
|
|
break;
|
|
|
|
|
case WIN_MSG_DELETE:
|
|
|
|
|
break;
|
|
|
|
|
case WIN_MSG_TIMER:
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><>ʱ<EFBFBD><CAB1>ʱ<EFBFBD>䵽
|
2025-06-27 00:32:57 +08:00
|
|
|
|
((WIN_WindowStruct *)timesetbox)->deleteWindow((WIN_WindowStruct *)timesetbox);
|
|
|
|
|
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:
|
|
|
|
|
timesetbox->press=0;
|
|
|
|
|
WIN_SetInvalidRect ((WIN_WindowStruct *)timesetbox,0,((WIN_WindowStruct *)timesetbox)->y_size-16,((WIN_WindowStruct *)timesetbox)->x_size,16);
|
|
|
|
|
break;
|
|
|
|
|
case MOVE_DATA_TOUCHOUT:
|
|
|
|
|
if (timesetbox->press)
|
|
|
|
|
((WIN_WindowStruct *)timesetbox)->deleteWindow((WIN_WindowStruct *)timesetbox);
|
|
|
|
|
break;
|
|
|
|
|
case MOVE_DATA_TOUCHIN:
|
|
|
|
|
timesetbox->press=1;
|
|
|
|
|
//WIN_SetInvalid ((WIN_WindowStruct *)msgbox);
|
|
|
|
|
WIN_SetInvalidRect ((WIN_WindowStruct *)timesetbox,0,((WIN_WindowStruct *)timesetbox)->y_size-16,((WIN_WindowStruct *)timesetbox)->x_size,16);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
WIN_DefaultMsgLoop((WIN_WindowStruct *)timesetbox,msg);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
WIN_DefaultMsgLoop((WIN_WindowStruct *)timesetbox,msg);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
int TIMESETBOX_TimeSet (void)
|
|
|
|
|
{
|
|
|
|
|
WIN_TimeSetboxStruct *timesetbox=WIN_CreatTimeSetbox (0,0,WIN_GetBaseWindow()->x_size/4,WIN_GetBaseWindow()->y_size/4,
|
|
|
|
|
WIN_GetBaseWindow()->x_size/2,WIN_GetBaseWindow()->y_size/2);
|
|
|
|
|
WIN_ShowWindow((WIN_WindowStruct *)timesetbox);
|
|
|
|
|
return WIN_RunBlock ((WIN_WindowStruct *)timesetbox);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|