From 08e05eb3b493cd92601217fcf86fe6daa196eec4 Mon Sep 17 00:00:00 2001 From: "dzzxzz@gmail.com" Date: Thu, 26 Jul 2012 06:36:49 +0000 Subject: sync with github bd3351e572 As always, full log is in GitHub. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2234 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- components/rtgui/widgets/notebook.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'components/rtgui/widgets/notebook.c') diff --git a/components/rtgui/widgets/notebook.c b/components/rtgui/widgets/notebook.c index 1192fd6e70..dcbeac9416 100644 --- a/components/rtgui/widgets/notebook.c +++ b/components/rtgui/widgets/notebook.c @@ -231,6 +231,8 @@ void rtgui_notebook_add(struct rtgui_notebook* notebook, const char* label, stru void rtgui_notebook_remove(struct rtgui_notebook* notebook, rt_uint16_t index) { struct rtgui_notebook_tab tab; + rt_bool_t need_update = RT_FALSE; + RT_ASSERT(notebook != RT_NULL); if (index < notebook->count) @@ -244,8 +246,11 @@ void rtgui_notebook_remove(struct rtgui_notebook* notebook, rt_uint16_t index) } else { + if (notebook->current == index) + need_update = RT_TRUE; + tab = notebook->childs[index]; - for (;index < notebook->count - 1; index ++) + for (;index < notebook->count - 1; index++) { notebook->childs[index] = notebook->childs[index + 1]; } @@ -255,16 +260,17 @@ void rtgui_notebook_remove(struct rtgui_notebook* notebook, rt_uint16_t index) sizeof(struct rtgui_notebook_tab) * notebook->count); } - // FIXME: do we really want to destroy it? - rtgui_widget_destroy(tab.widget); rtgui_free(tab.title); - if (notebook->current == index) + if (need_update) { - /* update tab */ if (notebook->current > notebook->count - 1) notebook->current = notebook->count - 1; + + rtgui_widget_hide(tab.widget); + rtgui_widget_show(notebook->childs[notebook->current].widget); rtgui_widget_update(RTGUI_WIDGET(notebook)); + rtgui_widget_set_parent(tab.widget, RT_NULL); } } } -- cgit v1.3.1