summaryrefslogtreecommitdiff
path: root/rtgui
diff options
context:
space:
mode:
authorbernard.xiong <[email protected]>2010-02-03 10:28:11 +0000
committerbernard.xiong <[email protected]>2010-02-03 10:28:11 +0000
commitb22642e934fd3d6efe2ace1498da5e478756c7bb (patch)
tree85f0fc161145420c248849759f9a257af41c3849 /rtgui
parent4f949216e353bf4f1ce3cafaf144d0d36837ac32 (diff)
add focus option to checkbox.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@368 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'rtgui')
-rw-r--r--rtgui/common/rtgui_theme.c15
-rw-r--r--rtgui/widgets/checkbox.c2
2 files changed, 15 insertions, 2 deletions
diff --git a/rtgui/common/rtgui_theme.c b/rtgui/common/rtgui_theme.c
index 8ac4fce891..e2c0dd95ce 100644
--- a/rtgui/common/rtgui_theme.c
+++ b/rtgui/common/rtgui_theme.c
@@ -252,6 +252,16 @@ void rtgui_theme_draw_button(rtgui_button_t* btn)
}
}
+ if (RTGUI_WIDGET_IS_FOCUSED(RTGUI_WIDGET(btn)))
+ {
+ /* re-set foreground and get default rect */
+ rtgui_widget_get_rect(RTGUI_WIDGET(btn), &rect);
+ rtgui_rect_inflate(&rect, -2);
+
+ RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(btn)) = black;
+ rtgui_dc_draw_focus_rect(dc, &rect);
+ }
+
/* set forecolor */
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(btn)) = bc;
RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(btn)) = fc;
@@ -412,8 +422,10 @@ void rtgui_theme_draw_checkbox(struct rtgui_checkbox* checkbox)
/* fill rect */
rtgui_dc_fill_rect(dc, &rect);
- if (RTGUI_WIDGET_IS_FOCUSED(RTGUI_WIDGET(checkbox)) == RT_TRUE)
+ if (RTGUI_WIDGET_IS_FOCUSED(RTGUI_WIDGET(checkbox)))
{
+ RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(checkbox)) = black;
+
/* draw focused border */
rtgui_rect_inflate(&rect, -1);
rtgui_dc_draw_focus_rect(dc, &rect);
@@ -427,6 +439,7 @@ void rtgui_theme_draw_checkbox(struct rtgui_checkbox* checkbox)
box_rect.x2 = CHECK_BOX_W;
box_rect.y2 = CHECK_BOX_H;
rtgui_rect_moveto_align(&rect, &box_rect, RTGUI_ALIGN_CENTER_VERTICAL);
+ box_rect.x1 += 2; box_rect.x2 += 2;
rtgui_dc_draw_border(dc, &box_rect, RTGUI_BORDER_BOX);
rtgui_rect_inflate(&box_rect, -1);
diff --git a/rtgui/widgets/checkbox.c b/rtgui/widgets/checkbox.c
index 4da3fe4b31..e3677f0547 100644
--- a/rtgui/widgets/checkbox.c
+++ b/rtgui/widgets/checkbox.c
@@ -54,7 +54,7 @@ rt_bool_t rtgui_checkbox_event_handler(struct rtgui_widget* widget, struct rtgui
emouse->button & RTGUI_MOUSE_BUTTON_UP)
{
/* set focus */
- RTGUI_WIDGET_FOCUS(widget);
+ rtgui_widget_focus(widget);
if (box->status_down & RTGUI_CHECKBOX_STATUS_UNCHECKED)
{