mirror of
https://gitee.com/idea4good/GuiLite.git
synced 2026-01-02 20:42:29 +08:00
refactor widgets
This commit is contained in:
@@ -2,18 +2,6 @@
|
||||
#define API_H
|
||||
|
||||
#define REAL_TIME_TASK_CYCLE_MS 50
|
||||
#define XXX -999
|
||||
#define NULL 0
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
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);
|
||||
|
||||
#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)
|
||||
@@ -25,7 +13,17 @@ void log_out(const char* log);
|
||||
#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))
|
||||
|
||||
typedef struct _T_TIME
|
||||
#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;
|
||||
@@ -36,6 +34,14 @@ typedef struct _T_TIME
|
||||
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();
|
||||
|
||||
@@ -7,11 +7,7 @@ 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_in_rect(c_surface* surface, int z_order, const BITMAP_INFO *pBitmap, c_rect rect, unsigned int align_type, unsigned int mask_rgb = DEFAULT_MASK_COLOR);
|
||||
private:
|
||||
static void draw_bitmap_565(c_surface* surface, int z_order, int x, int y, int xsize, int ysize, const unsigned char* pPixel, unsigned int mask_color);
|
||||
static void get_bitmap_pos(const BITMAP_INFO *pBitmap, c_rect rect, unsigned int align_type, int &x, int &y);
|
||||
static void draw_bitmap_565_in_rect(c_surface* surface, int z_order, int x, int y, int width, int height, int xsize, int ysize, const unsigned char* pPixel, unsigned int 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
|
||||
|
||||
@@ -11,7 +11,7 @@ class c_display {
|
||||
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 = NULL);
|
||||
unsigned int color_bytes, unsigned int surface_cnt, EXTERNAL_GFX_OP* gfx_op = 0);
|
||||
c_surface* alloc_surface(void* usr, Z_ORDER_LEVEL max_zorder);
|
||||
int merge_surface(c_surface* s1, c_surface* s2, int x0, int x1, int y0, int y2, int offset);
|
||||
unsigned int get_width() { return m_width; }
|
||||
|
||||
@@ -1,16 +1,6 @@
|
||||
#ifndef RECT_H
|
||||
#define RECT_H
|
||||
|
||||
#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
|
||||
|
||||
class c_rect
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
class c_frame_layer
|
||||
{
|
||||
public:
|
||||
c_frame_layer() { fb = NULL;}
|
||||
c_frame_layer() { fb = 0;}
|
||||
unsigned short* fb;
|
||||
c_rect rect;
|
||||
};
|
||||
@@ -63,7 +63,7 @@ protected:
|
||||
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 NULL
|
||||
c_frame_layer m_frame_layers[Z_ORDER_LEVEL_MAX];//Top layber fb always be 0
|
||||
void* m_usr;
|
||||
bool m_is_active;
|
||||
Z_ORDER_LEVEL m_max_zorder;
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
#ifndef WND_H
|
||||
#define WND_H
|
||||
|
||||
//Window attribution
|
||||
#define GL_ATTR_VISIBLE 0x80000000L
|
||||
#define GL_ATTR_DISABLED 0x40000000L
|
||||
#define GL_ATTR_FOCUS 0x20000000L
|
||||
#define GL_ATTR_MODAL 0x10000000L// Handle touch action at high priority
|
||||
|
||||
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,
|
||||
@@ -53,9 +55,9 @@ 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 = NULL);
|
||||
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 = NULL);
|
||||
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() {}
|
||||
@@ -65,8 +67,8 @@ public:
|
||||
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_style() const { return m_style; }
|
||||
void set_style(unsigned int style);
|
||||
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;
|
||||
@@ -114,7 +116,7 @@ protected:
|
||||
virtual void on_kill_focus() {};
|
||||
protected:
|
||||
WND_STATUS m_status;
|
||||
unsigned int m_style;
|
||||
WND_ATTRIBUTION m_attr;
|
||||
c_rect m_wnd_rect;// position relative to parent wnd.
|
||||
c_wnd* m_parent;
|
||||
c_wnd* m_top_child;
|
||||
|
||||
Reference in New Issue
Block a user