summaryrefslogtreecommitdiff
path: root/components/rtgui/widgets/notebook.c
diff options
context:
space:
mode:
author[email protected] <[email protected]>2012-07-20 12:37:56 +0000
committer[email protected] <[email protected]>2012-07-20 12:37:56 +0000
commit92a50c838d8ca2ae4027fd77b71db12fb52d86e3 (patch)
tree08cb5a9273c78c36df97f48eea17eb2e1034a497 /components/rtgui/widgets/notebook.c
parentc2868be90d0f1f43ee13bacdb1c0f55a9fe34276 (diff)
sync with RTGUI c074ff2898b9e
Full log is in GitHub. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2222 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components/rtgui/widgets/notebook.c')
-rw-r--r--components/rtgui/widgets/notebook.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/components/rtgui/widgets/notebook.c b/components/rtgui/widgets/notebook.c
index c928cd268d..6b6f9ec49f 100644
--- a/components/rtgui/widgets/notebook.c
+++ b/components/rtgui/widgets/notebook.c
@@ -301,12 +301,16 @@ void rtgui_notebook_set_current_by_index(struct rtgui_notebook* notebook, rt_uin
if ((index < notebook->count) && (notebook->current != index))
{
+ struct rtgui_widget *widget;
+
if (notebook->current != RTGUI_NOT_FOUND)
rtgui_widget_hide(notebook->childs[notebook->current].widget);
notebook->current = index;
- rtgui_widget_show(notebook->childs[notebook->current].widget);
- rtgui_widget_update(notebook->childs[notebook->current].widget);
+ widget = notebook->childs[notebook->current].widget;
+ rtgui_widget_show(widget);
+ rtgui_widget_update(widget);
+ rtgui_widget_focus(widget);
}
}
@@ -319,6 +323,16 @@ struct rtgui_widget* rtgui_notebook_get_widget_at(struct rtgui_notebook* noteboo
return RT_NULL;
}
+static rt_bool_t _rtgui_notebook_current_widget_handle(struct rtgui_notebook *notebook,
+ struct rtgui_event *event)
+{
+ struct rtgui_widget *widget = rtgui_notebook_get_current(notebook);
+ if (widget && widget != RTGUI_WIDGET(notebook))
+ return RTGUI_OBJECT(widget)->event_handler(RTGUI_OBJECT(widget), event);
+ else
+ return RT_FALSE;
+}
+
rt_bool_t rtgui_notebook_event_handler(struct rtgui_object* object, struct rtgui_event* event)
{
struct rtgui_notebook* notebook;
@@ -336,17 +350,18 @@ rt_bool_t rtgui_notebook_event_handler(struct rtgui_object* object, struct rtgui
case RTGUI_EVENT_MOUSE_BUTTON:
_rtgui_notebook_onmouse(notebook, (struct rtgui_event_mouse*)event);
break;
+ case RTGUI_EVENT_SHOW:
+ /* show myself */
+ rtgui_widget_onshow(object, event);
+ /* show the tab widget */
+ return _rtgui_notebook_current_widget_handle(notebook, event);
+ case RTGUI_EVENT_HIDE:
+ /* hide myself */
+ rtgui_widget_onhide(object, event);
+ /* hide the tab widget */
+ return _rtgui_notebook_current_widget_handle(notebook, event);
case RTGUI_EVENT_KBD:
- if (notebook->current != RTGUI_NOT_FOUND)
- {
- if (RTGUI_OBJECT(notebook->childs[notebook->current].widget
- )->event_handler != RT_NULL)
- return RTGUI_OBJECT(notebook->childs[notebook->current].widget
- )->event_handler(
- RTGUI_OBJECT(notebook->childs[notebook->current].widget),
- event);
- }
- break;
+ return _rtgui_notebook_current_widget_handle(notebook, event);
default:
/* use parent event handler */
return rtgui_widget_event_handler(object, event);