2025-06-27 00:32:57 +08:00
|
|
|
|
#include "mywin_inc.h"
|
|
|
|
|
#include "mywin_user_stat.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define WIN_STAT_TYPE "WIN_StatStruct"
|
|
|
|
|
|
|
|
|
|
WIN_StatStruct *WIN_CreatStat (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))STAT_DefaultMsgLoop;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WIN_StatStruct *ret=mymalloc (sizeof ( WIN_StatStruct));
|
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_StatStruct));
|
|
|
|
|
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_STAT_TYPE;
|
2025-07-05 19:47:28 +08:00
|
|
|
|
((WIN_WindowStruct *)ret)->keyShield=1;//<2F><><EFBFBD>ΰ<EFBFBD><CEB0><EFBFBD><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
2025-06-27 00:32:57 +08:00
|
|
|
|
((WIN_WindowStruct *)ret)->bkcolor=0x000000;
|
|
|
|
|
((WIN_WindowStruct *)ret)->color=0xffffff;
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
|
|
|
|
WIN_SetAsTopWin ((WIN_WindowStruct *)ret);//<2F><><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>֣<EFBFBD><D6A3>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>1
|
2025-06-27 00:32:57 +08:00
|
|
|
|
int STAT_SetTxt (WIN_StatStruct *stat,char *txt)
|
|
|
|
|
{
|
|
|
|
|
int ret=0;
|
|
|
|
|
int len=strlen(txt);
|
|
|
|
|
if (len>=STAT_TXT_MAXLEN)
|
|
|
|
|
{
|
|
|
|
|
ret=0;
|
|
|
|
|
len=STAT_TXT_MAXLEN-1;
|
|
|
|
|
mymemcpy (stat->txt,txt,len);
|
|
|
|
|
stat->txt[len]=0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ret=1;
|
|
|
|
|
mymemcpy (stat->txt,txt,len+1);
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
int STAT_SetImg (WIN_StatStruct *stat,u8 *img)
|
|
|
|
|
{
|
|
|
|
|
stat->img=img;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//Ĭ<>ϻ<EFBFBD><CFBB>ƺ<EFBFBD><C6BA><EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
void STAT_DefaultPaint (WIN_StatStruct *stat)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
int x=0;
|
|
|
|
|
int y=0;
|
|
|
|
|
int x_size=((WIN_WindowStruct *)stat)->x_size;
|
|
|
|
|
int y_size=((WIN_WindowStruct *)stat)->y_size;
|
|
|
|
|
WIN_PaintBackGround ((WIN_WindowStruct *)stat);
|
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=x_size-1; //ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int img_y=0; //ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2025-06-27 00:32:57 +08:00
|
|
|
|
|
|
|
|
|
int font_size=WIN_SetFontSize(12);
|
|
|
|
|
WIN_SetLcdColor (((WIN_WindowStruct *)stat)->color);
|
|
|
|
|
if (stat->img)
|
|
|
|
|
{
|
|
|
|
|
WIN_GetImageSize (stat->img,&img_xsize,&img_ysize);
|
|
|
|
|
if (img_xsize>x_size) img_xsize=x_size;
|
|
|
|
|
if (img_ysize>y_size) img_ysize=y_size;
|
|
|
|
|
img_x=x_size/2-img_xsize/2;
|
|
|
|
|
img_y=y_size/2-img_ysize/2;
|
2025-07-05 19:47:28 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ɫ
|
2025-06-27 00:32:57 +08:00
|
|
|
|
if (1)
|
|
|
|
|
{WIN_DrawImag (img_x,img_y, img_xsize,img_ysize,stat->img);}
|
|
|
|
|
}
|
|
|
|
|
else if (stat->txt[0])
|
|
|
|
|
{
|
|
|
|
|
WIN_DrawTxtHCenterAt (stat->txt,x_size/2,y_size/2-WIN_GetFontHight()/2);
|
|
|
|
|
}
|
|
|
|
|
WIN_SetFontSize (font_size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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 STAT_DefaultMsgLoop (WIN_StatStruct *stat,WIN_MsgStruct *msg)
|
|
|
|
|
{
|
|
|
|
|
WIN_MoveStruct *m=0;
|
|
|
|
|
WIN_TouchStruct *t=0;
|
|
|
|
|
switch (msg->msg)
|
|
|
|
|
{
|
|
|
|
|
case WIN_MSG_PAINT:
|
|
|
|
|
STAT_DefaultPaint(stat);
|
|
|
|
|
break;
|
|
|
|
|
case WIN_MSG_TIMER:
|
|
|
|
|
if (stat->TimerCallBack)
|
|
|
|
|
stat->TimerCallBack(stat);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
WIN_DefaultMsgLoop((WIN_WindowStruct *)stat,msg);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|