694 lines
15 KiB
C
694 lines
15 KiB
C
#include "mywin_inc.h"
|
|
#include "system_file.h"
|
|
#include "mywin_user_alarm.h"
|
|
//#include "mywin_user_num.h"
|
|
|
|
|
|
|
|
#define WIN_ALARM_TYPE "WIN_AlarmStruct"
|
|
|
|
|
|
|
|
|
|
static const char *g_popup_itmes[]=
|
|
{
|
|
"修改",
|
|
0, //开启此闹钟|关闭此闹钟
|
|
"添加新闹钟",
|
|
"删除此闹钟",
|
|
"删除所有闹钟",
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WIN_AlarmStruct *WIN_CreatAlarm (WIN_WindowStruct *base,
|
|
void (*msgLoop)(struct _WIN_WindowStruct *win,WIN_MsgStruct *msg),
|
|
int x,int y,int x_size,int y_size)
|
|
{
|
|
//重设消息循环
|
|
if (msgLoop==0)
|
|
{
|
|
msgLoop=(void (*)(struct _WIN_WindowStruct *win,WIN_MsgStruct *msg))ALARM_defaultMsgLoop;
|
|
}
|
|
|
|
WIN_AlarmStruct *ret=mymalloc (sizeof ( WIN_AlarmStruct));
|
|
//调用父类的构造函数
|
|
if (ret)
|
|
{
|
|
mymemset (ret,0,sizeof ( WIN_AlarmStruct));
|
|
// if (0==WIN_CreatWindowExt((WIN_WindowStruct *)ret,base,msgLoop,x,y,x_size,y_size))
|
|
if (0==WIN_CreatTouchEx((WIN_TouchWinStruct *)ret,base,msgLoop,x,y,x_size,y_size))
|
|
{
|
|
//创建失败
|
|
myfree (ret);
|
|
ret=0;
|
|
}
|
|
else
|
|
{
|
|
((WIN_WindowStruct *)ret)->winType=WIN_ALARM_TYPE;
|
|
((WIN_WindowStruct *)ret)->intercept=1;
|
|
//构造一个消息框
|
|
ret->title="闹钟";
|
|
ret->rectColor=0x221f18;
|
|
ret->txtColor=0x342e27;
|
|
ret->txtColor=0x000000;
|
|
ret->selectRectColor=0x666600;
|
|
ret->selectTxtColor=0xc2ae9b;
|
|
ret->key_back=WIN_CreatButton(((WIN_WindowStruct *)ret),0,x_size-65,0,65,30);
|
|
BUTTON_SetKeyString(ret->key_back,"返回");
|
|
}
|
|
}
|
|
|
|
|
|
return ret;
|
|
}
|
|
|
|
|
|
|
|
//刷新闹钟
|
|
void ALARM_FreshAlarm (WIN_AlarmStruct *alarm)
|
|
{
|
|
alarm->alarmNum=SysFile_GetAlarmNum();
|
|
if (alarm->alarmNum>ALARM_MAXNUM) alarm->alarmNum=ALARM_MAXNUM;
|
|
for (int i=0;i<alarm->alarmNum;i++)
|
|
{
|
|
SysFile_GetAlarm (i,&alarm->alarm[i]);
|
|
}
|
|
alarm->index=0;
|
|
alarm->startIndex=0;
|
|
}
|
|
|
|
|
|
|
|
|
|
//确定键的功能
|
|
void ALARM_KeyEnter (WIN_AlarmStruct *alarm,int x,int y)
|
|
{
|
|
if (alarm->page==0)
|
|
{
|
|
if (alarm->alarmNum==0)
|
|
{
|
|
//添加新闹钟
|
|
alarm->title="添加新闹钟";
|
|
alarm->page=2;
|
|
mymemset (&alarm->setAlarm,0,sizeof (AlarmStruct));
|
|
return;
|
|
}
|
|
char *popup_itmes[]={(char *)g_popup_itmes[0],(char *)g_popup_itmes[1],(char *)g_popup_itmes[2],
|
|
(char *)g_popup_itmes[3],(char *)g_popup_itmes[4]};
|
|
if (alarm->alarm[alarm->index].power==0)
|
|
{
|
|
popup_itmes[1]="打开此闹钟";
|
|
}
|
|
else
|
|
{
|
|
popup_itmes[1]="关闭此闹钟";
|
|
}
|
|
int index=POPUP_SelectItem ((WIN_WindowStruct *)alarm,(char **)popup_itmes,5,x,y);
|
|
if (index==0)
|
|
{
|
|
//修改闹钟
|
|
alarm->title="修改闹钟";
|
|
alarm->page=1;
|
|
mymemcpy (&alarm->setAlarm,&alarm->alarm[alarm->index],sizeof (AlarmStruct));
|
|
}
|
|
else if (index==1)
|
|
{
|
|
//改变开关状态
|
|
alarm->alarm[alarm->index].power=!alarm->alarm[alarm->index].power;
|
|
//保存修改后的状态
|
|
SysFile_AlterAlarm (alarm->index,&alarm->alarm[alarm->index]);
|
|
}
|
|
else if (index==2)
|
|
{
|
|
//添加新闹钟
|
|
alarm->title="添加新闹钟";
|
|
alarm->page=2;
|
|
mymemset (&alarm->setAlarm,0,sizeof (AlarmStruct));
|
|
}
|
|
else if (index==3)
|
|
{
|
|
//删除这个闹钟
|
|
SysFile_DelAlarm (alarm->index);
|
|
ALARM_FreshAlarm (alarm);
|
|
if (alarm->alarmNum==0)
|
|
{
|
|
((WIN_WindowStruct *)alarm)->deleteWindow((WIN_WindowStruct *)alarm);
|
|
}
|
|
}
|
|
else if (index==4)
|
|
{
|
|
//删除所有闹钟
|
|
SysFile_DelAllAlarm();
|
|
((WIN_WindowStruct *)alarm)->deleteWindow((WIN_WindowStruct *)alarm);
|
|
//ALARM_FreshAlarm (alarm);
|
|
}
|
|
}else if ((alarm->page==1)||(alarm->page==2))
|
|
{
|
|
//正在修改闹钟
|
|
if (alarm->setIndex<9)
|
|
alarm->setIndex++;
|
|
else
|
|
{
|
|
if (alarm->page==1)
|
|
{
|
|
SysFile_AlterAlarm (alarm->index,&alarm->setAlarm);
|
|
MSGBOX_TipsTime ((WIN_WindowStruct *)alarm,"提示","闹钟已修改" ,"确定",5000);
|
|
}
|
|
else if (alarm->page==2)
|
|
{
|
|
SysFile_AddAlarm (&alarm->setAlarm);
|
|
MSGBOX_TipsTime ((WIN_WindowStruct *)alarm,"提示","闹钟已添加" ,"确定",5000);
|
|
}
|
|
ALARM_FreshAlarm (alarm);
|
|
alarm->page=0;
|
|
alarm->setIndex=0;
|
|
alarm->title="闹钟";
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//返回键
|
|
void ALARM_KeyBack (WIN_AlarmStruct *alarm)
|
|
{
|
|
if (alarm->page==0)
|
|
{
|
|
((WIN_WindowStruct *)alarm)->deleteWindow((WIN_WindowStruct *)alarm);
|
|
}
|
|
else
|
|
{
|
|
if (MSGBOX_Inquiry ((WIN_WindowStruct *)alarm,"提示","要放弃这次修改吗?","是","否")==0)
|
|
{
|
|
alarm->page=0;
|
|
alarm->setIndex=0;
|
|
alarm->title="闹钟";
|
|
if (alarm->alarmNum==0)
|
|
{
|
|
((WIN_WindowStruct *)alarm)->deleteWindow((WIN_WindowStruct *)alarm);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
void ALARM_KeyUp (WIN_AlarmStruct *alarm)
|
|
{
|
|
if (alarm->page==0)
|
|
{
|
|
if (alarm->index>0)
|
|
{
|
|
alarm->index--;
|
|
if (alarm->startIndex>alarm->index)
|
|
alarm->startIndex=alarm->index;
|
|
}
|
|
else
|
|
{
|
|
alarm->index=alarm->alarmNum-1;
|
|
if (alarm->alarmNum>=3)
|
|
alarm->startIndex=alarm->index-2;
|
|
else
|
|
alarm->startIndex=0;
|
|
}
|
|
}
|
|
else if ((alarm->page==1)||(alarm->page==2))
|
|
{
|
|
if (alarm->setIndex==0)
|
|
{
|
|
if (alarm->setAlarm.hour<23) alarm->setAlarm.hour++;
|
|
else alarm->setAlarm.hour=0;
|
|
}
|
|
else if (alarm->setIndex==1)
|
|
{
|
|
if (alarm->setAlarm.min<59) alarm->setAlarm.min++;
|
|
else alarm->setAlarm.min=0;
|
|
}
|
|
else if ((alarm->setIndex>=2)&&(alarm->setIndex<=8))
|
|
{
|
|
int t=alarm->setIndex-2;
|
|
if (alarm->setAlarm.week&(1<<t))
|
|
{
|
|
alarm->setAlarm.week&=~(1<<t);//清除
|
|
}
|
|
else
|
|
{
|
|
alarm->setAlarm.week|=(1<<t);//设置
|
|
}
|
|
}
|
|
else if (alarm->setIndex==9)
|
|
{
|
|
alarm->setAlarm.power=!alarm->setAlarm.power;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
void ALARM_KeyDown (WIN_AlarmStruct *alarm)
|
|
{
|
|
if (alarm->page==0)
|
|
{
|
|
if (alarm->index<alarm->alarmNum-1)
|
|
{
|
|
alarm->index++;
|
|
if (alarm->startIndex<alarm->index-2)
|
|
alarm->startIndex=alarm->index-2;
|
|
}
|
|
else
|
|
{
|
|
alarm->index=0;
|
|
alarm->startIndex=alarm->index;
|
|
}
|
|
}
|
|
else if ((alarm->page==1)||(alarm->page==2))
|
|
{
|
|
if (alarm->setIndex==0)
|
|
{
|
|
if (alarm->setAlarm.hour>0) alarm->setAlarm.hour--;
|
|
else alarm->setAlarm.hour=23;
|
|
}
|
|
else if (alarm->setIndex==1)
|
|
{
|
|
if (alarm->setAlarm.min>0) alarm->setAlarm.min--;
|
|
else alarm->setAlarm.min=59;
|
|
}
|
|
else if ((alarm->setIndex>=2)&&(alarm->setIndex<=8))
|
|
{
|
|
int t=alarm->setIndex-2;
|
|
if (alarm->setAlarm.week&(1<<t))
|
|
{
|
|
alarm->setAlarm.week&=~(1<<t);//清除
|
|
}
|
|
else
|
|
{
|
|
alarm->setAlarm.week|=(1<<t);//设置
|
|
}
|
|
}
|
|
else if (alarm->setIndex==9)
|
|
{
|
|
alarm->setAlarm.power=!alarm->setAlarm.power;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
static const char *g_week[]={"日","一","二","三","四","五","六"};
|
|
|
|
//绘制列表
|
|
void ALARM_PaintList (WIN_AlarmStruct *alarm)
|
|
{
|
|
int x=0;
|
|
int y=0;
|
|
int x_size=((WIN_WindowStruct *)alarm)->x_size;
|
|
int y_size=((WIN_WindowStruct *)alarm)->y_size;
|
|
char txt_buff[20]={0};
|
|
u32 font_type=WIN_SetFontType(30);
|
|
|
|
x+=25;x_size-=25*2;
|
|
y+=45;y_size-=45*2;
|
|
|
|
//绘制矩形
|
|
int x_step=x_size/2;
|
|
int y_step=y_size/3;
|
|
x+=(x_size-x_step*2)/2;
|
|
y+=(y_size-y_step*3)/2;
|
|
x_size=x_step*2;
|
|
y_size=y_step*3;
|
|
|
|
//保存列表尺寸
|
|
alarm->rect_list.x=x,alarm->rect_list.y=y;
|
|
alarm->rect_list.x_size=x_size,alarm->rect_list.y_size=y_size;
|
|
|
|
if (alarm->alarmNum)
|
|
{
|
|
for (int i=0;i<3;i++)
|
|
{
|
|
if (i+alarm->startIndex>=alarm->alarmNum) break;
|
|
if (i+alarm->startIndex==alarm->index)
|
|
{
|
|
WIN_SetLcdColor (alarm->selectRectColor);
|
|
WIN_FillRectByColorAlpha (x,y+y_step*i,x_size,y_step,16);
|
|
WIN_SetLcdColor(0xff0000);
|
|
WIN_FillRectByColor(x,y+y_step*i,3,y_step);
|
|
}
|
|
else
|
|
{
|
|
WIN_SetLcdColor (alarm->rectColor);
|
|
WIN_FillRectByColorAlpha (x,y+y_step*i,x_size,y_step,16);
|
|
}
|
|
WIN_SetLcdColor (alarm->selectTxtColor);
|
|
int txt_x=x+20;
|
|
int txt_y=y+y_step*i;
|
|
sprintf (txt_buff,"%02d:%02d",alarm->alarm[i+alarm->startIndex].hour,alarm->alarm[i+alarm->startIndex].min);
|
|
WIN_SetFontType(30);
|
|
WIN_DrawTxtAt (txt_buff,txt_x,txt_y);
|
|
txt_x+=strlen(txt_buff)*WIN_GetFontWidth()/2;
|
|
WIN_SetFontType(24);
|
|
txt_y=txt_y+y_step-WIN_GetFontHight();
|
|
txt_x=x+x_size-9*WIN_GetFontWidth();
|
|
for (int j=0;j<7;j++)
|
|
{
|
|
if (alarm->alarm[i+alarm->startIndex].week&(1<<j))
|
|
{
|
|
WIN_SetLcdColor (alarm->selectTxtColor);
|
|
}
|
|
else
|
|
{
|
|
WIN_SetLcdColor (alarm->txtColor);
|
|
}
|
|
WIN_DrawTxtAt ((char *)g_week[j],txt_x,txt_y);
|
|
txt_x+=WIN_GetFontWidth();
|
|
}
|
|
txt_x+=WIN_GetFontWidth();
|
|
if (alarm->alarm[i+alarm->startIndex].power)
|
|
{
|
|
WIN_SetLcdColor (alarm->selectTxtColor);
|
|
WIN_DrawTxtAt ("开",txt_x,txt_y);
|
|
}else
|
|
{
|
|
WIN_SetLcdColor (alarm->txtColor);
|
|
WIN_DrawTxtAt ("关",txt_x,txt_y);
|
|
}
|
|
}
|
|
}
|
|
|
|
WIN_SetFontType(font_type);
|
|
}
|
|
|
|
|
|
|
|
//设置页面
|
|
void ALARM_PaintSet (WIN_AlarmStruct *alarm)
|
|
{
|
|
int x=0;
|
|
int y=0;
|
|
int x_size=((WIN_WindowStruct *)alarm)->x_size;
|
|
int y_size=((WIN_WindowStruct *)alarm)->y_size;
|
|
char txt_buff[20]={0};
|
|
u32 font_type=WIN_SetFontType (24);
|
|
|
|
x+=25;x_size-=25*2;
|
|
y+=45;y_size-=45*2;
|
|
|
|
//绘制矩形
|
|
int x_step=x_size/2;
|
|
int y_step=y_size/3;
|
|
x+=(x_size-x_step*2)/2;
|
|
y+=(y_size-y_step*3)/2;
|
|
x_size=x_step*2;
|
|
y_size=y_step*3;
|
|
//绘制矩形
|
|
WIN_SetLcdColor (alarm->rectColor);
|
|
WIN_FillRectByColorAlpha (x,y,x_size-1,y_step*2-1,16);
|
|
WIN_SetLcdColor (alarm->selectRectColor);
|
|
WIN_FillRectByColorAlpha (x,y+y_step*2,x_step-1,y_step-1,16);
|
|
WIN_FillRectByColorAlpha (x+x_step,y+y_step*2,x_step-1,y_step-1,16);
|
|
|
|
int num_type=30;
|
|
int txt_x=x;
|
|
WIN_SetFontType(num_type);
|
|
int txt_y=y+y_step/2-WIN_GetFontHight()/2;
|
|
sprintf (txt_buff,"%02d:%02d",alarm->setAlarm.hour,alarm->setAlarm.min);
|
|
txt_x+=x_size/2-strlen(txt_buff)*WIN_GetFontWidth()/2/2;
|
|
//绘制选中框
|
|
if (alarm->setIndex==0)
|
|
{
|
|
WIN_SetLcdColor (alarm->selectRectColor);
|
|
WIN_FillRectByColorAlpha (txt_x,txt_y,num_type+4,35,16);
|
|
WIN_SetLcdColor(0xff0000);
|
|
WIN_DrawHLine (txt_x,txt_y+WIN_GetFontHight()+5,txt_x+num_type+4);
|
|
}
|
|
else if (alarm->setIndex==1)
|
|
{
|
|
WIN_SetLcdColor (alarm->selectRectColor);
|
|
WIN_FillRectByColorAlpha (txt_x+num_type*3/2+1,txt_y,num_type+4,35,16);
|
|
WIN_SetLcdColor(0xff0000);
|
|
WIN_DrawHLine (txt_x+num_type*3/2+1,txt_y+WIN_GetFontHight()+5,txt_x+num_type*3/2+1+num_type+4);
|
|
}
|
|
WIN_SetLcdColor (alarm->selectTxtColor);
|
|
WIN_DrawTxtAt (txt_buff,txt_x,txt_y);
|
|
|
|
//显示星期
|
|
WIN_SetFontType(24);
|
|
txt_y+=y_step;
|
|
txt_x=x+x_size/2-9*WIN_GetFontWidth()/2;
|
|
//绘制选中框
|
|
if ((alarm->setIndex>=2)&&(alarm->setIndex<=8))
|
|
{
|
|
int t=alarm->setIndex-2;
|
|
int x_t=t*WIN_GetFontWidth();
|
|
WIN_SetLcdColor (alarm->selectRectColor);
|
|
WIN_FillRectByColorAlpha (txt_x+x_t,txt_y,WIN_GetFontWidth(),WIN_GetFontHight(),16);
|
|
WIN_SetLcdColor(0xff0000);
|
|
WIN_DrawHLine (txt_x+x_t,txt_y+WIN_GetFontHight()+5,txt_x+x_t+WIN_GetFontWidth());
|
|
}
|
|
for (int j=0;j<7;j++)
|
|
{
|
|
if (alarm->setAlarm.week&(1<<j))
|
|
{
|
|
WIN_SetLcdColor (alarm->selectTxtColor);
|
|
}
|
|
else
|
|
{
|
|
WIN_SetLcdColor (alarm->txtColor);
|
|
}
|
|
WIN_DrawTxtAt ((char *)g_week[j],txt_x,txt_y);
|
|
txt_x+=WIN_GetFontWidth();
|
|
}
|
|
//显示开关
|
|
txt_x+=WIN_GetFontWidth();
|
|
if (alarm->setIndex==9)
|
|
{
|
|
WIN_SetLcdColor (alarm->selectRectColor);
|
|
WIN_FillRectByColorAlpha (txt_x,txt_y,WIN_GetFontWidth(),WIN_GetFontHight(),16);
|
|
WIN_SetLcdColor(0xff0000);
|
|
WIN_DrawHLine (txt_x,txt_y+WIN_GetFontHight()+5,txt_x+WIN_GetFontWidth());
|
|
}
|
|
if (alarm->setAlarm.power)
|
|
{
|
|
WIN_SetLcdColor (alarm->selectTxtColor);
|
|
WIN_DrawTxtAt ("开",txt_x,txt_y);
|
|
}else
|
|
{
|
|
WIN_SetLcdColor (alarm->txtColor);
|
|
WIN_DrawTxtAt ("关",txt_x,txt_y);
|
|
}
|
|
WIN_SetLcdColor (alarm->selectTxtColor);
|
|
if (alarm->setIndex<9)
|
|
WIN_DrawTxtCenterAtRect ("下一步",x,y+y_step*2,x_step-1,y_step-1);
|
|
else
|
|
WIN_DrawTxtCenterAtRect ("完成",x,y+y_step*2,x_step-1,y_step-1);
|
|
WIN_DrawTxtCenterAtRect ("返回",x+x_step,y+y_step*2,x_step-1,y_step-1);
|
|
|
|
WIN_SetFontType(font_type);
|
|
}
|
|
|
|
|
|
|
|
//消息框的绘制函数
|
|
void ALARM_DefaultPaint (WIN_AlarmStruct *alarm)
|
|
{
|
|
int x=0;
|
|
int y=0;
|
|
int x_size=((WIN_WindowStruct *)alarm)->x_size;
|
|
int y_size=((WIN_WindowStruct *)alarm)->y_size;
|
|
char txt_buff[20]={0};
|
|
|
|
WIN_PaintBackGround ((WIN_WindowStruct *)alarm);
|
|
|
|
//显示标题
|
|
int img_x=x+25;
|
|
int img_y=y;
|
|
int img_xsize=0;
|
|
int img_ysize=0;
|
|
int head_ysize=45;
|
|
WIN_SetLcdColor (((WIN_WindowStruct *)alarm)->color);
|
|
if (alarm->icon)
|
|
{
|
|
WIN_GetImageSize (alarm->icon,&img_xsize,&img_ysize);
|
|
if (img_ysize>head_ysize) img_ysize=head_ysize;
|
|
WIN_DrawImagByAlpha (img_x,img_y+head_ysize/2-img_ysize/2, img_xsize,img_ysize,alarm->icon,WIN_GetLcdColor16());
|
|
img_xsize+=10;
|
|
}
|
|
WIN_DrawTxtAt (alarm->title,img_x+img_xsize,y+head_ysize/2-WIN_GetFontHight()/2);
|
|
x+=25;x_size-=25*2;
|
|
y+=45;y_size-=45*2;
|
|
|
|
//绘制矩形
|
|
if (alarm->page==0)
|
|
{
|
|
ALARM_PaintList (alarm);
|
|
}
|
|
else if ((alarm->page==1)||(alarm->page==2))
|
|
{
|
|
ALARM_PaintSet (alarm);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//消息框的消息处理函数
|
|
void ALARM_defaultMsgLoop (WIN_AlarmStruct *alarm,WIN_MsgStruct *msg)
|
|
{
|
|
WIN_KeyStruct *k=0;
|
|
WIN_MoveStruct *m=0;
|
|
switch (msg->msg)
|
|
{
|
|
case WIN_MSG_PAINT:
|
|
ALARM_DefaultPaint(alarm);
|
|
break;
|
|
case WIN_MSG_INIT:
|
|
{
|
|
int x_size=((WIN_WindowStruct *)alarm)->x_size;
|
|
alarm->key_back=WIN_CreatButton(((WIN_WindowStruct *)alarm),0,x_size-65,0,65,30);
|
|
BUTTON_SetKeyString(alarm->key_back,"返回");
|
|
}
|
|
break;
|
|
case WIN_MSG_KEY:
|
|
k=msg->data.p;
|
|
if (k->shortPress&KEY_VALUE_UP)//短按
|
|
{
|
|
ALARM_KeyUp (alarm);
|
|
}
|
|
else if (k->shortPress&KEY_VALUE_DOWN)
|
|
{
|
|
ALARM_KeyDown (alarm);
|
|
}
|
|
else if (k->shortPress&KEY_VALUE_HOME)
|
|
{
|
|
ALARM_KeyBack (alarm);
|
|
}
|
|
else if (k->shortPress&KEY_VALUE_ENTER)
|
|
{
|
|
ALARM_KeyEnter (alarm,100,100);
|
|
}
|
|
else if (k->longPress&KEY_VALUE_ENTER)
|
|
{
|
|
//长按直接保存
|
|
if (alarm->page==1)
|
|
{
|
|
SysFile_AlterAlarm (alarm->index,&alarm->setAlarm);
|
|
MSGBOX_TipsTime ((WIN_WindowStruct *)alarm,"提示","闹钟已修改" ,"确定",5000);
|
|
}
|
|
else if (alarm->page==2)
|
|
{
|
|
SysFile_AddAlarm (&alarm->setAlarm);
|
|
MSGBOX_TipsTime ((WIN_WindowStruct *)alarm,"提示","闹钟已添加" ,"确定",5000);
|
|
}
|
|
if (alarm->page)
|
|
{
|
|
ALARM_FreshAlarm (alarm);
|
|
alarm->page=0;
|
|
alarm->setIndex=0;
|
|
alarm->title="闹钟";
|
|
WIN_SetInvalid ((WIN_WindowStruct *)alarm);
|
|
}
|
|
}
|
|
if (k->shortPress)
|
|
{
|
|
WIN_SetInvalid ((WIN_WindowStruct *)alarm);
|
|
}
|
|
break;//case WIN_MSG_KEY:
|
|
case WIN_MSG_MOVE:
|
|
m=msg->data.p;
|
|
switch (m->moveType)
|
|
{
|
|
case MOVE_DATA_MOVED:
|
|
alarm->y_off+=m->y_move;
|
|
if (alarm->y_off>=30)
|
|
{
|
|
ALARM_KeyUp (alarm);
|
|
WIN_SetInvalid ((WIN_WindowStruct *)alarm);
|
|
alarm->y_off=0;
|
|
}
|
|
else if (alarm->y_off<=-30)
|
|
{
|
|
ALARM_KeyDown (alarm);
|
|
WIN_SetInvalid ((WIN_WindowStruct *)alarm);
|
|
alarm->y_off=0;
|
|
}
|
|
break;
|
|
case MOVE_DATA_SHORT:
|
|
{
|
|
int index=(m->y_move-alarm->rect_list.y)/(alarm->rect_list.y_size/3);
|
|
if (index>2) index=2;
|
|
alarm->index=index+alarm->startIndex;
|
|
WIN_SetInvalid ((WIN_WindowStruct *)alarm);
|
|
}
|
|
break;
|
|
case MOVE_DATA_LONG:
|
|
{
|
|
ALARM_KeyEnter(alarm,m->x_move,m->y_move);
|
|
WIN_SetInvalid ((WIN_WindowStruct *)alarm);
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
case WIN_MSG_CHID:
|
|
switch (msg->data.v)
|
|
{
|
|
case CHID_DELETE:
|
|
break;
|
|
case CHID_USER:
|
|
{
|
|
if (msg->data2.v==BUTTON_PRESSED)
|
|
{
|
|
if (msg->srcWin==alarm->key_back)
|
|
{
|
|
//返回
|
|
((WIN_WindowStruct *)alarm)->deleteWindow((WIN_WindowStruct *)alarm);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
default:
|
|
WIN_DefaultMsgLoop((WIN_WindowStruct *)alarm,msg);
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
WIN_AlarmStruct *ALARM_SetAlarm (WIN_WindowStruct *base)
|
|
{
|
|
WIN_AlarmStruct *ret=0;
|
|
if (base)
|
|
{
|
|
ret=WIN_CreatAlarm (base,0,0,0,base->x_size,base->y_size);
|
|
}
|
|
else
|
|
{
|
|
ret=WIN_CreatAlarm (0,0,0,0,WIN_GetBaseWindow()->x_size,WIN_GetBaseWindow()->y_size);
|
|
}
|
|
WIN_SetBackPic ((WIN_WindowStruct *)ret,&base->pic);
|
|
ALARM_FreshAlarm (ret);
|
|
if (ret->alarmNum==0)
|
|
{
|
|
//添加新闹钟
|
|
ret->title="添加新闹钟";
|
|
ret->page=2;
|
|
mymemset (&ret->setAlarm,0,sizeof (AlarmStruct));
|
|
}
|
|
WIN_ShowWindow((WIN_WindowStruct*)ret);
|
|
return ret;
|
|
}
|
|
|
|
|