88 lines
2.3 KiB
C
88 lines
2.3 KiB
C
#include "mywin_user_theme.h"
|
|
#include "flash_manager.h"
|
|
#include "mywin_inc.h"
|
|
#include "mywin_user_menu.h"
|
|
#include "system_file.h"
|
|
|
|
#include "date.h"
|
|
|
|
const static MENU_ItemStruct ptr[] = {
|
|
{0, "主题1"},
|
|
{0, "主题2"},
|
|
{0, "主题3"},
|
|
{0, "主题4"},
|
|
|
|
};
|
|
|
|
const static char *g_picName[4] = {"1.pic", "2.pic", "3.pic", "4.pic"};
|
|
|
|
// 进入
|
|
WIN_MenuStruct *MENU_ThemeSet(WIN_WindowStruct *base) {
|
|
WIN_MenuStruct *menu = WIN_CreatMenu(
|
|
base, (void (*)(WIN_WindowStruct *, WIN_MsgStruct *))MENU_ThemeSetMsgLoop,
|
|
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, 4);
|
|
for (int i = 0; i < 4; 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_SetBackPicPath((char *)g_picName[MENU_GetIndex(menu)]);
|
|
WIN_WindowStruct *home = WIN_GetWinByTitle(0, "home");
|
|
if (home) {
|
|
WIN_SetBackPicPath(home, SysFile_GetSysFile()->backPicPath);
|
|
MSGBOX_TipsTime((WIN_WindowStruct *)menu, "提示", "主题已更改", "确定",
|
|
5000);
|
|
} else {
|
|
MSGBOX_TipsTime((WIN_WindowStruct *)menu, "提示", "主题设置失败", "确定",
|
|
5000);
|
|
}
|
|
// 这里刷新新的背景
|
|
WIN_SetInvalid((WIN_WindowStruct *)menu);
|
|
//((WIN_WindowStruct *)menu)->deleteWindow((WIN_WindowStruct *)menu);
|
|
}
|
|
|
|
// 消息处理函数
|
|
void MENU_ThemeSetMsgLoop(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;
|
|
default:
|
|
MENU_DefaultMsgLoop(menu, msg);
|
|
break;
|
|
}
|
|
}
|