From 1109c4d4c9ff7d4fc2b1475312334a859c9200ec Mon Sep 17 00:00:00 2001 From: idea4good Date: Sat, 17 Oct 2020 15:20:37 +0800 Subject: [PATCH 01/12] helloWidgets ok --- HelloWidgets/UIcode/GuiLite.h | 220 ++++++++------------------------- HelloWidgets/UIcode/UIcode.cpp | 23 ++-- 2 files changed, 62 insertions(+), 181 deletions(-) diff --git a/HelloWidgets/UIcode/GuiLite.h b/HelloWidgets/UIcode/GuiLite.h index 4df4afa..de5a678 100644 --- a/HelloWidgets/UIcode/GuiLite.h +++ b/HelloWidgets/UIcode/GuiLite.h @@ -102,123 +102,6 @@ public: int m_right; int m_bottom; }; -#define MSG_TYPE_INVALID 0xFFFF -#define MSG_TYPE_WND 0x0001 -#define MSG_TYPE_USR 0x0002 -#define USR_MSG_MAX 32 -class c_cmd_target; -typedef void (c_cmd_target::*msgCallback)(int, int); -struct GL_MSG_ENTRY -{ - unsigned int msgType; - unsigned int msgId; - c_cmd_target* object; - msgCallback callBack; -}; -#define ON_GL_USER_MSG(msgId, func) \ -{MSG_TYPE_USR, msgId, 0, msgCallback(&func)}, -#define GL_DECLARE_MESSAGE_MAP() \ -protected: \ - virtual const GL_MSG_ENTRY* get_msg_entries() const;\ -private: \ - static const GL_MSG_ENTRY m_msg_entries[]; -#define GL_BEGIN_MESSAGE_MAP(theClass) \ -const GL_MSG_ENTRY* theClass::get_msg_entries() const \ -{ \ - return theClass::m_msg_entries; \ -} \ -const GL_MSG_ENTRY theClass::m_msg_entries[] = \ -{ -#define GL_END_MESSAGE_MAP() \ -{MSG_TYPE_INVALID, 0, 0, 0}}; -class c_cmd_target -{ -public: - static int handle_usr_msg(int msg_id, int resource_id, int param) - { - int i; - c_cmd_target* p_wnd = 0; - for (i = 0; i < ms_user_map_size; i++) - { - if (msg_id == ms_usr_map_entries[i].msgId) - { - p_wnd = (c_cmd_target*)ms_usr_map_entries[i].object; - (p_wnd->*ms_usr_map_entries[i].callBack)(resource_id, param); - } - } - return 1; - } -protected: - void load_cmd_msg() - { - const GL_MSG_ENTRY* p_entry = get_msg_entries(); - if (0 == p_entry) - { - return; - } - bool bExist = false; - while (MSG_TYPE_INVALID != p_entry->msgType) - { - if (MSG_TYPE_WND == p_entry->msgType) - { - p_entry++; - continue; - } - bExist = false; - for (int i = 0; i < ms_user_map_size; i++) - { - //repeat register, return. - if (p_entry->msgId == ms_usr_map_entries[i].msgId - && ms_usr_map_entries[i].object == this) - { - bExist = true; - break; - } - } - if (true == bExist) - { - p_entry++; - continue; - } - if (MSG_TYPE_USR == p_entry->msgType) - { - if (USR_MSG_MAX == ms_user_map_size) - { - ASSERT(false); - } - ms_usr_map_entries[ms_user_map_size] = *p_entry; - ms_usr_map_entries[ms_user_map_size].object = this; - ms_user_map_size++; - } - else - { - ASSERT(false); - break; - } - p_entry++; - } - } - const GL_MSG_ENTRY* find_msg_entry(const GL_MSG_ENTRY *pEntry, int msgType, int msgId) - { - if (MSG_TYPE_INVALID == msgType) - { - return 0; - } - while (MSG_TYPE_INVALID != pEntry->msgType) - { - if ((msgType == pEntry->msgType) && (msgId == pEntry->msgId)) - { - return pEntry; - } - pEntry++; - } - return 0; - } -private: - static GL_MSG_ENTRY ms_usr_map_entries[USR_MSG_MAX]; - static unsigned short ms_user_map_size; - GL_DECLARE_MESSAGE_MAP() -}; //BITMAP typedef struct struct_bitmap_info { @@ -1329,9 +1212,9 @@ typedef struct struct_wnd_tree short height; struct struct_wnd_tree* p_child_tree;//sub tree }WND_TREE; -class c_wnd : public c_cmd_target +typedef void (c_wnd::*WND_CALLBACK)(int, int); +class c_wnd { - friend class c_dialog; public: c_wnd() : m_status(STATUS_NORMAL), m_attr((WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS)), m_parent(0), m_top_child(0), m_prev_sibling(0), m_next_sibling(0), m_str(0), m_font_color(0), m_bg_color(0), m_id(0), m_z_order(Z_ORDER_LEVEL_0), m_focus_child(0), m_surface(0) {}; @@ -1370,7 +1253,6 @@ public: } if (load_child_wnd(p_child_tree) >= 0) { - load_cmd_msg(); on_init_children(); } return 0; @@ -1549,19 +1431,6 @@ public: } c_wnd* get_prev_sibling() const { return m_prev_sibling; } c_wnd* get_next_sibling() const { return m_next_sibling; } - void notify_parent(int msg_id, int param) - { - if (!m_parent) - { - return; - } - const GL_MSG_ENTRY* entry = m_parent->find_msg_entry(m_parent->get_msg_entries(), MSG_TYPE_WND, msg_id); - if (0 == entry) - { - return; - } - (m_parent->*(entry->callBack))(m_id, param); - } virtual void on_touch(int x, int y, TOUCH_ACTION action) { x -= m_wnd_rect.m_left; @@ -1733,6 +1602,7 @@ protected: virtual void on_focus() {}; virtual void on_kill_focus() {}; protected: + unsigned short m_id; WND_STATUS m_status; WND_ATTRIBUTION m_attr; c_rect m_wnd_rect; //position relative to parent window. @@ -1740,23 +1610,18 @@ protected: c_wnd* m_top_child; //the first sub window would be navigated c_wnd* m_prev_sibling; //previous brother c_wnd* m_next_sibling; //next brother + c_wnd* m_focus_child; //current focused window const char* m_str; //caption const FONT_INFO* m_font_type; unsigned int m_font_color; unsigned int m_bg_color; - unsigned short m_id; int m_z_order; //the graphic level for rendering - c_wnd* m_focus_child; //current focused window c_surface* m_surface; -private: - c_wnd(const c_wnd &win); - c_wnd& operator=(const c_wnd &win); }; -#define GL_BN_CLICKED 0x1111 -#define ON_GL_BN_CLICKED(func) {MSG_TYPE_WND, GL_BN_CLICKED, 0, msgCallback(&func)}, -typedef struct struct_bitmap_info BITMAP_INFO; class c_button : public c_wnd { +public: + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void on_paint() { @@ -1819,7 +1684,10 @@ protected: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_BN_CLICKED, 0); + if(on_click) + { + (m_parent->*(on_click))(m_id, 0); + } } } virtual void on_navigate(NAVIGATION_KEY key) @@ -1836,6 +1704,7 @@ protected: } return c_wnd::on_navigate(key); } + WND_CALLBACK on_click = 0; }; class c_surface; class c_dialog; @@ -2006,8 +1875,21 @@ public: } return -1; } + virtual void on_init_children() + { + c_wnd* child = m_top_child; + if (0 != child) + { + while (child) + { + ((c_button*)child)->set_on_click(WND_CALLBACK(&c_keyboard::on_key_clicked)); + child = child->get_next_sibling(); + } + } + } KEYBOARD_STATUS get_cap_status(){return m_cap_status;} char* get_str() { return m_str; } + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void pre_create_wnd() { @@ -2064,7 +1946,7 @@ protected: ASSERT(false); InputChar: m_str[m_str_len++] = id; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_del_clicked(int id, int param) { @@ -2073,7 +1955,7 @@ protected: return; } m_str[--m_str_len] = 0; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_caps_clicked(int id, int param) { @@ -2083,18 +1965,18 @@ protected: void on_enter_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - return notify_parent(KEYBORAD_CLICK, CLICK_ENTER); + (m_parent->*(on_click))(m_id, CLICK_ENTER); } void on_esc_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - notify_parent(KEYBORAD_CLICK, CLICK_ESC); + (m_parent->*(on_click))(m_id, CLICK_ESC); } - GL_DECLARE_MESSAGE_MAP() private: char m_str[32]; int m_str_len; KEYBOARD_STATUS m_cap_status; + WND_CALLBACK on_click; }; class c_keyboard_button : public c_button { @@ -2284,11 +2166,11 @@ protected: break; } } - GL_DECLARE_MESSAGE_MAP() private: void show_keyboard() { s_keyboard.connect(this, IDD_KEY_BOARD, m_kb_style); + s_keyboard.set_on_click(WND_CALLBACK(&c_edit::on_key_board_click)); s_keyboard.show_window(); } void on_touch_down(int x, int y) @@ -2368,12 +2250,12 @@ protected: }; #include #define MAX_ITEM_NUM 4 -#define GL_LIST_CONFIRM 0x1 #define ITEM_HEIGHT 45 -#define ON_LIST_CONFIRM(func) {MSG_TYPE_WND, GL_LIST_CONFIRM, 0, msgCallback(&func)}, class c_list_box : public c_wnd { public: + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } + short get_item_count() { return m_item_total; } int add_item(char* str) { if (m_item_total >= MAX_ITEM_NUM) @@ -2391,7 +2273,6 @@ public: memset(m_item_array, 0, sizeof(m_item_array)); update_list_size(); } - short get_item_count() { return m_item_total; } void select_item(short index) { if (index < 0 || index >= m_item_total) @@ -2546,7 +2427,10 @@ private: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } } } @@ -2569,7 +2453,10 @@ private: m_status = STATUS_FOCUSED; select_item((y - m_list_wnd_rect.m_top) / ITEM_HEIGHT); on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } else { @@ -2582,6 +2469,7 @@ private: char* m_item_array[MAX_ITEM_NUM]; c_rect m_list_wnd_rect; //rect relative to parent wnd. c_rect m_list_screen_rect; //rect relative to physical screen(frame buffer) + WND_CALLBACK on_change; }; #include #define MAX_PAGES 5 @@ -2920,8 +2808,6 @@ inline void c_slide_group::on_touch(int x, int y, TOUCH_ACTION action) } #define ID_BT_ARROW_UP 0x1111 #define ID_BT_ARROW_DOWN 0x2222 -#define GL_SPIN_CHANGE 0x3333 -#define ON_SPIN_CHANGE(func) {MSG_TYPE_WND, GL_SPIN_CHANGE, 0, msgCallback(&func)}, class c_spin_box; class c_spin_button : public c_button { @@ -2942,6 +2828,7 @@ public: short get_step() { return m_step; } void set_value_digit(short digit) { m_digit = digit; } short get_value_digit() { return m_digit; } + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } protected: virtual void on_paint() { @@ -2974,7 +2861,10 @@ protected: return; } m_cur_value += m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } void on_arrow_down_bt_click() @@ -2984,7 +2874,10 @@ protected: return; } m_cur_value -= m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } short m_cur_value; @@ -2995,6 +2888,7 @@ protected: short m_digit; c_spin_button m_bt_up; c_spin_button m_bt_down; + WND_CALLBACK on_change; }; inline void c_spin_button::on_touch(int x, int y, TOUCH_ACTION action) { @@ -3451,12 +3345,6 @@ private: unsigned char m_frame_len_map[64]; unsigned char m_frame_len_map_index; }; -#ifdef GUILITE_ON -GL_MSG_ENTRY c_cmd_target::ms_usr_map_entries[USR_MSG_MAX]; -unsigned short c_cmd_target::ms_user_map_size; -GL_BEGIN_MESSAGE_MAP(c_cmd_target) -GL_END_MESSAGE_MAP() -#endif #ifdef GUILITE_ON @@ -4305,9 +4193,6 @@ DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX]; #endif #ifdef GUILITE_ON c_keyboard c_edit::s_keyboard; -GL_BEGIN_MESSAGE_MAP(c_edit) -ON_KEYBORAD_UPDATE(c_edit::on_key_board_click) -GL_END_MESSAGE_MAP() #endif #ifdef GUILITE_ON static c_keyboard_button s_key_0, s_key_1, s_key_2, s_key_3, s_key_4, s_key_5, s_key_6, s_key_7, s_key_8, s_key_9; @@ -4375,7 +4260,4 @@ WND_TREE g_number_board_children[] = {&s_key_enter,'\n', 0, POS_X(3), POS_Y(2), KEY_WIDTH, KEY_HEIGHT * 2 + 2}, {0,0,0,0,0,0,0} }; -GL_BEGIN_MESSAGE_MAP(c_keyboard) -ON_GL_BN_CLICKED(c_keyboard::on_key_clicked) -GL_END_MESSAGE_MAP() #endif diff --git a/HelloWidgets/UIcode/UIcode.cpp b/HelloWidgets/UIcode/UIcode.cpp index 5a74344..e48aa75 100644 --- a/HelloWidgets/UIcode/UIcode.cpp +++ b/HelloWidgets/UIcode/UIcode.cpp @@ -27,6 +27,9 @@ class c_my_ui : public c_wnd { virtual void on_init_children() { + c_button* button = (c_button*)get_wnd_ptr(ID_BUTTON); + button->set_on_click((WND_CALLBACK)&c_my_ui::on_button_clicked); + c_edit* edit = (c_edit*)get_wnd_ptr(ID_EDIT_1); edit->set_keyboard_style(STYLE_ALL_BOARD); @@ -34,6 +37,7 @@ class c_my_ui : public c_wnd edit->set_keyboard_style(STYLE_NUM_BOARD); c_list_box *list_box = (c_list_box*)get_wnd_ptr(ID_LIST_BOX); + list_box->set_on_change((WND_CALLBACK)&c_my_ui::on_listbox_confirm); list_box->clear_item(); list_box->add_item((char*)"Item 0"); list_box->add_item((char*)"Item 1"); @@ -41,6 +45,7 @@ class c_my_ui : public c_wnd list_box->select_item(0); c_spin_box *spin_box = (c_spin_box*)get_wnd_ptr(ID_SPIN_BOX); + spin_box->set_on_change((WND_CALLBACK)&c_my_ui::on_spinbox_change); spin_box->set_max_min(9, 0); spin_box->set_step(1); spin_box->set_value(5); @@ -78,17 +83,16 @@ class c_my_ui : public c_wnd label->set_str(str); label->show_window(); } - GL_DECLARE_MESSAGE_MAP()//delcare message }; -GL_BEGIN_MESSAGE_MAP(c_my_ui) -ON_GL_BN_CLICKED(c_my_ui::on_button_clicked) -ON_SPIN_CHANGE(c_my_ui::on_spinbox_change) -ON_LIST_CONFIRM(c_my_ui::on_listbox_confirm) -GL_END_MESSAGE_MAP() - class c_my_dialog : public c_dialog { + virtual void on_init_children() + { + c_button* button = (c_button*)get_wnd_ptr(ID_DIALOG_EXIT_BUTTON); + button->set_on_click((WND_CALLBACK)&c_my_dialog::on_button_clicked); + } + void on_button_clicked(int ctrl_id, int param) { switch (ctrl_id) @@ -100,13 +104,8 @@ class c_my_dialog : public c_dialog break; } } - GL_DECLARE_MESSAGE_MAP()//delcare message }; -GL_BEGIN_MESSAGE_MAP(c_my_dialog) -ON_GL_BN_CLICKED(c_my_dialog::on_button_clicked) -GL_END_MESSAGE_MAP() - // Layout Widgets static c_my_ui s_my_ui; static c_label s_label_1, s_label_2, s_label_3; -- Gitee From da0a593a52c3fe7936e65e63c2144045b52e9357 Mon Sep 17 00:00:00 2001 From: idea4good Date: Sun, 18 Oct 2020 00:18:27 +0800 Subject: [PATCH 02/12] helloAnimation ok --- HelloAnimation/UIcode/GuiLite.h | 220 +++++++------------------------ HelloAnimation/UIcode/UIcode.cpp | 11 +- 2 files changed, 56 insertions(+), 175 deletions(-) diff --git a/HelloAnimation/UIcode/GuiLite.h b/HelloAnimation/UIcode/GuiLite.h index 4df4afa..de5a678 100644 --- a/HelloAnimation/UIcode/GuiLite.h +++ b/HelloAnimation/UIcode/GuiLite.h @@ -102,123 +102,6 @@ public: int m_right; int m_bottom; }; -#define MSG_TYPE_INVALID 0xFFFF -#define MSG_TYPE_WND 0x0001 -#define MSG_TYPE_USR 0x0002 -#define USR_MSG_MAX 32 -class c_cmd_target; -typedef void (c_cmd_target::*msgCallback)(int, int); -struct GL_MSG_ENTRY -{ - unsigned int msgType; - unsigned int msgId; - c_cmd_target* object; - msgCallback callBack; -}; -#define ON_GL_USER_MSG(msgId, func) \ -{MSG_TYPE_USR, msgId, 0, msgCallback(&func)}, -#define GL_DECLARE_MESSAGE_MAP() \ -protected: \ - virtual const GL_MSG_ENTRY* get_msg_entries() const;\ -private: \ - static const GL_MSG_ENTRY m_msg_entries[]; -#define GL_BEGIN_MESSAGE_MAP(theClass) \ -const GL_MSG_ENTRY* theClass::get_msg_entries() const \ -{ \ - return theClass::m_msg_entries; \ -} \ -const GL_MSG_ENTRY theClass::m_msg_entries[] = \ -{ -#define GL_END_MESSAGE_MAP() \ -{MSG_TYPE_INVALID, 0, 0, 0}}; -class c_cmd_target -{ -public: - static int handle_usr_msg(int msg_id, int resource_id, int param) - { - int i; - c_cmd_target* p_wnd = 0; - for (i = 0; i < ms_user_map_size; i++) - { - if (msg_id == ms_usr_map_entries[i].msgId) - { - p_wnd = (c_cmd_target*)ms_usr_map_entries[i].object; - (p_wnd->*ms_usr_map_entries[i].callBack)(resource_id, param); - } - } - return 1; - } -protected: - void load_cmd_msg() - { - const GL_MSG_ENTRY* p_entry = get_msg_entries(); - if (0 == p_entry) - { - return; - } - bool bExist = false; - while (MSG_TYPE_INVALID != p_entry->msgType) - { - if (MSG_TYPE_WND == p_entry->msgType) - { - p_entry++; - continue; - } - bExist = false; - for (int i = 0; i < ms_user_map_size; i++) - { - //repeat register, return. - if (p_entry->msgId == ms_usr_map_entries[i].msgId - && ms_usr_map_entries[i].object == this) - { - bExist = true; - break; - } - } - if (true == bExist) - { - p_entry++; - continue; - } - if (MSG_TYPE_USR == p_entry->msgType) - { - if (USR_MSG_MAX == ms_user_map_size) - { - ASSERT(false); - } - ms_usr_map_entries[ms_user_map_size] = *p_entry; - ms_usr_map_entries[ms_user_map_size].object = this; - ms_user_map_size++; - } - else - { - ASSERT(false); - break; - } - p_entry++; - } - } - const GL_MSG_ENTRY* find_msg_entry(const GL_MSG_ENTRY *pEntry, int msgType, int msgId) - { - if (MSG_TYPE_INVALID == msgType) - { - return 0; - } - while (MSG_TYPE_INVALID != pEntry->msgType) - { - if ((msgType == pEntry->msgType) && (msgId == pEntry->msgId)) - { - return pEntry; - } - pEntry++; - } - return 0; - } -private: - static GL_MSG_ENTRY ms_usr_map_entries[USR_MSG_MAX]; - static unsigned short ms_user_map_size; - GL_DECLARE_MESSAGE_MAP() -}; //BITMAP typedef struct struct_bitmap_info { @@ -1329,9 +1212,9 @@ typedef struct struct_wnd_tree short height; struct struct_wnd_tree* p_child_tree;//sub tree }WND_TREE; -class c_wnd : public c_cmd_target +typedef void (c_wnd::*WND_CALLBACK)(int, int); +class c_wnd { - friend class c_dialog; public: c_wnd() : m_status(STATUS_NORMAL), m_attr((WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS)), m_parent(0), m_top_child(0), m_prev_sibling(0), m_next_sibling(0), m_str(0), m_font_color(0), m_bg_color(0), m_id(0), m_z_order(Z_ORDER_LEVEL_0), m_focus_child(0), m_surface(0) {}; @@ -1370,7 +1253,6 @@ public: } if (load_child_wnd(p_child_tree) >= 0) { - load_cmd_msg(); on_init_children(); } return 0; @@ -1549,19 +1431,6 @@ public: } c_wnd* get_prev_sibling() const { return m_prev_sibling; } c_wnd* get_next_sibling() const { return m_next_sibling; } - void notify_parent(int msg_id, int param) - { - if (!m_parent) - { - return; - } - const GL_MSG_ENTRY* entry = m_parent->find_msg_entry(m_parent->get_msg_entries(), MSG_TYPE_WND, msg_id); - if (0 == entry) - { - return; - } - (m_parent->*(entry->callBack))(m_id, param); - } virtual void on_touch(int x, int y, TOUCH_ACTION action) { x -= m_wnd_rect.m_left; @@ -1733,6 +1602,7 @@ protected: virtual void on_focus() {}; virtual void on_kill_focus() {}; protected: + unsigned short m_id; WND_STATUS m_status; WND_ATTRIBUTION m_attr; c_rect m_wnd_rect; //position relative to parent window. @@ -1740,23 +1610,18 @@ protected: c_wnd* m_top_child; //the first sub window would be navigated c_wnd* m_prev_sibling; //previous brother c_wnd* m_next_sibling; //next brother + c_wnd* m_focus_child; //current focused window const char* m_str; //caption const FONT_INFO* m_font_type; unsigned int m_font_color; unsigned int m_bg_color; - unsigned short m_id; int m_z_order; //the graphic level for rendering - c_wnd* m_focus_child; //current focused window c_surface* m_surface; -private: - c_wnd(const c_wnd &win); - c_wnd& operator=(const c_wnd &win); }; -#define GL_BN_CLICKED 0x1111 -#define ON_GL_BN_CLICKED(func) {MSG_TYPE_WND, GL_BN_CLICKED, 0, msgCallback(&func)}, -typedef struct struct_bitmap_info BITMAP_INFO; class c_button : public c_wnd { +public: + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void on_paint() { @@ -1819,7 +1684,10 @@ protected: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_BN_CLICKED, 0); + if(on_click) + { + (m_parent->*(on_click))(m_id, 0); + } } } virtual void on_navigate(NAVIGATION_KEY key) @@ -1836,6 +1704,7 @@ protected: } return c_wnd::on_navigate(key); } + WND_CALLBACK on_click = 0; }; class c_surface; class c_dialog; @@ -2006,8 +1875,21 @@ public: } return -1; } + virtual void on_init_children() + { + c_wnd* child = m_top_child; + if (0 != child) + { + while (child) + { + ((c_button*)child)->set_on_click(WND_CALLBACK(&c_keyboard::on_key_clicked)); + child = child->get_next_sibling(); + } + } + } KEYBOARD_STATUS get_cap_status(){return m_cap_status;} char* get_str() { return m_str; } + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void pre_create_wnd() { @@ -2064,7 +1946,7 @@ protected: ASSERT(false); InputChar: m_str[m_str_len++] = id; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_del_clicked(int id, int param) { @@ -2073,7 +1955,7 @@ protected: return; } m_str[--m_str_len] = 0; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_caps_clicked(int id, int param) { @@ -2083,18 +1965,18 @@ protected: void on_enter_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - return notify_parent(KEYBORAD_CLICK, CLICK_ENTER); + (m_parent->*(on_click))(m_id, CLICK_ENTER); } void on_esc_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - notify_parent(KEYBORAD_CLICK, CLICK_ESC); + (m_parent->*(on_click))(m_id, CLICK_ESC); } - GL_DECLARE_MESSAGE_MAP() private: char m_str[32]; int m_str_len; KEYBOARD_STATUS m_cap_status; + WND_CALLBACK on_click; }; class c_keyboard_button : public c_button { @@ -2284,11 +2166,11 @@ protected: break; } } - GL_DECLARE_MESSAGE_MAP() private: void show_keyboard() { s_keyboard.connect(this, IDD_KEY_BOARD, m_kb_style); + s_keyboard.set_on_click(WND_CALLBACK(&c_edit::on_key_board_click)); s_keyboard.show_window(); } void on_touch_down(int x, int y) @@ -2368,12 +2250,12 @@ protected: }; #include #define MAX_ITEM_NUM 4 -#define GL_LIST_CONFIRM 0x1 #define ITEM_HEIGHT 45 -#define ON_LIST_CONFIRM(func) {MSG_TYPE_WND, GL_LIST_CONFIRM, 0, msgCallback(&func)}, class c_list_box : public c_wnd { public: + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } + short get_item_count() { return m_item_total; } int add_item(char* str) { if (m_item_total >= MAX_ITEM_NUM) @@ -2391,7 +2273,6 @@ public: memset(m_item_array, 0, sizeof(m_item_array)); update_list_size(); } - short get_item_count() { return m_item_total; } void select_item(short index) { if (index < 0 || index >= m_item_total) @@ -2546,7 +2427,10 @@ private: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } } } @@ -2569,7 +2453,10 @@ private: m_status = STATUS_FOCUSED; select_item((y - m_list_wnd_rect.m_top) / ITEM_HEIGHT); on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } else { @@ -2582,6 +2469,7 @@ private: char* m_item_array[MAX_ITEM_NUM]; c_rect m_list_wnd_rect; //rect relative to parent wnd. c_rect m_list_screen_rect; //rect relative to physical screen(frame buffer) + WND_CALLBACK on_change; }; #include #define MAX_PAGES 5 @@ -2920,8 +2808,6 @@ inline void c_slide_group::on_touch(int x, int y, TOUCH_ACTION action) } #define ID_BT_ARROW_UP 0x1111 #define ID_BT_ARROW_DOWN 0x2222 -#define GL_SPIN_CHANGE 0x3333 -#define ON_SPIN_CHANGE(func) {MSG_TYPE_WND, GL_SPIN_CHANGE, 0, msgCallback(&func)}, class c_spin_box; class c_spin_button : public c_button { @@ -2942,6 +2828,7 @@ public: short get_step() { return m_step; } void set_value_digit(short digit) { m_digit = digit; } short get_value_digit() { return m_digit; } + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } protected: virtual void on_paint() { @@ -2974,7 +2861,10 @@ protected: return; } m_cur_value += m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } void on_arrow_down_bt_click() @@ -2984,7 +2874,10 @@ protected: return; } m_cur_value -= m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } short m_cur_value; @@ -2995,6 +2888,7 @@ protected: short m_digit; c_spin_button m_bt_up; c_spin_button m_bt_down; + WND_CALLBACK on_change; }; inline void c_spin_button::on_touch(int x, int y, TOUCH_ACTION action) { @@ -3451,12 +3345,6 @@ private: unsigned char m_frame_len_map[64]; unsigned char m_frame_len_map_index; }; -#ifdef GUILITE_ON -GL_MSG_ENTRY c_cmd_target::ms_usr_map_entries[USR_MSG_MAX]; -unsigned short c_cmd_target::ms_user_map_size; -GL_BEGIN_MESSAGE_MAP(c_cmd_target) -GL_END_MESSAGE_MAP() -#endif #ifdef GUILITE_ON @@ -4305,9 +4193,6 @@ DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX]; #endif #ifdef GUILITE_ON c_keyboard c_edit::s_keyboard; -GL_BEGIN_MESSAGE_MAP(c_edit) -ON_KEYBORAD_UPDATE(c_edit::on_key_board_click) -GL_END_MESSAGE_MAP() #endif #ifdef GUILITE_ON static c_keyboard_button s_key_0, s_key_1, s_key_2, s_key_3, s_key_4, s_key_5, s_key_6, s_key_7, s_key_8, s_key_9; @@ -4375,7 +4260,4 @@ WND_TREE g_number_board_children[] = {&s_key_enter,'\n', 0, POS_X(3), POS_Y(2), KEY_WIDTH, KEY_HEIGHT * 2 + 2}, {0,0,0,0,0,0,0} }; -GL_BEGIN_MESSAGE_MAP(c_keyboard) -ON_GL_BN_CLICKED(c_keyboard::on_key_clicked) -GL_END_MESSAGE_MAP() #endif diff --git a/HelloAnimation/UIcode/UIcode.cpp b/HelloAnimation/UIcode/UIcode.cpp index b655803..bc4d33c 100644 --- a/HelloAnimation/UIcode/UIcode.cpp +++ b/HelloAnimation/UIcode/UIcode.cpp @@ -19,6 +19,11 @@ BITMAP_INFO s_frames[] = { frame_00_bmp, frame_01_bmp, frame_02_bmp, frame_03_b class c_myUI : public c_wnd { + virtual void on_init_children() + { + c_button* button = (c_button*)get_wnd_ptr(ID_BUTTON); + button->set_on_click((WND_CALLBACK)&c_myUI::on_clicked); + } virtual void on_paint(void) { c_rect rect; @@ -38,14 +43,8 @@ class c_myUI : public c_wnd thread_sleep(60); } } - GL_DECLARE_MESSAGE_MAP()//delcare message }; -//map message -GL_BEGIN_MESSAGE_MAP(c_myUI) -ON_GL_BN_CLICKED(c_myUI::on_clicked) -GL_END_MESSAGE_MAP() - //////////////////////// layout UI //////////////////////// static c_myUI s_myUI; static c_button s_button; -- Gitee From 46789b22de2825958da95559773bcbacb7b71eed Mon Sep 17 00:00:00 2001 From: idea4good Date: Sun, 18 Oct 2020 00:26:56 +0800 Subject: [PATCH 03/12] helloFont ok --- HelloFont/UIcode/GuiLite.h | 220 +++++++++--------------------------- HelloFont/UIcode/UIcode.cpp | 11 +- 2 files changed, 56 insertions(+), 175 deletions(-) diff --git a/HelloFont/UIcode/GuiLite.h b/HelloFont/UIcode/GuiLite.h index 4df4afa..de5a678 100644 --- a/HelloFont/UIcode/GuiLite.h +++ b/HelloFont/UIcode/GuiLite.h @@ -102,123 +102,6 @@ public: int m_right; int m_bottom; }; -#define MSG_TYPE_INVALID 0xFFFF -#define MSG_TYPE_WND 0x0001 -#define MSG_TYPE_USR 0x0002 -#define USR_MSG_MAX 32 -class c_cmd_target; -typedef void (c_cmd_target::*msgCallback)(int, int); -struct GL_MSG_ENTRY -{ - unsigned int msgType; - unsigned int msgId; - c_cmd_target* object; - msgCallback callBack; -}; -#define ON_GL_USER_MSG(msgId, func) \ -{MSG_TYPE_USR, msgId, 0, msgCallback(&func)}, -#define GL_DECLARE_MESSAGE_MAP() \ -protected: \ - virtual const GL_MSG_ENTRY* get_msg_entries() const;\ -private: \ - static const GL_MSG_ENTRY m_msg_entries[]; -#define GL_BEGIN_MESSAGE_MAP(theClass) \ -const GL_MSG_ENTRY* theClass::get_msg_entries() const \ -{ \ - return theClass::m_msg_entries; \ -} \ -const GL_MSG_ENTRY theClass::m_msg_entries[] = \ -{ -#define GL_END_MESSAGE_MAP() \ -{MSG_TYPE_INVALID, 0, 0, 0}}; -class c_cmd_target -{ -public: - static int handle_usr_msg(int msg_id, int resource_id, int param) - { - int i; - c_cmd_target* p_wnd = 0; - for (i = 0; i < ms_user_map_size; i++) - { - if (msg_id == ms_usr_map_entries[i].msgId) - { - p_wnd = (c_cmd_target*)ms_usr_map_entries[i].object; - (p_wnd->*ms_usr_map_entries[i].callBack)(resource_id, param); - } - } - return 1; - } -protected: - void load_cmd_msg() - { - const GL_MSG_ENTRY* p_entry = get_msg_entries(); - if (0 == p_entry) - { - return; - } - bool bExist = false; - while (MSG_TYPE_INVALID != p_entry->msgType) - { - if (MSG_TYPE_WND == p_entry->msgType) - { - p_entry++; - continue; - } - bExist = false; - for (int i = 0; i < ms_user_map_size; i++) - { - //repeat register, return. - if (p_entry->msgId == ms_usr_map_entries[i].msgId - && ms_usr_map_entries[i].object == this) - { - bExist = true; - break; - } - } - if (true == bExist) - { - p_entry++; - continue; - } - if (MSG_TYPE_USR == p_entry->msgType) - { - if (USR_MSG_MAX == ms_user_map_size) - { - ASSERT(false); - } - ms_usr_map_entries[ms_user_map_size] = *p_entry; - ms_usr_map_entries[ms_user_map_size].object = this; - ms_user_map_size++; - } - else - { - ASSERT(false); - break; - } - p_entry++; - } - } - const GL_MSG_ENTRY* find_msg_entry(const GL_MSG_ENTRY *pEntry, int msgType, int msgId) - { - if (MSG_TYPE_INVALID == msgType) - { - return 0; - } - while (MSG_TYPE_INVALID != pEntry->msgType) - { - if ((msgType == pEntry->msgType) && (msgId == pEntry->msgId)) - { - return pEntry; - } - pEntry++; - } - return 0; - } -private: - static GL_MSG_ENTRY ms_usr_map_entries[USR_MSG_MAX]; - static unsigned short ms_user_map_size; - GL_DECLARE_MESSAGE_MAP() -}; //BITMAP typedef struct struct_bitmap_info { @@ -1329,9 +1212,9 @@ typedef struct struct_wnd_tree short height; struct struct_wnd_tree* p_child_tree;//sub tree }WND_TREE; -class c_wnd : public c_cmd_target +typedef void (c_wnd::*WND_CALLBACK)(int, int); +class c_wnd { - friend class c_dialog; public: c_wnd() : m_status(STATUS_NORMAL), m_attr((WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS)), m_parent(0), m_top_child(0), m_prev_sibling(0), m_next_sibling(0), m_str(0), m_font_color(0), m_bg_color(0), m_id(0), m_z_order(Z_ORDER_LEVEL_0), m_focus_child(0), m_surface(0) {}; @@ -1370,7 +1253,6 @@ public: } if (load_child_wnd(p_child_tree) >= 0) { - load_cmd_msg(); on_init_children(); } return 0; @@ -1549,19 +1431,6 @@ public: } c_wnd* get_prev_sibling() const { return m_prev_sibling; } c_wnd* get_next_sibling() const { return m_next_sibling; } - void notify_parent(int msg_id, int param) - { - if (!m_parent) - { - return; - } - const GL_MSG_ENTRY* entry = m_parent->find_msg_entry(m_parent->get_msg_entries(), MSG_TYPE_WND, msg_id); - if (0 == entry) - { - return; - } - (m_parent->*(entry->callBack))(m_id, param); - } virtual void on_touch(int x, int y, TOUCH_ACTION action) { x -= m_wnd_rect.m_left; @@ -1733,6 +1602,7 @@ protected: virtual void on_focus() {}; virtual void on_kill_focus() {}; protected: + unsigned short m_id; WND_STATUS m_status; WND_ATTRIBUTION m_attr; c_rect m_wnd_rect; //position relative to parent window. @@ -1740,23 +1610,18 @@ protected: c_wnd* m_top_child; //the first sub window would be navigated c_wnd* m_prev_sibling; //previous brother c_wnd* m_next_sibling; //next brother + c_wnd* m_focus_child; //current focused window const char* m_str; //caption const FONT_INFO* m_font_type; unsigned int m_font_color; unsigned int m_bg_color; - unsigned short m_id; int m_z_order; //the graphic level for rendering - c_wnd* m_focus_child; //current focused window c_surface* m_surface; -private: - c_wnd(const c_wnd &win); - c_wnd& operator=(const c_wnd &win); }; -#define GL_BN_CLICKED 0x1111 -#define ON_GL_BN_CLICKED(func) {MSG_TYPE_WND, GL_BN_CLICKED, 0, msgCallback(&func)}, -typedef struct struct_bitmap_info BITMAP_INFO; class c_button : public c_wnd { +public: + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void on_paint() { @@ -1819,7 +1684,10 @@ protected: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_BN_CLICKED, 0); + if(on_click) + { + (m_parent->*(on_click))(m_id, 0); + } } } virtual void on_navigate(NAVIGATION_KEY key) @@ -1836,6 +1704,7 @@ protected: } return c_wnd::on_navigate(key); } + WND_CALLBACK on_click = 0; }; class c_surface; class c_dialog; @@ -2006,8 +1875,21 @@ public: } return -1; } + virtual void on_init_children() + { + c_wnd* child = m_top_child; + if (0 != child) + { + while (child) + { + ((c_button*)child)->set_on_click(WND_CALLBACK(&c_keyboard::on_key_clicked)); + child = child->get_next_sibling(); + } + } + } KEYBOARD_STATUS get_cap_status(){return m_cap_status;} char* get_str() { return m_str; } + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void pre_create_wnd() { @@ -2064,7 +1946,7 @@ protected: ASSERT(false); InputChar: m_str[m_str_len++] = id; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_del_clicked(int id, int param) { @@ -2073,7 +1955,7 @@ protected: return; } m_str[--m_str_len] = 0; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_caps_clicked(int id, int param) { @@ -2083,18 +1965,18 @@ protected: void on_enter_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - return notify_parent(KEYBORAD_CLICK, CLICK_ENTER); + (m_parent->*(on_click))(m_id, CLICK_ENTER); } void on_esc_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - notify_parent(KEYBORAD_CLICK, CLICK_ESC); + (m_parent->*(on_click))(m_id, CLICK_ESC); } - GL_DECLARE_MESSAGE_MAP() private: char m_str[32]; int m_str_len; KEYBOARD_STATUS m_cap_status; + WND_CALLBACK on_click; }; class c_keyboard_button : public c_button { @@ -2284,11 +2166,11 @@ protected: break; } } - GL_DECLARE_MESSAGE_MAP() private: void show_keyboard() { s_keyboard.connect(this, IDD_KEY_BOARD, m_kb_style); + s_keyboard.set_on_click(WND_CALLBACK(&c_edit::on_key_board_click)); s_keyboard.show_window(); } void on_touch_down(int x, int y) @@ -2368,12 +2250,12 @@ protected: }; #include #define MAX_ITEM_NUM 4 -#define GL_LIST_CONFIRM 0x1 #define ITEM_HEIGHT 45 -#define ON_LIST_CONFIRM(func) {MSG_TYPE_WND, GL_LIST_CONFIRM, 0, msgCallback(&func)}, class c_list_box : public c_wnd { public: + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } + short get_item_count() { return m_item_total; } int add_item(char* str) { if (m_item_total >= MAX_ITEM_NUM) @@ -2391,7 +2273,6 @@ public: memset(m_item_array, 0, sizeof(m_item_array)); update_list_size(); } - short get_item_count() { return m_item_total; } void select_item(short index) { if (index < 0 || index >= m_item_total) @@ -2546,7 +2427,10 @@ private: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } } } @@ -2569,7 +2453,10 @@ private: m_status = STATUS_FOCUSED; select_item((y - m_list_wnd_rect.m_top) / ITEM_HEIGHT); on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } else { @@ -2582,6 +2469,7 @@ private: char* m_item_array[MAX_ITEM_NUM]; c_rect m_list_wnd_rect; //rect relative to parent wnd. c_rect m_list_screen_rect; //rect relative to physical screen(frame buffer) + WND_CALLBACK on_change; }; #include #define MAX_PAGES 5 @@ -2920,8 +2808,6 @@ inline void c_slide_group::on_touch(int x, int y, TOUCH_ACTION action) } #define ID_BT_ARROW_UP 0x1111 #define ID_BT_ARROW_DOWN 0x2222 -#define GL_SPIN_CHANGE 0x3333 -#define ON_SPIN_CHANGE(func) {MSG_TYPE_WND, GL_SPIN_CHANGE, 0, msgCallback(&func)}, class c_spin_box; class c_spin_button : public c_button { @@ -2942,6 +2828,7 @@ public: short get_step() { return m_step; } void set_value_digit(short digit) { m_digit = digit; } short get_value_digit() { return m_digit; } + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } protected: virtual void on_paint() { @@ -2974,7 +2861,10 @@ protected: return; } m_cur_value += m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } void on_arrow_down_bt_click() @@ -2984,7 +2874,10 @@ protected: return; } m_cur_value -= m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } short m_cur_value; @@ -2995,6 +2888,7 @@ protected: short m_digit; c_spin_button m_bt_up; c_spin_button m_bt_down; + WND_CALLBACK on_change; }; inline void c_spin_button::on_touch(int x, int y, TOUCH_ACTION action) { @@ -3451,12 +3345,6 @@ private: unsigned char m_frame_len_map[64]; unsigned char m_frame_len_map_index; }; -#ifdef GUILITE_ON -GL_MSG_ENTRY c_cmd_target::ms_usr_map_entries[USR_MSG_MAX]; -unsigned short c_cmd_target::ms_user_map_size; -GL_BEGIN_MESSAGE_MAP(c_cmd_target) -GL_END_MESSAGE_MAP() -#endif #ifdef GUILITE_ON @@ -4305,9 +4193,6 @@ DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX]; #endif #ifdef GUILITE_ON c_keyboard c_edit::s_keyboard; -GL_BEGIN_MESSAGE_MAP(c_edit) -ON_KEYBORAD_UPDATE(c_edit::on_key_board_click) -GL_END_MESSAGE_MAP() #endif #ifdef GUILITE_ON static c_keyboard_button s_key_0, s_key_1, s_key_2, s_key_3, s_key_4, s_key_5, s_key_6, s_key_7, s_key_8, s_key_9; @@ -4375,7 +4260,4 @@ WND_TREE g_number_board_children[] = {&s_key_enter,'\n', 0, POS_X(3), POS_Y(2), KEY_WIDTH, KEY_HEIGHT * 2 + 2}, {0,0,0,0,0,0,0} }; -GL_BEGIN_MESSAGE_MAP(c_keyboard) -ON_GL_BN_CLICKED(c_keyboard::on_key_clicked) -GL_END_MESSAGE_MAP() #endif diff --git a/HelloFont/UIcode/UIcode.cpp b/HelloFont/UIcode/UIcode.cpp index 7d375fb..5a8511f 100644 --- a/HelloFont/UIcode/UIcode.cpp +++ b/HelloFont/UIcode/UIcode.cpp @@ -27,6 +27,11 @@ static const char* s_text = "朝辞白帝彩云间千里江陵一日还两岸猿 class c_myUI : public c_wnd { + virtual void on_init_children() + { + c_button* button = (c_button*)get_wnd_ptr(ID_BUTTON); + button->set_on_click((WND_CALLBACK)&c_myUI::on_clicked); + } virtual void on_paint(void) { c_rect rect; @@ -51,14 +56,8 @@ class c_myUI : public c_wnd tmp += 3; } } - GL_DECLARE_MESSAGE_MAP()//delcare message }; -//map message -GL_BEGIN_MESSAGE_MAP(c_myUI) -ON_GL_BN_CLICKED(c_myUI::on_clicked) -GL_END_MESSAGE_MAP() - //////////////////////// layout UI //////////////////////// static c_myUI s_myUI; static c_button s_button; -- Gitee From d5887f3971133bfe8048c6cbddceebfc910d5df9 Mon Sep 17 00:00:00 2001 From: idea4good Date: Sun, 18 Oct 2020 00:36:47 +0800 Subject: [PATCH 04/12] helloGuiLite ok --- HelloGuiLite/UIcode/GuiLite.h | 220 ++++++++------------------------ HelloGuiLite/UIcode/helloGL.cpp | 74 +++++------ 2 files changed, 85 insertions(+), 209 deletions(-) diff --git a/HelloGuiLite/UIcode/GuiLite.h b/HelloGuiLite/UIcode/GuiLite.h index 4df4afa..de5a678 100644 --- a/HelloGuiLite/UIcode/GuiLite.h +++ b/HelloGuiLite/UIcode/GuiLite.h @@ -102,123 +102,6 @@ public: int m_right; int m_bottom; }; -#define MSG_TYPE_INVALID 0xFFFF -#define MSG_TYPE_WND 0x0001 -#define MSG_TYPE_USR 0x0002 -#define USR_MSG_MAX 32 -class c_cmd_target; -typedef void (c_cmd_target::*msgCallback)(int, int); -struct GL_MSG_ENTRY -{ - unsigned int msgType; - unsigned int msgId; - c_cmd_target* object; - msgCallback callBack; -}; -#define ON_GL_USER_MSG(msgId, func) \ -{MSG_TYPE_USR, msgId, 0, msgCallback(&func)}, -#define GL_DECLARE_MESSAGE_MAP() \ -protected: \ - virtual const GL_MSG_ENTRY* get_msg_entries() const;\ -private: \ - static const GL_MSG_ENTRY m_msg_entries[]; -#define GL_BEGIN_MESSAGE_MAP(theClass) \ -const GL_MSG_ENTRY* theClass::get_msg_entries() const \ -{ \ - return theClass::m_msg_entries; \ -} \ -const GL_MSG_ENTRY theClass::m_msg_entries[] = \ -{ -#define GL_END_MESSAGE_MAP() \ -{MSG_TYPE_INVALID, 0, 0, 0}}; -class c_cmd_target -{ -public: - static int handle_usr_msg(int msg_id, int resource_id, int param) - { - int i; - c_cmd_target* p_wnd = 0; - for (i = 0; i < ms_user_map_size; i++) - { - if (msg_id == ms_usr_map_entries[i].msgId) - { - p_wnd = (c_cmd_target*)ms_usr_map_entries[i].object; - (p_wnd->*ms_usr_map_entries[i].callBack)(resource_id, param); - } - } - return 1; - } -protected: - void load_cmd_msg() - { - const GL_MSG_ENTRY* p_entry = get_msg_entries(); - if (0 == p_entry) - { - return; - } - bool bExist = false; - while (MSG_TYPE_INVALID != p_entry->msgType) - { - if (MSG_TYPE_WND == p_entry->msgType) - { - p_entry++; - continue; - } - bExist = false; - for (int i = 0; i < ms_user_map_size; i++) - { - //repeat register, return. - if (p_entry->msgId == ms_usr_map_entries[i].msgId - && ms_usr_map_entries[i].object == this) - { - bExist = true; - break; - } - } - if (true == bExist) - { - p_entry++; - continue; - } - if (MSG_TYPE_USR == p_entry->msgType) - { - if (USR_MSG_MAX == ms_user_map_size) - { - ASSERT(false); - } - ms_usr_map_entries[ms_user_map_size] = *p_entry; - ms_usr_map_entries[ms_user_map_size].object = this; - ms_user_map_size++; - } - else - { - ASSERT(false); - break; - } - p_entry++; - } - } - const GL_MSG_ENTRY* find_msg_entry(const GL_MSG_ENTRY *pEntry, int msgType, int msgId) - { - if (MSG_TYPE_INVALID == msgType) - { - return 0; - } - while (MSG_TYPE_INVALID != pEntry->msgType) - { - if ((msgType == pEntry->msgType) && (msgId == pEntry->msgId)) - { - return pEntry; - } - pEntry++; - } - return 0; - } -private: - static GL_MSG_ENTRY ms_usr_map_entries[USR_MSG_MAX]; - static unsigned short ms_user_map_size; - GL_DECLARE_MESSAGE_MAP() -}; //BITMAP typedef struct struct_bitmap_info { @@ -1329,9 +1212,9 @@ typedef struct struct_wnd_tree short height; struct struct_wnd_tree* p_child_tree;//sub tree }WND_TREE; -class c_wnd : public c_cmd_target +typedef void (c_wnd::*WND_CALLBACK)(int, int); +class c_wnd { - friend class c_dialog; public: c_wnd() : m_status(STATUS_NORMAL), m_attr((WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS)), m_parent(0), m_top_child(0), m_prev_sibling(0), m_next_sibling(0), m_str(0), m_font_color(0), m_bg_color(0), m_id(0), m_z_order(Z_ORDER_LEVEL_0), m_focus_child(0), m_surface(0) {}; @@ -1370,7 +1253,6 @@ public: } if (load_child_wnd(p_child_tree) >= 0) { - load_cmd_msg(); on_init_children(); } return 0; @@ -1549,19 +1431,6 @@ public: } c_wnd* get_prev_sibling() const { return m_prev_sibling; } c_wnd* get_next_sibling() const { return m_next_sibling; } - void notify_parent(int msg_id, int param) - { - if (!m_parent) - { - return; - } - const GL_MSG_ENTRY* entry = m_parent->find_msg_entry(m_parent->get_msg_entries(), MSG_TYPE_WND, msg_id); - if (0 == entry) - { - return; - } - (m_parent->*(entry->callBack))(m_id, param); - } virtual void on_touch(int x, int y, TOUCH_ACTION action) { x -= m_wnd_rect.m_left; @@ -1733,6 +1602,7 @@ protected: virtual void on_focus() {}; virtual void on_kill_focus() {}; protected: + unsigned short m_id; WND_STATUS m_status; WND_ATTRIBUTION m_attr; c_rect m_wnd_rect; //position relative to parent window. @@ -1740,23 +1610,18 @@ protected: c_wnd* m_top_child; //the first sub window would be navigated c_wnd* m_prev_sibling; //previous brother c_wnd* m_next_sibling; //next brother + c_wnd* m_focus_child; //current focused window const char* m_str; //caption const FONT_INFO* m_font_type; unsigned int m_font_color; unsigned int m_bg_color; - unsigned short m_id; int m_z_order; //the graphic level for rendering - c_wnd* m_focus_child; //current focused window c_surface* m_surface; -private: - c_wnd(const c_wnd &win); - c_wnd& operator=(const c_wnd &win); }; -#define GL_BN_CLICKED 0x1111 -#define ON_GL_BN_CLICKED(func) {MSG_TYPE_WND, GL_BN_CLICKED, 0, msgCallback(&func)}, -typedef struct struct_bitmap_info BITMAP_INFO; class c_button : public c_wnd { +public: + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void on_paint() { @@ -1819,7 +1684,10 @@ protected: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_BN_CLICKED, 0); + if(on_click) + { + (m_parent->*(on_click))(m_id, 0); + } } } virtual void on_navigate(NAVIGATION_KEY key) @@ -1836,6 +1704,7 @@ protected: } return c_wnd::on_navigate(key); } + WND_CALLBACK on_click = 0; }; class c_surface; class c_dialog; @@ -2006,8 +1875,21 @@ public: } return -1; } + virtual void on_init_children() + { + c_wnd* child = m_top_child; + if (0 != child) + { + while (child) + { + ((c_button*)child)->set_on_click(WND_CALLBACK(&c_keyboard::on_key_clicked)); + child = child->get_next_sibling(); + } + } + } KEYBOARD_STATUS get_cap_status(){return m_cap_status;} char* get_str() { return m_str; } + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void pre_create_wnd() { @@ -2064,7 +1946,7 @@ protected: ASSERT(false); InputChar: m_str[m_str_len++] = id; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_del_clicked(int id, int param) { @@ -2073,7 +1955,7 @@ protected: return; } m_str[--m_str_len] = 0; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_caps_clicked(int id, int param) { @@ -2083,18 +1965,18 @@ protected: void on_enter_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - return notify_parent(KEYBORAD_CLICK, CLICK_ENTER); + (m_parent->*(on_click))(m_id, CLICK_ENTER); } void on_esc_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - notify_parent(KEYBORAD_CLICK, CLICK_ESC); + (m_parent->*(on_click))(m_id, CLICK_ESC); } - GL_DECLARE_MESSAGE_MAP() private: char m_str[32]; int m_str_len; KEYBOARD_STATUS m_cap_status; + WND_CALLBACK on_click; }; class c_keyboard_button : public c_button { @@ -2284,11 +2166,11 @@ protected: break; } } - GL_DECLARE_MESSAGE_MAP() private: void show_keyboard() { s_keyboard.connect(this, IDD_KEY_BOARD, m_kb_style); + s_keyboard.set_on_click(WND_CALLBACK(&c_edit::on_key_board_click)); s_keyboard.show_window(); } void on_touch_down(int x, int y) @@ -2368,12 +2250,12 @@ protected: }; #include #define MAX_ITEM_NUM 4 -#define GL_LIST_CONFIRM 0x1 #define ITEM_HEIGHT 45 -#define ON_LIST_CONFIRM(func) {MSG_TYPE_WND, GL_LIST_CONFIRM, 0, msgCallback(&func)}, class c_list_box : public c_wnd { public: + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } + short get_item_count() { return m_item_total; } int add_item(char* str) { if (m_item_total >= MAX_ITEM_NUM) @@ -2391,7 +2273,6 @@ public: memset(m_item_array, 0, sizeof(m_item_array)); update_list_size(); } - short get_item_count() { return m_item_total; } void select_item(short index) { if (index < 0 || index >= m_item_total) @@ -2546,7 +2427,10 @@ private: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } } } @@ -2569,7 +2453,10 @@ private: m_status = STATUS_FOCUSED; select_item((y - m_list_wnd_rect.m_top) / ITEM_HEIGHT); on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } else { @@ -2582,6 +2469,7 @@ private: char* m_item_array[MAX_ITEM_NUM]; c_rect m_list_wnd_rect; //rect relative to parent wnd. c_rect m_list_screen_rect; //rect relative to physical screen(frame buffer) + WND_CALLBACK on_change; }; #include #define MAX_PAGES 5 @@ -2920,8 +2808,6 @@ inline void c_slide_group::on_touch(int x, int y, TOUCH_ACTION action) } #define ID_BT_ARROW_UP 0x1111 #define ID_BT_ARROW_DOWN 0x2222 -#define GL_SPIN_CHANGE 0x3333 -#define ON_SPIN_CHANGE(func) {MSG_TYPE_WND, GL_SPIN_CHANGE, 0, msgCallback(&func)}, class c_spin_box; class c_spin_button : public c_button { @@ -2942,6 +2828,7 @@ public: short get_step() { return m_step; } void set_value_digit(short digit) { m_digit = digit; } short get_value_digit() { return m_digit; } + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } protected: virtual void on_paint() { @@ -2974,7 +2861,10 @@ protected: return; } m_cur_value += m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } void on_arrow_down_bt_click() @@ -2984,7 +2874,10 @@ protected: return; } m_cur_value -= m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } short m_cur_value; @@ -2995,6 +2888,7 @@ protected: short m_digit; c_spin_button m_bt_up; c_spin_button m_bt_down; + WND_CALLBACK on_change; }; inline void c_spin_button::on_touch(int x, int y, TOUCH_ACTION action) { @@ -3451,12 +3345,6 @@ private: unsigned char m_frame_len_map[64]; unsigned char m_frame_len_map_index; }; -#ifdef GUILITE_ON -GL_MSG_ENTRY c_cmd_target::ms_usr_map_entries[USR_MSG_MAX]; -unsigned short c_cmd_target::ms_user_map_size; -GL_BEGIN_MESSAGE_MAP(c_cmd_target) -GL_END_MESSAGE_MAP() -#endif #ifdef GUILITE_ON @@ -4305,9 +4193,6 @@ DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX]; #endif #ifdef GUILITE_ON c_keyboard c_edit::s_keyboard; -GL_BEGIN_MESSAGE_MAP(c_edit) -ON_KEYBORAD_UPDATE(c_edit::on_key_board_click) -GL_END_MESSAGE_MAP() #endif #ifdef GUILITE_ON static c_keyboard_button s_key_0, s_key_1, s_key_2, s_key_3, s_key_4, s_key_5, s_key_6, s_key_7, s_key_8, s_key_9; @@ -4375,7 +4260,4 @@ WND_TREE g_number_board_children[] = {&s_key_enter,'\n', 0, POS_X(3), POS_Y(2), KEY_WIDTH, KEY_HEIGHT * 2 + 2}, {0,0,0,0,0,0,0} }; -GL_BEGIN_MESSAGE_MAP(c_keyboard) -ON_GL_BN_CLICKED(c_keyboard::on_key_clicked) -GL_END_MESSAGE_MAP() #endif diff --git a/HelloGuiLite/UIcode/helloGL.cpp b/HelloGuiLite/UIcode/helloGL.cpp index 40a4fb1..d56f4df 100644 --- a/HelloGuiLite/UIcode/helloGL.cpp +++ b/HelloGuiLite/UIcode/helloGL.cpp @@ -42,50 +42,44 @@ class c_start_button : public c_button class c_desktop : public c_wnd { - virtual void on_paint(void); - void on_clicked(int ctrl_id, int param); - GL_DECLARE_MESSAGE_MAP()//delcare message -}; - -//map message -GL_BEGIN_MESSAGE_MAP(c_desktop) -ON_GL_BN_CLICKED(c_desktop::on_clicked) -GL_END_MESSAGE_MAP() - -void c_desktop::on_clicked(int ctrl_id, int param) -{ - static bool is_open = false; - (is_open) ? c_dialog::close_dialog(m_surface): c_dialog::open_dialog((c_dialog*)get_wnd_ptr(ID_START_MENU), false); - is_open = !is_open; -} - -void c_desktop::on_paint() -{ - c_rect rect; - get_screen_rect(rect); - extern const BITMAP_INFO desktop_bmp; - int block_width = 80; - int block_height = 60; - int block_rows = desktop_bmp.height / block_height; - int block_cols = desktop_bmp.width / block_width; - int block_sum = block_rows * block_cols; - bool* block_map = (bool*)calloc(block_sum, sizeof(bool)); - if (!block_map) { return; } - int sum = 0; - while (sum < block_sum) + virtual void on_init_children() + { + ((c_button*)get_wnd_ptr(ID_START_BUTTON))->set_on_click((WND_CALLBACK)&c_desktop::on_clicked); + } + virtual void on_paint(void) { - int x = rand() % block_cols; - int y = rand() % block_rows; - if (block_map[x + (y * block_cols)] == false) + c_rect rect; + get_screen_rect(rect); + extern const BITMAP_INFO desktop_bmp; + int block_width = 80; + int block_height = 60; + int block_rows = desktop_bmp.height / block_height; + int block_cols = desktop_bmp.width / block_width; + int block_sum = block_rows * block_cols; + bool* block_map = (bool*)calloc(block_sum, sizeof(bool)); + if (!block_map) { return; } + int sum = 0; + while (sum < block_sum) { - c_bitmap::draw_bitmap(m_surface, m_z_order, &desktop_bmp, rect.m_left + x * block_width, rect.m_top + y * block_height, x * block_width, y * block_height, block_width, block_height); - block_map[x + (y * block_cols)] = true; - sum++; - thread_sleep(10); + int x = rand() % block_cols; + int y = rand() % block_rows; + if (block_map[x + (y * block_cols)] == false) + { + c_bitmap::draw_bitmap(m_surface, m_z_order, &desktop_bmp, rect.m_left + x * block_width, rect.m_top + y * block_height, x * block_width, y * block_height, block_width, block_height); + block_map[x + (y * block_cols)] = true; + sum++; + thread_sleep(10); + } } + free(block_map); } - free(block_map); -} + void on_clicked(int ctrl_id, int param) + { + static bool is_open = false; + (is_open) ? c_dialog::close_dialog(m_surface) : c_dialog::open_dialog((c_dialog*)get_wnd_ptr(ID_START_MENU), false); + is_open = !is_open; + } +}; class c_start_menu : public c_dialog { -- Gitee From 1a5584d8cad708bdff64867970141019a1d3ed09 Mon Sep 17 00:00:00 2001 From: idea4good Date: Sun, 18 Oct 2020 00:47:18 +0800 Subject: [PATCH 05/12] helloNoTouch ok --- HelloNoTouch/UIcode/GuiLite.h | 220 ++++++++------------------------- HelloNoTouch/UIcode/UIcode.cpp | 12 +- 2 files changed, 57 insertions(+), 175 deletions(-) diff --git a/HelloNoTouch/UIcode/GuiLite.h b/HelloNoTouch/UIcode/GuiLite.h index 4df4afa..de5a678 100644 --- a/HelloNoTouch/UIcode/GuiLite.h +++ b/HelloNoTouch/UIcode/GuiLite.h @@ -102,123 +102,6 @@ public: int m_right; int m_bottom; }; -#define MSG_TYPE_INVALID 0xFFFF -#define MSG_TYPE_WND 0x0001 -#define MSG_TYPE_USR 0x0002 -#define USR_MSG_MAX 32 -class c_cmd_target; -typedef void (c_cmd_target::*msgCallback)(int, int); -struct GL_MSG_ENTRY -{ - unsigned int msgType; - unsigned int msgId; - c_cmd_target* object; - msgCallback callBack; -}; -#define ON_GL_USER_MSG(msgId, func) \ -{MSG_TYPE_USR, msgId, 0, msgCallback(&func)}, -#define GL_DECLARE_MESSAGE_MAP() \ -protected: \ - virtual const GL_MSG_ENTRY* get_msg_entries() const;\ -private: \ - static const GL_MSG_ENTRY m_msg_entries[]; -#define GL_BEGIN_MESSAGE_MAP(theClass) \ -const GL_MSG_ENTRY* theClass::get_msg_entries() const \ -{ \ - return theClass::m_msg_entries; \ -} \ -const GL_MSG_ENTRY theClass::m_msg_entries[] = \ -{ -#define GL_END_MESSAGE_MAP() \ -{MSG_TYPE_INVALID, 0, 0, 0}}; -class c_cmd_target -{ -public: - static int handle_usr_msg(int msg_id, int resource_id, int param) - { - int i; - c_cmd_target* p_wnd = 0; - for (i = 0; i < ms_user_map_size; i++) - { - if (msg_id == ms_usr_map_entries[i].msgId) - { - p_wnd = (c_cmd_target*)ms_usr_map_entries[i].object; - (p_wnd->*ms_usr_map_entries[i].callBack)(resource_id, param); - } - } - return 1; - } -protected: - void load_cmd_msg() - { - const GL_MSG_ENTRY* p_entry = get_msg_entries(); - if (0 == p_entry) - { - return; - } - bool bExist = false; - while (MSG_TYPE_INVALID != p_entry->msgType) - { - if (MSG_TYPE_WND == p_entry->msgType) - { - p_entry++; - continue; - } - bExist = false; - for (int i = 0; i < ms_user_map_size; i++) - { - //repeat register, return. - if (p_entry->msgId == ms_usr_map_entries[i].msgId - && ms_usr_map_entries[i].object == this) - { - bExist = true; - break; - } - } - if (true == bExist) - { - p_entry++; - continue; - } - if (MSG_TYPE_USR == p_entry->msgType) - { - if (USR_MSG_MAX == ms_user_map_size) - { - ASSERT(false); - } - ms_usr_map_entries[ms_user_map_size] = *p_entry; - ms_usr_map_entries[ms_user_map_size].object = this; - ms_user_map_size++; - } - else - { - ASSERT(false); - break; - } - p_entry++; - } - } - const GL_MSG_ENTRY* find_msg_entry(const GL_MSG_ENTRY *pEntry, int msgType, int msgId) - { - if (MSG_TYPE_INVALID == msgType) - { - return 0; - } - while (MSG_TYPE_INVALID != pEntry->msgType) - { - if ((msgType == pEntry->msgType) && (msgId == pEntry->msgId)) - { - return pEntry; - } - pEntry++; - } - return 0; - } -private: - static GL_MSG_ENTRY ms_usr_map_entries[USR_MSG_MAX]; - static unsigned short ms_user_map_size; - GL_DECLARE_MESSAGE_MAP() -}; //BITMAP typedef struct struct_bitmap_info { @@ -1329,9 +1212,9 @@ typedef struct struct_wnd_tree short height; struct struct_wnd_tree* p_child_tree;//sub tree }WND_TREE; -class c_wnd : public c_cmd_target +typedef void (c_wnd::*WND_CALLBACK)(int, int); +class c_wnd { - friend class c_dialog; public: c_wnd() : m_status(STATUS_NORMAL), m_attr((WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS)), m_parent(0), m_top_child(0), m_prev_sibling(0), m_next_sibling(0), m_str(0), m_font_color(0), m_bg_color(0), m_id(0), m_z_order(Z_ORDER_LEVEL_0), m_focus_child(0), m_surface(0) {}; @@ -1370,7 +1253,6 @@ public: } if (load_child_wnd(p_child_tree) >= 0) { - load_cmd_msg(); on_init_children(); } return 0; @@ -1549,19 +1431,6 @@ public: } c_wnd* get_prev_sibling() const { return m_prev_sibling; } c_wnd* get_next_sibling() const { return m_next_sibling; } - void notify_parent(int msg_id, int param) - { - if (!m_parent) - { - return; - } - const GL_MSG_ENTRY* entry = m_parent->find_msg_entry(m_parent->get_msg_entries(), MSG_TYPE_WND, msg_id); - if (0 == entry) - { - return; - } - (m_parent->*(entry->callBack))(m_id, param); - } virtual void on_touch(int x, int y, TOUCH_ACTION action) { x -= m_wnd_rect.m_left; @@ -1733,6 +1602,7 @@ protected: virtual void on_focus() {}; virtual void on_kill_focus() {}; protected: + unsigned short m_id; WND_STATUS m_status; WND_ATTRIBUTION m_attr; c_rect m_wnd_rect; //position relative to parent window. @@ -1740,23 +1610,18 @@ protected: c_wnd* m_top_child; //the first sub window would be navigated c_wnd* m_prev_sibling; //previous brother c_wnd* m_next_sibling; //next brother + c_wnd* m_focus_child; //current focused window const char* m_str; //caption const FONT_INFO* m_font_type; unsigned int m_font_color; unsigned int m_bg_color; - unsigned short m_id; int m_z_order; //the graphic level for rendering - c_wnd* m_focus_child; //current focused window c_surface* m_surface; -private: - c_wnd(const c_wnd &win); - c_wnd& operator=(const c_wnd &win); }; -#define GL_BN_CLICKED 0x1111 -#define ON_GL_BN_CLICKED(func) {MSG_TYPE_WND, GL_BN_CLICKED, 0, msgCallback(&func)}, -typedef struct struct_bitmap_info BITMAP_INFO; class c_button : public c_wnd { +public: + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void on_paint() { @@ -1819,7 +1684,10 @@ protected: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_BN_CLICKED, 0); + if(on_click) + { + (m_parent->*(on_click))(m_id, 0); + } } } virtual void on_navigate(NAVIGATION_KEY key) @@ -1836,6 +1704,7 @@ protected: } return c_wnd::on_navigate(key); } + WND_CALLBACK on_click = 0; }; class c_surface; class c_dialog; @@ -2006,8 +1875,21 @@ public: } return -1; } + virtual void on_init_children() + { + c_wnd* child = m_top_child; + if (0 != child) + { + while (child) + { + ((c_button*)child)->set_on_click(WND_CALLBACK(&c_keyboard::on_key_clicked)); + child = child->get_next_sibling(); + } + } + } KEYBOARD_STATUS get_cap_status(){return m_cap_status;} char* get_str() { return m_str; } + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void pre_create_wnd() { @@ -2064,7 +1946,7 @@ protected: ASSERT(false); InputChar: m_str[m_str_len++] = id; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_del_clicked(int id, int param) { @@ -2073,7 +1955,7 @@ protected: return; } m_str[--m_str_len] = 0; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_caps_clicked(int id, int param) { @@ -2083,18 +1965,18 @@ protected: void on_enter_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - return notify_parent(KEYBORAD_CLICK, CLICK_ENTER); + (m_parent->*(on_click))(m_id, CLICK_ENTER); } void on_esc_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - notify_parent(KEYBORAD_CLICK, CLICK_ESC); + (m_parent->*(on_click))(m_id, CLICK_ESC); } - GL_DECLARE_MESSAGE_MAP() private: char m_str[32]; int m_str_len; KEYBOARD_STATUS m_cap_status; + WND_CALLBACK on_click; }; class c_keyboard_button : public c_button { @@ -2284,11 +2166,11 @@ protected: break; } } - GL_DECLARE_MESSAGE_MAP() private: void show_keyboard() { s_keyboard.connect(this, IDD_KEY_BOARD, m_kb_style); + s_keyboard.set_on_click(WND_CALLBACK(&c_edit::on_key_board_click)); s_keyboard.show_window(); } void on_touch_down(int x, int y) @@ -2368,12 +2250,12 @@ protected: }; #include #define MAX_ITEM_NUM 4 -#define GL_LIST_CONFIRM 0x1 #define ITEM_HEIGHT 45 -#define ON_LIST_CONFIRM(func) {MSG_TYPE_WND, GL_LIST_CONFIRM, 0, msgCallback(&func)}, class c_list_box : public c_wnd { public: + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } + short get_item_count() { return m_item_total; } int add_item(char* str) { if (m_item_total >= MAX_ITEM_NUM) @@ -2391,7 +2273,6 @@ public: memset(m_item_array, 0, sizeof(m_item_array)); update_list_size(); } - short get_item_count() { return m_item_total; } void select_item(short index) { if (index < 0 || index >= m_item_total) @@ -2546,7 +2427,10 @@ private: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } } } @@ -2569,7 +2453,10 @@ private: m_status = STATUS_FOCUSED; select_item((y - m_list_wnd_rect.m_top) / ITEM_HEIGHT); on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } else { @@ -2582,6 +2469,7 @@ private: char* m_item_array[MAX_ITEM_NUM]; c_rect m_list_wnd_rect; //rect relative to parent wnd. c_rect m_list_screen_rect; //rect relative to physical screen(frame buffer) + WND_CALLBACK on_change; }; #include #define MAX_PAGES 5 @@ -2920,8 +2808,6 @@ inline void c_slide_group::on_touch(int x, int y, TOUCH_ACTION action) } #define ID_BT_ARROW_UP 0x1111 #define ID_BT_ARROW_DOWN 0x2222 -#define GL_SPIN_CHANGE 0x3333 -#define ON_SPIN_CHANGE(func) {MSG_TYPE_WND, GL_SPIN_CHANGE, 0, msgCallback(&func)}, class c_spin_box; class c_spin_button : public c_button { @@ -2942,6 +2828,7 @@ public: short get_step() { return m_step; } void set_value_digit(short digit) { m_digit = digit; } short get_value_digit() { return m_digit; } + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } protected: virtual void on_paint() { @@ -2974,7 +2861,10 @@ protected: return; } m_cur_value += m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } void on_arrow_down_bt_click() @@ -2984,7 +2874,10 @@ protected: return; } m_cur_value -= m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } short m_cur_value; @@ -2995,6 +2888,7 @@ protected: short m_digit; c_spin_button m_bt_up; c_spin_button m_bt_down; + WND_CALLBACK on_change; }; inline void c_spin_button::on_touch(int x, int y, TOUCH_ACTION action) { @@ -3451,12 +3345,6 @@ private: unsigned char m_frame_len_map[64]; unsigned char m_frame_len_map_index; }; -#ifdef GUILITE_ON -GL_MSG_ENTRY c_cmd_target::ms_usr_map_entries[USR_MSG_MAX]; -unsigned short c_cmd_target::ms_user_map_size; -GL_BEGIN_MESSAGE_MAP(c_cmd_target) -GL_END_MESSAGE_MAP() -#endif #ifdef GUILITE_ON @@ -4305,9 +4193,6 @@ DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX]; #endif #ifdef GUILITE_ON c_keyboard c_edit::s_keyboard; -GL_BEGIN_MESSAGE_MAP(c_edit) -ON_KEYBORAD_UPDATE(c_edit::on_key_board_click) -GL_END_MESSAGE_MAP() #endif #ifdef GUILITE_ON static c_keyboard_button s_key_0, s_key_1, s_key_2, s_key_3, s_key_4, s_key_5, s_key_6, s_key_7, s_key_8, s_key_9; @@ -4375,7 +4260,4 @@ WND_TREE g_number_board_children[] = {&s_key_enter,'\n', 0, POS_X(3), POS_Y(2), KEY_WIDTH, KEY_HEIGHT * 2 + 2}, {0,0,0,0,0,0,0} }; -GL_BEGIN_MESSAGE_MAP(c_keyboard) -ON_GL_BN_CLICKED(c_keyboard::on_key_clicked) -GL_END_MESSAGE_MAP() #endif diff --git a/HelloNoTouch/UIcode/UIcode.cpp b/HelloNoTouch/UIcode/UIcode.cpp index 8fda5da..a117ced 100644 --- a/HelloNoTouch/UIcode/UIcode.cpp +++ b/HelloNoTouch/UIcode/UIcode.cpp @@ -20,6 +20,12 @@ enum WND_ID class c_myUI : public c_wnd { + virtual void on_init_children() + { + ((c_button*)get_wnd_ptr(ID_BUTTON1))->set_on_click((WND_CALLBACK)&c_myUI::on_clicked); + ((c_button*)get_wnd_ptr(ID_BUTTON2))->set_on_click((WND_CALLBACK)&c_myUI::on_clicked); + ((c_button*)get_wnd_ptr(ID_BUTTON3))->set_on_click((WND_CALLBACK)&c_myUI::on_clicked); + } virtual void on_paint(void) { c_rect rect; @@ -47,14 +53,8 @@ class c_myUI : public c_wnd } button->show_window(); } - GL_DECLARE_MESSAGE_MAP()//delcare message }; -//map message -GL_BEGIN_MESSAGE_MAP(c_myUI) -ON_GL_BN_CLICKED(c_myUI::on_clicked) -GL_END_MESSAGE_MAP() - //////////////////////// layout UI //////////////////////// static c_myUI s_myUI; static c_label s_label1, s_label2, s_label3; -- Gitee From 33286a7f7df70c89eaf2910296c3a128ebbc7967 Mon Sep 17 00:00:00 2001 From: idea4good Date: Sun, 18 Oct 2020 01:09:03 +0800 Subject: [PATCH 06/12] helloTransparent ok --- HelloTransparent/UIcode/GuiLite.h | 220 +++++++---------------------- HelloTransparent/UIcode/UIcode.cpp | 11 +- 2 files changed, 55 insertions(+), 176 deletions(-) diff --git a/HelloTransparent/UIcode/GuiLite.h b/HelloTransparent/UIcode/GuiLite.h index 4df4afa..de5a678 100644 --- a/HelloTransparent/UIcode/GuiLite.h +++ b/HelloTransparent/UIcode/GuiLite.h @@ -102,123 +102,6 @@ public: int m_right; int m_bottom; }; -#define MSG_TYPE_INVALID 0xFFFF -#define MSG_TYPE_WND 0x0001 -#define MSG_TYPE_USR 0x0002 -#define USR_MSG_MAX 32 -class c_cmd_target; -typedef void (c_cmd_target::*msgCallback)(int, int); -struct GL_MSG_ENTRY -{ - unsigned int msgType; - unsigned int msgId; - c_cmd_target* object; - msgCallback callBack; -}; -#define ON_GL_USER_MSG(msgId, func) \ -{MSG_TYPE_USR, msgId, 0, msgCallback(&func)}, -#define GL_DECLARE_MESSAGE_MAP() \ -protected: \ - virtual const GL_MSG_ENTRY* get_msg_entries() const;\ -private: \ - static const GL_MSG_ENTRY m_msg_entries[]; -#define GL_BEGIN_MESSAGE_MAP(theClass) \ -const GL_MSG_ENTRY* theClass::get_msg_entries() const \ -{ \ - return theClass::m_msg_entries; \ -} \ -const GL_MSG_ENTRY theClass::m_msg_entries[] = \ -{ -#define GL_END_MESSAGE_MAP() \ -{MSG_TYPE_INVALID, 0, 0, 0}}; -class c_cmd_target -{ -public: - static int handle_usr_msg(int msg_id, int resource_id, int param) - { - int i; - c_cmd_target* p_wnd = 0; - for (i = 0; i < ms_user_map_size; i++) - { - if (msg_id == ms_usr_map_entries[i].msgId) - { - p_wnd = (c_cmd_target*)ms_usr_map_entries[i].object; - (p_wnd->*ms_usr_map_entries[i].callBack)(resource_id, param); - } - } - return 1; - } -protected: - void load_cmd_msg() - { - const GL_MSG_ENTRY* p_entry = get_msg_entries(); - if (0 == p_entry) - { - return; - } - bool bExist = false; - while (MSG_TYPE_INVALID != p_entry->msgType) - { - if (MSG_TYPE_WND == p_entry->msgType) - { - p_entry++; - continue; - } - bExist = false; - for (int i = 0; i < ms_user_map_size; i++) - { - //repeat register, return. - if (p_entry->msgId == ms_usr_map_entries[i].msgId - && ms_usr_map_entries[i].object == this) - { - bExist = true; - break; - } - } - if (true == bExist) - { - p_entry++; - continue; - } - if (MSG_TYPE_USR == p_entry->msgType) - { - if (USR_MSG_MAX == ms_user_map_size) - { - ASSERT(false); - } - ms_usr_map_entries[ms_user_map_size] = *p_entry; - ms_usr_map_entries[ms_user_map_size].object = this; - ms_user_map_size++; - } - else - { - ASSERT(false); - break; - } - p_entry++; - } - } - const GL_MSG_ENTRY* find_msg_entry(const GL_MSG_ENTRY *pEntry, int msgType, int msgId) - { - if (MSG_TYPE_INVALID == msgType) - { - return 0; - } - while (MSG_TYPE_INVALID != pEntry->msgType) - { - if ((msgType == pEntry->msgType) && (msgId == pEntry->msgId)) - { - return pEntry; - } - pEntry++; - } - return 0; - } -private: - static GL_MSG_ENTRY ms_usr_map_entries[USR_MSG_MAX]; - static unsigned short ms_user_map_size; - GL_DECLARE_MESSAGE_MAP() -}; //BITMAP typedef struct struct_bitmap_info { @@ -1329,9 +1212,9 @@ typedef struct struct_wnd_tree short height; struct struct_wnd_tree* p_child_tree;//sub tree }WND_TREE; -class c_wnd : public c_cmd_target +typedef void (c_wnd::*WND_CALLBACK)(int, int); +class c_wnd { - friend class c_dialog; public: c_wnd() : m_status(STATUS_NORMAL), m_attr((WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS)), m_parent(0), m_top_child(0), m_prev_sibling(0), m_next_sibling(0), m_str(0), m_font_color(0), m_bg_color(0), m_id(0), m_z_order(Z_ORDER_LEVEL_0), m_focus_child(0), m_surface(0) {}; @@ -1370,7 +1253,6 @@ public: } if (load_child_wnd(p_child_tree) >= 0) { - load_cmd_msg(); on_init_children(); } return 0; @@ -1549,19 +1431,6 @@ public: } c_wnd* get_prev_sibling() const { return m_prev_sibling; } c_wnd* get_next_sibling() const { return m_next_sibling; } - void notify_parent(int msg_id, int param) - { - if (!m_parent) - { - return; - } - const GL_MSG_ENTRY* entry = m_parent->find_msg_entry(m_parent->get_msg_entries(), MSG_TYPE_WND, msg_id); - if (0 == entry) - { - return; - } - (m_parent->*(entry->callBack))(m_id, param); - } virtual void on_touch(int x, int y, TOUCH_ACTION action) { x -= m_wnd_rect.m_left; @@ -1733,6 +1602,7 @@ protected: virtual void on_focus() {}; virtual void on_kill_focus() {}; protected: + unsigned short m_id; WND_STATUS m_status; WND_ATTRIBUTION m_attr; c_rect m_wnd_rect; //position relative to parent window. @@ -1740,23 +1610,18 @@ protected: c_wnd* m_top_child; //the first sub window would be navigated c_wnd* m_prev_sibling; //previous brother c_wnd* m_next_sibling; //next brother + c_wnd* m_focus_child; //current focused window const char* m_str; //caption const FONT_INFO* m_font_type; unsigned int m_font_color; unsigned int m_bg_color; - unsigned short m_id; int m_z_order; //the graphic level for rendering - c_wnd* m_focus_child; //current focused window c_surface* m_surface; -private: - c_wnd(const c_wnd &win); - c_wnd& operator=(const c_wnd &win); }; -#define GL_BN_CLICKED 0x1111 -#define ON_GL_BN_CLICKED(func) {MSG_TYPE_WND, GL_BN_CLICKED, 0, msgCallback(&func)}, -typedef struct struct_bitmap_info BITMAP_INFO; class c_button : public c_wnd { +public: + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void on_paint() { @@ -1819,7 +1684,10 @@ protected: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_BN_CLICKED, 0); + if(on_click) + { + (m_parent->*(on_click))(m_id, 0); + } } } virtual void on_navigate(NAVIGATION_KEY key) @@ -1836,6 +1704,7 @@ protected: } return c_wnd::on_navigate(key); } + WND_CALLBACK on_click = 0; }; class c_surface; class c_dialog; @@ -2006,8 +1875,21 @@ public: } return -1; } + virtual void on_init_children() + { + c_wnd* child = m_top_child; + if (0 != child) + { + while (child) + { + ((c_button*)child)->set_on_click(WND_CALLBACK(&c_keyboard::on_key_clicked)); + child = child->get_next_sibling(); + } + } + } KEYBOARD_STATUS get_cap_status(){return m_cap_status;} char* get_str() { return m_str; } + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void pre_create_wnd() { @@ -2064,7 +1946,7 @@ protected: ASSERT(false); InputChar: m_str[m_str_len++] = id; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_del_clicked(int id, int param) { @@ -2073,7 +1955,7 @@ protected: return; } m_str[--m_str_len] = 0; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_caps_clicked(int id, int param) { @@ -2083,18 +1965,18 @@ protected: void on_enter_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - return notify_parent(KEYBORAD_CLICK, CLICK_ENTER); + (m_parent->*(on_click))(m_id, CLICK_ENTER); } void on_esc_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - notify_parent(KEYBORAD_CLICK, CLICK_ESC); + (m_parent->*(on_click))(m_id, CLICK_ESC); } - GL_DECLARE_MESSAGE_MAP() private: char m_str[32]; int m_str_len; KEYBOARD_STATUS m_cap_status; + WND_CALLBACK on_click; }; class c_keyboard_button : public c_button { @@ -2284,11 +2166,11 @@ protected: break; } } - GL_DECLARE_MESSAGE_MAP() private: void show_keyboard() { s_keyboard.connect(this, IDD_KEY_BOARD, m_kb_style); + s_keyboard.set_on_click(WND_CALLBACK(&c_edit::on_key_board_click)); s_keyboard.show_window(); } void on_touch_down(int x, int y) @@ -2368,12 +2250,12 @@ protected: }; #include #define MAX_ITEM_NUM 4 -#define GL_LIST_CONFIRM 0x1 #define ITEM_HEIGHT 45 -#define ON_LIST_CONFIRM(func) {MSG_TYPE_WND, GL_LIST_CONFIRM, 0, msgCallback(&func)}, class c_list_box : public c_wnd { public: + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } + short get_item_count() { return m_item_total; } int add_item(char* str) { if (m_item_total >= MAX_ITEM_NUM) @@ -2391,7 +2273,6 @@ public: memset(m_item_array, 0, sizeof(m_item_array)); update_list_size(); } - short get_item_count() { return m_item_total; } void select_item(short index) { if (index < 0 || index >= m_item_total) @@ -2546,7 +2427,10 @@ private: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } } } @@ -2569,7 +2453,10 @@ private: m_status = STATUS_FOCUSED; select_item((y - m_list_wnd_rect.m_top) / ITEM_HEIGHT); on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } else { @@ -2582,6 +2469,7 @@ private: char* m_item_array[MAX_ITEM_NUM]; c_rect m_list_wnd_rect; //rect relative to parent wnd. c_rect m_list_screen_rect; //rect relative to physical screen(frame buffer) + WND_CALLBACK on_change; }; #include #define MAX_PAGES 5 @@ -2920,8 +2808,6 @@ inline void c_slide_group::on_touch(int x, int y, TOUCH_ACTION action) } #define ID_BT_ARROW_UP 0x1111 #define ID_BT_ARROW_DOWN 0x2222 -#define GL_SPIN_CHANGE 0x3333 -#define ON_SPIN_CHANGE(func) {MSG_TYPE_WND, GL_SPIN_CHANGE, 0, msgCallback(&func)}, class c_spin_box; class c_spin_button : public c_button { @@ -2942,6 +2828,7 @@ public: short get_step() { return m_step; } void set_value_digit(short digit) { m_digit = digit; } short get_value_digit() { return m_digit; } + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } protected: virtual void on_paint() { @@ -2974,7 +2861,10 @@ protected: return; } m_cur_value += m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } void on_arrow_down_bt_click() @@ -2984,7 +2874,10 @@ protected: return; } m_cur_value -= m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } short m_cur_value; @@ -2995,6 +2888,7 @@ protected: short m_digit; c_spin_button m_bt_up; c_spin_button m_bt_down; + WND_CALLBACK on_change; }; inline void c_spin_button::on_touch(int x, int y, TOUCH_ACTION action) { @@ -3451,12 +3345,6 @@ private: unsigned char m_frame_len_map[64]; unsigned char m_frame_len_map_index; }; -#ifdef GUILITE_ON -GL_MSG_ENTRY c_cmd_target::ms_usr_map_entries[USR_MSG_MAX]; -unsigned short c_cmd_target::ms_user_map_size; -GL_BEGIN_MESSAGE_MAP(c_cmd_target) -GL_END_MESSAGE_MAP() -#endif #ifdef GUILITE_ON @@ -4305,9 +4193,6 @@ DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX]; #endif #ifdef GUILITE_ON c_keyboard c_edit::s_keyboard; -GL_BEGIN_MESSAGE_MAP(c_edit) -ON_KEYBORAD_UPDATE(c_edit::on_key_board_click) -GL_END_MESSAGE_MAP() #endif #ifdef GUILITE_ON static c_keyboard_button s_key_0, s_key_1, s_key_2, s_key_3, s_key_4, s_key_5, s_key_6, s_key_7, s_key_8, s_key_9; @@ -4375,7 +4260,4 @@ WND_TREE g_number_board_children[] = {&s_key_enter,'\n', 0, POS_X(3), POS_Y(2), KEY_WIDTH, KEY_HEIGHT * 2 + 2}, {0,0,0,0,0,0,0} }; -GL_BEGIN_MESSAGE_MAP(c_keyboard) -ON_GL_BN_CLICKED(c_keyboard::on_key_clicked) -GL_END_MESSAGE_MAP() #endif diff --git a/HelloTransparent/UIcode/UIcode.cpp b/HelloTransparent/UIcode/UIcode.cpp index 20ce977..b72187b 100644 --- a/HelloTransparent/UIcode/UIcode.cpp +++ b/HelloTransparent/UIcode/UIcode.cpp @@ -50,6 +50,10 @@ class c_wave : public c_wave_ctrl class c_my_dialog : public c_dialog { + virtual void on_init_children() + { + ((c_button*)get_wnd_ptr(ID_BUTTON))->set_on_click((WND_CALLBACK)&c_my_dialog::on_clicked); + } virtual void on_paint(void) { c_rect rect; @@ -61,15 +65,8 @@ class c_my_dialog : public c_dialog c_dialog::close_dialog(m_surface); ((c_surface_transparent*)m_surface)->clear_layer(m_z_order); } - - GL_DECLARE_MESSAGE_MAP()//delcare message }; -//map message -GL_BEGIN_MESSAGE_MAP(c_my_dialog) -ON_GL_BN_CLICKED(c_my_dialog::on_clicked) -GL_END_MESSAGE_MAP() - class c_my_ui : public c_wnd { public: -- Gitee From 13c110edd326fc3d30e805d83700d422bd895f24 Mon Sep 17 00:00:00 2001 From: idea4good Date: Sun, 18 Oct 2020 14:27:57 +0800 Subject: [PATCH 07/12] helloScroll ok --- HelloScroll/UIcode/GuiLite.h | 220 ++++++++-------------------------- HelloScroll/UIcode/UIcode.cpp | 30 +++-- HelloScroll/UIcode/scroll.h | 15 +-- 3 files changed, 73 insertions(+), 192 deletions(-) diff --git a/HelloScroll/UIcode/GuiLite.h b/HelloScroll/UIcode/GuiLite.h index 4df4afa..de5a678 100644 --- a/HelloScroll/UIcode/GuiLite.h +++ b/HelloScroll/UIcode/GuiLite.h @@ -102,123 +102,6 @@ public: int m_right; int m_bottom; }; -#define MSG_TYPE_INVALID 0xFFFF -#define MSG_TYPE_WND 0x0001 -#define MSG_TYPE_USR 0x0002 -#define USR_MSG_MAX 32 -class c_cmd_target; -typedef void (c_cmd_target::*msgCallback)(int, int); -struct GL_MSG_ENTRY -{ - unsigned int msgType; - unsigned int msgId; - c_cmd_target* object; - msgCallback callBack; -}; -#define ON_GL_USER_MSG(msgId, func) \ -{MSG_TYPE_USR, msgId, 0, msgCallback(&func)}, -#define GL_DECLARE_MESSAGE_MAP() \ -protected: \ - virtual const GL_MSG_ENTRY* get_msg_entries() const;\ -private: \ - static const GL_MSG_ENTRY m_msg_entries[]; -#define GL_BEGIN_MESSAGE_MAP(theClass) \ -const GL_MSG_ENTRY* theClass::get_msg_entries() const \ -{ \ - return theClass::m_msg_entries; \ -} \ -const GL_MSG_ENTRY theClass::m_msg_entries[] = \ -{ -#define GL_END_MESSAGE_MAP() \ -{MSG_TYPE_INVALID, 0, 0, 0}}; -class c_cmd_target -{ -public: - static int handle_usr_msg(int msg_id, int resource_id, int param) - { - int i; - c_cmd_target* p_wnd = 0; - for (i = 0; i < ms_user_map_size; i++) - { - if (msg_id == ms_usr_map_entries[i].msgId) - { - p_wnd = (c_cmd_target*)ms_usr_map_entries[i].object; - (p_wnd->*ms_usr_map_entries[i].callBack)(resource_id, param); - } - } - return 1; - } -protected: - void load_cmd_msg() - { - const GL_MSG_ENTRY* p_entry = get_msg_entries(); - if (0 == p_entry) - { - return; - } - bool bExist = false; - while (MSG_TYPE_INVALID != p_entry->msgType) - { - if (MSG_TYPE_WND == p_entry->msgType) - { - p_entry++; - continue; - } - bExist = false; - for (int i = 0; i < ms_user_map_size; i++) - { - //repeat register, return. - if (p_entry->msgId == ms_usr_map_entries[i].msgId - && ms_usr_map_entries[i].object == this) - { - bExist = true; - break; - } - } - if (true == bExist) - { - p_entry++; - continue; - } - if (MSG_TYPE_USR == p_entry->msgType) - { - if (USR_MSG_MAX == ms_user_map_size) - { - ASSERT(false); - } - ms_usr_map_entries[ms_user_map_size] = *p_entry; - ms_usr_map_entries[ms_user_map_size].object = this; - ms_user_map_size++; - } - else - { - ASSERT(false); - break; - } - p_entry++; - } - } - const GL_MSG_ENTRY* find_msg_entry(const GL_MSG_ENTRY *pEntry, int msgType, int msgId) - { - if (MSG_TYPE_INVALID == msgType) - { - return 0; - } - while (MSG_TYPE_INVALID != pEntry->msgType) - { - if ((msgType == pEntry->msgType) && (msgId == pEntry->msgId)) - { - return pEntry; - } - pEntry++; - } - return 0; - } -private: - static GL_MSG_ENTRY ms_usr_map_entries[USR_MSG_MAX]; - static unsigned short ms_user_map_size; - GL_DECLARE_MESSAGE_MAP() -}; //BITMAP typedef struct struct_bitmap_info { @@ -1329,9 +1212,9 @@ typedef struct struct_wnd_tree short height; struct struct_wnd_tree* p_child_tree;//sub tree }WND_TREE; -class c_wnd : public c_cmd_target +typedef void (c_wnd::*WND_CALLBACK)(int, int); +class c_wnd { - friend class c_dialog; public: c_wnd() : m_status(STATUS_NORMAL), m_attr((WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS)), m_parent(0), m_top_child(0), m_prev_sibling(0), m_next_sibling(0), m_str(0), m_font_color(0), m_bg_color(0), m_id(0), m_z_order(Z_ORDER_LEVEL_0), m_focus_child(0), m_surface(0) {}; @@ -1370,7 +1253,6 @@ public: } if (load_child_wnd(p_child_tree) >= 0) { - load_cmd_msg(); on_init_children(); } return 0; @@ -1549,19 +1431,6 @@ public: } c_wnd* get_prev_sibling() const { return m_prev_sibling; } c_wnd* get_next_sibling() const { return m_next_sibling; } - void notify_parent(int msg_id, int param) - { - if (!m_parent) - { - return; - } - const GL_MSG_ENTRY* entry = m_parent->find_msg_entry(m_parent->get_msg_entries(), MSG_TYPE_WND, msg_id); - if (0 == entry) - { - return; - } - (m_parent->*(entry->callBack))(m_id, param); - } virtual void on_touch(int x, int y, TOUCH_ACTION action) { x -= m_wnd_rect.m_left; @@ -1733,6 +1602,7 @@ protected: virtual void on_focus() {}; virtual void on_kill_focus() {}; protected: + unsigned short m_id; WND_STATUS m_status; WND_ATTRIBUTION m_attr; c_rect m_wnd_rect; //position relative to parent window. @@ -1740,23 +1610,18 @@ protected: c_wnd* m_top_child; //the first sub window would be navigated c_wnd* m_prev_sibling; //previous brother c_wnd* m_next_sibling; //next brother + c_wnd* m_focus_child; //current focused window const char* m_str; //caption const FONT_INFO* m_font_type; unsigned int m_font_color; unsigned int m_bg_color; - unsigned short m_id; int m_z_order; //the graphic level for rendering - c_wnd* m_focus_child; //current focused window c_surface* m_surface; -private: - c_wnd(const c_wnd &win); - c_wnd& operator=(const c_wnd &win); }; -#define GL_BN_CLICKED 0x1111 -#define ON_GL_BN_CLICKED(func) {MSG_TYPE_WND, GL_BN_CLICKED, 0, msgCallback(&func)}, -typedef struct struct_bitmap_info BITMAP_INFO; class c_button : public c_wnd { +public: + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void on_paint() { @@ -1819,7 +1684,10 @@ protected: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_BN_CLICKED, 0); + if(on_click) + { + (m_parent->*(on_click))(m_id, 0); + } } } virtual void on_navigate(NAVIGATION_KEY key) @@ -1836,6 +1704,7 @@ protected: } return c_wnd::on_navigate(key); } + WND_CALLBACK on_click = 0; }; class c_surface; class c_dialog; @@ -2006,8 +1875,21 @@ public: } return -1; } + virtual void on_init_children() + { + c_wnd* child = m_top_child; + if (0 != child) + { + while (child) + { + ((c_button*)child)->set_on_click(WND_CALLBACK(&c_keyboard::on_key_clicked)); + child = child->get_next_sibling(); + } + } + } KEYBOARD_STATUS get_cap_status(){return m_cap_status;} char* get_str() { return m_str; } + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void pre_create_wnd() { @@ -2064,7 +1946,7 @@ protected: ASSERT(false); InputChar: m_str[m_str_len++] = id; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_del_clicked(int id, int param) { @@ -2073,7 +1955,7 @@ protected: return; } m_str[--m_str_len] = 0; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_caps_clicked(int id, int param) { @@ -2083,18 +1965,18 @@ protected: void on_enter_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - return notify_parent(KEYBORAD_CLICK, CLICK_ENTER); + (m_parent->*(on_click))(m_id, CLICK_ENTER); } void on_esc_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - notify_parent(KEYBORAD_CLICK, CLICK_ESC); + (m_parent->*(on_click))(m_id, CLICK_ESC); } - GL_DECLARE_MESSAGE_MAP() private: char m_str[32]; int m_str_len; KEYBOARD_STATUS m_cap_status; + WND_CALLBACK on_click; }; class c_keyboard_button : public c_button { @@ -2284,11 +2166,11 @@ protected: break; } } - GL_DECLARE_MESSAGE_MAP() private: void show_keyboard() { s_keyboard.connect(this, IDD_KEY_BOARD, m_kb_style); + s_keyboard.set_on_click(WND_CALLBACK(&c_edit::on_key_board_click)); s_keyboard.show_window(); } void on_touch_down(int x, int y) @@ -2368,12 +2250,12 @@ protected: }; #include #define MAX_ITEM_NUM 4 -#define GL_LIST_CONFIRM 0x1 #define ITEM_HEIGHT 45 -#define ON_LIST_CONFIRM(func) {MSG_TYPE_WND, GL_LIST_CONFIRM, 0, msgCallback(&func)}, class c_list_box : public c_wnd { public: + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } + short get_item_count() { return m_item_total; } int add_item(char* str) { if (m_item_total >= MAX_ITEM_NUM) @@ -2391,7 +2273,6 @@ public: memset(m_item_array, 0, sizeof(m_item_array)); update_list_size(); } - short get_item_count() { return m_item_total; } void select_item(short index) { if (index < 0 || index >= m_item_total) @@ -2546,7 +2427,10 @@ private: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } } } @@ -2569,7 +2453,10 @@ private: m_status = STATUS_FOCUSED; select_item((y - m_list_wnd_rect.m_top) / ITEM_HEIGHT); on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } else { @@ -2582,6 +2469,7 @@ private: char* m_item_array[MAX_ITEM_NUM]; c_rect m_list_wnd_rect; //rect relative to parent wnd. c_rect m_list_screen_rect; //rect relative to physical screen(frame buffer) + WND_CALLBACK on_change; }; #include #define MAX_PAGES 5 @@ -2920,8 +2808,6 @@ inline void c_slide_group::on_touch(int x, int y, TOUCH_ACTION action) } #define ID_BT_ARROW_UP 0x1111 #define ID_BT_ARROW_DOWN 0x2222 -#define GL_SPIN_CHANGE 0x3333 -#define ON_SPIN_CHANGE(func) {MSG_TYPE_WND, GL_SPIN_CHANGE, 0, msgCallback(&func)}, class c_spin_box; class c_spin_button : public c_button { @@ -2942,6 +2828,7 @@ public: short get_step() { return m_step; } void set_value_digit(short digit) { m_digit = digit; } short get_value_digit() { return m_digit; } + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } protected: virtual void on_paint() { @@ -2974,7 +2861,10 @@ protected: return; } m_cur_value += m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } void on_arrow_down_bt_click() @@ -2984,7 +2874,10 @@ protected: return; } m_cur_value -= m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } short m_cur_value; @@ -2995,6 +2888,7 @@ protected: short m_digit; c_spin_button m_bt_up; c_spin_button m_bt_down; + WND_CALLBACK on_change; }; inline void c_spin_button::on_touch(int x, int y, TOUCH_ACTION action) { @@ -3451,12 +3345,6 @@ private: unsigned char m_frame_len_map[64]; unsigned char m_frame_len_map_index; }; -#ifdef GUILITE_ON -GL_MSG_ENTRY c_cmd_target::ms_usr_map_entries[USR_MSG_MAX]; -unsigned short c_cmd_target::ms_user_map_size; -GL_BEGIN_MESSAGE_MAP(c_cmd_target) -GL_END_MESSAGE_MAP() -#endif #ifdef GUILITE_ON @@ -4305,9 +4193,6 @@ DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX]; #endif #ifdef GUILITE_ON c_keyboard c_edit::s_keyboard; -GL_BEGIN_MESSAGE_MAP(c_edit) -ON_KEYBORAD_UPDATE(c_edit::on_key_board_click) -GL_END_MESSAGE_MAP() #endif #ifdef GUILITE_ON static c_keyboard_button s_key_0, s_key_1, s_key_2, s_key_3, s_key_4, s_key_5, s_key_6, s_key_7, s_key_8, s_key_9; @@ -4375,7 +4260,4 @@ WND_TREE g_number_board_children[] = {&s_key_enter,'\n', 0, POS_X(3), POS_Y(2), KEY_WIDTH, KEY_HEIGHT * 2 + 2}, {0,0,0,0,0,0,0} }; -GL_BEGIN_MESSAGE_MAP(c_keyboard) -ON_GL_BN_CLICKED(c_keyboard::on_key_clicked) -GL_END_MESSAGE_MAP() #endif diff --git a/HelloScroll/UIcode/UIcode.cpp b/HelloScroll/UIcode/UIcode.cpp index d3d6f95..8053073 100644 --- a/HelloScroll/UIcode/UIcode.cpp +++ b/HelloScroll/UIcode/UIcode.cpp @@ -27,11 +27,25 @@ enum WND_ID extern const BITMAP_INFO image1_bmp, image2_bmp, image3_bmp, image4_bmp, image5_bmp, image6_bmp, image7_bmp, image8_bmp, image9_bmp; -class c_my_ui : public c_wnd +class c_scroll_view_v : public c_scroll_view { + virtual void on_init_children() + { + ((c_button*)get_wnd_ptr(ID_BUTTON_1))->set_on_click((WND_CALLBACK)&c_scroll_view_v::on_button_clicked); + ((c_button*)get_wnd_ptr(ID_BUTTON_2))->set_on_click((WND_CALLBACK)&c_scroll_view_v::on_button_clicked); + ((c_button*)get_wnd_ptr(ID_BUTTON_3))->set_on_click((WND_CALLBACK)&c_scroll_view_v::on_button_clicked); + ((c_button*)get_wnd_ptr(ID_BUTTON_4))->set_on_click((WND_CALLBACK)&c_scroll_view_v::on_button_clicked); + ((c_button*)get_wnd_ptr(ID_BUTTON_5))->set_on_click((WND_CALLBACK)&c_scroll_view_v::on_button_clicked); + ((c_button*)get_wnd_ptr(ID_BUTTON_6))->set_on_click((WND_CALLBACK)&c_scroll_view_v::on_button_clicked); + ((c_button*)get_wnd_ptr(ID_BUTTON_7))->set_on_click((WND_CALLBACK)&c_scroll_view_v::on_button_clicked); + ((c_button*)get_wnd_ptr(ID_BUTTON_8))->set_on_click((WND_CALLBACK)&c_scroll_view_v::on_button_clicked); + ((c_button*)get_wnd_ptr(ID_BUTTON_9))->set_on_click((WND_CALLBACK)&c_scroll_view_v::on_button_clicked); + + c_scroll_view::on_init_children(); + } void on_button_clicked(int ctrl_id, int param) { - switch (param) + switch (ctrl_id) { case ID_BUTTON_1: c_bitmap::draw_bitmap(m_surface, m_z_order, &image1_bmp, 230, 10); @@ -65,16 +79,12 @@ class c_my_ui : public c_wnd break; } } - GL_DECLARE_MESSAGE_MAP()//delcare message }; -GL_BEGIN_MESSAGE_MAP(c_my_ui) -ON_GL_BN_CLICKED(c_my_ui::on_button_clicked) -GL_END_MESSAGE_MAP() - // Layout Widgets -static c_my_ui s_my_ui; -static c_scroll_view s_scroll_view_1, s_scroll_view_2; +static c_wnd s_my_ui; +static c_scroll_view_v s_scroll_view_1; +static c_scroll_view s_scroll_view_2; static c_button s_button_1, s_button_2, s_button_3, s_button_4, s_button_5, s_button_6, s_button_7, s_button_8, s_button_9; static c_label label_1; @@ -102,7 +112,7 @@ WND_TREE s_scroll_widgets_2[] = WND_TREE s_main_widgets[] = { - {(c_wnd*)&s_scroll_view_1, ID_SCROLL_VIEW_1, 0, 0, 0, 220, 290, s_scroll_widgets_1}, + {(c_wnd*)&s_scroll_view_1, ID_SCROLL_VIEW_1, 0, 0, 0, 600, 290, s_scroll_widgets_1}, {(c_wnd*)&s_scroll_view_2, ID_SCROLL_VIEW_2, 0, 0, 300, 600, 100, s_scroll_widgets_2}, {NULL, 0 , 0, 0, 0, 0, 0} }; diff --git a/HelloScroll/UIcode/scroll.h b/HelloScroll/UIcode/scroll.h index 6699286..2c818d2 100644 --- a/HelloScroll/UIcode/scroll.h +++ b/HelloScroll/UIcode/scroll.h @@ -20,8 +20,9 @@ public: }; #define MOVE_THRESHOLD 10 -class c_scroll_view : c_wnd +class c_scroll_view : public c_wnd { +protected: virtual void pre_create_wnd() { m_bg_color = GL_RGB(220, 220, 220); @@ -154,12 +155,6 @@ class c_scroll_view : c_wnd } } } - void on_button_clicked(int ctrl_id, int param) - { - notify_parent(GL_BN_CLICKED, ctrl_id); - } - - GL_DECLARE_MESSAGE_MAP()//delcare message private: TOUCH_ACTION m_touch_action = TOUCH_UP; c_display* m_mem_display; @@ -169,9 +164,3 @@ private: int m_offset_y = 0; int m_down_x, m_down_y; }; - -#ifdef GUILITE_ON -GL_BEGIN_MESSAGE_MAP(c_scroll_view) -ON_GL_BN_CLICKED(c_scroll_view::on_button_clicked) -GL_END_MESSAGE_MAP() -#endif -- Gitee From 4b3bd373fc4f19903fac8ac0b6a858864f8d57c5 Mon Sep 17 00:00:00 2001 From: idea4good Date: Sun, 18 Oct 2020 14:33:04 +0800 Subject: [PATCH 08/12] helloWave ok --- HelloWave/UIcode/GuiLite.h | 220 +++++++++--------------------------- HelloWave/UIcode/UIcode.cpp | 8 +- 2 files changed, 53 insertions(+), 175 deletions(-) diff --git a/HelloWave/UIcode/GuiLite.h b/HelloWave/UIcode/GuiLite.h index 4df4afa..de5a678 100644 --- a/HelloWave/UIcode/GuiLite.h +++ b/HelloWave/UIcode/GuiLite.h @@ -102,123 +102,6 @@ public: int m_right; int m_bottom; }; -#define MSG_TYPE_INVALID 0xFFFF -#define MSG_TYPE_WND 0x0001 -#define MSG_TYPE_USR 0x0002 -#define USR_MSG_MAX 32 -class c_cmd_target; -typedef void (c_cmd_target::*msgCallback)(int, int); -struct GL_MSG_ENTRY -{ - unsigned int msgType; - unsigned int msgId; - c_cmd_target* object; - msgCallback callBack; -}; -#define ON_GL_USER_MSG(msgId, func) \ -{MSG_TYPE_USR, msgId, 0, msgCallback(&func)}, -#define GL_DECLARE_MESSAGE_MAP() \ -protected: \ - virtual const GL_MSG_ENTRY* get_msg_entries() const;\ -private: \ - static const GL_MSG_ENTRY m_msg_entries[]; -#define GL_BEGIN_MESSAGE_MAP(theClass) \ -const GL_MSG_ENTRY* theClass::get_msg_entries() const \ -{ \ - return theClass::m_msg_entries; \ -} \ -const GL_MSG_ENTRY theClass::m_msg_entries[] = \ -{ -#define GL_END_MESSAGE_MAP() \ -{MSG_TYPE_INVALID, 0, 0, 0}}; -class c_cmd_target -{ -public: - static int handle_usr_msg(int msg_id, int resource_id, int param) - { - int i; - c_cmd_target* p_wnd = 0; - for (i = 0; i < ms_user_map_size; i++) - { - if (msg_id == ms_usr_map_entries[i].msgId) - { - p_wnd = (c_cmd_target*)ms_usr_map_entries[i].object; - (p_wnd->*ms_usr_map_entries[i].callBack)(resource_id, param); - } - } - return 1; - } -protected: - void load_cmd_msg() - { - const GL_MSG_ENTRY* p_entry = get_msg_entries(); - if (0 == p_entry) - { - return; - } - bool bExist = false; - while (MSG_TYPE_INVALID != p_entry->msgType) - { - if (MSG_TYPE_WND == p_entry->msgType) - { - p_entry++; - continue; - } - bExist = false; - for (int i = 0; i < ms_user_map_size; i++) - { - //repeat register, return. - if (p_entry->msgId == ms_usr_map_entries[i].msgId - && ms_usr_map_entries[i].object == this) - { - bExist = true; - break; - } - } - if (true == bExist) - { - p_entry++; - continue; - } - if (MSG_TYPE_USR == p_entry->msgType) - { - if (USR_MSG_MAX == ms_user_map_size) - { - ASSERT(false); - } - ms_usr_map_entries[ms_user_map_size] = *p_entry; - ms_usr_map_entries[ms_user_map_size].object = this; - ms_user_map_size++; - } - else - { - ASSERT(false); - break; - } - p_entry++; - } - } - const GL_MSG_ENTRY* find_msg_entry(const GL_MSG_ENTRY *pEntry, int msgType, int msgId) - { - if (MSG_TYPE_INVALID == msgType) - { - return 0; - } - while (MSG_TYPE_INVALID != pEntry->msgType) - { - if ((msgType == pEntry->msgType) && (msgId == pEntry->msgId)) - { - return pEntry; - } - pEntry++; - } - return 0; - } -private: - static GL_MSG_ENTRY ms_usr_map_entries[USR_MSG_MAX]; - static unsigned short ms_user_map_size; - GL_DECLARE_MESSAGE_MAP() -}; //BITMAP typedef struct struct_bitmap_info { @@ -1329,9 +1212,9 @@ typedef struct struct_wnd_tree short height; struct struct_wnd_tree* p_child_tree;//sub tree }WND_TREE; -class c_wnd : public c_cmd_target +typedef void (c_wnd::*WND_CALLBACK)(int, int); +class c_wnd { - friend class c_dialog; public: c_wnd() : m_status(STATUS_NORMAL), m_attr((WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS)), m_parent(0), m_top_child(0), m_prev_sibling(0), m_next_sibling(0), m_str(0), m_font_color(0), m_bg_color(0), m_id(0), m_z_order(Z_ORDER_LEVEL_0), m_focus_child(0), m_surface(0) {}; @@ -1370,7 +1253,6 @@ public: } if (load_child_wnd(p_child_tree) >= 0) { - load_cmd_msg(); on_init_children(); } return 0; @@ -1549,19 +1431,6 @@ public: } c_wnd* get_prev_sibling() const { return m_prev_sibling; } c_wnd* get_next_sibling() const { return m_next_sibling; } - void notify_parent(int msg_id, int param) - { - if (!m_parent) - { - return; - } - const GL_MSG_ENTRY* entry = m_parent->find_msg_entry(m_parent->get_msg_entries(), MSG_TYPE_WND, msg_id); - if (0 == entry) - { - return; - } - (m_parent->*(entry->callBack))(m_id, param); - } virtual void on_touch(int x, int y, TOUCH_ACTION action) { x -= m_wnd_rect.m_left; @@ -1733,6 +1602,7 @@ protected: virtual void on_focus() {}; virtual void on_kill_focus() {}; protected: + unsigned short m_id; WND_STATUS m_status; WND_ATTRIBUTION m_attr; c_rect m_wnd_rect; //position relative to parent window. @@ -1740,23 +1610,18 @@ protected: c_wnd* m_top_child; //the first sub window would be navigated c_wnd* m_prev_sibling; //previous brother c_wnd* m_next_sibling; //next brother + c_wnd* m_focus_child; //current focused window const char* m_str; //caption const FONT_INFO* m_font_type; unsigned int m_font_color; unsigned int m_bg_color; - unsigned short m_id; int m_z_order; //the graphic level for rendering - c_wnd* m_focus_child; //current focused window c_surface* m_surface; -private: - c_wnd(const c_wnd &win); - c_wnd& operator=(const c_wnd &win); }; -#define GL_BN_CLICKED 0x1111 -#define ON_GL_BN_CLICKED(func) {MSG_TYPE_WND, GL_BN_CLICKED, 0, msgCallback(&func)}, -typedef struct struct_bitmap_info BITMAP_INFO; class c_button : public c_wnd { +public: + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void on_paint() { @@ -1819,7 +1684,10 @@ protected: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_BN_CLICKED, 0); + if(on_click) + { + (m_parent->*(on_click))(m_id, 0); + } } } virtual void on_navigate(NAVIGATION_KEY key) @@ -1836,6 +1704,7 @@ protected: } return c_wnd::on_navigate(key); } + WND_CALLBACK on_click = 0; }; class c_surface; class c_dialog; @@ -2006,8 +1875,21 @@ public: } return -1; } + virtual void on_init_children() + { + c_wnd* child = m_top_child; + if (0 != child) + { + while (child) + { + ((c_button*)child)->set_on_click(WND_CALLBACK(&c_keyboard::on_key_clicked)); + child = child->get_next_sibling(); + } + } + } KEYBOARD_STATUS get_cap_status(){return m_cap_status;} char* get_str() { return m_str; } + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void pre_create_wnd() { @@ -2064,7 +1946,7 @@ protected: ASSERT(false); InputChar: m_str[m_str_len++] = id; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_del_clicked(int id, int param) { @@ -2073,7 +1955,7 @@ protected: return; } m_str[--m_str_len] = 0; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_caps_clicked(int id, int param) { @@ -2083,18 +1965,18 @@ protected: void on_enter_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - return notify_parent(KEYBORAD_CLICK, CLICK_ENTER); + (m_parent->*(on_click))(m_id, CLICK_ENTER); } void on_esc_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - notify_parent(KEYBORAD_CLICK, CLICK_ESC); + (m_parent->*(on_click))(m_id, CLICK_ESC); } - GL_DECLARE_MESSAGE_MAP() private: char m_str[32]; int m_str_len; KEYBOARD_STATUS m_cap_status; + WND_CALLBACK on_click; }; class c_keyboard_button : public c_button { @@ -2284,11 +2166,11 @@ protected: break; } } - GL_DECLARE_MESSAGE_MAP() private: void show_keyboard() { s_keyboard.connect(this, IDD_KEY_BOARD, m_kb_style); + s_keyboard.set_on_click(WND_CALLBACK(&c_edit::on_key_board_click)); s_keyboard.show_window(); } void on_touch_down(int x, int y) @@ -2368,12 +2250,12 @@ protected: }; #include #define MAX_ITEM_NUM 4 -#define GL_LIST_CONFIRM 0x1 #define ITEM_HEIGHT 45 -#define ON_LIST_CONFIRM(func) {MSG_TYPE_WND, GL_LIST_CONFIRM, 0, msgCallback(&func)}, class c_list_box : public c_wnd { public: + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } + short get_item_count() { return m_item_total; } int add_item(char* str) { if (m_item_total >= MAX_ITEM_NUM) @@ -2391,7 +2273,6 @@ public: memset(m_item_array, 0, sizeof(m_item_array)); update_list_size(); } - short get_item_count() { return m_item_total; } void select_item(short index) { if (index < 0 || index >= m_item_total) @@ -2546,7 +2427,10 @@ private: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } } } @@ -2569,7 +2453,10 @@ private: m_status = STATUS_FOCUSED; select_item((y - m_list_wnd_rect.m_top) / ITEM_HEIGHT); on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } else { @@ -2582,6 +2469,7 @@ private: char* m_item_array[MAX_ITEM_NUM]; c_rect m_list_wnd_rect; //rect relative to parent wnd. c_rect m_list_screen_rect; //rect relative to physical screen(frame buffer) + WND_CALLBACK on_change; }; #include #define MAX_PAGES 5 @@ -2920,8 +2808,6 @@ inline void c_slide_group::on_touch(int x, int y, TOUCH_ACTION action) } #define ID_BT_ARROW_UP 0x1111 #define ID_BT_ARROW_DOWN 0x2222 -#define GL_SPIN_CHANGE 0x3333 -#define ON_SPIN_CHANGE(func) {MSG_TYPE_WND, GL_SPIN_CHANGE, 0, msgCallback(&func)}, class c_spin_box; class c_spin_button : public c_button { @@ -2942,6 +2828,7 @@ public: short get_step() { return m_step; } void set_value_digit(short digit) { m_digit = digit; } short get_value_digit() { return m_digit; } + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } protected: virtual void on_paint() { @@ -2974,7 +2861,10 @@ protected: return; } m_cur_value += m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } void on_arrow_down_bt_click() @@ -2984,7 +2874,10 @@ protected: return; } m_cur_value -= m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } short m_cur_value; @@ -2995,6 +2888,7 @@ protected: short m_digit; c_spin_button m_bt_up; c_spin_button m_bt_down; + WND_CALLBACK on_change; }; inline void c_spin_button::on_touch(int x, int y, TOUCH_ACTION action) { @@ -3451,12 +3345,6 @@ private: unsigned char m_frame_len_map[64]; unsigned char m_frame_len_map_index; }; -#ifdef GUILITE_ON -GL_MSG_ENTRY c_cmd_target::ms_usr_map_entries[USR_MSG_MAX]; -unsigned short c_cmd_target::ms_user_map_size; -GL_BEGIN_MESSAGE_MAP(c_cmd_target) -GL_END_MESSAGE_MAP() -#endif #ifdef GUILITE_ON @@ -4305,9 +4193,6 @@ DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX]; #endif #ifdef GUILITE_ON c_keyboard c_edit::s_keyboard; -GL_BEGIN_MESSAGE_MAP(c_edit) -ON_KEYBORAD_UPDATE(c_edit::on_key_board_click) -GL_END_MESSAGE_MAP() #endif #ifdef GUILITE_ON static c_keyboard_button s_key_0, s_key_1, s_key_2, s_key_3, s_key_4, s_key_5, s_key_6, s_key_7, s_key_8, s_key_9; @@ -4375,7 +4260,4 @@ WND_TREE g_number_board_children[] = {&s_key_enter,'\n', 0, POS_X(3), POS_Y(2), KEY_WIDTH, KEY_HEIGHT * 2 + 2}, {0,0,0,0,0,0,0} }; -GL_BEGIN_MESSAGE_MAP(c_keyboard) -ON_GL_BN_CLICKED(c_keyboard::on_key_clicked) -GL_END_MESSAGE_MAP() #endif diff --git a/HelloWave/UIcode/UIcode.cpp b/HelloWave/UIcode/UIcode.cpp index 89c2b03..681e418 100644 --- a/HelloWave/UIcode/UIcode.cpp +++ b/HelloWave/UIcode/UIcode.cpp @@ -46,6 +46,8 @@ enum WND_ID class c_myUI : public c_wnd { virtual void on_init_children(void) { + ((c_button*)get_wnd_ptr(ID_BUTTON))->set_on_click((WND_CALLBACK)&c_myUI::on_clicked); + c_wave_ctrl *p_wave = (c_wave_ctrl*)get_wnd_ptr(ID_WAVE1); p_wave->set_wave_speed(1); p_wave->set_wave_color(GL_RGB(0, 255, 0)); @@ -96,14 +98,8 @@ public: c_wave_buffer m_wave_buffer1; c_wave_buffer m_wave_buffer2; c_wave_buffer m_wave_buffer3; - GL_DECLARE_MESSAGE_MAP()//delcare message }; -//map message -GL_BEGIN_MESSAGE_MAP(c_myUI) -ON_GL_BN_CLICKED(c_myUI::on_clicked) -GL_END_MESSAGE_MAP() - //////////////////////// layout UI //////////////////////// static c_myUI s_myUI; static c_wave_ctrl s_wave1; -- Gitee From b37c30e1cc85311eb4ed14e4b15cc5ef340c08a0 Mon Sep 17 00:00:00 2001 From: idea4good Date: Mon, 19 Oct 2020 12:47:29 +0800 Subject: [PATCH 09/12] hostmonitor-tbd --- HostMonitor/UIcode/include/GuiLite.h | 220 ++++-------------- .../UIcode/source/manager/wave_manager.h | 6 +- .../UIcode/source/start/host_monitor.cpp | 2 +- .../UIcode/source/ui_ctrl_ex/time_bar.cpp | 10 +- .../UIcode/source/ui_ctrl_ex/time_bar.h | 6 - .../source/ui_layout/View/top_bar/top_bar.cpp | 6 +- .../source/ui_layout/View/top_bar/top_bar.h | 1 - .../ui_layout/View/trend/trend_view.cpp | 2 +- .../source/ui_layout/View/trend/trend_view.h | 4 +- .../UIcode/source/ui_layout/slide_config.cpp | 41 ++-- 10 files changed, 81 insertions(+), 217 deletions(-) diff --git a/HostMonitor/UIcode/include/GuiLite.h b/HostMonitor/UIcode/include/GuiLite.h index 4df4afa..de5a678 100644 --- a/HostMonitor/UIcode/include/GuiLite.h +++ b/HostMonitor/UIcode/include/GuiLite.h @@ -102,123 +102,6 @@ public: int m_right; int m_bottom; }; -#define MSG_TYPE_INVALID 0xFFFF -#define MSG_TYPE_WND 0x0001 -#define MSG_TYPE_USR 0x0002 -#define USR_MSG_MAX 32 -class c_cmd_target; -typedef void (c_cmd_target::*msgCallback)(int, int); -struct GL_MSG_ENTRY -{ - unsigned int msgType; - unsigned int msgId; - c_cmd_target* object; - msgCallback callBack; -}; -#define ON_GL_USER_MSG(msgId, func) \ -{MSG_TYPE_USR, msgId, 0, msgCallback(&func)}, -#define GL_DECLARE_MESSAGE_MAP() \ -protected: \ - virtual const GL_MSG_ENTRY* get_msg_entries() const;\ -private: \ - static const GL_MSG_ENTRY m_msg_entries[]; -#define GL_BEGIN_MESSAGE_MAP(theClass) \ -const GL_MSG_ENTRY* theClass::get_msg_entries() const \ -{ \ - return theClass::m_msg_entries; \ -} \ -const GL_MSG_ENTRY theClass::m_msg_entries[] = \ -{ -#define GL_END_MESSAGE_MAP() \ -{MSG_TYPE_INVALID, 0, 0, 0}}; -class c_cmd_target -{ -public: - static int handle_usr_msg(int msg_id, int resource_id, int param) - { - int i; - c_cmd_target* p_wnd = 0; - for (i = 0; i < ms_user_map_size; i++) - { - if (msg_id == ms_usr_map_entries[i].msgId) - { - p_wnd = (c_cmd_target*)ms_usr_map_entries[i].object; - (p_wnd->*ms_usr_map_entries[i].callBack)(resource_id, param); - } - } - return 1; - } -protected: - void load_cmd_msg() - { - const GL_MSG_ENTRY* p_entry = get_msg_entries(); - if (0 == p_entry) - { - return; - } - bool bExist = false; - while (MSG_TYPE_INVALID != p_entry->msgType) - { - if (MSG_TYPE_WND == p_entry->msgType) - { - p_entry++; - continue; - } - bExist = false; - for (int i = 0; i < ms_user_map_size; i++) - { - //repeat register, return. - if (p_entry->msgId == ms_usr_map_entries[i].msgId - && ms_usr_map_entries[i].object == this) - { - bExist = true; - break; - } - } - if (true == bExist) - { - p_entry++; - continue; - } - if (MSG_TYPE_USR == p_entry->msgType) - { - if (USR_MSG_MAX == ms_user_map_size) - { - ASSERT(false); - } - ms_usr_map_entries[ms_user_map_size] = *p_entry; - ms_usr_map_entries[ms_user_map_size].object = this; - ms_user_map_size++; - } - else - { - ASSERT(false); - break; - } - p_entry++; - } - } - const GL_MSG_ENTRY* find_msg_entry(const GL_MSG_ENTRY *pEntry, int msgType, int msgId) - { - if (MSG_TYPE_INVALID == msgType) - { - return 0; - } - while (MSG_TYPE_INVALID != pEntry->msgType) - { - if ((msgType == pEntry->msgType) && (msgId == pEntry->msgId)) - { - return pEntry; - } - pEntry++; - } - return 0; - } -private: - static GL_MSG_ENTRY ms_usr_map_entries[USR_MSG_MAX]; - static unsigned short ms_user_map_size; - GL_DECLARE_MESSAGE_MAP() -}; //BITMAP typedef struct struct_bitmap_info { @@ -1329,9 +1212,9 @@ typedef struct struct_wnd_tree short height; struct struct_wnd_tree* p_child_tree;//sub tree }WND_TREE; -class c_wnd : public c_cmd_target +typedef void (c_wnd::*WND_CALLBACK)(int, int); +class c_wnd { - friend class c_dialog; public: c_wnd() : m_status(STATUS_NORMAL), m_attr((WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS)), m_parent(0), m_top_child(0), m_prev_sibling(0), m_next_sibling(0), m_str(0), m_font_color(0), m_bg_color(0), m_id(0), m_z_order(Z_ORDER_LEVEL_0), m_focus_child(0), m_surface(0) {}; @@ -1370,7 +1253,6 @@ public: } if (load_child_wnd(p_child_tree) >= 0) { - load_cmd_msg(); on_init_children(); } return 0; @@ -1549,19 +1431,6 @@ public: } c_wnd* get_prev_sibling() const { return m_prev_sibling; } c_wnd* get_next_sibling() const { return m_next_sibling; } - void notify_parent(int msg_id, int param) - { - if (!m_parent) - { - return; - } - const GL_MSG_ENTRY* entry = m_parent->find_msg_entry(m_parent->get_msg_entries(), MSG_TYPE_WND, msg_id); - if (0 == entry) - { - return; - } - (m_parent->*(entry->callBack))(m_id, param); - } virtual void on_touch(int x, int y, TOUCH_ACTION action) { x -= m_wnd_rect.m_left; @@ -1733,6 +1602,7 @@ protected: virtual void on_focus() {}; virtual void on_kill_focus() {}; protected: + unsigned short m_id; WND_STATUS m_status; WND_ATTRIBUTION m_attr; c_rect m_wnd_rect; //position relative to parent window. @@ -1740,23 +1610,18 @@ protected: c_wnd* m_top_child; //the first sub window would be navigated c_wnd* m_prev_sibling; //previous brother c_wnd* m_next_sibling; //next brother + c_wnd* m_focus_child; //current focused window const char* m_str; //caption const FONT_INFO* m_font_type; unsigned int m_font_color; unsigned int m_bg_color; - unsigned short m_id; int m_z_order; //the graphic level for rendering - c_wnd* m_focus_child; //current focused window c_surface* m_surface; -private: - c_wnd(const c_wnd &win); - c_wnd& operator=(const c_wnd &win); }; -#define GL_BN_CLICKED 0x1111 -#define ON_GL_BN_CLICKED(func) {MSG_TYPE_WND, GL_BN_CLICKED, 0, msgCallback(&func)}, -typedef struct struct_bitmap_info BITMAP_INFO; class c_button : public c_wnd { +public: + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void on_paint() { @@ -1819,7 +1684,10 @@ protected: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_BN_CLICKED, 0); + if(on_click) + { + (m_parent->*(on_click))(m_id, 0); + } } } virtual void on_navigate(NAVIGATION_KEY key) @@ -1836,6 +1704,7 @@ protected: } return c_wnd::on_navigate(key); } + WND_CALLBACK on_click = 0; }; class c_surface; class c_dialog; @@ -2006,8 +1875,21 @@ public: } return -1; } + virtual void on_init_children() + { + c_wnd* child = m_top_child; + if (0 != child) + { + while (child) + { + ((c_button*)child)->set_on_click(WND_CALLBACK(&c_keyboard::on_key_clicked)); + child = child->get_next_sibling(); + } + } + } KEYBOARD_STATUS get_cap_status(){return m_cap_status;} char* get_str() { return m_str; } + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void pre_create_wnd() { @@ -2064,7 +1946,7 @@ protected: ASSERT(false); InputChar: m_str[m_str_len++] = id; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_del_clicked(int id, int param) { @@ -2073,7 +1955,7 @@ protected: return; } m_str[--m_str_len] = 0; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_caps_clicked(int id, int param) { @@ -2083,18 +1965,18 @@ protected: void on_enter_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - return notify_parent(KEYBORAD_CLICK, CLICK_ENTER); + (m_parent->*(on_click))(m_id, CLICK_ENTER); } void on_esc_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - notify_parent(KEYBORAD_CLICK, CLICK_ESC); + (m_parent->*(on_click))(m_id, CLICK_ESC); } - GL_DECLARE_MESSAGE_MAP() private: char m_str[32]; int m_str_len; KEYBOARD_STATUS m_cap_status; + WND_CALLBACK on_click; }; class c_keyboard_button : public c_button { @@ -2284,11 +2166,11 @@ protected: break; } } - GL_DECLARE_MESSAGE_MAP() private: void show_keyboard() { s_keyboard.connect(this, IDD_KEY_BOARD, m_kb_style); + s_keyboard.set_on_click(WND_CALLBACK(&c_edit::on_key_board_click)); s_keyboard.show_window(); } void on_touch_down(int x, int y) @@ -2368,12 +2250,12 @@ protected: }; #include #define MAX_ITEM_NUM 4 -#define GL_LIST_CONFIRM 0x1 #define ITEM_HEIGHT 45 -#define ON_LIST_CONFIRM(func) {MSG_TYPE_WND, GL_LIST_CONFIRM, 0, msgCallback(&func)}, class c_list_box : public c_wnd { public: + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } + short get_item_count() { return m_item_total; } int add_item(char* str) { if (m_item_total >= MAX_ITEM_NUM) @@ -2391,7 +2273,6 @@ public: memset(m_item_array, 0, sizeof(m_item_array)); update_list_size(); } - short get_item_count() { return m_item_total; } void select_item(short index) { if (index < 0 || index >= m_item_total) @@ -2546,7 +2427,10 @@ private: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } } } @@ -2569,7 +2453,10 @@ private: m_status = STATUS_FOCUSED; select_item((y - m_list_wnd_rect.m_top) / ITEM_HEIGHT); on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } else { @@ -2582,6 +2469,7 @@ private: char* m_item_array[MAX_ITEM_NUM]; c_rect m_list_wnd_rect; //rect relative to parent wnd. c_rect m_list_screen_rect; //rect relative to physical screen(frame buffer) + WND_CALLBACK on_change; }; #include #define MAX_PAGES 5 @@ -2920,8 +2808,6 @@ inline void c_slide_group::on_touch(int x, int y, TOUCH_ACTION action) } #define ID_BT_ARROW_UP 0x1111 #define ID_BT_ARROW_DOWN 0x2222 -#define GL_SPIN_CHANGE 0x3333 -#define ON_SPIN_CHANGE(func) {MSG_TYPE_WND, GL_SPIN_CHANGE, 0, msgCallback(&func)}, class c_spin_box; class c_spin_button : public c_button { @@ -2942,6 +2828,7 @@ public: short get_step() { return m_step; } void set_value_digit(short digit) { m_digit = digit; } short get_value_digit() { return m_digit; } + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } protected: virtual void on_paint() { @@ -2974,7 +2861,10 @@ protected: return; } m_cur_value += m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } void on_arrow_down_bt_click() @@ -2984,7 +2874,10 @@ protected: return; } m_cur_value -= m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } short m_cur_value; @@ -2995,6 +2888,7 @@ protected: short m_digit; c_spin_button m_bt_up; c_spin_button m_bt_down; + WND_CALLBACK on_change; }; inline void c_spin_button::on_touch(int x, int y, TOUCH_ACTION action) { @@ -3451,12 +3345,6 @@ private: unsigned char m_frame_len_map[64]; unsigned char m_frame_len_map_index; }; -#ifdef GUILITE_ON -GL_MSG_ENTRY c_cmd_target::ms_usr_map_entries[USR_MSG_MAX]; -unsigned short c_cmd_target::ms_user_map_size; -GL_BEGIN_MESSAGE_MAP(c_cmd_target) -GL_END_MESSAGE_MAP() -#endif #ifdef GUILITE_ON @@ -4305,9 +4193,6 @@ DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX]; #endif #ifdef GUILITE_ON c_keyboard c_edit::s_keyboard; -GL_BEGIN_MESSAGE_MAP(c_edit) -ON_KEYBORAD_UPDATE(c_edit::on_key_board_click) -GL_END_MESSAGE_MAP() #endif #ifdef GUILITE_ON static c_keyboard_button s_key_0, s_key_1, s_key_2, s_key_3, s_key_4, s_key_5, s_key_6, s_key_7, s_key_8, s_key_9; @@ -4375,7 +4260,4 @@ WND_TREE g_number_board_children[] = {&s_key_enter,'\n', 0, POS_X(3), POS_Y(2), KEY_WIDTH, KEY_HEIGHT * 2 + 2}, {0,0,0,0,0,0,0} }; -GL_BEGIN_MESSAGE_MAP(c_keyboard) -ON_GL_BN_CLICKED(c_keyboard::on_key_clicked) -GL_END_MESSAGE_MAP() #endif diff --git a/HostMonitor/UIcode/source/manager/wave_manager.h b/HostMonitor/UIcode/source/manager/wave_manager.h index 33d79c2..4e3c2e0 100644 --- a/HostMonitor/UIcode/source/manager/wave_manager.h +++ b/HostMonitor/UIcode/source/manager/wave_manager.h @@ -44,7 +44,7 @@ typedef struct struct_wave_ctrl_discpritor }WAVE_CTRL_DISCPRITOR; class c_wave_ctrl; -class c_wave_manage : public c_cmd_target +class c_wave_manage { public: int register_wave_ctrl(WAVE_TYPE wave_ctrl_type, c_wave_ctrl* p_wave); @@ -59,11 +59,7 @@ public: private: c_wave_buffer m_waves[WAVE_TYPE_MAX]; c_wave_ctrl* m_wave_ctrls[WAVE_TYPE_MAX][WAVE_CTRL_MAX]; - c_wave_manage(); - c_wave_manage(const c_wave_manage&); - c_wave_manage& operator=(const c_wave_manage&); - ~c_wave_manage(){} }; #endif diff --git a/HostMonitor/UIcode/source/start/host_monitor.cpp b/HostMonitor/UIcode/source/start/host_monitor.cpp index 6427483..a06ad34 100644 --- a/HostMonitor/UIcode/source/start/host_monitor.cpp +++ b/HostMonitor/UIcode/source/start/host_monitor.cpp @@ -45,7 +45,7 @@ void startHostMonitor(void* phy_fb, int screen_width, int screen_height, int col if (read_usr_msg(&msg) > 0) { ASSERT((msg.dwMsgId & 0xf0000000) == 0); - c_cmd_target::handle_usr_msg(msg.dwMsgId, msg.dwParam1, msg.dwParam2); + //c_cmd_target::handle_usr_msg(msg.dwMsgId, msg.dwParam1, msg.dwParam2);//tbd } } } diff --git a/HostMonitor/UIcode/source/ui_ctrl_ex/time_bar.cpp b/HostMonitor/UIcode/source/ui_ctrl_ex/time_bar.cpp index 9553dc6..4edc2f8 100644 --- a/HostMonitor/UIcode/source/ui_ctrl_ex/time_bar.cpp +++ b/HostMonitor/UIcode/source/ui_ctrl_ex/time_bar.cpp @@ -15,10 +15,6 @@ #define ID_FORWARD_BTN 3 #define ID_FAST_FORWARD_BTN 4 -GL_BEGIN_MESSAGE_MAP(c_time_bar) -ON_GL_BN_CLICKED(c_time_bar::on_btn_click) -GL_END_MESSAGE_MAP() - void c_time_bar::on_init_children() { set_time(get_time_in_second()); @@ -30,6 +26,11 @@ void c_time_bar::on_init_children() m_backward.connect(this, ID_BACKWARD_BTN, "<", (BUTTON_LENGTH + 1), 0, BUTTON_LENGTH, rect.height()); m_forward.connect(this, ID_FORWARD_BTN, ">", (rect.width() - 2 * BUTTON_LENGTH - 6), 0, BUTTON_LENGTH, rect.height()); m_fast_forward.connect(this, ID_FAST_FORWARD_BTN, ">>", (rect.width() - BUTTON_LENGTH - 5), 0, BUTTON_LENGTH, rect.height()); + + ((c_button*)get_wnd_ptr(ID_FAST_BACKWARD_BTN))->set_on_click((WND_CALLBACK)&c_time_bar::on_btn_click); + ((c_button*)get_wnd_ptr(ID_BACKWARD_BTN))->set_on_click((WND_CALLBACK)&c_time_bar::on_btn_click); + ((c_button*)get_wnd_ptr(ID_FORWARD_BTN))->set_on_click((WND_CALLBACK)&c_time_bar::on_btn_click); + ((c_button*)get_wnd_ptr(ID_FAST_FORWARD_BTN))->set_on_click((WND_CALLBACK)&c_time_bar::on_btn_click); } void c_time_bar::on_paint(void) @@ -168,5 +169,4 @@ void c_time_bar::on_btn_click(int ctrl_id, int param) m_end_seconds += increment; m_start_seconds += increment; draw_mark(); - notify_parent(ND_SCALE_CLICKED, 0); } diff --git a/HostMonitor/UIcode/source/ui_ctrl_ex/time_bar.h b/HostMonitor/UIcode/source/ui_ctrl_ex/time_bar.h index fdd65ce..0c0d3fc 100644 --- a/HostMonitor/UIcode/source/ui_ctrl_ex/time_bar.h +++ b/HostMonitor/UIcode/source/ui_ctrl_ex/time_bar.h @@ -3,11 +3,6 @@ #include "GuiLite.h" -#define ND_SCALE_CLICKED 0x2013 - -#define ON_ND_SACLE_CLICKED(func) \ -{MSG_TYPE_WND, ND_SCALE_CLICKED, 0, msgCallback(&func)}, - class c_time_bar : public c_wnd { public: @@ -34,7 +29,6 @@ private: c_button m_fast_backward; c_button m_forward; c_button m_fast_forward; - GL_DECLARE_MESSAGE_MAP() }; #endif diff --git a/HostMonitor/UIcode/source/ui_layout/View/top_bar/top_bar.cpp b/HostMonitor/UIcode/source/ui_layout/View/top_bar/top_bar.cpp index 7ea79b7..710a70e 100644 --- a/HostMonitor/UIcode/source/ui_layout/View/top_bar/top_bar.cpp +++ b/HostMonitor/UIcode/source/ui_layout/View/top_bar/top_bar.cpp @@ -4,10 +4,6 @@ #include "top_bar.h" #include "top_bar_xml.h" -GL_BEGIN_MESSAGE_MAP(c_top_bar) -ON_GL_USER_MSG(USR_MSG_UPDATE_TIME,c_top_bar::on_refurbish_time) -GL_END_MESSAGE_MAP() - void c_top_bar::on_init_children(void) { m_bg_color = GL_RGB(0,0,0); @@ -34,7 +30,7 @@ void c_top_bar::on_refurbish_time(int id, int param) } extern int write_usr_msg(MSG_INFO* msg); -void c_top_bar::sysinfo_timer_callback(void* ptmr, void* parg) +void c_top_bar::sysinfo_timer_callback(void* ptmr, void* parg)//tbd { MSG_INFO msg_info; msg_info.dwMsgId = USR_MSG_UPDATE_TIME; diff --git a/HostMonitor/UIcode/source/ui_layout/View/top_bar/top_bar.h b/HostMonitor/UIcode/source/ui_layout/View/top_bar/top_bar.h index ee83ca3..d5b26c4 100644 --- a/HostMonitor/UIcode/source/ui_layout/View/top_bar/top_bar.h +++ b/HostMonitor/UIcode/source/ui_layout/View/top_bar/top_bar.h @@ -9,7 +9,6 @@ protected: virtual void on_init_children(void); virtual void on_paint(void); void on_refurbish_time(int id, int param); - GL_DECLARE_MESSAGE_MAP() }; #endif diff --git a/HostMonitor/UIcode/source/ui_layout/View/trend/trend_view.cpp b/HostMonitor/UIcode/source/ui_layout/View/trend/trend_view.cpp index 9b56410..4ae1106 100644 --- a/HostMonitor/UIcode/source/ui_layout/View/trend/trend_view.cpp +++ b/HostMonitor/UIcode/source/ui_layout/View/trend/trend_view.cpp @@ -23,7 +23,7 @@ GL_END_MESSAGE_MAP() void c_trend_view::on_init_children(void) { - c_trend_graph* p_trend_graph = (c_trend_graph*)get_wnd_ptr(ID_TREND_SCREEN_VITAL_TREND_CTRL); + c_trend_graph* p_trend_graph = (c_trend_graph*)get_wnd_ptr(ID_TREND_SCREEN_VITAL_TREND_CTRL); p_trend_graph->set_type(TREND_TYPE_VITAL); p_trend_graph = (c_trend_graph*)get_wnd_ptr(ID_TREND_SCREEN_PRESSURE_CTRL); p_trend_graph->set_type(TREND_TYPE_NIBP); diff --git a/HostMonitor/UIcode/source/ui_layout/View/trend/trend_view.h b/HostMonitor/UIcode/source/ui_layout/View/trend/trend_view.h index 99c9471..436d884 100644 --- a/HostMonitor/UIcode/source/ui_layout/View/trend/trend_view.h +++ b/HostMonitor/UIcode/source/ui_layout/View/trend/trend_view.h @@ -12,9 +12,7 @@ private: void on_update_trend_view(int id, int param); virtual void refresh_trend_table(long start_time, long end_time);//time unit: second virtual void refresh_trend_graphic(long time);//time unit: second - int read_trend_data(long start_time, long end_time, int hr[], int spo2[], int rr[], int pr[], - int nibp_sys[], int nibp_dia[], int nibp_mean[], int len);//time unit: second - GL_DECLARE_MESSAGE_MAP() + int read_trend_data(long start_time, long end_time, int hr[], int spo2[], int rr[], int pr[], int nibp_sys[], int nibp_dia[], int nibp_mean[], int len);//time unit: second }; #endif diff --git a/HostMonitor/UIcode/source/ui_layout/slide_config.cpp b/HostMonitor/UIcode/source/ui_layout/slide_config.cpp index b65a073..da7ecc2 100644 --- a/HostMonitor/UIcode/source/ui_layout/slide_config.cpp +++ b/HostMonitor/UIcode/source/ui_layout/slide_config.cpp @@ -7,30 +7,29 @@ #include "Dialog/about/about_dlg.h" #include "Dialog/about/about_dlg_xml.h" +//tbd class c_config_root : public c_wnd { - void on_clicked(int ctrl_id, int param); - GL_DECLARE_MESSAGE_MAP() -}; - -GL_BEGIN_MESSAGE_MAP(c_config_root) -ON_GL_BN_CLICKED(c_config_root::on_clicked) -GL_END_MESSAGE_MAP() - -void c_config_root::on_clicked(int ctrl_id, int param) -{ - switch(ctrl_id) + virtual void on_init_children() { - case 5: - c_dialog::open_dialog((c_dialog*)get_wnd_ptr(IDD_SETUP_DLG), false); - break; - case 7: - c_dialog::open_dialog((c_dialog*)get_wnd_ptr(IDD_ABOUT_DLG), false); - break; - default: - ASSERT(false); - break; + ((c_button*)get_wnd_ptr(IDD_SETUP_DLG))->set_on_click((WND_CALLBACK)&c_config_root::on_clicked); + ((c_button*)get_wnd_ptr(IDD_ABOUT_DLG))->set_on_click((WND_CALLBACK)&c_config_root::on_clicked); } -} + void on_clicked(int ctrl_id, int param) + { + switch (ctrl_id) + { + case 5: + c_dialog::open_dialog((c_dialog*)get_wnd_ptr(IDD_SETUP_DLG), false); + break; + case 7: + c_dialog::open_dialog((c_dialog*)get_wnd_ptr(IDD_ABOUT_DLG), false); + break; + default: + ASSERT(false); + break; + } + } +}; ////////////////////////////////////////////////////////////////////////// -- Gitee From 965444142bc0dd03905057e5a8423bd8be78f356 Mon Sep 17 00:00:00 2001 From: idea4good Date: Mon, 19 Oct 2020 17:40:59 +0800 Subject: [PATCH 10/12] host monitor build pass --- .github/.build-all.sh | 23 ++ .github/.updateGuiLite.sh | 22 ++ .github/FUNDING.yml | 1 + .gitignore | 3 +- Hello3D/UIcode/GuiLite.h | 247 +++++------------- Hello3Ddonut/UIcode/GuiLite.h | 247 +++++------------- Hello3Dwave/UIcode/GuiLite.h | 247 +++++------------- HelloAnimation/UIcode/GuiLite.h | 29 +- HelloCircle/UIcode/GuiLite.h | 247 +++++------------- HelloFFmpeg/UIcode/GuiLite.h | 247 +++++------------- HelloFont/UIcode/GuiLite.h | 29 +- HelloGuiLite/UIcode/GuiLite.h | 29 +- HelloLayers/UIcode/GuiLite.h | 247 +++++------------- HelloMario/UIcode/GuiLite.h | 247 +++++------------- HelloMolecule/UIcode/GuiLite.h | 247 +++++------------- HelloNets/UIcode/GuiLite.h | 247 +++++------------- HelloNoTouch/UIcode/GuiLite.h | 29 +- HelloParticle/UIcode/GuiLite.h | 247 +++++------------- HelloPendulum/UIcode/GuiLite.h | 247 +++++------------- HelloScroll/UIcode/GuiLite.h | 29 +- HelloSlide/UIcode/GuiLite.h | 247 +++++------------- HelloStar/UIcode/GuiLite.h | 247 +++++------------- HelloTimer/UIcode/GuiLite.h | 247 +++++------------- HelloTransparent/UIcode/GuiLite.h | 29 +- HelloWave/UIcode/GuiLite.h | 29 +- HelloWidgets/UIcode/GuiLite.h | 29 +- HostMonitor/UIcode/include/GuiLite.h | 29 +- HostMonitor/UIcode/include/ctrl_id.h | 4 +- HostMonitor/UIcode/include/msg_id.h | 2 +- .../UIcode/source/start/host_monitor.cpp | 8 +- .../UIcode/source/ui_ctrl_ex/value_view.cpp | 4 +- .../UIcode/source/ui_ctrl_ex/value_view.h | 2 +- .../source/ui_layout/View/top_bar/top_bar.cpp | 21 +- .../source/ui_layout/View/top_bar/top_bar.h | 3 +- .../ui_layout/View/trend/trend_view.cpp | 7 +- .../UIcode/source/ui_layout/slide_config.cpp | 17 +- .../UIcode/source/ui_layout/slide_trend.cpp | 2 +- 37 files changed, 1165 insertions(+), 2673 deletions(-) create mode 100644 .github/.build-all.sh create mode 100644 .github/.updateGuiLite.sh create mode 100644 .github/FUNDING.yml diff --git a/.github/.build-all.sh b/.github/.build-all.sh new file mode 100644 index 0000000..6003fc5 --- /dev/null +++ b/.github/.build-all.sh @@ -0,0 +1,23 @@ +# exit while meet error +set -e + +# build xWindow +cd ExternalWindow/X11 +gcc xWindow.c -lX11 -lpthread -o xWindow +cd ../.. + +#build HelloXXX +for file in ./Hello* +do + echo -e "\e[44m $file building...\e[49m" + cd $file + cmake . + make -j4 + cd .. +done + +#build HostMonitor +echo -e "\e[44m ./HostMonitor building...\e[49m" +cd HostMonitor +cmake . +make -j4 diff --git a/.github/.updateGuiLite.sh b/.github/.updateGuiLite.sh new file mode 100644 index 0000000..be7c59c --- /dev/null +++ b/.github/.updateGuiLite.sh @@ -0,0 +1,22 @@ +src=../../GuiLite.gitee +# exit while meet error +set -e +declare -i sum=0 + +#build HelloXXX +for file in ./Hello* +do + echo -e "\e[44m $file sync up...\e[49m" + cd $file + cp $src/GuiLite.h UIcode/GuiLite.h + cd .. + sum+=1 +done + +#build HostMonitor +echo -e "\e[44m ./HostMonitor sync up...\e[49m" +cd HostMonitor +cp $src/GuiLite.h UIcode/include/GuiLite.h +sum+=1 + +echo $sum files updated. diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..a373a67 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +custom: https://idea4good.github.io/ diff --git a/.gitignore b/.gitignore index 3cb25d2..4b8ca51 100644 --- a/.gitignore +++ b/.gitignore @@ -72,7 +72,7 @@ snap_short.bmp /HelloAnimation/BuildLinux/HelloAnimation /HelloCircle/BuildLinux/HelloCircle /HelloFFmpeg/BuildLinux/HelloFFmpeg -/HelloFont/BuildLinux/HelloFFmpeg +/HelloFont/BuildLinux/HelloFont /HelloGuiLite/BuildLinux/HelloGuiLite /HelloLayers/BuildLinux/HelloLayers /HelloMario/BuildLinux/HelloMario @@ -80,6 +80,7 @@ snap_short.bmp /HelloNets/BuildLinux/HelloNets /HelloNoTouch/BuildLinux/HelloNoTouch /HelloParticle/BuildLinux/HelloParticle +/HelloPendulum/BuildLinux/HelloPendulum /HelloScroll/BuildLinux/HelloScroll /HelloSlide/BuildLinux/HelloSlide /HelloStar/BuildLinux/HelloStar diff --git a/Hello3D/UIcode/GuiLite.h b/Hello3D/UIcode/GuiLite.h index 4df4afa..e397552 100644 --- a/Hello3D/UIcode/GuiLite.h +++ b/Hello3D/UIcode/GuiLite.h @@ -48,7 +48,7 @@ T_TIME second_to_day(long second); T_TIME get_time(); void start_real_timer(void (*func)(void* arg)); -void register_timer(int milli_second, void func(void* ptmr, void* parg)); +void register_timer(int milli_second, void func(void* param), void* param); unsigned int get_cur_thread_id(); void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg); @@ -102,123 +102,6 @@ public: int m_right; int m_bottom; }; -#define MSG_TYPE_INVALID 0xFFFF -#define MSG_TYPE_WND 0x0001 -#define MSG_TYPE_USR 0x0002 -#define USR_MSG_MAX 32 -class c_cmd_target; -typedef void (c_cmd_target::*msgCallback)(int, int); -struct GL_MSG_ENTRY -{ - unsigned int msgType; - unsigned int msgId; - c_cmd_target* object; - msgCallback callBack; -}; -#define ON_GL_USER_MSG(msgId, func) \ -{MSG_TYPE_USR, msgId, 0, msgCallback(&func)}, -#define GL_DECLARE_MESSAGE_MAP() \ -protected: \ - virtual const GL_MSG_ENTRY* get_msg_entries() const;\ -private: \ - static const GL_MSG_ENTRY m_msg_entries[]; -#define GL_BEGIN_MESSAGE_MAP(theClass) \ -const GL_MSG_ENTRY* theClass::get_msg_entries() const \ -{ \ - return theClass::m_msg_entries; \ -} \ -const GL_MSG_ENTRY theClass::m_msg_entries[] = \ -{ -#define GL_END_MESSAGE_MAP() \ -{MSG_TYPE_INVALID, 0, 0, 0}}; -class c_cmd_target -{ -public: - static int handle_usr_msg(int msg_id, int resource_id, int param) - { - int i; - c_cmd_target* p_wnd = 0; - for (i = 0; i < ms_user_map_size; i++) - { - if (msg_id == ms_usr_map_entries[i].msgId) - { - p_wnd = (c_cmd_target*)ms_usr_map_entries[i].object; - (p_wnd->*ms_usr_map_entries[i].callBack)(resource_id, param); - } - } - return 1; - } -protected: - void load_cmd_msg() - { - const GL_MSG_ENTRY* p_entry = get_msg_entries(); - if (0 == p_entry) - { - return; - } - bool bExist = false; - while (MSG_TYPE_INVALID != p_entry->msgType) - { - if (MSG_TYPE_WND == p_entry->msgType) - { - p_entry++; - continue; - } - bExist = false; - for (int i = 0; i < ms_user_map_size; i++) - { - //repeat register, return. - if (p_entry->msgId == ms_usr_map_entries[i].msgId - && ms_usr_map_entries[i].object == this) - { - bExist = true; - break; - } - } - if (true == bExist) - { - p_entry++; - continue; - } - if (MSG_TYPE_USR == p_entry->msgType) - { - if (USR_MSG_MAX == ms_user_map_size) - { - ASSERT(false); - } - ms_usr_map_entries[ms_user_map_size] = *p_entry; - ms_usr_map_entries[ms_user_map_size].object = this; - ms_user_map_size++; - } - else - { - ASSERT(false); - break; - } - p_entry++; - } - } - const GL_MSG_ENTRY* find_msg_entry(const GL_MSG_ENTRY *pEntry, int msgType, int msgId) - { - if (MSG_TYPE_INVALID == msgType) - { - return 0; - } - while (MSG_TYPE_INVALID != pEntry->msgType) - { - if ((msgType == pEntry->msgType) && (msgId == pEntry->msgId)) - { - return pEntry; - } - pEntry++; - } - return 0; - } -private: - static GL_MSG_ENTRY ms_usr_map_entries[USR_MSG_MAX]; - static unsigned short ms_user_map_size; - GL_DECLARE_MESSAGE_MAP() -}; //BITMAP typedef struct struct_bitmap_info { @@ -1329,9 +1212,9 @@ typedef struct struct_wnd_tree short height; struct struct_wnd_tree* p_child_tree;//sub tree }WND_TREE; -class c_wnd : public c_cmd_target +typedef void (c_wnd::*WND_CALLBACK)(int, int); +class c_wnd { - friend class c_dialog; public: c_wnd() : m_status(STATUS_NORMAL), m_attr((WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS)), m_parent(0), m_top_child(0), m_prev_sibling(0), m_next_sibling(0), m_str(0), m_font_color(0), m_bg_color(0), m_id(0), m_z_order(Z_ORDER_LEVEL_0), m_focus_child(0), m_surface(0) {}; @@ -1370,7 +1253,6 @@ public: } if (load_child_wnd(p_child_tree) >= 0) { - load_cmd_msg(); on_init_children(); } return 0; @@ -1549,19 +1431,6 @@ public: } c_wnd* get_prev_sibling() const { return m_prev_sibling; } c_wnd* get_next_sibling() const { return m_next_sibling; } - void notify_parent(int msg_id, int param) - { - if (!m_parent) - { - return; - } - const GL_MSG_ENTRY* entry = m_parent->find_msg_entry(m_parent->get_msg_entries(), MSG_TYPE_WND, msg_id); - if (0 == entry) - { - return; - } - (m_parent->*(entry->callBack))(m_id, param); - } virtual void on_touch(int x, int y, TOUCH_ACTION action) { x -= m_wnd_rect.m_left; @@ -1733,6 +1602,7 @@ protected: virtual void on_focus() {}; virtual void on_kill_focus() {}; protected: + unsigned short m_id; WND_STATUS m_status; WND_ATTRIBUTION m_attr; c_rect m_wnd_rect; //position relative to parent window. @@ -1740,23 +1610,18 @@ protected: c_wnd* m_top_child; //the first sub window would be navigated c_wnd* m_prev_sibling; //previous brother c_wnd* m_next_sibling; //next brother + c_wnd* m_focus_child; //current focused window const char* m_str; //caption const FONT_INFO* m_font_type; unsigned int m_font_color; unsigned int m_bg_color; - unsigned short m_id; int m_z_order; //the graphic level for rendering - c_wnd* m_focus_child; //current focused window c_surface* m_surface; -private: - c_wnd(const c_wnd &win); - c_wnd& operator=(const c_wnd &win); }; -#define GL_BN_CLICKED 0x1111 -#define ON_GL_BN_CLICKED(func) {MSG_TYPE_WND, GL_BN_CLICKED, 0, msgCallback(&func)}, -typedef struct struct_bitmap_info BITMAP_INFO; class c_button : public c_wnd { +public: + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void on_paint() { @@ -1803,6 +1668,7 @@ protected: } virtual void pre_create_wnd() { + on_click = 0; m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS); m_font_type = c_theme::get_font(FONT_DEFAULT); m_font_color = c_theme::get_color(COLOR_WND_FONT); @@ -1819,7 +1685,10 @@ protected: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_BN_CLICKED, 0); + if(on_click) + { + (m_parent->*(on_click))(m_id, 0); + } } } virtual void on_navigate(NAVIGATION_KEY key) @@ -1836,6 +1705,7 @@ protected: } return c_wnd::on_navigate(key); } + WND_CALLBACK on_click; }; class c_surface; class c_dialog; @@ -2006,8 +1876,21 @@ public: } return -1; } + virtual void on_init_children() + { + c_wnd* child = m_top_child; + if (0 != child) + { + while (child) + { + ((c_button*)child)->set_on_click(WND_CALLBACK(&c_keyboard::on_key_clicked)); + child = child->get_next_sibling(); + } + } + } KEYBOARD_STATUS get_cap_status(){return m_cap_status;} char* get_str() { return m_str; } + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void pre_create_wnd() { @@ -2064,7 +1947,7 @@ protected: ASSERT(false); InputChar: m_str[m_str_len++] = id; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_del_clicked(int id, int param) { @@ -2073,7 +1956,7 @@ protected: return; } m_str[--m_str_len] = 0; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_caps_clicked(int id, int param) { @@ -2083,18 +1966,18 @@ protected: void on_enter_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - return notify_parent(KEYBORAD_CLICK, CLICK_ENTER); + (m_parent->*(on_click))(m_id, CLICK_ENTER); } void on_esc_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - notify_parent(KEYBORAD_CLICK, CLICK_ESC); + (m_parent->*(on_click))(m_id, CLICK_ESC); } - GL_DECLARE_MESSAGE_MAP() private: char m_str[32]; int m_str_len; KEYBOARD_STATUS m_cap_status; + WND_CALLBACK on_click; }; class c_keyboard_button : public c_button { @@ -2284,11 +2167,11 @@ protected: break; } } - GL_DECLARE_MESSAGE_MAP() private: void show_keyboard() { s_keyboard.connect(this, IDD_KEY_BOARD, m_kb_style); + s_keyboard.set_on_click(WND_CALLBACK(&c_edit::on_key_board_click)); s_keyboard.show_window(); } void on_touch_down(int x, int y) @@ -2368,12 +2251,12 @@ protected: }; #include #define MAX_ITEM_NUM 4 -#define GL_LIST_CONFIRM 0x1 #define ITEM_HEIGHT 45 -#define ON_LIST_CONFIRM(func) {MSG_TYPE_WND, GL_LIST_CONFIRM, 0, msgCallback(&func)}, class c_list_box : public c_wnd { public: + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } + short get_item_count() { return m_item_total; } int add_item(char* str) { if (m_item_total >= MAX_ITEM_NUM) @@ -2391,7 +2274,6 @@ public: memset(m_item_array, 0, sizeof(m_item_array)); update_list_size(); } - short get_item_count() { return m_item_total; } void select_item(short index) { if (index < 0 || index >= m_item_total) @@ -2546,7 +2428,10 @@ private: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } } } @@ -2569,7 +2454,10 @@ private: m_status = STATUS_FOCUSED; select_item((y - m_list_wnd_rect.m_top) / ITEM_HEIGHT); on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } else { @@ -2582,6 +2470,7 @@ private: char* m_item_array[MAX_ITEM_NUM]; c_rect m_list_wnd_rect; //rect relative to parent wnd. c_rect m_list_screen_rect; //rect relative to physical screen(frame buffer) + WND_CALLBACK on_change; }; #include #define MAX_PAGES 5 @@ -2920,8 +2809,6 @@ inline void c_slide_group::on_touch(int x, int y, TOUCH_ACTION action) } #define ID_BT_ARROW_UP 0x1111 #define ID_BT_ARROW_DOWN 0x2222 -#define GL_SPIN_CHANGE 0x3333 -#define ON_SPIN_CHANGE(func) {MSG_TYPE_WND, GL_SPIN_CHANGE, 0, msgCallback(&func)}, class c_spin_box; class c_spin_button : public c_button { @@ -2942,6 +2829,7 @@ public: short get_step() { return m_step; } void set_value_digit(short digit) { m_digit = digit; } short get_value_digit() { return m_digit; } + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } protected: virtual void on_paint() { @@ -2974,7 +2862,10 @@ protected: return; } m_cur_value += m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } void on_arrow_down_bt_click() @@ -2984,7 +2875,10 @@ protected: return; } m_cur_value -= m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } short m_cur_value; @@ -2995,6 +2889,7 @@ protected: short m_digit; c_spin_button m_bt_up; c_spin_button m_bt_down; + WND_CALLBACK on_change; }; inline void c_spin_button::on_touch(int x, int y, TOUCH_ACTION action) { @@ -3451,12 +3346,6 @@ private: unsigned char m_frame_len_map[64]; unsigned char m_frame_len_map_index; }; -#ifdef GUILITE_ON -GL_MSG_ENTRY c_cmd_target::ms_usr_map_entries[USR_MSG_MAX]; -unsigned short c_cmd_target::ms_user_map_size; -GL_BEGIN_MESSAGE_MAP(c_cmd_target) -GL_END_MESSAGE_MAP() -#endif #ifdef GUILITE_ON @@ -3521,7 +3410,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3542,7 +3432,7 @@ static void* timer_routine(void*) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } usleep(1000 * TIMER_UNIT); @@ -3562,7 +3452,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc)(void* param), void* param) { init_mul_timer(); int i; @@ -3578,6 +3468,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -3641,9 +3532,9 @@ unsigned int get_cur_thread_id() { return (unsigned long)pthread_self(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -4002,7 +3893,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -4023,7 +3915,7 @@ DWORD WINAPI timer_routine(LPVOID lpParam) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } Sleep(TIMER_UNIT); @@ -4043,7 +3935,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc) (void* param), void* param) { init_mul_timer(); int i; @@ -4059,6 +3951,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -4126,9 +4019,9 @@ unsigned int get_cur_thread_id() { return GetCurrentThreadId(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -4305,9 +4198,6 @@ DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX]; #endif #ifdef GUILITE_ON c_keyboard c_edit::s_keyboard; -GL_BEGIN_MESSAGE_MAP(c_edit) -ON_KEYBORAD_UPDATE(c_edit::on_key_board_click) -GL_END_MESSAGE_MAP() #endif #ifdef GUILITE_ON static c_keyboard_button s_key_0, s_key_1, s_key_2, s_key_3, s_key_4, s_key_5, s_key_6, s_key_7, s_key_8, s_key_9; @@ -4375,7 +4265,4 @@ WND_TREE g_number_board_children[] = {&s_key_enter,'\n', 0, POS_X(3), POS_Y(2), KEY_WIDTH, KEY_HEIGHT * 2 + 2}, {0,0,0,0,0,0,0} }; -GL_BEGIN_MESSAGE_MAP(c_keyboard) -ON_GL_BN_CLICKED(c_keyboard::on_key_clicked) -GL_END_MESSAGE_MAP() #endif diff --git a/Hello3Ddonut/UIcode/GuiLite.h b/Hello3Ddonut/UIcode/GuiLite.h index 4df4afa..e397552 100644 --- a/Hello3Ddonut/UIcode/GuiLite.h +++ b/Hello3Ddonut/UIcode/GuiLite.h @@ -48,7 +48,7 @@ T_TIME second_to_day(long second); T_TIME get_time(); void start_real_timer(void (*func)(void* arg)); -void register_timer(int milli_second, void func(void* ptmr, void* parg)); +void register_timer(int milli_second, void func(void* param), void* param); unsigned int get_cur_thread_id(); void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg); @@ -102,123 +102,6 @@ public: int m_right; int m_bottom; }; -#define MSG_TYPE_INVALID 0xFFFF -#define MSG_TYPE_WND 0x0001 -#define MSG_TYPE_USR 0x0002 -#define USR_MSG_MAX 32 -class c_cmd_target; -typedef void (c_cmd_target::*msgCallback)(int, int); -struct GL_MSG_ENTRY -{ - unsigned int msgType; - unsigned int msgId; - c_cmd_target* object; - msgCallback callBack; -}; -#define ON_GL_USER_MSG(msgId, func) \ -{MSG_TYPE_USR, msgId, 0, msgCallback(&func)}, -#define GL_DECLARE_MESSAGE_MAP() \ -protected: \ - virtual const GL_MSG_ENTRY* get_msg_entries() const;\ -private: \ - static const GL_MSG_ENTRY m_msg_entries[]; -#define GL_BEGIN_MESSAGE_MAP(theClass) \ -const GL_MSG_ENTRY* theClass::get_msg_entries() const \ -{ \ - return theClass::m_msg_entries; \ -} \ -const GL_MSG_ENTRY theClass::m_msg_entries[] = \ -{ -#define GL_END_MESSAGE_MAP() \ -{MSG_TYPE_INVALID, 0, 0, 0}}; -class c_cmd_target -{ -public: - static int handle_usr_msg(int msg_id, int resource_id, int param) - { - int i; - c_cmd_target* p_wnd = 0; - for (i = 0; i < ms_user_map_size; i++) - { - if (msg_id == ms_usr_map_entries[i].msgId) - { - p_wnd = (c_cmd_target*)ms_usr_map_entries[i].object; - (p_wnd->*ms_usr_map_entries[i].callBack)(resource_id, param); - } - } - return 1; - } -protected: - void load_cmd_msg() - { - const GL_MSG_ENTRY* p_entry = get_msg_entries(); - if (0 == p_entry) - { - return; - } - bool bExist = false; - while (MSG_TYPE_INVALID != p_entry->msgType) - { - if (MSG_TYPE_WND == p_entry->msgType) - { - p_entry++; - continue; - } - bExist = false; - for (int i = 0; i < ms_user_map_size; i++) - { - //repeat register, return. - if (p_entry->msgId == ms_usr_map_entries[i].msgId - && ms_usr_map_entries[i].object == this) - { - bExist = true; - break; - } - } - if (true == bExist) - { - p_entry++; - continue; - } - if (MSG_TYPE_USR == p_entry->msgType) - { - if (USR_MSG_MAX == ms_user_map_size) - { - ASSERT(false); - } - ms_usr_map_entries[ms_user_map_size] = *p_entry; - ms_usr_map_entries[ms_user_map_size].object = this; - ms_user_map_size++; - } - else - { - ASSERT(false); - break; - } - p_entry++; - } - } - const GL_MSG_ENTRY* find_msg_entry(const GL_MSG_ENTRY *pEntry, int msgType, int msgId) - { - if (MSG_TYPE_INVALID == msgType) - { - return 0; - } - while (MSG_TYPE_INVALID != pEntry->msgType) - { - if ((msgType == pEntry->msgType) && (msgId == pEntry->msgId)) - { - return pEntry; - } - pEntry++; - } - return 0; - } -private: - static GL_MSG_ENTRY ms_usr_map_entries[USR_MSG_MAX]; - static unsigned short ms_user_map_size; - GL_DECLARE_MESSAGE_MAP() -}; //BITMAP typedef struct struct_bitmap_info { @@ -1329,9 +1212,9 @@ typedef struct struct_wnd_tree short height; struct struct_wnd_tree* p_child_tree;//sub tree }WND_TREE; -class c_wnd : public c_cmd_target +typedef void (c_wnd::*WND_CALLBACK)(int, int); +class c_wnd { - friend class c_dialog; public: c_wnd() : m_status(STATUS_NORMAL), m_attr((WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS)), m_parent(0), m_top_child(0), m_prev_sibling(0), m_next_sibling(0), m_str(0), m_font_color(0), m_bg_color(0), m_id(0), m_z_order(Z_ORDER_LEVEL_0), m_focus_child(0), m_surface(0) {}; @@ -1370,7 +1253,6 @@ public: } if (load_child_wnd(p_child_tree) >= 0) { - load_cmd_msg(); on_init_children(); } return 0; @@ -1549,19 +1431,6 @@ public: } c_wnd* get_prev_sibling() const { return m_prev_sibling; } c_wnd* get_next_sibling() const { return m_next_sibling; } - void notify_parent(int msg_id, int param) - { - if (!m_parent) - { - return; - } - const GL_MSG_ENTRY* entry = m_parent->find_msg_entry(m_parent->get_msg_entries(), MSG_TYPE_WND, msg_id); - if (0 == entry) - { - return; - } - (m_parent->*(entry->callBack))(m_id, param); - } virtual void on_touch(int x, int y, TOUCH_ACTION action) { x -= m_wnd_rect.m_left; @@ -1733,6 +1602,7 @@ protected: virtual void on_focus() {}; virtual void on_kill_focus() {}; protected: + unsigned short m_id; WND_STATUS m_status; WND_ATTRIBUTION m_attr; c_rect m_wnd_rect; //position relative to parent window. @@ -1740,23 +1610,18 @@ protected: c_wnd* m_top_child; //the first sub window would be navigated c_wnd* m_prev_sibling; //previous brother c_wnd* m_next_sibling; //next brother + c_wnd* m_focus_child; //current focused window const char* m_str; //caption const FONT_INFO* m_font_type; unsigned int m_font_color; unsigned int m_bg_color; - unsigned short m_id; int m_z_order; //the graphic level for rendering - c_wnd* m_focus_child; //current focused window c_surface* m_surface; -private: - c_wnd(const c_wnd &win); - c_wnd& operator=(const c_wnd &win); }; -#define GL_BN_CLICKED 0x1111 -#define ON_GL_BN_CLICKED(func) {MSG_TYPE_WND, GL_BN_CLICKED, 0, msgCallback(&func)}, -typedef struct struct_bitmap_info BITMAP_INFO; class c_button : public c_wnd { +public: + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void on_paint() { @@ -1803,6 +1668,7 @@ protected: } virtual void pre_create_wnd() { + on_click = 0; m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS); m_font_type = c_theme::get_font(FONT_DEFAULT); m_font_color = c_theme::get_color(COLOR_WND_FONT); @@ -1819,7 +1685,10 @@ protected: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_BN_CLICKED, 0); + if(on_click) + { + (m_parent->*(on_click))(m_id, 0); + } } } virtual void on_navigate(NAVIGATION_KEY key) @@ -1836,6 +1705,7 @@ protected: } return c_wnd::on_navigate(key); } + WND_CALLBACK on_click; }; class c_surface; class c_dialog; @@ -2006,8 +1876,21 @@ public: } return -1; } + virtual void on_init_children() + { + c_wnd* child = m_top_child; + if (0 != child) + { + while (child) + { + ((c_button*)child)->set_on_click(WND_CALLBACK(&c_keyboard::on_key_clicked)); + child = child->get_next_sibling(); + } + } + } KEYBOARD_STATUS get_cap_status(){return m_cap_status;} char* get_str() { return m_str; } + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void pre_create_wnd() { @@ -2064,7 +1947,7 @@ protected: ASSERT(false); InputChar: m_str[m_str_len++] = id; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_del_clicked(int id, int param) { @@ -2073,7 +1956,7 @@ protected: return; } m_str[--m_str_len] = 0; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_caps_clicked(int id, int param) { @@ -2083,18 +1966,18 @@ protected: void on_enter_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - return notify_parent(KEYBORAD_CLICK, CLICK_ENTER); + (m_parent->*(on_click))(m_id, CLICK_ENTER); } void on_esc_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - notify_parent(KEYBORAD_CLICK, CLICK_ESC); + (m_parent->*(on_click))(m_id, CLICK_ESC); } - GL_DECLARE_MESSAGE_MAP() private: char m_str[32]; int m_str_len; KEYBOARD_STATUS m_cap_status; + WND_CALLBACK on_click; }; class c_keyboard_button : public c_button { @@ -2284,11 +2167,11 @@ protected: break; } } - GL_DECLARE_MESSAGE_MAP() private: void show_keyboard() { s_keyboard.connect(this, IDD_KEY_BOARD, m_kb_style); + s_keyboard.set_on_click(WND_CALLBACK(&c_edit::on_key_board_click)); s_keyboard.show_window(); } void on_touch_down(int x, int y) @@ -2368,12 +2251,12 @@ protected: }; #include #define MAX_ITEM_NUM 4 -#define GL_LIST_CONFIRM 0x1 #define ITEM_HEIGHT 45 -#define ON_LIST_CONFIRM(func) {MSG_TYPE_WND, GL_LIST_CONFIRM, 0, msgCallback(&func)}, class c_list_box : public c_wnd { public: + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } + short get_item_count() { return m_item_total; } int add_item(char* str) { if (m_item_total >= MAX_ITEM_NUM) @@ -2391,7 +2274,6 @@ public: memset(m_item_array, 0, sizeof(m_item_array)); update_list_size(); } - short get_item_count() { return m_item_total; } void select_item(short index) { if (index < 0 || index >= m_item_total) @@ -2546,7 +2428,10 @@ private: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } } } @@ -2569,7 +2454,10 @@ private: m_status = STATUS_FOCUSED; select_item((y - m_list_wnd_rect.m_top) / ITEM_HEIGHT); on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } else { @@ -2582,6 +2470,7 @@ private: char* m_item_array[MAX_ITEM_NUM]; c_rect m_list_wnd_rect; //rect relative to parent wnd. c_rect m_list_screen_rect; //rect relative to physical screen(frame buffer) + WND_CALLBACK on_change; }; #include #define MAX_PAGES 5 @@ -2920,8 +2809,6 @@ inline void c_slide_group::on_touch(int x, int y, TOUCH_ACTION action) } #define ID_BT_ARROW_UP 0x1111 #define ID_BT_ARROW_DOWN 0x2222 -#define GL_SPIN_CHANGE 0x3333 -#define ON_SPIN_CHANGE(func) {MSG_TYPE_WND, GL_SPIN_CHANGE, 0, msgCallback(&func)}, class c_spin_box; class c_spin_button : public c_button { @@ -2942,6 +2829,7 @@ public: short get_step() { return m_step; } void set_value_digit(short digit) { m_digit = digit; } short get_value_digit() { return m_digit; } + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } protected: virtual void on_paint() { @@ -2974,7 +2862,10 @@ protected: return; } m_cur_value += m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } void on_arrow_down_bt_click() @@ -2984,7 +2875,10 @@ protected: return; } m_cur_value -= m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } short m_cur_value; @@ -2995,6 +2889,7 @@ protected: short m_digit; c_spin_button m_bt_up; c_spin_button m_bt_down; + WND_CALLBACK on_change; }; inline void c_spin_button::on_touch(int x, int y, TOUCH_ACTION action) { @@ -3451,12 +3346,6 @@ private: unsigned char m_frame_len_map[64]; unsigned char m_frame_len_map_index; }; -#ifdef GUILITE_ON -GL_MSG_ENTRY c_cmd_target::ms_usr_map_entries[USR_MSG_MAX]; -unsigned short c_cmd_target::ms_user_map_size; -GL_BEGIN_MESSAGE_MAP(c_cmd_target) -GL_END_MESSAGE_MAP() -#endif #ifdef GUILITE_ON @@ -3521,7 +3410,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3542,7 +3432,7 @@ static void* timer_routine(void*) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } usleep(1000 * TIMER_UNIT); @@ -3562,7 +3452,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc)(void* param), void* param) { init_mul_timer(); int i; @@ -3578,6 +3468,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -3641,9 +3532,9 @@ unsigned int get_cur_thread_id() { return (unsigned long)pthread_self(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -4002,7 +3893,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -4023,7 +3915,7 @@ DWORD WINAPI timer_routine(LPVOID lpParam) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } Sleep(TIMER_UNIT); @@ -4043,7 +3935,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc) (void* param), void* param) { init_mul_timer(); int i; @@ -4059,6 +3951,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -4126,9 +4019,9 @@ unsigned int get_cur_thread_id() { return GetCurrentThreadId(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -4305,9 +4198,6 @@ DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX]; #endif #ifdef GUILITE_ON c_keyboard c_edit::s_keyboard; -GL_BEGIN_MESSAGE_MAP(c_edit) -ON_KEYBORAD_UPDATE(c_edit::on_key_board_click) -GL_END_MESSAGE_MAP() #endif #ifdef GUILITE_ON static c_keyboard_button s_key_0, s_key_1, s_key_2, s_key_3, s_key_4, s_key_5, s_key_6, s_key_7, s_key_8, s_key_9; @@ -4375,7 +4265,4 @@ WND_TREE g_number_board_children[] = {&s_key_enter,'\n', 0, POS_X(3), POS_Y(2), KEY_WIDTH, KEY_HEIGHT * 2 + 2}, {0,0,0,0,0,0,0} }; -GL_BEGIN_MESSAGE_MAP(c_keyboard) -ON_GL_BN_CLICKED(c_keyboard::on_key_clicked) -GL_END_MESSAGE_MAP() #endif diff --git a/Hello3Dwave/UIcode/GuiLite.h b/Hello3Dwave/UIcode/GuiLite.h index 4df4afa..e397552 100644 --- a/Hello3Dwave/UIcode/GuiLite.h +++ b/Hello3Dwave/UIcode/GuiLite.h @@ -48,7 +48,7 @@ T_TIME second_to_day(long second); T_TIME get_time(); void start_real_timer(void (*func)(void* arg)); -void register_timer(int milli_second, void func(void* ptmr, void* parg)); +void register_timer(int milli_second, void func(void* param), void* param); unsigned int get_cur_thread_id(); void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg); @@ -102,123 +102,6 @@ public: int m_right; int m_bottom; }; -#define MSG_TYPE_INVALID 0xFFFF -#define MSG_TYPE_WND 0x0001 -#define MSG_TYPE_USR 0x0002 -#define USR_MSG_MAX 32 -class c_cmd_target; -typedef void (c_cmd_target::*msgCallback)(int, int); -struct GL_MSG_ENTRY -{ - unsigned int msgType; - unsigned int msgId; - c_cmd_target* object; - msgCallback callBack; -}; -#define ON_GL_USER_MSG(msgId, func) \ -{MSG_TYPE_USR, msgId, 0, msgCallback(&func)}, -#define GL_DECLARE_MESSAGE_MAP() \ -protected: \ - virtual const GL_MSG_ENTRY* get_msg_entries() const;\ -private: \ - static const GL_MSG_ENTRY m_msg_entries[]; -#define GL_BEGIN_MESSAGE_MAP(theClass) \ -const GL_MSG_ENTRY* theClass::get_msg_entries() const \ -{ \ - return theClass::m_msg_entries; \ -} \ -const GL_MSG_ENTRY theClass::m_msg_entries[] = \ -{ -#define GL_END_MESSAGE_MAP() \ -{MSG_TYPE_INVALID, 0, 0, 0}}; -class c_cmd_target -{ -public: - static int handle_usr_msg(int msg_id, int resource_id, int param) - { - int i; - c_cmd_target* p_wnd = 0; - for (i = 0; i < ms_user_map_size; i++) - { - if (msg_id == ms_usr_map_entries[i].msgId) - { - p_wnd = (c_cmd_target*)ms_usr_map_entries[i].object; - (p_wnd->*ms_usr_map_entries[i].callBack)(resource_id, param); - } - } - return 1; - } -protected: - void load_cmd_msg() - { - const GL_MSG_ENTRY* p_entry = get_msg_entries(); - if (0 == p_entry) - { - return; - } - bool bExist = false; - while (MSG_TYPE_INVALID != p_entry->msgType) - { - if (MSG_TYPE_WND == p_entry->msgType) - { - p_entry++; - continue; - } - bExist = false; - for (int i = 0; i < ms_user_map_size; i++) - { - //repeat register, return. - if (p_entry->msgId == ms_usr_map_entries[i].msgId - && ms_usr_map_entries[i].object == this) - { - bExist = true; - break; - } - } - if (true == bExist) - { - p_entry++; - continue; - } - if (MSG_TYPE_USR == p_entry->msgType) - { - if (USR_MSG_MAX == ms_user_map_size) - { - ASSERT(false); - } - ms_usr_map_entries[ms_user_map_size] = *p_entry; - ms_usr_map_entries[ms_user_map_size].object = this; - ms_user_map_size++; - } - else - { - ASSERT(false); - break; - } - p_entry++; - } - } - const GL_MSG_ENTRY* find_msg_entry(const GL_MSG_ENTRY *pEntry, int msgType, int msgId) - { - if (MSG_TYPE_INVALID == msgType) - { - return 0; - } - while (MSG_TYPE_INVALID != pEntry->msgType) - { - if ((msgType == pEntry->msgType) && (msgId == pEntry->msgId)) - { - return pEntry; - } - pEntry++; - } - return 0; - } -private: - static GL_MSG_ENTRY ms_usr_map_entries[USR_MSG_MAX]; - static unsigned short ms_user_map_size; - GL_DECLARE_MESSAGE_MAP() -}; //BITMAP typedef struct struct_bitmap_info { @@ -1329,9 +1212,9 @@ typedef struct struct_wnd_tree short height; struct struct_wnd_tree* p_child_tree;//sub tree }WND_TREE; -class c_wnd : public c_cmd_target +typedef void (c_wnd::*WND_CALLBACK)(int, int); +class c_wnd { - friend class c_dialog; public: c_wnd() : m_status(STATUS_NORMAL), m_attr((WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS)), m_parent(0), m_top_child(0), m_prev_sibling(0), m_next_sibling(0), m_str(0), m_font_color(0), m_bg_color(0), m_id(0), m_z_order(Z_ORDER_LEVEL_0), m_focus_child(0), m_surface(0) {}; @@ -1370,7 +1253,6 @@ public: } if (load_child_wnd(p_child_tree) >= 0) { - load_cmd_msg(); on_init_children(); } return 0; @@ -1549,19 +1431,6 @@ public: } c_wnd* get_prev_sibling() const { return m_prev_sibling; } c_wnd* get_next_sibling() const { return m_next_sibling; } - void notify_parent(int msg_id, int param) - { - if (!m_parent) - { - return; - } - const GL_MSG_ENTRY* entry = m_parent->find_msg_entry(m_parent->get_msg_entries(), MSG_TYPE_WND, msg_id); - if (0 == entry) - { - return; - } - (m_parent->*(entry->callBack))(m_id, param); - } virtual void on_touch(int x, int y, TOUCH_ACTION action) { x -= m_wnd_rect.m_left; @@ -1733,6 +1602,7 @@ protected: virtual void on_focus() {}; virtual void on_kill_focus() {}; protected: + unsigned short m_id; WND_STATUS m_status; WND_ATTRIBUTION m_attr; c_rect m_wnd_rect; //position relative to parent window. @@ -1740,23 +1610,18 @@ protected: c_wnd* m_top_child; //the first sub window would be navigated c_wnd* m_prev_sibling; //previous brother c_wnd* m_next_sibling; //next brother + c_wnd* m_focus_child; //current focused window const char* m_str; //caption const FONT_INFO* m_font_type; unsigned int m_font_color; unsigned int m_bg_color; - unsigned short m_id; int m_z_order; //the graphic level for rendering - c_wnd* m_focus_child; //current focused window c_surface* m_surface; -private: - c_wnd(const c_wnd &win); - c_wnd& operator=(const c_wnd &win); }; -#define GL_BN_CLICKED 0x1111 -#define ON_GL_BN_CLICKED(func) {MSG_TYPE_WND, GL_BN_CLICKED, 0, msgCallback(&func)}, -typedef struct struct_bitmap_info BITMAP_INFO; class c_button : public c_wnd { +public: + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void on_paint() { @@ -1803,6 +1668,7 @@ protected: } virtual void pre_create_wnd() { + on_click = 0; m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS); m_font_type = c_theme::get_font(FONT_DEFAULT); m_font_color = c_theme::get_color(COLOR_WND_FONT); @@ -1819,7 +1685,10 @@ protected: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_BN_CLICKED, 0); + if(on_click) + { + (m_parent->*(on_click))(m_id, 0); + } } } virtual void on_navigate(NAVIGATION_KEY key) @@ -1836,6 +1705,7 @@ protected: } return c_wnd::on_navigate(key); } + WND_CALLBACK on_click; }; class c_surface; class c_dialog; @@ -2006,8 +1876,21 @@ public: } return -1; } + virtual void on_init_children() + { + c_wnd* child = m_top_child; + if (0 != child) + { + while (child) + { + ((c_button*)child)->set_on_click(WND_CALLBACK(&c_keyboard::on_key_clicked)); + child = child->get_next_sibling(); + } + } + } KEYBOARD_STATUS get_cap_status(){return m_cap_status;} char* get_str() { return m_str; } + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void pre_create_wnd() { @@ -2064,7 +1947,7 @@ protected: ASSERT(false); InputChar: m_str[m_str_len++] = id; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_del_clicked(int id, int param) { @@ -2073,7 +1956,7 @@ protected: return; } m_str[--m_str_len] = 0; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_caps_clicked(int id, int param) { @@ -2083,18 +1966,18 @@ protected: void on_enter_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - return notify_parent(KEYBORAD_CLICK, CLICK_ENTER); + (m_parent->*(on_click))(m_id, CLICK_ENTER); } void on_esc_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - notify_parent(KEYBORAD_CLICK, CLICK_ESC); + (m_parent->*(on_click))(m_id, CLICK_ESC); } - GL_DECLARE_MESSAGE_MAP() private: char m_str[32]; int m_str_len; KEYBOARD_STATUS m_cap_status; + WND_CALLBACK on_click; }; class c_keyboard_button : public c_button { @@ -2284,11 +2167,11 @@ protected: break; } } - GL_DECLARE_MESSAGE_MAP() private: void show_keyboard() { s_keyboard.connect(this, IDD_KEY_BOARD, m_kb_style); + s_keyboard.set_on_click(WND_CALLBACK(&c_edit::on_key_board_click)); s_keyboard.show_window(); } void on_touch_down(int x, int y) @@ -2368,12 +2251,12 @@ protected: }; #include #define MAX_ITEM_NUM 4 -#define GL_LIST_CONFIRM 0x1 #define ITEM_HEIGHT 45 -#define ON_LIST_CONFIRM(func) {MSG_TYPE_WND, GL_LIST_CONFIRM, 0, msgCallback(&func)}, class c_list_box : public c_wnd { public: + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } + short get_item_count() { return m_item_total; } int add_item(char* str) { if (m_item_total >= MAX_ITEM_NUM) @@ -2391,7 +2274,6 @@ public: memset(m_item_array, 0, sizeof(m_item_array)); update_list_size(); } - short get_item_count() { return m_item_total; } void select_item(short index) { if (index < 0 || index >= m_item_total) @@ -2546,7 +2428,10 @@ private: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } } } @@ -2569,7 +2454,10 @@ private: m_status = STATUS_FOCUSED; select_item((y - m_list_wnd_rect.m_top) / ITEM_HEIGHT); on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } else { @@ -2582,6 +2470,7 @@ private: char* m_item_array[MAX_ITEM_NUM]; c_rect m_list_wnd_rect; //rect relative to parent wnd. c_rect m_list_screen_rect; //rect relative to physical screen(frame buffer) + WND_CALLBACK on_change; }; #include #define MAX_PAGES 5 @@ -2920,8 +2809,6 @@ inline void c_slide_group::on_touch(int x, int y, TOUCH_ACTION action) } #define ID_BT_ARROW_UP 0x1111 #define ID_BT_ARROW_DOWN 0x2222 -#define GL_SPIN_CHANGE 0x3333 -#define ON_SPIN_CHANGE(func) {MSG_TYPE_WND, GL_SPIN_CHANGE, 0, msgCallback(&func)}, class c_spin_box; class c_spin_button : public c_button { @@ -2942,6 +2829,7 @@ public: short get_step() { return m_step; } void set_value_digit(short digit) { m_digit = digit; } short get_value_digit() { return m_digit; } + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } protected: virtual void on_paint() { @@ -2974,7 +2862,10 @@ protected: return; } m_cur_value += m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } void on_arrow_down_bt_click() @@ -2984,7 +2875,10 @@ protected: return; } m_cur_value -= m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } short m_cur_value; @@ -2995,6 +2889,7 @@ protected: short m_digit; c_spin_button m_bt_up; c_spin_button m_bt_down; + WND_CALLBACK on_change; }; inline void c_spin_button::on_touch(int x, int y, TOUCH_ACTION action) { @@ -3451,12 +3346,6 @@ private: unsigned char m_frame_len_map[64]; unsigned char m_frame_len_map_index; }; -#ifdef GUILITE_ON -GL_MSG_ENTRY c_cmd_target::ms_usr_map_entries[USR_MSG_MAX]; -unsigned short c_cmd_target::ms_user_map_size; -GL_BEGIN_MESSAGE_MAP(c_cmd_target) -GL_END_MESSAGE_MAP() -#endif #ifdef GUILITE_ON @@ -3521,7 +3410,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3542,7 +3432,7 @@ static void* timer_routine(void*) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } usleep(1000 * TIMER_UNIT); @@ -3562,7 +3452,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc)(void* param), void* param) { init_mul_timer(); int i; @@ -3578,6 +3468,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -3641,9 +3532,9 @@ unsigned int get_cur_thread_id() { return (unsigned long)pthread_self(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -4002,7 +3893,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -4023,7 +3915,7 @@ DWORD WINAPI timer_routine(LPVOID lpParam) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } Sleep(TIMER_UNIT); @@ -4043,7 +3935,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc) (void* param), void* param) { init_mul_timer(); int i; @@ -4059,6 +3951,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -4126,9 +4019,9 @@ unsigned int get_cur_thread_id() { return GetCurrentThreadId(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -4305,9 +4198,6 @@ DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX]; #endif #ifdef GUILITE_ON c_keyboard c_edit::s_keyboard; -GL_BEGIN_MESSAGE_MAP(c_edit) -ON_KEYBORAD_UPDATE(c_edit::on_key_board_click) -GL_END_MESSAGE_MAP() #endif #ifdef GUILITE_ON static c_keyboard_button s_key_0, s_key_1, s_key_2, s_key_3, s_key_4, s_key_5, s_key_6, s_key_7, s_key_8, s_key_9; @@ -4375,7 +4265,4 @@ WND_TREE g_number_board_children[] = {&s_key_enter,'\n', 0, POS_X(3), POS_Y(2), KEY_WIDTH, KEY_HEIGHT * 2 + 2}, {0,0,0,0,0,0,0} }; -GL_BEGIN_MESSAGE_MAP(c_keyboard) -ON_GL_BN_CLICKED(c_keyboard::on_key_clicked) -GL_END_MESSAGE_MAP() #endif diff --git a/HelloAnimation/UIcode/GuiLite.h b/HelloAnimation/UIcode/GuiLite.h index de5a678..e397552 100644 --- a/HelloAnimation/UIcode/GuiLite.h +++ b/HelloAnimation/UIcode/GuiLite.h @@ -48,7 +48,7 @@ T_TIME second_to_day(long second); T_TIME get_time(); void start_real_timer(void (*func)(void* arg)); -void register_timer(int milli_second, void func(void* ptmr, void* parg)); +void register_timer(int milli_second, void func(void* param), void* param); unsigned int get_cur_thread_id(); void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg); @@ -1668,6 +1668,7 @@ protected: } virtual void pre_create_wnd() { + on_click = 0; m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS); m_font_type = c_theme::get_font(FONT_DEFAULT); m_font_color = c_theme::get_color(COLOR_WND_FONT); @@ -1704,7 +1705,7 @@ protected: } return c_wnd::on_navigate(key); } - WND_CALLBACK on_click = 0; + WND_CALLBACK on_click; }; class c_surface; class c_dialog; @@ -3409,7 +3410,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3430,7 +3432,7 @@ static void* timer_routine(void*) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } usleep(1000 * TIMER_UNIT); @@ -3450,7 +3452,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc)(void* param), void* param) { init_mul_timer(); int i; @@ -3466,6 +3468,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -3529,9 +3532,9 @@ unsigned int get_cur_thread_id() { return (unsigned long)pthread_self(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -3890,7 +3893,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3911,7 +3915,7 @@ DWORD WINAPI timer_routine(LPVOID lpParam) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } Sleep(TIMER_UNIT); @@ -3931,7 +3935,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc) (void* param), void* param) { init_mul_timer(); int i; @@ -3947,6 +3951,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -4014,9 +4019,9 @@ unsigned int get_cur_thread_id() { return GetCurrentThreadId(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { diff --git a/HelloCircle/UIcode/GuiLite.h b/HelloCircle/UIcode/GuiLite.h index 4df4afa..e397552 100644 --- a/HelloCircle/UIcode/GuiLite.h +++ b/HelloCircle/UIcode/GuiLite.h @@ -48,7 +48,7 @@ T_TIME second_to_day(long second); T_TIME get_time(); void start_real_timer(void (*func)(void* arg)); -void register_timer(int milli_second, void func(void* ptmr, void* parg)); +void register_timer(int milli_second, void func(void* param), void* param); unsigned int get_cur_thread_id(); void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg); @@ -102,123 +102,6 @@ public: int m_right; int m_bottom; }; -#define MSG_TYPE_INVALID 0xFFFF -#define MSG_TYPE_WND 0x0001 -#define MSG_TYPE_USR 0x0002 -#define USR_MSG_MAX 32 -class c_cmd_target; -typedef void (c_cmd_target::*msgCallback)(int, int); -struct GL_MSG_ENTRY -{ - unsigned int msgType; - unsigned int msgId; - c_cmd_target* object; - msgCallback callBack; -}; -#define ON_GL_USER_MSG(msgId, func) \ -{MSG_TYPE_USR, msgId, 0, msgCallback(&func)}, -#define GL_DECLARE_MESSAGE_MAP() \ -protected: \ - virtual const GL_MSG_ENTRY* get_msg_entries() const;\ -private: \ - static const GL_MSG_ENTRY m_msg_entries[]; -#define GL_BEGIN_MESSAGE_MAP(theClass) \ -const GL_MSG_ENTRY* theClass::get_msg_entries() const \ -{ \ - return theClass::m_msg_entries; \ -} \ -const GL_MSG_ENTRY theClass::m_msg_entries[] = \ -{ -#define GL_END_MESSAGE_MAP() \ -{MSG_TYPE_INVALID, 0, 0, 0}}; -class c_cmd_target -{ -public: - static int handle_usr_msg(int msg_id, int resource_id, int param) - { - int i; - c_cmd_target* p_wnd = 0; - for (i = 0; i < ms_user_map_size; i++) - { - if (msg_id == ms_usr_map_entries[i].msgId) - { - p_wnd = (c_cmd_target*)ms_usr_map_entries[i].object; - (p_wnd->*ms_usr_map_entries[i].callBack)(resource_id, param); - } - } - return 1; - } -protected: - void load_cmd_msg() - { - const GL_MSG_ENTRY* p_entry = get_msg_entries(); - if (0 == p_entry) - { - return; - } - bool bExist = false; - while (MSG_TYPE_INVALID != p_entry->msgType) - { - if (MSG_TYPE_WND == p_entry->msgType) - { - p_entry++; - continue; - } - bExist = false; - for (int i = 0; i < ms_user_map_size; i++) - { - //repeat register, return. - if (p_entry->msgId == ms_usr_map_entries[i].msgId - && ms_usr_map_entries[i].object == this) - { - bExist = true; - break; - } - } - if (true == bExist) - { - p_entry++; - continue; - } - if (MSG_TYPE_USR == p_entry->msgType) - { - if (USR_MSG_MAX == ms_user_map_size) - { - ASSERT(false); - } - ms_usr_map_entries[ms_user_map_size] = *p_entry; - ms_usr_map_entries[ms_user_map_size].object = this; - ms_user_map_size++; - } - else - { - ASSERT(false); - break; - } - p_entry++; - } - } - const GL_MSG_ENTRY* find_msg_entry(const GL_MSG_ENTRY *pEntry, int msgType, int msgId) - { - if (MSG_TYPE_INVALID == msgType) - { - return 0; - } - while (MSG_TYPE_INVALID != pEntry->msgType) - { - if ((msgType == pEntry->msgType) && (msgId == pEntry->msgId)) - { - return pEntry; - } - pEntry++; - } - return 0; - } -private: - static GL_MSG_ENTRY ms_usr_map_entries[USR_MSG_MAX]; - static unsigned short ms_user_map_size; - GL_DECLARE_MESSAGE_MAP() -}; //BITMAP typedef struct struct_bitmap_info { @@ -1329,9 +1212,9 @@ typedef struct struct_wnd_tree short height; struct struct_wnd_tree* p_child_tree;//sub tree }WND_TREE; -class c_wnd : public c_cmd_target +typedef void (c_wnd::*WND_CALLBACK)(int, int); +class c_wnd { - friend class c_dialog; public: c_wnd() : m_status(STATUS_NORMAL), m_attr((WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS)), m_parent(0), m_top_child(0), m_prev_sibling(0), m_next_sibling(0), m_str(0), m_font_color(0), m_bg_color(0), m_id(0), m_z_order(Z_ORDER_LEVEL_0), m_focus_child(0), m_surface(0) {}; @@ -1370,7 +1253,6 @@ public: } if (load_child_wnd(p_child_tree) >= 0) { - load_cmd_msg(); on_init_children(); } return 0; @@ -1549,19 +1431,6 @@ public: } c_wnd* get_prev_sibling() const { return m_prev_sibling; } c_wnd* get_next_sibling() const { return m_next_sibling; } - void notify_parent(int msg_id, int param) - { - if (!m_parent) - { - return; - } - const GL_MSG_ENTRY* entry = m_parent->find_msg_entry(m_parent->get_msg_entries(), MSG_TYPE_WND, msg_id); - if (0 == entry) - { - return; - } - (m_parent->*(entry->callBack))(m_id, param); - } virtual void on_touch(int x, int y, TOUCH_ACTION action) { x -= m_wnd_rect.m_left; @@ -1733,6 +1602,7 @@ protected: virtual void on_focus() {}; virtual void on_kill_focus() {}; protected: + unsigned short m_id; WND_STATUS m_status; WND_ATTRIBUTION m_attr; c_rect m_wnd_rect; //position relative to parent window. @@ -1740,23 +1610,18 @@ protected: c_wnd* m_top_child; //the first sub window would be navigated c_wnd* m_prev_sibling; //previous brother c_wnd* m_next_sibling; //next brother + c_wnd* m_focus_child; //current focused window const char* m_str; //caption const FONT_INFO* m_font_type; unsigned int m_font_color; unsigned int m_bg_color; - unsigned short m_id; int m_z_order; //the graphic level for rendering - c_wnd* m_focus_child; //current focused window c_surface* m_surface; -private: - c_wnd(const c_wnd &win); - c_wnd& operator=(const c_wnd &win); }; -#define GL_BN_CLICKED 0x1111 -#define ON_GL_BN_CLICKED(func) {MSG_TYPE_WND, GL_BN_CLICKED, 0, msgCallback(&func)}, -typedef struct struct_bitmap_info BITMAP_INFO; class c_button : public c_wnd { +public: + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void on_paint() { @@ -1803,6 +1668,7 @@ protected: } virtual void pre_create_wnd() { + on_click = 0; m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS); m_font_type = c_theme::get_font(FONT_DEFAULT); m_font_color = c_theme::get_color(COLOR_WND_FONT); @@ -1819,7 +1685,10 @@ protected: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_BN_CLICKED, 0); + if(on_click) + { + (m_parent->*(on_click))(m_id, 0); + } } } virtual void on_navigate(NAVIGATION_KEY key) @@ -1836,6 +1705,7 @@ protected: } return c_wnd::on_navigate(key); } + WND_CALLBACK on_click; }; class c_surface; class c_dialog; @@ -2006,8 +1876,21 @@ public: } return -1; } + virtual void on_init_children() + { + c_wnd* child = m_top_child; + if (0 != child) + { + while (child) + { + ((c_button*)child)->set_on_click(WND_CALLBACK(&c_keyboard::on_key_clicked)); + child = child->get_next_sibling(); + } + } + } KEYBOARD_STATUS get_cap_status(){return m_cap_status;} char* get_str() { return m_str; } + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void pre_create_wnd() { @@ -2064,7 +1947,7 @@ protected: ASSERT(false); InputChar: m_str[m_str_len++] = id; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_del_clicked(int id, int param) { @@ -2073,7 +1956,7 @@ protected: return; } m_str[--m_str_len] = 0; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_caps_clicked(int id, int param) { @@ -2083,18 +1966,18 @@ protected: void on_enter_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - return notify_parent(KEYBORAD_CLICK, CLICK_ENTER); + (m_parent->*(on_click))(m_id, CLICK_ENTER); } void on_esc_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - notify_parent(KEYBORAD_CLICK, CLICK_ESC); + (m_parent->*(on_click))(m_id, CLICK_ESC); } - GL_DECLARE_MESSAGE_MAP() private: char m_str[32]; int m_str_len; KEYBOARD_STATUS m_cap_status; + WND_CALLBACK on_click; }; class c_keyboard_button : public c_button { @@ -2284,11 +2167,11 @@ protected: break; } } - GL_DECLARE_MESSAGE_MAP() private: void show_keyboard() { s_keyboard.connect(this, IDD_KEY_BOARD, m_kb_style); + s_keyboard.set_on_click(WND_CALLBACK(&c_edit::on_key_board_click)); s_keyboard.show_window(); } void on_touch_down(int x, int y) @@ -2368,12 +2251,12 @@ protected: }; #include #define MAX_ITEM_NUM 4 -#define GL_LIST_CONFIRM 0x1 #define ITEM_HEIGHT 45 -#define ON_LIST_CONFIRM(func) {MSG_TYPE_WND, GL_LIST_CONFIRM, 0, msgCallback(&func)}, class c_list_box : public c_wnd { public: + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } + short get_item_count() { return m_item_total; } int add_item(char* str) { if (m_item_total >= MAX_ITEM_NUM) @@ -2391,7 +2274,6 @@ public: memset(m_item_array, 0, sizeof(m_item_array)); update_list_size(); } - short get_item_count() { return m_item_total; } void select_item(short index) { if (index < 0 || index >= m_item_total) @@ -2546,7 +2428,10 @@ private: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } } } @@ -2569,7 +2454,10 @@ private: m_status = STATUS_FOCUSED; select_item((y - m_list_wnd_rect.m_top) / ITEM_HEIGHT); on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } else { @@ -2582,6 +2470,7 @@ private: char* m_item_array[MAX_ITEM_NUM]; c_rect m_list_wnd_rect; //rect relative to parent wnd. c_rect m_list_screen_rect; //rect relative to physical screen(frame buffer) + WND_CALLBACK on_change; }; #include #define MAX_PAGES 5 @@ -2920,8 +2809,6 @@ inline void c_slide_group::on_touch(int x, int y, TOUCH_ACTION action) } #define ID_BT_ARROW_UP 0x1111 #define ID_BT_ARROW_DOWN 0x2222 -#define GL_SPIN_CHANGE 0x3333 -#define ON_SPIN_CHANGE(func) {MSG_TYPE_WND, GL_SPIN_CHANGE, 0, msgCallback(&func)}, class c_spin_box; class c_spin_button : public c_button { @@ -2942,6 +2829,7 @@ public: short get_step() { return m_step; } void set_value_digit(short digit) { m_digit = digit; } short get_value_digit() { return m_digit; } + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } protected: virtual void on_paint() { @@ -2974,7 +2862,10 @@ protected: return; } m_cur_value += m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } void on_arrow_down_bt_click() @@ -2984,7 +2875,10 @@ protected: return; } m_cur_value -= m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } short m_cur_value; @@ -2995,6 +2889,7 @@ protected: short m_digit; c_spin_button m_bt_up; c_spin_button m_bt_down; + WND_CALLBACK on_change; }; inline void c_spin_button::on_touch(int x, int y, TOUCH_ACTION action) { @@ -3451,12 +3346,6 @@ private: unsigned char m_frame_len_map[64]; unsigned char m_frame_len_map_index; }; -#ifdef GUILITE_ON -GL_MSG_ENTRY c_cmd_target::ms_usr_map_entries[USR_MSG_MAX]; -unsigned short c_cmd_target::ms_user_map_size; -GL_BEGIN_MESSAGE_MAP(c_cmd_target) -GL_END_MESSAGE_MAP() -#endif #ifdef GUILITE_ON @@ -3521,7 +3410,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3542,7 +3432,7 @@ static void* timer_routine(void*) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } usleep(1000 * TIMER_UNIT); @@ -3562,7 +3452,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc)(void* param), void* param) { init_mul_timer(); int i; @@ -3578,6 +3468,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -3641,9 +3532,9 @@ unsigned int get_cur_thread_id() { return (unsigned long)pthread_self(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -4002,7 +3893,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -4023,7 +3915,7 @@ DWORD WINAPI timer_routine(LPVOID lpParam) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } Sleep(TIMER_UNIT); @@ -4043,7 +3935,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc) (void* param), void* param) { init_mul_timer(); int i; @@ -4059,6 +3951,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -4126,9 +4019,9 @@ unsigned int get_cur_thread_id() { return GetCurrentThreadId(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -4305,9 +4198,6 @@ DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX]; #endif #ifdef GUILITE_ON c_keyboard c_edit::s_keyboard; -GL_BEGIN_MESSAGE_MAP(c_edit) -ON_KEYBORAD_UPDATE(c_edit::on_key_board_click) -GL_END_MESSAGE_MAP() #endif #ifdef GUILITE_ON static c_keyboard_button s_key_0, s_key_1, s_key_2, s_key_3, s_key_4, s_key_5, s_key_6, s_key_7, s_key_8, s_key_9; @@ -4375,7 +4265,4 @@ WND_TREE g_number_board_children[] = {&s_key_enter,'\n', 0, POS_X(3), POS_Y(2), KEY_WIDTH, KEY_HEIGHT * 2 + 2}, {0,0,0,0,0,0,0} }; -GL_BEGIN_MESSAGE_MAP(c_keyboard) -ON_GL_BN_CLICKED(c_keyboard::on_key_clicked) -GL_END_MESSAGE_MAP() #endif diff --git a/HelloFFmpeg/UIcode/GuiLite.h b/HelloFFmpeg/UIcode/GuiLite.h index 4df4afa..e397552 100644 --- a/HelloFFmpeg/UIcode/GuiLite.h +++ b/HelloFFmpeg/UIcode/GuiLite.h @@ -48,7 +48,7 @@ T_TIME second_to_day(long second); T_TIME get_time(); void start_real_timer(void (*func)(void* arg)); -void register_timer(int milli_second, void func(void* ptmr, void* parg)); +void register_timer(int milli_second, void func(void* param), void* param); unsigned int get_cur_thread_id(); void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg); @@ -102,123 +102,6 @@ public: int m_right; int m_bottom; }; -#define MSG_TYPE_INVALID 0xFFFF -#define MSG_TYPE_WND 0x0001 -#define MSG_TYPE_USR 0x0002 -#define USR_MSG_MAX 32 -class c_cmd_target; -typedef void (c_cmd_target::*msgCallback)(int, int); -struct GL_MSG_ENTRY -{ - unsigned int msgType; - unsigned int msgId; - c_cmd_target* object; - msgCallback callBack; -}; -#define ON_GL_USER_MSG(msgId, func) \ -{MSG_TYPE_USR, msgId, 0, msgCallback(&func)}, -#define GL_DECLARE_MESSAGE_MAP() \ -protected: \ - virtual const GL_MSG_ENTRY* get_msg_entries() const;\ -private: \ - static const GL_MSG_ENTRY m_msg_entries[]; -#define GL_BEGIN_MESSAGE_MAP(theClass) \ -const GL_MSG_ENTRY* theClass::get_msg_entries() const \ -{ \ - return theClass::m_msg_entries; \ -} \ -const GL_MSG_ENTRY theClass::m_msg_entries[] = \ -{ -#define GL_END_MESSAGE_MAP() \ -{MSG_TYPE_INVALID, 0, 0, 0}}; -class c_cmd_target -{ -public: - static int handle_usr_msg(int msg_id, int resource_id, int param) - { - int i; - c_cmd_target* p_wnd = 0; - for (i = 0; i < ms_user_map_size; i++) - { - if (msg_id == ms_usr_map_entries[i].msgId) - { - p_wnd = (c_cmd_target*)ms_usr_map_entries[i].object; - (p_wnd->*ms_usr_map_entries[i].callBack)(resource_id, param); - } - } - return 1; - } -protected: - void load_cmd_msg() - { - const GL_MSG_ENTRY* p_entry = get_msg_entries(); - if (0 == p_entry) - { - return; - } - bool bExist = false; - while (MSG_TYPE_INVALID != p_entry->msgType) - { - if (MSG_TYPE_WND == p_entry->msgType) - { - p_entry++; - continue; - } - bExist = false; - for (int i = 0; i < ms_user_map_size; i++) - { - //repeat register, return. - if (p_entry->msgId == ms_usr_map_entries[i].msgId - && ms_usr_map_entries[i].object == this) - { - bExist = true; - break; - } - } - if (true == bExist) - { - p_entry++; - continue; - } - if (MSG_TYPE_USR == p_entry->msgType) - { - if (USR_MSG_MAX == ms_user_map_size) - { - ASSERT(false); - } - ms_usr_map_entries[ms_user_map_size] = *p_entry; - ms_usr_map_entries[ms_user_map_size].object = this; - ms_user_map_size++; - } - else - { - ASSERT(false); - break; - } - p_entry++; - } - } - const GL_MSG_ENTRY* find_msg_entry(const GL_MSG_ENTRY *pEntry, int msgType, int msgId) - { - if (MSG_TYPE_INVALID == msgType) - { - return 0; - } - while (MSG_TYPE_INVALID != pEntry->msgType) - { - if ((msgType == pEntry->msgType) && (msgId == pEntry->msgId)) - { - return pEntry; - } - pEntry++; - } - return 0; - } -private: - static GL_MSG_ENTRY ms_usr_map_entries[USR_MSG_MAX]; - static unsigned short ms_user_map_size; - GL_DECLARE_MESSAGE_MAP() -}; //BITMAP typedef struct struct_bitmap_info { @@ -1329,9 +1212,9 @@ typedef struct struct_wnd_tree short height; struct struct_wnd_tree* p_child_tree;//sub tree }WND_TREE; -class c_wnd : public c_cmd_target +typedef void (c_wnd::*WND_CALLBACK)(int, int); +class c_wnd { - friend class c_dialog; public: c_wnd() : m_status(STATUS_NORMAL), m_attr((WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS)), m_parent(0), m_top_child(0), m_prev_sibling(0), m_next_sibling(0), m_str(0), m_font_color(0), m_bg_color(0), m_id(0), m_z_order(Z_ORDER_LEVEL_0), m_focus_child(0), m_surface(0) {}; @@ -1370,7 +1253,6 @@ public: } if (load_child_wnd(p_child_tree) >= 0) { - load_cmd_msg(); on_init_children(); } return 0; @@ -1549,19 +1431,6 @@ public: } c_wnd* get_prev_sibling() const { return m_prev_sibling; } c_wnd* get_next_sibling() const { return m_next_sibling; } - void notify_parent(int msg_id, int param) - { - if (!m_parent) - { - return; - } - const GL_MSG_ENTRY* entry = m_parent->find_msg_entry(m_parent->get_msg_entries(), MSG_TYPE_WND, msg_id); - if (0 == entry) - { - return; - } - (m_parent->*(entry->callBack))(m_id, param); - } virtual void on_touch(int x, int y, TOUCH_ACTION action) { x -= m_wnd_rect.m_left; @@ -1733,6 +1602,7 @@ protected: virtual void on_focus() {}; virtual void on_kill_focus() {}; protected: + unsigned short m_id; WND_STATUS m_status; WND_ATTRIBUTION m_attr; c_rect m_wnd_rect; //position relative to parent window. @@ -1740,23 +1610,18 @@ protected: c_wnd* m_top_child; //the first sub window would be navigated c_wnd* m_prev_sibling; //previous brother c_wnd* m_next_sibling; //next brother + c_wnd* m_focus_child; //current focused window const char* m_str; //caption const FONT_INFO* m_font_type; unsigned int m_font_color; unsigned int m_bg_color; - unsigned short m_id; int m_z_order; //the graphic level for rendering - c_wnd* m_focus_child; //current focused window c_surface* m_surface; -private: - c_wnd(const c_wnd &win); - c_wnd& operator=(const c_wnd &win); }; -#define GL_BN_CLICKED 0x1111 -#define ON_GL_BN_CLICKED(func) {MSG_TYPE_WND, GL_BN_CLICKED, 0, msgCallback(&func)}, -typedef struct struct_bitmap_info BITMAP_INFO; class c_button : public c_wnd { +public: + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void on_paint() { @@ -1803,6 +1668,7 @@ protected: } virtual void pre_create_wnd() { + on_click = 0; m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS); m_font_type = c_theme::get_font(FONT_DEFAULT); m_font_color = c_theme::get_color(COLOR_WND_FONT); @@ -1819,7 +1685,10 @@ protected: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_BN_CLICKED, 0); + if(on_click) + { + (m_parent->*(on_click))(m_id, 0); + } } } virtual void on_navigate(NAVIGATION_KEY key) @@ -1836,6 +1705,7 @@ protected: } return c_wnd::on_navigate(key); } + WND_CALLBACK on_click; }; class c_surface; class c_dialog; @@ -2006,8 +1876,21 @@ public: } return -1; } + virtual void on_init_children() + { + c_wnd* child = m_top_child; + if (0 != child) + { + while (child) + { + ((c_button*)child)->set_on_click(WND_CALLBACK(&c_keyboard::on_key_clicked)); + child = child->get_next_sibling(); + } + } + } KEYBOARD_STATUS get_cap_status(){return m_cap_status;} char* get_str() { return m_str; } + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void pre_create_wnd() { @@ -2064,7 +1947,7 @@ protected: ASSERT(false); InputChar: m_str[m_str_len++] = id; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_del_clicked(int id, int param) { @@ -2073,7 +1956,7 @@ protected: return; } m_str[--m_str_len] = 0; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_caps_clicked(int id, int param) { @@ -2083,18 +1966,18 @@ protected: void on_enter_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - return notify_parent(KEYBORAD_CLICK, CLICK_ENTER); + (m_parent->*(on_click))(m_id, CLICK_ENTER); } void on_esc_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - notify_parent(KEYBORAD_CLICK, CLICK_ESC); + (m_parent->*(on_click))(m_id, CLICK_ESC); } - GL_DECLARE_MESSAGE_MAP() private: char m_str[32]; int m_str_len; KEYBOARD_STATUS m_cap_status; + WND_CALLBACK on_click; }; class c_keyboard_button : public c_button { @@ -2284,11 +2167,11 @@ protected: break; } } - GL_DECLARE_MESSAGE_MAP() private: void show_keyboard() { s_keyboard.connect(this, IDD_KEY_BOARD, m_kb_style); + s_keyboard.set_on_click(WND_CALLBACK(&c_edit::on_key_board_click)); s_keyboard.show_window(); } void on_touch_down(int x, int y) @@ -2368,12 +2251,12 @@ protected: }; #include #define MAX_ITEM_NUM 4 -#define GL_LIST_CONFIRM 0x1 #define ITEM_HEIGHT 45 -#define ON_LIST_CONFIRM(func) {MSG_TYPE_WND, GL_LIST_CONFIRM, 0, msgCallback(&func)}, class c_list_box : public c_wnd { public: + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } + short get_item_count() { return m_item_total; } int add_item(char* str) { if (m_item_total >= MAX_ITEM_NUM) @@ -2391,7 +2274,6 @@ public: memset(m_item_array, 0, sizeof(m_item_array)); update_list_size(); } - short get_item_count() { return m_item_total; } void select_item(short index) { if (index < 0 || index >= m_item_total) @@ -2546,7 +2428,10 @@ private: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } } } @@ -2569,7 +2454,10 @@ private: m_status = STATUS_FOCUSED; select_item((y - m_list_wnd_rect.m_top) / ITEM_HEIGHT); on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } else { @@ -2582,6 +2470,7 @@ private: char* m_item_array[MAX_ITEM_NUM]; c_rect m_list_wnd_rect; //rect relative to parent wnd. c_rect m_list_screen_rect; //rect relative to physical screen(frame buffer) + WND_CALLBACK on_change; }; #include #define MAX_PAGES 5 @@ -2920,8 +2809,6 @@ inline void c_slide_group::on_touch(int x, int y, TOUCH_ACTION action) } #define ID_BT_ARROW_UP 0x1111 #define ID_BT_ARROW_DOWN 0x2222 -#define GL_SPIN_CHANGE 0x3333 -#define ON_SPIN_CHANGE(func) {MSG_TYPE_WND, GL_SPIN_CHANGE, 0, msgCallback(&func)}, class c_spin_box; class c_spin_button : public c_button { @@ -2942,6 +2829,7 @@ public: short get_step() { return m_step; } void set_value_digit(short digit) { m_digit = digit; } short get_value_digit() { return m_digit; } + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } protected: virtual void on_paint() { @@ -2974,7 +2862,10 @@ protected: return; } m_cur_value += m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } void on_arrow_down_bt_click() @@ -2984,7 +2875,10 @@ protected: return; } m_cur_value -= m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } short m_cur_value; @@ -2995,6 +2889,7 @@ protected: short m_digit; c_spin_button m_bt_up; c_spin_button m_bt_down; + WND_CALLBACK on_change; }; inline void c_spin_button::on_touch(int x, int y, TOUCH_ACTION action) { @@ -3451,12 +3346,6 @@ private: unsigned char m_frame_len_map[64]; unsigned char m_frame_len_map_index; }; -#ifdef GUILITE_ON -GL_MSG_ENTRY c_cmd_target::ms_usr_map_entries[USR_MSG_MAX]; -unsigned short c_cmd_target::ms_user_map_size; -GL_BEGIN_MESSAGE_MAP(c_cmd_target) -GL_END_MESSAGE_MAP() -#endif #ifdef GUILITE_ON @@ -3521,7 +3410,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3542,7 +3432,7 @@ static void* timer_routine(void*) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } usleep(1000 * TIMER_UNIT); @@ -3562,7 +3452,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc)(void* param), void* param) { init_mul_timer(); int i; @@ -3578,6 +3468,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -3641,9 +3532,9 @@ unsigned int get_cur_thread_id() { return (unsigned long)pthread_self(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -4002,7 +3893,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -4023,7 +3915,7 @@ DWORD WINAPI timer_routine(LPVOID lpParam) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } Sleep(TIMER_UNIT); @@ -4043,7 +3935,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc) (void* param), void* param) { init_mul_timer(); int i; @@ -4059,6 +3951,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -4126,9 +4019,9 @@ unsigned int get_cur_thread_id() { return GetCurrentThreadId(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -4305,9 +4198,6 @@ DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX]; #endif #ifdef GUILITE_ON c_keyboard c_edit::s_keyboard; -GL_BEGIN_MESSAGE_MAP(c_edit) -ON_KEYBORAD_UPDATE(c_edit::on_key_board_click) -GL_END_MESSAGE_MAP() #endif #ifdef GUILITE_ON static c_keyboard_button s_key_0, s_key_1, s_key_2, s_key_3, s_key_4, s_key_5, s_key_6, s_key_7, s_key_8, s_key_9; @@ -4375,7 +4265,4 @@ WND_TREE g_number_board_children[] = {&s_key_enter,'\n', 0, POS_X(3), POS_Y(2), KEY_WIDTH, KEY_HEIGHT * 2 + 2}, {0,0,0,0,0,0,0} }; -GL_BEGIN_MESSAGE_MAP(c_keyboard) -ON_GL_BN_CLICKED(c_keyboard::on_key_clicked) -GL_END_MESSAGE_MAP() #endif diff --git a/HelloFont/UIcode/GuiLite.h b/HelloFont/UIcode/GuiLite.h index de5a678..e397552 100644 --- a/HelloFont/UIcode/GuiLite.h +++ b/HelloFont/UIcode/GuiLite.h @@ -48,7 +48,7 @@ T_TIME second_to_day(long second); T_TIME get_time(); void start_real_timer(void (*func)(void* arg)); -void register_timer(int milli_second, void func(void* ptmr, void* parg)); +void register_timer(int milli_second, void func(void* param), void* param); unsigned int get_cur_thread_id(); void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg); @@ -1668,6 +1668,7 @@ protected: } virtual void pre_create_wnd() { + on_click = 0; m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS); m_font_type = c_theme::get_font(FONT_DEFAULT); m_font_color = c_theme::get_color(COLOR_WND_FONT); @@ -1704,7 +1705,7 @@ protected: } return c_wnd::on_navigate(key); } - WND_CALLBACK on_click = 0; + WND_CALLBACK on_click; }; class c_surface; class c_dialog; @@ -3409,7 +3410,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3430,7 +3432,7 @@ static void* timer_routine(void*) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } usleep(1000 * TIMER_UNIT); @@ -3450,7 +3452,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc)(void* param), void* param) { init_mul_timer(); int i; @@ -3466,6 +3468,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -3529,9 +3532,9 @@ unsigned int get_cur_thread_id() { return (unsigned long)pthread_self(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -3890,7 +3893,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3911,7 +3915,7 @@ DWORD WINAPI timer_routine(LPVOID lpParam) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } Sleep(TIMER_UNIT); @@ -3931,7 +3935,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc) (void* param), void* param) { init_mul_timer(); int i; @@ -3947,6 +3951,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -4014,9 +4019,9 @@ unsigned int get_cur_thread_id() { return GetCurrentThreadId(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { diff --git a/HelloGuiLite/UIcode/GuiLite.h b/HelloGuiLite/UIcode/GuiLite.h index de5a678..e397552 100644 --- a/HelloGuiLite/UIcode/GuiLite.h +++ b/HelloGuiLite/UIcode/GuiLite.h @@ -48,7 +48,7 @@ T_TIME second_to_day(long second); T_TIME get_time(); void start_real_timer(void (*func)(void* arg)); -void register_timer(int milli_second, void func(void* ptmr, void* parg)); +void register_timer(int milli_second, void func(void* param), void* param); unsigned int get_cur_thread_id(); void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg); @@ -1668,6 +1668,7 @@ protected: } virtual void pre_create_wnd() { + on_click = 0; m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS); m_font_type = c_theme::get_font(FONT_DEFAULT); m_font_color = c_theme::get_color(COLOR_WND_FONT); @@ -1704,7 +1705,7 @@ protected: } return c_wnd::on_navigate(key); } - WND_CALLBACK on_click = 0; + WND_CALLBACK on_click; }; class c_surface; class c_dialog; @@ -3409,7 +3410,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3430,7 +3432,7 @@ static void* timer_routine(void*) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } usleep(1000 * TIMER_UNIT); @@ -3450,7 +3452,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc)(void* param), void* param) { init_mul_timer(); int i; @@ -3466,6 +3468,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -3529,9 +3532,9 @@ unsigned int get_cur_thread_id() { return (unsigned long)pthread_self(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -3890,7 +3893,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3911,7 +3915,7 @@ DWORD WINAPI timer_routine(LPVOID lpParam) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } Sleep(TIMER_UNIT); @@ -3931,7 +3935,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc) (void* param), void* param) { init_mul_timer(); int i; @@ -3947,6 +3951,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -4014,9 +4019,9 @@ unsigned int get_cur_thread_id() { return GetCurrentThreadId(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { diff --git a/HelloLayers/UIcode/GuiLite.h b/HelloLayers/UIcode/GuiLite.h index 4df4afa..e397552 100644 --- a/HelloLayers/UIcode/GuiLite.h +++ b/HelloLayers/UIcode/GuiLite.h @@ -48,7 +48,7 @@ T_TIME second_to_day(long second); T_TIME get_time(); void start_real_timer(void (*func)(void* arg)); -void register_timer(int milli_second, void func(void* ptmr, void* parg)); +void register_timer(int milli_second, void func(void* param), void* param); unsigned int get_cur_thread_id(); void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg); @@ -102,123 +102,6 @@ public: int m_right; int m_bottom; }; -#define MSG_TYPE_INVALID 0xFFFF -#define MSG_TYPE_WND 0x0001 -#define MSG_TYPE_USR 0x0002 -#define USR_MSG_MAX 32 -class c_cmd_target; -typedef void (c_cmd_target::*msgCallback)(int, int); -struct GL_MSG_ENTRY -{ - unsigned int msgType; - unsigned int msgId; - c_cmd_target* object; - msgCallback callBack; -}; -#define ON_GL_USER_MSG(msgId, func) \ -{MSG_TYPE_USR, msgId, 0, msgCallback(&func)}, -#define GL_DECLARE_MESSAGE_MAP() \ -protected: \ - virtual const GL_MSG_ENTRY* get_msg_entries() const;\ -private: \ - static const GL_MSG_ENTRY m_msg_entries[]; -#define GL_BEGIN_MESSAGE_MAP(theClass) \ -const GL_MSG_ENTRY* theClass::get_msg_entries() const \ -{ \ - return theClass::m_msg_entries; \ -} \ -const GL_MSG_ENTRY theClass::m_msg_entries[] = \ -{ -#define GL_END_MESSAGE_MAP() \ -{MSG_TYPE_INVALID, 0, 0, 0}}; -class c_cmd_target -{ -public: - static int handle_usr_msg(int msg_id, int resource_id, int param) - { - int i; - c_cmd_target* p_wnd = 0; - for (i = 0; i < ms_user_map_size; i++) - { - if (msg_id == ms_usr_map_entries[i].msgId) - { - p_wnd = (c_cmd_target*)ms_usr_map_entries[i].object; - (p_wnd->*ms_usr_map_entries[i].callBack)(resource_id, param); - } - } - return 1; - } -protected: - void load_cmd_msg() - { - const GL_MSG_ENTRY* p_entry = get_msg_entries(); - if (0 == p_entry) - { - return; - } - bool bExist = false; - while (MSG_TYPE_INVALID != p_entry->msgType) - { - if (MSG_TYPE_WND == p_entry->msgType) - { - p_entry++; - continue; - } - bExist = false; - for (int i = 0; i < ms_user_map_size; i++) - { - //repeat register, return. - if (p_entry->msgId == ms_usr_map_entries[i].msgId - && ms_usr_map_entries[i].object == this) - { - bExist = true; - break; - } - } - if (true == bExist) - { - p_entry++; - continue; - } - if (MSG_TYPE_USR == p_entry->msgType) - { - if (USR_MSG_MAX == ms_user_map_size) - { - ASSERT(false); - } - ms_usr_map_entries[ms_user_map_size] = *p_entry; - ms_usr_map_entries[ms_user_map_size].object = this; - ms_user_map_size++; - } - else - { - ASSERT(false); - break; - } - p_entry++; - } - } - const GL_MSG_ENTRY* find_msg_entry(const GL_MSG_ENTRY *pEntry, int msgType, int msgId) - { - if (MSG_TYPE_INVALID == msgType) - { - return 0; - } - while (MSG_TYPE_INVALID != pEntry->msgType) - { - if ((msgType == pEntry->msgType) && (msgId == pEntry->msgId)) - { - return pEntry; - } - pEntry++; - } - return 0; - } -private: - static GL_MSG_ENTRY ms_usr_map_entries[USR_MSG_MAX]; - static unsigned short ms_user_map_size; - GL_DECLARE_MESSAGE_MAP() -}; //BITMAP typedef struct struct_bitmap_info { @@ -1329,9 +1212,9 @@ typedef struct struct_wnd_tree short height; struct struct_wnd_tree* p_child_tree;//sub tree }WND_TREE; -class c_wnd : public c_cmd_target +typedef void (c_wnd::*WND_CALLBACK)(int, int); +class c_wnd { - friend class c_dialog; public: c_wnd() : m_status(STATUS_NORMAL), m_attr((WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS)), m_parent(0), m_top_child(0), m_prev_sibling(0), m_next_sibling(0), m_str(0), m_font_color(0), m_bg_color(0), m_id(0), m_z_order(Z_ORDER_LEVEL_0), m_focus_child(0), m_surface(0) {}; @@ -1370,7 +1253,6 @@ public: } if (load_child_wnd(p_child_tree) >= 0) { - load_cmd_msg(); on_init_children(); } return 0; @@ -1549,19 +1431,6 @@ public: } c_wnd* get_prev_sibling() const { return m_prev_sibling; } c_wnd* get_next_sibling() const { return m_next_sibling; } - void notify_parent(int msg_id, int param) - { - if (!m_parent) - { - return; - } - const GL_MSG_ENTRY* entry = m_parent->find_msg_entry(m_parent->get_msg_entries(), MSG_TYPE_WND, msg_id); - if (0 == entry) - { - return; - } - (m_parent->*(entry->callBack))(m_id, param); - } virtual void on_touch(int x, int y, TOUCH_ACTION action) { x -= m_wnd_rect.m_left; @@ -1733,6 +1602,7 @@ protected: virtual void on_focus() {}; virtual void on_kill_focus() {}; protected: + unsigned short m_id; WND_STATUS m_status; WND_ATTRIBUTION m_attr; c_rect m_wnd_rect; //position relative to parent window. @@ -1740,23 +1610,18 @@ protected: c_wnd* m_top_child; //the first sub window would be navigated c_wnd* m_prev_sibling; //previous brother c_wnd* m_next_sibling; //next brother + c_wnd* m_focus_child; //current focused window const char* m_str; //caption const FONT_INFO* m_font_type; unsigned int m_font_color; unsigned int m_bg_color; - unsigned short m_id; int m_z_order; //the graphic level for rendering - c_wnd* m_focus_child; //current focused window c_surface* m_surface; -private: - c_wnd(const c_wnd &win); - c_wnd& operator=(const c_wnd &win); }; -#define GL_BN_CLICKED 0x1111 -#define ON_GL_BN_CLICKED(func) {MSG_TYPE_WND, GL_BN_CLICKED, 0, msgCallback(&func)}, -typedef struct struct_bitmap_info BITMAP_INFO; class c_button : public c_wnd { +public: + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void on_paint() { @@ -1803,6 +1668,7 @@ protected: } virtual void pre_create_wnd() { + on_click = 0; m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS); m_font_type = c_theme::get_font(FONT_DEFAULT); m_font_color = c_theme::get_color(COLOR_WND_FONT); @@ -1819,7 +1685,10 @@ protected: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_BN_CLICKED, 0); + if(on_click) + { + (m_parent->*(on_click))(m_id, 0); + } } } virtual void on_navigate(NAVIGATION_KEY key) @@ -1836,6 +1705,7 @@ protected: } return c_wnd::on_navigate(key); } + WND_CALLBACK on_click; }; class c_surface; class c_dialog; @@ -2006,8 +1876,21 @@ public: } return -1; } + virtual void on_init_children() + { + c_wnd* child = m_top_child; + if (0 != child) + { + while (child) + { + ((c_button*)child)->set_on_click(WND_CALLBACK(&c_keyboard::on_key_clicked)); + child = child->get_next_sibling(); + } + } + } KEYBOARD_STATUS get_cap_status(){return m_cap_status;} char* get_str() { return m_str; } + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void pre_create_wnd() { @@ -2064,7 +1947,7 @@ protected: ASSERT(false); InputChar: m_str[m_str_len++] = id; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_del_clicked(int id, int param) { @@ -2073,7 +1956,7 @@ protected: return; } m_str[--m_str_len] = 0; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_caps_clicked(int id, int param) { @@ -2083,18 +1966,18 @@ protected: void on_enter_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - return notify_parent(KEYBORAD_CLICK, CLICK_ENTER); + (m_parent->*(on_click))(m_id, CLICK_ENTER); } void on_esc_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - notify_parent(KEYBORAD_CLICK, CLICK_ESC); + (m_parent->*(on_click))(m_id, CLICK_ESC); } - GL_DECLARE_MESSAGE_MAP() private: char m_str[32]; int m_str_len; KEYBOARD_STATUS m_cap_status; + WND_CALLBACK on_click; }; class c_keyboard_button : public c_button { @@ -2284,11 +2167,11 @@ protected: break; } } - GL_DECLARE_MESSAGE_MAP() private: void show_keyboard() { s_keyboard.connect(this, IDD_KEY_BOARD, m_kb_style); + s_keyboard.set_on_click(WND_CALLBACK(&c_edit::on_key_board_click)); s_keyboard.show_window(); } void on_touch_down(int x, int y) @@ -2368,12 +2251,12 @@ protected: }; #include #define MAX_ITEM_NUM 4 -#define GL_LIST_CONFIRM 0x1 #define ITEM_HEIGHT 45 -#define ON_LIST_CONFIRM(func) {MSG_TYPE_WND, GL_LIST_CONFIRM, 0, msgCallback(&func)}, class c_list_box : public c_wnd { public: + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } + short get_item_count() { return m_item_total; } int add_item(char* str) { if (m_item_total >= MAX_ITEM_NUM) @@ -2391,7 +2274,6 @@ public: memset(m_item_array, 0, sizeof(m_item_array)); update_list_size(); } - short get_item_count() { return m_item_total; } void select_item(short index) { if (index < 0 || index >= m_item_total) @@ -2546,7 +2428,10 @@ private: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } } } @@ -2569,7 +2454,10 @@ private: m_status = STATUS_FOCUSED; select_item((y - m_list_wnd_rect.m_top) / ITEM_HEIGHT); on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } else { @@ -2582,6 +2470,7 @@ private: char* m_item_array[MAX_ITEM_NUM]; c_rect m_list_wnd_rect; //rect relative to parent wnd. c_rect m_list_screen_rect; //rect relative to physical screen(frame buffer) + WND_CALLBACK on_change; }; #include #define MAX_PAGES 5 @@ -2920,8 +2809,6 @@ inline void c_slide_group::on_touch(int x, int y, TOUCH_ACTION action) } #define ID_BT_ARROW_UP 0x1111 #define ID_BT_ARROW_DOWN 0x2222 -#define GL_SPIN_CHANGE 0x3333 -#define ON_SPIN_CHANGE(func) {MSG_TYPE_WND, GL_SPIN_CHANGE, 0, msgCallback(&func)}, class c_spin_box; class c_spin_button : public c_button { @@ -2942,6 +2829,7 @@ public: short get_step() { return m_step; } void set_value_digit(short digit) { m_digit = digit; } short get_value_digit() { return m_digit; } + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } protected: virtual void on_paint() { @@ -2974,7 +2862,10 @@ protected: return; } m_cur_value += m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } void on_arrow_down_bt_click() @@ -2984,7 +2875,10 @@ protected: return; } m_cur_value -= m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } short m_cur_value; @@ -2995,6 +2889,7 @@ protected: short m_digit; c_spin_button m_bt_up; c_spin_button m_bt_down; + WND_CALLBACK on_change; }; inline void c_spin_button::on_touch(int x, int y, TOUCH_ACTION action) { @@ -3451,12 +3346,6 @@ private: unsigned char m_frame_len_map[64]; unsigned char m_frame_len_map_index; }; -#ifdef GUILITE_ON -GL_MSG_ENTRY c_cmd_target::ms_usr_map_entries[USR_MSG_MAX]; -unsigned short c_cmd_target::ms_user_map_size; -GL_BEGIN_MESSAGE_MAP(c_cmd_target) -GL_END_MESSAGE_MAP() -#endif #ifdef GUILITE_ON @@ -3521,7 +3410,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3542,7 +3432,7 @@ static void* timer_routine(void*) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } usleep(1000 * TIMER_UNIT); @@ -3562,7 +3452,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc)(void* param), void* param) { init_mul_timer(); int i; @@ -3578,6 +3468,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -3641,9 +3532,9 @@ unsigned int get_cur_thread_id() { return (unsigned long)pthread_self(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -4002,7 +3893,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -4023,7 +3915,7 @@ DWORD WINAPI timer_routine(LPVOID lpParam) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } Sleep(TIMER_UNIT); @@ -4043,7 +3935,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc) (void* param), void* param) { init_mul_timer(); int i; @@ -4059,6 +3951,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -4126,9 +4019,9 @@ unsigned int get_cur_thread_id() { return GetCurrentThreadId(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -4305,9 +4198,6 @@ DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX]; #endif #ifdef GUILITE_ON c_keyboard c_edit::s_keyboard; -GL_BEGIN_MESSAGE_MAP(c_edit) -ON_KEYBORAD_UPDATE(c_edit::on_key_board_click) -GL_END_MESSAGE_MAP() #endif #ifdef GUILITE_ON static c_keyboard_button s_key_0, s_key_1, s_key_2, s_key_3, s_key_4, s_key_5, s_key_6, s_key_7, s_key_8, s_key_9; @@ -4375,7 +4265,4 @@ WND_TREE g_number_board_children[] = {&s_key_enter,'\n', 0, POS_X(3), POS_Y(2), KEY_WIDTH, KEY_HEIGHT * 2 + 2}, {0,0,0,0,0,0,0} }; -GL_BEGIN_MESSAGE_MAP(c_keyboard) -ON_GL_BN_CLICKED(c_keyboard::on_key_clicked) -GL_END_MESSAGE_MAP() #endif diff --git a/HelloMario/UIcode/GuiLite.h b/HelloMario/UIcode/GuiLite.h index 4df4afa..e397552 100644 --- a/HelloMario/UIcode/GuiLite.h +++ b/HelloMario/UIcode/GuiLite.h @@ -48,7 +48,7 @@ T_TIME second_to_day(long second); T_TIME get_time(); void start_real_timer(void (*func)(void* arg)); -void register_timer(int milli_second, void func(void* ptmr, void* parg)); +void register_timer(int milli_second, void func(void* param), void* param); unsigned int get_cur_thread_id(); void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg); @@ -102,123 +102,6 @@ public: int m_right; int m_bottom; }; -#define MSG_TYPE_INVALID 0xFFFF -#define MSG_TYPE_WND 0x0001 -#define MSG_TYPE_USR 0x0002 -#define USR_MSG_MAX 32 -class c_cmd_target; -typedef void (c_cmd_target::*msgCallback)(int, int); -struct GL_MSG_ENTRY -{ - unsigned int msgType; - unsigned int msgId; - c_cmd_target* object; - msgCallback callBack; -}; -#define ON_GL_USER_MSG(msgId, func) \ -{MSG_TYPE_USR, msgId, 0, msgCallback(&func)}, -#define GL_DECLARE_MESSAGE_MAP() \ -protected: \ - virtual const GL_MSG_ENTRY* get_msg_entries() const;\ -private: \ - static const GL_MSG_ENTRY m_msg_entries[]; -#define GL_BEGIN_MESSAGE_MAP(theClass) \ -const GL_MSG_ENTRY* theClass::get_msg_entries() const \ -{ \ - return theClass::m_msg_entries; \ -} \ -const GL_MSG_ENTRY theClass::m_msg_entries[] = \ -{ -#define GL_END_MESSAGE_MAP() \ -{MSG_TYPE_INVALID, 0, 0, 0}}; -class c_cmd_target -{ -public: - static int handle_usr_msg(int msg_id, int resource_id, int param) - { - int i; - c_cmd_target* p_wnd = 0; - for (i = 0; i < ms_user_map_size; i++) - { - if (msg_id == ms_usr_map_entries[i].msgId) - { - p_wnd = (c_cmd_target*)ms_usr_map_entries[i].object; - (p_wnd->*ms_usr_map_entries[i].callBack)(resource_id, param); - } - } - return 1; - } -protected: - void load_cmd_msg() - { - const GL_MSG_ENTRY* p_entry = get_msg_entries(); - if (0 == p_entry) - { - return; - } - bool bExist = false; - while (MSG_TYPE_INVALID != p_entry->msgType) - { - if (MSG_TYPE_WND == p_entry->msgType) - { - p_entry++; - continue; - } - bExist = false; - for (int i = 0; i < ms_user_map_size; i++) - { - //repeat register, return. - if (p_entry->msgId == ms_usr_map_entries[i].msgId - && ms_usr_map_entries[i].object == this) - { - bExist = true; - break; - } - } - if (true == bExist) - { - p_entry++; - continue; - } - if (MSG_TYPE_USR == p_entry->msgType) - { - if (USR_MSG_MAX == ms_user_map_size) - { - ASSERT(false); - } - ms_usr_map_entries[ms_user_map_size] = *p_entry; - ms_usr_map_entries[ms_user_map_size].object = this; - ms_user_map_size++; - } - else - { - ASSERT(false); - break; - } - p_entry++; - } - } - const GL_MSG_ENTRY* find_msg_entry(const GL_MSG_ENTRY *pEntry, int msgType, int msgId) - { - if (MSG_TYPE_INVALID == msgType) - { - return 0; - } - while (MSG_TYPE_INVALID != pEntry->msgType) - { - if ((msgType == pEntry->msgType) && (msgId == pEntry->msgId)) - { - return pEntry; - } - pEntry++; - } - return 0; - } -private: - static GL_MSG_ENTRY ms_usr_map_entries[USR_MSG_MAX]; - static unsigned short ms_user_map_size; - GL_DECLARE_MESSAGE_MAP() -}; //BITMAP typedef struct struct_bitmap_info { @@ -1329,9 +1212,9 @@ typedef struct struct_wnd_tree short height; struct struct_wnd_tree* p_child_tree;//sub tree }WND_TREE; -class c_wnd : public c_cmd_target +typedef void (c_wnd::*WND_CALLBACK)(int, int); +class c_wnd { - friend class c_dialog; public: c_wnd() : m_status(STATUS_NORMAL), m_attr((WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS)), m_parent(0), m_top_child(0), m_prev_sibling(0), m_next_sibling(0), m_str(0), m_font_color(0), m_bg_color(0), m_id(0), m_z_order(Z_ORDER_LEVEL_0), m_focus_child(0), m_surface(0) {}; @@ -1370,7 +1253,6 @@ public: } if (load_child_wnd(p_child_tree) >= 0) { - load_cmd_msg(); on_init_children(); } return 0; @@ -1549,19 +1431,6 @@ public: } c_wnd* get_prev_sibling() const { return m_prev_sibling; } c_wnd* get_next_sibling() const { return m_next_sibling; } - void notify_parent(int msg_id, int param) - { - if (!m_parent) - { - return; - } - const GL_MSG_ENTRY* entry = m_parent->find_msg_entry(m_parent->get_msg_entries(), MSG_TYPE_WND, msg_id); - if (0 == entry) - { - return; - } - (m_parent->*(entry->callBack))(m_id, param); - } virtual void on_touch(int x, int y, TOUCH_ACTION action) { x -= m_wnd_rect.m_left; @@ -1733,6 +1602,7 @@ protected: virtual void on_focus() {}; virtual void on_kill_focus() {}; protected: + unsigned short m_id; WND_STATUS m_status; WND_ATTRIBUTION m_attr; c_rect m_wnd_rect; //position relative to parent window. @@ -1740,23 +1610,18 @@ protected: c_wnd* m_top_child; //the first sub window would be navigated c_wnd* m_prev_sibling; //previous brother c_wnd* m_next_sibling; //next brother + c_wnd* m_focus_child; //current focused window const char* m_str; //caption const FONT_INFO* m_font_type; unsigned int m_font_color; unsigned int m_bg_color; - unsigned short m_id; int m_z_order; //the graphic level for rendering - c_wnd* m_focus_child; //current focused window c_surface* m_surface; -private: - c_wnd(const c_wnd &win); - c_wnd& operator=(const c_wnd &win); }; -#define GL_BN_CLICKED 0x1111 -#define ON_GL_BN_CLICKED(func) {MSG_TYPE_WND, GL_BN_CLICKED, 0, msgCallback(&func)}, -typedef struct struct_bitmap_info BITMAP_INFO; class c_button : public c_wnd { +public: + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void on_paint() { @@ -1803,6 +1668,7 @@ protected: } virtual void pre_create_wnd() { + on_click = 0; m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS); m_font_type = c_theme::get_font(FONT_DEFAULT); m_font_color = c_theme::get_color(COLOR_WND_FONT); @@ -1819,7 +1685,10 @@ protected: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_BN_CLICKED, 0); + if(on_click) + { + (m_parent->*(on_click))(m_id, 0); + } } } virtual void on_navigate(NAVIGATION_KEY key) @@ -1836,6 +1705,7 @@ protected: } return c_wnd::on_navigate(key); } + WND_CALLBACK on_click; }; class c_surface; class c_dialog; @@ -2006,8 +1876,21 @@ public: } return -1; } + virtual void on_init_children() + { + c_wnd* child = m_top_child; + if (0 != child) + { + while (child) + { + ((c_button*)child)->set_on_click(WND_CALLBACK(&c_keyboard::on_key_clicked)); + child = child->get_next_sibling(); + } + } + } KEYBOARD_STATUS get_cap_status(){return m_cap_status;} char* get_str() { return m_str; } + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void pre_create_wnd() { @@ -2064,7 +1947,7 @@ protected: ASSERT(false); InputChar: m_str[m_str_len++] = id; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_del_clicked(int id, int param) { @@ -2073,7 +1956,7 @@ protected: return; } m_str[--m_str_len] = 0; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_caps_clicked(int id, int param) { @@ -2083,18 +1966,18 @@ protected: void on_enter_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - return notify_parent(KEYBORAD_CLICK, CLICK_ENTER); + (m_parent->*(on_click))(m_id, CLICK_ENTER); } void on_esc_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - notify_parent(KEYBORAD_CLICK, CLICK_ESC); + (m_parent->*(on_click))(m_id, CLICK_ESC); } - GL_DECLARE_MESSAGE_MAP() private: char m_str[32]; int m_str_len; KEYBOARD_STATUS m_cap_status; + WND_CALLBACK on_click; }; class c_keyboard_button : public c_button { @@ -2284,11 +2167,11 @@ protected: break; } } - GL_DECLARE_MESSAGE_MAP() private: void show_keyboard() { s_keyboard.connect(this, IDD_KEY_BOARD, m_kb_style); + s_keyboard.set_on_click(WND_CALLBACK(&c_edit::on_key_board_click)); s_keyboard.show_window(); } void on_touch_down(int x, int y) @@ -2368,12 +2251,12 @@ protected: }; #include #define MAX_ITEM_NUM 4 -#define GL_LIST_CONFIRM 0x1 #define ITEM_HEIGHT 45 -#define ON_LIST_CONFIRM(func) {MSG_TYPE_WND, GL_LIST_CONFIRM, 0, msgCallback(&func)}, class c_list_box : public c_wnd { public: + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } + short get_item_count() { return m_item_total; } int add_item(char* str) { if (m_item_total >= MAX_ITEM_NUM) @@ -2391,7 +2274,6 @@ public: memset(m_item_array, 0, sizeof(m_item_array)); update_list_size(); } - short get_item_count() { return m_item_total; } void select_item(short index) { if (index < 0 || index >= m_item_total) @@ -2546,7 +2428,10 @@ private: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } } } @@ -2569,7 +2454,10 @@ private: m_status = STATUS_FOCUSED; select_item((y - m_list_wnd_rect.m_top) / ITEM_HEIGHT); on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } else { @@ -2582,6 +2470,7 @@ private: char* m_item_array[MAX_ITEM_NUM]; c_rect m_list_wnd_rect; //rect relative to parent wnd. c_rect m_list_screen_rect; //rect relative to physical screen(frame buffer) + WND_CALLBACK on_change; }; #include #define MAX_PAGES 5 @@ -2920,8 +2809,6 @@ inline void c_slide_group::on_touch(int x, int y, TOUCH_ACTION action) } #define ID_BT_ARROW_UP 0x1111 #define ID_BT_ARROW_DOWN 0x2222 -#define GL_SPIN_CHANGE 0x3333 -#define ON_SPIN_CHANGE(func) {MSG_TYPE_WND, GL_SPIN_CHANGE, 0, msgCallback(&func)}, class c_spin_box; class c_spin_button : public c_button { @@ -2942,6 +2829,7 @@ public: short get_step() { return m_step; } void set_value_digit(short digit) { m_digit = digit; } short get_value_digit() { return m_digit; } + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } protected: virtual void on_paint() { @@ -2974,7 +2862,10 @@ protected: return; } m_cur_value += m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } void on_arrow_down_bt_click() @@ -2984,7 +2875,10 @@ protected: return; } m_cur_value -= m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } short m_cur_value; @@ -2995,6 +2889,7 @@ protected: short m_digit; c_spin_button m_bt_up; c_spin_button m_bt_down; + WND_CALLBACK on_change; }; inline void c_spin_button::on_touch(int x, int y, TOUCH_ACTION action) { @@ -3451,12 +3346,6 @@ private: unsigned char m_frame_len_map[64]; unsigned char m_frame_len_map_index; }; -#ifdef GUILITE_ON -GL_MSG_ENTRY c_cmd_target::ms_usr_map_entries[USR_MSG_MAX]; -unsigned short c_cmd_target::ms_user_map_size; -GL_BEGIN_MESSAGE_MAP(c_cmd_target) -GL_END_MESSAGE_MAP() -#endif #ifdef GUILITE_ON @@ -3521,7 +3410,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3542,7 +3432,7 @@ static void* timer_routine(void*) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } usleep(1000 * TIMER_UNIT); @@ -3562,7 +3452,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc)(void* param), void* param) { init_mul_timer(); int i; @@ -3578,6 +3468,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -3641,9 +3532,9 @@ unsigned int get_cur_thread_id() { return (unsigned long)pthread_self(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -4002,7 +3893,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -4023,7 +3915,7 @@ DWORD WINAPI timer_routine(LPVOID lpParam) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } Sleep(TIMER_UNIT); @@ -4043,7 +3935,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc) (void* param), void* param) { init_mul_timer(); int i; @@ -4059,6 +3951,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -4126,9 +4019,9 @@ unsigned int get_cur_thread_id() { return GetCurrentThreadId(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -4305,9 +4198,6 @@ DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX]; #endif #ifdef GUILITE_ON c_keyboard c_edit::s_keyboard; -GL_BEGIN_MESSAGE_MAP(c_edit) -ON_KEYBORAD_UPDATE(c_edit::on_key_board_click) -GL_END_MESSAGE_MAP() #endif #ifdef GUILITE_ON static c_keyboard_button s_key_0, s_key_1, s_key_2, s_key_3, s_key_4, s_key_5, s_key_6, s_key_7, s_key_8, s_key_9; @@ -4375,7 +4265,4 @@ WND_TREE g_number_board_children[] = {&s_key_enter,'\n', 0, POS_X(3), POS_Y(2), KEY_WIDTH, KEY_HEIGHT * 2 + 2}, {0,0,0,0,0,0,0} }; -GL_BEGIN_MESSAGE_MAP(c_keyboard) -ON_GL_BN_CLICKED(c_keyboard::on_key_clicked) -GL_END_MESSAGE_MAP() #endif diff --git a/HelloMolecule/UIcode/GuiLite.h b/HelloMolecule/UIcode/GuiLite.h index 4df4afa..e397552 100644 --- a/HelloMolecule/UIcode/GuiLite.h +++ b/HelloMolecule/UIcode/GuiLite.h @@ -48,7 +48,7 @@ T_TIME second_to_day(long second); T_TIME get_time(); void start_real_timer(void (*func)(void* arg)); -void register_timer(int milli_second, void func(void* ptmr, void* parg)); +void register_timer(int milli_second, void func(void* param), void* param); unsigned int get_cur_thread_id(); void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg); @@ -102,123 +102,6 @@ public: int m_right; int m_bottom; }; -#define MSG_TYPE_INVALID 0xFFFF -#define MSG_TYPE_WND 0x0001 -#define MSG_TYPE_USR 0x0002 -#define USR_MSG_MAX 32 -class c_cmd_target; -typedef void (c_cmd_target::*msgCallback)(int, int); -struct GL_MSG_ENTRY -{ - unsigned int msgType; - unsigned int msgId; - c_cmd_target* object; - msgCallback callBack; -}; -#define ON_GL_USER_MSG(msgId, func) \ -{MSG_TYPE_USR, msgId, 0, msgCallback(&func)}, -#define GL_DECLARE_MESSAGE_MAP() \ -protected: \ - virtual const GL_MSG_ENTRY* get_msg_entries() const;\ -private: \ - static const GL_MSG_ENTRY m_msg_entries[]; -#define GL_BEGIN_MESSAGE_MAP(theClass) \ -const GL_MSG_ENTRY* theClass::get_msg_entries() const \ -{ \ - return theClass::m_msg_entries; \ -} \ -const GL_MSG_ENTRY theClass::m_msg_entries[] = \ -{ -#define GL_END_MESSAGE_MAP() \ -{MSG_TYPE_INVALID, 0, 0, 0}}; -class c_cmd_target -{ -public: - static int handle_usr_msg(int msg_id, int resource_id, int param) - { - int i; - c_cmd_target* p_wnd = 0; - for (i = 0; i < ms_user_map_size; i++) - { - if (msg_id == ms_usr_map_entries[i].msgId) - { - p_wnd = (c_cmd_target*)ms_usr_map_entries[i].object; - (p_wnd->*ms_usr_map_entries[i].callBack)(resource_id, param); - } - } - return 1; - } -protected: - void load_cmd_msg() - { - const GL_MSG_ENTRY* p_entry = get_msg_entries(); - if (0 == p_entry) - { - return; - } - bool bExist = false; - while (MSG_TYPE_INVALID != p_entry->msgType) - { - if (MSG_TYPE_WND == p_entry->msgType) - { - p_entry++; - continue; - } - bExist = false; - for (int i = 0; i < ms_user_map_size; i++) - { - //repeat register, return. - if (p_entry->msgId == ms_usr_map_entries[i].msgId - && ms_usr_map_entries[i].object == this) - { - bExist = true; - break; - } - } - if (true == bExist) - { - p_entry++; - continue; - } - if (MSG_TYPE_USR == p_entry->msgType) - { - if (USR_MSG_MAX == ms_user_map_size) - { - ASSERT(false); - } - ms_usr_map_entries[ms_user_map_size] = *p_entry; - ms_usr_map_entries[ms_user_map_size].object = this; - ms_user_map_size++; - } - else - { - ASSERT(false); - break; - } - p_entry++; - } - } - const GL_MSG_ENTRY* find_msg_entry(const GL_MSG_ENTRY *pEntry, int msgType, int msgId) - { - if (MSG_TYPE_INVALID == msgType) - { - return 0; - } - while (MSG_TYPE_INVALID != pEntry->msgType) - { - if ((msgType == pEntry->msgType) && (msgId == pEntry->msgId)) - { - return pEntry; - } - pEntry++; - } - return 0; - } -private: - static GL_MSG_ENTRY ms_usr_map_entries[USR_MSG_MAX]; - static unsigned short ms_user_map_size; - GL_DECLARE_MESSAGE_MAP() -}; //BITMAP typedef struct struct_bitmap_info { @@ -1329,9 +1212,9 @@ typedef struct struct_wnd_tree short height; struct struct_wnd_tree* p_child_tree;//sub tree }WND_TREE; -class c_wnd : public c_cmd_target +typedef void (c_wnd::*WND_CALLBACK)(int, int); +class c_wnd { - friend class c_dialog; public: c_wnd() : m_status(STATUS_NORMAL), m_attr((WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS)), m_parent(0), m_top_child(0), m_prev_sibling(0), m_next_sibling(0), m_str(0), m_font_color(0), m_bg_color(0), m_id(0), m_z_order(Z_ORDER_LEVEL_0), m_focus_child(0), m_surface(0) {}; @@ -1370,7 +1253,6 @@ public: } if (load_child_wnd(p_child_tree) >= 0) { - load_cmd_msg(); on_init_children(); } return 0; @@ -1549,19 +1431,6 @@ public: } c_wnd* get_prev_sibling() const { return m_prev_sibling; } c_wnd* get_next_sibling() const { return m_next_sibling; } - void notify_parent(int msg_id, int param) - { - if (!m_parent) - { - return; - } - const GL_MSG_ENTRY* entry = m_parent->find_msg_entry(m_parent->get_msg_entries(), MSG_TYPE_WND, msg_id); - if (0 == entry) - { - return; - } - (m_parent->*(entry->callBack))(m_id, param); - } virtual void on_touch(int x, int y, TOUCH_ACTION action) { x -= m_wnd_rect.m_left; @@ -1733,6 +1602,7 @@ protected: virtual void on_focus() {}; virtual void on_kill_focus() {}; protected: + unsigned short m_id; WND_STATUS m_status; WND_ATTRIBUTION m_attr; c_rect m_wnd_rect; //position relative to parent window. @@ -1740,23 +1610,18 @@ protected: c_wnd* m_top_child; //the first sub window would be navigated c_wnd* m_prev_sibling; //previous brother c_wnd* m_next_sibling; //next brother + c_wnd* m_focus_child; //current focused window const char* m_str; //caption const FONT_INFO* m_font_type; unsigned int m_font_color; unsigned int m_bg_color; - unsigned short m_id; int m_z_order; //the graphic level for rendering - c_wnd* m_focus_child; //current focused window c_surface* m_surface; -private: - c_wnd(const c_wnd &win); - c_wnd& operator=(const c_wnd &win); }; -#define GL_BN_CLICKED 0x1111 -#define ON_GL_BN_CLICKED(func) {MSG_TYPE_WND, GL_BN_CLICKED, 0, msgCallback(&func)}, -typedef struct struct_bitmap_info BITMAP_INFO; class c_button : public c_wnd { +public: + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void on_paint() { @@ -1803,6 +1668,7 @@ protected: } virtual void pre_create_wnd() { + on_click = 0; m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS); m_font_type = c_theme::get_font(FONT_DEFAULT); m_font_color = c_theme::get_color(COLOR_WND_FONT); @@ -1819,7 +1685,10 @@ protected: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_BN_CLICKED, 0); + if(on_click) + { + (m_parent->*(on_click))(m_id, 0); + } } } virtual void on_navigate(NAVIGATION_KEY key) @@ -1836,6 +1705,7 @@ protected: } return c_wnd::on_navigate(key); } + WND_CALLBACK on_click; }; class c_surface; class c_dialog; @@ -2006,8 +1876,21 @@ public: } return -1; } + virtual void on_init_children() + { + c_wnd* child = m_top_child; + if (0 != child) + { + while (child) + { + ((c_button*)child)->set_on_click(WND_CALLBACK(&c_keyboard::on_key_clicked)); + child = child->get_next_sibling(); + } + } + } KEYBOARD_STATUS get_cap_status(){return m_cap_status;} char* get_str() { return m_str; } + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void pre_create_wnd() { @@ -2064,7 +1947,7 @@ protected: ASSERT(false); InputChar: m_str[m_str_len++] = id; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_del_clicked(int id, int param) { @@ -2073,7 +1956,7 @@ protected: return; } m_str[--m_str_len] = 0; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_caps_clicked(int id, int param) { @@ -2083,18 +1966,18 @@ protected: void on_enter_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - return notify_parent(KEYBORAD_CLICK, CLICK_ENTER); + (m_parent->*(on_click))(m_id, CLICK_ENTER); } void on_esc_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - notify_parent(KEYBORAD_CLICK, CLICK_ESC); + (m_parent->*(on_click))(m_id, CLICK_ESC); } - GL_DECLARE_MESSAGE_MAP() private: char m_str[32]; int m_str_len; KEYBOARD_STATUS m_cap_status; + WND_CALLBACK on_click; }; class c_keyboard_button : public c_button { @@ -2284,11 +2167,11 @@ protected: break; } } - GL_DECLARE_MESSAGE_MAP() private: void show_keyboard() { s_keyboard.connect(this, IDD_KEY_BOARD, m_kb_style); + s_keyboard.set_on_click(WND_CALLBACK(&c_edit::on_key_board_click)); s_keyboard.show_window(); } void on_touch_down(int x, int y) @@ -2368,12 +2251,12 @@ protected: }; #include #define MAX_ITEM_NUM 4 -#define GL_LIST_CONFIRM 0x1 #define ITEM_HEIGHT 45 -#define ON_LIST_CONFIRM(func) {MSG_TYPE_WND, GL_LIST_CONFIRM, 0, msgCallback(&func)}, class c_list_box : public c_wnd { public: + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } + short get_item_count() { return m_item_total; } int add_item(char* str) { if (m_item_total >= MAX_ITEM_NUM) @@ -2391,7 +2274,6 @@ public: memset(m_item_array, 0, sizeof(m_item_array)); update_list_size(); } - short get_item_count() { return m_item_total; } void select_item(short index) { if (index < 0 || index >= m_item_total) @@ -2546,7 +2428,10 @@ private: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } } } @@ -2569,7 +2454,10 @@ private: m_status = STATUS_FOCUSED; select_item((y - m_list_wnd_rect.m_top) / ITEM_HEIGHT); on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } else { @@ -2582,6 +2470,7 @@ private: char* m_item_array[MAX_ITEM_NUM]; c_rect m_list_wnd_rect; //rect relative to parent wnd. c_rect m_list_screen_rect; //rect relative to physical screen(frame buffer) + WND_CALLBACK on_change; }; #include #define MAX_PAGES 5 @@ -2920,8 +2809,6 @@ inline void c_slide_group::on_touch(int x, int y, TOUCH_ACTION action) } #define ID_BT_ARROW_UP 0x1111 #define ID_BT_ARROW_DOWN 0x2222 -#define GL_SPIN_CHANGE 0x3333 -#define ON_SPIN_CHANGE(func) {MSG_TYPE_WND, GL_SPIN_CHANGE, 0, msgCallback(&func)}, class c_spin_box; class c_spin_button : public c_button { @@ -2942,6 +2829,7 @@ public: short get_step() { return m_step; } void set_value_digit(short digit) { m_digit = digit; } short get_value_digit() { return m_digit; } + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } protected: virtual void on_paint() { @@ -2974,7 +2862,10 @@ protected: return; } m_cur_value += m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } void on_arrow_down_bt_click() @@ -2984,7 +2875,10 @@ protected: return; } m_cur_value -= m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } short m_cur_value; @@ -2995,6 +2889,7 @@ protected: short m_digit; c_spin_button m_bt_up; c_spin_button m_bt_down; + WND_CALLBACK on_change; }; inline void c_spin_button::on_touch(int x, int y, TOUCH_ACTION action) { @@ -3451,12 +3346,6 @@ private: unsigned char m_frame_len_map[64]; unsigned char m_frame_len_map_index; }; -#ifdef GUILITE_ON -GL_MSG_ENTRY c_cmd_target::ms_usr_map_entries[USR_MSG_MAX]; -unsigned short c_cmd_target::ms_user_map_size; -GL_BEGIN_MESSAGE_MAP(c_cmd_target) -GL_END_MESSAGE_MAP() -#endif #ifdef GUILITE_ON @@ -3521,7 +3410,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3542,7 +3432,7 @@ static void* timer_routine(void*) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } usleep(1000 * TIMER_UNIT); @@ -3562,7 +3452,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc)(void* param), void* param) { init_mul_timer(); int i; @@ -3578,6 +3468,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -3641,9 +3532,9 @@ unsigned int get_cur_thread_id() { return (unsigned long)pthread_self(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -4002,7 +3893,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -4023,7 +3915,7 @@ DWORD WINAPI timer_routine(LPVOID lpParam) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } Sleep(TIMER_UNIT); @@ -4043,7 +3935,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc) (void* param), void* param) { init_mul_timer(); int i; @@ -4059,6 +3951,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -4126,9 +4019,9 @@ unsigned int get_cur_thread_id() { return GetCurrentThreadId(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -4305,9 +4198,6 @@ DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX]; #endif #ifdef GUILITE_ON c_keyboard c_edit::s_keyboard; -GL_BEGIN_MESSAGE_MAP(c_edit) -ON_KEYBORAD_UPDATE(c_edit::on_key_board_click) -GL_END_MESSAGE_MAP() #endif #ifdef GUILITE_ON static c_keyboard_button s_key_0, s_key_1, s_key_2, s_key_3, s_key_4, s_key_5, s_key_6, s_key_7, s_key_8, s_key_9; @@ -4375,7 +4265,4 @@ WND_TREE g_number_board_children[] = {&s_key_enter,'\n', 0, POS_X(3), POS_Y(2), KEY_WIDTH, KEY_HEIGHT * 2 + 2}, {0,0,0,0,0,0,0} }; -GL_BEGIN_MESSAGE_MAP(c_keyboard) -ON_GL_BN_CLICKED(c_keyboard::on_key_clicked) -GL_END_MESSAGE_MAP() #endif diff --git a/HelloNets/UIcode/GuiLite.h b/HelloNets/UIcode/GuiLite.h index 4df4afa..e397552 100644 --- a/HelloNets/UIcode/GuiLite.h +++ b/HelloNets/UIcode/GuiLite.h @@ -48,7 +48,7 @@ T_TIME second_to_day(long second); T_TIME get_time(); void start_real_timer(void (*func)(void* arg)); -void register_timer(int milli_second, void func(void* ptmr, void* parg)); +void register_timer(int milli_second, void func(void* param), void* param); unsigned int get_cur_thread_id(); void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg); @@ -102,123 +102,6 @@ public: int m_right; int m_bottom; }; -#define MSG_TYPE_INVALID 0xFFFF -#define MSG_TYPE_WND 0x0001 -#define MSG_TYPE_USR 0x0002 -#define USR_MSG_MAX 32 -class c_cmd_target; -typedef void (c_cmd_target::*msgCallback)(int, int); -struct GL_MSG_ENTRY -{ - unsigned int msgType; - unsigned int msgId; - c_cmd_target* object; - msgCallback callBack; -}; -#define ON_GL_USER_MSG(msgId, func) \ -{MSG_TYPE_USR, msgId, 0, msgCallback(&func)}, -#define GL_DECLARE_MESSAGE_MAP() \ -protected: \ - virtual const GL_MSG_ENTRY* get_msg_entries() const;\ -private: \ - static const GL_MSG_ENTRY m_msg_entries[]; -#define GL_BEGIN_MESSAGE_MAP(theClass) \ -const GL_MSG_ENTRY* theClass::get_msg_entries() const \ -{ \ - return theClass::m_msg_entries; \ -} \ -const GL_MSG_ENTRY theClass::m_msg_entries[] = \ -{ -#define GL_END_MESSAGE_MAP() \ -{MSG_TYPE_INVALID, 0, 0, 0}}; -class c_cmd_target -{ -public: - static int handle_usr_msg(int msg_id, int resource_id, int param) - { - int i; - c_cmd_target* p_wnd = 0; - for (i = 0; i < ms_user_map_size; i++) - { - if (msg_id == ms_usr_map_entries[i].msgId) - { - p_wnd = (c_cmd_target*)ms_usr_map_entries[i].object; - (p_wnd->*ms_usr_map_entries[i].callBack)(resource_id, param); - } - } - return 1; - } -protected: - void load_cmd_msg() - { - const GL_MSG_ENTRY* p_entry = get_msg_entries(); - if (0 == p_entry) - { - return; - } - bool bExist = false; - while (MSG_TYPE_INVALID != p_entry->msgType) - { - if (MSG_TYPE_WND == p_entry->msgType) - { - p_entry++; - continue; - } - bExist = false; - for (int i = 0; i < ms_user_map_size; i++) - { - //repeat register, return. - if (p_entry->msgId == ms_usr_map_entries[i].msgId - && ms_usr_map_entries[i].object == this) - { - bExist = true; - break; - } - } - if (true == bExist) - { - p_entry++; - continue; - } - if (MSG_TYPE_USR == p_entry->msgType) - { - if (USR_MSG_MAX == ms_user_map_size) - { - ASSERT(false); - } - ms_usr_map_entries[ms_user_map_size] = *p_entry; - ms_usr_map_entries[ms_user_map_size].object = this; - ms_user_map_size++; - } - else - { - ASSERT(false); - break; - } - p_entry++; - } - } - const GL_MSG_ENTRY* find_msg_entry(const GL_MSG_ENTRY *pEntry, int msgType, int msgId) - { - if (MSG_TYPE_INVALID == msgType) - { - return 0; - } - while (MSG_TYPE_INVALID != pEntry->msgType) - { - if ((msgType == pEntry->msgType) && (msgId == pEntry->msgId)) - { - return pEntry; - } - pEntry++; - } - return 0; - } -private: - static GL_MSG_ENTRY ms_usr_map_entries[USR_MSG_MAX]; - static unsigned short ms_user_map_size; - GL_DECLARE_MESSAGE_MAP() -}; //BITMAP typedef struct struct_bitmap_info { @@ -1329,9 +1212,9 @@ typedef struct struct_wnd_tree short height; struct struct_wnd_tree* p_child_tree;//sub tree }WND_TREE; -class c_wnd : public c_cmd_target +typedef void (c_wnd::*WND_CALLBACK)(int, int); +class c_wnd { - friend class c_dialog; public: c_wnd() : m_status(STATUS_NORMAL), m_attr((WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS)), m_parent(0), m_top_child(0), m_prev_sibling(0), m_next_sibling(0), m_str(0), m_font_color(0), m_bg_color(0), m_id(0), m_z_order(Z_ORDER_LEVEL_0), m_focus_child(0), m_surface(0) {}; @@ -1370,7 +1253,6 @@ public: } if (load_child_wnd(p_child_tree) >= 0) { - load_cmd_msg(); on_init_children(); } return 0; @@ -1549,19 +1431,6 @@ public: } c_wnd* get_prev_sibling() const { return m_prev_sibling; } c_wnd* get_next_sibling() const { return m_next_sibling; } - void notify_parent(int msg_id, int param) - { - if (!m_parent) - { - return; - } - const GL_MSG_ENTRY* entry = m_parent->find_msg_entry(m_parent->get_msg_entries(), MSG_TYPE_WND, msg_id); - if (0 == entry) - { - return; - } - (m_parent->*(entry->callBack))(m_id, param); - } virtual void on_touch(int x, int y, TOUCH_ACTION action) { x -= m_wnd_rect.m_left; @@ -1733,6 +1602,7 @@ protected: virtual void on_focus() {}; virtual void on_kill_focus() {}; protected: + unsigned short m_id; WND_STATUS m_status; WND_ATTRIBUTION m_attr; c_rect m_wnd_rect; //position relative to parent window. @@ -1740,23 +1610,18 @@ protected: c_wnd* m_top_child; //the first sub window would be navigated c_wnd* m_prev_sibling; //previous brother c_wnd* m_next_sibling; //next brother + c_wnd* m_focus_child; //current focused window const char* m_str; //caption const FONT_INFO* m_font_type; unsigned int m_font_color; unsigned int m_bg_color; - unsigned short m_id; int m_z_order; //the graphic level for rendering - c_wnd* m_focus_child; //current focused window c_surface* m_surface; -private: - c_wnd(const c_wnd &win); - c_wnd& operator=(const c_wnd &win); }; -#define GL_BN_CLICKED 0x1111 -#define ON_GL_BN_CLICKED(func) {MSG_TYPE_WND, GL_BN_CLICKED, 0, msgCallback(&func)}, -typedef struct struct_bitmap_info BITMAP_INFO; class c_button : public c_wnd { +public: + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void on_paint() { @@ -1803,6 +1668,7 @@ protected: } virtual void pre_create_wnd() { + on_click = 0; m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS); m_font_type = c_theme::get_font(FONT_DEFAULT); m_font_color = c_theme::get_color(COLOR_WND_FONT); @@ -1819,7 +1685,10 @@ protected: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_BN_CLICKED, 0); + if(on_click) + { + (m_parent->*(on_click))(m_id, 0); + } } } virtual void on_navigate(NAVIGATION_KEY key) @@ -1836,6 +1705,7 @@ protected: } return c_wnd::on_navigate(key); } + WND_CALLBACK on_click; }; class c_surface; class c_dialog; @@ -2006,8 +1876,21 @@ public: } return -1; } + virtual void on_init_children() + { + c_wnd* child = m_top_child; + if (0 != child) + { + while (child) + { + ((c_button*)child)->set_on_click(WND_CALLBACK(&c_keyboard::on_key_clicked)); + child = child->get_next_sibling(); + } + } + } KEYBOARD_STATUS get_cap_status(){return m_cap_status;} char* get_str() { return m_str; } + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void pre_create_wnd() { @@ -2064,7 +1947,7 @@ protected: ASSERT(false); InputChar: m_str[m_str_len++] = id; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_del_clicked(int id, int param) { @@ -2073,7 +1956,7 @@ protected: return; } m_str[--m_str_len] = 0; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_caps_clicked(int id, int param) { @@ -2083,18 +1966,18 @@ protected: void on_enter_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - return notify_parent(KEYBORAD_CLICK, CLICK_ENTER); + (m_parent->*(on_click))(m_id, CLICK_ENTER); } void on_esc_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - notify_parent(KEYBORAD_CLICK, CLICK_ESC); + (m_parent->*(on_click))(m_id, CLICK_ESC); } - GL_DECLARE_MESSAGE_MAP() private: char m_str[32]; int m_str_len; KEYBOARD_STATUS m_cap_status; + WND_CALLBACK on_click; }; class c_keyboard_button : public c_button { @@ -2284,11 +2167,11 @@ protected: break; } } - GL_DECLARE_MESSAGE_MAP() private: void show_keyboard() { s_keyboard.connect(this, IDD_KEY_BOARD, m_kb_style); + s_keyboard.set_on_click(WND_CALLBACK(&c_edit::on_key_board_click)); s_keyboard.show_window(); } void on_touch_down(int x, int y) @@ -2368,12 +2251,12 @@ protected: }; #include #define MAX_ITEM_NUM 4 -#define GL_LIST_CONFIRM 0x1 #define ITEM_HEIGHT 45 -#define ON_LIST_CONFIRM(func) {MSG_TYPE_WND, GL_LIST_CONFIRM, 0, msgCallback(&func)}, class c_list_box : public c_wnd { public: + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } + short get_item_count() { return m_item_total; } int add_item(char* str) { if (m_item_total >= MAX_ITEM_NUM) @@ -2391,7 +2274,6 @@ public: memset(m_item_array, 0, sizeof(m_item_array)); update_list_size(); } - short get_item_count() { return m_item_total; } void select_item(short index) { if (index < 0 || index >= m_item_total) @@ -2546,7 +2428,10 @@ private: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } } } @@ -2569,7 +2454,10 @@ private: m_status = STATUS_FOCUSED; select_item((y - m_list_wnd_rect.m_top) / ITEM_HEIGHT); on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } else { @@ -2582,6 +2470,7 @@ private: char* m_item_array[MAX_ITEM_NUM]; c_rect m_list_wnd_rect; //rect relative to parent wnd. c_rect m_list_screen_rect; //rect relative to physical screen(frame buffer) + WND_CALLBACK on_change; }; #include #define MAX_PAGES 5 @@ -2920,8 +2809,6 @@ inline void c_slide_group::on_touch(int x, int y, TOUCH_ACTION action) } #define ID_BT_ARROW_UP 0x1111 #define ID_BT_ARROW_DOWN 0x2222 -#define GL_SPIN_CHANGE 0x3333 -#define ON_SPIN_CHANGE(func) {MSG_TYPE_WND, GL_SPIN_CHANGE, 0, msgCallback(&func)}, class c_spin_box; class c_spin_button : public c_button { @@ -2942,6 +2829,7 @@ public: short get_step() { return m_step; } void set_value_digit(short digit) { m_digit = digit; } short get_value_digit() { return m_digit; } + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } protected: virtual void on_paint() { @@ -2974,7 +2862,10 @@ protected: return; } m_cur_value += m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } void on_arrow_down_bt_click() @@ -2984,7 +2875,10 @@ protected: return; } m_cur_value -= m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } short m_cur_value; @@ -2995,6 +2889,7 @@ protected: short m_digit; c_spin_button m_bt_up; c_spin_button m_bt_down; + WND_CALLBACK on_change; }; inline void c_spin_button::on_touch(int x, int y, TOUCH_ACTION action) { @@ -3451,12 +3346,6 @@ private: unsigned char m_frame_len_map[64]; unsigned char m_frame_len_map_index; }; -#ifdef GUILITE_ON -GL_MSG_ENTRY c_cmd_target::ms_usr_map_entries[USR_MSG_MAX]; -unsigned short c_cmd_target::ms_user_map_size; -GL_BEGIN_MESSAGE_MAP(c_cmd_target) -GL_END_MESSAGE_MAP() -#endif #ifdef GUILITE_ON @@ -3521,7 +3410,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3542,7 +3432,7 @@ static void* timer_routine(void*) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } usleep(1000 * TIMER_UNIT); @@ -3562,7 +3452,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc)(void* param), void* param) { init_mul_timer(); int i; @@ -3578,6 +3468,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -3641,9 +3532,9 @@ unsigned int get_cur_thread_id() { return (unsigned long)pthread_self(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -4002,7 +3893,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -4023,7 +3915,7 @@ DWORD WINAPI timer_routine(LPVOID lpParam) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } Sleep(TIMER_UNIT); @@ -4043,7 +3935,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc) (void* param), void* param) { init_mul_timer(); int i; @@ -4059,6 +3951,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -4126,9 +4019,9 @@ unsigned int get_cur_thread_id() { return GetCurrentThreadId(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -4305,9 +4198,6 @@ DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX]; #endif #ifdef GUILITE_ON c_keyboard c_edit::s_keyboard; -GL_BEGIN_MESSAGE_MAP(c_edit) -ON_KEYBORAD_UPDATE(c_edit::on_key_board_click) -GL_END_MESSAGE_MAP() #endif #ifdef GUILITE_ON static c_keyboard_button s_key_0, s_key_1, s_key_2, s_key_3, s_key_4, s_key_5, s_key_6, s_key_7, s_key_8, s_key_9; @@ -4375,7 +4265,4 @@ WND_TREE g_number_board_children[] = {&s_key_enter,'\n', 0, POS_X(3), POS_Y(2), KEY_WIDTH, KEY_HEIGHT * 2 + 2}, {0,0,0,0,0,0,0} }; -GL_BEGIN_MESSAGE_MAP(c_keyboard) -ON_GL_BN_CLICKED(c_keyboard::on_key_clicked) -GL_END_MESSAGE_MAP() #endif diff --git a/HelloNoTouch/UIcode/GuiLite.h b/HelloNoTouch/UIcode/GuiLite.h index de5a678..e397552 100644 --- a/HelloNoTouch/UIcode/GuiLite.h +++ b/HelloNoTouch/UIcode/GuiLite.h @@ -48,7 +48,7 @@ T_TIME second_to_day(long second); T_TIME get_time(); void start_real_timer(void (*func)(void* arg)); -void register_timer(int milli_second, void func(void* ptmr, void* parg)); +void register_timer(int milli_second, void func(void* param), void* param); unsigned int get_cur_thread_id(); void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg); @@ -1668,6 +1668,7 @@ protected: } virtual void pre_create_wnd() { + on_click = 0; m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS); m_font_type = c_theme::get_font(FONT_DEFAULT); m_font_color = c_theme::get_color(COLOR_WND_FONT); @@ -1704,7 +1705,7 @@ protected: } return c_wnd::on_navigate(key); } - WND_CALLBACK on_click = 0; + WND_CALLBACK on_click; }; class c_surface; class c_dialog; @@ -3409,7 +3410,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3430,7 +3432,7 @@ static void* timer_routine(void*) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } usleep(1000 * TIMER_UNIT); @@ -3450,7 +3452,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc)(void* param), void* param) { init_mul_timer(); int i; @@ -3466,6 +3468,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -3529,9 +3532,9 @@ unsigned int get_cur_thread_id() { return (unsigned long)pthread_self(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -3890,7 +3893,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3911,7 +3915,7 @@ DWORD WINAPI timer_routine(LPVOID lpParam) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } Sleep(TIMER_UNIT); @@ -3931,7 +3935,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc) (void* param), void* param) { init_mul_timer(); int i; @@ -3947,6 +3951,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -4014,9 +4019,9 @@ unsigned int get_cur_thread_id() { return GetCurrentThreadId(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { diff --git a/HelloParticle/UIcode/GuiLite.h b/HelloParticle/UIcode/GuiLite.h index 4df4afa..e397552 100644 --- a/HelloParticle/UIcode/GuiLite.h +++ b/HelloParticle/UIcode/GuiLite.h @@ -48,7 +48,7 @@ T_TIME second_to_day(long second); T_TIME get_time(); void start_real_timer(void (*func)(void* arg)); -void register_timer(int milli_second, void func(void* ptmr, void* parg)); +void register_timer(int milli_second, void func(void* param), void* param); unsigned int get_cur_thread_id(); void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg); @@ -102,123 +102,6 @@ public: int m_right; int m_bottom; }; -#define MSG_TYPE_INVALID 0xFFFF -#define MSG_TYPE_WND 0x0001 -#define MSG_TYPE_USR 0x0002 -#define USR_MSG_MAX 32 -class c_cmd_target; -typedef void (c_cmd_target::*msgCallback)(int, int); -struct GL_MSG_ENTRY -{ - unsigned int msgType; - unsigned int msgId; - c_cmd_target* object; - msgCallback callBack; -}; -#define ON_GL_USER_MSG(msgId, func) \ -{MSG_TYPE_USR, msgId, 0, msgCallback(&func)}, -#define GL_DECLARE_MESSAGE_MAP() \ -protected: \ - virtual const GL_MSG_ENTRY* get_msg_entries() const;\ -private: \ - static const GL_MSG_ENTRY m_msg_entries[]; -#define GL_BEGIN_MESSAGE_MAP(theClass) \ -const GL_MSG_ENTRY* theClass::get_msg_entries() const \ -{ \ - return theClass::m_msg_entries; \ -} \ -const GL_MSG_ENTRY theClass::m_msg_entries[] = \ -{ -#define GL_END_MESSAGE_MAP() \ -{MSG_TYPE_INVALID, 0, 0, 0}}; -class c_cmd_target -{ -public: - static int handle_usr_msg(int msg_id, int resource_id, int param) - { - int i; - c_cmd_target* p_wnd = 0; - for (i = 0; i < ms_user_map_size; i++) - { - if (msg_id == ms_usr_map_entries[i].msgId) - { - p_wnd = (c_cmd_target*)ms_usr_map_entries[i].object; - (p_wnd->*ms_usr_map_entries[i].callBack)(resource_id, param); - } - } - return 1; - } -protected: - void load_cmd_msg() - { - const GL_MSG_ENTRY* p_entry = get_msg_entries(); - if (0 == p_entry) - { - return; - } - bool bExist = false; - while (MSG_TYPE_INVALID != p_entry->msgType) - { - if (MSG_TYPE_WND == p_entry->msgType) - { - p_entry++; - continue; - } - bExist = false; - for (int i = 0; i < ms_user_map_size; i++) - { - //repeat register, return. - if (p_entry->msgId == ms_usr_map_entries[i].msgId - && ms_usr_map_entries[i].object == this) - { - bExist = true; - break; - } - } - if (true == bExist) - { - p_entry++; - continue; - } - if (MSG_TYPE_USR == p_entry->msgType) - { - if (USR_MSG_MAX == ms_user_map_size) - { - ASSERT(false); - } - ms_usr_map_entries[ms_user_map_size] = *p_entry; - ms_usr_map_entries[ms_user_map_size].object = this; - ms_user_map_size++; - } - else - { - ASSERT(false); - break; - } - p_entry++; - } - } - const GL_MSG_ENTRY* find_msg_entry(const GL_MSG_ENTRY *pEntry, int msgType, int msgId) - { - if (MSG_TYPE_INVALID == msgType) - { - return 0; - } - while (MSG_TYPE_INVALID != pEntry->msgType) - { - if ((msgType == pEntry->msgType) && (msgId == pEntry->msgId)) - { - return pEntry; - } - pEntry++; - } - return 0; - } -private: - static GL_MSG_ENTRY ms_usr_map_entries[USR_MSG_MAX]; - static unsigned short ms_user_map_size; - GL_DECLARE_MESSAGE_MAP() -}; //BITMAP typedef struct struct_bitmap_info { @@ -1329,9 +1212,9 @@ typedef struct struct_wnd_tree short height; struct struct_wnd_tree* p_child_tree;//sub tree }WND_TREE; -class c_wnd : public c_cmd_target +typedef void (c_wnd::*WND_CALLBACK)(int, int); +class c_wnd { - friend class c_dialog; public: c_wnd() : m_status(STATUS_NORMAL), m_attr((WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS)), m_parent(0), m_top_child(0), m_prev_sibling(0), m_next_sibling(0), m_str(0), m_font_color(0), m_bg_color(0), m_id(0), m_z_order(Z_ORDER_LEVEL_0), m_focus_child(0), m_surface(0) {}; @@ -1370,7 +1253,6 @@ public: } if (load_child_wnd(p_child_tree) >= 0) { - load_cmd_msg(); on_init_children(); } return 0; @@ -1549,19 +1431,6 @@ public: } c_wnd* get_prev_sibling() const { return m_prev_sibling; } c_wnd* get_next_sibling() const { return m_next_sibling; } - void notify_parent(int msg_id, int param) - { - if (!m_parent) - { - return; - } - const GL_MSG_ENTRY* entry = m_parent->find_msg_entry(m_parent->get_msg_entries(), MSG_TYPE_WND, msg_id); - if (0 == entry) - { - return; - } - (m_parent->*(entry->callBack))(m_id, param); - } virtual void on_touch(int x, int y, TOUCH_ACTION action) { x -= m_wnd_rect.m_left; @@ -1733,6 +1602,7 @@ protected: virtual void on_focus() {}; virtual void on_kill_focus() {}; protected: + unsigned short m_id; WND_STATUS m_status; WND_ATTRIBUTION m_attr; c_rect m_wnd_rect; //position relative to parent window. @@ -1740,23 +1610,18 @@ protected: c_wnd* m_top_child; //the first sub window would be navigated c_wnd* m_prev_sibling; //previous brother c_wnd* m_next_sibling; //next brother + c_wnd* m_focus_child; //current focused window const char* m_str; //caption const FONT_INFO* m_font_type; unsigned int m_font_color; unsigned int m_bg_color; - unsigned short m_id; int m_z_order; //the graphic level for rendering - c_wnd* m_focus_child; //current focused window c_surface* m_surface; -private: - c_wnd(const c_wnd &win); - c_wnd& operator=(const c_wnd &win); }; -#define GL_BN_CLICKED 0x1111 -#define ON_GL_BN_CLICKED(func) {MSG_TYPE_WND, GL_BN_CLICKED, 0, msgCallback(&func)}, -typedef struct struct_bitmap_info BITMAP_INFO; class c_button : public c_wnd { +public: + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void on_paint() { @@ -1803,6 +1668,7 @@ protected: } virtual void pre_create_wnd() { + on_click = 0; m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS); m_font_type = c_theme::get_font(FONT_DEFAULT); m_font_color = c_theme::get_color(COLOR_WND_FONT); @@ -1819,7 +1685,10 @@ protected: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_BN_CLICKED, 0); + if(on_click) + { + (m_parent->*(on_click))(m_id, 0); + } } } virtual void on_navigate(NAVIGATION_KEY key) @@ -1836,6 +1705,7 @@ protected: } return c_wnd::on_navigate(key); } + WND_CALLBACK on_click; }; class c_surface; class c_dialog; @@ -2006,8 +1876,21 @@ public: } return -1; } + virtual void on_init_children() + { + c_wnd* child = m_top_child; + if (0 != child) + { + while (child) + { + ((c_button*)child)->set_on_click(WND_CALLBACK(&c_keyboard::on_key_clicked)); + child = child->get_next_sibling(); + } + } + } KEYBOARD_STATUS get_cap_status(){return m_cap_status;} char* get_str() { return m_str; } + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void pre_create_wnd() { @@ -2064,7 +1947,7 @@ protected: ASSERT(false); InputChar: m_str[m_str_len++] = id; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_del_clicked(int id, int param) { @@ -2073,7 +1956,7 @@ protected: return; } m_str[--m_str_len] = 0; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_caps_clicked(int id, int param) { @@ -2083,18 +1966,18 @@ protected: void on_enter_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - return notify_parent(KEYBORAD_CLICK, CLICK_ENTER); + (m_parent->*(on_click))(m_id, CLICK_ENTER); } void on_esc_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - notify_parent(KEYBORAD_CLICK, CLICK_ESC); + (m_parent->*(on_click))(m_id, CLICK_ESC); } - GL_DECLARE_MESSAGE_MAP() private: char m_str[32]; int m_str_len; KEYBOARD_STATUS m_cap_status; + WND_CALLBACK on_click; }; class c_keyboard_button : public c_button { @@ -2284,11 +2167,11 @@ protected: break; } } - GL_DECLARE_MESSAGE_MAP() private: void show_keyboard() { s_keyboard.connect(this, IDD_KEY_BOARD, m_kb_style); + s_keyboard.set_on_click(WND_CALLBACK(&c_edit::on_key_board_click)); s_keyboard.show_window(); } void on_touch_down(int x, int y) @@ -2368,12 +2251,12 @@ protected: }; #include #define MAX_ITEM_NUM 4 -#define GL_LIST_CONFIRM 0x1 #define ITEM_HEIGHT 45 -#define ON_LIST_CONFIRM(func) {MSG_TYPE_WND, GL_LIST_CONFIRM, 0, msgCallback(&func)}, class c_list_box : public c_wnd { public: + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } + short get_item_count() { return m_item_total; } int add_item(char* str) { if (m_item_total >= MAX_ITEM_NUM) @@ -2391,7 +2274,6 @@ public: memset(m_item_array, 0, sizeof(m_item_array)); update_list_size(); } - short get_item_count() { return m_item_total; } void select_item(short index) { if (index < 0 || index >= m_item_total) @@ -2546,7 +2428,10 @@ private: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } } } @@ -2569,7 +2454,10 @@ private: m_status = STATUS_FOCUSED; select_item((y - m_list_wnd_rect.m_top) / ITEM_HEIGHT); on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } else { @@ -2582,6 +2470,7 @@ private: char* m_item_array[MAX_ITEM_NUM]; c_rect m_list_wnd_rect; //rect relative to parent wnd. c_rect m_list_screen_rect; //rect relative to physical screen(frame buffer) + WND_CALLBACK on_change; }; #include #define MAX_PAGES 5 @@ -2920,8 +2809,6 @@ inline void c_slide_group::on_touch(int x, int y, TOUCH_ACTION action) } #define ID_BT_ARROW_UP 0x1111 #define ID_BT_ARROW_DOWN 0x2222 -#define GL_SPIN_CHANGE 0x3333 -#define ON_SPIN_CHANGE(func) {MSG_TYPE_WND, GL_SPIN_CHANGE, 0, msgCallback(&func)}, class c_spin_box; class c_spin_button : public c_button { @@ -2942,6 +2829,7 @@ public: short get_step() { return m_step; } void set_value_digit(short digit) { m_digit = digit; } short get_value_digit() { return m_digit; } + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } protected: virtual void on_paint() { @@ -2974,7 +2862,10 @@ protected: return; } m_cur_value += m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } void on_arrow_down_bt_click() @@ -2984,7 +2875,10 @@ protected: return; } m_cur_value -= m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } short m_cur_value; @@ -2995,6 +2889,7 @@ protected: short m_digit; c_spin_button m_bt_up; c_spin_button m_bt_down; + WND_CALLBACK on_change; }; inline void c_spin_button::on_touch(int x, int y, TOUCH_ACTION action) { @@ -3451,12 +3346,6 @@ private: unsigned char m_frame_len_map[64]; unsigned char m_frame_len_map_index; }; -#ifdef GUILITE_ON -GL_MSG_ENTRY c_cmd_target::ms_usr_map_entries[USR_MSG_MAX]; -unsigned short c_cmd_target::ms_user_map_size; -GL_BEGIN_MESSAGE_MAP(c_cmd_target) -GL_END_MESSAGE_MAP() -#endif #ifdef GUILITE_ON @@ -3521,7 +3410,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3542,7 +3432,7 @@ static void* timer_routine(void*) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } usleep(1000 * TIMER_UNIT); @@ -3562,7 +3452,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc)(void* param), void* param) { init_mul_timer(); int i; @@ -3578,6 +3468,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -3641,9 +3532,9 @@ unsigned int get_cur_thread_id() { return (unsigned long)pthread_self(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -4002,7 +3893,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -4023,7 +3915,7 @@ DWORD WINAPI timer_routine(LPVOID lpParam) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } Sleep(TIMER_UNIT); @@ -4043,7 +3935,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc) (void* param), void* param) { init_mul_timer(); int i; @@ -4059,6 +3951,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -4126,9 +4019,9 @@ unsigned int get_cur_thread_id() { return GetCurrentThreadId(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -4305,9 +4198,6 @@ DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX]; #endif #ifdef GUILITE_ON c_keyboard c_edit::s_keyboard; -GL_BEGIN_MESSAGE_MAP(c_edit) -ON_KEYBORAD_UPDATE(c_edit::on_key_board_click) -GL_END_MESSAGE_MAP() #endif #ifdef GUILITE_ON static c_keyboard_button s_key_0, s_key_1, s_key_2, s_key_3, s_key_4, s_key_5, s_key_6, s_key_7, s_key_8, s_key_9; @@ -4375,7 +4265,4 @@ WND_TREE g_number_board_children[] = {&s_key_enter,'\n', 0, POS_X(3), POS_Y(2), KEY_WIDTH, KEY_HEIGHT * 2 + 2}, {0,0,0,0,0,0,0} }; -GL_BEGIN_MESSAGE_MAP(c_keyboard) -ON_GL_BN_CLICKED(c_keyboard::on_key_clicked) -GL_END_MESSAGE_MAP() #endif diff --git a/HelloPendulum/UIcode/GuiLite.h b/HelloPendulum/UIcode/GuiLite.h index 4df4afa..e397552 100644 --- a/HelloPendulum/UIcode/GuiLite.h +++ b/HelloPendulum/UIcode/GuiLite.h @@ -48,7 +48,7 @@ T_TIME second_to_day(long second); T_TIME get_time(); void start_real_timer(void (*func)(void* arg)); -void register_timer(int milli_second, void func(void* ptmr, void* parg)); +void register_timer(int milli_second, void func(void* param), void* param); unsigned int get_cur_thread_id(); void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg); @@ -102,123 +102,6 @@ public: int m_right; int m_bottom; }; -#define MSG_TYPE_INVALID 0xFFFF -#define MSG_TYPE_WND 0x0001 -#define MSG_TYPE_USR 0x0002 -#define USR_MSG_MAX 32 -class c_cmd_target; -typedef void (c_cmd_target::*msgCallback)(int, int); -struct GL_MSG_ENTRY -{ - unsigned int msgType; - unsigned int msgId; - c_cmd_target* object; - msgCallback callBack; -}; -#define ON_GL_USER_MSG(msgId, func) \ -{MSG_TYPE_USR, msgId, 0, msgCallback(&func)}, -#define GL_DECLARE_MESSAGE_MAP() \ -protected: \ - virtual const GL_MSG_ENTRY* get_msg_entries() const;\ -private: \ - static const GL_MSG_ENTRY m_msg_entries[]; -#define GL_BEGIN_MESSAGE_MAP(theClass) \ -const GL_MSG_ENTRY* theClass::get_msg_entries() const \ -{ \ - return theClass::m_msg_entries; \ -} \ -const GL_MSG_ENTRY theClass::m_msg_entries[] = \ -{ -#define GL_END_MESSAGE_MAP() \ -{MSG_TYPE_INVALID, 0, 0, 0}}; -class c_cmd_target -{ -public: - static int handle_usr_msg(int msg_id, int resource_id, int param) - { - int i; - c_cmd_target* p_wnd = 0; - for (i = 0; i < ms_user_map_size; i++) - { - if (msg_id == ms_usr_map_entries[i].msgId) - { - p_wnd = (c_cmd_target*)ms_usr_map_entries[i].object; - (p_wnd->*ms_usr_map_entries[i].callBack)(resource_id, param); - } - } - return 1; - } -protected: - void load_cmd_msg() - { - const GL_MSG_ENTRY* p_entry = get_msg_entries(); - if (0 == p_entry) - { - return; - } - bool bExist = false; - while (MSG_TYPE_INVALID != p_entry->msgType) - { - if (MSG_TYPE_WND == p_entry->msgType) - { - p_entry++; - continue; - } - bExist = false; - for (int i = 0; i < ms_user_map_size; i++) - { - //repeat register, return. - if (p_entry->msgId == ms_usr_map_entries[i].msgId - && ms_usr_map_entries[i].object == this) - { - bExist = true; - break; - } - } - if (true == bExist) - { - p_entry++; - continue; - } - if (MSG_TYPE_USR == p_entry->msgType) - { - if (USR_MSG_MAX == ms_user_map_size) - { - ASSERT(false); - } - ms_usr_map_entries[ms_user_map_size] = *p_entry; - ms_usr_map_entries[ms_user_map_size].object = this; - ms_user_map_size++; - } - else - { - ASSERT(false); - break; - } - p_entry++; - } - } - const GL_MSG_ENTRY* find_msg_entry(const GL_MSG_ENTRY *pEntry, int msgType, int msgId) - { - if (MSG_TYPE_INVALID == msgType) - { - return 0; - } - while (MSG_TYPE_INVALID != pEntry->msgType) - { - if ((msgType == pEntry->msgType) && (msgId == pEntry->msgId)) - { - return pEntry; - } - pEntry++; - } - return 0; - } -private: - static GL_MSG_ENTRY ms_usr_map_entries[USR_MSG_MAX]; - static unsigned short ms_user_map_size; - GL_DECLARE_MESSAGE_MAP() -}; //BITMAP typedef struct struct_bitmap_info { @@ -1329,9 +1212,9 @@ typedef struct struct_wnd_tree short height; struct struct_wnd_tree* p_child_tree;//sub tree }WND_TREE; -class c_wnd : public c_cmd_target +typedef void (c_wnd::*WND_CALLBACK)(int, int); +class c_wnd { - friend class c_dialog; public: c_wnd() : m_status(STATUS_NORMAL), m_attr((WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS)), m_parent(0), m_top_child(0), m_prev_sibling(0), m_next_sibling(0), m_str(0), m_font_color(0), m_bg_color(0), m_id(0), m_z_order(Z_ORDER_LEVEL_0), m_focus_child(0), m_surface(0) {}; @@ -1370,7 +1253,6 @@ public: } if (load_child_wnd(p_child_tree) >= 0) { - load_cmd_msg(); on_init_children(); } return 0; @@ -1549,19 +1431,6 @@ public: } c_wnd* get_prev_sibling() const { return m_prev_sibling; } c_wnd* get_next_sibling() const { return m_next_sibling; } - void notify_parent(int msg_id, int param) - { - if (!m_parent) - { - return; - } - const GL_MSG_ENTRY* entry = m_parent->find_msg_entry(m_parent->get_msg_entries(), MSG_TYPE_WND, msg_id); - if (0 == entry) - { - return; - } - (m_parent->*(entry->callBack))(m_id, param); - } virtual void on_touch(int x, int y, TOUCH_ACTION action) { x -= m_wnd_rect.m_left; @@ -1733,6 +1602,7 @@ protected: virtual void on_focus() {}; virtual void on_kill_focus() {}; protected: + unsigned short m_id; WND_STATUS m_status; WND_ATTRIBUTION m_attr; c_rect m_wnd_rect; //position relative to parent window. @@ -1740,23 +1610,18 @@ protected: c_wnd* m_top_child; //the first sub window would be navigated c_wnd* m_prev_sibling; //previous brother c_wnd* m_next_sibling; //next brother + c_wnd* m_focus_child; //current focused window const char* m_str; //caption const FONT_INFO* m_font_type; unsigned int m_font_color; unsigned int m_bg_color; - unsigned short m_id; int m_z_order; //the graphic level for rendering - c_wnd* m_focus_child; //current focused window c_surface* m_surface; -private: - c_wnd(const c_wnd &win); - c_wnd& operator=(const c_wnd &win); }; -#define GL_BN_CLICKED 0x1111 -#define ON_GL_BN_CLICKED(func) {MSG_TYPE_WND, GL_BN_CLICKED, 0, msgCallback(&func)}, -typedef struct struct_bitmap_info BITMAP_INFO; class c_button : public c_wnd { +public: + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void on_paint() { @@ -1803,6 +1668,7 @@ protected: } virtual void pre_create_wnd() { + on_click = 0; m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS); m_font_type = c_theme::get_font(FONT_DEFAULT); m_font_color = c_theme::get_color(COLOR_WND_FONT); @@ -1819,7 +1685,10 @@ protected: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_BN_CLICKED, 0); + if(on_click) + { + (m_parent->*(on_click))(m_id, 0); + } } } virtual void on_navigate(NAVIGATION_KEY key) @@ -1836,6 +1705,7 @@ protected: } return c_wnd::on_navigate(key); } + WND_CALLBACK on_click; }; class c_surface; class c_dialog; @@ -2006,8 +1876,21 @@ public: } return -1; } + virtual void on_init_children() + { + c_wnd* child = m_top_child; + if (0 != child) + { + while (child) + { + ((c_button*)child)->set_on_click(WND_CALLBACK(&c_keyboard::on_key_clicked)); + child = child->get_next_sibling(); + } + } + } KEYBOARD_STATUS get_cap_status(){return m_cap_status;} char* get_str() { return m_str; } + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void pre_create_wnd() { @@ -2064,7 +1947,7 @@ protected: ASSERT(false); InputChar: m_str[m_str_len++] = id; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_del_clicked(int id, int param) { @@ -2073,7 +1956,7 @@ protected: return; } m_str[--m_str_len] = 0; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_caps_clicked(int id, int param) { @@ -2083,18 +1966,18 @@ protected: void on_enter_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - return notify_parent(KEYBORAD_CLICK, CLICK_ENTER); + (m_parent->*(on_click))(m_id, CLICK_ENTER); } void on_esc_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - notify_parent(KEYBORAD_CLICK, CLICK_ESC); + (m_parent->*(on_click))(m_id, CLICK_ESC); } - GL_DECLARE_MESSAGE_MAP() private: char m_str[32]; int m_str_len; KEYBOARD_STATUS m_cap_status; + WND_CALLBACK on_click; }; class c_keyboard_button : public c_button { @@ -2284,11 +2167,11 @@ protected: break; } } - GL_DECLARE_MESSAGE_MAP() private: void show_keyboard() { s_keyboard.connect(this, IDD_KEY_BOARD, m_kb_style); + s_keyboard.set_on_click(WND_CALLBACK(&c_edit::on_key_board_click)); s_keyboard.show_window(); } void on_touch_down(int x, int y) @@ -2368,12 +2251,12 @@ protected: }; #include #define MAX_ITEM_NUM 4 -#define GL_LIST_CONFIRM 0x1 #define ITEM_HEIGHT 45 -#define ON_LIST_CONFIRM(func) {MSG_TYPE_WND, GL_LIST_CONFIRM, 0, msgCallback(&func)}, class c_list_box : public c_wnd { public: + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } + short get_item_count() { return m_item_total; } int add_item(char* str) { if (m_item_total >= MAX_ITEM_NUM) @@ -2391,7 +2274,6 @@ public: memset(m_item_array, 0, sizeof(m_item_array)); update_list_size(); } - short get_item_count() { return m_item_total; } void select_item(short index) { if (index < 0 || index >= m_item_total) @@ -2546,7 +2428,10 @@ private: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } } } @@ -2569,7 +2454,10 @@ private: m_status = STATUS_FOCUSED; select_item((y - m_list_wnd_rect.m_top) / ITEM_HEIGHT); on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } else { @@ -2582,6 +2470,7 @@ private: char* m_item_array[MAX_ITEM_NUM]; c_rect m_list_wnd_rect; //rect relative to parent wnd. c_rect m_list_screen_rect; //rect relative to physical screen(frame buffer) + WND_CALLBACK on_change; }; #include #define MAX_PAGES 5 @@ -2920,8 +2809,6 @@ inline void c_slide_group::on_touch(int x, int y, TOUCH_ACTION action) } #define ID_BT_ARROW_UP 0x1111 #define ID_BT_ARROW_DOWN 0x2222 -#define GL_SPIN_CHANGE 0x3333 -#define ON_SPIN_CHANGE(func) {MSG_TYPE_WND, GL_SPIN_CHANGE, 0, msgCallback(&func)}, class c_spin_box; class c_spin_button : public c_button { @@ -2942,6 +2829,7 @@ public: short get_step() { return m_step; } void set_value_digit(short digit) { m_digit = digit; } short get_value_digit() { return m_digit; } + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } protected: virtual void on_paint() { @@ -2974,7 +2862,10 @@ protected: return; } m_cur_value += m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } void on_arrow_down_bt_click() @@ -2984,7 +2875,10 @@ protected: return; } m_cur_value -= m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } short m_cur_value; @@ -2995,6 +2889,7 @@ protected: short m_digit; c_spin_button m_bt_up; c_spin_button m_bt_down; + WND_CALLBACK on_change; }; inline void c_spin_button::on_touch(int x, int y, TOUCH_ACTION action) { @@ -3451,12 +3346,6 @@ private: unsigned char m_frame_len_map[64]; unsigned char m_frame_len_map_index; }; -#ifdef GUILITE_ON -GL_MSG_ENTRY c_cmd_target::ms_usr_map_entries[USR_MSG_MAX]; -unsigned short c_cmd_target::ms_user_map_size; -GL_BEGIN_MESSAGE_MAP(c_cmd_target) -GL_END_MESSAGE_MAP() -#endif #ifdef GUILITE_ON @@ -3521,7 +3410,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3542,7 +3432,7 @@ static void* timer_routine(void*) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } usleep(1000 * TIMER_UNIT); @@ -3562,7 +3452,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc)(void* param), void* param) { init_mul_timer(); int i; @@ -3578,6 +3468,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -3641,9 +3532,9 @@ unsigned int get_cur_thread_id() { return (unsigned long)pthread_self(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -4002,7 +3893,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -4023,7 +3915,7 @@ DWORD WINAPI timer_routine(LPVOID lpParam) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } Sleep(TIMER_UNIT); @@ -4043,7 +3935,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc) (void* param), void* param) { init_mul_timer(); int i; @@ -4059,6 +3951,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -4126,9 +4019,9 @@ unsigned int get_cur_thread_id() { return GetCurrentThreadId(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -4305,9 +4198,6 @@ DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX]; #endif #ifdef GUILITE_ON c_keyboard c_edit::s_keyboard; -GL_BEGIN_MESSAGE_MAP(c_edit) -ON_KEYBORAD_UPDATE(c_edit::on_key_board_click) -GL_END_MESSAGE_MAP() #endif #ifdef GUILITE_ON static c_keyboard_button s_key_0, s_key_1, s_key_2, s_key_3, s_key_4, s_key_5, s_key_6, s_key_7, s_key_8, s_key_9; @@ -4375,7 +4265,4 @@ WND_TREE g_number_board_children[] = {&s_key_enter,'\n', 0, POS_X(3), POS_Y(2), KEY_WIDTH, KEY_HEIGHT * 2 + 2}, {0,0,0,0,0,0,0} }; -GL_BEGIN_MESSAGE_MAP(c_keyboard) -ON_GL_BN_CLICKED(c_keyboard::on_key_clicked) -GL_END_MESSAGE_MAP() #endif diff --git a/HelloScroll/UIcode/GuiLite.h b/HelloScroll/UIcode/GuiLite.h index de5a678..e397552 100644 --- a/HelloScroll/UIcode/GuiLite.h +++ b/HelloScroll/UIcode/GuiLite.h @@ -48,7 +48,7 @@ T_TIME second_to_day(long second); T_TIME get_time(); void start_real_timer(void (*func)(void* arg)); -void register_timer(int milli_second, void func(void* ptmr, void* parg)); +void register_timer(int milli_second, void func(void* param), void* param); unsigned int get_cur_thread_id(); void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg); @@ -1668,6 +1668,7 @@ protected: } virtual void pre_create_wnd() { + on_click = 0; m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS); m_font_type = c_theme::get_font(FONT_DEFAULT); m_font_color = c_theme::get_color(COLOR_WND_FONT); @@ -1704,7 +1705,7 @@ protected: } return c_wnd::on_navigate(key); } - WND_CALLBACK on_click = 0; + WND_CALLBACK on_click; }; class c_surface; class c_dialog; @@ -3409,7 +3410,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3430,7 +3432,7 @@ static void* timer_routine(void*) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } usleep(1000 * TIMER_UNIT); @@ -3450,7 +3452,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc)(void* param), void* param) { init_mul_timer(); int i; @@ -3466,6 +3468,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -3529,9 +3532,9 @@ unsigned int get_cur_thread_id() { return (unsigned long)pthread_self(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -3890,7 +3893,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3911,7 +3915,7 @@ DWORD WINAPI timer_routine(LPVOID lpParam) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } Sleep(TIMER_UNIT); @@ -3931,7 +3935,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc) (void* param), void* param) { init_mul_timer(); int i; @@ -3947,6 +3951,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -4014,9 +4019,9 @@ unsigned int get_cur_thread_id() { return GetCurrentThreadId(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { diff --git a/HelloSlide/UIcode/GuiLite.h b/HelloSlide/UIcode/GuiLite.h index 4df4afa..e397552 100644 --- a/HelloSlide/UIcode/GuiLite.h +++ b/HelloSlide/UIcode/GuiLite.h @@ -48,7 +48,7 @@ T_TIME second_to_day(long second); T_TIME get_time(); void start_real_timer(void (*func)(void* arg)); -void register_timer(int milli_second, void func(void* ptmr, void* parg)); +void register_timer(int milli_second, void func(void* param), void* param); unsigned int get_cur_thread_id(); void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg); @@ -102,123 +102,6 @@ public: int m_right; int m_bottom; }; -#define MSG_TYPE_INVALID 0xFFFF -#define MSG_TYPE_WND 0x0001 -#define MSG_TYPE_USR 0x0002 -#define USR_MSG_MAX 32 -class c_cmd_target; -typedef void (c_cmd_target::*msgCallback)(int, int); -struct GL_MSG_ENTRY -{ - unsigned int msgType; - unsigned int msgId; - c_cmd_target* object; - msgCallback callBack; -}; -#define ON_GL_USER_MSG(msgId, func) \ -{MSG_TYPE_USR, msgId, 0, msgCallback(&func)}, -#define GL_DECLARE_MESSAGE_MAP() \ -protected: \ - virtual const GL_MSG_ENTRY* get_msg_entries() const;\ -private: \ - static const GL_MSG_ENTRY m_msg_entries[]; -#define GL_BEGIN_MESSAGE_MAP(theClass) \ -const GL_MSG_ENTRY* theClass::get_msg_entries() const \ -{ \ - return theClass::m_msg_entries; \ -} \ -const GL_MSG_ENTRY theClass::m_msg_entries[] = \ -{ -#define GL_END_MESSAGE_MAP() \ -{MSG_TYPE_INVALID, 0, 0, 0}}; -class c_cmd_target -{ -public: - static int handle_usr_msg(int msg_id, int resource_id, int param) - { - int i; - c_cmd_target* p_wnd = 0; - for (i = 0; i < ms_user_map_size; i++) - { - if (msg_id == ms_usr_map_entries[i].msgId) - { - p_wnd = (c_cmd_target*)ms_usr_map_entries[i].object; - (p_wnd->*ms_usr_map_entries[i].callBack)(resource_id, param); - } - } - return 1; - } -protected: - void load_cmd_msg() - { - const GL_MSG_ENTRY* p_entry = get_msg_entries(); - if (0 == p_entry) - { - return; - } - bool bExist = false; - while (MSG_TYPE_INVALID != p_entry->msgType) - { - if (MSG_TYPE_WND == p_entry->msgType) - { - p_entry++; - continue; - } - bExist = false; - for (int i = 0; i < ms_user_map_size; i++) - { - //repeat register, return. - if (p_entry->msgId == ms_usr_map_entries[i].msgId - && ms_usr_map_entries[i].object == this) - { - bExist = true; - break; - } - } - if (true == bExist) - { - p_entry++; - continue; - } - if (MSG_TYPE_USR == p_entry->msgType) - { - if (USR_MSG_MAX == ms_user_map_size) - { - ASSERT(false); - } - ms_usr_map_entries[ms_user_map_size] = *p_entry; - ms_usr_map_entries[ms_user_map_size].object = this; - ms_user_map_size++; - } - else - { - ASSERT(false); - break; - } - p_entry++; - } - } - const GL_MSG_ENTRY* find_msg_entry(const GL_MSG_ENTRY *pEntry, int msgType, int msgId) - { - if (MSG_TYPE_INVALID == msgType) - { - return 0; - } - while (MSG_TYPE_INVALID != pEntry->msgType) - { - if ((msgType == pEntry->msgType) && (msgId == pEntry->msgId)) - { - return pEntry; - } - pEntry++; - } - return 0; - } -private: - static GL_MSG_ENTRY ms_usr_map_entries[USR_MSG_MAX]; - static unsigned short ms_user_map_size; - GL_DECLARE_MESSAGE_MAP() -}; //BITMAP typedef struct struct_bitmap_info { @@ -1329,9 +1212,9 @@ typedef struct struct_wnd_tree short height; struct struct_wnd_tree* p_child_tree;//sub tree }WND_TREE; -class c_wnd : public c_cmd_target +typedef void (c_wnd::*WND_CALLBACK)(int, int); +class c_wnd { - friend class c_dialog; public: c_wnd() : m_status(STATUS_NORMAL), m_attr((WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS)), m_parent(0), m_top_child(0), m_prev_sibling(0), m_next_sibling(0), m_str(0), m_font_color(0), m_bg_color(0), m_id(0), m_z_order(Z_ORDER_LEVEL_0), m_focus_child(0), m_surface(0) {}; @@ -1370,7 +1253,6 @@ public: } if (load_child_wnd(p_child_tree) >= 0) { - load_cmd_msg(); on_init_children(); } return 0; @@ -1549,19 +1431,6 @@ public: } c_wnd* get_prev_sibling() const { return m_prev_sibling; } c_wnd* get_next_sibling() const { return m_next_sibling; } - void notify_parent(int msg_id, int param) - { - if (!m_parent) - { - return; - } - const GL_MSG_ENTRY* entry = m_parent->find_msg_entry(m_parent->get_msg_entries(), MSG_TYPE_WND, msg_id); - if (0 == entry) - { - return; - } - (m_parent->*(entry->callBack))(m_id, param); - } virtual void on_touch(int x, int y, TOUCH_ACTION action) { x -= m_wnd_rect.m_left; @@ -1733,6 +1602,7 @@ protected: virtual void on_focus() {}; virtual void on_kill_focus() {}; protected: + unsigned short m_id; WND_STATUS m_status; WND_ATTRIBUTION m_attr; c_rect m_wnd_rect; //position relative to parent window. @@ -1740,23 +1610,18 @@ protected: c_wnd* m_top_child; //the first sub window would be navigated c_wnd* m_prev_sibling; //previous brother c_wnd* m_next_sibling; //next brother + c_wnd* m_focus_child; //current focused window const char* m_str; //caption const FONT_INFO* m_font_type; unsigned int m_font_color; unsigned int m_bg_color; - unsigned short m_id; int m_z_order; //the graphic level for rendering - c_wnd* m_focus_child; //current focused window c_surface* m_surface; -private: - c_wnd(const c_wnd &win); - c_wnd& operator=(const c_wnd &win); }; -#define GL_BN_CLICKED 0x1111 -#define ON_GL_BN_CLICKED(func) {MSG_TYPE_WND, GL_BN_CLICKED, 0, msgCallback(&func)}, -typedef struct struct_bitmap_info BITMAP_INFO; class c_button : public c_wnd { +public: + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void on_paint() { @@ -1803,6 +1668,7 @@ protected: } virtual void pre_create_wnd() { + on_click = 0; m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS); m_font_type = c_theme::get_font(FONT_DEFAULT); m_font_color = c_theme::get_color(COLOR_WND_FONT); @@ -1819,7 +1685,10 @@ protected: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_BN_CLICKED, 0); + if(on_click) + { + (m_parent->*(on_click))(m_id, 0); + } } } virtual void on_navigate(NAVIGATION_KEY key) @@ -1836,6 +1705,7 @@ protected: } return c_wnd::on_navigate(key); } + WND_CALLBACK on_click; }; class c_surface; class c_dialog; @@ -2006,8 +1876,21 @@ public: } return -1; } + virtual void on_init_children() + { + c_wnd* child = m_top_child; + if (0 != child) + { + while (child) + { + ((c_button*)child)->set_on_click(WND_CALLBACK(&c_keyboard::on_key_clicked)); + child = child->get_next_sibling(); + } + } + } KEYBOARD_STATUS get_cap_status(){return m_cap_status;} char* get_str() { return m_str; } + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void pre_create_wnd() { @@ -2064,7 +1947,7 @@ protected: ASSERT(false); InputChar: m_str[m_str_len++] = id; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_del_clicked(int id, int param) { @@ -2073,7 +1956,7 @@ protected: return; } m_str[--m_str_len] = 0; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_caps_clicked(int id, int param) { @@ -2083,18 +1966,18 @@ protected: void on_enter_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - return notify_parent(KEYBORAD_CLICK, CLICK_ENTER); + (m_parent->*(on_click))(m_id, CLICK_ENTER); } void on_esc_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - notify_parent(KEYBORAD_CLICK, CLICK_ESC); + (m_parent->*(on_click))(m_id, CLICK_ESC); } - GL_DECLARE_MESSAGE_MAP() private: char m_str[32]; int m_str_len; KEYBOARD_STATUS m_cap_status; + WND_CALLBACK on_click; }; class c_keyboard_button : public c_button { @@ -2284,11 +2167,11 @@ protected: break; } } - GL_DECLARE_MESSAGE_MAP() private: void show_keyboard() { s_keyboard.connect(this, IDD_KEY_BOARD, m_kb_style); + s_keyboard.set_on_click(WND_CALLBACK(&c_edit::on_key_board_click)); s_keyboard.show_window(); } void on_touch_down(int x, int y) @@ -2368,12 +2251,12 @@ protected: }; #include #define MAX_ITEM_NUM 4 -#define GL_LIST_CONFIRM 0x1 #define ITEM_HEIGHT 45 -#define ON_LIST_CONFIRM(func) {MSG_TYPE_WND, GL_LIST_CONFIRM, 0, msgCallback(&func)}, class c_list_box : public c_wnd { public: + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } + short get_item_count() { return m_item_total; } int add_item(char* str) { if (m_item_total >= MAX_ITEM_NUM) @@ -2391,7 +2274,6 @@ public: memset(m_item_array, 0, sizeof(m_item_array)); update_list_size(); } - short get_item_count() { return m_item_total; } void select_item(short index) { if (index < 0 || index >= m_item_total) @@ -2546,7 +2428,10 @@ private: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } } } @@ -2569,7 +2454,10 @@ private: m_status = STATUS_FOCUSED; select_item((y - m_list_wnd_rect.m_top) / ITEM_HEIGHT); on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } else { @@ -2582,6 +2470,7 @@ private: char* m_item_array[MAX_ITEM_NUM]; c_rect m_list_wnd_rect; //rect relative to parent wnd. c_rect m_list_screen_rect; //rect relative to physical screen(frame buffer) + WND_CALLBACK on_change; }; #include #define MAX_PAGES 5 @@ -2920,8 +2809,6 @@ inline void c_slide_group::on_touch(int x, int y, TOUCH_ACTION action) } #define ID_BT_ARROW_UP 0x1111 #define ID_BT_ARROW_DOWN 0x2222 -#define GL_SPIN_CHANGE 0x3333 -#define ON_SPIN_CHANGE(func) {MSG_TYPE_WND, GL_SPIN_CHANGE, 0, msgCallback(&func)}, class c_spin_box; class c_spin_button : public c_button { @@ -2942,6 +2829,7 @@ public: short get_step() { return m_step; } void set_value_digit(short digit) { m_digit = digit; } short get_value_digit() { return m_digit; } + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } protected: virtual void on_paint() { @@ -2974,7 +2862,10 @@ protected: return; } m_cur_value += m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } void on_arrow_down_bt_click() @@ -2984,7 +2875,10 @@ protected: return; } m_cur_value -= m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } short m_cur_value; @@ -2995,6 +2889,7 @@ protected: short m_digit; c_spin_button m_bt_up; c_spin_button m_bt_down; + WND_CALLBACK on_change; }; inline void c_spin_button::on_touch(int x, int y, TOUCH_ACTION action) { @@ -3451,12 +3346,6 @@ private: unsigned char m_frame_len_map[64]; unsigned char m_frame_len_map_index; }; -#ifdef GUILITE_ON -GL_MSG_ENTRY c_cmd_target::ms_usr_map_entries[USR_MSG_MAX]; -unsigned short c_cmd_target::ms_user_map_size; -GL_BEGIN_MESSAGE_MAP(c_cmd_target) -GL_END_MESSAGE_MAP() -#endif #ifdef GUILITE_ON @@ -3521,7 +3410,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3542,7 +3432,7 @@ static void* timer_routine(void*) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } usleep(1000 * TIMER_UNIT); @@ -3562,7 +3452,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc)(void* param), void* param) { init_mul_timer(); int i; @@ -3578,6 +3468,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -3641,9 +3532,9 @@ unsigned int get_cur_thread_id() { return (unsigned long)pthread_self(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -4002,7 +3893,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -4023,7 +3915,7 @@ DWORD WINAPI timer_routine(LPVOID lpParam) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } Sleep(TIMER_UNIT); @@ -4043,7 +3935,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc) (void* param), void* param) { init_mul_timer(); int i; @@ -4059,6 +3951,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -4126,9 +4019,9 @@ unsigned int get_cur_thread_id() { return GetCurrentThreadId(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -4305,9 +4198,6 @@ DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX]; #endif #ifdef GUILITE_ON c_keyboard c_edit::s_keyboard; -GL_BEGIN_MESSAGE_MAP(c_edit) -ON_KEYBORAD_UPDATE(c_edit::on_key_board_click) -GL_END_MESSAGE_MAP() #endif #ifdef GUILITE_ON static c_keyboard_button s_key_0, s_key_1, s_key_2, s_key_3, s_key_4, s_key_5, s_key_6, s_key_7, s_key_8, s_key_9; @@ -4375,7 +4265,4 @@ WND_TREE g_number_board_children[] = {&s_key_enter,'\n', 0, POS_X(3), POS_Y(2), KEY_WIDTH, KEY_HEIGHT * 2 + 2}, {0,0,0,0,0,0,0} }; -GL_BEGIN_MESSAGE_MAP(c_keyboard) -ON_GL_BN_CLICKED(c_keyboard::on_key_clicked) -GL_END_MESSAGE_MAP() #endif diff --git a/HelloStar/UIcode/GuiLite.h b/HelloStar/UIcode/GuiLite.h index 4df4afa..e397552 100644 --- a/HelloStar/UIcode/GuiLite.h +++ b/HelloStar/UIcode/GuiLite.h @@ -48,7 +48,7 @@ T_TIME second_to_day(long second); T_TIME get_time(); void start_real_timer(void (*func)(void* arg)); -void register_timer(int milli_second, void func(void* ptmr, void* parg)); +void register_timer(int milli_second, void func(void* param), void* param); unsigned int get_cur_thread_id(); void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg); @@ -102,123 +102,6 @@ public: int m_right; int m_bottom; }; -#define MSG_TYPE_INVALID 0xFFFF -#define MSG_TYPE_WND 0x0001 -#define MSG_TYPE_USR 0x0002 -#define USR_MSG_MAX 32 -class c_cmd_target; -typedef void (c_cmd_target::*msgCallback)(int, int); -struct GL_MSG_ENTRY -{ - unsigned int msgType; - unsigned int msgId; - c_cmd_target* object; - msgCallback callBack; -}; -#define ON_GL_USER_MSG(msgId, func) \ -{MSG_TYPE_USR, msgId, 0, msgCallback(&func)}, -#define GL_DECLARE_MESSAGE_MAP() \ -protected: \ - virtual const GL_MSG_ENTRY* get_msg_entries() const;\ -private: \ - static const GL_MSG_ENTRY m_msg_entries[]; -#define GL_BEGIN_MESSAGE_MAP(theClass) \ -const GL_MSG_ENTRY* theClass::get_msg_entries() const \ -{ \ - return theClass::m_msg_entries; \ -} \ -const GL_MSG_ENTRY theClass::m_msg_entries[] = \ -{ -#define GL_END_MESSAGE_MAP() \ -{MSG_TYPE_INVALID, 0, 0, 0}}; -class c_cmd_target -{ -public: - static int handle_usr_msg(int msg_id, int resource_id, int param) - { - int i; - c_cmd_target* p_wnd = 0; - for (i = 0; i < ms_user_map_size; i++) - { - if (msg_id == ms_usr_map_entries[i].msgId) - { - p_wnd = (c_cmd_target*)ms_usr_map_entries[i].object; - (p_wnd->*ms_usr_map_entries[i].callBack)(resource_id, param); - } - } - return 1; - } -protected: - void load_cmd_msg() - { - const GL_MSG_ENTRY* p_entry = get_msg_entries(); - if (0 == p_entry) - { - return; - } - bool bExist = false; - while (MSG_TYPE_INVALID != p_entry->msgType) - { - if (MSG_TYPE_WND == p_entry->msgType) - { - p_entry++; - continue; - } - bExist = false; - for (int i = 0; i < ms_user_map_size; i++) - { - //repeat register, return. - if (p_entry->msgId == ms_usr_map_entries[i].msgId - && ms_usr_map_entries[i].object == this) - { - bExist = true; - break; - } - } - if (true == bExist) - { - p_entry++; - continue; - } - if (MSG_TYPE_USR == p_entry->msgType) - { - if (USR_MSG_MAX == ms_user_map_size) - { - ASSERT(false); - } - ms_usr_map_entries[ms_user_map_size] = *p_entry; - ms_usr_map_entries[ms_user_map_size].object = this; - ms_user_map_size++; - } - else - { - ASSERT(false); - break; - } - p_entry++; - } - } - const GL_MSG_ENTRY* find_msg_entry(const GL_MSG_ENTRY *pEntry, int msgType, int msgId) - { - if (MSG_TYPE_INVALID == msgType) - { - return 0; - } - while (MSG_TYPE_INVALID != pEntry->msgType) - { - if ((msgType == pEntry->msgType) && (msgId == pEntry->msgId)) - { - return pEntry; - } - pEntry++; - } - return 0; - } -private: - static GL_MSG_ENTRY ms_usr_map_entries[USR_MSG_MAX]; - static unsigned short ms_user_map_size; - GL_DECLARE_MESSAGE_MAP() -}; //BITMAP typedef struct struct_bitmap_info { @@ -1329,9 +1212,9 @@ typedef struct struct_wnd_tree short height; struct struct_wnd_tree* p_child_tree;//sub tree }WND_TREE; -class c_wnd : public c_cmd_target +typedef void (c_wnd::*WND_CALLBACK)(int, int); +class c_wnd { - friend class c_dialog; public: c_wnd() : m_status(STATUS_NORMAL), m_attr((WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS)), m_parent(0), m_top_child(0), m_prev_sibling(0), m_next_sibling(0), m_str(0), m_font_color(0), m_bg_color(0), m_id(0), m_z_order(Z_ORDER_LEVEL_0), m_focus_child(0), m_surface(0) {}; @@ -1370,7 +1253,6 @@ public: } if (load_child_wnd(p_child_tree) >= 0) { - load_cmd_msg(); on_init_children(); } return 0; @@ -1549,19 +1431,6 @@ public: } c_wnd* get_prev_sibling() const { return m_prev_sibling; } c_wnd* get_next_sibling() const { return m_next_sibling; } - void notify_parent(int msg_id, int param) - { - if (!m_parent) - { - return; - } - const GL_MSG_ENTRY* entry = m_parent->find_msg_entry(m_parent->get_msg_entries(), MSG_TYPE_WND, msg_id); - if (0 == entry) - { - return; - } - (m_parent->*(entry->callBack))(m_id, param); - } virtual void on_touch(int x, int y, TOUCH_ACTION action) { x -= m_wnd_rect.m_left; @@ -1733,6 +1602,7 @@ protected: virtual void on_focus() {}; virtual void on_kill_focus() {}; protected: + unsigned short m_id; WND_STATUS m_status; WND_ATTRIBUTION m_attr; c_rect m_wnd_rect; //position relative to parent window. @@ -1740,23 +1610,18 @@ protected: c_wnd* m_top_child; //the first sub window would be navigated c_wnd* m_prev_sibling; //previous brother c_wnd* m_next_sibling; //next brother + c_wnd* m_focus_child; //current focused window const char* m_str; //caption const FONT_INFO* m_font_type; unsigned int m_font_color; unsigned int m_bg_color; - unsigned short m_id; int m_z_order; //the graphic level for rendering - c_wnd* m_focus_child; //current focused window c_surface* m_surface; -private: - c_wnd(const c_wnd &win); - c_wnd& operator=(const c_wnd &win); }; -#define GL_BN_CLICKED 0x1111 -#define ON_GL_BN_CLICKED(func) {MSG_TYPE_WND, GL_BN_CLICKED, 0, msgCallback(&func)}, -typedef struct struct_bitmap_info BITMAP_INFO; class c_button : public c_wnd { +public: + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void on_paint() { @@ -1803,6 +1668,7 @@ protected: } virtual void pre_create_wnd() { + on_click = 0; m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS); m_font_type = c_theme::get_font(FONT_DEFAULT); m_font_color = c_theme::get_color(COLOR_WND_FONT); @@ -1819,7 +1685,10 @@ protected: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_BN_CLICKED, 0); + if(on_click) + { + (m_parent->*(on_click))(m_id, 0); + } } } virtual void on_navigate(NAVIGATION_KEY key) @@ -1836,6 +1705,7 @@ protected: } return c_wnd::on_navigate(key); } + WND_CALLBACK on_click; }; class c_surface; class c_dialog; @@ -2006,8 +1876,21 @@ public: } return -1; } + virtual void on_init_children() + { + c_wnd* child = m_top_child; + if (0 != child) + { + while (child) + { + ((c_button*)child)->set_on_click(WND_CALLBACK(&c_keyboard::on_key_clicked)); + child = child->get_next_sibling(); + } + } + } KEYBOARD_STATUS get_cap_status(){return m_cap_status;} char* get_str() { return m_str; } + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void pre_create_wnd() { @@ -2064,7 +1947,7 @@ protected: ASSERT(false); InputChar: m_str[m_str_len++] = id; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_del_clicked(int id, int param) { @@ -2073,7 +1956,7 @@ protected: return; } m_str[--m_str_len] = 0; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_caps_clicked(int id, int param) { @@ -2083,18 +1966,18 @@ protected: void on_enter_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - return notify_parent(KEYBORAD_CLICK, CLICK_ENTER); + (m_parent->*(on_click))(m_id, CLICK_ENTER); } void on_esc_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - notify_parent(KEYBORAD_CLICK, CLICK_ESC); + (m_parent->*(on_click))(m_id, CLICK_ESC); } - GL_DECLARE_MESSAGE_MAP() private: char m_str[32]; int m_str_len; KEYBOARD_STATUS m_cap_status; + WND_CALLBACK on_click; }; class c_keyboard_button : public c_button { @@ -2284,11 +2167,11 @@ protected: break; } } - GL_DECLARE_MESSAGE_MAP() private: void show_keyboard() { s_keyboard.connect(this, IDD_KEY_BOARD, m_kb_style); + s_keyboard.set_on_click(WND_CALLBACK(&c_edit::on_key_board_click)); s_keyboard.show_window(); } void on_touch_down(int x, int y) @@ -2368,12 +2251,12 @@ protected: }; #include #define MAX_ITEM_NUM 4 -#define GL_LIST_CONFIRM 0x1 #define ITEM_HEIGHT 45 -#define ON_LIST_CONFIRM(func) {MSG_TYPE_WND, GL_LIST_CONFIRM, 0, msgCallback(&func)}, class c_list_box : public c_wnd { public: + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } + short get_item_count() { return m_item_total; } int add_item(char* str) { if (m_item_total >= MAX_ITEM_NUM) @@ -2391,7 +2274,6 @@ public: memset(m_item_array, 0, sizeof(m_item_array)); update_list_size(); } - short get_item_count() { return m_item_total; } void select_item(short index) { if (index < 0 || index >= m_item_total) @@ -2546,7 +2428,10 @@ private: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } } } @@ -2569,7 +2454,10 @@ private: m_status = STATUS_FOCUSED; select_item((y - m_list_wnd_rect.m_top) / ITEM_HEIGHT); on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } else { @@ -2582,6 +2470,7 @@ private: char* m_item_array[MAX_ITEM_NUM]; c_rect m_list_wnd_rect; //rect relative to parent wnd. c_rect m_list_screen_rect; //rect relative to physical screen(frame buffer) + WND_CALLBACK on_change; }; #include #define MAX_PAGES 5 @@ -2920,8 +2809,6 @@ inline void c_slide_group::on_touch(int x, int y, TOUCH_ACTION action) } #define ID_BT_ARROW_UP 0x1111 #define ID_BT_ARROW_DOWN 0x2222 -#define GL_SPIN_CHANGE 0x3333 -#define ON_SPIN_CHANGE(func) {MSG_TYPE_WND, GL_SPIN_CHANGE, 0, msgCallback(&func)}, class c_spin_box; class c_spin_button : public c_button { @@ -2942,6 +2829,7 @@ public: short get_step() { return m_step; } void set_value_digit(short digit) { m_digit = digit; } short get_value_digit() { return m_digit; } + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } protected: virtual void on_paint() { @@ -2974,7 +2862,10 @@ protected: return; } m_cur_value += m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } void on_arrow_down_bt_click() @@ -2984,7 +2875,10 @@ protected: return; } m_cur_value -= m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } short m_cur_value; @@ -2995,6 +2889,7 @@ protected: short m_digit; c_spin_button m_bt_up; c_spin_button m_bt_down; + WND_CALLBACK on_change; }; inline void c_spin_button::on_touch(int x, int y, TOUCH_ACTION action) { @@ -3451,12 +3346,6 @@ private: unsigned char m_frame_len_map[64]; unsigned char m_frame_len_map_index; }; -#ifdef GUILITE_ON -GL_MSG_ENTRY c_cmd_target::ms_usr_map_entries[USR_MSG_MAX]; -unsigned short c_cmd_target::ms_user_map_size; -GL_BEGIN_MESSAGE_MAP(c_cmd_target) -GL_END_MESSAGE_MAP() -#endif #ifdef GUILITE_ON @@ -3521,7 +3410,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3542,7 +3432,7 @@ static void* timer_routine(void*) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } usleep(1000 * TIMER_UNIT); @@ -3562,7 +3452,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc)(void* param), void* param) { init_mul_timer(); int i; @@ -3578,6 +3468,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -3641,9 +3532,9 @@ unsigned int get_cur_thread_id() { return (unsigned long)pthread_self(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -4002,7 +3893,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -4023,7 +3915,7 @@ DWORD WINAPI timer_routine(LPVOID lpParam) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } Sleep(TIMER_UNIT); @@ -4043,7 +3935,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc) (void* param), void* param) { init_mul_timer(); int i; @@ -4059,6 +3951,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -4126,9 +4019,9 @@ unsigned int get_cur_thread_id() { return GetCurrentThreadId(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -4305,9 +4198,6 @@ DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX]; #endif #ifdef GUILITE_ON c_keyboard c_edit::s_keyboard; -GL_BEGIN_MESSAGE_MAP(c_edit) -ON_KEYBORAD_UPDATE(c_edit::on_key_board_click) -GL_END_MESSAGE_MAP() #endif #ifdef GUILITE_ON static c_keyboard_button s_key_0, s_key_1, s_key_2, s_key_3, s_key_4, s_key_5, s_key_6, s_key_7, s_key_8, s_key_9; @@ -4375,7 +4265,4 @@ WND_TREE g_number_board_children[] = {&s_key_enter,'\n', 0, POS_X(3), POS_Y(2), KEY_WIDTH, KEY_HEIGHT * 2 + 2}, {0,0,0,0,0,0,0} }; -GL_BEGIN_MESSAGE_MAP(c_keyboard) -ON_GL_BN_CLICKED(c_keyboard::on_key_clicked) -GL_END_MESSAGE_MAP() #endif diff --git a/HelloTimer/UIcode/GuiLite.h b/HelloTimer/UIcode/GuiLite.h index 4df4afa..e397552 100644 --- a/HelloTimer/UIcode/GuiLite.h +++ b/HelloTimer/UIcode/GuiLite.h @@ -48,7 +48,7 @@ T_TIME second_to_day(long second); T_TIME get_time(); void start_real_timer(void (*func)(void* arg)); -void register_timer(int milli_second, void func(void* ptmr, void* parg)); +void register_timer(int milli_second, void func(void* param), void* param); unsigned int get_cur_thread_id(); void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg); @@ -102,123 +102,6 @@ public: int m_right; int m_bottom; }; -#define MSG_TYPE_INVALID 0xFFFF -#define MSG_TYPE_WND 0x0001 -#define MSG_TYPE_USR 0x0002 -#define USR_MSG_MAX 32 -class c_cmd_target; -typedef void (c_cmd_target::*msgCallback)(int, int); -struct GL_MSG_ENTRY -{ - unsigned int msgType; - unsigned int msgId; - c_cmd_target* object; - msgCallback callBack; -}; -#define ON_GL_USER_MSG(msgId, func) \ -{MSG_TYPE_USR, msgId, 0, msgCallback(&func)}, -#define GL_DECLARE_MESSAGE_MAP() \ -protected: \ - virtual const GL_MSG_ENTRY* get_msg_entries() const;\ -private: \ - static const GL_MSG_ENTRY m_msg_entries[]; -#define GL_BEGIN_MESSAGE_MAP(theClass) \ -const GL_MSG_ENTRY* theClass::get_msg_entries() const \ -{ \ - return theClass::m_msg_entries; \ -} \ -const GL_MSG_ENTRY theClass::m_msg_entries[] = \ -{ -#define GL_END_MESSAGE_MAP() \ -{MSG_TYPE_INVALID, 0, 0, 0}}; -class c_cmd_target -{ -public: - static int handle_usr_msg(int msg_id, int resource_id, int param) - { - int i; - c_cmd_target* p_wnd = 0; - for (i = 0; i < ms_user_map_size; i++) - { - if (msg_id == ms_usr_map_entries[i].msgId) - { - p_wnd = (c_cmd_target*)ms_usr_map_entries[i].object; - (p_wnd->*ms_usr_map_entries[i].callBack)(resource_id, param); - } - } - return 1; - } -protected: - void load_cmd_msg() - { - const GL_MSG_ENTRY* p_entry = get_msg_entries(); - if (0 == p_entry) - { - return; - } - bool bExist = false; - while (MSG_TYPE_INVALID != p_entry->msgType) - { - if (MSG_TYPE_WND == p_entry->msgType) - { - p_entry++; - continue; - } - bExist = false; - for (int i = 0; i < ms_user_map_size; i++) - { - //repeat register, return. - if (p_entry->msgId == ms_usr_map_entries[i].msgId - && ms_usr_map_entries[i].object == this) - { - bExist = true; - break; - } - } - if (true == bExist) - { - p_entry++; - continue; - } - if (MSG_TYPE_USR == p_entry->msgType) - { - if (USR_MSG_MAX == ms_user_map_size) - { - ASSERT(false); - } - ms_usr_map_entries[ms_user_map_size] = *p_entry; - ms_usr_map_entries[ms_user_map_size].object = this; - ms_user_map_size++; - } - else - { - ASSERT(false); - break; - } - p_entry++; - } - } - const GL_MSG_ENTRY* find_msg_entry(const GL_MSG_ENTRY *pEntry, int msgType, int msgId) - { - if (MSG_TYPE_INVALID == msgType) - { - return 0; - } - while (MSG_TYPE_INVALID != pEntry->msgType) - { - if ((msgType == pEntry->msgType) && (msgId == pEntry->msgId)) - { - return pEntry; - } - pEntry++; - } - return 0; - } -private: - static GL_MSG_ENTRY ms_usr_map_entries[USR_MSG_MAX]; - static unsigned short ms_user_map_size; - GL_DECLARE_MESSAGE_MAP() -}; //BITMAP typedef struct struct_bitmap_info { @@ -1329,9 +1212,9 @@ typedef struct struct_wnd_tree short height; struct struct_wnd_tree* p_child_tree;//sub tree }WND_TREE; -class c_wnd : public c_cmd_target +typedef void (c_wnd::*WND_CALLBACK)(int, int); +class c_wnd { - friend class c_dialog; public: c_wnd() : m_status(STATUS_NORMAL), m_attr((WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS)), m_parent(0), m_top_child(0), m_prev_sibling(0), m_next_sibling(0), m_str(0), m_font_color(0), m_bg_color(0), m_id(0), m_z_order(Z_ORDER_LEVEL_0), m_focus_child(0), m_surface(0) {}; @@ -1370,7 +1253,6 @@ public: } if (load_child_wnd(p_child_tree) >= 0) { - load_cmd_msg(); on_init_children(); } return 0; @@ -1549,19 +1431,6 @@ public: } c_wnd* get_prev_sibling() const { return m_prev_sibling; } c_wnd* get_next_sibling() const { return m_next_sibling; } - void notify_parent(int msg_id, int param) - { - if (!m_parent) - { - return; - } - const GL_MSG_ENTRY* entry = m_parent->find_msg_entry(m_parent->get_msg_entries(), MSG_TYPE_WND, msg_id); - if (0 == entry) - { - return; - } - (m_parent->*(entry->callBack))(m_id, param); - } virtual void on_touch(int x, int y, TOUCH_ACTION action) { x -= m_wnd_rect.m_left; @@ -1733,6 +1602,7 @@ protected: virtual void on_focus() {}; virtual void on_kill_focus() {}; protected: + unsigned short m_id; WND_STATUS m_status; WND_ATTRIBUTION m_attr; c_rect m_wnd_rect; //position relative to parent window. @@ -1740,23 +1610,18 @@ protected: c_wnd* m_top_child; //the first sub window would be navigated c_wnd* m_prev_sibling; //previous brother c_wnd* m_next_sibling; //next brother + c_wnd* m_focus_child; //current focused window const char* m_str; //caption const FONT_INFO* m_font_type; unsigned int m_font_color; unsigned int m_bg_color; - unsigned short m_id; int m_z_order; //the graphic level for rendering - c_wnd* m_focus_child; //current focused window c_surface* m_surface; -private: - c_wnd(const c_wnd &win); - c_wnd& operator=(const c_wnd &win); }; -#define GL_BN_CLICKED 0x1111 -#define ON_GL_BN_CLICKED(func) {MSG_TYPE_WND, GL_BN_CLICKED, 0, msgCallback(&func)}, -typedef struct struct_bitmap_info BITMAP_INFO; class c_button : public c_wnd { +public: + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void on_paint() { @@ -1803,6 +1668,7 @@ protected: } virtual void pre_create_wnd() { + on_click = 0; m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS); m_font_type = c_theme::get_font(FONT_DEFAULT); m_font_color = c_theme::get_color(COLOR_WND_FONT); @@ -1819,7 +1685,10 @@ protected: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_BN_CLICKED, 0); + if(on_click) + { + (m_parent->*(on_click))(m_id, 0); + } } } virtual void on_navigate(NAVIGATION_KEY key) @@ -1836,6 +1705,7 @@ protected: } return c_wnd::on_navigate(key); } + WND_CALLBACK on_click; }; class c_surface; class c_dialog; @@ -2006,8 +1876,21 @@ public: } return -1; } + virtual void on_init_children() + { + c_wnd* child = m_top_child; + if (0 != child) + { + while (child) + { + ((c_button*)child)->set_on_click(WND_CALLBACK(&c_keyboard::on_key_clicked)); + child = child->get_next_sibling(); + } + } + } KEYBOARD_STATUS get_cap_status(){return m_cap_status;} char* get_str() { return m_str; } + void set_on_click(WND_CALLBACK on_click) { this->on_click = on_click; } protected: virtual void pre_create_wnd() { @@ -2064,7 +1947,7 @@ protected: ASSERT(false); InputChar: m_str[m_str_len++] = id; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_del_clicked(int id, int param) { @@ -2073,7 +1956,7 @@ protected: return; } m_str[--m_str_len] = 0; - notify_parent(KEYBORAD_CLICK, CLICK_CHAR); + (m_parent->*(on_click))(m_id, CLICK_CHAR); } void on_caps_clicked(int id, int param) { @@ -2083,18 +1966,18 @@ protected: void on_enter_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - return notify_parent(KEYBORAD_CLICK, CLICK_ENTER); + (m_parent->*(on_click))(m_id, CLICK_ENTER); } void on_esc_clicked(int id, int param) { memset(m_str, 0, sizeof(m_str)); - notify_parent(KEYBORAD_CLICK, CLICK_ESC); + (m_parent->*(on_click))(m_id, CLICK_ESC); } - GL_DECLARE_MESSAGE_MAP() private: char m_str[32]; int m_str_len; KEYBOARD_STATUS m_cap_status; + WND_CALLBACK on_click; }; class c_keyboard_button : public c_button { @@ -2284,11 +2167,11 @@ protected: break; } } - GL_DECLARE_MESSAGE_MAP() private: void show_keyboard() { s_keyboard.connect(this, IDD_KEY_BOARD, m_kb_style); + s_keyboard.set_on_click(WND_CALLBACK(&c_edit::on_key_board_click)); s_keyboard.show_window(); } void on_touch_down(int x, int y) @@ -2368,12 +2251,12 @@ protected: }; #include #define MAX_ITEM_NUM 4 -#define GL_LIST_CONFIRM 0x1 #define ITEM_HEIGHT 45 -#define ON_LIST_CONFIRM(func) {MSG_TYPE_WND, GL_LIST_CONFIRM, 0, msgCallback(&func)}, class c_list_box : public c_wnd { public: + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } + short get_item_count() { return m_item_total; } int add_item(char* str) { if (m_item_total >= MAX_ITEM_NUM) @@ -2391,7 +2274,6 @@ public: memset(m_item_array, 0, sizeof(m_item_array)); update_list_size(); } - short get_item_count() { return m_item_total; } void select_item(short index) { if (index < 0 || index >= m_item_total) @@ -2546,7 +2428,10 @@ private: { m_status = STATUS_FOCUSED; on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } } } @@ -2569,7 +2454,10 @@ private: m_status = STATUS_FOCUSED; select_item((y - m_list_wnd_rect.m_top) / ITEM_HEIGHT); on_paint(); - notify_parent(GL_LIST_CONFIRM, m_selected_item); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_selected_item); + } } else { @@ -2582,6 +2470,7 @@ private: char* m_item_array[MAX_ITEM_NUM]; c_rect m_list_wnd_rect; //rect relative to parent wnd. c_rect m_list_screen_rect; //rect relative to physical screen(frame buffer) + WND_CALLBACK on_change; }; #include #define MAX_PAGES 5 @@ -2920,8 +2809,6 @@ inline void c_slide_group::on_touch(int x, int y, TOUCH_ACTION action) } #define ID_BT_ARROW_UP 0x1111 #define ID_BT_ARROW_DOWN 0x2222 -#define GL_SPIN_CHANGE 0x3333 -#define ON_SPIN_CHANGE(func) {MSG_TYPE_WND, GL_SPIN_CHANGE, 0, msgCallback(&func)}, class c_spin_box; class c_spin_button : public c_button { @@ -2942,6 +2829,7 @@ public: short get_step() { return m_step; } void set_value_digit(short digit) { m_digit = digit; } short get_value_digit() { return m_digit; } + void set_on_change(WND_CALLBACK on_change) { this->on_change = on_change; } protected: virtual void on_paint() { @@ -2974,7 +2862,10 @@ protected: return; } m_cur_value += m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } void on_arrow_down_bt_click() @@ -2984,7 +2875,10 @@ protected: return; } m_cur_value -= m_step; - notify_parent(GL_SPIN_CHANGE, m_cur_value); + if(on_change) + { + (m_parent->*(on_change))(m_id, m_cur_value); + } on_paint(); } short m_cur_value; @@ -2995,6 +2889,7 @@ protected: short m_digit; c_spin_button m_bt_up; c_spin_button m_bt_down; + WND_CALLBACK on_change; }; inline void c_spin_button::on_touch(int x, int y, TOUCH_ACTION action) { @@ -3451,12 +3346,6 @@ private: unsigned char m_frame_len_map[64]; unsigned char m_frame_len_map_index; }; -#ifdef GUILITE_ON -GL_MSG_ENTRY c_cmd_target::ms_usr_map_entries[USR_MSG_MAX]; -unsigned short c_cmd_target::ms_user_map_size; -GL_BEGIN_MESSAGE_MAP(c_cmd_target) -GL_END_MESSAGE_MAP() -#endif #ifdef GUILITE_ON @@ -3521,7 +3410,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3542,7 +3432,7 @@ static void* timer_routine(void*) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } usleep(1000 * TIMER_UNIT); @@ -3562,7 +3452,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc)(void* param), void* param) { init_mul_timer(); int i; @@ -3578,6 +3468,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -3641,9 +3532,9 @@ unsigned int get_cur_thread_id() { return (unsigned long)pthread_self(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -4002,7 +3893,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -4023,7 +3915,7 @@ DWORD WINAPI timer_routine(LPVOID lpParam) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } Sleep(TIMER_UNIT); @@ -4043,7 +3935,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc) (void* param), void* param) { init_mul_timer(); int i; @@ -4059,6 +3951,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -4126,9 +4019,9 @@ unsigned int get_cur_thread_id() { return GetCurrentThreadId(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -4305,9 +4198,6 @@ DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX]; #endif #ifdef GUILITE_ON c_keyboard c_edit::s_keyboard; -GL_BEGIN_MESSAGE_MAP(c_edit) -ON_KEYBORAD_UPDATE(c_edit::on_key_board_click) -GL_END_MESSAGE_MAP() #endif #ifdef GUILITE_ON static c_keyboard_button s_key_0, s_key_1, s_key_2, s_key_3, s_key_4, s_key_5, s_key_6, s_key_7, s_key_8, s_key_9; @@ -4375,7 +4265,4 @@ WND_TREE g_number_board_children[] = {&s_key_enter,'\n', 0, POS_X(3), POS_Y(2), KEY_WIDTH, KEY_HEIGHT * 2 + 2}, {0,0,0,0,0,0,0} }; -GL_BEGIN_MESSAGE_MAP(c_keyboard) -ON_GL_BN_CLICKED(c_keyboard::on_key_clicked) -GL_END_MESSAGE_MAP() #endif diff --git a/HelloTransparent/UIcode/GuiLite.h b/HelloTransparent/UIcode/GuiLite.h index de5a678..e397552 100644 --- a/HelloTransparent/UIcode/GuiLite.h +++ b/HelloTransparent/UIcode/GuiLite.h @@ -48,7 +48,7 @@ T_TIME second_to_day(long second); T_TIME get_time(); void start_real_timer(void (*func)(void* arg)); -void register_timer(int milli_second, void func(void* ptmr, void* parg)); +void register_timer(int milli_second, void func(void* param), void* param); unsigned int get_cur_thread_id(); void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg); @@ -1668,6 +1668,7 @@ protected: } virtual void pre_create_wnd() { + on_click = 0; m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS); m_font_type = c_theme::get_font(FONT_DEFAULT); m_font_color = c_theme::get_color(COLOR_WND_FONT); @@ -1704,7 +1705,7 @@ protected: } return c_wnd::on_navigate(key); } - WND_CALLBACK on_click = 0; + WND_CALLBACK on_click; }; class c_surface; class c_dialog; @@ -3409,7 +3410,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3430,7 +3432,7 @@ static void* timer_routine(void*) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } usleep(1000 * TIMER_UNIT); @@ -3450,7 +3452,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc)(void* param), void* param) { init_mul_timer(); int i; @@ -3466,6 +3468,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -3529,9 +3532,9 @@ unsigned int get_cur_thread_id() { return (unsigned long)pthread_self(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -3890,7 +3893,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3911,7 +3915,7 @@ DWORD WINAPI timer_routine(LPVOID lpParam) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } Sleep(TIMER_UNIT); @@ -3931,7 +3935,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc) (void* param), void* param) { init_mul_timer(); int i; @@ -3947,6 +3951,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -4014,9 +4019,9 @@ unsigned int get_cur_thread_id() { return GetCurrentThreadId(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { diff --git a/HelloWave/UIcode/GuiLite.h b/HelloWave/UIcode/GuiLite.h index de5a678..e397552 100644 --- a/HelloWave/UIcode/GuiLite.h +++ b/HelloWave/UIcode/GuiLite.h @@ -48,7 +48,7 @@ T_TIME second_to_day(long second); T_TIME get_time(); void start_real_timer(void (*func)(void* arg)); -void register_timer(int milli_second, void func(void* ptmr, void* parg)); +void register_timer(int milli_second, void func(void* param), void* param); unsigned int get_cur_thread_id(); void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg); @@ -1668,6 +1668,7 @@ protected: } virtual void pre_create_wnd() { + on_click = 0; m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS); m_font_type = c_theme::get_font(FONT_DEFAULT); m_font_color = c_theme::get_color(COLOR_WND_FONT); @@ -1704,7 +1705,7 @@ protected: } return c_wnd::on_navigate(key); } - WND_CALLBACK on_click = 0; + WND_CALLBACK on_click; }; class c_surface; class c_dialog; @@ -3409,7 +3410,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3430,7 +3432,7 @@ static void* timer_routine(void*) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } usleep(1000 * TIMER_UNIT); @@ -3450,7 +3452,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc)(void* param), void* param) { init_mul_timer(); int i; @@ -3466,6 +3468,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -3529,9 +3532,9 @@ unsigned int get_cur_thread_id() { return (unsigned long)pthread_self(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -3890,7 +3893,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3911,7 +3915,7 @@ DWORD WINAPI timer_routine(LPVOID lpParam) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } Sleep(TIMER_UNIT); @@ -3931,7 +3935,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc) (void* param), void* param) { init_mul_timer(); int i; @@ -3947,6 +3951,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -4014,9 +4019,9 @@ unsigned int get_cur_thread_id() { return GetCurrentThreadId(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { diff --git a/HelloWidgets/UIcode/GuiLite.h b/HelloWidgets/UIcode/GuiLite.h index de5a678..e397552 100644 --- a/HelloWidgets/UIcode/GuiLite.h +++ b/HelloWidgets/UIcode/GuiLite.h @@ -48,7 +48,7 @@ T_TIME second_to_day(long second); T_TIME get_time(); void start_real_timer(void (*func)(void* arg)); -void register_timer(int milli_second, void func(void* ptmr, void* parg)); +void register_timer(int milli_second, void func(void* param), void* param); unsigned int get_cur_thread_id(); void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg); @@ -1668,6 +1668,7 @@ protected: } virtual void pre_create_wnd() { + on_click = 0; m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS); m_font_type = c_theme::get_font(FONT_DEFAULT); m_font_color = c_theme::get_color(COLOR_WND_FONT); @@ -1704,7 +1705,7 @@ protected: } return c_wnd::on_navigate(key); } - WND_CALLBACK on_click = 0; + WND_CALLBACK on_click; }; class c_surface; class c_dialog; @@ -3409,7 +3410,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3430,7 +3432,7 @@ static void* timer_routine(void*) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } usleep(1000 * TIMER_UNIT); @@ -3450,7 +3452,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc)(void* param), void* param) { init_mul_timer(); int i; @@ -3466,6 +3468,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -3529,9 +3532,9 @@ unsigned int get_cur_thread_id() { return (unsigned long)pthread_self(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -3890,7 +3893,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3911,7 +3915,7 @@ DWORD WINAPI timer_routine(LPVOID lpParam) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } Sleep(TIMER_UNIT); @@ -3931,7 +3935,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc) (void* param), void* param) { init_mul_timer(); int i; @@ -3947,6 +3951,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -4014,9 +4019,9 @@ unsigned int get_cur_thread_id() { return GetCurrentThreadId(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { diff --git a/HostMonitor/UIcode/include/GuiLite.h b/HostMonitor/UIcode/include/GuiLite.h index de5a678..e397552 100644 --- a/HostMonitor/UIcode/include/GuiLite.h +++ b/HostMonitor/UIcode/include/GuiLite.h @@ -48,7 +48,7 @@ T_TIME second_to_day(long second); T_TIME get_time(); void start_real_timer(void (*func)(void* arg)); -void register_timer(int milli_second, void func(void* ptmr, void* parg)); +void register_timer(int milli_second, void func(void* param), void* param); unsigned int get_cur_thread_id(); void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg); @@ -1668,6 +1668,7 @@ protected: } virtual void pre_create_wnd() { + on_click = 0; m_attr = (WND_ATTRIBUTION)(ATTR_VISIBLE | ATTR_FOCUS); m_font_type = c_theme::get_font(FONT_DEFAULT); m_font_color = c_theme::get_color(COLOR_WND_FONT); @@ -1704,7 +1705,7 @@ protected: } return c_wnd::on_navigate(key); } - WND_CALLBACK on_click = 0; + WND_CALLBACK on_click; }; class c_surface; class c_dialog; @@ -3409,7 +3410,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3430,7 +3432,7 @@ static void* timer_routine(void*) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } usleep(1000 * TIMER_UNIT); @@ -3450,7 +3452,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc)(void* param), void* param) { init_mul_timer(); int i; @@ -3466,6 +3468,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -3529,9 +3532,9 @@ unsigned int get_cur_thread_id() { return (unsigned long)pthread_self(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { @@ -3890,7 +3893,8 @@ typedef struct _timer_manage int state; /* on or off */ int interval; int elapse; /* 0~interval */ - void (* timer_proc) (void* ptmr, void* parg); + void (* timer_proc) (void* param); + void* param; }timer_info[MAX_TIMER_CNT]; void (* old_sigfunc)(int); void (* new_sigfunc)(int); @@ -3911,7 +3915,7 @@ DWORD WINAPI timer_routine(LPVOID lpParam) if(timer_manage.timer_info[i].elapse == timer_manage.timer_info[i].interval) { timer_manage.timer_info[i].elapse = 0; - timer_manage.timer_info[i].timer_proc(0, 0); + timer_manage.timer_info[i].timer_proc(timer_manage.timer_info[i].param); } } Sleep(TIMER_UNIT); @@ -3931,7 +3935,7 @@ static int init_mul_timer() s_is_init = true; return 1; } -static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg)) +static int set_a_timer(int interval, void (* timer_proc) (void* param), void* param) { init_mul_timer(); int i; @@ -3947,6 +3951,7 @@ static int set_a_timer(int interval, void (* timer_proc) (void* ptmr, void* parg } memset(&timer_manage.timer_info[i], 0, sizeof(timer_manage.timer_info[i])); timer_manage.timer_info[i].timer_proc = timer_proc; + timer_manage.timer_info[i].param = param; timer_manage.timer_info[i].interval = interval; timer_manage.timer_info[i].elapse = 0; timer_manage.timer_info[i].state = 1; @@ -4014,9 +4019,9 @@ unsigned int get_cur_thread_id() { return GetCurrentThreadId(); } -void register_timer(int milli_second,void func(void* ptmr, void* parg)) +void register_timer(int milli_second,void func(void* param), void* param) { - set_a_timer(milli_second/TIMER_UNIT,func); + set_a_timer(milli_second/TIMER_UNIT,func, param); } long get_time_in_second() { diff --git a/HostMonitor/UIcode/include/ctrl_id.h b/HostMonitor/UIcode/include/ctrl_id.h index 6d77588..c571419 100644 --- a/HostMonitor/UIcode/include/ctrl_id.h +++ b/HostMonitor/UIcode/include/ctrl_id.h @@ -106,7 +106,9 @@ typedef enum e_ctrlid * dialog ****************************************/ //patient setup dialog - IDD_SETUP_DLG, + ID_SETUP_BUTTON, + ID_ABOUT_BUTTON, + ID_SETUP_DLG, ID_SETUP_DLG_EDIT_FIRST_NAME, ID_SETUP_DLG_EDIT_SECOND_NAME, ID_SETUP_DLG_LB_PATIENT_TYPE, diff --git a/HostMonitor/UIcode/include/msg_id.h b/HostMonitor/UIcode/include/msg_id.h index 2139999..4077e15 100644 --- a/HostMonitor/UIcode/include/msg_id.h +++ b/HostMonitor/UIcode/include/msg_id.h @@ -11,7 +11,7 @@ typedef struct typedef enum e_app_msg { USR_MSG_UPDATE_TIME = 0x5300, - USR_MSG_UPDATE_TREND_VIEW + USR_MSG_UPDATE_TREND_VIEW//tbd }E_APP_MSG; #endif diff --git a/HostMonitor/UIcode/source/start/host_monitor.cpp b/HostMonitor/UIcode/source/start/host_monitor.cpp index a06ad34..8a93e4f 100644 --- a/HostMonitor/UIcode/source/start/host_monitor.cpp +++ b/HostMonitor/UIcode/source/start/host_monitor.cpp @@ -11,7 +11,7 @@ extern void load_ui_single(void* phy_fb, int width, int height, int color_bytes); static void init(); static void wave_refresh_timer_callback(void* arg); -static void database_timer_callback(void* ptmr, void* parg); +static void database_timer_callback(void* param); static c_fifo s_usr_fifo; int read_usr_msg(MSG_INFO* msg) @@ -34,7 +34,7 @@ void startHostMonitor(void* phy_fb, int screen_width, int screen_height, int col //Start system. start_real_timer(wave_refresh_timer_callback); - register_timer((60 * 1000), database_timer_callback);//update data per minute. + register_timer((60 * 1000), database_timer_callback, 0);//update data per minute. MSG_INFO msg; msg.dwMsgId = USR_MSG_UPDATE_TREND_VIEW; @@ -45,7 +45,7 @@ void startHostMonitor(void* phy_fb, int screen_width, int screen_height, int col if (read_usr_msg(&msg) > 0) { ASSERT((msg.dwMsgId & 0xf0000000) == 0); - //c_cmd_target::handle_usr_msg(msg.dwMsgId, msg.dwParam1, msg.dwParam2);//tbd + //c_cmd_target::handle_usr_msg(msg.dwMsgId, msg.dwParam1, msg.dwParam2); } } } @@ -65,7 +65,7 @@ static void wave_refresh_timer_callback(void* arg) typedef int(*SYNC_DATA)(int hr, int spo2, int rr, int nibp_sys, int nibp_dia, int nibp_mean); extern SYNC_DATA gSyncData; -static void database_timer_callback(void* ptmr, void* parg) +static void database_timer_callback(void* param) { VALUE_SET data; memset(&data, 0, sizeof(data)); diff --git a/HostMonitor/UIcode/source/ui_ctrl_ex/value_view.cpp b/HostMonitor/UIcode/source/ui_ctrl_ex/value_view.cpp index 9a79e03..3de1191 100644 --- a/HostMonitor/UIcode/source/ui_ctrl_ex/value_view.cpp +++ b/HostMonitor/UIcode/source/ui_ctrl_ex/value_view.cpp @@ -47,13 +47,13 @@ int c_value_view::register_value_view(c_value_view* p_pm_view) if (!ms_is_has_timer) { - register_timer(1000, c_value_view::refresh_group_value); + register_timer(1000, c_value_view::refresh_group_value, 0); ms_is_has_timer = true; } return 1; } -void c_value_view::refresh_group_value(void* ptmr, void* parg) +void c_value_view::refresh_group_value(void* param) { static unsigned int s_sequnce; unsigned int flash_color = (s_sequnce++ % 2) ? GL_RGB(255, 0, 0) : GL_RGB(0, 0, 0); diff --git a/HostMonitor/UIcode/source/ui_ctrl_ex/value_view.h b/HostMonitor/UIcode/source/ui_ctrl_ex/value_view.h index 5033295..a62a811 100644 --- a/HostMonitor/UIcode/source/ui_ctrl_ex/value_view.h +++ b/HostMonitor/UIcode/source/ui_ctrl_ex/value_view.h @@ -6,7 +6,7 @@ class c_value_view : public c_wnd { public: - static void refresh_group_value(void* ptmr, void* parg); + static void refresh_group_value(void* param); protected: static int register_value_view(c_value_view* p_pm_view); void refresh_value(bool flash_or_not, unsigned int flash_color); diff --git a/HostMonitor/UIcode/source/ui_layout/View/top_bar/top_bar.cpp b/HostMonitor/UIcode/source/ui_layout/View/top_bar/top_bar.cpp index 710a70e..bfa4339 100644 --- a/HostMonitor/UIcode/source/ui_layout/View/top_bar/top_bar.cpp +++ b/HostMonitor/UIcode/source/ui_layout/View/top_bar/top_bar.cpp @@ -7,7 +7,7 @@ void c_top_bar::on_init_children(void) { m_bg_color = GL_RGB(0,0,0); - register_timer(1000, c_top_bar::sysinfo_timer_callback); + register_timer(1000, c_top_bar::sysinfo_timer_callback, this); } void c_top_bar::on_paint(void) @@ -18,21 +18,8 @@ void c_top_bar::on_paint(void) m_surface->draw_hline(rect.m_left,rect.m_right,rect.m_bottom,GL_RGB(74,74,74), m_z_order); } -void c_top_bar::on_refurbish_time(int id, int param) +void c_top_bar::sysinfo_timer_callback(void* param)//tbd { - c_wnd *p_ctl = get_wnd_ptr(ID_TOP_BAR_TIME_ID); - if(p_ctl == 0) - { - ASSERT(false); - return; - } - p_ctl->on_paint(); -} - -extern int write_usr_msg(MSG_INFO* msg); -void c_top_bar::sysinfo_timer_callback(void* ptmr, void* parg)//tbd -{ - MSG_INFO msg_info; - msg_info.dwMsgId = USR_MSG_UPDATE_TIME; - write_usr_msg(&msg_info); + c_top_bar* top_bar = (c_top_bar*)param; + top_bar->get_wnd_ptr(ID_TOP_BAR_TIME_ID)->on_paint(); } diff --git a/HostMonitor/UIcode/source/ui_layout/View/top_bar/top_bar.h b/HostMonitor/UIcode/source/ui_layout/View/top_bar/top_bar.h index d5b26c4..c700a20 100644 --- a/HostMonitor/UIcode/source/ui_layout/View/top_bar/top_bar.h +++ b/HostMonitor/UIcode/source/ui_layout/View/top_bar/top_bar.h @@ -4,11 +4,10 @@ class c_top_bar : public c_wnd { public: - static void sysinfo_timer_callback(void* ptmr, void* parg); + static void sysinfo_timer_callback(void* param); protected: virtual void on_init_children(void); virtual void on_paint(void); - void on_refurbish_time(int id, int param); }; #endif diff --git a/HostMonitor/UIcode/source/ui_layout/View/trend/trend_view.cpp b/HostMonitor/UIcode/source/ui_layout/View/trend/trend_view.cpp index 4ae1106..6f7625c 100644 --- a/HostMonitor/UIcode/source/ui_layout/View/trend/trend_view.cpp +++ b/HostMonitor/UIcode/source/ui_layout/View/trend/trend_view.cpp @@ -16,11 +16,6 @@ #define H_AXIS_MARK_CNT 7 #define H_AXIS_MARK_INTERVAL (60 * 10) //10 minutes between 2 marks -GL_BEGIN_MESSAGE_MAP(c_trend_view) -ON_ND_SACLE_CLICKED(c_trend_view::on_time_bar_change) -ON_GL_USER_MSG(USR_MSG_UPDATE_TREND_VIEW, c_trend_view::on_update_trend_view) -GL_END_MESSAGE_MAP() - void c_trend_view::on_init_children(void) { c_trend_graph* p_trend_graph = (c_trend_graph*)get_wnd_ptr(ID_TREND_SCREEN_VITAL_TREND_CTRL); @@ -40,7 +35,7 @@ void c_trend_view::on_paint(void) m_surface->draw_rect(rect.m_left+2, rect.m_top+2, rect.m_right-4, rect.m_bottom-9, GL_RGB(99,101,99), m_z_order); } -void c_trend_view::on_time_bar_change(int ctrl_id, int param) +void c_trend_view::on_time_bar_change(int ctrl_id, int param)//tbd { c_time_bar* p_time_bar = (c_time_bar*)get_wnd_ptr(ID_TREND_SCREEN_TIME_SCALE_BAR_CTRL); refresh_trend_table(p_time_bar->get_start_time(), p_time_bar->get_end_time()); diff --git a/HostMonitor/UIcode/source/ui_layout/slide_config.cpp b/HostMonitor/UIcode/source/ui_layout/slide_config.cpp index da7ecc2..90d6140 100644 --- a/HostMonitor/UIcode/source/ui_layout/slide_config.cpp +++ b/HostMonitor/UIcode/source/ui_layout/slide_config.cpp @@ -7,21 +7,20 @@ #include "Dialog/about/about_dlg.h" #include "Dialog/about/about_dlg_xml.h" -//tbd class c_config_root : public c_wnd { virtual void on_init_children() { - ((c_button*)get_wnd_ptr(IDD_SETUP_DLG))->set_on_click((WND_CALLBACK)&c_config_root::on_clicked); - ((c_button*)get_wnd_ptr(IDD_ABOUT_DLG))->set_on_click((WND_CALLBACK)&c_config_root::on_clicked); + ((c_button*)get_wnd_ptr(ID_SETUP_BUTTON))->set_on_click((WND_CALLBACK)&c_config_root::on_clicked); + ((c_button*)get_wnd_ptr(ID_ABOUT_BUTTON))->set_on_click((WND_CALLBACK)&c_config_root::on_clicked); } void on_clicked(int ctrl_id, int param) { switch (ctrl_id) { - case 5: - c_dialog::open_dialog((c_dialog*)get_wnd_ptr(IDD_SETUP_DLG), false); + case ID_SETUP_BUTTON: + c_dialog::open_dialog((c_dialog*)get_wnd_ptr(ID_SETUP_DLG), false); break; - case 7: + case ID_ABOUT_BUTTON: c_dialog::open_dialog((c_dialog*)get_wnd_ptr(IDD_ABOUT_DLG), false); break; default: @@ -48,10 +47,10 @@ static c_about_dlg s_about; static WND_TREE s_config_children[]= { - {&s_btn_patient_setup, 5, "Patient Setup", 0, 5, BUTTON_WIDTH, BUTTON_HEIGHT}, - {&s_btn_demo_setup, 7, "About", (BUTTON_WIDTH + 10), 5, BUTTON_WIDTH, BUTTON_HEIGHT}, + {&s_btn_patient_setup, ID_SETUP_BUTTON, "Patient Setup", 0, 5, BUTTON_WIDTH, BUTTON_HEIGHT}, + {&s_btn_demo_setup, ID_ABOUT_BUTTON, "About", (BUTTON_WIDTH + 10), 5, BUTTON_WIDTH, BUTTON_HEIGHT}, - {&s_patient_setup_dlg, IDD_SETUP_DLG, "Patient Setup", 0, DIALOG_Y, PAGE_WIDTH, DIALOG_HEIGHT, g_patient_setup_children}, + {&s_patient_setup_dlg, ID_SETUP_DLG, "Patient Setup", 0, DIALOG_Y, PAGE_WIDTH, DIALOG_HEIGHT, g_patient_setup_children}, {&s_about, IDD_ABOUT_DLG, "About", 0, DIALOG_Y, PAGE_WIDTH, DIALOG_HEIGHT, g_about_children}, {0,0,0,0,0,0,0} }; diff --git a/HostMonitor/UIcode/source/ui_layout/slide_trend.cpp b/HostMonitor/UIcode/source/ui_layout/slide_trend.cpp index 29bb489..9f70133 100644 --- a/HostMonitor/UIcode/source/ui_layout/slide_trend.cpp +++ b/HostMonitor/UIcode/source/ui_layout/slide_trend.cpp @@ -38,7 +38,7 @@ WND_TREE g_page_trend_view_children[] = {0,0,0,0,0,0,0,0 } }; -static c_trend_view s_trend_view; +static c_trend_view s_trend_view; static c_wnd s_root; WND_TREE g_trend_page_children[]= -- Gitee From 3e71f6eea26864608b52436ca455b7eabea91899 Mon Sep 17 00:00:00 2001 From: idea4good Date: Tue, 20 Oct 2020 11:34:00 +0800 Subject: [PATCH 11/12] hostmonitor ok --- HostMonitor/UIcode/include/msg_id.h | 17 ----- .../UIcode/source/modules/demo_module.cpp | 1 - .../UIcode/source/start/host_monitor.cpp | 74 ++----------------- .../View/ecg_value/ecg_value_view.cpp | 1 - .../source/ui_layout/View/top_bar/top_bar.cpp | 1 - .../ui_layout/View/trend/trend_view.cpp | 48 +++++++++--- .../source/ui_layout/View/trend/trend_view.h | 4 +- 7 files changed, 45 insertions(+), 101 deletions(-) delete mode 100644 HostMonitor/UIcode/include/msg_id.h diff --git a/HostMonitor/UIcode/include/msg_id.h b/HostMonitor/UIcode/include/msg_id.h deleted file mode 100644 index 4077e15..0000000 --- a/HostMonitor/UIcode/include/msg_id.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _KEY_MSG_H -#define _KEY_MSG_H - -typedef struct -{ - unsigned int dwMsgId; - unsigned int dwParam1; - unsigned int dwParam2; -}MSG_INFO; - -typedef enum e_app_msg -{ - USR_MSG_UPDATE_TIME = 0x5300, - USR_MSG_UPDATE_TREND_VIEW//tbd -}E_APP_MSG; - -#endif diff --git a/HostMonitor/UIcode/source/modules/demo_module.cpp b/HostMonitor/UIcode/source/modules/demo_module.cpp index 17ce232..dca92a8 100644 --- a/HostMonitor/UIcode/source/modules/demo_module.cpp +++ b/HostMonitor/UIcode/source/modules/demo_module.cpp @@ -1,4 +1,3 @@ -#include "../include/msg_id.h" #include "../source/manager/wave_manager.h" #include "../source/manager/value_manager.h" #include diff --git a/HostMonitor/UIcode/source/start/host_monitor.cpp b/HostMonitor/UIcode/source/start/host_monitor.cpp index 8a93e4f..2188a71 100644 --- a/HostMonitor/UIcode/source/start/host_monitor.cpp +++ b/HostMonitor/UIcode/source/start/host_monitor.cpp @@ -1,6 +1,4 @@ #define GUILITE_ON //Do not define this macro once more!!! -#include "../include/msg_id.h" -#include "../manager/value_manager.h" #include "../manager/wave_manager.h" #include "../modules/module_group.h" #include "../data/database.h" @@ -8,49 +6,9 @@ #include #include +extern void load_theme(int index); extern void load_ui_single(void* phy_fb, int width, int height, int color_bytes); -static void init(); -static void wave_refresh_timer_callback(void* arg); -static void database_timer_callback(void* param); - -static c_fifo s_usr_fifo; -int read_usr_msg(MSG_INFO* msg) -{ - return s_usr_fifo.read(msg, sizeof(MSG_INFO)); -} -int write_usr_msg(MSG_INFO* msg) -{ - if (msg->dwMsgId & 0xf000000)ASSERT(false); - return s_usr_fifo.write(msg, sizeof(MSG_INFO)); -} - -void startHostMonitor(void* phy_fb, int screen_width, int screen_height, int color_bytes) -{ - init(); - - //Load UI. - load_ui_single(phy_fb, screen_width, screen_height, color_bytes); - - //Start system. - start_real_timer(wave_refresh_timer_callback); - register_timer((60 * 1000), database_timer_callback, 0);//update data per minute. - - MSG_INFO msg; - msg.dwMsgId = USR_MSG_UPDATE_TREND_VIEW; - write_usr_msg(&msg); - - while(1) - { - if (read_usr_msg(&msg) > 0) - { - ASSERT((msg.dwMsgId & 0xf0000000) == 0); - //c_cmd_target::handle_usr_msg(msg.dwMsgId, msg.dwParam1, msg.dwParam2); - } - } -} - -extern void load_theme(int index); static void init() { c_database::get_instance()->init(); @@ -63,29 +21,11 @@ static void wave_refresh_timer_callback(void* arg) c_wave_manage::get_instance()->refurbish_all_waves(); } -typedef int(*SYNC_DATA)(int hr, int spo2, int rr, int nibp_sys, int nibp_dia, int nibp_mean); -extern SYNC_DATA gSyncData; -static void database_timer_callback(void* param) +void startHostMonitor(void* phy_fb, int screen_width, int screen_height, int color_bytes) { - VALUE_SET data; - memset(&data, 0, sizeof(data)); - c_value_manager* real_data_mgr = c_value_manager::get_instance(); - - data.time = get_time_in_second(); - data.hr = data.pr = real_data_mgr->get_value(VALUE_HR); - data.spo2 = real_data_mgr->get_value(VALUE_SPO2); - data.rr = real_data_mgr->get_value(VALUE_RESP); - data.nibp_sys = real_data_mgr->get_value(VALUE_NIBP_SYS); - data.nibp_dia = real_data_mgr->get_value(VALUE_NIBP_DIA); - data.nibp_mean = real_data_mgr->get_value(VALUE_NIBP_MEAN); - c_database::get_instance()->write(data); - - MSG_INFO msg; - msg.dwMsgId = USR_MSG_UPDATE_TREND_VIEW; - write_usr_msg(&msg); - - if(gSyncData) - { - gSyncData(data.hr, data.spo2, data.rr, data.nibp_sys, data.nibp_dia, data.nibp_mean); - } + init(); + //Load UI. + load_ui_single(phy_fb, screen_width, screen_height, color_bytes); + //Start system. + start_real_timer(wave_refresh_timer_callback); } diff --git a/HostMonitor/UIcode/source/ui_layout/View/ecg_value/ecg_value_view.cpp b/HostMonitor/UIcode/source/ui_layout/View/ecg_value/ecg_value_view.cpp index 7eb0fe5..794568e 100644 --- a/HostMonitor/UIcode/source/ui_layout/View/ecg_value/ecg_value_view.cpp +++ b/HostMonitor/UIcode/source/ui_layout/View/ecg_value/ecg_value_view.cpp @@ -1,6 +1,5 @@ #include "../include/GuiLite.h" #include "../include/ctrl_id.h" -#include "../include/msg_id.h" #include "../source/ui_ctrl_ex/value_view.h" #include "../source/ui_ctrl_ex/value_ctrl.h" diff --git a/HostMonitor/UIcode/source/ui_layout/View/top_bar/top_bar.cpp b/HostMonitor/UIcode/source/ui_layout/View/top_bar/top_bar.cpp index bfa4339..3479f01 100644 --- a/HostMonitor/UIcode/source/ui_layout/View/top_bar/top_bar.cpp +++ b/HostMonitor/UIcode/source/ui_layout/View/top_bar/top_bar.cpp @@ -1,5 +1,4 @@ #include "../include/GuiLite.h" -#include "../include/msg_id.h" #include "../include/ctrl_id.h" #include "top_bar.h" #include "top_bar_xml.h" diff --git a/HostMonitor/UIcode/source/ui_layout/View/trend/trend_view.cpp b/HostMonitor/UIcode/source/ui_layout/View/trend/trend_view.cpp index 6f7625c..3fe047b 100644 --- a/HostMonitor/UIcode/source/ui_layout/View/trend/trend_view.cpp +++ b/HostMonitor/UIcode/source/ui_layout/View/trend/trend_view.cpp @@ -1,11 +1,10 @@ #include "../include/GuiLite.h" #include "../include/ctrl_id.h" -#include "../include/msg_id.h" +#include "../../../manager/value_manager.h" #include "../source/data/database.h" #include "../source/ui_ctrl_ex/trend_graph.h" #include "../source/ui_ctrl_ex/trend_table.h" #include "../source/ui_ctrl_ex/time_bar.h" -#include #include "trend_view.h" #define HR_COLOR GL_RGB(148,251,78) @@ -22,6 +21,7 @@ void c_trend_view::on_init_children(void) p_trend_graph->set_type(TREND_TYPE_VITAL); p_trend_graph = (c_trend_graph*)get_wnd_ptr(ID_TREND_SCREEN_PRESSURE_CTRL); p_trend_graph->set_type(TREND_TYPE_NIBP); + register_timer((60 * 1000), database_timer_callback, this); } void c_trend_view::on_paint(void) @@ -33,21 +33,21 @@ void c_trend_view::on_paint(void) m_surface->draw_rect(rect.m_left, rect.m_top, rect.m_right-2, rect.m_bottom-7, GL_RGB(165,166,156), m_z_order); m_surface->draw_rect(rect.m_left+1, rect.m_top+1, rect.m_right-3, rect.m_bottom-8, GL_RGB(123,125,123), m_z_order); m_surface->draw_rect(rect.m_left+2, rect.m_top+2, rect.m_right-4, rect.m_bottom-9, GL_RGB(99,101,99), m_z_order); -} -void c_trend_view::on_time_bar_change(int ctrl_id, int param)//tbd -{ - c_time_bar* p_time_bar = (c_time_bar*)get_wnd_ptr(ID_TREND_SCREEN_TIME_SCALE_BAR_CTRL); - refresh_trend_table(p_time_bar->get_start_time(), p_time_bar->get_end_time()); - refresh_trend_graphic(p_time_bar->get_end_time()); + static bool first_show=true; + if (first_show) + { + database_timer_callback(this); + first_show = false; + } } -void c_trend_view::on_update_trend_view(int id, int param) +void c_trend_view::update_trend_view() { - //update time bar c_time_bar* p_time_bar = (c_time_bar*)get_wnd_ptr(ID_TREND_SCREEN_TIME_SCALE_BAR_CTRL); p_time_bar->set_time(get_time_in_second()); - on_time_bar_change(0, 0); + refresh_trend_table(p_time_bar->get_start_time(), p_time_bar->get_end_time()); + refresh_trend_graphic(p_time_bar->get_end_time()); } void c_trend_view::refresh_trend_table(long start_time, long end_time) @@ -182,6 +182,30 @@ int c_trend_view::read_trend_data(long start_time, long end_time, int hr[], int } time += detal; } - return read_cnt; } + +typedef int(*SYNC_DATA)(int hr, int spo2, int rr, int nibp_sys, int nibp_dia, int nibp_mean); +extern SYNC_DATA gSyncData; +void c_trend_view::database_timer_callback(void* param) +{ + VALUE_SET data; + memset(&data, 0, sizeof(data)); + c_value_manager* real_data_mgr = c_value_manager::get_instance(); + + data.time = get_time_in_second(); + data.hr = data.pr = real_data_mgr->get_value(VALUE_HR); + data.spo2 = real_data_mgr->get_value(VALUE_SPO2); + data.rr = real_data_mgr->get_value(VALUE_RESP); + data.nibp_sys = real_data_mgr->get_value(VALUE_NIBP_SYS); + data.nibp_dia = real_data_mgr->get_value(VALUE_NIBP_DIA); + data.nibp_mean = real_data_mgr->get_value(VALUE_NIBP_MEAN); + c_database::get_instance()->write(data); + + ((c_trend_view*)param)->update_trend_view(); + + if (gSyncData) + { + gSyncData(data.hr, data.spo2, data.rr, data.nibp_sys, data.nibp_dia, data.nibp_mean); + } +} diff --git a/HostMonitor/UIcode/source/ui_layout/View/trend/trend_view.h b/HostMonitor/UIcode/source/ui_layout/View/trend/trend_view.h index 436d884..02d5bba 100644 --- a/HostMonitor/UIcode/source/ui_layout/View/trend/trend_view.h +++ b/HostMonitor/UIcode/source/ui_layout/View/trend/trend_view.h @@ -8,11 +8,11 @@ public: virtual void on_init_children(void); virtual void on_paint(void); private: - void on_time_bar_change(int ctrl_id, int param); - void on_update_trend_view(int id, int param); + void update_trend_view(); virtual void refresh_trend_table(long start_time, long end_time);//time unit: second virtual void refresh_trend_graphic(long time);//time unit: second int read_trend_data(long start_time, long end_time, int hr[], int spo2[], int rr[], int pr[], int nibp_sys[], int nibp_dia[], int nibp_mean[], int len);//time unit: second + static void database_timer_callback(void* param); }; #endif -- Gitee From b1718c1c807fa1d460e60c383948afcd54bad414 Mon Sep 17 00:00:00 2001 From: idea4good Date: Tue, 20 Oct 2020 11:46:03 +0800 Subject: [PATCH 12/12] update gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 4b8ca51..1bcad82 100644 --- a/.gitignore +++ b/.gitignore @@ -63,6 +63,8 @@ EventRecorderStub.scvd Makefile* # For output +ExternalWindow/X11/xWindow + libUIcode.a snap_short.bmp -- Gitee