annotate include/mb_shapes.h @ 376:7d244a85dd68

Change the screen layout to make it more like an usual IDE.
author wycc
date Sat, 04 Apr 2009 06:12:10 +0800
parents 3e84458968ec
children 27774b93521e
rev   line source
101
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
1 /*! \file
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
2 * \brief Declare interfaces of shapes.
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
3 *
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
4 * \todo Add ellipse shape.
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
5 * \todo Add circle shape.
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
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
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents: 5
diff changeset
10 #include <cairo.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"
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
14 #include <pango/pangocairo.h>
5
9c331ec9e210 SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
15
101
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
16 /*! \page define_shape How to Define Shapes
27
19c603dd6ff9 Add text shape.
Thinker K.F. Li <thinker@branda.to>
parents: 22
diff changeset
17 *
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
18 * 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
19 * - rdman_shape_*_new()
35
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 33
diff changeset
20 * - clear memory for shape_t member.
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
19c603dd6ff9 Add text shape.
Thinker K.F. Li <thinker@branda.to>
parents: 22
diff changeset
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
565b55508c8d More dox
Thinker K.F. Li <thinker@branda.to>
parents: 101
diff changeset
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
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
33 * - event.c::draw_shape_path()
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
34 * - redraw_man.c::clean_shape()
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
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.
50d253d0fcba Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents: 197
diff changeset
43 *
27
19c603dd6ff9 Add text shape.
Thinker K.F. Li <thinker@branda.to>
parents: 22
diff changeset
44 */
19c603dd6ff9 Add text shape.
Thinker K.F. Li <thinker@branda.to>
parents: 22
diff changeset
45
101
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
46 /*! \defgroup shapes Shapes
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
47 * @{
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
48 */
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
49
101
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
50 /*! \defgroup shape_path Shape of Path
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
51 * @{
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
52 */
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
53 extern shape_t *rdman_shape_path_new(redraw_man_t *rdman, char *data);
197
bcad1ccdf45c Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents: 186
diff changeset
54 extern shape_t *rdman_shape_path_new_from_binary(redraw_man_t *rdman, char *commands, co_aix *arg,int arg_cnt,int *fix_arg,int fix_arg_cnt);
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents: 5
diff changeset
55 extern void sh_path_transform(shape_t *shape);
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
56 extern void sh_path_draw(shape_t *shape, cairo_t *cr);
101
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
57 /* @} */
5
9c331ec9e210 SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
58
101
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
59 /*! \defgroup shape_text Shape of Text
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
60 * @{
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
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_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
63 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
64 co_aix font_size,
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
65 cairo_font_face_t *face,PangoAttrList *attrs);
293
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
66 /*! \brief Change the content of the text element.
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
67 * 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
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
68 * text segement as a single string. The attribute of these characters are saved in a seperate data structure. In the program level, we will
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
69 * not keep the SVG text tree. Instead, all attributes will be expanded into a list.
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
70 *
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
71 * 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
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
72 * them seperately.
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
73 *
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
74 */
88
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents: 73
diff changeset
75 extern void sh_text_set_text(shape_t *shape, const char *txt);
293
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
76
27
19c603dd6ff9 Add text shape.
Thinker K.F. Li <thinker@branda.to>
parents: 22
diff changeset
77 extern void sh_text_transform(shape_t *shape);
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
78 extern void sh_text_draw(shape_t *shape, cairo_t *cr);
101
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
79 /* @} */
27
19c603dd6ff9 Add text shape.
Thinker K.F. Li <thinker@branda.to>
parents: 22
diff changeset
80
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
81 /*! \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
82 * @{
a90fd749af82 Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents: 197
diff changeset
83 */
a90fd749af82 Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents: 197
diff changeset
84 #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
85 #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
86 #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
87 #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
88 #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
89 #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
90
291
137a73822d48 Add sh_text_set_style support to change the style of text element.
wycc
parents: 280
diff changeset
91
137a73822d48 Add sh_text_set_style support to change the style of text element.
wycc
parents: 280
diff changeset
92 #define TEXTALIGN_START 1
137a73822d48 Add sh_text_set_style support to change the style of text element.
wycc
parents: 280
diff changeset
93 #define TEXTALIGN_MIDDLE 2
137a73822d48 Add sh_text_set_style support to change the style of text element.
wycc
parents: 280
diff changeset
94 #define TEXTALIGN_END 3
137a73822d48 Add sh_text_set_style support to change the style of text element.
wycc
parents: 280
diff changeset
95
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
96 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
97 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
98 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
99 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
100 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
101 } 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
102
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 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
104 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
105 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
106 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
107 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
108 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
109 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
110 } 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
111
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 #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
113
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 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
115 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
116 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
117 int flag;
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 cairo_surface_t *surface;
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 } 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
120
293
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
121 /*! \brief Change the style of the text.
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
122 *
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
123 * 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
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
124 * will be applied to the whole text field. The @style should be initialized by using the mb_textstyle_xxx functions. All attributes
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
125 * which is not initialized will not be changed. It means that the @style will be added into all existing style instead of reaplcing
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
126 * it.
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
127 */
291
137a73822d48 Add sh_text_set_style support to change the style of text element.
wycc
parents: 280
diff changeset
128 extern void sh_text_set_style(shape_t *shape,int begin,int end,mb_textstyle_t *format);
293
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
129 /*! \brief Change the color of the text field
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
130 * Change the color of the whole text field. This will removed all existing color attribute. If you want to change part of the text
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
131 * field only, please use the sh_text_set_style instead.
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
132 */
292
7270e368ee98 Add more text API
wycc
parents: 291
diff changeset
133 extern void sh_text_set_color(shape_t *shape, unsigned color);
293
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
134 /*! \brief Turn on/off the bold attribute.
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
135 * 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
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
136 * field only, please use the sh_text_set_style instead.
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
137 */
292
7270e368ee98 Add more text API
wycc
parents: 291
diff changeset
138 extern void sh_text_set_bold(shape_t *shape, int bold);
293
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
139 /*! \brief Turn on/off the italic attribute.
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
140 * 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
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
141 * field only, please use the sh_text_set_style instead.
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
142 */
292
7270e368ee98 Add more text API
wycc
parents: 291
diff changeset
143 extern void sh_text_set_italic(shape_t *shape, int italic);
293
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
144 /*! \brief Turn on/off the underline attribute.
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
145 * 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
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
146 * field only, please use the sh_text_set_style instead.
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
147 */
292
7270e368ee98 Add more text API
wycc
parents: 291
diff changeset
148 extern void sh_text_set_underline(shape_t *shape, int underline);
293
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
149 /*! \brief Change the font of the text field.
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
150 * Change the font of the whole text field. This will removed all existing underline setting. If you want to change part of the text
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
151 * field only, please use the sh_text_set_style instead.
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
152 */
292
7270e368ee98 Add more text API
wycc
parents: 291
diff changeset
153 extern void sh_text_set_font(shape_t *shape, char *family);
293
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
154 /*! \brief Init the text style data structure.
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
155 *
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
156 * 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
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
157 * property will not change when the sh_text_set_style is called.
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
158 *
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
159 */
291
137a73822d48 Add sh_text_set_style support to change the style of text element.
wycc
parents: 280
diff changeset
160 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
161 {
137a73822d48 Add sh_text_set_style support to change the style of text element.
wycc
parents: 280
diff changeset
162 style->property = 0;
137a73822d48 Add sh_text_set_style support to change the style of text element.
wycc
parents: 280
diff changeset
163 }
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
164 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
165 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
166 {
a90fd749af82 Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents: 197
diff changeset
167 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
168 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
169 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
170 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
171 }
a90fd749af82 Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents: 197
diff changeset
172 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
173 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
174 {
a90fd749af82 Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents: 197
diff changeset
175 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
176 }
a90fd749af82 Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents: 197
diff changeset
177 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
178 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
179 {
a90fd749af82 Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents: 197
diff changeset
180 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
181 }
a90fd749af82 Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents: 197
diff changeset
182 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
183 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
184 {
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 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
186 }
291
137a73822d48 Add sh_text_set_style support to change the style of text element.
wycc
parents: 280
diff changeset
187 #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
188 #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
189 #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
190 #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
191 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
192 {
137a73822d48 Add sh_text_set_style support to change the style of text element.
wycc
parents: 280
diff changeset
193 style->property |= TEXTSTYLE_COLOR;
137a73822d48 Add sh_text_set_style support to change the style of text element.
wycc
parents: 280
diff changeset
194 style->color = color;
137a73822d48 Add sh_text_set_style support to change the style of text element.
wycc
parents: 280
diff changeset
195 }
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
196 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
197 {
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 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
199 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
200 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
201 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
202 }
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 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
205 {
a90fd749af82 Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents: 197
diff changeset
206 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
207 }
a90fd749af82 Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents: 197
diff changeset
208 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
209 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
210
a90fd749af82 Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents: 197
diff changeset
211
a90fd749af82 Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents: 197
diff changeset
212
a90fd749af82 Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents: 197
diff changeset
213 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
214 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
215 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
216 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
217
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
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 /* @} */
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
101
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
221 /*! \defgroup shape_rect Shape of Rectangle
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
222 * @{
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
223 */
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
224 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
225 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
226 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
227 co_aix rx, co_aix ry);
35
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 33
diff changeset
228 extern void sh_rect_transform(shape_t *shape);
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 33
diff changeset
229 extern void sh_rect_draw(shape_t *shape, cairo_t *cr);
40
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
230 extern void sh_rect_set(shape_t *shape, co_aix x, co_aix y,
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
231 co_aix w, co_aix h, co_aix rx, co_aix ry);
101
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
232 /* @} */
257
50d253d0fcba Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents: 197
diff changeset
233
50d253d0fcba Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents: 197
diff changeset
234 /*! \defgroup shape_image Shape of Image
50d253d0fcba Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents: 197
diff changeset
235 * @{
50d253d0fcba Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents: 197
diff changeset
236 */
50d253d0fcba Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents: 197
diff changeset
237 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
238 co_aix x, co_aix y,
50d253d0fcba Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents: 197
diff changeset
239 co_aix w, co_aix h);
50d253d0fcba Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents: 197
diff changeset
240 extern void sh_image_transform(shape_t *shape);
50d253d0fcba Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents: 197
diff changeset
241 extern void sh_image_draw(shape_t *shape, cairo_t *cr);
265
b42ee279669e Change function name and add comments.
Thinker K.F. Li <thinker@branda.to>
parents: 260
diff changeset
242 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
243 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
244 /* @} */
101
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
245 /* @} */
27
19c603dd6ff9 Add text shape.
Thinker K.F. Li <thinker@branda.to>
parents: 22
diff changeset
246
5
9c331ec9e210 SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
247 #endif /* __SHAPES_H_ */