提交 8457439d 编写于 作者: B bernard.xiong

use new object type implementation.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1402 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 169c31fc
...@@ -58,6 +58,7 @@ widgets/textbox.c ...@@ -58,6 +58,7 @@ widgets/textbox.c
widgets/listbox.c widgets/listbox.c
widgets/title.c widgets/title.c
widgets/toplevel.c widgets/toplevel.c
widgets/notebook.c
widgets/view.c widgets/view.c
widgets/list_view.c widgets/list_view.c
widgets/about_view.c widgets/about_view.c
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <rtgui/image_xpm.h> #include <rtgui/image_xpm.h>
#include <rtgui/rtgui_system.h> #include <rtgui/rtgui_system.h>
#ifdef RTGUI_IMAGE_XPM
#define XPM_MAGIC_LEN 9 #define XPM_MAGIC_LEN 9
static rt_bool_t rtgui_image_xpm_check(struct rtgui_filerw * file); static rt_bool_t rtgui_image_xpm_check(struct rtgui_filerw * file);
...@@ -607,4 +608,4 @@ static void rtgui_image_xpm_blit(struct rtgui_image* image, struct rtgui_dc* dc, ...@@ -607,4 +608,4 @@ static void rtgui_image_xpm_blit(struct rtgui_image* image, struct rtgui_dc* dc,
} }
} }
} }
#endif
...@@ -28,90 +28,36 @@ static void _rtgui_object_destructor(rtgui_object_t *object) ...@@ -28,90 +28,36 @@ static void _rtgui_object_destructor(rtgui_object_t *object)
/* nothing */ /* nothing */
} }
rtgui_type_t *rtgui_type_create(const char *type_name, rtgui_type_t *parent_type, DEFINE_CLASS_TYPE(type, "object",
int type_size, rtgui_constructor_t constructor, RT_NULL,
rtgui_destructor_t destructor) _rtgui_object_constructor,
{ _rtgui_object_destructor,
rtgui_type_t *new_type; sizeof(struct rtgui_object));
if (!type_name)
return RT_NULL;
new_type = rtgui_malloc(sizeof(rtgui_type_t));
new_type->name = rt_strdup(type_name);
new_type->size = type_size;
new_type->constructor = constructor;
new_type->destructor = destructor;
if (!parent_type)
{
new_type->hierarchy_depth = 0;
new_type->hierarchy = RT_NULL;
}
else
{
/* Build the type hierarchy */
new_type->hierarchy_depth = parent_type->hierarchy_depth + 1;
new_type->hierarchy = rtgui_malloc(sizeof(rtgui_type_t *) * new_type->hierarchy_depth);
new_type->hierarchy[0] = parent_type;
rt_memcpy(new_type->hierarchy + 1, parent_type->hierarchy,
parent_type->hierarchy_depth * sizeof(rtgui_type_t *));
}
return new_type;
}
void rtgui_type_destroy(rtgui_type_t *type)
{
if (!type) return;
if (type->hierarchy) rtgui_free(type->hierarchy);
rtgui_free(type->name);
rtgui_free(type);
}
void rtgui_type_object_construct(rtgui_type_t *type, rtgui_object_t *object) void rtgui_type_object_construct(rtgui_type_t *type, rtgui_object_t *object)
{ {
int i; /* first call parent's type */
if (type->parent != RT_NULL)
rtgui_type_object_construct(type->parent, object);
if (!type || !object) return;
/* Call the constructors */
for (i = type->hierarchy_depth - 1; i >= 0; i--)
{
if (type->hierarchy[i]->constructor)
type->hierarchy[i]->constructor(object);
}
if (type->constructor) type->constructor(object); if (type->constructor) type->constructor(object);
} }
void rtgui_type_destructors_call(rtgui_type_t *type, rtgui_object_t *object) void rtgui_type_destructors_call(rtgui_type_t *type, rtgui_object_t *object)
{ {
int i; while (type)
if (!type || !object) return;
if (type->destructor) type->destructor(object);
for (i = 0; i < type->hierarchy_depth; i++)
{ {
if (type->hierarchy[i]->destructor) if (type->destructor) type->destructor(object);
type->hierarchy[i]->destructor(object); type = type->parent;
} }
} }
rt_bool_t rtgui_type_inherits_from(rtgui_type_t *type, rtgui_type_t *parent) rt_bool_t rtgui_type_inherits_from(rtgui_type_t *type, rtgui_type_t *parent)
{ {
int i; while (type)
if (!type || !parent) return RT_FALSE;
if (type == parent) return RT_TRUE;
for (i = 0; i < type->hierarchy_depth; i++)
{ {
if (type->hierarchy[i] == parent) return RT_TRUE; if (type == parent) return RT_TRUE;
type = type->parent;
} }
return RT_FALSE; return RT_FALSE;
...@@ -119,9 +65,7 @@ rt_bool_t rtgui_type_inherits_from(rtgui_type_t *type, rtgui_type_t *parent) ...@@ -119,9 +65,7 @@ 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) rtgui_type_t *rtgui_type_parent_type_get(rtgui_type_t *type)
{ {
if (!type || !type->hierarchy) return RT_NULL; return type->parent;
return type->hierarchy[0];
} }
const char *rtgui_type_name_get(rtgui_type_t *type) const char *rtgui_type_name_get(rtgui_type_t *type)
...@@ -131,6 +75,7 @@ const char *rtgui_type_name_get(rtgui_type_t *type) ...@@ -131,6 +75,7 @@ const char *rtgui_type_name_get(rtgui_type_t *type)
return type->name; return type->name;
} }
#ifdef RTGUI_OBJECT_TRACE
struct rtgui_object_information struct rtgui_object_information
{ {
rt_uint32_t objs_number; rt_uint32_t objs_number;
...@@ -138,6 +83,7 @@ struct rtgui_object_information ...@@ -138,6 +83,7 @@ struct rtgui_object_information
rt_uint32_t max_allocated; rt_uint32_t max_allocated;
}; };
struct rtgui_object_information obj_info = {0, 0, 0}; struct rtgui_object_information obj_info = {0, 0, 0};
#endif
/** /**
* @brief Creates a new object: it calls the corresponding constructors (from the constructor of the base class to the * @brief Creates a new object: it calls the corresponding constructors (from the constructor of the base class to the
...@@ -155,10 +101,12 @@ rtgui_object_t *rtgui_object_create(rtgui_type_t *object_type) ...@@ -155,10 +101,12 @@ rtgui_object_t *rtgui_object_create(rtgui_type_t *object_type)
new_object = rtgui_malloc(object_type->size); new_object = rtgui_malloc(object_type->size);
if (new_object == RT_NULL) return RT_NULL; if (new_object == RT_NULL) return RT_NULL;
#ifdef RTGUI_OBJECT_TRACE
obj_info.objs_number ++; obj_info.objs_number ++;
obj_info.allocated_size += object_type->size; obj_info.allocated_size += object_type->size;
if (obj_info.allocated_size > obj_info.max_allocated) if (obj_info.allocated_size > obj_info.max_allocated)
obj_info.max_allocated = obj_info.allocated_size; obj_info.max_allocated = obj_info.allocated_size;
#endif
new_object->type = object_type; new_object->type = object_type;
new_object->is_static = RT_FALSE; new_object->is_static = RT_FALSE;
...@@ -179,8 +127,10 @@ void rtgui_object_destroy(rtgui_object_t *object) ...@@ -179,8 +127,10 @@ void rtgui_object_destroy(rtgui_object_t *object)
{ {
if (!object || object->is_static == RT_TRUE) return; if (!object || object->is_static == RT_TRUE) return;
#ifdef RTGUI_OBJECT_TRACE
obj_info.objs_number --; obj_info.objs_number --;
obj_info.allocated_size -= object->type->size; obj_info.allocated_size -= object->type->size;
#endif
/* call destructor */ /* call destructor */
RT_ASSERT(object->type != RT_NULL); RT_ASSERT(object->type != RT_NULL);
...@@ -190,25 +140,6 @@ void rtgui_object_destroy(rtgui_object_t *object) ...@@ -190,25 +140,6 @@ void rtgui_object_destroy(rtgui_object_t *object)
rtgui_free(object); rtgui_free(object);
} }
/**
* @internal
* @brief Gets the type of a rtgui_object
* @return Returns the type of a rtgui_object
*/
rtgui_type_t *rtgui_object_type_get(void)
{
static rtgui_type_t *object_type = RT_NULL;
if (!object_type)
{
object_type = rtgui_type_create("object", RT_NULL,
sizeof(rtgui_object_t), RTGUI_CONSTRUCTOR(_rtgui_object_constructor),
RTGUI_DESTRUCTOR(_rtgui_object_destructor));
}
return object_type;
}
/** /**
* @brief Checks if @a object can be cast to @a type. * @brief Checks if @a object can be cast to @a type.
* If @a object doesn't inherit from @a type, a warning is displayed in the console but the object is returned anyway. * If @a object doesn't inherit from @a type, a warning is displayed in the console but the object is returned anyway.
...@@ -217,16 +148,16 @@ rtgui_type_t *rtgui_object_type_get(void) ...@@ -217,16 +148,16 @@ rtgui_type_t *rtgui_object_type_get(void)
* @return Returns the object * @return Returns the object
* @note You usually do not need to call this function, use specific macros instead (ETK_IS_WIDGET() for example) * @note You usually do not need to call this function, use specific macros instead (ETK_IS_WIDGET() for example)
*/ */
rtgui_object_t *rtgui_object_check_cast(rtgui_object_t *object, rtgui_type_t *type) rtgui_object_t *rtgui_object_check_cast(rtgui_object_t *obj, rtgui_type_t *obj_type)
{ {
if (!object) return RT_NULL; if (!obj) return RT_NULL;
if (!rtgui_type_inherits_from(object->type, type)) if (!rtgui_type_inherits_from(obj->type, obj_type))
{ {
rt_kprintf("Invalid cast from \"%s\" to \"%s\"\n", rtgui_type_name_get(object->type), rtgui_type_name_get(type)); rt_kprintf("Invalid cast from \"%s\" to \"%s\"\n", rtgui_type_name_get(obj->type), rtgui_type_name_get(obj_type));
} }
return object; return obj;
} }
/** /**
...@@ -240,3 +171,4 @@ rtgui_type_t *rtgui_object_object_type_get(rtgui_object_t *object) ...@@ -240,3 +171,4 @@ rtgui_type_t *rtgui_object_object_type_get(rtgui_object_t *object)
return object->type; return object->type;
} }
...@@ -35,7 +35,6 @@ void rtgui_system_server_init() ...@@ -35,7 +35,6 @@ void rtgui_system_server_init()
rtgui_font_system_init(); rtgui_font_system_init();
/* init rtgui server */ /* init rtgui server */
rtgui_panel_init();
rtgui_topwin_init(); rtgui_topwin_init();
rtgui_server_init(); rtgui_server_init();
...@@ -236,11 +235,6 @@ static void rtgui_event_dump(rt_thread_t tid, rtgui_event_t* event) ...@@ -236,11 +235,6 @@ static void rtgui_event_dump(rt_thread_t tid, rtgui_event_t* event)
struct rtgui_event_monitor *monitor = (struct rtgui_event_monitor*)event; struct rtgui_event_monitor *monitor = (struct rtgui_event_monitor*)event;
if (monitor->panel != RT_NULL) if (monitor->panel != RT_NULL)
{ {
#if 0
rt_kprintf("panel: %s, the rect is:(%d, %d) - (%d, %d)", monitor->panel->name,
monitor->rect.x1, monitor->rect.y1,
monitor->rect.x2, monitor->rect.y2);
#endif
rt_kprintf("the rect is:(%d, %d) - (%d, %d)", rt_kprintf("the rect is:(%d, %d) - (%d, %d)",
monitor->rect.x1, monitor->rect.y1, monitor->rect.x1, monitor->rect.y1,
monitor->rect.x2, monitor->rect.y2); monitor->rect.x2, monitor->rect.y2);
......
...@@ -275,6 +275,7 @@ struct rtgui_event_paint ...@@ -275,6 +275,7 @@ struct rtgui_event_paint
struct rtgui_event parent; struct rtgui_event parent;
rtgui_win_t* wid; /* destination window */ rtgui_win_t* wid; /* destination window */
rtgui_rect_t rect; /* rect to be updated */
}; };
struct rtgui_timer; struct rtgui_timer;
......
...@@ -42,9 +42,8 @@ struct rtgui_type ...@@ -42,9 +42,8 @@ struct rtgui_type
/* type name */ /* type name */
char* name; char* name;
/* hierarchy and depth */ /* parent type link */
struct rtgui_type **hierarchy; struct rtgui_type *parent;
int hierarchy_depth;
/* constructor and destructor */ /* constructor and destructor */
rtgui_constructor_t constructor; rtgui_constructor_t constructor;
...@@ -54,11 +53,16 @@ struct rtgui_type ...@@ -54,11 +53,16 @@ struct rtgui_type
int size; int size;
}; };
typedef struct rtgui_type rtgui_type_t; typedef struct rtgui_type rtgui_type_t;
#define RTGUI_TYPE(type) (struct rtgui_type*)&(_rtgui_##type)
rtgui_type_t *rtgui_type_create(const char *type_name, rtgui_type_t *parent_type, #define DECLARE_CLASS_TYPE(type) extern const struct rtgui_type _rtgui_##type
int type_size, rtgui_constructor_t constructor, #define DEFINE_CLASS_TYPE(type, name, parent, constructor, destructor, size) \
rtgui_destructor_t destructor); const struct rtgui_type _rtgui_##type = { \
void rtgui_type_destroy(rtgui_type_t *type); name, \
parent, \
constructor, \
destructor, \
size }
void rtgui_type_object_construct(rtgui_type_t *type, rtgui_object_t *object); 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); void rtgui_type_destructors_call(rtgui_type_t *type, rtgui_object_t *object);
...@@ -68,17 +72,18 @@ const char *rtgui_type_name_get(rtgui_type_t *type); ...@@ -68,17 +72,18 @@ const char *rtgui_type_name_get(rtgui_type_t *type);
rtgui_type_t *rtgui_type_get_from_name(const char *name); rtgui_type_t *rtgui_type_get_from_name(const char *name);
#ifdef RTGUI_USING_CAST_CHECK #ifdef RTGUI_USING_CAST_CHECK
#define RTGUI_OBJECT_CAST(obj, rtgui_type_t, c_type) \ #define RTGUI_OBJECT_CAST(obj, obj_type, c_type) \
((c_type *)rtgui_object_check_cast((rtgui_object_t *)(obj), (rtgui_type_t))) ((c_type *)rtgui_object_check_cast((rtgui_object_t *)(obj), (obj_type)))
#else #else
#define RTGUI_OBJECT_CAST(obj, rtgui_type_t, c_type) ((c_type *)(obj)) #define RTGUI_OBJECT_CAST(obj, obj_type, c_type) ((c_type *)(obj))
#endif #endif
#define RTGUI_OBJECT_CHECK_TYPE(_obj, _type) \ #define RTGUI_OBJECT_CHECK_TYPE(_obj, _type) \
(rtgui_type_inherits_from(((rtgui_object_t *)(_obj))->type, (_type))) (rtgui_type_inherits_from(((rtgui_object_t *)(_obj))->type, (_type)))
DECLARE_CLASS_TYPE(type);
/** Gets the type of an object */ /** Gets the type of an object */
#define RTGUI_OBJECT_TYPE (rtgui_object_type_get()) #define RTGUI_OBJECT_TYPE RTGUI_TYPE(type)
/** Casts the object to an rtgui_object_t */ /** Casts the object to an rtgui_object_t */
#define RTGUI_OBJECT(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_OBJECT_TYPE, rtgui_object_t)) #define RTGUI_OBJECT(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_OBJECT_TYPE, rtgui_object_t))
/** Checks if the object is an rtgui_Object */ /** Checks if the object is an rtgui_Object */
...@@ -88,7 +93,7 @@ rtgui_type_t *rtgui_type_get_from_name(const char *name); ...@@ -88,7 +93,7 @@ rtgui_type_t *rtgui_type_get_from_name(const char *name);
struct rtgui_object struct rtgui_object
{ {
/* object type */ /* object type */
rtgui_type_t* type; const rtgui_type_t* type;
rt_bool_t is_static; rt_bool_t is_static;
}; };
......
...@@ -63,7 +63,6 @@ typedef struct rtgui_topwin rtgui_topwin_t; ...@@ -63,7 +63,6 @@ typedef struct rtgui_topwin rtgui_topwin_t;
/* top win manager init */ /* top win manager init */
void rtgui_topwin_init(void); void rtgui_topwin_init(void);
void rtgui_panel_init (void);
void rtgui_server_init(void); void rtgui_server_init(void);
/* post an event to server */ /* post an event to server */
......
...@@ -20,8 +20,9 @@ ...@@ -20,8 +20,9 @@
#include <rtgui/rtgui_system.h> #include <rtgui/rtgui_system.h>
#include <rtgui/widgets/view.h> #include <rtgui/widgets/view.h>
DECLARE_CLASS_TYPE(aboutview);
/** Gets the type of a about view */ /** Gets the type of a about view */
#define RTGUI_ABOUT_VIEW_TYPE (rtgui_about_view_type_get()) #define RTGUI_ABOUT_VIEW_TYPE (RTGUI_TYPE(aboutview))
/** Casts the object to a about view */ /** Casts the object to a about view */
#define RTGUI_ABOUT_VIEW(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_ABOUT_VIEW_TYPE, rtgui_about_view_t)) #define RTGUI_ABOUT_VIEW(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_ABOUT_VIEW_TYPE, rtgui_about_view_t))
/** Checks if the object is a about view */ /** Checks if the object is a about view */
......
...@@ -22,8 +22,10 @@ ...@@ -22,8 +22,10 @@
extern "C" { extern "C" {
#endif #endif
DECLARE_CLASS_TYPE(box);
/** Gets the type of a box */ /** Gets the type of a box */
#define RTGUI_BOX_TYPE (rtgui_box_type_get()) #define RTGUI_BOX_TYPE (RTGUI_TYPE(box))
/** Casts the object to an rtgui_box */ /** Casts the object to an rtgui_box */
#define RTGUI_BOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_BOX_TYPE, rtgui_box_t)) #define RTGUI_BOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_BOX_TYPE, rtgui_box_t))
/** Checks if the object is an rtgui_box */ /** Checks if the object is an rtgui_box */
...@@ -38,8 +40,6 @@ struct rtgui_box ...@@ -38,8 +40,6 @@ struct rtgui_box
}; };
typedef struct rtgui_box rtgui_box_t; typedef struct rtgui_box rtgui_box_t;
rtgui_type_t *rtgui_box_type_get(void);
struct rtgui_box* rtgui_box_create(int orientation, rtgui_rect_t* rect); struct rtgui_box* rtgui_box_create(int orientation, rtgui_rect_t* rect);
void rtgui_box_destroy(struct rtgui_box* box); void rtgui_box_destroy(struct rtgui_box* box);
......
...@@ -27,8 +27,10 @@ extern "C" { ...@@ -27,8 +27,10 @@ extern "C" {
* @{ * @{
*/ */
DECLARE_CLASS_TYPE(button);
/** Gets the type of a button */ /** Gets the type of a button */
#define RTGUI_BUTTON_TYPE (rtgui_button_type_get()) #define RTGUI_BUTTON_TYPE (RTGUI_TYPE(button))
/** Casts the object to an rtgui_button */ /** Casts the object to an rtgui_button */
#define RTGUI_BUTTON(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_BUTTON_TYPE, rtgui_button_t)) #define RTGUI_BUTTON(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_BUTTON_TYPE, rtgui_button_t))
/** Checks if the object is an rtgui_button */ /** Checks if the object is an rtgui_button */
...@@ -59,8 +61,6 @@ struct rtgui_button ...@@ -59,8 +61,6 @@ struct rtgui_button
}; };
typedef struct rtgui_button rtgui_button_t; typedef struct rtgui_button rtgui_button_t;
rtgui_type_t *rtgui_button_type_get(void);
rtgui_button_t* rtgui_button_create(const char* text); rtgui_button_t* rtgui_button_create(const char* text);
rtgui_button_t* rtgui_pushbutton_create(const char* text); rtgui_button_t* rtgui_pushbutton_create(const char* text);
void rtgui_button_destroy(rtgui_button_t* btn); void rtgui_button_destroy(rtgui_button_t* btn);
......
...@@ -5,8 +5,10 @@ ...@@ -5,8 +5,10 @@
#include <rtgui/widgets/widget.h> #include <rtgui/widgets/widget.h>
#include <rtgui/widgets/label.h> #include <rtgui/widgets/label.h>
/** Gets the type of a button */ DECLARE_CLASS_TYPE(checkbox);
#define RTGUI_CHECKBOX_TYPE (rtgui_checkbox_type_get())
/** Gets the type of a checkbox */
#define RTGUI_CHECKBOX_TYPE (RTGUI_TYPE(checkbox))
/** Casts the object to an rtgui_button */ /** Casts the object to an rtgui_button */
#define RTGUI_CHECKBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_CHECKBOX_TYPE, rtgui_checkbox)) #define RTGUI_CHECKBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_CHECKBOX_TYPE, rtgui_checkbox))
/** Checks if the object is an rtgui_button */ /** Checks if the object is an rtgui_button */
...@@ -28,8 +30,6 @@ struct rtgui_checkbox ...@@ -28,8 +30,6 @@ struct rtgui_checkbox
}; };
typedef struct rtgui_checkbox rtgui_checkbox_t; typedef struct rtgui_checkbox rtgui_checkbox_t;
rtgui_type_t *rtgui_checkbox_type_get(void);
rtgui_checkbox_t* rtgui_checkbox_create(const char* text, rt_bool_t checked); rtgui_checkbox_t* rtgui_checkbox_create(const char* text, rt_bool_t checked);
void rtgui_checkbox_destroy(rtgui_checkbox_t* checkbox); void rtgui_checkbox_destroy(rtgui_checkbox_t* checkbox);
......
...@@ -6,8 +6,9 @@ ...@@ -6,8 +6,9 @@
#include <rtgui/widgets/window.h> #include <rtgui/widgets/window.h>
#include <rtgui/widgets/listbox.h> #include <rtgui/widgets/listbox.h>
DECLARE_CLASS_TYPE(combobox);
/** Gets the type of a combobox */ /** Gets the type of a combobox */
#define RTGUI_COMBOBOX_TYPE (rtgui_combobox_type_get()) #define RTGUI_COMBOBOX_TYPE (RTGUI_TYPE(combobox))
/** Casts the object to a rtgui_combobox */ /** Casts the object to a rtgui_combobox */
#define RTGUI_COMBOBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_COMBOBOX_TYPE, rtgui_combobox_t)) #define RTGUI_COMBOBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_COMBOBOX_TYPE, rtgui_combobox_t))
/** Checks if the object is a rtgui_combobox */ /** Checks if the object is a rtgui_combobox */
...@@ -37,7 +38,6 @@ struct rtgui_combobox ...@@ -37,7 +38,6 @@ struct rtgui_combobox
}; };
typedef struct rtgui_combobox rtgui_combobox_t; typedef struct rtgui_combobox rtgui_combobox_t;
rtgui_type_t *rtgui_combobox_type_get(void);
rtgui_combobox_t *rtgui_combobox_create(struct rtgui_listbox_item* items, rt_uint16_t counter, struct rtgui_rect* rect); rtgui_combobox_t *rtgui_combobox_create(struct rtgui_listbox_item* items, rt_uint16_t counter, struct rtgui_rect* rect);
void rtgui_combobox_destroy(rtgui_combobox_t* box); void rtgui_combobox_destroy(rtgui_combobox_t* box);
......
...@@ -16,8 +16,9 @@ ...@@ -16,8 +16,9 @@
#include <rtgui/widgets/widget.h> #include <rtgui/widgets/widget.h>
DECLARE_CLASS_TYPE(container);
/** Gets the type of a container */ /** Gets the type of a container */
#define RTGUI_CONTAINER_TYPE (rtgui_container_type_get()) #define RTGUI_CONTAINER_TYPE (RTGUI_TYPE(container))
/** Casts the object to a rtgui_container */ /** Casts the object to a rtgui_container */
#define RTGUI_CONTAINER(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_CONTAINER_TYPE, rtgui_container_t)) #define RTGUI_CONTAINER(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_CONTAINER_TYPE, rtgui_container_t))
/** Checks if the object is a rtgui_container */ /** Checks if the object is a rtgui_container */
...@@ -33,8 +34,6 @@ struct rtgui_container ...@@ -33,8 +34,6 @@ struct rtgui_container
}; };
typedef struct rtgui_container rtgui_container_t; typedef struct rtgui_container rtgui_container_t;
rtgui_type_t *rtgui_container_type_get(void);
void rtgui_container_add_child(rtgui_container_t *container, rtgui_widget_t* child); void rtgui_container_add_child(rtgui_container_t *container, rtgui_widget_t* child);
void rtgui_container_remove_child(rtgui_container_t *container, rtgui_widget_t* child); void rtgui_container_remove_child(rtgui_container_t *container, rtgui_widget_t* child);
void rtgui_container_destroy_children(rtgui_container_t *container); void rtgui_container_destroy_children(rtgui_container_t *container);
......
...@@ -14,8 +14,9 @@ struct rtgui_file_item ...@@ -14,8 +14,9 @@ struct rtgui_file_item
rt_uint32_t size; rt_uint32_t size;
}; };
DECLARE_CLASS_TYPE(filelist);
/** Gets the type of a filelist view */ /** Gets the type of a filelist view */
#define RTGUI_FILELIST_VIEW_TYPE (rtgui_filelist_view_type_get()) #define RTGUI_FILELIST_VIEW_TYPE (RTGUI_TYPE(filelist))
/** Casts the object to a filelist */ /** Casts the object to a filelist */
#define RTGUI_FILELIST_VIEW(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_FILELIST_VIEW_TYPE, rtgui_filelist_view_t)) #define RTGUI_FILELIST_VIEW(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_FILELIST_VIEW_TYPE, rtgui_filelist_view_t))
/** Checks if the object is a filelist view */ /** Checks if the object is a filelist view */
...@@ -43,8 +44,6 @@ struct rtgui_filelist_view ...@@ -43,8 +44,6 @@ struct rtgui_filelist_view
}; };
typedef struct rtgui_filelist_view rtgui_filelist_view_t; typedef struct rtgui_filelist_view rtgui_filelist_view_t;
rtgui_type_t *rtgui_filelist_view_type_get(void);
rtgui_filelist_view_t* rtgui_filelist_view_create(rtgui_workbench_t* workbench, rtgui_filelist_view_t* rtgui_filelist_view_create(rtgui_workbench_t* workbench,
const char* directory, const char* pattern, const rtgui_rect_t* rect); const char* directory, const char* pattern, const rtgui_rect_t* rect);
void rtgui_filelist_view_destroy(rtgui_filelist_view_t* view); void rtgui_filelist_view_destroy(rtgui_filelist_view_t* view);
......
...@@ -18,8 +18,9 @@ ...@@ -18,8 +18,9 @@
#include <rtgui/image.h> #include <rtgui/image.h>
#include <rtgui/widgets/widget.h> #include <rtgui/widgets/widget.h>
DECLARE_CLASS_TYPE(iconbox);
/** Gets the type of a iconbox */ /** Gets the type of a iconbox */
#define RTGUI_ICONBOX_TYPE (rtgui_iconbox_type_get()) #define RTGUI_ICONBOX_TYPE (RTGUI_TYPE(iconbox))
/** Casts the object to a rtgui_iconbox */ /** Casts the object to a rtgui_iconbox */
#define RTGUI_ICONBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_ICONBOX_TYPE, rtgui_iconbox_t)) #define RTGUI_ICONBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_ICONBOX_TYPE, rtgui_iconbox_t))
/** Checks if the object is a rtgui_iconbox */ /** Checks if the object is a rtgui_iconbox */
...@@ -44,8 +45,6 @@ struct rtgui_iconbox ...@@ -44,8 +45,6 @@ struct rtgui_iconbox
}; };
typedef struct rtgui_iconbox rtgui_iconbox_t; typedef struct rtgui_iconbox rtgui_iconbox_t;
rtgui_type_t *rtgui_iconbox_type_get(void);
struct rtgui_iconbox* rtgui_iconbox_create(struct rtgui_image* image, const char* text, int position); struct rtgui_iconbox* rtgui_iconbox_create(struct rtgui_image* image, const char* text, int position);
void rtgui_iconbox_destroy(struct rtgui_iconbox* iconbox); void rtgui_iconbox_destroy(struct rtgui_iconbox* iconbox);
......
...@@ -17,8 +17,10 @@ ...@@ -17,8 +17,10 @@
#include <rtgui/rtgui.h> #include <rtgui/rtgui.h>
#include <rtgui/widgets/widget.h> #include <rtgui/widgets/widget.h>
DECLARE_CLASS_TYPE(label);
/** Gets the type of a button */ /** Gets the type of a button */
#define RTGUI_LABEL_TYPE (rtgui_label_type_get()) #define RTGUI_LABEL_TYPE (RTGUI_TYPE(label))
/** Casts the object to an rtgui_button */ /** Casts the object to an rtgui_button */
#define RTGUI_LABEL(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_LABEL_TYPE, rtgui_label_t)) #define RTGUI_LABEL(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_LABEL_TYPE, rtgui_label_t))
/** Checks if the object is an rtgui_button */ /** Checks if the object is an rtgui_button */
...@@ -36,8 +38,6 @@ struct rtgui_label ...@@ -36,8 +38,6 @@ struct rtgui_label
}; };
typedef struct rtgui_label rtgui_label_t; typedef struct rtgui_label rtgui_label_t;
rtgui_type_t *rtgui_label_type_get(void);
rtgui_label_t* rtgui_label_create(const char* text); rtgui_label_t* rtgui_label_create(const char* text);
void rtgui_label_destroy(rtgui_label_t* label); void rtgui_label_destroy(rtgui_label_t* label);
......
...@@ -31,8 +31,9 @@ struct rtgui_list_item ...@@ -31,8 +31,9 @@ struct rtgui_list_item
void *parameter; void *parameter;
}; };
DECLARE_CLASS_TYPE(listview);
/** Gets the type of a list view */ /** Gets the type of a list view */
#define RTGUI_LIST_VIEW_TYPE (rtgui_list_view_type_get()) #define RTGUI_LIST_VIEW_TYPE (RTGUI_TYPE(listview))
/** Casts the object to a filelist */ /** Casts the object to a filelist */
#define RTGUI_LIST_VIEW(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_LIST_VIEW_TYPE, rtgui_list_view_t)) #define RTGUI_LIST_VIEW(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_LIST_VIEW_TYPE, rtgui_list_view_t))
/** Checks if the object is a filelist view */ /** Checks if the object is a filelist view */
......
...@@ -26,8 +26,9 @@ struct rtgui_listbox_item ...@@ -26,8 +26,9 @@ struct rtgui_listbox_item
rtgui_image_t *image; rtgui_image_t *image;
}; };
DECLARE_CLASS_TYPE(listbox);
/** Gets the type of a list box */ /** Gets the type of a list box */
#define RTGUI_LISTBOX_TYPE (rtgui_listbox_type_get()) #define RTGUI_LISTBOX_TYPE (RTGUI_TYPE(listbox))
/** Casts the object to a filelist */ /** Casts the object to a filelist */
#define RTGUI_LISTBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_LISTBOX_TYPE, rtgui_listbox_t)) #define RTGUI_LISTBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_LISTBOX_TYPE, rtgui_listbox_t))
/** Checks if the object is a filelist box */ /** Checks if the object is a filelist box */
...@@ -54,8 +55,6 @@ struct rtgui_listbox ...@@ -54,8 +55,6 @@ struct rtgui_listbox
typedef struct rtgui_listbox rtgui_listbox_t; typedef struct rtgui_listbox rtgui_listbox_t;
typedef void (*rtgui_onitem_func_t)(struct rtgui_widget* widget, rtgui_event_t *event); typedef void (*rtgui_onitem_func_t)(struct rtgui_widget* widget, rtgui_event_t *event);
rtgui_type_t *rtgui_listbox_type_get(void);
rtgui_listbox_t* rtgui_listbox_create(const struct rtgui_listbox_item* items, rt_uint16_t count, rtgui_listbox_t* rtgui_listbox_create(const struct rtgui_listbox_item* items, rt_uint16_t count,
rtgui_rect_t *rect); rtgui_rect_t *rect);
void rtgui_listbox_destroy(rtgui_listbox_t* box); void rtgui_listbox_destroy(rtgui_listbox_t* box);
......
...@@ -20,8 +20,9 @@ ...@@ -20,8 +20,9 @@
#include <rtgui/rtgui_system.h> #include <rtgui/rtgui_system.h>
#include <rtgui/widgets/widget.h> #include <rtgui/widgets/widget.h>
DECLARE_CLASS_TYPE(listctrl);
/** Gets the type of a listctrl */ /** Gets the type of a listctrl */
#define RTGUI_LISTCTRL_TYPE (rtgui_listctrl_type_get()) #define RTGUI_LISTCTRL_TYPE (RTGUI_TYPE(listctrl))
/** Casts the object to a listctrl */ /** Casts the object to a listctrl */
#define RTGUI_LISTCTRL(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_LISTCTRL_TYPE, rtgui_listctrl_t)) #define RTGUI_LISTCTRL(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_LISTCTRL_TYPE, rtgui_listctrl_t))
/** Checks if the object is a listctrl */ /** Checks if the object is a listctrl */
......
...@@ -33,8 +33,9 @@ struct rtgui_menu_item ...@@ -33,8 +33,9 @@ struct rtgui_menu_item
}; };
typedef struct rtgui_menu_item rtgui_menu_item_t; typedef struct rtgui_menu_item rtgui_menu_item_t;
DECLARE_CLASS_TYPE(menu);
/** Gets the type of a menu */ /** Gets the type of a menu */
#define RTGUI_MENU_TYPE (rtgui_menu_type_get()) #define RTGUI_MENU_TYPE (RTGUI_TYPE(menu))
/** Casts the object to an rtgui_menu */ /** Casts the object to an rtgui_menu */
#define RTGUI_MENU(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_MENU_TYPE, rtgui_menu_t)) #define RTGUI_MENU(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_MENU_TYPE, rtgui_menu_t))
/** Checks if the object is an rtgui_menu */ /** Checks if the object is an rtgui_menu */
......
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
#include <rtgui/rtgui.h> #include <rtgui/rtgui.h>
#include <rtgui/widgets/container.h> #include <rtgui/widgets/container.h>
DECLARE_CLASS_TYPE(notebook);
/** Gets the type of a notebook */ /** Gets the type of a notebook */
#define RTGUI_NOTEBOOK_TYPE (rtgui_notebook_type_get()) #define RTGUI_NOTEBOOK_TYPE (RTGUI_TYPE(notebook))
/** Casts the object to a notebook control */ /** Casts the object to a notebook control */
#define RTGUI_NOTEBOOK(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_NOTEBOOK_TYPE, rtgui_notebook_t)) #define RTGUI_NOTEBOOK(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_NOTEBOOK_TYPE, rtgui_notebook_t))
/** Checks if the object is a notebook control */ /** Checks if the object is a notebook control */
......
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
#include <rtgui/rtgui.h> #include <rtgui/rtgui.h>
#include <rtgui/widgets/widget.h> #include <rtgui/widgets/widget.h>
DECLARE_CLASS_TYPE(progressbar);
/** Gets the type of a progressbar */ /** Gets the type of a progressbar */
#define RTGUI_PROGRESSBAR_TYPE (rtgui_progressbar_type_get()) #define RTGUI_PROGRESSBAR_TYPE (RTGUI_TYPE(progressbar))
/** Casts the object to a rtgui_progressbar */ /** Casts the object to a rtgui_progressbar */
#define RTGUI_PROGRESSBAR(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_PROGRESSBAR_TYPE, rtgui_progressbar_t)) #define RTGUI_PROGRESSBAR(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_PROGRESSBAR_TYPE, rtgui_progressbar_t))
/** Checks if the object is a rtgui_progressbar */ /** Checks if the object is a rtgui_progressbar */
...@@ -25,8 +26,6 @@ struct rtgui_progressbar ...@@ -25,8 +26,6 @@ struct rtgui_progressbar
}; };
typedef struct rtgui_progressbar rtgui_progressbar_t; typedef struct rtgui_progressbar rtgui_progressbar_t;
rtgui_type_t *rtgui_progressbar_type_get(void);
struct rtgui_progressbar* rtgui_progressbar_create(int orientation, int range, rtgui_rect_t* r); struct rtgui_progressbar* rtgui_progressbar_create(int orientation, int range, rtgui_rect_t* r);
void rtgui_progressbar_destroy(struct rtgui_progressbar* p_bar); void rtgui_progressbar_destroy(struct rtgui_progressbar* p_bar);
......
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
#include <rtgui/rtgui.h> #include <rtgui/rtgui.h>
#include <rtgui/widgets/widget.h> #include <rtgui/widgets/widget.h>
DECLARE_CLASS_TYPE(radiobox);
/** Gets the type of a radiobox */ /** Gets the type of a radiobox */
#define RTGUI_RADIOBOX_TYPE (rtgui_radiobox_type_get()) #define RTGUI_RADIOBOX_TYPE (RTGUI_TYPE(radiobox))
/** Casts the object to an rtgui_radiobox */ /** Casts the object to an rtgui_radiobox */
#define RTGUI_RADIOBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_RADIOBOX_TYPE, rtgui_radiobox_t)) #define RTGUI_RADIOBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_RADIOBOX_TYPE, rtgui_radiobox_t))
/** Checks if the object is an rtgui_radiobox */ /** Checks if the object is an rtgui_radiobox */
...@@ -30,8 +31,6 @@ struct rtgui_radiobox ...@@ -30,8 +31,6 @@ struct rtgui_radiobox
}; };
typedef struct rtgui_radiobox rtgui_radiobox_t; typedef struct rtgui_radiobox rtgui_radiobox_t;
rtgui_type_t *rtgui_radiobox_type_get(void);
struct rtgui_radiobox* rtgui_radiobox_create(const char* label, int orient, char** radio_items, int number); struct rtgui_radiobox* rtgui_radiobox_create(const char* label, int orient, char** radio_items, int number);
void rtgui_radiobox_destroy(struct rtgui_radiobox* radiobox); void rtgui_radiobox_destroy(struct rtgui_radiobox* radiobox);
......
...@@ -21,8 +21,9 @@ ...@@ -21,8 +21,9 @@
extern "C" { extern "C" {
#endif #endif
DECLARE_CLASS_TYPE(scrollbar);
/** Gets the type of a scrollbar */ /** Gets the type of a scrollbar */
#define RTGUI_SCROLLBAR_TYPE (rtgui_scrollbar_type_get()) #define RTGUI_SCROLLBAR_TYPE (RTGUI_TYPE(scrollbar))
/** Casts the object to an rtgui_scrollbar */ /** Casts the object to an rtgui_scrollbar */
#define RTGUI_SCROLLBAR(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_SCROLLBAR_TYPE, rtgui_scrollbar_t)) #define RTGUI_SCROLLBAR(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_SCROLLBAR_TYPE, rtgui_scrollbar_t))
/** Checks if the object is an rtgui_scrollbar */ /** Checks if the object is an rtgui_scrollbar */
...@@ -65,8 +66,6 @@ struct rtgui_scrollbar ...@@ -65,8 +66,6 @@ struct rtgui_scrollbar
}; };
typedef struct rtgui_scrollbar rtgui_scrollbar_t; typedef struct rtgui_scrollbar rtgui_scrollbar_t;
rtgui_type_t *rtgui_scrollbar_type_get(void);
struct rtgui_scrollbar* rtgui_scrollbar_create(int orient, rtgui_rect_t* r); struct rtgui_scrollbar* rtgui_scrollbar_create(int orient, rtgui_rect_t* r);
void rtgui_scrollbar_destroy(struct rtgui_scrollbar* bar); void rtgui_scrollbar_destroy(struct rtgui_scrollbar* bar);
......
...@@ -17,8 +17,9 @@ ...@@ -17,8 +17,9 @@
#include <rtgui/rtgui.h> #include <rtgui/rtgui.h>
#include <rtgui/widgets/widget.h> #include <rtgui/widgets/widget.h>
DECLARE_CLASS_TYPE(slider);
/** Gets the type of a slider */ /** Gets the type of a slider */
#define RTGUI_SLIDER_TYPE (rtgui_slider_type_get()) #define RTGUI_SLIDER_TYPE (RTGUI_TYPE(slider))
/** Casts the object to an rtgui_slider */ /** Casts the object to an rtgui_slider */
#define RTGUI_SLIDER(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_SLIDER_TYPE, rtgui_slider_t)) #define RTGUI_SLIDER(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_SLIDER_TYPE, rtgui_slider_t))
/** Checks if the object is an rtgui_slider */ /** Checks if the object is an rtgui_slider */
...@@ -38,8 +39,6 @@ struct rtgui_slider ...@@ -38,8 +39,6 @@ struct rtgui_slider
}; };
typedef struct rtgui_slider rtgui_slider_t; typedef struct rtgui_slider rtgui_slider_t;
rtgui_type_t *rtgui_slider_type_get(void);
struct rtgui_slider* rtgui_slider_create(rt_size_t min, rt_size_t max, int orient); struct rtgui_slider* rtgui_slider_create(rt_size_t min, rt_size_t max, int orient);
void rtgui_slider_destroy(struct rtgui_slider* slider); void rtgui_slider_destroy(struct rtgui_slider* slider);
......
...@@ -8,8 +8,9 @@ ...@@ -8,8 +8,9 @@
* the static line widget * the static line widget
*/ */
DECLARE_CLASS_TYPE(staticline);
/** Gets the type of a staticline */ /** Gets the type of a staticline */
#define RTGUI_STATICLINE_TYPE (rtgui_staticline_type_get()) #define RTGUI_STATICLINE_TYPE (RTGUI_TYPE(staticline))
/** Casts the object to an rtgui_staticline */ /** Casts the object to an rtgui_staticline */
#define RTGUI_STATICLINE(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_STATICLINE_TYPE, rtgui_staticline_t)) #define RTGUI_STATICLINE(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_STATICLINE_TYPE, rtgui_staticline_t))
/** Checks if the object is an rtgui_staticline */ /** Checks if the object is an rtgui_staticline */
......
...@@ -17,8 +17,9 @@ ...@@ -17,8 +17,9 @@
#include <rtgui/rtgui.h> #include <rtgui/rtgui.h>
#include <rtgui/widgets/widget.h> #include <rtgui/widgets/widget.h>
DECLARE_CLASS_TYPE(textbox);
/** Gets the type of a textbox */ /** Gets the type of a textbox */
#define RTGUI_TEXTBOX_TYPE (rtgui_textbox_type_get()) #define RTGUI_TEXTBOX_TYPE (RTGUI_TYPE(textbox))
/** Casts the object to a rtgui_textbox */ /** Casts the object to a rtgui_textbox */
#define RTGUI_TEXTBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_TEXTBOX_TYPE, rtgui_textbox_t)) #define RTGUI_TEXTBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_TEXTBOX_TYPE, rtgui_textbox_t))
/** Checks if the object is a rtgui_textbox */ /** Checks if the object is a rtgui_textbox */
...@@ -61,8 +62,6 @@ struct rtgui_textbox ...@@ -61,8 +62,6 @@ struct rtgui_textbox
}; };
typedef struct rtgui_textbox rtgui_textbox_t; typedef struct rtgui_textbox rtgui_textbox_t;
rtgui_type_t *rtgui_textbox_type_get(void);
struct rtgui_textbox* rtgui_textbox_create(const char* text, rt_uint8_t flag); struct rtgui_textbox* rtgui_textbox_create(const char* text, rt_uint8_t flag);
void rtgui_textbox_destroy(struct rtgui_textbox* box); void rtgui_textbox_destroy(struct rtgui_textbox* box);
......
...@@ -16,8 +16,9 @@ ...@@ -16,8 +16,9 @@
#include <rtgui/widgets/toplevel.h> #include <rtgui/widgets/toplevel.h>
/** Gets the type of a top win */ DECLARE_CLASS_TYPE(wintitle);
#define RTGUI_WINTITLE_TYPE (rtgui_wintitle_type_get()) /** Gets the type of a title */
#define RTGUI_WINTITLE_TYPE (RTGUI_TYPE(wintitle))
/** Casts the object to an rtgui_wintitle */ /** Casts the object to an rtgui_wintitle */
#define RTGUI_WINTITLE(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_WINTITLE_TYPE, rtgui_wintitle_t)) #define RTGUI_WINTITLE(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_WINTITLE_TYPE, rtgui_wintitle_t))
/** Checks if the object is an rtgui_wintitle */ /** Checks if the object is an rtgui_wintitle */
...@@ -32,8 +33,6 @@ struct rtgui_wintitle ...@@ -32,8 +33,6 @@ struct rtgui_wintitle
}; };
typedef struct rtgui_wintitle rtgui_wintitle_t; typedef struct rtgui_wintitle rtgui_wintitle_t;
rtgui_type_t* rtgui_wintitle_type_get(void);
rtgui_wintitle_t* rtgui_wintitle_create(const char* title); rtgui_wintitle_t* rtgui_wintitle_create(const char* title);
void rtgui_wintitle_destroy(rtgui_wintitle_t* wintitle); void rtgui_wintitle_destroy(rtgui_wintitle_t* wintitle);
......
...@@ -16,8 +16,9 @@ ...@@ -16,8 +16,9 @@
#include <rtgui/widgets/container.h> #include <rtgui/widgets/container.h>
DECLARE_CLASS_TYPE(toplevel);
/** Gets the type of a toplevel */ /** Gets the type of a toplevel */
#define RTGUI_TOPLEVEL_TYPE (rtgui_toplevel_type_get()) #define RTGUI_TOPLEVEL_TYPE (RTGUI_TYPE(toplevel))
/** Casts the object to an rtgui_toplevel */ /** Casts the object to an rtgui_toplevel */
#define RTGUI_TOPLEVEL(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_TOPLEVEL_TYPE, rtgui_toplevel_t)) #define RTGUI_TOPLEVEL(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_TOPLEVEL_TYPE, rtgui_toplevel_t))
/** Checks if the object is an rtgui_toplevel */ /** Checks if the object is an rtgui_toplevel */
...@@ -40,10 +41,7 @@ struct rtgui_toplevel ...@@ -40,10 +41,7 @@ struct rtgui_toplevel
}; };
typedef struct rtgui_toplevel rtgui_toplevel_t; typedef struct rtgui_toplevel rtgui_toplevel_t;
rtgui_type_t *rtgui_toplevel_type_get(void);
rt_bool_t rtgui_toplevel_event_handler(rtgui_widget_t* widget, rtgui_event_t* event); rt_bool_t rtgui_toplevel_event_handler(rtgui_widget_t* widget, rtgui_event_t* event);
void rtgui_toplevel_update_clip(rtgui_toplevel_t* top); void rtgui_toplevel_update_clip(rtgui_toplevel_t* top);
#endif #endif
...@@ -21,8 +21,9 @@ ...@@ -21,8 +21,9 @@
extern "C" { extern "C" {
#endif #endif
DECLARE_CLASS_TYPE(view);
/** Gets the type of a view */ /** Gets the type of a view */
#define RTGUI_VIEW_TYPE (rtgui_view_type_get()) #define RTGUI_VIEW_TYPE (RTGUI_TYPE(view))
/** Casts the object to an rtgui_view */ /** Casts the object to an rtgui_view */
#define RTGUI_VIEW(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_VIEW_TYPE, rtgui_view_t)) #define RTGUI_VIEW(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_VIEW_TYPE, rtgui_view_t))
/** Checks if the object is an rtgui_view */ /** Checks if the object is an rtgui_view */
...@@ -42,8 +43,6 @@ struct rtgui_view ...@@ -42,8 +43,6 @@ struct rtgui_view
}; };
typedef struct rtgui_view rtgui_view_t; typedef struct rtgui_view rtgui_view_t;
rtgui_type_t *rtgui_view_type_get(void);
rtgui_view_t* rtgui_view_create(const char* title); rtgui_view_t* rtgui_view_create(const char* title);
void rtgui_view_destroy(rtgui_view_t* view); void rtgui_view_destroy(rtgui_view_t* view);
......
...@@ -59,8 +59,10 @@ extern "C" { ...@@ -59,8 +59,10 @@ extern "C" {
#define RTGUI_WIDGET_FONT(w) ((w)->gc.font) #define RTGUI_WIDGET_FONT(w) ((w)->gc.font)
#define RTGUI_WIDGET_FLAG(w) ((w)->flag) #define RTGUI_WIDGET_FLAG(w) ((w)->flag)
DECLARE_CLASS_TYPE(widget);
/** Gets the type of a widget */ /** Gets the type of a widget */
#define RTGUI_WIDGET_TYPE (rtgui_widget_type_get()) #define RTGUI_WIDGET_TYPE (RTGUI_TYPE(widget))
/** Casts the object to a rtgui_widget */ /** Casts the object to a rtgui_widget */
#define RTGUI_WIDGET(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_WIDGET_TYPE, rtgui_widget_t)) #define RTGUI_WIDGET(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_WIDGET_TYPE, rtgui_widget_t))
/** Check if the object is a rtgui_widget */ /** Check if the object is a rtgui_widget */
......
...@@ -21,8 +21,9 @@ ...@@ -21,8 +21,9 @@
#include <rtgui/widgets/toplevel.h> #include <rtgui/widgets/toplevel.h>
#include <rtgui/widgets/box.h> #include <rtgui/widgets/box.h>
DECLARE_CLASS_TYPE(win);
/** Gets the type of a win */ /** Gets the type of a win */
#define RTGUI_WIN_TYPE (rtgui_win_type_get()) #define RTGUI_WIN_TYPE (RTGUI_TYPE(win))
/** Casts the object to an rtgui_win */ /** Casts the object to an rtgui_win */
#define RTGUI_WIN(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_WIN_TYPE, rtgui_win_t)) #define RTGUI_WIN(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_WIN_TYPE, rtgui_win_t))
/** Checks if the object is an rtgui_win */ /** Checks if the object is an rtgui_win */
...@@ -72,8 +73,6 @@ struct rtgui_win ...@@ -72,8 +73,6 @@ struct rtgui_win
rt_uint32_t user_data; rt_uint32_t user_data;
}; };
rtgui_type_t *rtgui_win_type_get(void);
rtgui_win_t* rtgui_win_create(rtgui_toplevel_t* parent_toplevel, const char* title, rtgui_win_t* rtgui_win_create(rtgui_toplevel_t* parent_toplevel, const char* title,
rtgui_rect_t *rect, rt_uint8_t flag); rtgui_rect_t *rect, rt_uint8_t flag);
void rtgui_win_destroy(rtgui_win_t* win); void rtgui_win_destroy(rtgui_win_t* win);
......
...@@ -35,8 +35,10 @@ ...@@ -35,8 +35,10 @@
#define RTGUI_WORKBENCH_IS_MODAL_MODE(w) ((w)->flag & RTGUI_WORKBENCH_FLAG_MODAL_MODE) #define RTGUI_WORKBENCH_IS_MODAL_MODE(w) ((w)->flag & RTGUI_WORKBENCH_FLAG_MODAL_MODE)
DECLARE_CLASS_TYPE(workbench);
/** Gets the type of a workbench */ /** Gets the type of a workbench */
#define RTGUI_WORKBENCH_TYPE (rtgui_workbench_type_get()) #define RTGUI_WORKBENCH_TYPE (RTGUI_TYPE(workbench))
/** Casts the object to an rtgui_workbench */ /** Casts the object to an rtgui_workbench */
#define RTGUI_WORKBENCH(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_WORKBENCH_TYPE, rtgui_workbench_t)) #define RTGUI_WORKBENCH(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_WORKBENCH_TYPE, rtgui_workbench_t))
/** Checks if the object is an rtgui_workbench */ /** Checks if the object is an rtgui_workbench */
...@@ -64,7 +66,7 @@ rtgui_type_t* rtgui_workbench_type_get(void); ...@@ -64,7 +66,7 @@ rtgui_type_t* rtgui_workbench_type_get(void);
rtgui_workbench_t *rtgui_workbench_create(const char* panel_name, const unsigned char* title); rtgui_workbench_t *rtgui_workbench_create(const char* panel_name, const unsigned char* title);
void rtgui_workbench_destroy(rtgui_workbench_t* workbench); void rtgui_workbench_destroy(rtgui_workbench_t* workbench);
void rtgui_workbench_close(rtgui_workbench_t* workbench); void rtgui_workbench_close(rtgui_workbench_t* workbench);
rt_bool_t rtgui_workbench_event_handler(rtgui_widget_t* widget, rtgui_event_t* event); rt_bool_t rtgui_workbench_event_handler(rtgui_widget_t* widget, rtgui_event_t* event);
......
...@@ -18,12 +18,7 @@ ...@@ -18,12 +18,7 @@
#include <rtgui/rtgui_system.h> #include <rtgui/rtgui_system.h>
/* the global parameter */ /* the global parameter */
struct rtgui_list_node _rtgui_panel_list; struct rtgui_list_node _rtgui_panel_list = {RT_NULL};
void rtgui_panel_init()
{
rtgui_list_init(&_rtgui_panel_list);
}
void rtgui_panel_register(char* name, rtgui_rect_t* extent) void rtgui_panel_register(char* name, rtgui_rect_t* extent)
{ {
......
...@@ -268,154 +268,66 @@ void rtgui_topwin_deactivate_win(struct rtgui_topwin* win) ...@@ -268,154 +268,66 @@ void rtgui_topwin_deactivate_win(struct rtgui_topwin* win)
} }
/* raise window to front */ /* raise window to front */
#ifdef RTGUI_USING_SMALL_SIZE
void rtgui_topwin_raise(struct rtgui_win* wid, rt_thread_t sender) void rtgui_topwin_raise(struct rtgui_win* wid, rt_thread_t sender)
{ {
struct rtgui_topwin* topwin; struct rtgui_topwin* topwin;
struct rtgui_list_node* node;
struct rtgui_event_clip_info eclip;
/* find the topwin node */ RTGUI_EVENT_CLIP_INFO_INIT(&eclip);
topwin = rtgui_topwin_search_in_list(wid, &_rtgui_topwin_show_list); eclip.wid = RT_NULL;
if (topwin)
{
rt_int32_t count;
struct rtgui_list_node* node;
struct rtgui_event_clip_info eclip;
RTGUI_EVENT_CLIP_INFO_INIT(&eclip);
eclip.wid = RT_NULL;
/* the window is already placed in front */
if (&(topwin->list) == _rtgui_topwin_show_list.next)
{
rtgui_server_focus_topwin = RT_NULL;
rtgui_topwin_activate_win(topwin);
return ;
}
/* remove node from list */
rtgui_list_remove(&_rtgui_topwin_show_list, &(topwin->list));
/* add to front */
rtgui_list_insert(&_rtgui_topwin_show_list, &(topwin->list));
/* send clip info event */
count = 0;
for (node = _rtgui_topwin_show_list.next; node != RT_NULL; node = node->next)
{
struct rtgui_topwin* wnd = rtgui_list_entry(node, struct rtgui_topwin, list);
eclip.num_rect = count;
eclip.wid = wnd->wid;
count ++;
/* send to destination window */
rtgui_thread_send(wnd->tid, &(eclip.parent), sizeof(struct rtgui_event_clip_info));
/* reset clip info in title */
if (wnd->title != RT_NULL)
{
rtgui_toplevel_update_clip(RTGUI_TOPLEVEL(wnd->title));
rtgui_region_subtract_rect(&(RTGUI_WIDGET(wnd->title)->clip),
&(RTGUI_WIDGET(wnd->title)->clip),
&(wnd->extent));
}
}
/* the window is already placed in front */
if (&(topwin->list) == _rtgui_topwin_show_list.next)
{
rtgui_server_focus_topwin = RT_NULL;
rtgui_topwin_activate_win(topwin); rtgui_topwin_activate_win(topwin);
return ;
} }
}
#else
void rtgui_topwin_raise(struct rtgui_win* wid, rt_thread_t sender)
{
struct rtgui_topwin* topwin;
// rt_sem_take(&_rtgui_topwin_lock, RT_WAITING_FOREVER);
/* find the topwin node */ /* find the topwin node */
topwin = rtgui_topwin_search_in_list(wid, &_rtgui_topwin_show_list); for (node = _rtgui_topwin_show_list.next; node->next != RT_NULL; node = node->next)
if (topwin)
{ {
rt_int32_t count; topwin = rtgui_list_entry(node->next, struct rtgui_topwin, list);
struct rtgui_list_node* node; if (topwin->wid == wid)
struct rtgui_event_clip_info* eclip;
struct rtgui_rect* rect;
/* the window is already placed in front */
if (&(topwin->list) == _rtgui_topwin_show_list.next)
{
rtgui_server_focus_topwin = RT_NULL;
rtgui_topwin_activate_win(topwin);
return ;
}
/* update clip info */
count = 0;
node = _rtgui_topwin_show_list.next;
while (node != &(topwin->list))
{
count ++;
node = node->next;
}
eclip = (struct rtgui_event_clip_info*)rtgui_malloc(sizeof(struct rtgui_event_clip_info)
+ (count + 1)* sizeof(struct rtgui_rect));
/* reset clip info to top window */
RTGUI_EVENT_CLIP_INFO_INIT(eclip);
eclip->num_rect = 0;
eclip->wid = topwin->wid;
/* send to destination window */
rtgui_thread_send(topwin->tid, &(eclip->parent), sizeof(struct rtgui_event_clip_info));
/* reset clip info in title */
if (topwin->title != RT_NULL)
{
rtgui_toplevel_update_clip(RTGUI_TOPLEVEL(topwin->title));
rtgui_region_subtract_rect(&(RTGUI_WIDGET(topwin->title)->clip),
&(RTGUI_WIDGET(topwin->title)->clip),
&(topwin->extent));
}
rect = RTGUI_EVENT_GET_RECT(eclip, 0);
*rect = (topwin->title != RT_NULL)? RTGUI_WIDGET(topwin->title)->extent : topwin->extent;
count = 1;
for (node = _rtgui_topwin_show_list.next;
node != &(topwin->list);
node = node->next)
{ {
struct rtgui_topwin* wnd; /* found target */
wnd = rtgui_list_entry(node, struct rtgui_topwin, list);
struct rtgui_list_node* n;
eclip->num_rect = count; n = node->next;
eclip->wid = wnd->wid; /* remove node */
node->next = node->next->next;
/* send to destination window */ /* insert node to the header */
rtgui_thread_send(wnd->tid, &(eclip->parent), n->next = _rtgui_topwin_show_list.next;
sizeof(struct rtgui_event_clip_info) + count * sizeof(struct rtgui_rect)); _rtgui_topwin_show_list.next = n;
/* reset clip info in title */ /* send clip update to each upper window */
if (wnd->title != RT_NULL) for (n = _rtgui_topwin_show_list.next; n != node->next; n = n->next)
{ {
rtgui_toplevel_update_clip(RTGUI_TOPLEVEL(wnd->title)); struct rtgui_topwin* wnd = rtgui_list_entry(n, struct rtgui_topwin, list);
rtgui_region_subtract_rect(&(RTGUI_WIDGET(wnd->title)->clip), eclip.wid = wnd->wid;
&(RTGUI_WIDGET(wnd->title)->clip),
&(wnd->extent)); /* send to destination window */
rtgui_thread_send(wnd->tid, &(eclip.parent), sizeof(struct rtgui_event_clip_info));
/* reset clip info in title */
if (wnd->title != RT_NULL)
{
rtgui_toplevel_update_clip(RTGUI_TOPLEVEL(wnd->title));
rtgui_region_subtract_rect(&(RTGUI_WIDGET(wnd->title)->clip),
&(RTGUI_WIDGET(wnd->title)->clip),
&(wnd->extent));
}
} }
rect = RTGUI_EVENT_GET_RECT(eclip, count++); /* active window */
*rect = (wnd->title != RT_NULL)? RTGUI_WIDGET(wnd->title)->extent : wnd->extent; rtgui_topwin_activate_win(topwin);
break;
} }
/* release clip info event */
rtgui_free(eclip);
/* remove node from list */
rtgui_list_remove(&_rtgui_topwin_show_list, &(topwin->list));
/* add to front */
rtgui_list_insert(&_rtgui_topwin_show_list, &(topwin->list));
rtgui_topwin_activate_win(topwin);
} }
// rt_sem_release(&_rtgui_topwin_lock);
} }
#endif
/* show a window */ /* show a window */
void rtgui_topwin_show(struct rtgui_event_win* event) void rtgui_topwin_show(struct rtgui_event_win* event)
......
...@@ -32,18 +32,11 @@ static void _rtgui_about_view_constructor(struct rtgui_about_view *view) ...@@ -32,18 +32,11 @@ static void _rtgui_about_view_constructor(struct rtgui_about_view *view)
RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(view)) = RTGUI_ALIGN_CENTER_VERTICAL; RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(view)) = RTGUI_ALIGN_CENTER_VERTICAL;
} }
rtgui_type_t *rtgui_about_view_type_get(void) DEFINE_CLASS_TYPE(aboutview, "aboutview",
{ RTGUI_VIEW_TYPE,
static rtgui_type_t *list_view_type = RT_NULL; _rtgui_about_view_constructor,
RT_NULL,
if (!list_view_type) sizeof(struct rtgui_about_view));
{
list_view_type = rtgui_type_create("aboutview", RTGUI_VIEW_TYPE,
sizeof(rtgui_about_view_t), RTGUI_CONSTRUCTOR(_rtgui_about_view_constructor), RT_NULL);
}
return list_view_type;
}
void rtgui_about_view_ondraw(struct rtgui_about_view* view) void rtgui_about_view_ondraw(struct rtgui_about_view* view)
{ {
......
...@@ -28,18 +28,11 @@ static void _rtgui_box_constructor(rtgui_box_t *box) ...@@ -28,18 +28,11 @@ static void _rtgui_box_constructor(rtgui_box_t *box)
box->border_size = RTGUI_BORDER_DEFAULT_WIDTH; box->border_size = RTGUI_BORDER_DEFAULT_WIDTH;
} }
rtgui_type_t *rtgui_box_type_get(void) DEFINE_CLASS_TYPE(box, "box",
{ RTGUI_CONTAINER_TYPE,
static rtgui_type_t *box_type = RT_NULL; _rtgui_box_constructor,
RT_NULL,
if (!box_type) sizeof(struct rtgui_box));
{
box_type = rtgui_type_create("box", RTGUI_CONTAINER_TYPE,
sizeof(rtgui_box_t), RTGUI_CONSTRUCTOR(_rtgui_box_constructor), RT_NULL);
}
return box_type;
}
rt_bool_t rtgui_box_event_handler(rtgui_widget_t* widget, rtgui_event_t* event) rt_bool_t rtgui_box_event_handler(rtgui_widget_t* widget, rtgui_event_t* event)
{ {
......
...@@ -50,20 +50,11 @@ static void _rtgui_button_destructor(rtgui_button_t *button) ...@@ -50,20 +50,11 @@ static void _rtgui_button_destructor(rtgui_button_t *button)
} }
} }
rtgui_type_t *rtgui_button_type_get(void) DEFINE_CLASS_TYPE(button, "button",
{ RTGUI_LABEL_TYPE,
static rtgui_type_t *button_type = RT_NULL; _rtgui_button_constructor,
_rtgui_button_destructor,
if (!button_type) sizeof(struct rtgui_button));
{
button_type = rtgui_type_create("button", RTGUI_LABEL_TYPE,
sizeof(rtgui_button_t),
RTGUI_CONSTRUCTOR(_rtgui_button_constructor),
RTGUI_DESTRUCTOR(_rtgui_button_destructor));
}
return button_type;
}
rt_bool_t rtgui_button_event_handler(struct rtgui_widget* widget, struct rtgui_event* event) rt_bool_t rtgui_button_event_handler(struct rtgui_widget* widget, struct rtgui_event* event)
{ {
......
...@@ -16,18 +16,11 @@ static void _rtgui_checkbox_constructor(rtgui_checkbox_t *box) ...@@ -16,18 +16,11 @@ static void _rtgui_checkbox_constructor(rtgui_checkbox_t *box)
RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(box)) = RTGUI_ALIGN_LEFT | RTGUI_ALIGN_CENTER_VERTICAL; RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(box)) = RTGUI_ALIGN_LEFT | RTGUI_ALIGN_CENTER_VERTICAL;
} }
rtgui_type_t *rtgui_checkbox_type_get(void) DEFINE_CLASS_TYPE(checkbox, "checkbox",
{ RTGUI_LABEL_TYPE,
static rtgui_type_t *checkbox_type = RT_NULL; _rtgui_checkbox_constructor,
RT_NULL,
if (!checkbox_type) sizeof(struct rtgui_checkbox));
{
checkbox_type = rtgui_type_create("checkbox", RTGUI_LABEL_TYPE,
sizeof(rtgui_checkbox_t), RTGUI_CONSTRUCTOR(_rtgui_checkbox_constructor), RT_NULL);
}
return checkbox_type;
}
void rtgui_checkbox_set_onbutton(rtgui_checkbox_t* checkbox, rtgui_onbutton_func_t func) void rtgui_checkbox_set_onbutton(rtgui_checkbox_t* checkbox, rtgui_onbutton_func_t func)
{ {
......
...@@ -56,20 +56,11 @@ rt_bool_t rtgui_combobox_pdwin_ondeactive(struct rtgui_widget* widget, struct rt ...@@ -56,20 +56,11 @@ rt_bool_t rtgui_combobox_pdwin_ondeactive(struct rtgui_widget* widget, struct rt
return RT_TRUE; return RT_TRUE;
} }
rtgui_type_t *rtgui_combobox_type_get(void) DEFINE_CLASS_TYPE(combobox, "combobox",
{ RTGUI_WIDGET_TYPE,
static rtgui_type_t *combobox_type = RT_NULL; _rtgui_combobox_constructor,
_rtgui_combobox_destructor,
if (!combobox_type) sizeof(struct rtgui_combobox));
{
combobox_type = rtgui_type_create("combobox", RTGUI_WIDGET_TYPE,
sizeof(rtgui_combobox_t),
RTGUI_CONSTRUCTOR(_rtgui_combobox_constructor),
RTGUI_DESTRUCTOR(_rtgui_combobox_destructor));
}
return combobox_type;
}
rtgui_combobox_t *rtgui_combobox_create(struct rtgui_listbox_item* items, rt_uint16_t count, struct rtgui_rect* rect) rtgui_combobox_t *rtgui_combobox_create(struct rtgui_listbox_item* items, rt_uint16_t count, struct rtgui_rect* rect)
{ {
......
...@@ -49,20 +49,11 @@ static void _rtgui_container_update_toplevel(rtgui_container_t* container) ...@@ -49,20 +49,11 @@ static void _rtgui_container_update_toplevel(rtgui_container_t* container)
} }
} }
rtgui_type_t *rtgui_container_type_get(void) DEFINE_CLASS_TYPE(container, "container",
{ RTGUI_WIDGET_TYPE,
static rtgui_type_t *container_type = RT_NULL; _rtgui_container_constructor,
_rtgui_container_destructor,
if (!container_type) sizeof(struct rtgui_container));
{
container_type = rtgui_type_create("container", RTGUI_WIDGET_TYPE,
sizeof(rtgui_container_t),
RTGUI_CONSTRUCTOR(_rtgui_container_constructor),
RTGUI_DESTRUCTOR(_rtgui_container_destructor));
}
return container_type;
}
rt_bool_t rtgui_container_dispatch_event(rtgui_container_t *container, rtgui_event_t* event) rt_bool_t rtgui_container_dispatch_event(rtgui_container_t *container, rtgui_event_t* event)
{ {
......
...@@ -356,20 +356,11 @@ static void _rtgui_filelist_view_destructor(struct rtgui_filelist_view *view) ...@@ -356,20 +356,11 @@ static void _rtgui_filelist_view_destructor(struct rtgui_filelist_view *view)
rtgui_image_destroy(folder_image); rtgui_image_destroy(folder_image);
} }
rtgui_type_t *rtgui_filelist_view_type_get(void) DEFINE_CLASS_TYPE(filelist, "filelist",
{ RTGUI_VIEW_TYPE,
static rtgui_type_t *filelist_view_type = RT_NULL; _rtgui_filelist_view_constructor,
_rtgui_filelist_view_destructor,
if (!filelist_view_type) sizeof(struct rtgui_filelist_view));
{
filelist_view_type = rtgui_type_create("flview", RTGUI_VIEW_TYPE,
sizeof(rtgui_filelist_view_t),
RTGUI_CONSTRUCTOR(_rtgui_filelist_view_constructor),
RTGUI_DESTRUCTOR(_rtgui_filelist_view_destructor));
}
return filelist_view_type;
}
void rtgui_filelist_view_ondraw(struct rtgui_filelist_view* view) void rtgui_filelist_view_ondraw(struct rtgui_filelist_view* view)
{ {
......
...@@ -40,19 +40,11 @@ static void _rtgui_iconbox_destructor(rtgui_iconbox_t *iconbox) ...@@ -40,19 +40,11 @@ static void _rtgui_iconbox_destructor(rtgui_iconbox_t *iconbox)
iconbox->text = RT_NULL; iconbox->text = RT_NULL;
} }
rtgui_type_t *rtgui_iconbox_type_get(void) DEFINE_CLASS_TYPE(iconbox, "iconbox",
{ RTGUI_WIDGET_TYPE,
static rtgui_type_t *iconbox_type = RT_NULL; _rtgui_iconbox_constructor,
_rtgui_iconbox_destructor,
if (!iconbox_type) sizeof(struct rtgui_iconbox));
{
iconbox_type = rtgui_type_create("iconbox", RTGUI_WIDGET_TYPE,
sizeof(rtgui_iconbox_t), RTGUI_CONSTRUCTOR(_rtgui_iconbox_constructor),
RTGUI_DESTRUCTOR(_rtgui_iconbox_destructor));
}
return iconbox_type;
}
rt_bool_t rtgui_iconbox_event_handler(struct rtgui_widget* widget, struct rtgui_event* event) rt_bool_t rtgui_iconbox_event_handler(struct rtgui_widget* widget, struct rtgui_event* event)
{ {
......
...@@ -32,20 +32,11 @@ static void _rtgui_label_destructor(rtgui_label_t *label) ...@@ -32,20 +32,11 @@ static void _rtgui_label_destructor(rtgui_label_t *label)
label->text = RT_NULL; label->text = RT_NULL;
} }
rtgui_type_t *rtgui_label_type_get(void) DEFINE_CLASS_TYPE(label, "label",
{ RTGUI_WIDGET_TYPE,
static rtgui_type_t *label_type = RT_NULL; _rtgui_label_constructor,
_rtgui_label_destructor,
if (!label_type) sizeof(struct rtgui_label));
{
label_type = rtgui_type_create("label", RTGUI_WIDGET_TYPE,
sizeof(rtgui_label_t),
RTGUI_CONSTRUCTOR(_rtgui_label_constructor),
RTGUI_DESTRUCTOR(_rtgui_label_destructor));
}
return label_type;
}
rt_bool_t rtgui_label_event_handler(struct rtgui_widget* widget, struct rtgui_event* event) rt_bool_t rtgui_label_event_handler(struct rtgui_widget* widget, struct rtgui_event* event)
{ {
......
...@@ -37,18 +37,11 @@ static void _rtgui_list_view_constructor(struct rtgui_list_view *view) ...@@ -37,18 +37,11 @@ static void _rtgui_list_view_constructor(struct rtgui_list_view *view)
RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(view)) = RTGUI_ALIGN_CENTER_VERTICAL; RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(view)) = RTGUI_ALIGN_CENTER_VERTICAL;
} }
rtgui_type_t *rtgui_list_view_type_get(void) DEFINE_CLASS_TYPE(listview, "listview",
{ RTGUI_VIEW_TYPE,
static rtgui_type_t *list_view_type = RT_NULL; _rtgui_list_view_constructor,
RT_NULL,
if (!list_view_type) sizeof(struct rtgui_list_view));
{
list_view_type = rtgui_type_create("listview", RTGUI_VIEW_TYPE,
sizeof(rtgui_list_view_t), RTGUI_CONSTRUCTOR(_rtgui_list_view_constructor), RT_NULL);
}
return list_view_type;
}
static void rtgui_list_view_onicondraw(struct rtgui_list_view* view, struct rtgui_dc *dc) static void rtgui_list_view_onicondraw(struct rtgui_list_view* view, struct rtgui_dc *dc)
{ {
......
...@@ -33,18 +33,11 @@ static void _rtgui_listbox_constructor(struct rtgui_listbox *box) ...@@ -33,18 +33,11 @@ static void _rtgui_listbox_constructor(struct rtgui_listbox *box)
RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(box)) = RTGUI_ALIGN_CENTER_VERTICAL; RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(box)) = RTGUI_ALIGN_CENTER_VERTICAL;
} }
rtgui_type_t *rtgui_listbox_type_get(void) DEFINE_CLASS_TYPE(listbox, "listbox",
{ RTGUI_WIDGET_TYPE,
static rtgui_type_t *listbox_type = RT_NULL; _rtgui_listbox_constructor,
RT_NULL,
if (!listbox_type) sizeof(struct rtgui_listbox));
{
listbox_type = rtgui_type_create("listbox", RTGUI_WIDGET_TYPE,
sizeof(rtgui_listbox_t), RTGUI_CONSTRUCTOR(_rtgui_listbox_constructor), RT_NULL);
}
return listbox_type;
}
void rtgui_listbox_ondraw(struct rtgui_listbox* box) void rtgui_listbox_ondraw(struct rtgui_listbox* box)
{ {
......
...@@ -34,18 +34,11 @@ static void _rtgui_listctrl_constructor(struct rtgui_listctrl *ctrl) ...@@ -34,18 +34,11 @@ static void _rtgui_listctrl_constructor(struct rtgui_listctrl *ctrl)
RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(ctrl)) = RTGUI_ALIGN_CENTER_VERTICAL; RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(ctrl)) = RTGUI_ALIGN_CENTER_VERTICAL;
} }
rtgui_type_t *rtgui_listctrl_type_get(void) DEFINE_CLASS_TYPE(listctrl, "listctrl",
{ RTGUI_WIDGET_TYPE,
static rtgui_type_t *listctrl_type = RT_NULL; _rtgui_listctrl_constructor,
RT_NULL,
if (!listctrl_type) sizeof(struct rtgui_listctrl));
{
listctrl_type = rtgui_type_create("listctrl", RTGUI_WIDGET_TYPE,
sizeof(rtgui_listctrl_t), RTGUI_CONSTRUCTOR(_rtgui_listctrl_constructor), RT_NULL);
}
return listctrl_type;
}
static void _rtgui_listctrl_get_rect(struct rtgui_listctrl* ctrl, rtgui_rect_t* rect) static void _rtgui_listctrl_get_rect(struct rtgui_listctrl* ctrl, rtgui_rect_t* rect)
{ {
......
...@@ -141,20 +141,11 @@ static void _rtgui_menu_item_onmouse() ...@@ -141,20 +141,11 @@ static void _rtgui_menu_item_onmouse()
{ {
} }
rtgui_type_t *rtgui_menu_type_get(void) DEFINE_CLASS_TYPE(menu, "menu",
{ RTGUI_WIDGET_TYPE,
static rtgui_type_t *menu_type = RT_NULL; _rtgui_menu_constructor,
_rtgui_menu_destructor,
if (!menu_type) sizeof(struct rtgui_menu));
{
menu_type = rtgui_type_create("menu", RTGUI_WIN_TYPE,
sizeof(rtgui_menu_t),
RTGUI_CONSTRUCTOR(_rtgui_menu_constructor),
RTGUI_DESTRUCTOR (_rtgui_menu_destructor));
}
return menu_type;
}
static rt_bool_t rtgui_menu_on_deactivate(rtgui_widget_t* widget, rtgui_event_t* event) static rt_bool_t rtgui_menu_on_deactivate(rtgui_widget_t* widget, rtgui_event_t* event)
{ {
......
...@@ -147,20 +147,11 @@ static void _rtgui_notebook_get_bar_rect(rtgui_notebook_t *notebook, struct rtgu ...@@ -147,20 +147,11 @@ static void _rtgui_notebook_get_bar_rect(rtgui_notebook_t *notebook, struct rtgu
rect->y1 = rect->y2 - 25; rect->y1 = rect->y2 - 25;
} }
rtgui_type_t *rtgui_notebook_type_get(void) DEFINE_CLASS_TYPE(notebook, "notebook",
{ RTGUI_CONTAINER_TYPE,
static rtgui_type_t *noteboot_type = RT_NULL; _rtgui_notebook_constructor,
_rtgui_notebook_destructor,
if (!noteboot_type) sizeof(struct rtgui_notebook));
{
noteboot_type = rtgui_type_create("notebook", RTGUI_CONTAINER_TYPE,
sizeof(rtgui_notebook_t),
RTGUI_CONSTRUCTOR(_rtgui_notebook_constructor),
RTGUI_DESTRUCTOR(_rtgui_notebook_destructor));
}
return noteboot_type;
}
rtgui_notebook_tab_t *tabs; rtgui_notebook_tab_t *tabs;
struct rtgui_notebook *_notebook; struct rtgui_notebook *_notebook;
......
...@@ -19,18 +19,11 @@ static void _rtgui_progressbar_constructor(rtgui_progressbar_t *bar) ...@@ -19,18 +19,11 @@ static void _rtgui_progressbar_constructor(rtgui_progressbar_t *bar)
RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(bar)) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL; RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(bar)) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL;
} }
rtgui_type_t *rtgui_progressbar_type_get(void) DEFINE_CLASS_TYPE(progressbar, "progressbar",
{ RTGUI_WIDGET_TYPE,
static rtgui_type_t *progressbar_type = RT_NULL; _rtgui_progressbar_constructor,
RT_NULL,
if (!progressbar_type) sizeof(struct rtgui_progressbar));
{
progressbar_type = rtgui_type_create("progressbar", RTGUI_WIDGET_TYPE,
sizeof(rtgui_progressbar_t), RTGUI_CONSTRUCTOR(_rtgui_progressbar_constructor), RT_NULL);
}
return progressbar_type;
}
rt_bool_t rtgui_progressbar_event_handler(struct rtgui_widget* widget, rt_bool_t rtgui_progressbar_event_handler(struct rtgui_widget* widget,
struct rtgui_event* event) struct rtgui_event* event)
......
...@@ -11,7 +11,7 @@ static void _rtgui_radiobox_constructor(rtgui_radiobox_t *radiobox) ...@@ -11,7 +11,7 @@ static void _rtgui_radiobox_constructor(rtgui_radiobox_t *radiobox)
/* init widget and set event handler */ /* init widget and set event handler */
RTGUI_WIDGET(radiobox)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE; RTGUI_WIDGET(radiobox)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(radiobox)) = RTGUI_ALIGN_LEFT | RTGUI_ALIGN_CENTER_VERTICAL; RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(radiobox)) = RTGUI_ALIGN_LEFT | RTGUI_ALIGN_CENTER_VERTICAL;
rtgui_widget_set_rect(RTGUI_WIDGET(radiobox), &rect); rtgui_widget_set_rect(RTGUI_WIDGET(radiobox), &rect);
rtgui_widget_set_event_handler(RTGUI_WIDGET(radiobox), rtgui_radiobox_event_handler); rtgui_widget_set_event_handler(RTGUI_WIDGET(radiobox), rtgui_radiobox_event_handler);
...@@ -22,18 +22,11 @@ static void _rtgui_radiobox_constructor(rtgui_radiobox_t *radiobox) ...@@ -22,18 +22,11 @@ static void _rtgui_radiobox_constructor(rtgui_radiobox_t *radiobox)
radiobox->orient = RTGUI_HORIZONTAL; radiobox->orient = RTGUI_HORIZONTAL;
} }
rtgui_type_t *rtgui_radiobox_type_get(void) DEFINE_CLASS_TYPE(radiobox, "radiobox",
{ RTGUI_WIDGET_TYPE,
static rtgui_type_t *radiobox_type = RT_NULL; _rtgui_radiobox_constructor,
RT_NULL,
if (!radiobox_type) sizeof(struct rtgui_radiobox));
{
radiobox_type = rtgui_type_create("radiobox", RTGUI_WIDGET_TYPE,
sizeof(rtgui_radiobox_t), RTGUI_CONSTRUCTOR(_rtgui_radiobox_constructor), RT_NULL);
}
return radiobox_type;
}
static void rtgui_radiobox_onmouse(struct rtgui_radiobox* radiobox, struct rtgui_event_mouse* event) static void rtgui_radiobox_onmouse(struct rtgui_radiobox* radiobox, struct rtgui_event_mouse* event)
{ {
......
...@@ -89,18 +89,11 @@ void rtgui_scrollbar_get_thumb_rect(rtgui_scrollbar_t *bar, rtgui_rect_t *rect) ...@@ -89,18 +89,11 @@ void rtgui_scrollbar_get_thumb_rect(rtgui_scrollbar_t *bar, rtgui_rect_t *rect)
} }
} }
rtgui_type_t *rtgui_scrollbar_type_get(void) DEFINE_CLASS_TYPE(scrollbar, "scrollbar",
{ RTGUI_WIDGET_TYPE,
static rtgui_type_t *scrollbar_type = RT_NULL; _rtgui_scrollbar_constructor,
RT_NULL,
if (!scrollbar_type) sizeof(struct rtgui_scrollbar));
{
scrollbar_type = rtgui_type_create("scrollbar", RTGUI_WIDGET_TYPE,
sizeof(rtgui_scrollbar_t), RTGUI_CONSTRUCTOR(_rtgui_scrollbar_constructor), RT_NULL);
}
return scrollbar_type;
}
static void _rtgui_scrollbar_on_mouseclick(struct rtgui_widget * widget, struct rtgui_event * event) static void _rtgui_scrollbar_on_mouseclick(struct rtgui_widget * widget, struct rtgui_event * event)
{ {
......
...@@ -41,18 +41,11 @@ static void _rtgui_slider_constructor(rtgui_slider_t *slider) ...@@ -41,18 +41,11 @@ static void _rtgui_slider_constructor(rtgui_slider_t *slider)
slider->on_changed = RT_NULL; slider->on_changed = RT_NULL;
} }
rtgui_type_t *rtgui_slider_type_get(void) DEFINE_CLASS_TYPE(slider, "slider",
{ RTGUI_WIDGET_TYPE,
static rtgui_type_t *slider_type = RT_NULL; _rtgui_slider_constructor,
RT_NULL,
if (!slider_type) sizeof(struct rtgui_slider));
{
slider_type = rtgui_type_create("slider", RTGUI_WIDGET_TYPE,
sizeof(rtgui_slider_t), RTGUI_CONSTRUCTOR(_rtgui_slider_constructor), RT_NULL);
}
return slider_type;
}
static void rtgui_slider_onmouse(struct rtgui_slider* slider, struct rtgui_event_mouse* event) static void rtgui_slider_onmouse(struct rtgui_slider* slider, struct rtgui_event_mouse* event)
{ {
......
...@@ -13,18 +13,12 @@ static void _rtgui_staticline_constructor(rtgui_staticline_t *staticline) ...@@ -13,18 +13,12 @@ static void _rtgui_staticline_constructor(rtgui_staticline_t *staticline)
rtgui_widget_set_event_handler(RTGUI_WIDGET(staticline), rtgui_staticline_event_handler); rtgui_widget_set_event_handler(RTGUI_WIDGET(staticline), rtgui_staticline_event_handler);
} }
rtgui_type_t *rtgui_staticline_type_get(void)
{
static rtgui_type_t *staticline_type = RT_NULL;
if (!staticline_type) DEFINE_CLASS_TYPE(staticline, "staticline",
{ RTGUI_WIDGET_TYPE,
staticline_type = rtgui_type_create("staticline", RTGUI_WIDGET_TYPE, _rtgui_staticline_constructor,
sizeof(rtgui_staticline_t), RTGUI_CONSTRUCTOR(_rtgui_staticline_constructor), RT_NULL); RT_NULL,
} sizeof(struct rtgui_staticline));
return staticline_type;
}
rt_bool_t rtgui_staticline_event_handler(struct rtgui_widget* widget, struct rtgui_event* event) rt_bool_t rtgui_staticline_event_handler(struct rtgui_widget* widget, struct rtgui_event* event)
{ {
......
...@@ -84,20 +84,11 @@ static void _rtgui_textbox_deconstructor(rtgui_textbox_t *box) ...@@ -84,20 +84,11 @@ static void _rtgui_textbox_deconstructor(rtgui_textbox_t *box)
box->caret_timer = RT_NULL; box->caret_timer = RT_NULL;
} }
rtgui_type_t *rtgui_textbox_type_get(void) DEFINE_CLASS_TYPE(textbox, "textbox",
{ RTGUI_WIDGET_TYPE,
static rtgui_type_t *textbox_type = RT_NULL; _rtgui_textbox_constructor,
_rtgui_textbox_deconstructor,
if (!textbox_type) sizeof(struct rtgui_textbox));
{
textbox_type = rtgui_type_create("textbox", RTGUI_WIDGET_TYPE,
sizeof(rtgui_textbox_t),
RTGUI_CONSTRUCTOR(_rtgui_textbox_constructor),
RTGUI_DESTRUCTOR(_rtgui_textbox_deconstructor));
}
return textbox_type;
}
static void rtgui_textbox_onmouse(struct rtgui_textbox* box, struct rtgui_event_mouse* event) static void rtgui_textbox_onmouse(struct rtgui_textbox* box, struct rtgui_event_mouse* event)
{ {
......
...@@ -28,20 +28,11 @@ static void _rtgui_wintitle_deconstructor(rtgui_wintitle_t* wintitle) ...@@ -28,20 +28,11 @@ static void _rtgui_wintitle_deconstructor(rtgui_wintitle_t* wintitle)
wintitle->title = RT_NULL; wintitle->title = RT_NULL;
} }
rtgui_type_t* rtgui_wintitle_type_get() DEFINE_CLASS_TYPE(wintitle, "wintitle",
{ RTGUI_TOPLEVEL_TYPE,
static rtgui_type_t *wintitle_type = RT_NULL; _rtgui_wintitle_constructor,
_rtgui_wintitle_deconstructor,
if (!wintitle_type) sizeof(struct rtgui_wintitle));
{
wintitle_type = rtgui_type_create("wintitle", RTGUI_TOPLEVEL_TYPE,
sizeof(rtgui_wintitle_t),
RTGUI_CONSTRUCTOR(_rtgui_wintitle_constructor),
RTGUI_DESTRUCTOR(_rtgui_wintitle_deconstructor));
}
return wintitle_type;
}
rtgui_wintitle_t* rtgui_wintitle_create(const char* title) rtgui_wintitle_t* rtgui_wintitle_create(const char* title)
{ {
......
...@@ -38,20 +38,11 @@ static void _rtgui_toplevel_destructor(rtgui_toplevel_t* toplevel) ...@@ -38,20 +38,11 @@ static void _rtgui_toplevel_destructor(rtgui_toplevel_t* toplevel)
toplevel->drawing = 0; toplevel->drawing = 0;
} }
rtgui_type_t *rtgui_toplevel_type_get(void) DEFINE_CLASS_TYPE(toplevel, "toplevel",
{ RTGUI_CONTAINER_TYPE,
static rtgui_type_t *toplevel_type = RT_NULL; _rtgui_toplevel_constructor,
_rtgui_toplevel_destructor,
if (!toplevel_type) sizeof(struct rtgui_toplevel));
{
toplevel_type = rtgui_type_create("toplevel", RTGUI_CONTAINER_TYPE,
sizeof(rtgui_toplevel_t),
RTGUI_CONSTRUCTOR(_rtgui_toplevel_constructor),
RTGUI_DESTRUCTOR(_rtgui_toplevel_destructor));
}
return toplevel_type;
}
rt_bool_t rtgui_toplevel_event_handler(rtgui_widget_t* widget, rtgui_event_t* event) rt_bool_t rtgui_toplevel_event_handler(rtgui_widget_t* widget, rtgui_event_t* event)
{ {
......
...@@ -48,20 +48,11 @@ static void _rtgui_view_destructor(rtgui_view_t *view) ...@@ -48,20 +48,11 @@ static void _rtgui_view_destructor(rtgui_view_t *view)
} }
} }
rtgui_type_t *rtgui_view_type_get(void) DEFINE_CLASS_TYPE(view, "view",
{ RTGUI_CONTAINER_TYPE,
static rtgui_type_t *view_type = RT_NULL; _rtgui_view_constructor,
_rtgui_view_destructor,
if (!view_type) sizeof(struct rtgui_view));
{
view_type = rtgui_type_create("view", RTGUI_CONTAINER_TYPE,
sizeof(rtgui_view_t),
RTGUI_CONSTRUCTOR(_rtgui_view_constructor),
RTGUI_DESTRUCTOR(_rtgui_view_destructor));
}
return view_type;
}
rt_bool_t rtgui_view_event_handler(struct rtgui_widget* widget, struct rtgui_event* event) rt_bool_t rtgui_view_event_handler(struct rtgui_widget* widget, struct rtgui_event* event)
{ {
......
...@@ -84,19 +84,11 @@ static void _rtgui_widget_destructor(rtgui_widget_t *widget) ...@@ -84,19 +84,11 @@ static void _rtgui_widget_destructor(rtgui_widget_t *widget)
rtgui_region_fini(&(widget->clip)); rtgui_region_fini(&(widget->clip));
} }
rtgui_type_t *rtgui_widget_type_get(void) DEFINE_CLASS_TYPE(widget, "widget",
{ RTGUI_OBJECT_TYPE,
static rtgui_type_t *widget_type = RT_NULL; _rtgui_widget_constructor,
_rtgui_widget_destructor,
if (!widget_type) sizeof(struct rtgui_widget));
{
widget_type = rtgui_type_create("rtgui_widget", RTGUI_OBJECT_TYPE,
sizeof(rtgui_widget_t), RTGUI_CONSTRUCTOR(_rtgui_widget_constructor),
RTGUI_DESTRUCTOR(_rtgui_widget_destructor));
}
return widget_type;
}
rtgui_widget_t *rtgui_widget_create(rtgui_type_t *widget_type) rtgui_widget_t *rtgui_widget_create(rtgui_type_t *widget_type)
{ {
......
...@@ -100,20 +100,11 @@ static rt_bool_t _rtgui_win_create_in_server(rtgui_win_t* win) ...@@ -100,20 +100,11 @@ static rt_bool_t _rtgui_win_create_in_server(rtgui_win_t* win)
return RT_TRUE; return RT_TRUE;
} }
rtgui_type_t *rtgui_win_type_get(void) DEFINE_CLASS_TYPE(win, "win",
{ RTGUI_TOPLEVEL_TYPE,
static rtgui_type_t *win_type = RT_NULL; _rtgui_win_constructor,
_rtgui_win_destructor,
if (!win_type) sizeof(struct rtgui_win));
{
win_type = rtgui_type_create("win", RTGUI_TOPLEVEL_TYPE,
sizeof(rtgui_win_t),
RTGUI_CONSTRUCTOR(_rtgui_win_constructor),
RTGUI_DESTRUCTOR(_rtgui_win_destructor));
}
return win_type;
}
rtgui_win_t* rtgui_win_create(rtgui_toplevel_t* parent_toplevel, const char* title, rtgui_rect_t *rect, rt_uint8_t style) rtgui_win_t* rtgui_win_create(rtgui_toplevel_t* parent_toplevel, const char* title, rtgui_rect_t *rect, rt_uint8_t style)
{ {
......
...@@ -55,20 +55,11 @@ static void _rtgui_workbench_destructor(rtgui_workbench_t *workbench) ...@@ -55,20 +55,11 @@ static void _rtgui_workbench_destructor(rtgui_workbench_t *workbench)
workbench->title = RT_NULL; workbench->title = RT_NULL;
} }
rtgui_type_t *rtgui_workbench_type_get(void) DEFINE_CLASS_TYPE(workbench, "workbench",
{ RTGUI_TOPLEVEL_TYPE,
static rtgui_type_t *workbench_type = RT_NULL; _rtgui_workbench_constructor,
_rtgui_workbench_destructor,
if (!workbench_type) sizeof(struct rtgui_workbench));
{
workbench_type = rtgui_type_create("workbench", RTGUI_TOPLEVEL_TYPE,
sizeof(rtgui_workbench_t),
RTGUI_CONSTRUCTOR(_rtgui_workbench_constructor),
RTGUI_DESTRUCTOR(_rtgui_workbench_destructor));
}
return workbench_type;
}
rtgui_workbench_t *rtgui_workbench_create(const char* panel_name, const unsigned char* title) rtgui_workbench_t *rtgui_workbench_create(const char* panel_name, const unsigned char* title)
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册