summaryrefslogtreecommitdiff
path: root/components/rtgui/common
diff options
context:
space:
mode:
author[email protected] <[email protected]>2011-06-11 06:18:46 +0000
committer[email protected] <[email protected]>2011-06-11 06:18:46 +0000
commit14c2f8c0399d2041d75fac43c42d87bf6a2e3b93 (patch)
treea7a5de9eb33296b476eeb813be8df28baf4384ef /components/rtgui/common
parente8d7220682b061846844f98eb0f8d891c89c0e37 (diff)
add rtgui_listbox_set_current_item function; fix draw rect issue on the border; fix progress bar drawing issue; fix on_item issue in menu if the sub_menu is shown;
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1488 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components/rtgui/common')
-rw-r--r--components/rtgui/common/dc.c12
-rw-r--r--components/rtgui/common/dc_client.c1
-rw-r--r--components/rtgui/common/rtgui_theme.c61
3 files changed, 12 insertions, 62 deletions
diff --git a/components/rtgui/common/dc.c b/components/rtgui/common/dc.c
index a0d170de8f..5c7d130037 100644
--- a/components/rtgui/common/dc.c
+++ b/components/rtgui/common/dc.c
@@ -242,24 +242,24 @@ void rtgui_dc_draw_shaded_rect(struct rtgui_dc* dc, rtgui_rect_t* rect,
rtgui_dc_draw_hline(dc, rect->x1 + 1, rect->x2, rect->y1);
RTGUI_DC_FC(dc) = c2;
- rtgui_dc_draw_vline(dc, rect->x2, rect->y1, rect->y2);
- rtgui_dc_draw_hline(dc, rect->x1, rect->x2 + 1, rect->y2);
+ rtgui_dc_draw_vline(dc, rect->x2 - 1, rect->y1, rect->y2);
+ rtgui_dc_draw_hline(dc, rect->x1, rect->x2, rect->y2 - 1);
}
void rtgui_dc_draw_focus_rect(struct rtgui_dc* dc, rtgui_rect_t* rect)
{
int i;
- for (i = rect->x1; i <= rect->x2; i += 2)
+ for (i = rect->x1; i < rect->x2; i += 2)
{
rtgui_dc_draw_point(dc, i, rect->y1);
- rtgui_dc_draw_point(dc, i, rect->y2);
+ rtgui_dc_draw_point(dc, i, rect->y2 - 1);
}
- for (i = rect->y1; i <= rect->y2; i += 2)
+ for (i = rect->y1; i < rect->y2; i += 2)
{
rtgui_dc_draw_point(dc, rect->x1, i);
- rtgui_dc_draw_point(dc, rect->x2, i);
+ rtgui_dc_draw_point(dc, rect->x2 - 1, i);
}
}
diff --git a/components/rtgui/common/dc_client.c b/components/rtgui/common/dc_client.c
index a3559a8842..2b43d189e6 100644
--- a/components/rtgui/common/dc_client.c
+++ b/components/rtgui/common/dc_client.c
@@ -251,7 +251,6 @@ static void rtgui_dc_client_draw_point(struct rtgui_dc* self, int x, int y)
owner = RTGUI_CONTAINER_OF(self, struct rtgui_widget, dc_type);
if (!RTGUI_WIDGET_IS_DC_VISIBLE(owner)) return;
-
x = x + owner->extent.x1;
y = y + owner->extent.y1;
diff --git a/components/rtgui/common/rtgui_theme.c b/components/rtgui/common/rtgui_theme.c
index 5e337482a7..b9e52b3a99 100644
--- a/components/rtgui/common/rtgui_theme.c
+++ b/components/rtgui/common/rtgui_theme.c
@@ -174,36 +174,7 @@ void rtgui_theme_draw_button(rtgui_button_t* btn)
bc = RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(btn));
fc = RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(btn));
- if (btn->flag & RTGUI_BUTTON_TYPE_PUSH && btn->flag & RTGUI_BUTTON_FLAG_PRESS)
- {
- /* fill button rect with background color */
- rtgui_dc_fill_rect(dc, &rect);
-
- /* draw border */
- RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(btn)) = RTGUI_RGB(64, 64, 64);
- rtgui_dc_draw_hline(dc, rect.x1, rect.x2, rect.y1);
- rtgui_dc_draw_vline(dc, rect.x1, rect.y1, rect.y2);
-
- RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(btn)) = RTGUI_RGB(128, 128, 128);
- rtgui_dc_draw_hline(dc, rect.x1, rect.x2 - 1, rect.y1 + 1);
- rtgui_dc_draw_vline(dc, rect.x1 + 1, rect.y1 + 1, rect.y2 - 2);
-
- RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(btn)) = RTGUI_RGB(255, 255, 255);
- rtgui_dc_draw_hline(dc, rect.x1, rect.x2 + 1, rect.y2 - 1);
- rtgui_dc_draw_vline(dc, rect.x2 - 1, rect.y1, rect.y2);
-
- if (btn->pressed_image != RT_NULL)
- {
- rtgui_rect_t image_rect;
- image_rect.x1 = 0; image_rect.y1 = 0;
- image_rect.x2 = btn->unpressed_image->w;
- image_rect.y2 = btn->unpressed_image->h;
- rtgui_rect_moveto_align(&rect, &image_rect, RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL);
-
- rtgui_image_blit(btn->pressed_image, dc, &image_rect);
- }
- }
- else if (btn->flag & RTGUI_BUTTON_FLAG_PRESS)
+ if (btn->flag & RTGUI_BUTTON_FLAG_PRESS)
{
if (btn->pressed_image != RT_NULL)
{
@@ -218,16 +189,8 @@ void rtgui_theme_draw_button(rtgui_button_t* btn)
else
{
/* fill button rect with background color */
- RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(btn)) = RTGUI_RGB(0xff, 0xff, 0xff);
rtgui_dc_fill_rect(dc, &rect);
-
- /* draw border */
- RTGUI_WIDGET(btn)->gc.foreground = RTGUI_RGB(0, 0, 0);
- rtgui_dc_draw_rect(dc, &rect);
-
- RTGUI_WIDGET(btn)->gc.foreground = RTGUI_RGB(128, 128, 128);
- rect.x1 += 1; rect.y1 += 1; rect.x2 -= 1; rect.y2 -= 1;
- rtgui_dc_draw_rect(dc, &rect);
+ rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_SUNKEN);
}
}
else
@@ -246,19 +209,7 @@ void rtgui_theme_draw_button(rtgui_button_t* btn)
{
/* fill button rect with background color */
rtgui_dc_fill_rect(dc, &rect);
-
- /* draw border */
- RTGUI_WIDGET(btn)->gc.foreground = RTGUI_RGB(255, 255, 255);
- rtgui_dc_draw_hline(dc, rect.x1, rect.x2, rect.y1);
- rtgui_dc_draw_vline(dc, rect.x1, rect.y1, rect.y2);
-
- RTGUI_WIDGET(btn)->gc.foreground = RTGUI_RGB(0, 0, 0);
- rtgui_dc_draw_hline(dc, rect.x1, rect.x2 + 1, rect.y2);
- rtgui_dc_draw_vline(dc, rect.x2, rect.y1, rect.y2);
-
- RTGUI_WIDGET(btn)->gc.foreground = RTGUI_RGB(128, 128, 128);
- rtgui_dc_draw_hline(dc, rect.x1 + 1, rect.x2, rect.y2 - 1);
- rtgui_dc_draw_vline(dc, rect.x2 - 1, rect.y1 + 1, rect.y2 - 1);
+ rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_RAISE);
}
}
@@ -930,10 +881,9 @@ void rtgui_theme_draw_progressbar(struct rtgui_progressbar* bar)
rtgui_widget_get_rect(&(bar->parent), &rect);
/* fill button rect with background color */
- bar->parent.gc.background = RTGUI_RGB(212, 208, 200);
+ RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(bar)) = RTGUI_RGB(212, 208, 200);
/* draw border */
- rect.x2 --; rect.y2 --;
rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_SUNKEN);
/* Nothing to draw */
@@ -946,7 +896,8 @@ void rtgui_theme_draw_progressbar(struct rtgui_progressbar* bar)
rect.x2 ++; rect.y2 ++;
left = max - pos;
rtgui_rect_inflate(&rect, -2);
- bar->parent.gc.background = RTGUI_RGB(0, 0, 255);
+ RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(bar)) = RTGUI_RGB(0, 0, 255);
+ rect.y2 --; rect.x2 --;
if (bar->orient == RTGUI_VERTICAL)
{