add focus option to checkbox.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@368 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
bernard.xiong 2010-02-03 10:28:11 +00:00
parent 4f949216e3
commit b22642e934
2 changed files with 15 additions and 2 deletions

View File

@ -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);

View File

@ -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)
{