remove shape resource

This commit is contained in:
idea4good 2018-12-28 15:56:36 +08:00
parent 389202b202
commit 6cdcd25436
19 changed files with 156 additions and 280 deletions

View File

@ -25,16 +25,4 @@ typedef struct struct_font_info
LATTICE* lattice_array;
} FONT_INFO;
//SHAPE
#define INVALID_RGN 0xFFFFFF
#define COLOR_USERDEF GL_RGB(41,49,49)
typedef struct struct_color_rect
{
int l;
int t;
int r;
int b;
unsigned int color;
}COLOR_RECT;
#endif

View File

@ -23,7 +23,6 @@ class c_surface {
public:
virtual void draw_pixel(int x, int y, unsigned int rgb, unsigned int z_order);
virtual void fill_rect(int x0, int y0, int x1, int y1, unsigned int rgb, unsigned int z_order);
void fill_rect_ex(int l, int t, int r, int b, unsigned int color, const COLOR_RECT* extend_rects, int z_order);
virtual unsigned int get_pixel(int x, int y, unsigned int z_order);
int get_width() { return m_width; }
@ -31,7 +30,7 @@ public:
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);
void draw_rect(int x0, int y0, int x1, int y1, unsigned int rgb, unsigned int z_order, unsigned int size = 1);
int flush_scrren(int left, int top, int right, int bottom);
bool is_valid(c_rect rect);
@ -45,7 +44,6 @@ protected:
virtual void set_pixel(int x, int y, unsigned int rgb);
void set_surface(void* wnd_root, Z_ORDER_LEVEL max_z_order);
int copy_layer_pixel_2_fb(int x, int y, unsigned int 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

View File

@ -85,9 +85,6 @@ public:
c_wnd* get_active_child() const { return m_active_child; }
void modify_status(WND_STATUS status) { m_status = status; }
WND_STATUS get_status() { return m_status; }
c_surface* get_surface() { return m_surface; }
void set_surface(c_surface* surface) { m_surface = surface; }
protected:
@ -111,12 +108,10 @@ protected:
void draw_hline(int x0, int x1, int y, unsigned int rgb);
void draw_vline(int x, int y0, int y1, unsigned int rgb);
void draw_line(int x0, int y0, int x1, int y1, unsigned int rgb);
void draw_rect(int x0, int y0, int x1, int y1, unsigned int rgb);
void draw_rect(c_rect rect, unsigned int rgb);
void draw_rect(int x0, int y0, int x1, int y1, unsigned int rgb, unsigned int size = 1);
void draw_rect(c_rect rect, unsigned int rgb, unsigned int size = 1);
void fill_rect(int x0, int y0, int x1, int y1, unsigned int rgb);
void fill_rect(c_rect rect, unsigned int rgb);
void fill_rect_ex(int l, int t, int r, int b, unsigned int color, const COLOR_RECT* extend_rects);
void fill_rect_ex(c_rect rect, unsigned int color, const COLOR_RECT* extend_rects);
protected:
WND_STATUS m_status;
unsigned int m_style;

View File

@ -300,119 +300,89 @@ void c_surface::draw_line(int x1, int y1, int x2, int y2, unsigned int rgb, unsi
}
}
void c_surface::draw_rect(int x0, int y0, int x1, int y1, unsigned int rgb, unsigned int z_order)
void c_surface::draw_rect(int x0, int y0, int x1, int y1, unsigned int rgb, unsigned int z_order, unsigned int size)
{
draw_hline(x0, x1, y0, rgb, z_order);
draw_hline(x0, x1, y1, rgb, z_order);
draw_vline(x0, y0, y1, rgb, z_order);
draw_vline(x1, y0, y1, rgb, z_order);
for (unsigned int offset = 0; offset < size; offset++)
{
draw_hline(x0 + offset, x1 - offset, y0 + offset, rgb, z_order);
draw_hline(x0 + offset, x1 - offset, y1 - offset, rgb, z_order);
draw_vline(x0 + offset, y0 + offset, y1 - offset, rgb, z_order);
draw_vline(x1 - offset, y0 + offset, y1 - offset, rgb, z_order);
}
}
int c_surface::set_frame_layer(c_rect& rect, unsigned int z_order)
{
if (z_order <= Z_ORDER_LEVEL_0 || z_order >= Z_ORDER_LEVEL_MAX)
if (rect == m_frame_layers[z_order].rect)
{
return 0;
}
if (rect.m_left < 0 || rect.m_left >= m_width ||
rect.m_right < 0 || rect.m_right >= m_width ||
rect.m_top < 0 || rect.m_top >= m_height ||
rect.m_bottom < 0 || rect.m_bottom >=m_height)
{
ASSERT(FALSE);
return -1;
}
if (!(rect == m_frame_layers[z_order].rect))
{//release current zone, and recover the lower layer
c_rect rc = m_frame_layers[z_order].rect;
int src_order = m_top_zorder = (Z_ORDER_LEVEL)(z_order - 1);
int x,y;
for(y = rc.m_top; y <= rc.m_bottom; y++)
{
for(x = rc.m_left; x <= rc.m_right; x++)
{
if(m_frame_layers[src_order].rect.PtInRect(x,y))
{
copy_layer_pixel_2_fb(x, y, src_order);
}
else
{
if(src_order - 1 < Z_ORDER_LEVEL_0)continue;
if(m_frame_layers[src_order - 1].rect.PtInRect(x,y))
{
copy_layer_pixel_2_fb(x, y, src_order - 1);
}
}
}
}
}
m_frame_layers[z_order].rect = rect;
return 1;
}
int c_surface::copy_layer_pixel_2_fb(int x, int y, unsigned int z_order)
{
if (x >= m_width || y >= m_height || x < 0 || y < 0 ||
z_order >= Z_ORDER_LEVEL_MAX)
if (!(z_order > Z_ORDER_LEVEL_0 || z_order < Z_ORDER_LEVEL_MAX))
{
ASSERT(FALSE);
return 0;
return -2;
}
if (z_order < m_top_zorder)
{
ASSERT(FALSE);
return -3;
}
m_top_zorder = (Z_ORDER_LEVEL)z_order;
c_rect current_rect = m_frame_layers[z_order].rect;
if (!current_rect.IsEmpty())
{
//Recover the lower layer
int src_zorder = (Z_ORDER_LEVEL)(z_order - 1);
int display_width = m_display->get_width();
int display_height = m_display->get_height();
for (int y = current_rect.m_top; y <= current_rect.m_bottom; y++)
{
for (int x = current_rect.m_left; x <= current_rect.m_right; x++)
{
if (m_frame_layers[src_zorder].rect.PtInRect(x, y))
{
if (m_color_bytes == 4)
{
unsigned int rgb = ((unsigned int*)(m_frame_layers[z_order].fb))[x + y * m_width];
unsigned int rgb = ((unsigned int*)(m_frame_layers[src_zorder].fb))[x + y * m_width];
((unsigned int*)m_fb)[y * m_width + x] = rgb;
if (m_is_active && (x < display_width) && (y < display_height))
{
((unsigned int*)m_phy_fb)[y * display_width + x] = rgb;
*m_phy_write_index = *m_phy_write_index + 1;
}
}
else//16 bits
{
short rgb = ((short*)(m_frame_layers[z_order].fb))[x + y * m_width];
short rgb = ((short*)(m_frame_layers[src_zorder].fb))[x + y * m_width];
((short*)m_fb)[y * m_width + x] = rgb;
if (m_is_active && (x < display_width) && (y < display_height))
{
((short*)m_phy_fb)[y * display_width + x] = rgb;
}
}
}
}
}
}
m_frame_layers[z_order].rect = rect;
if (rect.IsEmpty())
{
m_top_zorder = (Z_ORDER_LEVEL)(z_order - 1);
}
*m_phy_write_index = *m_phy_write_index + 1;
}
}
return 0;
}
void c_surface::fill_rect_ex(int l, int t, int r, int b, unsigned int color, const COLOR_RECT* extend_rects, int z_order)
{
if (NULL == extend_rects)
{
return fill_rect(l, t, r, b, color, z_order);
}
COLOR_RECT* p_item = (COLOR_RECT*)extend_rects;
int templ, tempt, tempr, tempb;
for(int i = 0; INVALID_RGN != p_item[i].l; i++)
{
templ = (p_item[i].l < 0) ? (r + 1 + p_item[i].l) : p_item[i].l + l;
tempt = (p_item[i].t < 0) ? (b + 1 + p_item[i].t) : p_item[i].t + t;
tempr = (p_item[i].r < 0) ? (r + 1 + p_item[i].r) : p_item[i].r + l;
tempb = (p_item[i].b < 0) ? (b + 1 + p_item[i].b) : p_item[i].b + t;
if (templ >= tempr)
tempr = templ;
if (tempt >= tempb)
tempb = tempt;
unsigned int tempcolor = (COLOR_USERDEF == p_item[i].color) ? (color) : p_item[i].color;
for (int y = tempt ; y <= tempb; y++)
{
for(int x = templ; x <= tempr; x++)
{
draw_pixel(x , y, tempcolor, z_order);
}
}
}
}
int c_surface::flush_scrren(int left, int top, int right, int bottom)
{
if(left < 0 || left >= m_width || right < 0 || right >= m_width ||
@ -534,13 +504,14 @@ void c_surface_16bits::fill_rect(int x0, int y0, int x1, int y1, unsigned int rg
{
int x, y;
unsigned short *mem_fb;
unsigned int rgb_16 = GL_RGB_32_to_16(rgb);
for (y = y0; y <= y1; y++)
{
x = x0;
mem_fb = &((unsigned short*)m_frame_layers[z_order].fb)[y * m_width + x];
for (; x <= x1; x++)
{
*mem_fb++ = rgb;
*mem_fb++ = rgb_16;
}
}
return fill_rect_on_fb(x0, y0, x1, y1, GL_RGB_32_to_16(rgb));

View File

@ -624,14 +624,14 @@ void c_wnd::draw_line(int x0, int y0, int x1, int y1, unsigned int rgb)
m_surface->draw_line(x0, y0, x1, y1, rgb, m_z_order);
}
void c_wnd::draw_rect(int x0, int y0, int x1, int y1, unsigned int rgb)
void c_wnd::draw_rect(int x0, int y0, int x1, int y1, unsigned int rgb, unsigned int size)
{
m_surface->draw_rect(x0, y0, x1, y1, rgb, m_z_order);
m_surface->draw_rect(x0, y0, x1, y1, rgb, m_z_order, size);
}
void c_wnd::draw_rect(c_rect rect, unsigned int rgb)
void c_wnd::draw_rect(c_rect rect, unsigned int rgb, unsigned int size)
{
m_surface->draw_rect(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, rgb, m_z_order);
m_surface->draw_rect(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, rgb, m_z_order, size);
}
void c_wnd::fill_rect(int x0, int y0, int x1, int y1, unsigned int rgb)
@ -643,13 +643,3 @@ void c_wnd::fill_rect(c_rect rect, unsigned int rgb)
{
m_surface->fill_rect(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, rgb, m_z_order);
}
void c_wnd::fill_rect_ex(int l, int t, int r, int b, unsigned int color, const COLOR_RECT* extend_rects)
{
m_surface->fill_rect_ex(l, t, r, b, color, extend_rects, m_z_order);
}
void c_wnd::fill_rect_ex(c_rect rect, unsigned int color, const COLOR_RECT* extend_rects)
{
m_surface->fill_rect_ex(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, color, extend_rects, m_z_order);
}

View File

@ -15,6 +15,7 @@ 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);
void set_divider_lines(unsigned char lines){m_divider_lines = lines;}
virtual void on_touch_down(int x, int y);
virtual void on_touch_up(int x, int y);
@ -24,7 +25,6 @@ protected:
virtual void on_paint();
static DIALOG_ARRAY ms_the_dialogs[SURFACE_CNT_MAX];
private:
static c_dialog* get_the_dialog(c_surface* surface);
int set_me_the_dialog();
unsigned char m_divider_lines;
};

View File

@ -27,8 +27,7 @@ typedef enum
class c_keyboard: public c_wnd
{
public:
virtual int create(c_wnd *parent, unsigned short resource_id, char* str,
short x, short y, short width, short height, WND_TREE* p_child_tree = NULL);
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; }

View File

@ -27,7 +27,6 @@ public:
protected:
virtual c_wnd* clone(){return new c_list_box();}
virtual void pre_create_wnd();
virtual void on_init_children();
virtual void on_paint();
virtual void on_focus();
virtual void on_kill_focus();

View File

@ -36,29 +36,20 @@ enum BITMAP_TYPE
BITMAP_MAX
};
enum SHAPE_TYPE
{
BUTTON_NORMAL,
BUTTON_FOCUS,
BUTTON_PUSH,
LIST_BOX_SELECT,
LIST_BOX_PUSH,
LIST_BOX_EXTEND,
KEY_BUTTON_NORMAL,
KEY_BUTTON_PUSH,
SHAPE_CUSTOM1,
SHAPE_CUSTOM2,
SHAPE_CUSTOM3,
SHAPE_MAX
};
enum COLOR_TYPE
{
WND_BACKCOLOR,
WND_FORECOLOR,
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
};
@ -72,9 +63,6 @@ public:
static int add_bitmap(BITMAP_TYPE index, const BITMAP_INFO* bmp);
static const BITMAP_INFO* get_bmp(BITMAP_TYPE index);
static int add_shape(SHAPE_TYPE index, const COLOR_RECT* shape);
static const COLOR_RECT* get_shape(SHAPE_TYPE index);
static int add_color(COLOR_TYPE index, const unsigned int color);
static const unsigned int get_color(COLOR_TYPE index);
};

View File

@ -16,15 +16,13 @@ public:
int set_row_height(unsigned int index, unsigned int height);
int set_col_width(unsigned int index, unsigned int width);
int set_item(int row, int col, char* str, unsigned int with_bg_color = -1);
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:
virtual void pre_create_wnd();
void draw_item(int col, int row, const char* str, unsigned int with_bg_color = -1);
void draw_item(int col, int row, const char* str, unsigned int color);
unsigned int m_align_type;
unsigned int m_row_num;

View File

@ -13,26 +13,25 @@ void c_button::pre_create_wnd()
{
m_style = GL_ATTR_VISIBLE | GL_ATTR_FOCUS | ALIGN_HCENTER | ALIGN_VCENTER;
m_font_type = c_my_resource::get_font(FONT_DEFAULT);
m_font_color = c_my_resource::get_color(WND_FORECOLOR);
m_bg_color = c_my_resource::get_color(WND_BACKCOLOR);
m_font_color = c_my_resource::get_color(COLOR_WND_FONT);
}
void c_button::on_focus()
{
modify_status(STATUS_FOCUSED);
m_status = STATUS_FOCUSED;
on_paint();
}
void c_button::on_kill_focus()
{
modify_status(STATUS_NORMAL);
m_status = STATUS_NORMAL;
on_paint();
}
void c_button::on_touch_down(int x, int y)
{
get_parent()->set_focus(this);
modify_status(STATUS_PUSHED);
m_status = STATUS_PUSHED;
on_paint();
}
@ -40,7 +39,7 @@ void c_button::on_touch_up(int x, int y)
{
if (STATUS_PUSHED == m_status)
{
modify_status(STATUS_FOCUSED);
m_status = STATUS_FOCUSED;
on_paint();
notify_parent(GL_BN_CLICKED, get_id(), 0);
@ -61,7 +60,7 @@ void c_button::on_paint()
}
else
{
fill_rect_ex(rect, m_bg_color, c_my_resource::get_shape(BUTTON_NORMAL));
fill_rect(rect, c_my_resource::get_color(COLOR_WND_NORMAL));
}
break;
case STATUS_FOCUSED:
@ -71,7 +70,7 @@ void c_button::on_paint()
}
else
{
fill_rect_ex(rect, m_bg_color, c_my_resource::get_shape(BUTTON_FOCUS));
fill_rect(rect, c_my_resource::get_color(COLOR_WND_FOCUS));
}
break;
case STATUS_PUSHED:
@ -81,7 +80,8 @@ void c_button::on_paint()
}
else
{
fill_rect_ex(rect, m_bg_color, c_my_resource::get_shape(BUTTON_PUSH));
fill_rect(rect, c_my_resource::get_color(COLOR_WND_PUSHED));
draw_rect(rect, c_my_resource::get_color(COLOR_WND_BORDER), 2);
}
break;
default:

View File

@ -19,7 +19,7 @@ void c_dialog::pre_create_wnd()
{
m_style = GL_ATTR_FOCUS;
m_z_order = Z_ORDER_LEVEL_1;
m_bg_color = GL_RGB(33,33,33);
m_bg_color = GL_RGB(33, 42, 53);
m_divider_lines = 0;
}
@ -27,8 +27,7 @@ void c_dialog::on_paint()
{
c_rect rect;
get_screen_rect(rect);
m_surface->fill_rect(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, m_bg_color, m_z_order);
fill_rect(rect, m_bg_color);
int start_y = 29;
int interval = 41;
@ -37,7 +36,7 @@ void c_dialog::on_paint()
{
for ( unsigned int i = 0; i < m_divider_lines; i++ )
{
m_surface->draw_hline( rect.m_left + 35, rect.m_right - 35, rect.m_top + start_y + (i * interval), GL_RGB(70, 73, 76), m_z_order);
draw_hline(rect.m_left + 35, rect.m_right - 35, rect.m_top + start_y + (i * interval), GL_RGB(70, 73, 76));
}
}

View File

@ -26,8 +26,7 @@ void c_edit::pre_create_wnd()
{
m_style = GL_ATTR_VISIBLE | GL_ATTR_FOCUS | ALIGN_HCENTER | ALIGN_VCENTER | KEY_BOARD_STYLE;
m_font_type = c_my_resource::get_font(FONT_DEFAULT);
m_font_color = c_my_resource::get_color(WND_FORECOLOR);
m_bg_color = c_my_resource::get_color(WND_BACKCOLOR);
m_font_color = c_my_resource::get_color(COLOR_WND_FONT);
memset(m_str_input, 0, sizeof(m_str_input));
memset(m_str, 0, sizeof(m_str));
@ -65,7 +64,7 @@ void c_edit::on_touch_down(int x, int y)
{
if (STATUS_PUSHED == m_status)
{
modify_status(STATUS_FOCUSED);
m_status = STATUS_FOCUSED;
on_paint();
}
}
@ -75,14 +74,14 @@ void c_edit::on_touch_up(int x, int y)
{
if (STATUS_FOCUSED == m_status)
{
modify_status(STATUS_PUSHED);
m_status = STATUS_PUSHED;
on_paint();
}
else if (STATUS_PUSHED == m_status)
{
if (m_wnd_rect.PtInRect(x,y))
{//click edit box
modify_status(STATUS_FOCUSED);
m_status = STATUS_FOCUSED;
on_paint();
}
else
@ -94,13 +93,13 @@ void c_edit::on_touch_up(int x, int y)
void c_edit::on_focus()
{
modify_status(STATUS_FOCUSED);
m_status = STATUS_FOCUSED;
on_paint();
}
void c_edit::on_kill_focus()
{
modify_status(STATUS_NORMAL);
m_status = STATUS_NORMAL;
on_paint();
}
@ -119,7 +118,7 @@ void c_edit::on_paint()
m_surface->set_frame_layer(empty_rect, s_keyboard.get_z_order());
m_z_order = m_parent->get_z_order();
}
fill_rect_ex(rect, m_bg_color, c_my_resource::get_shape(BUTTON_NORMAL));
fill_rect(rect, c_my_resource::get_color(COLOR_WND_NORMAL));
break;
case STATUS_FOCUSED:
if (m_z_order > m_parent->get_z_order())
@ -128,7 +127,7 @@ void c_edit::on_paint()
m_surface->set_frame_layer(empty_rect, s_keyboard.get_z_order());
m_z_order = m_parent->get_z_order();
}
fill_rect_ex(rect, m_bg_color, c_my_resource::get_shape(BUTTON_FOCUS));
fill_rect(rect, c_my_resource::get_color(COLOR_WND_FOCUS));
break;
case STATUS_PUSHED:
if (m_z_order == m_parent->get_z_order())
@ -136,7 +135,8 @@ void c_edit::on_paint()
m_z_order++;
show_keyboard();
}
m_surface->fill_rect_ex(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, m_bg_color, c_my_resource::get_shape(LIST_BOX_SELECT), m_parent->get_z_order());
m_surface->fill_rect(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, c_my_resource::get_color(COLOR_WND_PUSHED), m_parent->get_z_order());
m_surface->draw_rect(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, c_my_resource::get_color(COLOR_WND_BORDER), m_parent->get_z_order(), 2);
break;
default:
ASSERT(FALSE);
@ -163,15 +163,13 @@ void c_edit::show_keyboard()
if ((get_style()&KEY_BOARD_STYLE) == KEY_BOARD_STYLE )
{
c_rect parent_rc;
m_parent->get_wnd_rect(parent_rc);
s_keyboard.set_style(STYLE_ALL_BOARD);
s_keyboard.create(this, IDD_ALL_KEY_BOARD, 0, m_wnd_rect.m_left, m_wnd_rect.m_top, parent_rc.Width(), parent_rc.Height(), NULL);
s_keyboard.connect(this, IDD_ALL_KEY_BOARD);
}
else
{
s_keyboard.set_style(STYLE_NUM_BOARD);
s_keyboard.create(this, IDD_NUM_KEY_BOARD, 0, 0, m_wnd_rect.Height(), 0, 0, NULL);
s_keyboard.connect(this, IDD_NUM_KEY_BOARD);
}
c_rect kb_rect;
@ -193,12 +191,12 @@ void c_edit::on_key_board_click(unsigned int ctrl_id, long param)
{
memcpy(m_str, m_str_input, sizeof(m_str_input));
}
modify_status(STATUS_FOCUSED);
m_status = STATUS_FOCUSED;
on_paint();
break;
case CLICK_ESC:
memset(m_str_input, 0, sizeof(m_str_input));
modify_status(STATUS_FOCUSED);
m_status = STATUS_FOCUSED;
on_paint();
break;
default:

View File

@ -145,28 +145,31 @@ ON_GL_BN_CLICKED('\n', c_keyboard::on_enter_clicked)
ON_GL_BN_CLICKED(0x1B, c_keyboard::on_esc_clicked)
GL_END_MESSAGE_MAP()
int c_keyboard::create(c_wnd *parent, unsigned short resource_id, char* str,
short x, short y, short width, short height, WND_TREE* p_child_tree)
int c_keyboard::connect(c_wnd *user, unsigned short resource_id)
{
c_rect user_rect;
user->get_wnd_rect(user_rect);
if (m_style == STYLE_ALL_BOARD)
{
return c_wnd::connect(parent, resource_id, str, (0 - x), (height - y - KEYBOARD_HEIGHT), KEYBOARD_WIDTH, KEYBOARD_HEIGHT, g_key_board_children);
{//Place keyboard at the bottom of user's parent window.
c_rect user_parent_rect;
user->get_parent()->get_wnd_rect(user_parent_rect);
return c_wnd::connect(user, resource_id, NULL, (0 - user_rect.m_left), (user_parent_rect.Height() - user_rect.m_top - KEYBOARD_HEIGHT), KEYBOARD_WIDTH, KEYBOARD_HEIGHT, g_key_board_children);
}
else if(m_style == STYLE_NUM_BOARD)
{
return c_wnd::connect(parent, resource_id, str, x, y, NUM_BOARD_WIDTH, NUM_BOARD_HEIGHT, g_number_board_children);
{//Place keyboard below the user window.
return c_wnd::connect(user, resource_id, NULL, 0, user_rect.Height(), NUM_BOARD_WIDTH, NUM_BOARD_HEIGHT, g_number_board_children);
}
else
{
ASSERT(FALSE);
}
return -1;
}
void c_keyboard::pre_create_wnd()
{
m_style = GL_ATTR_VISIBLE | GL_ATTR_FOCUS;
m_cap_status = STATUS_UPPERCASE;
m_bg_color = GL_RGB(39,39,39);
memset(m_str, 0, sizeof(m_str));
m_str_len = 0;
}
@ -231,13 +234,14 @@ void c_keyboard_button::on_paint()
switch(m_status)
{
case STATUS_NORMAL:
fill_rect_ex(rect, m_bg_color, c_my_resource::get_shape(KEY_BUTTON_NORMAL));
fill_rect(rect, c_my_resource::get_color(COLOR_WND_NORMAL));
break;
case STATUS_FOCUSED:
fill_rect_ex(rect, m_bg_color, c_my_resource::get_shape(BUTTON_FOCUS));
fill_rect(rect, c_my_resource::get_color(COLOR_WND_FOCUS));
break;
case STATUS_PUSHED:
fill_rect_ex(rect, m_bg_color, c_my_resource::get_shape(KEY_BUTTON_PUSH));
fill_rect(rect, c_my_resource::get_color(COLOR_WND_PUSHED));
draw_rect(rect, c_my_resource::get_color(COLOR_WND_BORDER), 2);
break;
default:
ASSERT(FALSE);

View File

@ -15,7 +15,6 @@ void c_label::pre_create_wnd()
m_font_color = GL_RGB(255,255,255);
m_font_type = c_my_resource::get_font(FONT_DEFAULT);
m_bg_color = get_parent()->get_bg_color();
}
void c_label::on_paint()
@ -25,7 +24,7 @@ void c_label::on_paint()
if (m_str)
{
fill_rect(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom,m_bg_color);
fill_rect(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, get_parent()->get_bg_color());
c_word::draw_string_in_rect(m_surface, m_z_order, m_str, rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), m_style);
}
}

View File

@ -18,28 +18,21 @@ void c_list_box::pre_create_wnd()
{
m_style = GL_ATTR_VISIBLE | GL_ATTR_FOCUS | ALIGN_HCENTER | ALIGN_VCENTER;
memset(m_item_array, 0, sizeof(m_item_array));
m_item_total = 0;
m_font_color = c_my_resource::get_color(WND_FORECOLOR);
}
void c_list_box::on_init_children()
{
m_item_total = 0;
m_selected_item = 0;
m_font_type = c_my_resource::get_font(FONT_DEFAULT);
m_font_color = c_my_resource::get_color(WND_FORECOLOR);
m_bg_color = c_my_resource::get_color(WND_BACKCOLOR);
m_font_color = c_my_resource::get_color(COLOR_WND_FONT);
}
void c_list_box::on_focus()
{
modify_status(STATUS_FOCUSED);
m_status = STATUS_FOCUSED;
on_paint();
}
void c_list_box::on_kill_focus()
{
modify_status(STATUS_NORMAL);
m_status = STATUS_NORMAL;
on_paint();
}
@ -57,7 +50,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();
}
fill_rect_ex(rect, m_bg_color, c_my_resource::get_shape(BUTTON_NORMAL));
fill_rect(rect, c_my_resource::get_color(COLOR_WND_NORMAL));
break;
case STATUS_FOCUSED:
if (m_z_order > m_parent->get_z_order())
@ -65,10 +58,11 @@ void c_list_box::on_paint()
m_surface->set_frame_layer(empty_rect, m_z_order);
m_z_order = m_parent->get_z_order();
}
fill_rect_ex(rect, m_bg_color, c_my_resource::get_shape(BUTTON_FOCUS));
fill_rect(rect, c_my_resource::get_color(COLOR_WND_FOCUS));
break;
case STATUS_PUSHED:
fill_rect_ex(rect, m_bg_color, c_my_resource::get_shape(LIST_BOX_PUSH));
fill_rect(rect, c_my_resource::get_color(COLOR_WND_PUSHED));
draw_rect(rect, c_my_resource::get_color(COLOR_WND_BORDER), 2);
c_word::draw_string_in_rect(m_surface, m_z_order, m_item_array[m_selected_item], rect, m_font_type, GL_RGB(2, 124, 165), GL_ARGB(0, 0, 0, 0), ALIGN_HCENTER | ALIGN_VCENTER);
//draw list
if (m_item_total > 0)
@ -111,7 +105,7 @@ void c_list_box::on_touch_down(int x, int y)
{
if (STATUS_PUSHED == m_status)
{
modify_status(STATUS_FOCUSED);
m_status = STATUS_FOCUSED;
on_paint();
notify_parent(GL_LIST_CONFIRM, get_id(), 0);
}
@ -122,7 +116,7 @@ void c_list_box::on_touch_up(int x, int y)
{
if (STATUS_FOCUSED == m_status)
{
modify_status(STATUS_PUSHED);
m_status = STATUS_PUSHED;
on_paint();
notify_parent(GL_LIST_SELECT, get_id(), 0);
}
@ -130,12 +124,12 @@ void c_list_box::on_touch_up(int x, int y)
{
if (m_wnd_rect.PtInRect(x, y))
{//click base
modify_status(STATUS_FOCUSED);
m_status = STATUS_FOCUSED;
on_paint();
}
else if (m_list_wnd_rect.PtInRect(x, y))
{//click extend list
modify_status(STATUS_FOCUSED);
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);
@ -160,9 +154,7 @@ void c_list_box::update_list_size()
void c_list_box::show_list()
{
fill_rect_ex(m_list_screen_rect, m_bg_color, c_my_resource::get_shape(LIST_BOX_EXTEND));
m_font_color = GL_RGB(255, 255, 255);
fill_rect(m_list_screen_rect, GL_RGB(17, 17, 17));
//draw all items
c_rect tmp_rect;
for (int i = 0; i < m_item_total; i++)
@ -180,9 +172,7 @@ void c_list_box::show_list()
tmp_rect.m_top = m_list_screen_rect.m_top + m_selected_item * ITEM_HEIGHT;
tmp_rect.m_bottom = tmp_rect.m_top + ITEM_HEIGHT;
fill_rect_ex(tmp_rect, GL_RGB(0, 255, 0), c_my_resource::get_shape(LIST_BOX_SELECT));
m_font_color = GL_RGB(255, 255, 255);
fill_rect(tmp_rect, c_my_resource::get_color(COLOR_WND_FOCUS));
c_word::draw_string_in_rect(m_surface, m_z_order, m_item_array[m_selected_item], tmp_rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), ALIGN_HCENTER | ALIGN_VCENTER);
}

View File

@ -5,7 +5,6 @@
static const FONT_INFO* s_font_map[FONT_MAX];
static const BITMAP_INFO* s_bmp_map[BITMAP_MAX];
static const COLOR_RECT* s_shape_map[SHAPE_MAX];
static unsigned int s_color_map[COLOR_MAX];
int c_my_resource::add_font(FONT_TYPE index, const FONT_INFO* font)
@ -50,27 +49,6 @@ const BITMAP_INFO* c_my_resource::get_bmp(BITMAP_TYPE index)
return s_bmp_map[index];
}
int c_my_resource::add_shape(SHAPE_TYPE index, const COLOR_RECT* shape)
{
if (index >= SHAPE_MAX)
{
ASSERT(FALSE);
return -1;
}
s_shape_map[index] = shape;
return 0;
}
const COLOR_RECT* c_my_resource::get_shape(SHAPE_TYPE index)
{
if (index >= SHAPE_MAX)
{
ASSERT(FALSE);
return NULL;
}
return s_shape_map[index];
}
int c_my_resource::add_color(COLOR_TYPE index, const unsigned int color)
{
if (index >= COLOR_MAX)

View File

@ -22,8 +22,7 @@ void c_spin_box::pre_create_wnd()
{
m_style = GL_ATTR_VISIBLE | GL_ATTR_FOCUS | ALIGN_HCENTER | ALIGN_VCENTER;
m_font_type = c_my_resource::get_font(FONT_DEFAULT);
m_bg_color = c_my_resource::get_color(WND_BACKCOLOR);
m_font_color = c_my_resource::get_color(WND_FORECOLOR);
m_font_color = c_my_resource::get_color(COLOR_WND_FONT);
m_max = 6;
m_min = 1;
@ -70,7 +69,7 @@ void c_spin_box::on_touch_down(int x, int y)
{
m_value = m_cur_value;
}
modify_status(STATUS_FOCUSED);
m_status = STATUS_FOCUSED;
on_paint();
notify_parent(GL_SPIN_CONFIRM, get_id(), 0);
}
@ -81,7 +80,7 @@ void c_spin_box::on_touch_up(int x, int y)
{
if (STATUS_FOCUSED == m_status)
{
modify_status(STATUS_PUSHED);
m_status = STATUS_PUSHED;
on_paint();
notify_parent(GL_SPIN_SELECT, get_id(), 0);
}
@ -93,7 +92,7 @@ void c_spin_box::on_touch_up(int x, int y)
{
m_value = m_cur_value;
}
modify_status(STATUS_FOCUSED);
m_status = STATUS_FOCUSED;
on_paint();
notify_parent(GL_SPIN_CONFIRM, get_id(), 0);
}
@ -106,14 +105,14 @@ void c_spin_box::on_touch_up(int x, int y)
void c_spin_box::on_focus()
{
modify_status(STATUS_FOCUSED);
m_status = STATUS_FOCUSED;
on_paint();
}
void c_spin_box::on_kill_focus()
{
m_cur_value = m_value;
modify_status(STATUS_NORMAL);
m_status = STATUS_NORMAL;
on_paint();
}
@ -157,7 +156,7 @@ void c_spin_box::on_paint()
m_surface->set_frame_layer(tmp_rect, m_z_order);
m_z_order = m_parent->get_z_order();
}
fill_rect_ex(rect, m_bg_color, c_my_resource::get_shape(BUTTON_NORMAL));
fill_rect(rect, c_my_resource::get_color(COLOR_WND_NORMAL));
break;
case STATUS_FOCUSED:
if (m_z_order > m_parent->get_z_order())
@ -167,7 +166,7 @@ void c_spin_box::on_paint()
m_surface->set_frame_layer(tmp_rect, m_z_order);
m_z_order = m_parent->get_z_order();
}
fill_rect_ex(rect, m_bg_color, c_my_resource::get_shape(BUTTON_FOCUS));
fill_rect(rect, c_my_resource::get_color(COLOR_WND_FOCUS));
break;
case STATUS_PUSHED:
if (m_z_order == m_parent->get_z_order())
@ -179,7 +178,8 @@ void c_spin_box::on_paint()
m_surface->set_frame_layer(tmp_rect, m_z_order);
show_arrow_button();
m_surface->fill_rect_ex(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, m_bg_color, c_my_resource::get_shape(LIST_BOX_PUSH),m_parent->get_z_order());
m_surface->fill_rect(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, c_my_resource::get_color(COLOR_WND_PUSHED), m_parent->get_z_order());
m_surface->draw_rect(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, c_my_resource::get_color(COLOR_WND_BORDER), m_parent->get_z_order(), 2);
c_word::draw_value_in_rect(m_surface, m_parent->get_z_order(), m_cur_value, m_digit, rect, m_font_type, GL_RGB(2, 124, 165), GL_ARGB(0, 0, 0, 0), m_style);
return;
break;

View File

@ -8,33 +8,15 @@
#include "../gui_include/my_resource.h"
#include "../gui_include/table.h"
void c_table::pre_create_wnd()
void c_table::set_item(int row, int col, char* str, unsigned int color)
{
m_style = GL_ATTR_VISIBLE;
draw_item( row, col, str, color);
}
int c_table::set_item(int row, int col, char* str, unsigned int with_bg_color)
{
draw_item( row, col, str, with_bg_color);
return 1;
}
void c_table::draw_item(int row, int col, const char* str, unsigned int with_bg_color)
void c_table::draw_item(int row, int col, const char* str, unsigned int color)
{
c_rect rect = get_item_rect(row, col);
unsigned int back_color = 0;
if (with_bg_color == 0xFFFFFFFF)
{
back_color = m_bg_color;
}
else
{
back_color = with_bg_color;
}
fill_rect(rect.m_left+1, rect.m_top+1, rect.m_right-1, rect.m_bottom-1, back_color);
fill_rect(rect.m_left+1, rect.m_top+1, rect.m_right-1, rect.m_bottom-1, color);
c_word::draw_string_in_rect(m_surface, m_z_order, str, rect, m_font_type, m_font_color, GL_ARGB(0, 0, 0, 0), m_align_type);
}