# HG changeset patch # User Thinker K.F. Li # Date 1228815250 -28800 # Node ID c234ee745ceb9cfe91ef1f8c678622f37b2f2df3 # Parent 5235aded379c9ce2a852434d64d2a9ee3bb280c8 Start moving to mb_obj_t diff -r 5235aded379c -r c234ee745ceb include/mb_types.h --- a/include/mb_types.h Wed Nov 19 20:54:27 2008 +0800 +++ b/include/mb_types.h Tue Dec 09 17:34:10 2008 +0800 @@ -11,9 +11,27 @@ typedef struct _area area_t; typedef struct _shnode shnode_t; typedef struct _paint paint_t; +typedef struct _mb_obj mb_obj_t; struct _redraw_man; +struct _mb_obj { + int obj_type; +}; + +enum { MBO_DUMMY, + MBO_COORD, + MBO_SHAPES=0x1000, + MBO_PATH, + MBO_TEXT, + MBO_RECT +}; +#define MBO_CLASS_MASK 0xf000 +#define MBO_CLASS(x) (((mb_obj_t *)(x))->obj_type & MBO_CLASS_MASK) +#define MBO_TYPE(x) (((mb_obj_t *)(x))->obj_type) +#define IS_MBO_SHAPES(obj) (MBO_CLASS(obj) == MBO_SHAPES) +#define IS_MBO_COORD(obj) (MBO_TYPE(obj) == MB_COORD) + /*! \brief Base of paint types. * * Paints should be freed by users by calling rdman_paint_free() of @@ -93,6 +111,7 @@ * \enddot */ typedef struct _coord { + mb_obj_t obj; unsigned int order; unsigned int flags; co_aix opacity; @@ -161,7 +180,7 @@ * \enddot */ struct _shape { - int sh_type; + mb_obj_t obj; geo_t *geo; coord_t *coord; paint_t *fill, *stroke; @@ -171,7 +190,7 @@ struct _shape *sh_next; /*!< Link all shapes of a rdman together. */ void (*free)(shape_t *shape); }; -enum { SHT_UNKNOW, SHT_PATH, SHT_TEXT, SHT_RECT }; +/* enum { SHT_UNKNOW, SHT_PATH, SHT_TEXT, SHT_RECT }; */ #define sh_get_mouse_event_subject(sh) ((sh)->geo->mouse_event) #define sh_hide(sh) \ diff -r 5235aded379c -r c234ee745ceb src/coord.c --- a/src/coord.c Wed Nov 19 20:54:27 2008 +0800 +++ b/src/coord.c Tue Dec 09 17:34:10 2008 +0800 @@ -90,6 +90,7 @@ co->parent = parent; STAILQ_INS_TAIL(parent->children, coord_t, sibling, co); } + MBO_TYPE(co) = MBO_COORD; co->matrix[0] = 1; co->matrix[4] = 1; co->aggr_matrix[0] = 1; diff -r 5235aded379c -r c234ee745ceb src/event.c --- a/src/event.c Wed Nov 19 20:54:27 2008 +0800 +++ b/src/event.c Tue Dec 09 17:34:10 2008 +0800 @@ -52,14 +52,14 @@ } static void draw_shape_path(shape_t *shape, cairo_t *cr) { - switch(shape->sh_type) { - case SHT_PATH: + switch(MBO_TYPE(shape)) { + case MBO_PATH: sh_path_draw(shape, cr); break; - case SHT_TEXT: + case MBO_TEXT: sh_text_draw(shape, cr); break; - case SHT_RECT: + case MBO_RECT: sh_rect_draw(shape, cr); break; } diff -r 5235aded379c -r c234ee745ceb src/redraw_man.c --- a/src/redraw_man.c Wed Nov 19 20:54:27 2008 +0800 +++ b/src/redraw_man.c Tue Dec 09 17:34:10 2008 +0800 @@ -750,14 +750,14 @@ } static void clean_shape(shape_t *shape) { - switch(shape->sh_type) { - case SHT_PATH: + switch(MBO_TYPE(shape)) { + case MBO_PATH: sh_path_transform(shape); break; - case SHT_TEXT: + case MBO_TEXT: sh_text_transform(shape); break; - case SHT_RECT: + case MBO_RECT: sh_rect_transform(shape); break; #ifdef UNITTEST @@ -950,14 +950,14 @@ * operators for them. */ if(shape->fill || shape->stroke) { - switch(shape->sh_type) { - case SHT_PATH: + switch(MBO_TYPE(shape)) { + case MBO_PATH: sh_path_draw(shape, cr); break; - case SHT_TEXT: + case MBO_TEXT: sh_text_draw(shape, cr); break; - case SHT_RECT: + case MBO_RECT: sh_rect_draw(shape, cr); break; #ifdef UNITTEST diff -r 5235aded379c -r c234ee745ceb src/shape_path.c --- a/src/shape_path.c Wed Nov 19 20:54:27 2008 +0800 +++ b/src/shape_path.c Tue Dec 09 17:34:10 2008 +0800 @@ -682,7 +682,7 @@ path = (sh_path_t *)malloc(sizeof(sh_path_t)); /*! \todo Remove this memset()? */ memset(&path->shape, 0, sizeof(shape_t)); - path->shape.sh_type = SHT_PATH; + MBO_TYPE(path) = MBO_PATH; path->cmd_len = cmd_cnt; path->arg_len = arg_cnt; path->fix_arg_len = fix_arg_cnt; diff -r 5235aded379c -r c234ee745ceb src/shape_rect.c --- a/src/shape_rect.c Wed Nov 19 20:54:27 2008 +0800 +++ b/src/shape_rect.c Tue Dec 09 17:34:10 2008 +0800 @@ -27,7 +27,7 @@ memset(rect, 0, sizeof(sh_rect_t)); - rect->shape.sh_type = SHT_RECT; + MBO_TYPE(rect) = MBO_RECT; rect->x = x; rect->y = y; rect->w = w; diff -r 5235aded379c -r c234ee745ceb src/shape_text.c --- a/src/shape_text.c Wed Nov 19 20:54:27 2008 +0800 +++ b/src/shape_text.c Tue Dec 09 17:34:10 2008 +0800 @@ -42,7 +42,7 @@ return NULL; memset(text, 0, sizeof(sh_text_t)); - text->shape.sh_type = SHT_TEXT; + MBO_TYPE(text) = MBO_TEXT; text->data = strdup(txt); if(text->data == NULL) { free(text);