Mercurial > MadButterfly
comparison include/mb_shapes.h @ 1067:7b4e80ab671a openvg
merge from default branch
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Wed, 01 Dec 2010 12:25:56 +0800 |
parents | a8d20bc8ce40 |
children | bae104d8d247 |
comparison
equal
deleted
inserted
replaced
630:bd18951b51d5 | 1067:7b4e80ab671a |
---|---|
1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- | |
2 // vim: sw=4:ts=8:sts=4 | |
1 /*! \file | 3 /*! \file |
2 * \brief Declare interfaces of shapes. | 4 * \brief Declare interfaces of shapes. |
3 * | 5 * |
4 * \todo Add ellipse shape. | 6 * \todo Add ellipse shape. |
5 * \todo Add circle shape. | 7 * \todo Add circle shape. |
24 * - rdman_shape_*_new() | 26 * - rdman_shape_*_new() |
25 * - clear memory for shape_t member. | 27 * - clear memory for shape_t member. |
26 * - mb_obj_init() to initialize shape_t::obj. | 28 * - mb_obj_init() to initialize shape_t::obj. |
27 * - assign *_free() to \ref shape_t::free. | 29 * - assign *_free() to \ref shape_t::free. |
28 * - make new object been managed by a redraw manager. | 30 * - make new object been managed by a redraw manager. |
29 * - call rdman_shape_man() | 31 * - call rdman_man_shape() |
30 * - *_free() | 32 * - *_free() |
31 * - assigned to \ref shape_t::free. | 33 * - assigned to \ref shape_t::free. |
32 * - *_transform() | 34 * - *_transform() |
33 * - *_draw() | 35 * - *_draw() |
34 * - *_draw() is responsive to define shape. How the shape is filled | 36 * - *_draw() is responsive to define shape. How the shape is filled |
35 * or stroked is defined by paint. | 37 * or stroked is defined by paint. |
36 * - first member variable of a shape type must be a shape_t. | 38 * - first member variable of a shape type must be a shape_t. |
37 * | 39 * |
38 * Must modify | 40 * Must modify |
39 * - event.c::draw_shape_path() | 41 * - event.c::draw_shape_path() |
40 * - redraw_man.c::clean_shape() | 42 * - redraw_man.c::clean_shape() |
41 * - redraw_man.c::draw_shape() | 43 * - redraw_man.c::draw_shape() |
42 * | 44 * |
46 * redraw_man.c::clean_shape(). It's task is to update \ref geo_t of the | 48 * redraw_man.c::clean_shape(). It's task is to update \ref geo_t of the |
47 * shape object. In most situtation, it call geo_from_positions() to | 49 * shape object. In most situtation, it call geo_from_positions() to |
48 * update geo_t. | 50 * update geo_t. |
49 * | 51 * |
50 * \section rdman_man_shape Make a redraw manager managing a shape. | 52 * \section rdman_man_shape Make a redraw manager managing a shape. |
51 * | 53 * |
52 * It means managing life cycle of a shape to make a redraw manager | 54 * It means managing life cycle of a shape to make a redraw manager |
53 * managing a shape. Shapes are referenced by a redraw manager to | 55 * managing a shape. Shapes are referenced by a redraw manager to |
54 * update output device. So, a redraw manager must make sure all | 56 * update output device. So, a redraw manager must make sure all |
55 * shapes are valid when they are needed to update output. To make sure | 57 * shapes are valid when they are needed to update output. To make sure |
56 * lifecycle of shapes are synchronized with status of a redraw manager, | 58 * lifecycle of shapes are synchronized with status of a redraw manager, |
57 * lifecycle of shapes are managed by associated redraw manager. | 59 * lifecycle of shapes are managed by associated redraw manager. |
58 * | 60 * |
59 */ | 61 */ |
60 | 62 |
61 /*! \defgroup shapes Shapes | 63 /*! \defgroup shapes Shapes |
62 * @{ | 64 * @{ |
63 */ | 65 */ |
83 extern shape_t *rdman_shape_text_new(redraw_man_t *rdman, | 85 extern shape_t *rdman_shape_text_new(redraw_man_t *rdman, |
84 const char *txt, co_aix x, co_aix y, | 86 const char *txt, co_aix x, co_aix y, |
85 co_aix font_size, | 87 co_aix font_size, |
86 mbe_font_face_t *face,PangoAttrList *attrs); | 88 mbe_font_face_t *face,PangoAttrList *attrs); |
87 /*! \brief Change the content of the text element. | 89 /*! \brief Change the content of the text element. |
88 * In the SVG, the content of a text tag can be composed of several tspan inside it. The Madbutterfly parser will collect all content of a | 90 * In the SVG, the content of a text tag can be composed of several tspan inside it. The Madbutterfly parser will collect all content of a |
89 * text segement as a single string. The attribute of these characters are saved in a seperate data structure. In the program level, we will | 91 * text segement as a single string. The attribute of these characters are saved in a seperate data structure. In the program level, we will |
90 * not keep the SVG text tree. Instead, all attributes will be expanded into a list. | 92 * not keep the SVG text tree. Instead, all attributes will be expanded into a list. |
91 * | 93 * |
92 * When you change the content of a text element, please remember that the attributes will not be removed by the way. You need to change | 94 * When you change the content of a text element, please remember that the attributes will not be removed by the way. You need to change |
93 * them seperately. | 95 * them seperately. |
94 * | 96 * |
95 */ | 97 */ |
96 extern void sh_text_set_text(shape_t *shape, const char *txt); | 98 extern void sh_text_set_text(shape_t *shape, const char *txt); |
97 | 99 |
98 extern void sh_text_transform(shape_t *shape); | 100 extern void sh_text_transform(shape_t *shape); |
140 mbe_surface_t *surface; | 142 mbe_surface_t *surface; |
141 } mb_text_t; | 143 } mb_text_t; |
142 | 144 |
143 /*! \brief Change the style of the text. | 145 /*! \brief Change the style of the text. |
144 * | 146 * |
145 * This function can add a couple of attributes to a segment of text or the whole text field. If the @end is -1, the attributes | 147 * This function can add a couple of attributes to a segment of text or the whole text field. If the @end is -1, the attributes |
146 * will be applied to the whole text field. The @style should be initialized by using the mb_textstyle_xxx functions. All attributes | 148 * will be applied to the whole text field. The @style should be initialized by using the mb_textstyle_xxx functions. All attributes |
147 * which is not initialized will not be changed. It means that the @style will be added into all existing style instead of reaplcing | 149 * which is not initialized will not be changed. It means that the @style will be added into all existing style instead of reaplcing |
148 * it. | 150 * it. |
149 */ | 151 */ |
150 extern void sh_text_set_style(shape_t *shape,int begin,int end,mb_textstyle_t *format); | 152 extern void sh_text_set_style(shape_t *shape,int begin,int end,mb_textstyle_t *format); |
151 /*! \brief Change the color of the text field | 153 /*! \brief Change the color of the text field |
152 * Change the color of the whole text field. This will removed all existing color attribute. If you want to change part of the text | 154 * Change the color of the whole text field. This will removed all existing color attribute. If you want to change part of the text |
153 * field only, please use the sh_text_set_style instead. | 155 * field only, please use the sh_text_set_style instead. |
154 */ | 156 */ |
155 extern void sh_text_set_color(shape_t *shape, unsigned color); | 157 extern void sh_text_set_color(shape_t *shape, unsigned color); |
156 /*! \brief Turn on/off the bold attribute. | 158 /*! \brief Turn on/off the bold attribute. |
157 * Turn on/off the font weight of the whole text field. This will removed all existing bold setting. If you want to change part of the text | 159 * Turn on/off the font weight of the whole text field. This will removed all existing bold setting. If you want to change part of the text |
158 * field only, please use the sh_text_set_style instead. | 160 * field only, please use the sh_text_set_style instead. |
159 */ | 161 */ |
160 extern void sh_text_set_bold(shape_t *shape, int bold); | 162 extern void sh_text_set_bold(shape_t *shape, int bold); |
161 /*! \brief Turn on/off the italic attribute. | 163 /*! \brief Turn on/off the italic attribute. |
162 * Turn on/off the italic of the whole text field. This will removed all existing italic setting. If you want to change part of the text | 164 * Turn on/off the italic of the whole text field. This will removed all existing italic setting. If you want to change part of the text |
163 * field only, please use the sh_text_set_style instead. | 165 * field only, please use the sh_text_set_style instead. |
164 */ | 166 */ |
165 extern void sh_text_set_italic(shape_t *shape, int italic); | 167 extern void sh_text_set_italic(shape_t *shape, int italic); |
166 /*! \brief Turn on/off the underline attribute. | 168 /*! \brief Turn on/off the underline attribute. |
167 * Turn on/off the underline of the whole text field. This will removed all existing underline setting. If you want to change part of the text | 169 * Turn on/off the underline of the whole text field. This will removed all existing underline setting. If you want to change part of the text |
168 * field only, please use the sh_text_set_style instead. | 170 * field only, please use the sh_text_set_style instead. |
169 */ | 171 */ |
170 extern void sh_text_set_underline(shape_t *shape, int underline); | 172 extern void sh_text_set_underline(shape_t *shape, int underline); |
171 /*! \brief Change the font of the text field. | 173 /*! \brief Change the font of the text field. |
172 * Change the font of the whole text field. This will removed all existing underline setting. If you want to change part of the text | 174 * Change the font of the whole text field. This will removed all existing underline setting. If you want to change part of the text |
173 * field only, please use the sh_text_set_style instead. | 175 * field only, please use the sh_text_set_style instead. |
174 */ | 176 */ |
175 extern void sh_text_set_font(shape_t *shape, char *family); | 177 extern void sh_text_set_font(shape_t *shape, char *family); |
176 /*! \brief Init the text style data structure. | 178 /*! \brief Init the text style data structure. |
177 * | 179 * |
193 return style->font; | 195 return style->font; |
194 else | 196 else |
195 return NULL; | 197 return NULL; |
196 } | 198 } |
197 extern void mb_textstyle_set_bold(mb_textstyle_t *style, int bold); | 199 extern void mb_textstyle_set_bold(mb_textstyle_t *style, int bold); |
198 static inline int mb_textstyle_get_bold(mb_textstyle_t *style) | 200 static inline int mb_textstyle_get_bold(mb_textstyle_t *style) |
199 { | 201 { |
200 return style->property & TEXTSTYLE_BOLD; | 202 return style->property & TEXTSTYLE_BOLD; |
201 } | 203 } |
202 extern void mb_textstyle_set_italic(mb_textstyle_t *style, int italic); | 204 extern void mb_textstyle_set_italic(mb_textstyle_t *style, int italic); |
203 static inline int mb_textstyle_get_italic(mb_textstyle_t *style) | 205 static inline int mb_textstyle_get_italic(mb_textstyle_t *style) |