diff --git a/components/rtgui/common/rtgui_object.c b/components/rtgui/common/rtgui_object.c index 12bc29a6fbd7124ea70305503237f324443722be..f3f779e3a881e0cb75c2cc2c10c2db24910ad7a7 100644 --- a/components/rtgui/common/rtgui_object.c +++ b/components/rtgui/common/rtgui_object.c @@ -34,7 +34,7 @@ DEFINE_CLASS_TYPE(type, "object", _rtgui_object_destructor, sizeof(struct rtgui_object)); -void rtgui_type_object_construct(rtgui_type_t *type, rtgui_object_t *object) +void rtgui_type_object_construct(const rtgui_type_t *type, rtgui_object_t *object) { /* first call parent's type */ if (type->parent != RT_NULL) @@ -43,32 +43,38 @@ void rtgui_type_object_construct(rtgui_type_t *type, rtgui_object_t *object) if (type->constructor) type->constructor(object); } -void rtgui_type_destructors_call(rtgui_type_t *type, rtgui_object_t *object) -{ - while (type) +void rtgui_type_destructors_call(const rtgui_type_t *type, rtgui_object_t *object) +{ + const rtgui_type_t *t; + + t = type; + while (t) { - if (type->destructor) type->destructor(object); - type = type->parent; + if (t->destructor) t->destructor(object); + t = t->parent; } } -rt_bool_t rtgui_type_inherits_from(rtgui_type_t *type, rtgui_type_t *parent) -{ - while (type) +rt_bool_t rtgui_type_inherits_from(const rtgui_type_t *type, const rtgui_type_t *parent) +{ + const rtgui_type_t *t; + + t = type; + while (t) { - if (type == parent) return RT_TRUE; - type = type->parent; + if (t == parent) return RT_TRUE; + t = t->parent; } return RT_FALSE; } -rtgui_type_t *rtgui_type_parent_type_get(rtgui_type_t *type) +const rtgui_type_t *rtgui_type_parent_type_get(const rtgui_type_t *type) { return type->parent; } -const char *rtgui_type_name_get(rtgui_type_t *type) +const char *rtgui_type_name_get(const rtgui_type_t *type) { if (!type) return RT_NULL; @@ -165,7 +171,7 @@ rtgui_object_t *rtgui_object_check_cast(rtgui_object_t *obj, rtgui_type_t *obj_t * @param object an object * @return Returns the type of @a object (RT_NULL on failure) */ -rtgui_type_t *rtgui_object_object_type_get(rtgui_object_t *object) +const rtgui_type_t *rtgui_object_object_type_get(rtgui_object_t *object) { if (!object) return RT_NULL; diff --git a/components/rtgui/include/rtgui/rtgui_object.h b/components/rtgui/include/rtgui/rtgui_object.h index 2010d9b4037851c6531ee8c464dae9d3501df469..20da0485b823c7958e320390f0d32aab1750553f 100644 --- a/components/rtgui/include/rtgui/rtgui_object.h +++ b/components/rtgui/include/rtgui/rtgui_object.h @@ -60,16 +60,16 @@ typedef struct rtgui_type rtgui_type_t; const struct rtgui_type _rtgui_##type = { \ name, \ parent, \ - constructor, \ - destructor, \ + RTGUI_CONSTRUCTOR(constructor), \ + RTGUI_DESTRUCTOR(destructor), \ size } -void rtgui_type_object_construct(rtgui_type_t *type, rtgui_object_t *object); -void rtgui_type_destructors_call(rtgui_type_t *type, rtgui_object_t *object); -rt_bool_t rtgui_type_inherits_from(rtgui_type_t *type, rtgui_type_t *parent); -rtgui_type_t *rtgui_type_parent_type_get(rtgui_type_t *type); -const char *rtgui_type_name_get(rtgui_type_t *type); -rtgui_type_t *rtgui_type_get_from_name(const char *name); +void rtgui_type_object_construct(const rtgui_type_t *type, rtgui_object_t *object); +void rtgui_type_destructors_call(const rtgui_type_t *type, rtgui_object_t *object); +rt_bool_t rtgui_type_inherits_from(const rtgui_type_t *type, const rtgui_type_t *parent); +const rtgui_type_t *rtgui_type_parent_type_get(const rtgui_type_t *type); +const char *rtgui_type_name_get(const rtgui_type_t *type); +const rtgui_type_t *rtgui_object_object_type_get(rtgui_object_t *object); #ifdef RTGUI_USING_CAST_CHECK #define RTGUI_OBJECT_CAST(obj, obj_type, c_type) \ diff --git a/components/rtgui/widgets/container.c b/components/rtgui/widgets/container.c index 420a2cd10183bbc9199d4ed1f1549f4d89138ee3..c1e90f719a2f544aef37216958a992ff36c3491d 100644 --- a/components/rtgui/widgets/container.c +++ b/components/rtgui/widgets/container.c @@ -120,12 +120,10 @@ rt_bool_t rtgui_container_event_handler(rtgui_widget_t* widget, rtgui_event_t* e /* handle in child widget */ return rtgui_container_dispatch_mouse_event(container, (struct rtgui_event_mouse*)event); - break; case RTGUI_EVENT_MOUSE_MOTION: return rtgui_container_dispatch_mouse_event(container, (struct rtgui_event_mouse*)event); - break; default: /* call parent widget event handler */ diff --git a/components/rtgui/widgets/menu.c b/components/rtgui/widgets/menu.c index d327063d90014103357a792b3c8f125708949115..9c1d19f73a175b37a1ef11c86ed235f2e37d19dc 100644 --- a/components/rtgui/widgets/menu.c +++ b/components/rtgui/widgets/menu.c @@ -137,10 +137,6 @@ static void _rtgui_menu_item_ondraw(struct rtgui_listctrl *list, struct rtgui_dc } } -static void _rtgui_menu_item_onmouse() -{ -} - DEFINE_CLASS_TYPE(menu, "menu", RTGUI_WIDGET_TYPE, _rtgui_menu_constructor, diff --git a/components/rtgui/widgets/toplevel.c b/components/rtgui/widgets/toplevel.c index 5e2387fab54ab5beb468cbef4da2d1253e9ff987..ee29015dd8ff5a6cba1bbc360af15ed79c78aec7 100644 --- a/components/rtgui/widgets/toplevel.c +++ b/components/rtgui/widgets/toplevel.c @@ -13,6 +13,7 @@ */ #include #include +extern void rtgui_topwin_do_clip(rtgui_widget_t* widget); static void _rtgui_toplevel_constructor(rtgui_toplevel_t *toplevel) { @@ -100,7 +101,6 @@ rt_bool_t rtgui_toplevel_event_handler(rtgui_widget_t* widget, rtgui_event_t* ev void rtgui_toplevel_update_clip(rtgui_toplevel_t* top) { - rt_uint32_t idx; rtgui_container_t* container; struct rtgui_list_node* node; rtgui_rect_t screen_rect; diff --git a/components/rtgui/widgets/widget.c b/components/rtgui/widgets/widget.c index daed3889f925a574d3b2f162f1478df2649a7fe3..32280c3d587a8ae8542cd74c8f00095ed178d680 100644 --- a/components/rtgui/widgets/widget.c +++ b/components/rtgui/widgets/widget.c @@ -17,6 +17,7 @@ #include #include #include +extern void rtgui_topwin_do_clip(rtgui_widget_t* widget); static void _rtgui_widget_constructor(rtgui_widget_t *widget) { @@ -494,8 +495,6 @@ void rtgui_widget_show(rtgui_widget_t* widget) void rtgui_widget_hide(rtgui_widget_t* widget) { - rtgui_rect_t rect; - /* hide this widget */ RTGUI_WIDGET_HIDE(widget);