124 lines
2.2 KiB
C
124 lines
2.2 KiB
C
#include "mywin_inc.h"
|
|
#include "mywin_user_menu.h"
|
|
#include "mywin_user_light.h"
|
|
|
|
#include "date.h"
|
|
#include "system_file.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const static MENU_ItemStruct ptr[]={
|
|
{0, "5 秒"},
|
|
{0, "15 秒" } ,
|
|
{0, "30 秒" } ,
|
|
{0, "90 秒" } ,
|
|
{0, "常亮" } ,
|
|
|
|
};
|
|
|
|
|
|
const static u8 g_time[5]={5,15,30,90,0};
|
|
|
|
|
|
//进入
|
|
WIN_MenuStruct *MENU_LightSet (WIN_WindowStruct *base)
|
|
{
|
|
WIN_MenuStruct *menu=WIN_CreatMenu (base,(void (*)(WIN_WindowStruct *,WIN_MsgStruct *))MENU_LightSetMsgLoop,
|
|
0,0,base->x_size,base->y_size);
|
|
((WIN_WindowStruct *)menu)->intercept=1;//不发送按键消息到父窗口
|
|
|
|
WIN_SetBackPicPath ((WIN_WindowStruct *)menu,base->pic_path);
|
|
MENU_SetTitle (menu,0,"背光设置");
|
|
|
|
MENU_SetMaxItem(menu,5);
|
|
for (int i=0;i<5;i++)
|
|
{
|
|
MENU_AddItem (menu,ptr[i].img,(char *)ptr[i].txt);
|
|
}
|
|
|
|
WIN_ShowWindow((WIN_WindowStruct*)menu);
|
|
return menu;
|
|
}
|
|
|
|
|
|
|
|
static void MENU_Enter (WIN_MenuStruct *menu)
|
|
{
|
|
|
|
SysFile_GetSysFile()->screenOffTime=g_time[MENU_GetIndex(menu)];
|
|
char txt[20]={0};
|
|
sprintf(txt,"将在 %d 秒后熄屏",g_time[MENU_GetIndex(menu)]);
|
|
MSGBOX_TipsTime ((WIN_WindowStruct*)menu,"提示",txt ,"确定",5000);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//消息处理函数
|
|
void MENU_LightSetMsgLoop (WIN_MenuStruct *menu,WIN_MsgStruct *msg)
|
|
{
|
|
WIN_MoveStruct *m=0;
|
|
WIN_TouchStruct *t=0;
|
|
WIN_KeyStruct *k=0;
|
|
switch (msg->msg)
|
|
{
|
|
case WIN_MSG_KEY:
|
|
k=msg->data.p;
|
|
if (k->shortPress&KEY_VALUE_ENTER)
|
|
{
|
|
MENU_Enter(menu);
|
|
}
|
|
else
|
|
{
|
|
MENU_DefaultMsgLoop (menu,msg);
|
|
}
|
|
break;//case WIN_MSG_KEY:
|
|
case WIN_MSG_MOVE:
|
|
m=msg->data.p;
|
|
switch (m->moveType)
|
|
{
|
|
case MOVE_DATA_SHORT:
|
|
if (m->y_move>((WIN_WindowStruct *)menu)->y_size/2-20&&m->y_move<((WIN_WindowStruct *)menu)->y_size/2+20)
|
|
{
|
|
MENU_Enter(menu);
|
|
}
|
|
break;
|
|
default:
|
|
MENU_DefaultMsgLoop (menu,msg);
|
|
break;
|
|
}
|
|
break;
|
|
case WIN_MSG_CHID:
|
|
switch (msg->data.v)
|
|
{
|
|
case CHID_DELETE:
|
|
break;
|
|
case CHID_USER:
|
|
{
|
|
if (msg->srcWin==menu->bar)
|
|
{
|
|
if (msg->data2.v==SCROLLBAR_PRESSED)
|
|
{
|
|
MENU_Enter(menu);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MENU_DefaultMsgLoop (menu,msg);
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
default:
|
|
MENU_DefaultMsgLoop (menu,msg);
|
|
break;
|
|
}
|
|
}
|