!31 Remove cmd_target, refact timer

This commit is contained in:
idea4good
2020-10-20 11:57:57 +08:00
parent 75b2ad7b7c
commit bdf5dce9e1
15 changed files with 138 additions and 391 deletions

View File

@@ -9,12 +9,10 @@
#include "../core_include/display.h"
#include "../core_include/theme.h"
#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()
{
@@ -62,6 +60,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);
@@ -79,7 +78,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)
@@ -96,4 +98,5 @@ protected:
}
return c_wnd::on_navigate(key);
}
WND_CALLBACK on_click;
};

View File

@@ -137,11 +137,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)

View File

@@ -78,8 +78,22 @@ 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()
{
@@ -138,7 +152,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)
{
@@ -147,7 +161,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)
{
@@ -157,19 +171,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

View File

@@ -12,13 +12,14 @@
#include <string.h>
#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)
@@ -36,7 +37,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)
@@ -195,7 +195,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);
}
}
}
}
@@ -218,7 +221,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
{
@@ -232,4 +238,5 @@ 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;
};

View File

@@ -11,8 +11,6 @@
#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
@@ -35,7 +33,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()
{
@@ -70,7 +68,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()
@@ -80,7 +81,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();
}
@@ -92,6 +96,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)