mirror of
https://gitee.com/idea4good/GuiLite.git
synced 2026-01-02 04:17:19 +08:00
refactor folder
This commit is contained in:
71
workspace/core_include/api.h
Normal file
71
workspace/core_include/api.h
Normal file
@@ -0,0 +1,71 @@
|
||||
#ifndef GUILITE_CORE_INCLUDE_API_H
|
||||
#define GUILITE_CORE_INCLUDE_API_H
|
||||
|
||||
#define REAL_TIME_TASK_CYCLE_MS 50
|
||||
|
||||
#define GL_ARGB(a, r, g, b) ((((unsigned int)(a)) << 24) | (((unsigned int)(r)) << 16) | (((unsigned int)(g)) << 8) | ((unsigned int)(b)))
|
||||
#define GL_ARGB_A(rgb) ((((unsigned int)(rgb)) >> 24) & 0xFF)
|
||||
|
||||
#define GL_RGB(r, g, b) ((0xFF << 24) | (((unsigned int)(r)) << 16) | (((unsigned int)(g)) << 8) | ((unsigned int)(b)))
|
||||
#define GL_RGB_R(rgb) ((((unsigned int)(rgb)) >> 16) & 0xFF)
|
||||
#define GL_RGB_G(rgb) ((((unsigned int)(rgb)) >> 8) & 0xFF)
|
||||
#define GL_RGB_B(rgb) (((unsigned int)(rgb)) & 0xFF)
|
||||
#define GL_RGB_32_to_16(rgb) (((((unsigned int)(rgb)) & 0xFF) >> 3) | ((((unsigned int)(rgb)) & 0xFC00) >> 5) | ((((unsigned int)(rgb)) & 0xF80000) >> 8))
|
||||
#define GL_RGB_16_to_32(rgb) ((0xFF << 24) | ((((unsigned int)(rgb)) & 0x1F) << 3) | ((((unsigned int)(rgb)) & 0x7E0) << 5) | ((((unsigned int)(rgb)) & 0xF800) << 8))
|
||||
|
||||
#define ALIGN_HCENTER 0x00000000L
|
||||
#define ALIGN_LEFT 0x01000000L
|
||||
#define ALIGN_RIGHT 0x02000000L
|
||||
#define ALIGN_HMASK 0x03000000L
|
||||
|
||||
#define ALIGN_VCENTER 0x00000000L
|
||||
#define ALIGN_TOP 0x00100000L
|
||||
#define ALIGN_BOTTOM 0x00200000L
|
||||
#define ALIGN_VMASK 0x00300000L
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short year;
|
||||
unsigned short month;
|
||||
unsigned short date;
|
||||
unsigned short day;
|
||||
unsigned short hour;
|
||||
unsigned short minute;
|
||||
unsigned short second;
|
||||
}T_TIME;
|
||||
|
||||
void register_debug_function(void(*my_assert)(const char* file, int line), void(*my_log_out)(const char* log));
|
||||
void _assert(const char* file, int line);
|
||||
#define ASSERT(condition) \
|
||||
do{ \
|
||||
if(!(condition))_assert(__FILE__, __LINE__);\
|
||||
}while(0)
|
||||
void log_out(const char* log);
|
||||
|
||||
long get_time_in_second();
|
||||
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));
|
||||
|
||||
unsigned int get_cur_thread_id();
|
||||
void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg);
|
||||
void thread_sleep(unsigned int milli_seconds);
|
||||
int build_bmp(const char *filename, unsigned int width, unsigned int height, unsigned char *data);
|
||||
|
||||
#define FIFO_BUFFER_LEN 1024
|
||||
class c_fifo
|
||||
{
|
||||
public:
|
||||
c_fifo();
|
||||
int read(void* buf, int len);
|
||||
int write(void* buf, int len);
|
||||
private:
|
||||
unsigned char m_buf[FIFO_BUFFER_LEN];
|
||||
int m_head;
|
||||
int m_tail;
|
||||
void* m_read_sem;
|
||||
void* m_write_mutex;
|
||||
};
|
||||
#endif
|
||||
19
workspace/core_include/audio.h
Normal file
19
workspace/core_include/audio.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef GUILITE_CORE_INCLUDE_AUDIO_H
|
||||
#define GUILITE_CORE_INCLUDE_AUDIO_H
|
||||
|
||||
enum AUDIO_TYPE
|
||||
{
|
||||
AUDIO_HEART_BEAT,
|
||||
AUDIO_ALARM,
|
||||
AUDIO_MAX
|
||||
};
|
||||
|
||||
class c_audio
|
||||
{
|
||||
public:
|
||||
static int play(AUDIO_TYPE type);
|
||||
private:
|
||||
static void init();
|
||||
};
|
||||
|
||||
#endif
|
||||
13
workspace/core_include/bitmap.h
Normal file
13
workspace/core_include/bitmap.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef GUILITE_CORE_INCLUDE_BITMAP_H
|
||||
#define GUILITE_CORE_INCLUDE_BITMAP_H
|
||||
|
||||
#define DEFAULT_MASK_COLOR 0xFF080408
|
||||
class c_surface;
|
||||
class c_bitmap
|
||||
{
|
||||
public:
|
||||
static void draw_bitmap(c_surface* surface, int z_order, const BITMAP_INFO *pBitmap, int x, int y, unsigned int mask_rgb = DEFAULT_MASK_COLOR);
|
||||
static void draw_bitmap(c_surface* surface, int z_order, const BITMAP_INFO* pBitmap, int x, int y, int src_x, int src_y, int width, int height, unsigned int mask_rgb = DEFAULT_MASK_COLOR);
|
||||
};
|
||||
|
||||
#endif
|
||||
81
workspace/core_include/cmd_target.h
Normal file
81
workspace/core_include/cmd_target.h
Normal file
@@ -0,0 +1,81 @@
|
||||
#ifndef GUILITE_CORE_INCLUDE_CMD_TARGET_H
|
||||
#define GUILITE_CORE_INCLUDE_CMD_TARGET_H
|
||||
|
||||
class c_cmd_target;
|
||||
|
||||
#define MSG_TYPE_INVALID 0xFFFF
|
||||
#define MSG_TYPE_WND 0x0001
|
||||
#define MSG_TYPE_USR 0x0002
|
||||
#define USR_MSG_MAX 32
|
||||
|
||||
typedef void (c_cmd_target::*MsgFuncVV)();
|
||||
|
||||
enum MSG_CALLBACK_TYPE
|
||||
{
|
||||
MSG_CALLBACK_NULL = 0,
|
||||
MSG_CALLBACK_VV,
|
||||
MSG_CALLBACK_IWL,
|
||||
MSG_CALLBACK_IWV,
|
||||
MSG_CALLBACK_VWV,
|
||||
MSG_CALLBACK_VVL,
|
||||
MSG_CALLBACK_VWL,
|
||||
MSG_CALLBACK_IVV
|
||||
};
|
||||
|
||||
typedef union
|
||||
{
|
||||
void (c_cmd_target::*func)();
|
||||
void (c_cmd_target::*func_vwv)(unsigned int w_param);
|
||||
int (c_cmd_target::*func_iwl)(unsigned int w_param, long l_param);
|
||||
int (c_cmd_target::*func_iwv)(unsigned int w_param);
|
||||
void (c_cmd_target::*func_vvl)(long l_param);
|
||||
void (c_cmd_target::*func_vwl)(unsigned int w_param, long l_param);
|
||||
int (c_cmd_target::*func_ivv)();
|
||||
}MSGFUNCS;
|
||||
|
||||
struct GL_MSG_ENTRY
|
||||
{
|
||||
unsigned int msgType;
|
||||
unsigned int msgId;
|
||||
c_cmd_target* pObject;
|
||||
MSG_CALLBACK_TYPE callbackType;
|
||||
MsgFuncVV func;
|
||||
};
|
||||
|
||||
#define ON_GL_USER_MSG(msgId, func) \
|
||||
{MSG_TYPE_USR, msgId, 0, MSG_CALLBACK_VWL, (MsgFuncVV)(static_cast<void (c_cmd_target::*)(unsigned int, unsigned int)>(&func))},
|
||||
|
||||
#define GL_DECLARE_MESSAGE_MAP() \
|
||||
protected: \
|
||||
virtual const GL_MSG_ENTRY* GetMSgEntries() const; \
|
||||
private: \
|
||||
static const GL_MSG_ENTRY mMsgEntries[];
|
||||
|
||||
#define GL_BEGIN_MESSAGE_MAP(theClass) \
|
||||
const GL_MSG_ENTRY* theClass::GetMSgEntries() const \
|
||||
{ \
|
||||
return theClass::mMsgEntries; \
|
||||
} \
|
||||
const GL_MSG_ENTRY theClass::mMsgEntries[] = \
|
||||
{
|
||||
|
||||
#define GL_END_MESSAGE_MAP() \
|
||||
{MSG_TYPE_INVALID, 0, (c_cmd_target*)0, MSG_CALLBACK_NULL, (MsgFuncVV)0}};
|
||||
|
||||
class c_cmd_target
|
||||
{
|
||||
public:
|
||||
c_cmd_target();
|
||||
virtual ~c_cmd_target();
|
||||
static int handle_usr_msg(unsigned int msgId, unsigned int wParam, unsigned int lParam);
|
||||
protected:
|
||||
void load_cmd_msg();
|
||||
const GL_MSG_ENTRY* FindMsgEntry(const GL_MSG_ENTRY *pEntry,
|
||||
unsigned int msgType, unsigned short msgId, unsigned short ctrlId);
|
||||
private:
|
||||
static GL_MSG_ENTRY ms_usr_map_entries[USR_MSG_MAX];
|
||||
static unsigned short ms_user_map_size;
|
||||
GL_DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
#endif
|
||||
33
workspace/core_include/display.h
Normal file
33
workspace/core_include/display.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef GUILITE_CORE_INCLUDE_DISPLAY_H
|
||||
#define GUILITE_CORE_INCLUDE_DISPLAY_H
|
||||
|
||||
#define SURFACE_CNT_MAX 6//root + pages
|
||||
|
||||
class c_hid_pipe;
|
||||
class c_surface;
|
||||
|
||||
class c_display {
|
||||
friend class c_surface;
|
||||
public:
|
||||
c_display(void* phy_fb, unsigned int display_width, unsigned int display_height,
|
||||
unsigned int surface_width, unsigned int surface_height,
|
||||
unsigned int color_bytes, unsigned int surface_cnt, EXTERNAL_GFX_OP* gfx_op = 0);
|
||||
c_surface* alloc_surface(Z_ORDER_LEVEL max_zorder);
|
||||
int swipe_surface(c_surface* s0, c_surface* s1, int x0, int x1, int y0, int y2, int offset);
|
||||
unsigned int get_width() { return m_width; }
|
||||
unsigned int get_height() { return m_height; }
|
||||
|
||||
void* get_updated_fb(int* width, int* height, bool force_update = false);
|
||||
int snap_shot(const char* file_name);
|
||||
private:
|
||||
unsigned int m_width; //in pixels
|
||||
unsigned int m_height; //in pixels
|
||||
unsigned int m_color_bytes; //16 bits, 32 bits only
|
||||
void* m_phy_fb;
|
||||
int m_phy_read_index;
|
||||
int m_phy_write_index;
|
||||
c_surface* m_surface_group[SURFACE_CNT_MAX];
|
||||
unsigned int m_surface_cnt;
|
||||
unsigned int m_surface_index;
|
||||
};
|
||||
#endif
|
||||
27
workspace/core_include/rect.h
Normal file
27
workspace/core_include/rect.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef GUILITE_CORE_INCLUDE_RECT_H
|
||||
#define GUILITE_CORE_INCLUDE_RECT_H
|
||||
|
||||
class c_rect
|
||||
{
|
||||
public:
|
||||
c_rect(){Empty();}
|
||||
c_rect(int left, int top, int right, int bottom){m_left = left;m_top = top;m_right = right;m_bottom = bottom;};
|
||||
void SetRect( int left, int top, int right, int bottom);
|
||||
c_rect(const c_rect&);
|
||||
c_rect& operator=(const c_rect&);
|
||||
void Empty();
|
||||
void Offset(int x, int y);
|
||||
int IsEmpty() const ;
|
||||
int PtInRect(int x, int y) const ;
|
||||
int operator==(const c_rect& ) const;
|
||||
c_rect operator&(const c_rect& aRect) const;
|
||||
int Width() const {return m_right - m_left + 1;}
|
||||
int Height() const {return m_bottom - m_top + 1;}
|
||||
|
||||
int m_left;
|
||||
int m_top;
|
||||
int m_right;
|
||||
int m_bottom;
|
||||
};
|
||||
|
||||
#endif
|
||||
28
workspace/core_include/resource.h
Normal file
28
workspace/core_include/resource.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef GUILITE_CORE_INCLUDE_RESOURCE_H
|
||||
#define GUILITE_CORE_INCLUDE_RESOURCE_H
|
||||
|
||||
//BITMAP
|
||||
typedef struct struct_bitmap_info
|
||||
{
|
||||
unsigned short width;
|
||||
unsigned short height;
|
||||
unsigned short color_bits;//support 16 bits only
|
||||
const unsigned short* pixel_color_array;
|
||||
} BITMAP_INFO;
|
||||
|
||||
//FONT
|
||||
typedef struct struct_lattice
|
||||
{
|
||||
unsigned int utf8_code;
|
||||
unsigned char width;
|
||||
const unsigned char* pixel_gray_array;
|
||||
} LATTICE;
|
||||
|
||||
typedef struct struct_font_info
|
||||
{
|
||||
unsigned char height;
|
||||
unsigned int count;
|
||||
LATTICE* lattice_array;
|
||||
} FONT_INFO;
|
||||
|
||||
#endif
|
||||
85
workspace/core_include/surface.h
Normal file
85
workspace/core_include/surface.h
Normal file
@@ -0,0 +1,85 @@
|
||||
#ifndef GUILITE_CORE_INCLUDE_SURFACE_H
|
||||
#define GUILITE_CORE_INCLUDE_SURFACE_H
|
||||
|
||||
class c_frame_layer
|
||||
{
|
||||
public:
|
||||
c_frame_layer() { fb = 0;}
|
||||
unsigned short* fb;
|
||||
c_rect visible_rect;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Z_ORDER_LEVEL_0,//view/wave/page
|
||||
Z_ORDER_LEVEL_1,//dialog
|
||||
Z_ORDER_LEVEL_2,//editbox/spinbox/listbox/keyboard
|
||||
Z_ORDER_LEVEL_MAX
|
||||
}Z_ORDER_LEVEL;
|
||||
|
||||
struct EXTERNAL_GFX_OP
|
||||
{
|
||||
void(*draw_pixel)(int x, int y, unsigned int rgb);
|
||||
void(*fill_rect)(int x0, int y0, int x1, int y1, unsigned int rgb);
|
||||
};
|
||||
|
||||
class c_display;
|
||||
class c_surface {
|
||||
friend class c_display; friend class c_bitmap;
|
||||
public:
|
||||
int get_width() { return m_width; }
|
||||
int get_height() { return m_height; }
|
||||
unsigned int get_pixel(int x, int y, unsigned int z_order);
|
||||
|
||||
void draw_pixel(int x, int y, unsigned int rgb, unsigned int z_order);
|
||||
void fill_rect(int x0, int y0, int x1, int y1, unsigned int rgb, unsigned int z_order);
|
||||
void draw_hline(int x0, int x1, int y, unsigned int rgb, unsigned int z_order);
|
||||
void draw_vline(int x, int y0, int y1, unsigned int rgb, unsigned int z_order);
|
||||
void draw_line(int x0, int y0, int x1, int y1, unsigned int rgb, unsigned int z_order);
|
||||
void draw_rect(int x0, int y0, int x1, int y1, unsigned int rgb, unsigned int z_order, unsigned int size = 1);
|
||||
|
||||
inline void draw_rect(c_rect rect, unsigned int rgb, unsigned int size, unsigned int z_order)
|
||||
{
|
||||
draw_rect(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, rgb, z_order, size);
|
||||
}
|
||||
inline void fill_rect(c_rect rect, unsigned int rgb, unsigned int z_order)
|
||||
{
|
||||
fill_rect(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, rgb, z_order);
|
||||
}
|
||||
|
||||
int flush_screen(int left, int top, int right, int bottom);
|
||||
bool is_valid(c_rect rect);
|
||||
bool is_active() { return m_is_active; }
|
||||
c_display* get_display() { return m_display; }
|
||||
|
||||
int set_frame_layer_visible_rect(c_rect& rect, unsigned int z_order);
|
||||
void set_active(bool flag){m_is_active = flag;}
|
||||
protected:
|
||||
virtual void fill_rect_on_fb(int x0, int y0, int x1, int y1, unsigned int rgb);
|
||||
virtual void draw_pixel_on_fb(int x, int y, unsigned int rgb);
|
||||
void set_surface(Z_ORDER_LEVEL max_z_order);
|
||||
c_surface(c_display* display, unsigned int width, unsigned int height, unsigned int color_bytes);
|
||||
int m_width; //in pixels
|
||||
int m_height; //in pixels
|
||||
int m_color_bytes; //16 bits, 32 bits only
|
||||
void* m_fb; //Top frame buffer you could see
|
||||
c_frame_layer m_frame_layers[Z_ORDER_LEVEL_MAX];//Top layber fb always be 0
|
||||
bool m_is_active;
|
||||
Z_ORDER_LEVEL m_max_zorder;
|
||||
Z_ORDER_LEVEL m_top_zorder;
|
||||
void* m_phy_fb;
|
||||
int* m_phy_write_index;
|
||||
c_display* m_display;
|
||||
};
|
||||
|
||||
class c_surface_no_fb : public c_surface {//No physical framebuffer, memory fb is 32 bits
|
||||
friend class c_display;
|
||||
c_surface_no_fb(c_display* display, unsigned int width, unsigned int height, unsigned int color_bytes, struct EXTERNAL_GFX_OP* gfx_op) :
|
||||
c_surface(display, width, height, color_bytes) {m_gfx_op = gfx_op;}
|
||||
protected:
|
||||
virtual void fill_rect_on_fb(int x0, int y0, int x1, int y1, unsigned int rgb);
|
||||
virtual void draw_pixel_on_fb(int x, int y, unsigned int rgb);
|
||||
struct EXTERNAL_GFX_OP* m_gfx_op;//Rendering by external method
|
||||
};
|
||||
|
||||
#endif
|
||||
65
workspace/core_include/theme.h
Normal file
65
workspace/core_include/theme.h
Normal file
@@ -0,0 +1,65 @@
|
||||
#ifndef GUILITE_CORE_INCLUDE_THEME_H
|
||||
#define GUILITE_CORE_INCLUDE_THEME_H
|
||||
|
||||
typedef struct struct_font_info FONT_INFO;
|
||||
typedef struct struct_color_rect COLOR_RECT;
|
||||
typedef struct struct_bitmap_info BITMAP_INFO;
|
||||
|
||||
//Rebuild gui library once you change this file
|
||||
enum FONT_TYPE
|
||||
{
|
||||
FONT_NULL,
|
||||
FONT_DEFAULT,
|
||||
FONT_CUSTOM1,
|
||||
FONT_CUSTOM2,
|
||||
FONT_CUSTOM3,
|
||||
FONT_CUSTOM4,
|
||||
FONT_CUSTOM5,
|
||||
FONT_CUSTOM6,
|
||||
FONT_MAX
|
||||
};
|
||||
|
||||
enum BITMAP_TYPE
|
||||
{
|
||||
BITMAP_CUSTOM1,
|
||||
BITMAP_CUSTOM2,
|
||||
BITMAP_CUSTOM3,
|
||||
BITMAP_CUSTOM4,
|
||||
BITMAP_CUSTOM5,
|
||||
BITMAP_CUSTOM6,
|
||||
|
||||
BITMAP_MAX
|
||||
};
|
||||
|
||||
enum COLOR_TYPE
|
||||
{
|
||||
COLOR_WND_FONT,
|
||||
COLOR_WND_NORMAL,
|
||||
COLOR_WND_PUSHED,
|
||||
COLOR_WND_FOCUS,
|
||||
COLOR_WND_BORDER,
|
||||
|
||||
COLOR_CUSTOME1,
|
||||
COLOR_CUSTOME2,
|
||||
COLOR_CUSTOME3,
|
||||
COLOR_CUSTOME4,
|
||||
COLOR_CUSTOME5,
|
||||
COLOR_CUSTOME6,
|
||||
|
||||
COLOR_MAX
|
||||
};
|
||||
|
||||
class c_theme
|
||||
{
|
||||
public:
|
||||
static int add_font(FONT_TYPE index, const FONT_INFO* font);
|
||||
static const FONT_INFO* get_font(FONT_TYPE index);
|
||||
|
||||
static int add_bitmap(BITMAP_TYPE index, const BITMAP_INFO* bmp);
|
||||
static const BITMAP_INFO* get_bmp(BITMAP_TYPE index);
|
||||
|
||||
static int add_color(COLOR_TYPE index, const unsigned int color);
|
||||
static const unsigned int get_color(COLOR_TYPE index);
|
||||
};
|
||||
|
||||
#endif
|
||||
138
workspace/core_include/wnd.h
Normal file
138
workspace/core_include/wnd.h
Normal file
@@ -0,0 +1,138 @@
|
||||
#ifndef GUILITE_CORE_INCLUDE_WND_H
|
||||
#define GUILITE_CORE_INCLUDE_WND_H
|
||||
|
||||
typedef struct struct_font_info FONT_INFO;
|
||||
typedef struct struct_color_rect COLOR_RECT;
|
||||
|
||||
class c_wnd;
|
||||
class c_surface;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ATTR_VISIBLE = 0x80000000L,
|
||||
ATTR_DISABLED = 0x40000000L,
|
||||
ATTR_FOCUS = 0x20000000L,
|
||||
ATTR_MODAL = 0x10000000L// Handle touch action at high priority
|
||||
}WND_ATTRIBUTION;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
STATUS_NORMAL,
|
||||
STATUS_PUSHED,
|
||||
STATUS_FOCUSED,
|
||||
STATUS_DISABLED
|
||||
}WND_STATUS;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
KEY_FORWARD,
|
||||
KEY_BACKWARD,
|
||||
KEY_ENTER
|
||||
}KEY_TYPE;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TOUCH_DOWN,
|
||||
TOUCH_UP
|
||||
}TOUCH_ACTION;
|
||||
|
||||
typedef struct struct_wnd_tree
|
||||
{
|
||||
c_wnd* p_wnd;
|
||||
unsigned int resource_id;
|
||||
const char* str;
|
||||
short x;
|
||||
short y;
|
||||
short width;
|
||||
short height;
|
||||
struct struct_wnd_tree* p_child_tree;
|
||||
}WND_TREE;
|
||||
|
||||
class c_wnd : public c_cmd_target
|
||||
{
|
||||
friend class c_dialog;
|
||||
public:
|
||||
c_wnd();
|
||||
virtual ~c_wnd() {};
|
||||
virtual int connect(c_wnd *parent, unsigned short resource_id, const char* str,
|
||||
short x, short y, short width, short height, WND_TREE* p_child_tree = 0);
|
||||
virtual c_wnd* connect_clone(c_wnd *parent, unsigned short resource_id, const char* str,
|
||||
short x, short y, short width, short height, WND_TREE* p_child_tree = 0);
|
||||
void disconnect();
|
||||
virtual c_wnd* clone() = 0;
|
||||
virtual void on_init_children() {}
|
||||
virtual void on_paint() {}
|
||||
virtual void show_window();
|
||||
|
||||
unsigned short get_id() const { return m_resource_id; }
|
||||
int get_z_order() { return m_z_order; }
|
||||
c_wnd* get_wnd_ptr(unsigned short id) const;
|
||||
unsigned int get_attr() const { return m_attr; }
|
||||
void set_attr(WND_ATTRIBUTION attr);
|
||||
|
||||
void set_str(const char* str) { m_str = str; }
|
||||
int is_focus_wnd() const;
|
||||
|
||||
void set_font_color(unsigned int color) { m_font_color = color; }
|
||||
unsigned int get_font_color() { return m_font_color; }
|
||||
void set_bg_color(unsigned int color) { m_bg_color = color; }
|
||||
unsigned int get_bg_color() { return m_bg_color; }
|
||||
void set_font_type(const FONT_INFO *font_type) { m_font_type = font_type; }
|
||||
const FONT_INFO* get_font_type() { return m_font_type; }
|
||||
|
||||
void set_wnd_pos(short x, short y, short width, short height);
|
||||
void get_wnd_rect(c_rect &rect) const;
|
||||
void get_screen_rect(c_rect &rect) const;
|
||||
|
||||
c_wnd* set_child_focus(c_wnd *focus_child);
|
||||
|
||||
c_wnd* get_parent() const { return m_parent; }
|
||||
c_wnd* get_last_child() const;
|
||||
int unlink_child(c_wnd *child);
|
||||
c_wnd* get_prev_sibling() const { return m_prev_sibling; }
|
||||
c_wnd* get_next_sibling() const { return m_next_sibling; }
|
||||
|
||||
void notify_parent(unsigned int msg_id, int param);
|
||||
|
||||
virtual bool on_touch(int x, int y, TOUCH_ACTION action);// return true: handled; false: not be handled.
|
||||
virtual bool on_key(KEY_TYPE key);// return false: skip handling by parent;
|
||||
|
||||
c_surface* get_surface() { return m_surface; }
|
||||
void set_surface(c_surface* surface) { m_surface = surface; }
|
||||
protected:
|
||||
virtual void pre_create_wnd() {};
|
||||
void add_child_2_tail(c_wnd *child);
|
||||
|
||||
void wnd2screen(int &x, int &y) const;
|
||||
void wnd2screen(c_rect &rect) const;
|
||||
|
||||
int load_child_wnd(WND_TREE *p_child_tree);
|
||||
int load_clone_child_wnd(WND_TREE *p_child_tree);
|
||||
void set_active_child(c_wnd* child) { m_focus_child = child; }
|
||||
|
||||
virtual void on_focus() {};
|
||||
virtual void on_kill_focus() {};
|
||||
protected:
|
||||
WND_STATUS m_status;
|
||||
WND_ATTRIBUTION m_attr;
|
||||
c_rect m_wnd_rect;// position relative to parent wnd.
|
||||
c_wnd* m_parent;
|
||||
c_wnd* m_top_child;
|
||||
c_wnd* m_prev_sibling;
|
||||
c_wnd* m_next_sibling;
|
||||
const char* m_str;
|
||||
|
||||
const FONT_INFO* m_font_type;
|
||||
unsigned int m_font_color;
|
||||
unsigned int m_bg_color;
|
||||
|
||||
unsigned short m_resource_id;
|
||||
|
||||
int m_z_order;
|
||||
c_wnd* m_focus_child;//current focused wnd
|
||||
c_surface* m_surface;
|
||||
private:
|
||||
c_wnd(const c_wnd &win);
|
||||
c_wnd& operator=(const c_wnd &win);
|
||||
};
|
||||
#endif
|
||||
23
workspace/core_include/word.h
Normal file
23
workspace/core_include/word.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef GUILITE_CORE_INCLUDE_WORD_H
|
||||
#define GUILITE_CORE_INCLUDE_WORD_H
|
||||
|
||||
class c_surface;
|
||||
class c_word
|
||||
{
|
||||
public:
|
||||
static void draw_string(c_surface* surface, int z_order, const char *s, int x, int y, const FONT_INFO* font, unsigned int font_color, unsigned int bg_color, unsigned int align_type = ALIGN_LEFT);
|
||||
static void draw_string_in_rect(c_surface* surface, int z_order, const char *s, c_rect rect, const FONT_INFO* font, unsigned int font_color, unsigned int bg_color, unsigned int align_type = ALIGN_LEFT);
|
||||
static void draw_value(c_surface* surface, int z_order, int value, int dot_position, int x, int y, const FONT_INFO* font, unsigned int font_color, unsigned int bg_color, unsigned int align_type = ALIGN_LEFT);
|
||||
static void draw_value_in_rect(c_surface* surface, int z_order, int value, int dot_position, c_rect rect, const FONT_INFO* font, unsigned int font_color, unsigned int bg_color, unsigned int align_type = ALIGN_LEFT);
|
||||
static void value_2_string(int value, int dot_position, char* buf, int len);
|
||||
|
||||
static int get_str_size(const char *s, const FONT_INFO* font, int& width, int& height);
|
||||
private:
|
||||
static int draw_single_char(c_surface* surface, int z_order, unsigned int utf8_code, int x, int y, const FONT_INFO* font, unsigned int font_color, unsigned int bg_color);
|
||||
static void draw_lattice(c_surface* surface, int z_order, int x, int y, int width, int height, const unsigned char* p_data, unsigned int font_color, unsigned int bg_color);
|
||||
|
||||
static const LATTICE* get_lattice(const FONT_INFO* font, unsigned int utf8_code);
|
||||
static void get_string_pos(const char *s, const FONT_INFO* font, c_rect rect, unsigned int align_type, int &x, int &y);
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user