From d7c6cad8c11d3e1541ca1716669b0292c58371f0 Mon Sep 17 00:00:00 2001 From: "bernard.xiong@gmail.com" Date: Sun, 22 Aug 2010 14:53:32 +0000 Subject: [PATCH] update widget clip function. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@875 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- components/rtgui/common/dc_client.c | 2 ++ components/rtgui/common/rtgui_theme.c | 2 ++ components/rtgui/widgets/widget.c | 12 ++++++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/components/rtgui/common/dc_client.c b/components/rtgui/common/dc_client.c index 6dcf3181c..15360501c 100644 --- a/components/rtgui/common/dc_client.c +++ b/components/rtgui/common/dc_client.c @@ -42,6 +42,8 @@ static void rtgui_dc_client_get_rect(struct rtgui_dc* dc, rtgui_rect_t* rect); struct rtgui_dc* rtgui_dc_begin_drawing(rtgui_widget_t* owner) { + RT_ASSERT(owner != RT_NULL); + if ((rtgui_region_is_flat(&owner->clip) == RT_EOK) && rtgui_rect_is_equal(&(owner->extent), &(owner->clip.extents)) == RT_EOK) { diff --git a/components/rtgui/common/rtgui_theme.c b/components/rtgui/common/rtgui_theme.c index 266ceea9c..e328f19f0 100644 --- a/components/rtgui/common/rtgui_theme.c +++ b/components/rtgui/common/rtgui_theme.c @@ -58,6 +58,8 @@ void rtgui_theme_draw_win(struct rtgui_topwin* win) struct rtgui_dc* dc; rtgui_rect_t rect; + if (win->title == RT_NULL) return; /* no title and no board */ + /* begin drawing */ dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(win->title)); if (dc == RT_NULL) return; diff --git a/components/rtgui/widgets/widget.c b/components/rtgui/widgets/widget.c index 81968f929..34b022c04 100644 --- a/components/rtgui/widgets/widget.c +++ b/components/rtgui/widgets/widget.c @@ -134,7 +134,7 @@ void rtgui_widget_set_rect(rtgui_widget_t* widget, rtgui_rect_t* rect) if ((widget->parent != RT_NULL) && (widget->toplevel != RT_NULL)) { /* update widget clip */ - rtgui_widget_update_clip(widget); + rtgui_widget_update_clip(widget->parent); } } @@ -417,7 +417,15 @@ void rtgui_widget_update_clip(rtgui_widget_t* widget) parent = widget->parent; /* if there is no parent, do not update clip (please use toplevel widget API) */ - if (parent == RT_NULL) return; + if (parent == RT_NULL) + { + if (RTGUI_IS_TOPLEVEL(widget)) + { + /* if it's toplevel widget, update it by toplevel function */ + rtgui_toplevel_update_clip(RTGUI_TOPLEVEL(widget)); + } + return; + } /* reset clip to extent */ rtgui_region_reset(&(widget->clip), &(widget->extent));