Mercurial > MadButterfly
annotate src/mb_types.h @ 14:d34232f15863
-
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Thu, 31 Jul 2008 17:43:20 +0800 |
parents | ed55009d96d3 |
children | c2ce186a5c37 |
rev | line source |
---|---|
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1 #ifndef __MB_TYPES_H_ |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
2 #define __MB_TYPES_H_ |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
3 |
12 | 4 #include "tools.h" |
5 | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
6 typedef float co_aix; |
11
128af06c876c
Fix the bug that data of a path end with white spaces would make system down
Thinker K.F. Li <thinker@branda.to>
parents:
10
diff
changeset
|
7 typedef struct _shape shape_t; |
12 | 8 typedef struct _geo geo_t; |
13 | 9 typedef struct _area area_t; |
10 | |
11 struct _area { | |
12 co_aix x, y; | |
13 co_aix w, h; | |
14 }; | |
15 | |
16 /*! \brief Geometry data of a shape or a group of shape. | |
17 */ | |
18 struct _geo { | |
19 unsigned int order; | |
20 unsigned int flags; | |
21 shape_t *shape; | |
22 geo_t *next; /*!< \brief Link all geo objects. */ | |
23 | |
24 area_t *cur_area, *last_area; | |
25 area_t areas[2]; | |
26 }; | |
27 #define GEF_DIRTY 0x1 | |
28 | |
29 extern int is_overlay(area_t *r1, area_t *r2); | |
30 extern void geo_init(geo_t *g, int n_pos, co_aix pos[][2]); | |
31 extern void geo_mark_overlay(geo_t *g, int n_others, geo_t **others, | |
32 int *n_overlays, geo_t **overlays); | |
33 #define geo_get_shape(g) ((g)->shape) | |
34 #define geo_set_shape(g, sh) do {(g)->shape = sh;} while(0) | |
35 | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
36 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
37 /*! \brief A coordination system. |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
38 * |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
39 * It have a transform function defined by matrix to transform |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
40 * coordination from source space to target space. |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
41 * Source space is where the contained is drawed, and target space |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
42 * is where the coordination of parent container of the element |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
43 * represented by this coord object. |
12 | 44 * |
45 * \dot | |
46 * digraph G { | |
47 * graph [rankdir=LR]; | |
48 * root -> child00 -> child10 -> child20 [label="children" color="blue"]; | |
49 * child00 -> child01 -> child02 [label="sibling"]; | |
50 * child10 -> child11 [label="sibling"]; | |
51 * } | |
52 * \enddot | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
53 */ |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
54 typedef struct _coord { |
13 | 55 unsigned int order; |
56 unsigned int flags; | |
57 area_t *cur_area, *last_area; | |
58 | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
59 co_aix matrix[6]; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
60 co_aix aggr_matrix[6]; |
13 | 61 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
62 struct _coord *parent; |
12 | 63 STAILQ(struct _coord) children; |
64 struct _coord *sibling; | |
13 | 65 |
66 STAILQ(shape_t) members; /*!< All shape_t objects in this coord. */ | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
67 } coord_t; |
13 | 68 #define COF_DIRTY 0x1 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
69 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
70 extern void coord_init(coord_t *co, coord_t *parent); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
71 extern void coord_trans_pos(coord_t *co, co_aix *x, co_aix *y); |
10 | 72 extern void update_aggr_matrix(coord_t *start); |
13 | 73 extern coord_t *preorder_coord_subtree(coord_t *root, coord_t *last); |
12 | 74 |
75 | |
76 /*! \brief A grahpic shape. | |
77 * | |
78 * \dot | |
79 * digraph G { | |
80 * "shape" -> "coord"; | |
81 * "shape" -> "geo"; | |
82 * "geo" -> "shape"; | |
83 * "coord" -> "shape" [label="members"] | |
84 * "shape" -> "shape" [label="sibling"]; | |
85 * } | |
86 * \enddot | |
87 */ | |
88 struct _shape { | |
89 int sh_type; | |
90 geo_t *geo; | |
91 coord_t *coord; | |
92 shape_t *coord_mem_next; | |
93 }; | |
94 enum { SHT_UNKNOW, SHT_PATH, SHT_TEXT }; | |
95 | |
96 #define sh_attach_geo(sh, g) \ | |
97 do { \ | |
98 (sh)->geo = g; \ | |
99 (g)->shape = (shape_t *)(sh); \ | |
100 } while(0) | |
101 #define sh_detach_geo(sh) \ | |
102 do { \ | |
103 (sh)->geo->shape = NULL; \ | |
104 (sh)->geo = NULL; \ | |
105 } while(0) | |
106 extern void sh_attach_coord(shape_t *sh, coord_t *coord); | |
107 extern void sh_detach_coord(shape_t *sh); | |
108 | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
109 #endif /* __MB_TYPES_H_ */ |