Mercurial > MadButterfly
annotate include/mb_shapes.h @ 472:4254eaa699d0 Android_Skia
Declare functions that should be implemented by Skia graphic engine
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Thu, 12 Nov 2009 21:32:52 +0800 |
parents | af4b506ad56f |
children | ba64f928542b |
rev | line source |
---|---|
101 | 1 /*! \file |
2 * \brief Declare interfaces of shapes. | |
3 * | |
4 * \todo Add ellipse shape. | |
5 * \todo Add circle shape. | |
6 */ | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
7 #ifndef __SHAPES_H_ |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
8 #define __SHAPES_H_ |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
9 |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
444
diff
changeset
|
10 #include "mb_graph_engine.h" |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
11 #include "mb_types.h" |
186
530bb7728546
Move header files to $(top_srcdir)/include/ and prefixed with 'mb_'.
Thinker K.F. Li <thinker@branda.to>
parents:
185
diff
changeset
|
12 #include "mb_redraw_man.h" |
257
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
13 #include "mb_img_ldr.h" |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
14 |
101 | 15 /*! \page define_shape How to Define Shapes |
27 | 16 * |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
17 * A shape implementation must include |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
18 * - rdman_shape_*_new() |
35
581a03196093
Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents:
33
diff
changeset
|
19 * - clear memory for shape_t member. |
393
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
20 * - mb_obj_init() to initialize shape_t::obj. |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
21 * - assign *_free() to \ref shape_t::free. |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
22 * - make new object been managed by a redraw manager. |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
23 * - call rdman_shape_man() |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
24 * - *_free() |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
25 * - assigned to \ref shape_t::free. |
27 | 26 * - *_transform() |
30
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
27 * - *_draw() |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
28 * - *_draw() is responsive to define shape. How the shape is filled |
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
29 * or stroked is defined by paint. |
108 | 30 * - first member variable of a shape type must be a shape_t. |
35
581a03196093
Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents:
33
diff
changeset
|
31 * |
581a03196093
Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents:
33
diff
changeset
|
32 * Must modify |
101 | 33 * - event.c::draw_shape_path() |
34 * - redraw_man.c::clean_shape() | |
35 * - redraw_man.c::draw_shape() | |
257
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
36 * |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
37 * \section shape_transform Shape Transform |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
38 * |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
39 * All shape types must have a shape transform function. It is invoked by |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
40 * redraw_man.c::clean_shape(). It's task is to update \ref geo_t of the |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
41 * shape object. In most situtation, it call geo_from_positions() to |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
42 * update geo_t. |
416
5791263ebe7b
Document for why a shape should be managed by the redraw manager.
Thinker K.F. Li <thinker@branda.to>
parents:
393
diff
changeset
|
43 * |
5791263ebe7b
Document for why a shape should be managed by the redraw manager.
Thinker K.F. Li <thinker@branda.to>
parents:
393
diff
changeset
|
44 * \section rdman_man_shape Make a redraw manager managing a shape. |
5791263ebe7b
Document for why a shape should be managed by the redraw manager.
Thinker K.F. Li <thinker@branda.to>
parents:
393
diff
changeset
|
45 * |
5791263ebe7b
Document for why a shape should be managed by the redraw manager.
Thinker K.F. Li <thinker@branda.to>
parents:
393
diff
changeset
|
46 * It means managing life cycle of a shape to make a redraw manager |
5791263ebe7b
Document for why a shape should be managed by the redraw manager.
Thinker K.F. Li <thinker@branda.to>
parents:
393
diff
changeset
|
47 * managing a shape. Shapes are referenced by a redraw manager to |
5791263ebe7b
Document for why a shape should be managed by the redraw manager.
Thinker K.F. Li <thinker@branda.to>
parents:
393
diff
changeset
|
48 * update output device. So, a redraw manager must make sure all |
5791263ebe7b
Document for why a shape should be managed by the redraw manager.
Thinker K.F. Li <thinker@branda.to>
parents:
393
diff
changeset
|
49 * shapes are valid when they are needed to update output. To make sure |
5791263ebe7b
Document for why a shape should be managed by the redraw manager.
Thinker K.F. Li <thinker@branda.to>
parents:
393
diff
changeset
|
50 * lifecycle of shapes are synchronized with status of a redraw manager, |
5791263ebe7b
Document for why a shape should be managed by the redraw manager.
Thinker K.F. Li <thinker@branda.to>
parents:
393
diff
changeset
|
51 * lifecycle of shapes are managed by associated redraw manager. |
257
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
52 * |
27 | 53 */ |
54 | |
101 | 55 /*! \defgroup shapes Shapes |
56 * @{ | |
57 */ | |
30
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
58 |
101 | 59 /*! \defgroup shape_path Shape of Path |
60 * @{ | |
61 */ | |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
62 extern shape_t *rdman_shape_path_new(redraw_man_t *rdman, char *data); |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
63 extern shape_t *rdman_shape_path_new_from_binary(redraw_man_t *rdman, |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
64 char *commands, |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
65 co_aix *pnts, |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
66 int pnt_cnt, |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
67 co_aix *float_args, |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
68 int float_arg_cnt); |
12 | 69 extern void sh_path_transform(shape_t *shape); |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
444
diff
changeset
|
70 extern void sh_path_draw(shape_t *shape, mbe_t *cr); |
101 | 71 /* @} */ |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
72 |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
462
diff
changeset
|
73 #ifdef SH_TEXT |
101 | 74 /*! \defgroup shape_text Shape of Text |
75 * @{ | |
76 */ | |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
77 extern shape_t *rdman_shape_text_new(redraw_man_t *rdman, |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
78 const char *txt, co_aix x, co_aix y, |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
79 co_aix font_size, |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
444
diff
changeset
|
80 mbe_font_face_t *face,PangoAttrList *attrs); |
293 | 81 /*! \brief Change the content of the text element. |
82 * 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 | |
83 * text segement as a single string. The attribute of these characters are saved in a seperate data structure. In the program level, we will | |
84 * not keep the SVG text tree. Instead, all attributes will be expanded into a list. | |
85 * | |
86 * 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 | |
87 * them seperately. | |
88 * | |
89 */ | |
88
dd813dcc232c
New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
73
diff
changeset
|
90 extern void sh_text_set_text(shape_t *shape, const char *txt); |
293 | 91 |
27 | 92 extern void sh_text_transform(shape_t *shape); |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
444
diff
changeset
|
93 extern void sh_text_draw(shape_t *shape, mbe_t *cr); |
101 | 94 /* @} */ |
472
4254eaa699d0
Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents:
462
diff
changeset
|
95 #endif |
27 | 96 |
278
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
97 /*! \defgroup mb_text_t Shape of Text |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
98 * @{ |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
99 */ |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
100 #define TEXTSTYLE_BOLD 1 |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
101 #define TEXTSTYLE_ITALIC 2 |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
102 #define TEXTSTYLE_UNDERLINE 4 |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
103 #define TEXTSTYLE_COLOR 8 |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
104 #define TEXTSTYLE_FONT 0x10 |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
105 #define TEXTSTYLE_ALIGN 0x20 |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
106 |
291
137a73822d48
Add sh_text_set_style support to change the style of text element.
wycc
parents:
280
diff
changeset
|
107 |
137a73822d48
Add sh_text_set_style support to change the style of text element.
wycc
parents:
280
diff
changeset
|
108 #define TEXTALIGN_START 1 |
137a73822d48
Add sh_text_set_style support to change the style of text element.
wycc
parents:
280
diff
changeset
|
109 #define TEXTALIGN_MIDDLE 2 |
137a73822d48
Add sh_text_set_style support to change the style of text element.
wycc
parents:
280
diff
changeset
|
110 #define TEXTALIGN_END 3 |
137a73822d48
Add sh_text_set_style support to change the style of text element.
wycc
parents:
280
diff
changeset
|
111 |
278
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
112 typedef struct { |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
113 int property; |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
114 unsigned int color; |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
115 unsigned int align; |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
116 char *font; |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
117 } mb_textstyle_t; |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
118 |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
119 typedef struct _textsegment { |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
120 int x; |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
121 int y; |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
122 mb_textstyle_t style; |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
123 int size; |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
124 char *buf; |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
125 struct _textsegment *next; |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
126 } mb_text_segment_t; |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
127 |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
128 #define MBTEXT_DIRTY 1 |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
129 |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
130 typedef struct { |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
131 int nseg; |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
132 mb_text_segment_t *segs; |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
133 int flag; |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
444
diff
changeset
|
134 mbe_surface_t *surface; |
278
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
135 } mb_text_t; |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
136 |
293 | 137 /*! \brief Change the style of the text. |
138 * | |
139 * 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 | |
140 * will be applied to the whole text field. The @style should be initialized by using the mb_textstyle_xxx functions. All attributes | |
141 * which is not initialized will not be changed. It means that the @style will be added into all existing style instead of reaplcing | |
142 * it. | |
143 */ | |
291
137a73822d48
Add sh_text_set_style support to change the style of text element.
wycc
parents:
280
diff
changeset
|
144 extern void sh_text_set_style(shape_t *shape,int begin,int end,mb_textstyle_t *format); |
293 | 145 /*! \brief Change the color of the text field |
146 * Change the color of the whole text field. This will removed all existing color attribute. If you want to change part of the text | |
147 * field only, please use the sh_text_set_style instead. | |
148 */ | |
292 | 149 extern void sh_text_set_color(shape_t *shape, unsigned color); |
293 | 150 /*! \brief Turn on/off the bold attribute. |
151 * 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 | |
152 * field only, please use the sh_text_set_style instead. | |
153 */ | |
292 | 154 extern void sh_text_set_bold(shape_t *shape, int bold); |
293 | 155 /*! \brief Turn on/off the italic attribute. |
156 * 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 | |
157 * field only, please use the sh_text_set_style instead. | |
158 */ | |
292 | 159 extern void sh_text_set_italic(shape_t *shape, int italic); |
293 | 160 /*! \brief Turn on/off the underline attribute. |
161 * 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 | |
162 * field only, please use the sh_text_set_style instead. | |
163 */ | |
292 | 164 extern void sh_text_set_underline(shape_t *shape, int underline); |
293 | 165 /*! \brief Change the font of the text field. |
166 * Change the font of the whole text field. This will removed all existing underline setting. If you want to change part of the text | |
167 * field only, please use the sh_text_set_style instead. | |
168 */ | |
292 | 169 extern void sh_text_set_font(shape_t *shape, char *family); |
293 | 170 /*! \brief Init the text style data structure. |
171 * | |
172 * This is usually used to initialize the mb_textstyle_t which is allocate in the stack. It will mark all property as undefined. All undefined | |
173 * property will not change when the sh_text_set_style is called. | |
174 * | |
175 */ | |
291
137a73822d48
Add sh_text_set_style support to change the style of text element.
wycc
parents:
280
diff
changeset
|
176 static inline void mb_textstyle_init(mb_textstyle_t *style) |
137a73822d48
Add sh_text_set_style support to change the style of text element.
wycc
parents:
280
diff
changeset
|
177 { |
137a73822d48
Add sh_text_set_style support to change the style of text element.
wycc
parents:
280
diff
changeset
|
178 style->property = 0; |
137a73822d48
Add sh_text_set_style support to change the style of text element.
wycc
parents:
280
diff
changeset
|
179 } |
462
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
458
diff
changeset
|
180 /*! \brief Get the dimension of the text |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
458
diff
changeset
|
181 */ |
af4b506ad56f
Add backend layer to seperate the backend with the MBAF. Currently, X is the only backend. If we have more than one backend, we need to modify the Makefile to sleect the backend or implement a backend selection mechanism in the runtime.
wycc@122-116-38-188.HINET-IP.hinet.net
parents:
458
diff
changeset
|
182 extern void sh_text_get_size(shape_t *sh, int *w, int *h); |
278
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
183 extern void mb_textstyle_set_font(mb_textstyle_t *style, char *font); |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
184 static inline char *mb_textstyle_get_font(mb_textstyle_t *style) |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
185 { |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
186 if (style->property & TEXTSTYLE_FONT) |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
187 return style->font; |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
188 else |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
189 return NULL; |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
190 } |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
191 extern void mb_textstyle_set_bold(mb_textstyle_t *style, int bold); |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
192 static inline int mb_textstyle_get_bold(mb_textstyle_t *style) |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
193 { |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
194 return style->property & TEXTSTYLE_BOLD; |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
195 } |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
196 extern void mb_textstyle_set_italic(mb_textstyle_t *style, int italic); |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
197 static inline int mb_textstyle_get_italic(mb_textstyle_t *style) |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
198 { |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
199 return style->property & TEXTSTYLE_ITALIC; |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
200 } |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
201 extern void mb_textstyle_set_underline(mb_textstyle_t *style, int underline); |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
202 static inline int mb_textstyle_get_undeline(mb_textstyle_t *style) |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
203 { |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
204 return style->property & TEXTSTYLE_UNDERLINE; |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
205 } |
291
137a73822d48
Add sh_text_set_style support to change the style of text element.
wycc
parents:
280
diff
changeset
|
206 #define TEXTCOLOR_RED(c) (((c)&0xff0000)>>16) |
137a73822d48
Add sh_text_set_style support to change the style of text element.
wycc
parents:
280
diff
changeset
|
207 #define TEXTCOLOR_GREEN(c) (((c)&0xff00)>>8) |
137a73822d48
Add sh_text_set_style support to change the style of text element.
wycc
parents:
280
diff
changeset
|
208 #define TEXTCOLOR_BLUE(c) (((c)&0xff)) |
137a73822d48
Add sh_text_set_style support to change the style of text element.
wycc
parents:
280
diff
changeset
|
209 #define TEXTCOLOR_RGB(r,g,b) (((r)<<16)|((g)<<8)|(b)) |
137a73822d48
Add sh_text_set_style support to change the style of text element.
wycc
parents:
280
diff
changeset
|
210 static inline void mb_textstyle_set_color(mb_textstyle_t *style, unsigned int color) |
137a73822d48
Add sh_text_set_style support to change the style of text element.
wycc
parents:
280
diff
changeset
|
211 { |
137a73822d48
Add sh_text_set_style support to change the style of text element.
wycc
parents:
280
diff
changeset
|
212 style->property |= TEXTSTYLE_COLOR; |
137a73822d48
Add sh_text_set_style support to change the style of text element.
wycc
parents:
280
diff
changeset
|
213 style->color = color; |
137a73822d48
Add sh_text_set_style support to change the style of text element.
wycc
parents:
280
diff
changeset
|
214 } |
278
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
215 static inline unsigned int mb_textstyle_get_color(mb_textstyle_t *style) |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
216 { |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
217 if (style->property & TEXTSTYLE_COLOR) |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
218 return style->color; |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
219 else |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
220 return 0; |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
221 } |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
222 |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
223 static inline int mb_textstyle_has_color(mb_textstyle_t *style) |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
224 { |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
225 return style->property & TEXTSTYLE_COLOR; |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
226 } |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
227 extern void mb_textstyle_set_alignment(mb_textstyle_t *style, int alignment); |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
228 extern int mb_textstyle_get_alignment(mb_textstyle_t *style); |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
229 |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
230 |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
231 |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
232 extern void mb_text_set_style(mb_text_t *text, int begin,int end,mb_textstyle_t *style); |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
233 extern void mb_text_get_style(mb_text_t *text, int n,mb_textstyle_t *style); |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
234 extern void mb_text_set_text(mb_text_t *text, char *string,int begin,int end); |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
235 extern void mb_text_get_text(mb_text_t *text, int begin,int end, char *string); |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
236 |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
237 /* @} */ |
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
197
diff
changeset
|
238 |
101 | 239 /*! \defgroup shape_rect Shape of Rectangle |
240 * @{ | |
241 */ | |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
242 extern shape_t *rdman_shape_rect_new(redraw_man_t *rdman, |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
243 co_aix x, co_aix y, |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
244 co_aix w, co_aix h, |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
245 co_aix rx, co_aix ry); |
35
581a03196093
Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents:
33
diff
changeset
|
246 extern void sh_rect_transform(shape_t *shape); |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
444
diff
changeset
|
247 extern void sh_rect_draw(shape_t *shape, mbe_t *cr); |
40 | 248 extern void sh_rect_set(shape_t *shape, co_aix x, co_aix y, |
249 co_aix w, co_aix h, co_aix rx, co_aix ry); | |
101 | 250 /* @} */ |
257
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
251 |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
252 /*! \defgroup shape_image Shape of Image |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
253 * @{ |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
254 */ |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
255 extern shape_t *rdman_shape_image_new(redraw_man_t *rdman, |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
256 co_aix x, co_aix y, |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
257 co_aix w, co_aix h); |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
258 extern void sh_image_transform(shape_t *shape); |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
444
diff
changeset
|
259 extern void sh_image_draw(shape_t *shape, mbe_t *cr); |
265
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
260 extern void sh_image_set_geometry(shape_t *shape, co_aix x, co_aix y, |
b42ee279669e
Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents:
260
diff
changeset
|
261 co_aix w, co_aix h); |
257
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
262 /* @} */ |
393
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
263 |
444
12b117b19c2a
Change title of shape_stext group
Thinker K.F. Li <thinker@branda.to>
parents:
429
diff
changeset
|
264 /*! \defgroup shape_stext Shape of Simple Text |
393
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
265 * @{ |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
266 */ |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
267 |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
268 /*! \defgroup font_face Define font face used to describe style of text. |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
269 * @{ |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
270 */ |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
271 /*! \brief Font face of MadButterfly. |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
272 * |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
444
diff
changeset
|
273 * It actully a mbe_font_face_t, now. But, it can be change for latter. |
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
444
diff
changeset
|
274 * So, programmer should not depend on mbe_font_face_t. |
393
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
275 */ |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
276 typedef struct _mb_font_face mb_font_face_t; |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
277 |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
278 enum MB_FONT_SLANTS { |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
279 MB_FONT_SLANT_DUMMY, |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
280 MB_FONT_SLANT_ROMAN, |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
281 MB_FONT_SLANT_ITALIC, |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
282 MB_FONT_SLANT_OBLIQUE, |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
283 MB_FONT_SLANT_MAX |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
284 }; |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
285 |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
286 extern mb_font_face_t *mb_font_face_query(redraw_man_t *rdman, |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
287 const char *family, |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
288 int slant, |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
289 int weight); |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
290 extern void mb_font_face_free(mb_font_face_t *face); |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
291 /* @} */ |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
292 |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
293 /*! \brief Describe style of a block of text. |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
294 * |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
295 * \ref sh_stext_t describes style of a text by a list of |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
296 * \ref mb_style_blk_t. |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
297 */ |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
298 typedef struct { |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
299 int n_chars; |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
300 mb_font_face_t *face; |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
301 co_aix font_sz; |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
302 } mb_style_blk_t; |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
303 |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
304 extern shape_t *rdman_shape_stext_new(redraw_man_t *rdman, |
429
9d5506968efb
Change the interface of rdman_shape_stext_new().
Thinker K.F. Li <thinker@branda.to>
parents:
416
diff
changeset
|
305 const char *txt, |
9d5506968efb
Change the interface of rdman_shape_stext_new().
Thinker K.F. Li <thinker@branda.to>
parents:
416
diff
changeset
|
306 co_aix x, co_aix y); |
393
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
307 extern void sh_stext_transform(shape_t *shape); |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
444
diff
changeset
|
308 extern void sh_stext_draw(shape_t *shape, mbe_t *cr); |
393
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
309 extern int sh_stext_set_text(shape_t *shape, const char *txt); |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
310 extern int sh_stext_set_style(shape_t *shape, |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
311 const mb_style_blk_t *blks, |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
312 int nblks); |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
313 |
27774b93521e
Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents:
356
diff
changeset
|
314 /* @} */ |
101 | 315 /* @} */ |
27 | 316 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
317 #endif /* __SHAPES_H_ */ |