diff --git a/components/rtgui/include/rtgui/widgets/slider.h b/components/rtgui/include/rtgui/widgets/slider.h index 23bceedc9e..062c617f2a 100644 --- a/components/rtgui/include/rtgui/widgets/slider.h +++ b/components/rtgui/include/rtgui/widgets/slider.h @@ -33,6 +33,8 @@ struct rtgui_slider rt_size_t thumb_width; int orient; + + void (*on_changed)(struct rtgui_widget* widget, struct rtgui_event *event); }; typedef struct rtgui_slider rtgui_slider_t; diff --git a/components/rtgui/widgets/button.c b/components/rtgui/widgets/button.c index 35f910e213..8d24d191fd 100644 --- a/components/rtgui/widgets/button.c +++ b/components/rtgui/widgets/button.c @@ -86,7 +86,7 @@ rt_bool_t rtgui_button_event_handler(struct rtgui_widget* widget, struct rtgui_e { struct rtgui_event_kbd* ekbd = (struct rtgui_event_kbd*) event; - if (RTGUI_WIDGET_IS_HIDE(widget)) RT_FALSE; + if (RTGUI_WIDGET_IS_HIDE(widget)) return RT_FALSE; if ((ekbd->key == RTGUIK_RETURN) || (ekbd->key == RTGUIK_SPACE)) { if (RTGUI_KBD_IS_DOWN(ekbd)) @@ -111,7 +111,7 @@ rt_bool_t rtgui_button_event_handler(struct rtgui_widget* widget, struct rtgui_e break; case RTGUI_EVENT_MOUSE_BUTTON: - if (RTGUI_WIDGET_IS_HIDE(widget)) RT_FALSE; + if (RTGUI_WIDGET_IS_HIDE(widget)) return RT_FALSE; { struct rtgui_event_mouse* emouse = (struct rtgui_event_mouse*)event; diff --git a/components/rtgui/widgets/progressbar.c b/components/rtgui/widgets/progressbar.c index f29e2bfadc..7e346c8194 100644 --- a/components/rtgui/widgets/progressbar.c +++ b/components/rtgui/widgets/progressbar.c @@ -81,6 +81,8 @@ void rtgui_progressbar_set_value(struct rtgui_progressbar *bar, int value) { RT_ASSERT(bar != RT_NULL); + if (!RTGUI_WIDGET_IS_ENABLE(RTGUI_WIDGET(bar))) return; + bar->position = value; rtgui_theme_draw_progressbar(bar); diff --git a/components/rtgui/widgets/radiobox.c b/components/rtgui/widgets/radiobox.c index 5fbb79f0a6..b9ae846e8b 100644 --- a/components/rtgui/widgets/radiobox.c +++ b/components/rtgui/widgets/radiobox.c @@ -40,6 +40,10 @@ static void rtgui_radiobox_onmouse(struct rtgui_radiobox* radiobox, struct rtgui RT_ASSERT(radiobox != RT_NULL); RT_ASSERT(event != RT_NULL); + /* widget is hide, return */ + if (RTGUI_WIDGET_IS_HIDE(RTGUI_WIDGET(radiobox)) || + !RTGUI_WIDGET_IS_ENABLE(RTGUI_WIDGET(radiobox))) return; + if (event->button & RTGUI_MOUSE_BUTTON_DOWN && event->button & RTGUI_MOUSE_BUTTON_LEFT) { @@ -97,6 +101,8 @@ rt_bool_t rtgui_radiobox_event_handler(struct rtgui_widget* widget, struct rtgui break; case RTGUI_EVENT_KBD: + if (RTGUI_WIDGET_IS_HIDE(RTGUI_WIDGET(radiobox))) return RT_FALSE; + #ifndef RTGUI_USING_SMALL_SIZE if (widget->on_key != RT_NULL) widget->on_key(widget, event); else diff --git a/components/rtgui/widgets/scrollbar.c b/components/rtgui/widgets/scrollbar.c index c83c7bb717..df585193dd 100644 --- a/components/rtgui/widgets/scrollbar.c +++ b/components/rtgui/widgets/scrollbar.c @@ -286,7 +286,7 @@ rt_bool_t rtgui_scrollbar_event_handler(struct rtgui_widget * widget, break; case RTGUI_EVENT_MOUSE_BUTTON: - if (RTGUI_WIDGET_IS_ENABLE(widget)) + if (RTGUI_WIDGET_IS_ENABLE(widget) && !RTGUI_WIDGET_IS_HIDE(widget)) { #ifndef RTGUI_USING_SMALL_SIZE if (widget->on_mouseclick != RT_NULL) diff --git a/components/rtgui/widgets/slider.c b/components/rtgui/widgets/slider.c index 4779892c8b..d2851c17b2 100644 --- a/components/rtgui/widgets/slider.c +++ b/components/rtgui/widgets/slider.c @@ -10,6 +10,7 @@ * Change Logs: * Date Author Notes * 2009-10-16 Bernard first version + * 2010-09-10 Bernard fix hide issue */ #include #include @@ -37,6 +38,7 @@ static void _rtgui_slider_constructor(rtgui_slider_t *slider) slider->ticks = 10; slider->thumb_width = 8; + slider->on_changed = RT_NULL; } rtgui_type_t *rtgui_slider_type_get(void) @@ -95,6 +97,8 @@ static void rtgui_slider_onmouse(struct rtgui_slider* slider, struct rtgui_event rtgui_widget_focus(RTGUI_WIDGET(slider)); rtgui_slider_set_value(slider, sel); + if (slider->on_changed != RT_NULL) /* invoke callback function */ + slider->on_changed(RTGUI_WIDGET(slider), RT_NULL); } } @@ -119,6 +123,8 @@ static void rtgui_slider_onkey(struct rtgui_slider* slider, struct rtgui_event_k /* update widget */ rtgui_widget_update(RTGUI_WIDGET(slider)); + if (slider->on_changed != RT_NULL) /* invoke callback function */ + slider->on_changed(RTGUI_WIDGET(slider), RT_NULL); } rt_bool_t rtgui_slider_event_handler(struct rtgui_widget* widget, struct rtgui_event* event) @@ -139,6 +145,8 @@ rt_bool_t rtgui_slider_event_handler(struct rtgui_widget* widget, struct rtgui_e break; case RTGUI_EVENT_KBD: + if (!RTGUI_WIDGET_IS_ENABLE(widget) || RTGUI_WIDGET_IS_HIDE(widget)) return RT_FALSE; + #ifndef RTGUI_USING_SMALL_SIZE if (widget->on_key != RT_NULL) widget->on_key(widget, event); else @@ -149,6 +157,8 @@ rt_bool_t rtgui_slider_event_handler(struct rtgui_widget* widget, struct rtgui_e break; case RTGUI_EVENT_MOUSE_BUTTON: + if (!RTGUI_WIDGET_IS_ENABLE(widget) || RTGUI_WIDGET_IS_HIDE(widget)) return RT_FALSE; + #ifndef RTGUI_USING_SMALL_SIZE if (widget->on_mouseclick != RT_NULL) widget->on_mouseclick(widget, event); else @@ -195,13 +205,16 @@ void rtgui_slider_set_value(struct rtgui_slider* slider, rt_size_t value) { RT_ASSERT(slider != RT_NULL); - if (value < slider->min) value = slider->min; - if (value > slider->max) value = slider->max; - - if (slider->value != value) + if (RTGUI_WIDGET_IS_ENABLE(RTGUI_WIDGET(slider))) { - slider->value = value; - rtgui_theme_draw_slider(slider); + if (value < slider->min) value = slider->min; + if (value > slider->max) value = slider->max; + + if (slider->value != value) + { + slider->value = value; + rtgui_theme_draw_slider(slider); + } } } diff --git a/components/rtgui/widgets/textbox.c b/components/rtgui/widgets/textbox.c index b8a1096200..6a7ca0e7a2 100644 --- a/components/rtgui/widgets/textbox.c +++ b/components/rtgui/widgets/textbox.c @@ -273,6 +273,8 @@ rt_bool_t rtgui_textbox_event_handler(struct rtgui_widget* widget, struct rtgui_ break; case RTGUI_EVENT_MOUSE_BUTTON: + if (!RTGUI_WIDGET_IS_ENABLE(widget) || RTGUI_WIDGET_IS_HIDE(widget)) return RT_FALSE; + #ifndef RTGUI_USING_SMALL_SIZE if (widget->on_mouseclick != RT_NULL) widget->on_mouseclick(widget, event); else @@ -281,6 +283,8 @@ rt_bool_t rtgui_textbox_event_handler(struct rtgui_widget* widget, struct rtgui_ return RT_TRUE; case RTGUI_EVENT_KBD: + if (!RTGUI_WIDGET_IS_ENABLE(widget) || RTGUI_WIDGET_IS_HIDE(widget)) return RT_FALSE; + #ifndef RTGUI_USING_SMALL_SIZE if (widget->on_key != RT_NULL) widget->on_key(widget, event); else