#include "include.h" #include "func.h" #include "func_menu.h" #if TRACE_EN #define TRACE(...) printf(__VA_ARGS__) #else #define TRACE(...) #endif #define SET_LIST_CNT ((int)(sizeof(tbl_setting_list) / sizeof(tbl_setting_list[0]))) enum { COMPO_ID_LISTBOX = 1, }; //组件ID enum{ COMPO_ID_BIN_ON = 1, COMPO_ID_BIN_OFF, COMPO_ID_BIN_CHANGE, }; typedef struct f_geneal_list_t_ { compo_listbox_t *listbox; } f_geneal_list_t; u8 func_general_list_idx = 0; static const compo_listbox_item_t tbl_setting_list[] = { {STR_SETTING_BT, UI_BUF_SETTING_GENERAL_BLUETOOTH_BIN, .item_mode = COMPO_LISTBOX_ITEM_MODE_SWITCH, .vidx = SYS_CTL_BT, .func_sta = FUNC_NULL}, //蓝牙 {STR_SETTING_ABOUT, UI_BUF_SETTING_GENERAL_ABOUT_BIN, .item_mode = COMPO_LISTBOX_ITEM_MODE_NORMAL, .vidx = 0, .func_sta = FUNC_SET_SUB_ABOUT}, //关于 {STR_SETTING_LANGUAGE, UI_BUF_SETTING_GENERAL_LANGUAGE_BIN, .item_mode = COMPO_LISTBOX_ITEM_MODE_NORMAL, .vidx = 0, .func_sta = FUNC_SET_SUB_LANGUAGE}, //语言设置 {STR_SETTING_QR_CODE, UI_BUF_SETTING_GENERAL_QR_CODE_BIN, .item_mode = COMPO_LISTBOX_ITEM_MODE_NORMAL, .vidx = 0, .func_sta = FUNC_SCAN}, //二维码 #if defined(TJD_XG_PROJECT_CUSTOMIZED_TZ1) #else {STR_SETTING_RSTFY, UI_BUF_SETTING_GENERAL_RESET_BIN, .item_mode = COMPO_LISTBOX_ITEM_MODE_NORMAL, .vidx = 0, .func_sta = FUNC_SET_SUB_RSTFY}, //恢复出厂 {STR_SETTING_RESTART, UI_BUF_SETTING_GENERAL_RESTART_BIN, .item_mode = COMPO_LISTBOX_ITEM_MODE_NORMAL, .vidx = 0, .func_sta = FUNC_SET_SUB_RESTART}, //重启 {STR_SETTING_OFF, UI_BUF_SETTING_GENERAL_SHUTDOWN_BIN, .item_mode = COMPO_LISTBOX_ITEM_MODE_NORMAL, .vidx = 0, .func_sta = FUNC_SET_SUB_OFF}, //关机 #endif }; //创建主菜单窗体,创建窗体中不要使用功能结构体 func_cb.f_cb compo_form_t *func_set_sub_general_form_create(void) { //新建窗体 compo_form_t *frm = compo_form_create(true); //设置标题栏 compo_form_set_mode(frm, COMPO_FORM_MODE_SHOW_TITLE | COMPO_FORM_MODE_SHOW_TIME); compo_form_set_title(frm, i18n[STR_GENERAL]); //新建菜单列表 compo_listbox_t *listbox = compo_listbox_create(frm, COMPO_LISTBOX_STYLE_TITLE_NORMAL); compo_listbox_set(listbox, tbl_setting_list, SET_LIST_CNT); compo_listbox_set_bgimg(listbox, UI_BUF_COMMON_BG_BIN); compo_setid(listbox, COMPO_ID_LISTBOX); compo_listbox_set_sta_icon(listbox, UI_BUF_COMMON_ON_BIN, UI_BUF_COMMON_OFF_BIN); compo_listbox_set_bithook(listbox, bsp_sys_get_ctlbit); //文字位置调整 // compo_listbox_set_item_text(listbox, 45, 26, 160, 40, false); if(bt_get_scan()||bt_is_connected()) bsp_sys_set_ctlbit(tbl_setting_list[0].vidx, TRUE); else bsp_sys_set_ctlbit(tbl_setting_list[0].vidx, FALSE); if (func_general_list_idx < 1) { func_general_list_idx = 1; } compo_listbox_set_focus_byidx(listbox, func_general_list_idx); compo_listbox_update(listbox); return frm; } //点进图标进入应用 static void func_set_sub_general_icon_click(void) { int icon_idx; f_geneal_list_t *f_geneal = (f_geneal_list_t *)func_cb.f_cb; compo_listbox_t *listbox = f_geneal->listbox; u8 func_sta; icon_idx = compo_listbox_select(listbox, ctp_get_sxy()); if (icon_idx == 0) { if(bt_get_scan()) { if (bt_is_connected()) { bt_disconnect(0); } bt_scan_disable(); bsp_sys_set_ctlbit(tbl_setting_list[icon_idx].vidx, FALSE); }else { bt_scan_enable(); bsp_sys_set_ctlbit(tbl_setting_list[0].vidx, TRUE); } compo_listbox_update(listbox); } if (icon_idx < 0 || icon_idx >= SET_LIST_CNT) { return; } //根据图标索引获取应用ID func_sta = tbl_setting_list[icon_idx].func_sta; //切入应用 if (func_sta > 0) { // compo_form_t *frm = func_create_form(func_sta); // func_switching(FUNC_SWITCH_ZOOM_FADE | FUNC_SWITCH_AUTO, listbox->sel_icon); // compo_form_destroy(frm); func_switch_to_assign_screen(func_sta, false); func_general_list_idx = listbox->focus_icon_idx; } } //切换到通用页面 static void func_set_sub_general_switch_to_clock(void) { u8 func_sta = FUNC_CLOCK; f_geneal_list_t *f_geneal = (f_geneal_list_t *)func_cb.f_cb; compo_listbox_t *listbox = f_geneal->listbox; widget_icon_t *icon = compo_listbox_select_byidx(listbox, 0); compo_form_t *frm = func_create_form(func_sta); func_switching(FUNC_SWITCH_ZOOM_FADE_ENTER | FUNC_SWITCH_AUTO, icon); compo_form_destroy(frm); func_switch_to_assign_screen(func_sta, false); func_general_list_idx = 0; } //通用功能事件处理 static void func_set_general_list_process(void) { f_geneal_list_t *f_geneal = (f_geneal_list_t *)func_cb.f_cb; compo_listbox_move(f_geneal->listbox); func_process(); } //进入通用菜单页面 static void func_set_general_sub_list_enter(void) { func_cb.f_cb = func_zalloc(sizeof(f_geneal_list_t)); func_cb.frm_main = func_set_sub_general_form_create(); f_geneal_list_t *f_geneal = (f_geneal_list_t *)func_cb.f_cb; f_geneal->listbox = compo_getobj_byid(COMPO_ID_LISTBOX); compo_listbox_t *listbox = f_geneal->listbox; if (listbox->type != COMPO_TYPE_LISTBOX) { halt(HALT_GUI_COMPO_LISTBOX_TYPE); } listbox->mcb = func_zalloc(sizeof(compo_listbox_move_cb_t)); //建立移动控制块,退出时需要释放 printf(">>>mcb 0x%x\n", listbox->mcb); compo_listbox_move_init_modify(listbox, compo_listbox_gety_byidx(listbox, 1), compo_listbox_gety_byidx(listbox, SET_LIST_CNT - 2)); func_cb.enter_tick = tick_get(); } //主菜单功能消息处理 static void func_set_general_list_message(size_msg_t msg) { f_geneal_list_t *f_geneal = (f_geneal_list_t *)func_cb.f_cb; compo_listbox_t *listbox = f_geneal->listbox; if (compo_listbox_message(listbox, msg)) { return; //处理列表框信息 } switch (msg) { case MSG_CTP_CLICK: func_set_sub_general_icon_click(); //单击图标 break; case MSG_CTP_LONG: break; case MSG_CTP_SHORT_RIGHT: func_message(msg); if (func_cb.sta != FUNC_SET_GENERAL) { func_general_list_idx = 0; } break; case KU_DELAY_BACK: if (tick_check_expire(func_cb.enter_tick, TICK_IGNORE_KEY)) { func_set_sub_general_switch_to_clock(); //返回设置界面 } break; default: func_message(msg); break; } } //退出通用样式 void func_set_general_exit(void) { f_geneal_list_t *f_geneal = (f_geneal_list_t *)func_cb.f_cb; compo_listbox_t *listbox = f_geneal->listbox; printf("0x%x\n", listbox->mcb); func_free(listbox->mcb); //释放移动控制块 func_cb.last = FUNC_SET_GENERAL; printf("func_set_general_exit\r\n"); } //通用功能 void func_set_general_list(void) { func_set_general_sub_list_enter(); while (func_cb.sta == FUNC_SET_GENERAL) { func_set_general_list_process(); func_set_general_list_message(msg_dequeue()); } func_set_general_exit(); }