!19 Refactor wnd, add HelloWidgets

This commit is contained in:
idea4good
2019-05-24 10:20:40 +08:00
committed by Gitee
parent ef7e8f8b70
commit c38b8b0cf1
62 changed files with 265 additions and 347 deletions

View File

@@ -42,7 +42,7 @@ bool c_button::on_touch(int x, int y, TOUCH_ACTION action)
on_paint();
notify_parent(GL_BN_CLICKED, get_id(), 0);
}
return false;// Do not handle TOUCH_ACTION by other wnd.
return true;
}
bool c_button::on_key(KEY_TYPE key)

View File

@@ -2,22 +2,17 @@
#include "core_include/rect.h"
#include "core_include/cmd_target.h"
#include "core_include/wnd.h"
#include "core_include/msg.h"
#include "core_include/surface.h"
#include "core_include/display.h"
#include "core_include/resource.h"
#include "core_include/bitmap.h"
#include "core_include/word.h"
#include "core_include/theme.h"
#include "../widgets_include/button.h"
#include "../widgets_include/dialog.h"
#include <string.h>
#include "widgets_include/dialog.h"
DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX];
void c_dialog::pre_create_wnd()
{
m_style = GL_ATTR_FOCUS;
m_style = 0;// no focus/visible
m_z_order = Z_ORDER_LEVEL_1;
m_bg_color = GL_RGB(33, 42, 53);
}
@@ -61,14 +56,14 @@ int c_dialog::open_dialog(c_dialog* p_dlg)
if(cur_dlg)
{
cur_dlg->modify_style(0, GL_ATTR_VISIBLE);
cur_dlg->set_style(0);
}
c_rect rc;
p_dlg->get_screen_rect(rc);
p_dlg->get_surface()->set_frame_layer(rc, Z_ORDER_LEVEL_1);
p_dlg->modify_style(GL_ATTR_VISIBLE, 0);
p_dlg->set_style(GL_ATTR_VISIBLE | GL_ATTR_FOCUS | GL_ATTR_PRIORITY);
p_dlg->show_window();
p_dlg->set_me_the_dialog();
return 1;
@@ -84,7 +79,7 @@ int c_dialog::close_dialog(c_surface* surface)
}
c_rect rc;
dlg->modify_style(0, GL_ATTR_VISIBLE);
dlg->set_style(0);
surface->set_frame_layer(rc, dlg->m_z_order);
//clear the dialog
@@ -100,29 +95,6 @@ int c_dialog::close_dialog(c_surface* surface)
return -1;
}
bool c_dialog::on_touch(int x, int y, TOUCH_ACTION action)
{
c_wnd *child = m_top_child;
c_rect rect;
get_wnd_rect(rect);
if ( NULL != child )
{
while ( child )
{
if (child->m_z_order > m_z_order)
{
x -= rect.m_left;
y -= rect.m_top;
child->on_touch(x, y, action);
return true;
}
child = child->m_next_sibling;
}
}
return c_wnd::on_touch(x, y, action);
}
int c_dialog::set_me_the_dialog()
{
c_surface* surface = get_surface();

View File

@@ -30,6 +30,7 @@ void c_edit::pre_create_wnd()
memset(m_str_input, 0, sizeof(m_str_input));
memset(m_str, 0, sizeof(m_str));
set_text(c_wnd::m_str);
}
void c_edit::set_text(const char* str)
@@ -123,6 +124,7 @@ void c_edit::on_paint()
s_keyboard.disconnect();
m_surface->set_frame_layer(empty_rect, s_keyboard.get_z_order());
m_z_order = m_parent->get_z_order();
m_style &= ~GL_ATTR_PRIORITY;
}
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_NORMAL), m_z_order);
break;
@@ -132,6 +134,7 @@ void c_edit::on_paint()
s_keyboard.disconnect();
m_surface->set_frame_layer(empty_rect, s_keyboard.get_z_order());
m_z_order = m_parent->get_z_order();
m_style &= ~GL_ATTR_PRIORITY;
}
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_FOCUS), m_z_order);
break;
@@ -139,6 +142,7 @@ void c_edit::on_paint()
if (m_z_order == m_parent->get_z_order())
{
m_z_order++;
m_style |= GL_ATTR_PRIORITY;
show_keyboard();
}
m_surface->fill_rect(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, c_theme::get_color(COLOR_WND_PUSHED), m_parent->get_z_order());

View File

@@ -40,7 +40,6 @@ void c_list_box::on_paint()
{
c_rect rect, empty_rect;
get_screen_rect(rect);
empty_rect.Empty();
switch(m_status)
{
@@ -49,6 +48,7 @@ void c_list_box::on_paint()
{
m_surface->set_frame_layer(empty_rect, m_z_order);
m_z_order = m_parent->get_z_order();
m_style &= ~GL_ATTR_PRIORITY;
}
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_NORMAL), m_z_order);
break;
@@ -57,6 +57,7 @@ void c_list_box::on_paint()
{
m_surface->set_frame_layer(empty_rect, m_z_order);
m_z_order = m_parent->get_z_order();
m_style &= ~GL_ATTR_PRIORITY;
}
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_FOCUS), m_z_order);
break;
@@ -72,6 +73,7 @@ void c_list_box::on_paint()
m_z_order++;
}
m_surface->set_frame_layer(m_list_screen_rect, m_z_order);
m_style |= GL_ATTR_PRIORITY;
show_list();
return;
}
@@ -113,7 +115,7 @@ void c_list_box::on_touch_down(int x, int y)
{
m_status = STATUS_FOCUSED;
on_paint();
notify_parent(GL_LIST_CONFIRM, get_id(), 0);
notify_parent(GL_LIST_CONFIRM, get_id(), m_selected_item);
}
}
}
@@ -124,7 +126,6 @@ void c_list_box::on_touch_up(int x, int y)
{
m_status = STATUS_PUSHED;
on_paint();
notify_parent(GL_LIST_SELECT, get_id(), 0);
}
else if (STATUS_PUSHED == m_status)
{
@@ -138,7 +139,7 @@ void c_list_box::on_touch_up(int x, int y)
m_status = STATUS_FOCUSED;
select_item((y - m_list_wnd_rect.m_top) / ITEM_HEIGHT);
on_paint();
notify_parent(GL_LIST_CONFIRM, get_id(), 0);
notify_parent(GL_LIST_CONFIRM, get_id(), m_selected_item);
}
else
{

View File

@@ -1,4 +1,4 @@
#include "core_include/api.h"
#include "core_include/api.h"
#include "core_include/rect.h"
#include "core_include/cmd_target.h"
#include "core_include/wnd.h"
@@ -47,65 +47,39 @@ void c_spin_box::pre_create_wnd()
bool c_spin_box::on_touch(int x, int y, TOUCH_ACTION action)
{
(action == TOUCH_DOWN) ? on_touch_down(x, y) : on_touch_up(x, y);
return true;
return c_wnd::on_touch(x, y, action);
}
void c_spin_box::on_touch_down(int x, int y)
{
c_rect arrow_rect = m_wnd_rect;
arrow_rect.m_right = m_bt_down_rect.m_right;
arrow_rect.m_bottom = m_bt_down_rect.m_bottom;
if ( TRUE == m_wnd_rect.PtInRect(x, y) )
{//click spin box
if (STATUS_NORMAL == m_status)
{
m_parent->set_child_focus(this);
}
if (FALSE == m_wnd_rect.PtInRect(x, y))
{//maybe click on up/down arrow button
return;
}
else if (TRUE == arrow_rect.PtInRect(x, y))
{//click arrow button
c_wnd::on_touch(x, y, TOUCH_DOWN);
}
else
{//click invalid place.
if (STATUS_PUSHED == m_status)
{
if (m_value != m_cur_value)
{
m_value = m_cur_value;
}
m_status = STATUS_FOCUSED;
on_paint();
notify_parent(GL_SPIN_CONFIRM, get_id(), 0);
}
if (STATUS_NORMAL == m_status)
{
m_parent->set_child_focus(this);
}
}
void c_spin_box::on_touch_up(int x, int y)
{
if (FALSE == m_wnd_rect.PtInRect(x, y))
{//maybe click on up/down arrow button
return;
}
if (STATUS_FOCUSED == m_status)
{
m_status = STATUS_PUSHED;
on_paint();
notify_parent(GL_SPIN_SELECT, get_id(), 0);
}
else if (STATUS_PUSHED == m_status)
{
if (m_wnd_rect.PtInRect(x, y))
{//click spin box.
if (m_value != m_cur_value)
{
m_value = m_cur_value;
}
m_status = STATUS_FOCUSED;
on_paint();
notify_parent(GL_SPIN_CONFIRM, get_id(), 0);
}
else
{//click arrow button.
c_wnd::on_touch(x, y, TOUCH_UP);
}
m_value = m_cur_value;
m_status = STATUS_FOCUSED;
on_paint();
notify_parent(GL_SPIN_CONFIRM, get_id(), m_value);
}
}
@@ -124,30 +98,24 @@ void c_spin_box::on_kill_focus()
void c_spin_box::show_arrow_button()
{
m_surface->fill_rect(m_bt_up_rect.m_left, m_bt_up_rect.m_top, m_bt_down_rect.m_right, m_bt_down_rect.m_bottom, GL_RGB(99,108,124), m_z_order);
m_bt_up.connect(this, ID_BT_ARROW_UP, 0, 0, m_wnd_rect.Height(), m_bt_up_rect.Width(),m_bt_up_rect.Height());
m_bt_up.set_bitmap(c_theme::get_bmp(BITMAP_UP_ARROW1));
m_bt_up.set_focus_bitmap(c_theme::get_bmp(BITMAP_UP_ARROW2));
m_bt_up.set_pushed_bitmap(c_theme::get_bmp(BITMAP_UP_ARROW2));
m_bt_up.connect(this, ID_BT_ARROW_UP, "\xe2\x96\xb2"/*▲*/, 0, m_wnd_rect.Height(), m_bt_up_rect.Width(),m_bt_up_rect.Height());
m_bt_up.show_window();
m_bt_down.connect(this, ID_BT_ARROW_DOWN, 0, m_bt_up_rect.Width(), m_wnd_rect.Height(), m_bt_down_rect.Width(),m_bt_down_rect.Height());
m_bt_down.set_bitmap(c_theme::get_bmp(BITMAP_DOWN_ARROW1));
m_bt_down.set_focus_bitmap(c_theme::get_bmp(BITMAP_DOWN_ARROW2));
m_bt_down.set_pushed_bitmap(c_theme::get_bmp(BITMAP_DOWN_ARROW2));
m_bt_down.connect(this, ID_BT_ARROW_DOWN, "\xe2\x96\xbc"/*▼*/, m_bt_up_rect.Width(), m_wnd_rect.Height(), m_bt_down_rect.Width(),m_bt_down_rect.Height());
m_bt_down.show_window();
m_style |= GL_ATTR_PRIORITY;
}
void c_spin_box::hide_arrow_button()
{
m_bt_up.disconnect();
m_bt_down.disconnect();
m_style &= ~GL_ATTR_PRIORITY;
}
void c_spin_box::on_paint()
{
c_rect rect,tmp_rect;
c_rect rect, tmp_rect, empty_rect;
get_screen_rect(rect);
tmp_rect.m_left = rect.m_left;
tmp_rect.m_right = rect.m_right;
@@ -158,8 +126,7 @@ void c_spin_box::on_paint()
if (m_z_order > m_parent->get_z_order())
{
hide_arrow_button();
tmp_rect.Empty();
m_surface->set_frame_layer(tmp_rect, m_z_order);
m_surface->set_frame_layer(empty_rect, m_z_order);
m_z_order = m_parent->get_z_order();
}
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_NORMAL), m_z_order);
@@ -168,8 +135,7 @@ void c_spin_box::on_paint()
if (m_z_order > m_parent->get_z_order())
{
hide_arrow_button();
tmp_rect.Empty();
m_surface->set_frame_layer(tmp_rect, m_z_order);
m_surface->set_frame_layer(empty_rect, m_z_order);
m_z_order = m_parent->get_z_order();
}
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_FOCUS), m_z_order);
@@ -199,26 +165,22 @@ void c_spin_box::on_paint()
void c_spin_box::on_arrow_up_bt_click(unsigned int ctr_id)
{
if (m_cur_value + m_step > m_max)
{
return;
}
m_cur_value += m_step;
if (m_cur_value > m_max)
{
m_cur_value = m_max;
}
else
{
on_paint();
}
notify_parent(GL_SPIN_CHANGE, get_id(), m_cur_value);
on_paint();
}
void c_spin_box::on_arrow_down_bt_click(unsigned int ctr_id)
{
if (m_cur_value - m_step < m_min)
{
return;
}
m_cur_value -= m_step;
if (m_cur_value < m_min)
{
m_cur_value = m_min;
}
else
{
on_paint();
}
notify_parent(GL_SPIN_CHANGE, get_id(), m_cur_value);
on_paint();
}

View File

@@ -1,34 +0,0 @@
#ifndef BUTTON_H
#define BUTTON_H
#define GL_BN_CLICKED 0x1111
#define ON_GL_BN_CLICKED(ctrlId, func) \
{MSG_TYPE_WND, GL_BN_CLICKED, (c_cmd_target*)ctrlId, MSG_CALLBACK_VWV, (MsgFuncVV)(static_cast<void (c_cmd_target::*)(unsigned int)>(&func))},
typedef struct struct_bitmap_info BITMAP_INFO;
class c_button : public c_wnd
{
public:
virtual const char* get_class_name() const {return "c_button";}
virtual c_wnd* clone(){return new c_button();}
void set_bitmap(const BITMAP_INFO *pBitmap) { m_bitmap_normal = pBitmap; }
void set_focus_bitmap(const BITMAP_INFO *pBitmap) { m_bitmap_focus = pBitmap; }
void set_pushed_bitmap(const BITMAP_INFO *pBitmap) { m_bitmap_pushed = pBitmap; }
void set_disable_bitmap(const BITMAP_INFO *pBitmap) { m_bitmap_disable = pBitmap; }
protected:
virtual void on_paint();
virtual void on_focus();
virtual void on_kill_focus();
virtual void pre_create_wnd();
virtual bool on_touch(int x, int y, TOUCH_ACTION action);
virtual bool on_key(KEY_TYPE key);
const BITMAP_INFO* m_bitmap_normal;
const BITMAP_INFO* m_bitmap_focus;
const BITMAP_INFO* m_bitmap_pushed;
const BITMAP_INFO* m_bitmap_disable;
};
#endif

View File

@@ -1,29 +0,0 @@
#ifndef DIALOG_H
#define DIALOG_H
class c_surface;
class c_dialog;
typedef struct
{
c_dialog* dialog;
c_surface* surface;
} DIALOG_ARRAY;
class c_dialog : public c_wnd
{
public:
static int open_dialog(c_dialog* p_dlg);
static int close_dialog(c_surface* surface);
static c_dialog* get_the_dialog(c_surface* surface);
virtual bool on_touch(int x, int y, TOUCH_ACTION action);
protected:
virtual const char* get_class_name(void) const {return "c_dialog";}
virtual void pre_create_wnd();
virtual void on_paint();
static DIALOG_ARRAY ms_the_dialogs[SURFACE_CNT_MAX];
private:
int set_me_the_dialog();
};
#endif

View File

@@ -1,35 +0,0 @@
#ifndef EDIT_H
#define EDIT_H
#define KEY_BOARD_STYLE 0x00001000L
#define NUM_BOARD_STYLE 0x00002000L
#define MAX_EDIT_STRLEN 32
class c_edit : public c_wnd
{
friend class c_keyboard;
public:
virtual c_wnd* clone(){return new c_edit();}
virtual const char* get_class_name() const {return "c_edit";}
const char* get_text(){return m_str;}
void set_text(const char* str);
protected:
virtual void pre_create_wnd();
virtual void on_paint();
virtual void on_focus();
virtual void on_kill_focus();
virtual bool on_touch(int x, int y, TOUCH_ACTION action);
void on_key_board_click(unsigned int ctrl_id, long param);
GL_DECLARE_MESSAGE_MAP()
private:
void show_keyboard();
void on_touch_down(int x, int y);
void on_touch_up(int x, int y);
char m_str_input[MAX_EDIT_STRLEN];
char m_str[MAX_EDIT_STRLEN];
};
#endif

View File

@@ -1,38 +0,0 @@
#ifndef GESTURE_H
#define GESTURE_H
typedef enum{
TOUCH_MOVE,
TOUCH_IDLE
}ACTION;
class c_slide_group;
class c_gesture{
public:
c_gesture(c_wnd* root, c_slide_group* group, c_fifo* hid_fifo);
void set_page_group(c_slide_group* group){m_slide_group = group;}
protected:
bool handle_flip(MSG_INFO &msg);
bool on_move(int x);
bool on_flip(int x);
private:
int flip_left();
int flip_right();
void move_left();
void move_right();
void handle_hid_msg(MSG_INFO &msg);
int m_down_x;
int m_down_y;
int m_move_x;
int m_move_y;
ACTION m_action;
c_slide_group* m_slide_group;
c_wnd* m_root;
c_fifo* m_hid_fifo;
static void* task_handle_msg(void* param);
};
#endif

View File

@@ -1,59 +0,0 @@
#ifndef KEYBOARD_H
#define KEYBOARD_H
#define KEYBORAD_CLICK 0x5014
#define ON_KEYBORAD_UPDATE(ctrlId, func) \
{MSG_TYPE_WND, KEYBORAD_CLICK, (c_cmd_target*)ctrlId, MSG_CALLBACK_VWL, (MsgFuncVV)(static_cast<void (c_cmd_target::*)(unsigned int, long)>(&func))},
typedef enum
{
STATUS_UPPERCASE,
STATUS_LOWERCASE
}KEYBOARD_STATUS;
typedef enum
{
STYLE_ALL_BOARD,
STYLE_NUM_BOARD
}KEYBOARD_STYLE;
typedef enum
{
CLICK_CHAR,
CLICK_ENTER,
CLICK_ESC
}CLICK_STATUS;
class c_keyboard: public c_wnd
{
public:
virtual int connect(c_wnd *user, unsigned short resource_id);
KEYBOARD_STATUS get_cap_status(){return m_cap_status;}
void set_style(KEYBOARD_STYLE style) { m_style = style; }
char* get_str() { return m_str; }
protected:
virtual void pre_create_wnd();
virtual c_wnd* clone(){return new c_keyboard();}
void on_char_clicked(unsigned int ctrl_id);
void on_del_clicked(unsigned int ctrl_id);
void on_caps_clicked(unsigned int ctrl_id);
void on_enter_clicked(unsigned int ctrl_id);
void on_esc_clicked(unsigned int ctrl_id);
GL_DECLARE_MESSAGE_MAP()
private:
char m_str[32];
int m_str_len;
KEYBOARD_STATUS m_cap_status;
KEYBOARD_STYLE m_stlyle;
};
class c_keyboard_button : public c_button
{
protected:
virtual c_wnd* clone(){return new c_keyboard_button();}
virtual void on_paint();
};
#endif /* KEYBOARD_H_ */

View File

@@ -1,14 +0,0 @@
#ifndef LABEL_H
#define LABEL_H
class c_label : public c_wnd
{
public:
virtual c_wnd* clone(){return new c_label();}
virtual void on_paint();
protected:
virtual void pre_create_wnd();
private:
};
#endif

View File

@@ -1,48 +0,0 @@
#ifndef LIST_BOX_H
#define LIST_BOX_H
#define MAX_ITEM_NUM 12
#define GL_LIST_SELECT 0x1
#define GL_LIST_CONFIRM 0x2
#define GL_LIST_ROTATION 0x3
#define ON_LIST_SELECT(ctrlId, func) \
{MSG_TYPE_WND, GL_LIST_SELECT, (c_cmd_target*)ctrlId, ctrlId, MSG_CALLBACK_VWV, reinterpret_cast<MsgFuncVV>(&func)},
#define ON_LIST_CONFIRM(ctrlId, func) \
{MSG_TYPE_WND, GL_LIST_CONFIRM, (c_cmd_target*)ctrlId, ctrlId, MSG_CALLBACK_VWV, reinterpret_cast<MsgFuncVV>(&func)},
#define ON_LIST_ROTATION(ctrlId, func) \
{MSG_TYPE_WND, GL_LIST_ROTATION, (c_cmd_target*)ctrlId, ctrlId, MSG_CALLBACK_VWL, reinterpret_cast<MsgFuncVV>(&func)},
class c_list_box : public c_wnd
{
public:
int add_item(char* str);
void clear_item();
short get_item_count() { return m_item_total; }
void select_item(short index);
protected:
virtual c_wnd* clone(){return new c_list_box();}
virtual void pre_create_wnd();
virtual void on_paint();
virtual void on_focus();
virtual void on_kill_focus();
virtual bool on_touch(int x, int y, TOUCH_ACTION action);
private:
void update_list_size();
void show_list();
void on_touch_down(int x, int y);
void on_touch_up(int x, int y);
short m_selected_item;
short m_item_total;
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)
};
#endif

View File

@@ -1,28 +0,0 @@
#ifndef PAGE_GROUP_H
#define PAGE_GROUP_H
#define MAX_PAGES 5
class c_slide_group : public c_wnd {
public:
c_slide_group();
int set_active_slide(int index, bool is_redraw = true);
c_wnd* get_slide(int index){return m_slides[index];}
c_wnd* get_active_slide(){return m_slides[m_active_slide_index];}
int get_active_slide_index(){return m_active_slide_index;}
int add_slide(c_wnd* slide, unsigned short resource_id, short x, short y,
short width, short height, WND_TREE* p_child_tree = NULL,
Z_ORDER_LEVEL max_zorder = Z_ORDER_LEVEL_0);
int add_clone_silde(c_wnd* slide, unsigned short resource_id, short x, short y,
short width, short height, WND_TREE* p_child_tree = NULL,
Z_ORDER_LEVEL max_zorder = Z_ORDER_LEVEL_0);
void disabel_all_slide();
virtual bool on_touch(int x, int y, TOUCH_ACTION action);
virtual bool on_key(KEY_TYPE key);
protected:
virtual c_wnd* clone(){return new c_slide_group();}
c_wnd* m_slides[MAX_PAGES];
int m_active_slide_index;
};
#endif

View File

@@ -1,66 +0,0 @@
#ifndef SPIN_BOX_H
#define SPIN_BOX_H
#define GL_SPIN_SELECT 0x2222
#define GL_SPIN_CONFIRM 0x3333
#define GL_SPIN_ROTATION 0x4444
#define ON_SPIN_SELECT(ctrlId, func) \
{MSG_TYPE_WND, GL_SPIN_SELECT, (c_cmd_target*)ctrlId, MSG_CALLBACK_VWV, (MsgFuncVV)(static_cast<void (c_cmd_target::*)(unsigned int)>(&func))},
#define ON_SPIN_CONFIRM(ctrlId, func) \
{MSG_TYPE_WND, GL_SPIN_CONFIRM, (c_cmd_target*)ctrlId, MSG_CALLBACK_VWV, (MsgFuncVV)(static_cast<void (c_cmd_target::*)(unsigned int)>(&func))},
#define ON_SPIN_ROTATION(ctrlId, func) \
{MSG_TYPE_WND, GL_SPIN_ROTATION, (c_cmd_target*)ctrlId, MSG_CALLBACK_VWL, (MsgFuncVV)(static_cast<void (c_cmd_target::*)(unsigned int)>(&func))},
class c_spin_box : public c_wnd
{
public:
short get_value(){return m_value;}
void set_value(unsigned short value){m_value = m_cur_value = value;}
void set_max_min(short max, short min){m_max = max; m_min = min;}
void set_step(short step){m_step = step;}
short get_min(){return m_min;}
short get_max(){return m_max;}
short get_step(){return m_step;}
void set_value_digit(short digit){m_digit = digit;}
short get_value_digit(){return m_digit;}
protected:
virtual c_wnd* clone(){return new c_spin_box();}
virtual void on_paint();
virtual void on_focus();
virtual void on_kill_focus();
virtual void pre_create_wnd();
virtual bool on_touch(int x, int y, TOUCH_ACTION action);
void on_arrow_up_bt_click(unsigned int ctr_id);
void on_arrow_down_bt_click(unsigned int ctr_id);
GL_DECLARE_MESSAGE_MAP()
private:
void show_arrow_button();
void hide_arrow_button();
void on_touch_down(int x, int y);
void on_touch_up(int x, int y);
protected:
short m_cur_value;
short m_value;
short m_step;
short m_max;
short m_min;
short m_digit;
c_button m_bt_up;
c_button m_bt_down;
c_rect m_bt_up_rect;
c_rect m_bt_down_rect;
};
#endif

View File

@@ -1,33 +0,0 @@
#ifndef TABLE_H
#define TABLE_H
#define MAX_COL_NUM 30
#define MAX_ROW_NUM 30
class c_table: public c_wnd
{
public:
virtual c_wnd* clone(){return new c_table();}
void set_sheet_align(unsigned int align_type){ m_align_type = align_type;}
void set_row_num(unsigned int row_num){ m_row_num = row_num;}
void set_col_num(unsigned int col_num){ m_col_num = col_num;}
void set_row_height(unsigned int height);
void set_col_width(unsigned int width);
int set_row_height(unsigned int index, unsigned int height);
int set_col_width(unsigned int index, unsigned int width);
void set_item(int row, int col, char* str, unsigned int color);
unsigned int get_row_num(){ return m_row_num;}
unsigned int get_col_num(){ return m_col_num;}
c_rect get_item_rect(int row, int col);
protected:
void draw_item(int col, int row, const char* str, unsigned int color);
unsigned int m_align_type;
unsigned int m_row_num;
unsigned int m_col_num;
unsigned int m_row_height[MAX_ROW_NUM];
unsigned int m_col_width[MAX_COL_NUM];
};
#endif

View File

@@ -1,36 +0,0 @@
#ifndef WAVE_BUFFER_H
#define WAVE_BUFFER_H
#define WAVE_BUFFER_LEN 1024
#define WAVE_READ_CACHE_LEN 8
#define BUFFER_EMPTY -1111
#define BUFFER_FULL -2222;
class c_wave_buffer
{
public:
c_wave_buffer();
int write_wave_data(short data);
int read_wave_data_by_frame(short &max, short &min, short frame_len, unsigned int sequence, short offset);
void reset();
void clear_data();
short get_cnt();
private:
int read_data();
short m_wave_buf[WAVE_BUFFER_LEN];
short m_head;
short m_tail;
int m_min_old;
int m_max_old;
int m_min_older;
int m_max_older;
int m_last_data;
short m_read_cache_min[WAVE_READ_CACHE_LEN];
short m_read_cache_mid[WAVE_READ_CACHE_LEN];
short m_read_cache_max[WAVE_READ_CACHE_LEN];
short m_read_cache_sum;
unsigned int m_refresh_sequence;
};
#endif

View File

@@ -1,74 +0,0 @@
#ifndef WAVE_CTRL_H
#define WAVE_CTRL_H
typedef enum
{
FILL_MODE,
SCAN_MODE
}E_WAVE_DRAW_MODE;
class c_wave_buffer;
class c_wave_ctrl : public c_wnd
{
public:
c_wave_ctrl();
virtual c_wnd* clone(){return new c_wave_ctrl();}
virtual void on_init_children();
virtual void on_paint();
void set_wave_name(char* wave_name){ m_wave_name = wave_name;}
void set_wave_unit(char* wave_unit){ m_wave_unit = wave_unit;}
void set_wave_name_font(const FONT_INFO* wave_name_font_type){ m_wave_name_font = wave_name_font_type;}
void set_wave_unit_font(const FONT_INFO* wave_unit_font_type){ m_wave_unit_font = wave_unit_font_type;}
void set_wave_name_color(unsigned int wave_name_color){ m_wave_name_color = wave_name_color;}
void set_wave_unit_color(unsigned int wave_unit_color){ m_wave_unit_color = wave_unit_color;}
void set_wave_color(unsigned int color){ m_wave_color = color;}
void set_wave_in_out_rate(unsigned int data_rate, unsigned int refresh_rate);
void set_wave_speed(unsigned int speed);
void set_max_min(short max_data, short min_data);
void set_wave(c_wave_buffer* wave){m_wave = wave;}
c_wave_buffer* get_wave(){return m_wave;}
void clear_data();
bool is_data_enough();
void refresh_wave(unsigned char frame);
void clear_wave();
protected:
void draw_smooth_vline(int y_min, int y_max, int mid, unsigned int rgb);
void restore_background();
void save_background();
char* m_wave_name;
char* m_wave_unit;
const FONT_INFO* m_wave_name_font;
const FONT_INFO* m_wave_unit_font;
unsigned int m_wave_name_color;
unsigned int m_wave_unit_color;
unsigned int m_wave_color;
unsigned int m_back_color;
int m_wave_left;
int m_wave_right;
int m_wave_top;
int m_wave_bottom;
short m_max_data;
short m_min_data;
private:
c_wave_buffer* m_wave;
unsigned int* m_bg_fb; //background frame buffer, could be used to draw scale line.
int m_wave_cursor;
int m_wave_speed; //pixels per refresh
unsigned int m_wave_data_rate; //data sample rate
unsigned int m_wave_refresh_rate;//refresh cycle in millisecond
unsigned char m_frame_len_map[64];
unsigned char m_frame_len_map_index;
};
#endif