Mercurial > MadButterfly
comparison src/mbaf/mbobject.c @ 303:f894b30676e9
Add MBAF object suport. This is still work in progress yet. However, it won't affect other features. Therefore, it is checked in before it become mature.
author | wycc |
---|---|
date | Sun, 15 Feb 2009 08:34:57 +0800 |
parents | |
children | 586e50f82c1f |
comparison
equal
deleted
inserted
replaced
302:8b45e7b374b8 | 303:f894b30676e9 |
---|---|
1 #include "mb_types.h" | |
2 #include "mb_obj.h" | |
3 | |
4 | |
5 void mb_obj_set_pos(mb_obj_t *obj, co_aix x, co_aix y) | |
6 { | |
7 if (MBO_TYPE(obj) == MBO_COORD) { | |
8 coord_x(((coord_t *) obj)) = x; | |
9 coord_y(((coord_t *) obj)) = y; | |
10 } else if (MBO_TYPE(obj) == MBO_TEXT) { | |
11 sh_text_set_pos((shape_t *) obj, x, y); | |
12 } else { | |
13 return; | |
14 } | |
15 | |
16 } | |
17 | |
18 void mb_obj_get_pos(mb_obj_t *obj, co_aix *x, co_aix *y) | |
19 { | |
20 if (MBO_TYPE(obj) == MBO_COORD) { | |
21 *x = coord_x((coord_t *) obj); | |
22 *y = coord_y((coord_t *) obj); | |
23 } else if (MBO_TYPE(obj) == MBO_TEXT) { | |
24 sh_text_get_pos((shape_t *) obj, x, y); | |
25 } else { | |
26 return; | |
27 } | |
28 | |
29 } | |
30 | |
31 void mb_obj_set_text(mb_obj_t *obj, const char *text) | |
32 { | |
33 if (MBO_TYPE(obj) == MBO_COORD) { | |
34 geo_t *geo; | |
35 shape_t *shape; | |
36 coord_t *g = (coord_t *) obj; | |
37 | |
38 FOR_COORD_MEMBERS(g, geo) { | |
39 shape = geo_get_shape(geo); | |
40 if(shape->obj.obj_type == MBO_TEXT) { | |
41 sh_text_set_text(shape, text); | |
42 return; | |
43 } | |
44 } | |
45 } else if (MBO_TYPE(obj) == MBO_TEXT) { | |
46 sh_text_set_text((shape_t *) obj,text); | |
47 } else { | |
48 return; | |
49 } | |
50 | |
51 } | |
52 | |
53 | |
54 void mb_obj_get_text(mb_obj_t *obj, char *text,int size) | |
55 { | |
56 if (MBO_TYPE(obj) == MBO_COORD) { | |
57 geo_t *geo; | |
58 shape_t *shape; | |
59 coord_t *g = (coord_t *) obj; | |
60 | |
61 FOR_COORD_MEMBERS(g, geo) { | |
62 shape = geo_get_shape(geo); | |
63 if(shape->obj.obj_type == MBO_TEXT) { | |
64 sh_text_get_text(shape, text,size); | |
65 return; | |
66 } | |
67 } | |
68 } else if (MBO_TYPE(obj) == MBO_TEXT) { | |
69 sh_text_get_text((shape_t *) obj,text,size); | |
70 } else { | |
71 *text = 0; | |
72 return; | |
73 } | |
74 } | |
75 | |
76 void mb_obj_set_scalex(mb_obj_t *obj,int scale) | |
77 { | |
78 if (MBO_TYPE(obj) == MBO_COORD) { | |
79 coord_set_scalex((coord_t *) obj, scale); | |
80 } else { | |
81 } | |
82 } | |
83 | |
84 int mb_obj_get_scalex(mb_obj_t *obj) | |
85 { | |
86 if (MBO_TYPE(obj) == MBO_COORD) { | |
87 return coord_scalex((coord_t *) obj); | |
88 } else { | |
89 return 100; | |
90 } | |
91 } | |
92 | |
93 void mb_obj_set_scaley(mb_obj_t *obj,int scale) | |
94 { | |
95 if (MBO_TYPE(obj) == MBO_COORD) { | |
96 coord_set_scaley((coord_t *) obj, scale); | |
97 } else { | |
98 } | |
99 } | |
100 int mb_obj_get_scaley(mb_obj_t *obj) | |
101 { | |
102 if (MBO_TYPE(obj) == MBO_COORD) { | |
103 return coord_scaley((coord_t *) obj); | |
104 } else { | |
105 return 100; | |
106 } | |
107 } | |
108 | |
109 void mb_obj_set_rotation(mb_obj_t *obj, int degree) | |
110 { | |
111 printf("%s is not implemented yet\n",__FUNCTION__); | |
112 } | |
113 | |
114 int mb_obj_get_rotation(mb_obj_t *obj) | |
115 { | |
116 printf("%s is not implemented yet\n",__FUNCTION__); | |
117 } | |
118 | |
119 | |
120 | |
121 void mb_obj_set_color(mb_obj_t *obj, int color) | |
122 { | |
123 printf("%s is not implemented yet\n",__FUNCTION__); | |
124 } | |
125 | |
126 | |
127 int mb_obj_get_color(mb_obj_t *obj) | |
128 { | |
129 printf("%s is not implemented yet\n",__FUNCTION__); | |
130 return 0; | |
131 } | |
132 |