refactor folder

This commit is contained in:
idea4good
2019-11-08 23:11:45 +08:00
parent 5f63734089
commit 5bbbc41898
102 changed files with 12014 additions and 40 deletions

View File

@@ -0,0 +1,23 @@
#ifndef GUILITE_WIDGETS_INCLUDE_BUTTON_H
#define GUILITE_WIDGETS_INCLUDE_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 c_wnd* clone(){return new c_button();}
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);
};
#endif

View File

@@ -0,0 +1,28 @@
#ifndef GUILITE_WIDGETS_INCLUDE_DIALOG_H
#define GUILITE_WIDGETS_INCLUDE_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, bool modal_mode = true);
static int close_dialog(c_surface* surface);
static c_dialog* get_the_dialog(c_surface* surface);
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

@@ -0,0 +1,34 @@
#ifndef GUILITE_WIDGETS_INCLUDE_EDIT_H
#define GUILITE_WIDGETS_INCLUDE_EDIT_H
#define MAX_EDIT_STRLEN 32
class c_edit : public c_wnd
{
friend class c_keyboard;
public:
virtual c_wnd* clone(){return new c_edit();}
const char* get_text(){return m_str;}
void set_text(const char* str);
void set_keyboard_style(KEYBOARD_STYLE kb_sytle) { m_kb_style = kb_sytle; }
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);
KEYBOARD_STYLE m_kb_style;
char m_str_input[MAX_EDIT_STRLEN];
char m_str[MAX_EDIT_STRLEN];
};
#endif

View File

@@ -0,0 +1,30 @@
#ifndef GUILITE_WIDGETS_INCLUDE_GESTURE_H
#define GUILITE_WIDGETS_INCLUDE_GESTURE_H
typedef enum{
TOUCH_MOVE,
TOUCH_IDLE
}TOUCH_STATE;
class c_slide_group;
class c_gesture{
public:
c_gesture(c_slide_group* group);
bool handle_swipe(int x, int y, TOUCH_ACTION action);
private:
bool on_move(int x);
bool on_swipe(int x);
int swipe_left();
int swipe_right();
void move_left();
void move_right();
int m_down_x;
int m_down_y;
int m_move_x;
int m_move_y;
TOUCH_STATE m_state;
c_slide_group* m_slide_group;
};
#endif

View File

@@ -0,0 +1,58 @@
#ifndef GUILITE_WIDGETS_INCLUDE_KEYBOARD_H
#define GUILITE_WIDGETS_INCLUDE_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_STYLE style);
KEYBOARD_STATUS get_cap_status(){return m_cap_status;}
char* get_str() { return m_str; }
protected:
virtual void pre_create_wnd();
virtual c_wnd* clone(){return new c_keyboard();}
virtual void on_paint();
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;
};
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

@@ -0,0 +1,14 @@
#ifndef GUILITE_WIDGETS_INCLUDE_LABEL_H
#define GUILITE_WIDGETS_INCLUDE_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

@@ -0,0 +1,39 @@
#ifndef GUILITE_WIDGETS_INCLUDE_LIST_BOX_H
#define GUILITE_WIDGETS_INCLUDE_LIST_BOX_H
#define MAX_ITEM_NUM 4
#define GL_LIST_CONFIRM 0x1
#define ON_LIST_CONFIRM(ctrlId, func) \
{MSG_TYPE_WND, GL_LIST_CONFIRM, (c_cmd_target*)ctrlId, MSG_CALLBACK_VWL, (MsgFuncVV)(static_cast<void (c_cmd_target::*)(unsigned int, int)>(&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

@@ -0,0 +1,29 @@
#ifndef GUILITE_WIDGETS_INCLUDE_SLIDE_GROUP_H
#define GUILITE_WIDGETS_INCLUDE_SLIDE_GROUP_H
#define MAX_PAGES 5
class c_gesture;
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 = 0,
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 = 0,
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;
c_gesture* m_gesture;
};
#endif

View File

@@ -0,0 +1,62 @@
#ifndef GUILITE_WIDGETS_INCLUDE_SPINBOX_H
#define GUILITE_WIDGETS_INCLUDE_SPINBOX_H
#define GL_SPIN_CONFIRM 0x2222
#define GL_SPIN_CHANGE 0x3333
#define ON_SPIN_CONFIRM(ctrlId, func) \
{MSG_TYPE_WND, GL_SPIN_CONFIRM, (c_cmd_target*)ctrlId, MSG_CALLBACK_VWL, (MsgFuncVV)(static_cast<void (c_cmd_target::*)(unsigned int, int)>(&func))},
#define ON_SPIN_CHANGE(ctrlId, func) \
{MSG_TYPE_WND, GL_SPIN_CHANGE, (c_cmd_target*)ctrlId, MSG_CALLBACK_VWL, (MsgFuncVV)(static_cast<void (c_cmd_target::*)(unsigned int, 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

@@ -0,0 +1,33 @@
#ifndef GUILITE_WIDGETS_INCLUDE_TABLE_H
#define GUILITE_WIDGETS_INCLUDE_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 row, int col, 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

@@ -0,0 +1,36 @@
#ifndef GUILITE_WIDGETS_INCLUDE_WAVE_BUFFER_H
#define GUILITE_WIDGETS_INCLUDE_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

@@ -0,0 +1,74 @@
#ifndef GUILITE_WIDGETS_INCLUDE_WAVE_CTRL_H
#define GUILITE_WIDGETS_INCLUDE_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