00001 #ifndef __MB_TYPES_H_
00002 #define __MB_TYPES_H_
00003
00004 #include <cairo.h>
00005 #include "mb_tools.h"
00006 #include "mb_observer.h"
00007
00008 typedef float co_aix;
00009 typedef struct _shape shape_t;
00010 typedef struct _geo geo_t;
00011 typedef struct _area area_t;
00012 typedef struct _shnode shnode_t;
00013 typedef struct _paint paint_t;
00014
00015 struct _redraw_man;
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 struct _paint {
00026 int flags;
00027 void (*prepare)(paint_t *paint, cairo_t *cr);
00028 void (*free)(struct _redraw_man *rdman, paint_t *paint);
00029 STAILQ(shnode_t) members;
00030 paint_t *pnt_next;
00031 };
00032
00033 #define PNTF_FREE 0x1
00034
00035 struct _shnode {
00036 shape_t *shape;
00037 shnode_t *next;
00038 };
00039
00040 struct _area {
00041 co_aix x, y;
00042 co_aix w, h;
00043 };
00044
00045
00046
00047 struct _geo {
00048 #ifdef GEO_ORDER
00049 unsigned int order;
00050 #endif
00051 unsigned int flags;
00052 shape_t *shape;
00053 geo_t *coord_next;
00054
00055 area_t *cur_area, *last_area;
00056 area_t areas[2];
00057
00058 subject_t *mouse_event;
00059 };
00060 #define GEF_DIRTY 0x1
00061 #define GEF_HIDDEN 0x2
00062 #define GEF_FREE 0x4
00063
00064 extern int is_overlay(area_t *r1, area_t *r2);
00065 extern void area_init(area_t *area, int n_pos, co_aix pos[][2]);
00066 extern void geo_init(geo_t *g);
00067 extern void geo_from_positions(geo_t *g, int n_pos, co_aix pos[][2]);
00068 extern void geo_mark_overlay(geo_t *g, int n_others, geo_t **others,
00069 int *n_overlays, geo_t **overlays);
00070 #define geo_get_shape(g) ((g)->shape)
00071 #define geo_set_shape(g, sh) do {(g)->shape = sh;} while(0)
00072 #define _geo_is_in(a, s, w) ((a) >= (s) && (a) < ((s) + (w)))
00073 #define geo_pos_is_in(g, _x, _y) \
00074 (_geo_is_in(_x, (g)->cur_area->x, (g)->cur_area->w) && \
00075 _geo_is_in(_y, (g)->cur_area->y, (g)->cur_area->h))
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 typedef struct _coord {
00096 unsigned int order;
00097 unsigned int flags;
00098 co_aix opacity;
00099
00100
00101
00102
00103
00104
00105 cairo_t *canvas;
00106 area_t *cur_area, *last_area;
00107 area_t areas[2];
00108
00109 co_aix matrix[6];
00110 co_aix aggr_matrix[6];
00111
00112 struct _coord *parent;
00113 STAILQ(struct _coord) children;
00114 struct _coord *sibling;
00115 unsigned int before_pmem;
00116
00117
00118 int num_members;
00119 STAILQ(geo_t) members;
00120
00121 subject_t *mouse_event;
00122 } coord_t;
00123 #define COF_DIRTY 0x1
00124 #define COF_HIDDEN 0x2
00125 #define COF_OWN_CANVAS 0x4
00126
00127
00128 #define COF_SKIP_TRIVAL 0x8
00129
00130
00131 #define COF_FREE 0x10
00132
00133 extern void coord_init(coord_t *co, coord_t *parent);
00134 extern void coord_trans_pos(coord_t *co, co_aix *x, co_aix *y);
00135 extern co_aix coord_trans_size(coord_t *co, co_aix size);
00136 extern void compute_aggr_of_coord(coord_t *coord);
00137 extern void update_aggr_matrix(coord_t *start);
00138 extern coord_t *preorder_coord_subtree(coord_t *root, coord_t *last);
00139 extern coord_t *postorder_coord_subtree(coord_t *root, coord_t *last);
00140 extern void preorder_coord_skip_subtree(coord_t *subroot);
00141 #define preorder_coord_skip_subtree(sub) \
00142 do { (sub)->flags |= COF_SKIP_TRIVAL; } while(0)
00143 #define coord_hide(co) \
00144 do { \
00145 (co)->flags |= COF_HIDDEN; \
00146 } while(0)
00147 #define coord_show(co) do { co->flags &= ~COF_HIDDEN; } while(0)
00148 #define coord_get_mouse_event(coord) ((coord)->mouse_event)
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163 struct _shape {
00164 int sh_type;
00165 geo_t *geo;
00166 coord_t *coord;
00167 paint_t *fill, *stroke;
00168 co_aix stroke_width;
00169 int stroke_linecap:2;
00170 int stroke_linejoin:2;
00171 struct _shape *sh_next;
00172 void (*free)(shape_t *shape);
00173 };
00174 enum { SHT_UNKNOW, SHT_PATH, SHT_TEXT, SHT_RECT };
00175
00176 #define sh_get_mouse_event_subject(sh) ((sh)->geo->mouse_event)
00177 #define sh_hide(sh) \
00178 do { \
00179 (sh)->geo->flags |= GEF_HIDDEN; \
00180 } while(0)
00181 #define sh_show(sh) \
00182 do { \
00183 (sh)->geo->flags &= ~GEF_HIDDEN; \
00184 } while(0)
00185
00186
00187 #endif