change window close button outlook and add select bar drawing.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@355 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
5c2be6f0ea
commit
97d4abe294
|
@ -14,7 +14,11 @@ static void open_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event)
|
|||
workbench = RTGUI_WORKBENCH(rtgui_widget_get_toplevel(widget));
|
||||
rtgui_widget_get_rect(RTGUI_WIDGET(workbench), &rect);
|
||||
|
||||
#ifdef _WIN32
|
||||
view = rtgui_filelist_view_create(workbench, "d:\\", "*.*", &rect);
|
||||
#else
|
||||
view = rtgui_filelist_view_create(workbench, "/", "*.*", &rect);
|
||||
#endif
|
||||
if (rtgui_view_show(RTGUI_VIEW(view), RT_TRUE) == RTGUI_MODAL_OK)
|
||||
{
|
||||
char path[32];
|
||||
|
|
|
@ -3,6 +3,28 @@
|
|||
#include <rtgui/widgets/label.h>
|
||||
#include <rtgui/widgets/slider.h>
|
||||
|
||||
static const rt_uint8_t boxChecked[7] = {0x02, 0x06, 0x8E, 0xDC, 0xF8, 0x70, 0x20};
|
||||
|
||||
static const rt_uint8_t sysMin[2] = {0x7E, 0x7E};
|
||||
static const rt_uint8_t sysMax[18] = {0x0F, 0xF8, 0x0F, 0xF8, 0x08, 0x08,
|
||||
0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
|
||||
0x08, 0x08, 0x08, 0x08, 0x0F, 0xF8
|
||||
};
|
||||
static const rt_uint8_t sysNormal[18] = {0x03, 0xF0, 0x03, 0xF0, 0x02, 0x10,
|
||||
0x0F, 0xD0, 0x0F, 0xD0, 0x08, 0x70,
|
||||
0x08, 0x40, 0x08, 0x40, 0x0F, 0xC0
|
||||
};
|
||||
|
||||
static const rt_uint8_t sysClose[14] = {0x06, 0x18, 0x03, 0x30, 0x01, 0xE0, 0x00,
|
||||
0xC0, 0x01, 0xE0, 0x03, 0x30, 0x06, 0x18
|
||||
};
|
||||
|
||||
static const rt_uint8_t viewSYS[28] = {0xFF, 0x1F, 0x3C, 0x06, 0x1C, 0x04, 0x1C,
|
||||
0x0C, 0x0E, 0x08, 0x0E, 0x18, 0x07, 0x10,
|
||||
0x07, 0x30, 0x03, 0xA0, 0x03, 0xE0, 0x01,
|
||||
0xC0, 0x01, 0xC0, 0x00, 0x80, 0x00, 0x80
|
||||
};
|
||||
|
||||
rt_bool_t dc_event_handler(rtgui_widget_t* widget, rtgui_event_t *event)
|
||||
{
|
||||
if (event->type == RTGUI_EVENT_PAINT)
|
||||
|
@ -43,6 +65,97 @@ rt_bool_t dc_event_handler(rtgui_widget_t* widget, rtgui_event_t *event)
|
|||
rtgui_dc_set_color(dc, blue);
|
||||
rtgui_dc_draw_polygon(dc, vx, vy, 6);
|
||||
|
||||
{
|
||||
rtgui_rect_t item_rect = {0, 0, 14, 14};
|
||||
rt_uint16_t item_size = 14;
|
||||
|
||||
rtgui_rect_moveto(&item_rect, 100, 100);
|
||||
|
||||
rtgui_dc_set_color(dc, RTGUI_RGB(0x66, 0x66, 0x66));
|
||||
rtgui_dc_draw_circle(dc, item_rect.x1 + item_size/2, item_rect.y1 + item_size/2, item_size/2);
|
||||
rtgui_dc_set_color(dc, RTGUI_RGB(0xff, 0xFF, 0xFF));
|
||||
rtgui_dc_draw_circle(dc, item_rect.x1 + item_size/2, item_rect.y1 + item_size/2, item_size/2 - 1);
|
||||
|
||||
rtgui_dc_set_color(dc, RTGUI_RGB(0x00, 0x00, 0x00));
|
||||
rtgui_dc_fill_circle(dc, item_rect.x1 + item_size/2, item_rect.y1 + item_size/2, item_size/2 - 3);
|
||||
}
|
||||
|
||||
{
|
||||
rtgui_rect_t item_rect = {0, 0, 14, 14};
|
||||
rt_uint16_t item_size = 14;
|
||||
rtgui_rect_moveto(&item_rect, 120, 120);
|
||||
|
||||
rtgui_dc_set_color(dc, RTGUI_RGB(0x66, 0x66, 0x66));
|
||||
rtgui_dc_draw_circle(dc, item_rect.x1 + item_size/2, item_rect.y1 + item_size/2, item_size/2);
|
||||
rtgui_dc_set_color(dc, RTGUI_RGB(0xff, 0xFF, 0xFF));
|
||||
rtgui_dc_draw_circle(dc, item_rect.x1 + item_size/2, item_rect.y1 + item_size/2, item_size/2 - 1);
|
||||
rtgui_dc_set_color(dc, RTGUI_RGB(0x00, 0x00, 0x00));
|
||||
}
|
||||
{
|
||||
int x, y;
|
||||
|
||||
x = 150; y = 150;
|
||||
rtgui_dc_set_color(dc, black);
|
||||
|
||||
rtgui_dc_draw_byte(dc, x, y, 7, boxChecked);
|
||||
y += 7 + 2;
|
||||
|
||||
rtgui_dc_draw_byte(dc, x, y, 2, sysMin);
|
||||
y += 2 + 2;
|
||||
|
||||
rtgui_dc_draw_word(dc, x, y, 9, sysMax);
|
||||
y += 9 + 2;
|
||||
|
||||
rtgui_dc_draw_word(dc, x, y, 9, sysNormal);
|
||||
y += 9 + 2;
|
||||
|
||||
rtgui_dc_draw_word(dc, x, y, 7, sysClose);
|
||||
y += 7 + 2;
|
||||
|
||||
rtgui_dc_draw_word(dc, x, y, 14, viewSYS);
|
||||
y += 14 + 2;
|
||||
}
|
||||
|
||||
{
|
||||
rtgui_rect_t rect = {0, 0, 16, 16};
|
||||
rtgui_rect_moveto(&rect, 30, 120);
|
||||
|
||||
rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_RAISE);
|
||||
rect.x1 += 20; rect.x2 += 20 + 50;
|
||||
rtgui_dc_draw_text(dc, "raise", &rect);
|
||||
rect.x1 -= 20; rect.x2 -= 20 + 50;
|
||||
rect.y1 += 20; rect.y2 += 20;
|
||||
|
||||
rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_SIMPLE);
|
||||
rect.x1 += 20; rect.x2 += 20 + 50;
|
||||
rtgui_dc_draw_text(dc, "simple", &rect);
|
||||
rect.x1 -= 20; rect.x2 -= 20 + 50;
|
||||
rect.y1 += 20; rect.y2 += 20;
|
||||
|
||||
rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_SUNKEN);
|
||||
rect.x1 += 20; rect.x2 += 20 + 50;
|
||||
rtgui_dc_draw_text(dc, "sunken", &rect);
|
||||
rect.x1 -= 20; rect.x2 -= 20 + 50;
|
||||
rect.y1 += 20; rect.y2 += 20;
|
||||
|
||||
rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_BOX);
|
||||
rect.x1 += 20; rect.x2 += 20 + 50;
|
||||
rtgui_dc_draw_text(dc, "box", &rect);
|
||||
rect.x1 -= 20; rect.x2 -= 20 + 50;
|
||||
rect.y1 += 20; rect.y2 += 20;
|
||||
|
||||
rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_STATIC);
|
||||
rect.x1 += 20; rect.x2 += 20 + 50;
|
||||
rtgui_dc_draw_text(dc, "static", &rect);
|
||||
rect.x1 -= 20; rect.x2 -= 20 + 50;
|
||||
rect.y1 += 20; rect.y2 += 20;
|
||||
|
||||
rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_EXTRA);
|
||||
rect.x1 += 20; rect.x2 += 20 + 50;
|
||||
rtgui_dc_draw_text(dc, "extra", &rect);
|
||||
rect.x1 -= 20; rect.x2 -= 20 + 50;
|
||||
rect.y1 += 20; rect.y2 += 20;
|
||||
}
|
||||
/* 绘图完成 */
|
||||
rtgui_dc_end_drawing(dc);
|
||||
}
|
||||
|
|
|
@ -226,11 +226,11 @@ void rtgui_dc_draw_text (struct rtgui_dc* dc, const rt_uint8_t* text, struct rtg
|
|||
#endif
|
||||
}
|
||||
|
||||
void rtgui_dc_draw_byte(struct rtgui_dc*dc, int x, int y, int h, rt_uint8_t* data)
|
||||
void rtgui_dc_draw_byte(struct rtgui_dc*dc, int x, int y, int h, const rt_uint8_t* data)
|
||||
{
|
||||
int i, k;
|
||||
|
||||
/* draw word */
|
||||
/* draw byte */
|
||||
for (i=0; i < h; i ++)
|
||||
{
|
||||
for (k=0; k < 8; k++)
|
||||
|
@ -243,6 +243,24 @@ void rtgui_dc_draw_byte(struct rtgui_dc*dc, int x, int y, int h, rt_uint8_t* dat
|
|||
}
|
||||
}
|
||||
|
||||
void rtgui_dc_draw_word(struct rtgui_dc*dc, int x, int y, int h, const rt_uint8_t* data)
|
||||
{
|
||||
int i, j, k;
|
||||
|
||||
/* draw word */
|
||||
for (i=0; i < h; i ++)
|
||||
{
|
||||
for (j=0; j < 2; j++)
|
||||
for (k=0; k < 8; k++)
|
||||
{
|
||||
if (((data[i * 2 + j] >> (7-k)) & 0x01) != 0)
|
||||
{
|
||||
rtgui_dc_draw_point(dc, x + 8*j + k, y + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void rtgui_dc_set_color(struct rtgui_dc* dc, rtgui_color_t color)
|
||||
{
|
||||
if (dc != RT_NULL)
|
||||
|
|
|
@ -32,9 +32,6 @@ void rtgui_system_server_init()
|
|||
/* init rtgui_thread */
|
||||
rtgui_thread_system_init();
|
||||
|
||||
/* init theme */
|
||||
rtgui_system_theme_init();
|
||||
|
||||
/* init image */
|
||||
rtgui_system_image_init();
|
||||
/* init font */
|
||||
|
@ -44,6 +41,9 @@ void rtgui_system_server_init()
|
|||
rtgui_panel_init();
|
||||
rtgui_topwin_init();
|
||||
rtgui_server_init();
|
||||
|
||||
/* init theme */
|
||||
rtgui_system_theme_init();
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
|
|
|
@ -24,170 +24,11 @@
|
|||
#include <rtgui/rtgui_server.h>
|
||||
#include <rtgui/rtgui_system.h>
|
||||
|
||||
#define WINTITLE_CB_WIDTH 14
|
||||
#define WINTITLE_CB_HEIGHT 14
|
||||
#define SELECTED_HEIGHT 25
|
||||
|
||||
static const rt_uint8_t *close_unpressed_xpm[] = {
|
||||
"14 14 55 1",
|
||||
" c None",
|
||||
". c #DCDFEA",
|
||||
"+ c #A4ADD3",
|
||||
"@ c #8F9ACA",
|
||||
"# c #98A2CD",
|
||||
"$ c #D2D6E6",
|
||||
"% c #F7F7F7",
|
||||
"& c #F6F6F6",
|
||||
"* c #B9C1D0",
|
||||
"= c #7A8AAA",
|
||||
"- c #D6DAE2",
|
||||
"; c #D8DCE3",
|
||||
"> c #7485A5",
|
||||
", c #455C89",
|
||||
"' c #516690",
|
||||
") c #D3D8E0",
|
||||
"! c #536891",
|
||||
"~ c #6D7FA1",
|
||||
"{ c #F5F5F5",
|
||||
"] c #D1D6DF",
|
||||
"^ c #D2D7DF",
|
||||
"/ c #D5D9E1",
|
||||
"( c #4E648E",
|
||||
"_ c #CFD4DE",
|
||||
": c #F4F4F4",
|
||||
"< c #D0D5DE",
|
||||
"[ c #CED3DD",
|
||||
"} c #F3F3F3",
|
||||
"| c #CFD4DD",
|
||||
"1 c #CDD2DC",
|
||||
"2 c #F2F2F2",
|
||||
"3 c #D3D7DF",
|
||||
"4 c #526790",
|
||||
"5 c #D0D5DD",
|
||||
"6 c #F1F1F1",
|
||||
"7 c #D2D6DE",
|
||||
"8 c #CFD4DC",
|
||||
"9 c #F0F0F0",
|
||||
"0 c #D1D5DD",
|
||||
"a c #C9CED8",
|
||||
"b c #CDD2DB",
|
||||
"c c #50658F",
|
||||
"d c #CED3DB",
|
||||
"e c #7283A3",
|
||||
"f c #6E80A2",
|
||||
"g c #EFEFEF",
|
||||
"h c #B2BACA",
|
||||
"i c #7081A2",
|
||||
"j c #C8CDD7",
|
||||
"k c #CCD1DA",
|
||||
"l c #ACB5C7",
|
||||
"m c #D0D4E2",
|
||||
"n c #EEEEEE",
|
||||
"o c #D2D5E3",
|
||||
"p c #97A1CC",
|
||||
".+@@@@@@@@@@+.",
|
||||
"#$%%%%%%%%%%$#",
|
||||
"@&*=-&&&&;=*&@",
|
||||
"@&>,')&&-!,~&@",
|
||||
"@{]','^/!,(_{@",
|
||||
"@::<','!,([::@",
|
||||
"@}}}|',,(1}}}@",
|
||||
"@22234,,'5222@",
|
||||
"@6674,(','866@",
|
||||
"@904,(abc,cd9@",
|
||||
"@9e,(a99bc,f9@",
|
||||
"@ghijggggkelg@",
|
||||
"#mnnnnnnnnnnm#",
|
||||
"op@@@@@@@@@@po"};
|
||||
|
||||
static const rt_uint8_t *close_pressed_xpm[] = {
|
||||
"14 14 66 1",
|
||||
" c None",
|
||||
". c #CED4EE",
|
||||
"+ c #7E90DD",
|
||||
"@ c #6076D7",
|
||||
"# c #6C80D9",
|
||||
"$ c #BFC8EA",
|
||||
"% c #F2F3F5",
|
||||
"& c #F0F2F3",
|
||||
"* c #A5B6D7",
|
||||
"= c #587ABB",
|
||||
"- c #C9D3E4",
|
||||
"; c #CBD5E4",
|
||||
"> c #EEF0F2",
|
||||
", c #5073B7",
|
||||
"' c #1746A3",
|
||||
") c #2551A8",
|
||||
"! c #C5CFE2",
|
||||
"~ c #C8D1E3",
|
||||
"{ c #2853A8",
|
||||
"] c #496DB4",
|
||||
"^ c #ECEEF1",
|
||||
"/ c #C0CCE0",
|
||||
"( c #C3CEE1",
|
||||
"_ c #C6D0E2",
|
||||
": c #224FA7",
|
||||
"< c #BEC9DF",
|
||||
"[ c #EAECF0",
|
||||
"} c #BFCAE0",
|
||||
"| c #2551A7",
|
||||
"1 c #224EA7",
|
||||
"2 c #BCC8DF",
|
||||
"3 c #E8EBEE",
|
||||
"4 c #BDCADE",
|
||||
"5 c #BAC7DD",
|
||||
"6 c #E6E9ED",
|
||||
"7 c #C1CBDF",
|
||||
"8 c #2753A8",
|
||||
"9 c #BECADE",
|
||||
"0 c #E4E7EB",
|
||||
"a c #BFCADD",
|
||||
"b c #224EA6",
|
||||
"c c #BDC8DC",
|
||||
"d c #E1E5EA",
|
||||
"e c #2752A8",
|
||||
"f c #B3C0D9",
|
||||
"g c #B8C5DB",
|
||||
"h c #2451A7",
|
||||
"i c #BAC6DB",
|
||||
"j c #DFE2E8",
|
||||
"k c #4C70B4",
|
||||
"l c #B2BED8",
|
||||
"m c #B6C2D9",
|
||||
"n c #2450A7",
|
||||
"o c #486BB3",
|
||||
"p c #DCE0E7",
|
||||
"q c #96A8CE",
|
||||
"r c #496CB3",
|
||||
"s c #AFBCD7",
|
||||
"t c #B4C1D8",
|
||||
"u c #4B6FB4",
|
||||
"v c #8EA4CC",
|
||||
"w c #6C80D8",
|
||||
"x c #B4BEDF",
|
||||
"y c #DADEE5",
|
||||
"z c #B5BEDE",
|
||||
"A c #6A7ED7",
|
||||
".+@@@@@@@@@@+.",
|
||||
"#$%%%%%%%%%%$#",
|
||||
"@&*=-&&&&;=*&@",
|
||||
"@>,')!>>~{']>@",
|
||||
"@^/)')(_{':<^@",
|
||||
"@[[}|'|{'12[[@",
|
||||
"@3334|''15333@",
|
||||
"@66678''|9666@",
|
||||
"@00a8'b|'|c00@",
|
||||
"@dce'bfgh'hid@",
|
||||
"@jk'bljjmn'oj@",
|
||||
"@pqrspppptuvp@",
|
||||
"wxyyyyyyyyyyxw",
|
||||
"zA@@@@@@@@@@Az"};
|
||||
|
||||
static rtgui_image_t* close_pressed = RT_NULL;
|
||||
static rtgui_image_t* close_unpressed = RT_NULL;
|
||||
|
||||
const rtgui_color_t default_foreground = RTGUI_RGB(0x00, 0x00, 0x00);
|
||||
const rtgui_color_t default_background = RTGUI_RGB(212, 208, 200);
|
||||
const rtgui_color_t selected_color = RTGUI_RGB(0xc0, 0xc0, 0xc0);
|
||||
|
||||
extern struct rtgui_font rtgui_font_asc16;
|
||||
extern struct rtgui_font rtgui_font_arial16;
|
||||
|
@ -197,28 +38,19 @@ extern struct rtgui_font rtgui_font_arial12;
|
|||
/* init theme */
|
||||
void rtgui_system_theme_init()
|
||||
{
|
||||
close_pressed = rtgui_image_create_from_mem("xpm",
|
||||
(const rt_uint8_t*)close_pressed_xpm, sizeof(close_pressed_xpm), RT_TRUE);
|
||||
close_unpressed = rtgui_image_create_from_mem("xpm",
|
||||
(const rt_uint8_t*)close_unpressed_xpm, sizeof(close_unpressed_xpm), RT_TRUE);
|
||||
|
||||
rtgui_font_set_defaut(&rtgui_font_arial16);
|
||||
rtgui_font_set_defaut(&rtgui_font_asc12);
|
||||
}
|
||||
|
||||
static const rt_uint8_t close_byte[14] = {0x06, 0x18, 0x03, 0x30, 0x01, 0xE0, 0x00,
|
||||
0xC0, 0x01, 0xE0, 0x03, 0x30, 0x06, 0x18
|
||||
};
|
||||
|
||||
/* window drawing */
|
||||
void rtgui_theme_draw_win(struct rtgui_topwin* win)
|
||||
{
|
||||
struct rtgui_dc* dc;
|
||||
rtgui_rect_t rect;
|
||||
|
||||
/* init close box image */
|
||||
if (close_pressed == RT_NULL)
|
||||
close_pressed = rtgui_image_create_from_mem("xpm",
|
||||
(const rt_uint8_t*)close_pressed_xpm, sizeof(close_pressed_xpm), RT_TRUE);
|
||||
if (close_unpressed == RT_NULL)
|
||||
close_unpressed = rtgui_image_create_from_mem("xpm",
|
||||
(const rt_uint8_t*)close_unpressed_xpm, sizeof(close_unpressed_xpm), RT_TRUE);
|
||||
|
||||
/* begin drawing */
|
||||
dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(win->title));
|
||||
|
||||
|
@ -228,6 +60,7 @@ void rtgui_theme_draw_win(struct rtgui_topwin* win)
|
|||
/* draw border */
|
||||
if (win->flag & WINTITLE_BORDER)
|
||||
{
|
||||
rect.x2 -= 1; rect.y2 -= 1;
|
||||
RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(win->title)) = RTGUI_RGB(212, 208, 200);
|
||||
rtgui_dc_draw_hline(dc, rect.x1, rect.x2, rect.y1);
|
||||
rtgui_dc_draw_vline(dc, rect.x1, rect.y1, rect.y2);
|
||||
|
@ -241,14 +74,11 @@ void rtgui_theme_draw_win(struct rtgui_topwin* win)
|
|||
rtgui_dc_draw_vline(dc, rect.x2 - 1, rect.y1 + 1, rect.y2 - 1);
|
||||
|
||||
RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(win->title)) = RTGUI_RGB(64, 64, 64);
|
||||
rtgui_dc_draw_hline(dc, rect.x1, rect.x2 + 1, rect.y2);
|
||||
rtgui_dc_draw_hline(dc, rect.x1, rect.x2, rect.y2);
|
||||
rtgui_dc_draw_vline(dc, rect.x2, rect.y1, rect.y2);
|
||||
|
||||
/* shrink border */
|
||||
rect.x1 += WINTITLE_BORDER_SIZE;
|
||||
rect.y1 += WINTITLE_BORDER_SIZE;
|
||||
rect.x2 -= WINTITLE_BORDER_SIZE;
|
||||
rect.y2 -= WINTITLE_BORDER_SIZE;
|
||||
rtgui_rect_inflate(&rect, -WINTITLE_BORDER_SIZE);
|
||||
}
|
||||
|
||||
/* draw title */
|
||||
|
@ -291,15 +121,24 @@ void rtgui_theme_draw_win(struct rtgui_topwin* win)
|
|||
if (win->flag & WINTITLE_CLOSEBOX)
|
||||
{
|
||||
/* get close button rect */
|
||||
rect.x1 = rtgui_rect_width(RTGUI_WIDGET(win->title)->extent) -
|
||||
WINTITLE_BORDER_SIZE - WINTITLE_CB_WIDTH - 3;
|
||||
rect.y1 = 3;
|
||||
rect.x2 = rect.x1 + WINTITLE_CB_WIDTH;
|
||||
rect.y2 = rect.y1 + WINTITLE_CB_HEIGHT;
|
||||
rtgui_rect_t box_rect = {0, 0, WINTITLE_CB_WIDTH, WINTITLE_CB_HEIGHT};
|
||||
rtgui_rect_moveto_align(&rect, &box_rect, RTGUI_ALIGN_CENTER_VERTICAL | RTGUI_ALIGN_RIGHT);
|
||||
box_rect.x1 -= 3; box_rect.x2 -= 3;
|
||||
rtgui_dc_fill_rect(dc, &box_rect);
|
||||
|
||||
/* draw close box */
|
||||
if(win->flag & WINTITLE_CB_PRESSED) rtgui_image_blit(close_pressed, dc, &rect);
|
||||
else rtgui_image_blit(close_unpressed, dc, &rect);
|
||||
if (win->flag & WINTITLE_CB_PRESSED)
|
||||
{
|
||||
rtgui_dc_draw_border(dc, &box_rect, RTGUI_BORDER_SUNKEN);
|
||||
RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(win->title)) = red;
|
||||
rtgui_dc_draw_word(dc, box_rect.x1, box_rect.y1 + 6, 7, close_byte);
|
||||
}
|
||||
else
|
||||
{
|
||||
rtgui_dc_draw_border(dc, &box_rect, RTGUI_BORDER_RAISE);
|
||||
RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(win->title)) = black;
|
||||
rtgui_dc_draw_word(dc, box_rect.x1 - 1, box_rect.y1 + 5, 7, close_byte);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -550,10 +389,18 @@ void rtgui_theme_draw_iconbox(rtgui_iconbox_t* iconbox)
|
|||
rtgui_dc_end_drawing(dc);
|
||||
}
|
||||
|
||||
#define CHECK_BOX_W 13
|
||||
#define CHECK_BOX_H 13
|
||||
static const rt_uint8_t checked_byte[7] = {0x02, 0x06, 0x8E, 0xDC, 0xF8, 0x70, 0x20};
|
||||
|
||||
void rtgui_theme_draw_checkbox(struct rtgui_checkbox* checkbox)
|
||||
{
|
||||
struct rtgui_dc* dc;
|
||||
struct rtgui_rect rect, box_rect;
|
||||
rtgui_color_t bc, fc;
|
||||
|
||||
fc = RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(checkbox));
|
||||
bc = RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(checkbox));
|
||||
|
||||
/* begin drawing */
|
||||
dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(checkbox));
|
||||
|
@ -575,29 +422,26 @@ void rtgui_theme_draw_checkbox(struct rtgui_checkbox* checkbox)
|
|||
}
|
||||
|
||||
/* draw check box */
|
||||
box_rect = rect;
|
||||
box_rect.x1 += 2;
|
||||
box_rect.y1 += 2;
|
||||
box_rect.x2 = rtgui_rect_height(rect) - 4;
|
||||
box_rect.y2 = rtgui_rect_height(rect) - 4;
|
||||
box_rect.x1 = 0;
|
||||
box_rect.y1 = 0;
|
||||
box_rect.x2 = CHECK_BOX_W;
|
||||
box_rect.y2 = CHECK_BOX_H;
|
||||
rtgui_rect_moveto_align(&rect, &box_rect, RTGUI_ALIGN_CENTER_VERTICAL);
|
||||
|
||||
rtgui_dc_draw_rect(dc, &box_rect);
|
||||
rtgui_dc_draw_border(dc, &box_rect, RTGUI_BORDER_BOX);
|
||||
rtgui_rect_inflate(&box_rect, -1);
|
||||
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(checkbox)) = RTGUI_RGB(247, 247, 246);
|
||||
rtgui_dc_fill_rect(dc, &box_rect);
|
||||
if (checkbox->status_down == RTGUI_CHECKBOX_STATUS_CHECKED)
|
||||
{
|
||||
rtgui_color_t save;
|
||||
|
||||
save = RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(checkbox));
|
||||
|
||||
/* swap fore/back color */
|
||||
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(checkbox)) = RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(checkbox));
|
||||
|
||||
rtgui_rect_inflate(&box_rect, -4);
|
||||
rtgui_dc_fill_rect(dc, &box_rect);
|
||||
|
||||
/* restore saved color */
|
||||
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(checkbox)) = save;
|
||||
RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(checkbox)) = RTGUI_RGB(33, 161, 33);
|
||||
rtgui_dc_draw_byte(dc, box_rect.x1 + 2, box_rect.y1 + 2, 7, checked_byte);
|
||||
}
|
||||
|
||||
/* restore saved color */
|
||||
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(checkbox)) = bc;
|
||||
RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(checkbox)) = fc;
|
||||
|
||||
/* draw text */
|
||||
rect.x1 += rtgui_rect_height(rect) - 4 + 5;
|
||||
rtgui_dc_draw_text(dc, rtgui_label_get_text(RTGUI_LABEL(checkbox)), &rect);
|
||||
|
@ -922,19 +766,22 @@ rt_uint16_t rtgui_theme_get_selected_height()
|
|||
|
||||
void rtgui_theme_draw_selected(struct rtgui_dc* dc, rtgui_rect_t *rect)
|
||||
{
|
||||
rtgui_color_t saved;
|
||||
rtgui_rect_t focus_rect;
|
||||
rtgui_color_t bc;
|
||||
rt_uint16_t index;
|
||||
|
||||
focus_rect = *rect;
|
||||
saved = rtgui_dc_get_color(dc);
|
||||
rtgui_dc_set_color(dc, blue);
|
||||
bc = rtgui_dc_get_color(dc);
|
||||
rtgui_dc_set_color(dc, selected_color);
|
||||
|
||||
rtgui_rect_inflate(&focus_rect, -1);
|
||||
rtgui_dc_draw_focus_rect(dc, &focus_rect);
|
||||
rtgui_rect_inflate(&focus_rect, -1);
|
||||
rtgui_dc_draw_focus_rect(dc, &focus_rect);
|
||||
rtgui_dc_draw_hline(dc, rect->x1 + 3, rect->x2 - 2, rect->y1 + 1);
|
||||
rtgui_dc_draw_hline(dc, rect->x1 + 3, rect->x2 - 2, rect->y2 - 2);
|
||||
|
||||
rtgui_dc_set_color(dc, saved);
|
||||
rtgui_dc_draw_vline(dc, rect->x1 + 2, rect->y1 + 2, rect->y2 - 2);
|
||||
rtgui_dc_draw_vline(dc, rect->x2 - 2, rect->y1 + 2, rect->y2 - 2);
|
||||
|
||||
for (index = rect->y1 + 1; index < rect->y2 - 2; index ++)
|
||||
rtgui_dc_draw_hline(dc, rect->x1 + 3, rect->x2 - 2, index);
|
||||
|
||||
rtgui_dc_set_color(dc, bc);
|
||||
}
|
||||
|
||||
/* get default background color */
|
||||
|
|
|
@ -107,7 +107,8 @@ void rtgui_dc_draw_rect (struct rtgui_dc* dc, struct rtgui_rect* rect);
|
|||
void rtgui_dc_draw_round_rect(struct rtgui_dc* dc, struct rtgui_rect* rect);
|
||||
|
||||
void rtgui_dc_draw_text (struct rtgui_dc* dc, const rt_uint8_t* text, struct rtgui_rect* rect);
|
||||
void rtgui_dc_draw_byte(struct rtgui_dc*dc, int x, int y, int h, rt_uint8_t* data);
|
||||
void rtgui_dc_draw_byte(struct rtgui_dc*dc, int x, int y, int h, const rt_uint8_t* data);
|
||||
void rtgui_dc_draw_word(struct rtgui_dc*dc, int x, int y, int h, const rt_uint8_t* data);
|
||||
|
||||
void rtgui_dc_draw_border(struct rtgui_dc* dc, rtgui_rect_t* rect, int flag);
|
||||
void rtgui_dc_draw_horizontal_line(struct rtgui_dc* dc, int x1, int x2, int y);
|
||||
|
|
|
@ -61,7 +61,9 @@ enum RTGUI_BORDER_STYLE
|
|||
RTGUI_BORDER_SUNKEN,
|
||||
RTGUI_BORDER_BOX,
|
||||
RTGUI_BORDER_STATIC,
|
||||
RTGUI_BORDER_EXTRA
|
||||
RTGUI_BORDER_EXTRA,
|
||||
RTGUI_BORDER_UP,
|
||||
RTGUI_BORDER_DOWN
|
||||
};
|
||||
#define RTGUI_BORDER_DEFAULT_WIDTH 2
|
||||
#define RTGUI_WIDGET_DEFAULT_MARGIN 3
|
||||
|
|
|
@ -31,6 +31,8 @@ enum
|
|||
};
|
||||
|
||||
#define WINTITLE_HEIGHT 20
|
||||
#define WINTITLE_CB_WIDTH 16
|
||||
#define WINTITLE_CB_HEIGHT 16
|
||||
#define WINTITLE_BORDER_SIZE 2
|
||||
|
||||
struct rtgui_topwin
|
||||
|
|
|
@ -30,9 +30,6 @@ static struct rt_semaphore _rtgui_topwin_lock;
|
|||
static void rtgui_topwin_update_clip(void);
|
||||
static void rtgui_topwin_redraw(struct rtgui_rect* rect);
|
||||
|
||||
#define WINTITLE_CB_WIDTH 14
|
||||
#define WINTITLE_CB_HEIGHT 14
|
||||
|
||||
void rtgui_topwin_init()
|
||||
{
|
||||
/* init window list */
|
||||
|
@ -90,10 +87,7 @@ rt_err_t rtgui_topwin_add(struct rtgui_event_win_create* event)
|
|||
/* add border rect */
|
||||
if (topwin->flag & WINTITLE_BORDER)
|
||||
{
|
||||
rect.x1 -= WINTITLE_BORDER_SIZE;
|
||||
rect.y1 -= WINTITLE_BORDER_SIZE;
|
||||
rect.x2 += WINTITLE_BORDER_SIZE;
|
||||
rect.y2 += WINTITLE_BORDER_SIZE;
|
||||
rtgui_rect_inflate(&rect, WINTITLE_BORDER_SIZE);
|
||||
}
|
||||
|
||||
/* add title rect */
|
||||
|
@ -688,10 +682,7 @@ void rtgui_topwin_resize(struct rtgui_win* wid, rtgui_rect_t* r)
|
|||
/* add border rect */
|
||||
if (topwin->flag & WINTITLE_BORDER)
|
||||
{
|
||||
rect.x1 -= WINTITLE_BORDER_SIZE;
|
||||
rect.y1 -= WINTITLE_BORDER_SIZE;
|
||||
rect.x2 += WINTITLE_BORDER_SIZE;
|
||||
rect.y2 += WINTITLE_BORDER_SIZE;
|
||||
rtgui_rect_inflate(&rect, WINTITLE_BORDER_SIZE);
|
||||
}
|
||||
|
||||
/* add title rect */
|
||||
|
|
Loading…
Reference in New Issue