annotate include/mb_shapes.h @ 1380:76d2aad5da35

Implement runToScene method for the Flash-like animation.
author wycc
date Wed, 23 Mar 2011 00:33:51 +0800
parents bae104d8d247
children
rev   line source
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 492
diff changeset
1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*-
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 492
diff changeset
2 // vim: sw=4:ts=8:sts=4
101
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
3 /*! \file
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
4 * \brief Declare interfaces of shapes.
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
5 *
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
6 * \todo Add ellipse shape.
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
7 * \todo Add circle shape.
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
8 */
5
9c331ec9e210 SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
9 #ifndef __SHAPES_H_
9c331ec9e210 SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
10 #define __SHAPES_H_
9c331ec9e210 SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
11
473
ba64f928542b Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents: 472
diff changeset
12 #include "mb_config.h"
ba64f928542b Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents: 472
diff changeset
13
ba64f928542b Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents: 472
diff changeset
14 #ifdef SH_TEXT
ba64f928542b Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents: 472
diff changeset
15 #include <pango/pangocairo.h>
ba64f928542b Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents: 472
diff changeset
16 #endif
ba64f928542b Remove mbe_matrix_t type.
Thinker K.F. Li <thinker@branda.to>
parents: 472
diff changeset
17
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 444
diff changeset
18 #include "mb_graph_engine.h"
5
9c331ec9e210 SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
19 #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
20 #include "mb_redraw_man.h"
257
50d253d0fcba Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents: 197
diff changeset
21 #include "mb_img_ldr.h"
5
9c331ec9e210 SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
22
101
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
23 /*! \page define_shape How to Define Shapes
27
19c603dd6ff9 Add text shape.
Thinker K.F. Li <thinker@branda.to>
parents: 22
diff changeset
24 *
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
25 * 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
26 * - rdman_shape_*_new()
35
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 33
diff changeset
27 * - 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
28 * - 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
29 * - 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
30 * - make new object been managed by a redraw manager.
1062
a8d20bc8ce40 Rename rdman_shape_man() to rdman_man_shape() to mean managing a shape
Thinker K.F. Li <thinker@codemud.net>
parents: 822
diff changeset
31 * - call rdman_man_shape()
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
32 * - *_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
33 * - assigned to \ref shape_t::free.
27
19c603dd6ff9 Add text shape.
Thinker K.F. Li <thinker@branda.to>
parents: 22
diff changeset
34 * - *_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
35 * - *_draw()
260
29acbd8a0dd0 Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents: 257
diff changeset
36 * - *_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
37 * or stroked is defined by paint.
108
565b55508c8d More dox
Thinker K.F. Li <thinker@branda.to>
parents: 101
diff changeset
38 * - first member variable of a shape type must be a shape_t.
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 492
diff changeset
39 *
35
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 33
diff changeset
40 * Must modify
101
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
41 * - event.c::draw_shape_path()
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
42 * - redraw_man.c::clean_shape()
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
43 * - redraw_man.c::draw_shape()
257
50d253d0fcba Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents: 197
diff changeset
44 *
50d253d0fcba Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents: 197
diff changeset
45 * \section shape_transform Shape Transform
50d253d0fcba Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents: 197
diff changeset
46 *
50d253d0fcba Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents: 197
diff changeset
47 * 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
48 * 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
49 * 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
50 * 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
51 *
5791263ebe7b Document for why a shape should be managed by the redraw manager.
Thinker K.F. Li <thinker@branda.to>
parents: 393
diff changeset
52 * \section rdman_man_shape Make a redraw manager managing a shape.
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 492
diff changeset
53 *
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
54 * 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
55 * 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
56 * 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
57 * 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
58 * 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
59 * lifecycle of shapes are managed by associated redraw manager.
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 492
diff changeset
60 *
27
19c603dd6ff9 Add text shape.
Thinker K.F. Li <thinker@branda.to>
parents: 22
diff changeset
61 */
19c603dd6ff9 Add text shape.
Thinker K.F. Li <thinker@branda.to>
parents: 22
diff changeset
62
101
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
63 /*! \defgroup shapes Shapes
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
64 * @{
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
65 */
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
66
101
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
67 /*! \defgroup shape_path Shape of Path
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
68 * @{
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
69 */
492
e95598916dfb Make path data constant.
Thinker K.F. Li <thinker@branda.to>
parents: 473
diff changeset
70 extern shape_t *rdman_shape_path_new(redraw_man_t *rdman, const char *data);
458
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 448
diff changeset
71 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
72 char *commands,
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 448
diff changeset
73 co_aix *pnts,
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 448
diff changeset
74 int pnt_cnt,
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 448
diff changeset
75 co_aix *float_args,
bb4f651090bf Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents: 448
diff changeset
76 int float_arg_cnt);
1370
bae104d8d247 Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents: 1062
diff changeset
77 extern shape_t *rdman_shape_path_clone(redraw_man_t *rdman,
bae104d8d247 Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents: 1062
diff changeset
78 const shape_t *src_path);
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents: 5
diff changeset
79 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
80 extern void sh_path_draw(shape_t *shape, mbe_t *cr);
101
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
81 /* @} */
5
9c331ec9e210 SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
82
472
4254eaa699d0 Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents: 462
diff changeset
83 #ifdef SH_TEXT
101
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
84 /*! \defgroup shape_text Shape of Text
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
85 * @{
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
86 */
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
87 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
88 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
89 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
90 mbe_font_face_t *face,PangoAttrList *attrs);
293
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
91 /*! \brief Change the content of the text element.
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 492
diff changeset
92 * 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
293
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
93 * text segement as a single string. The attribute of these characters are saved in a seperate data structure. In the program level, we will
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 492
diff changeset
94 * not keep the SVG text tree. Instead, all attributes will be expanded into a list.
293
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
95 *
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 492
diff changeset
96 * 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
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 492
diff changeset
97 * them seperately.
293
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
98 *
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
99 */
88
dd813dcc232c New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents: 73
diff changeset
100 extern void sh_text_set_text(shape_t *shape, const char *txt);
293
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
101
27
19c603dd6ff9 Add text shape.
Thinker K.F. Li <thinker@branda.to>
parents: 22
diff changeset
102 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
103 extern void sh_text_draw(shape_t *shape, mbe_t *cr);
101
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
104 /* @} */
472
4254eaa699d0 Declare functions that should be implemented by Skia graphic engine
Thinker K.F. Li <thinker@branda.to>
parents: 462
diff changeset
105 #endif
27
19c603dd6ff9 Add text shape.
Thinker K.F. Li <thinker@branda.to>
parents: 22
diff changeset
106
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
107 /*! \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
108 * @{
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 */
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 #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
111 #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
112 #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
113 #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
114 #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
115 #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
116
291
137a73822d48 Add sh_text_set_style support to change the style of text element.
wycc
parents: 280
diff changeset
117
137a73822d48 Add sh_text_set_style support to change the style of text element.
wycc
parents: 280
diff changeset
118 #define TEXTALIGN_START 1
137a73822d48 Add sh_text_set_style support to change the style of text element.
wycc
parents: 280
diff changeset
119 #define TEXTALIGN_MIDDLE 2
137a73822d48 Add sh_text_set_style support to change the style of text element.
wycc
parents: 280
diff changeset
120 #define TEXTALIGN_END 3
137a73822d48 Add sh_text_set_style support to change the style of text element.
wycc
parents: 280
diff changeset
121
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
122 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
123 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
124 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
125 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
126 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
127 } 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
128
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 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
130 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
131 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
132 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
133 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
134 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
135 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
136 } 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
137
a90fd749af82 Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents: 197
diff changeset
138 #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
139
a90fd749af82 Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents: 197
diff changeset
140 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
141 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
142 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
143 int flag;
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 444
diff changeset
144 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
145 } 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
146
293
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
147 /*! \brief Change the style of the text.
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
148 *
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 492
diff changeset
149 * 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
293
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
150 * 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
151 * 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
152 * it.
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
153 */
291
137a73822d48 Add sh_text_set_style support to change the style of text element.
wycc
parents: 280
diff changeset
154 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
155 /*! \brief Change the color of the text field
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 492
diff changeset
156 * Change the color of the whole text field. This will removed all existing color attribute. If you want to change part of the text
293
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
157 * field only, please use the sh_text_set_style instead.
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
158 */
292
7270e368ee98 Add more text API
wycc
parents: 291
diff changeset
159 extern void sh_text_set_color(shape_t *shape, unsigned color);
293
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
160 /*! \brief Turn on/off the bold attribute.
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 492
diff changeset
161 * 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
293
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
162 * field only, please use the sh_text_set_style instead.
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
163 */
292
7270e368ee98 Add more text API
wycc
parents: 291
diff changeset
164 extern void sh_text_set_bold(shape_t *shape, int bold);
293
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
165 /*! \brief Turn on/off the italic attribute.
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 492
diff changeset
166 * 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
293
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
167 * field only, please use the sh_text_set_style instead.
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
168 */
292
7270e368ee98 Add more text API
wycc
parents: 291
diff changeset
169 extern void sh_text_set_italic(shape_t *shape, int italic);
293
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
170 /*! \brief Turn on/off the underline attribute.
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 492
diff changeset
171 * 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
293
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
172 * field only, please use the sh_text_set_style instead.
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
173 */
292
7270e368ee98 Add more text API
wycc
parents: 291
diff changeset
174 extern void sh_text_set_underline(shape_t *shape, int underline);
293
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
175 /*! \brief Change the font of the text field.
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 492
diff changeset
176 * Change the font of the whole text field. This will removed all existing underline setting. If you want to change part of the text
293
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
177 * field only, please use the sh_text_set_style instead.
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
178 */
292
7270e368ee98 Add more text API
wycc
parents: 291
diff changeset
179 extern void sh_text_set_font(shape_t *shape, char *family);
293
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
180 /*! \brief Init the text style data structure.
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
181 *
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
182 * 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
183 * property will not change when the sh_text_set_style is called.
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
184 *
a171b94582ae Add document for TextField API.
wycc
parents: 292
diff changeset
185 */
291
137a73822d48 Add sh_text_set_style support to change the style of text element.
wycc
parents: 280
diff changeset
186 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
187 {
137a73822d48 Add sh_text_set_style support to change the style of text element.
wycc
parents: 280
diff changeset
188 style->property = 0;
137a73822d48 Add sh_text_set_style support to change the style of text element.
wycc
parents: 280
diff changeset
189 }
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
190 /*! \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
191 */
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
192 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
193 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
194 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
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 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
197 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
198 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
199 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
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_bold(mb_textstyle_t *style, int bold);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 492
diff changeset
202 static inline int mb_textstyle_get_bold(mb_textstyle_t *style)
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
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_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
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 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
207 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
208 {
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 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
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 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
212 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
213 {
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 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
215 }
291
137a73822d48 Add sh_text_set_style support to change the style of text element.
wycc
parents: 280
diff changeset
216 #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
217 #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
218 #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
219 #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
220 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
221 {
137a73822d48 Add sh_text_set_style support to change the style of text element.
wycc
parents: 280
diff changeset
222 style->property |= TEXTSTYLE_COLOR;
137a73822d48 Add sh_text_set_style support to change the style of text element.
wycc
parents: 280
diff changeset
223 style->color = color;
137a73822d48 Add sh_text_set_style support to change the style of text element.
wycc
parents: 280
diff changeset
224 }
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
225 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
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 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
228 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
229 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
230 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
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
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 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
234 {
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 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
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 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
238 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
239
a90fd749af82 Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents: 197
diff changeset
240
a90fd749af82 Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents: 197
diff changeset
241
a90fd749af82 Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents: 197
diff changeset
242 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
243 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
244 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
245 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
246
a90fd749af82 Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents: 197
diff changeset
247 /* @} */
a90fd749af82 Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents: 197
diff changeset
248
101
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
249 /*! \defgroup shape_rect Shape of Rectangle
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
250 * @{
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
251 */
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
252 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
253 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
254 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
255 co_aix rx, co_aix ry);
1370
bae104d8d247 Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents: 1062
diff changeset
256 extern shape_t *rdman_shape_rect_clone(redraw_man_t *rdman,
bae104d8d247 Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents: 1062
diff changeset
257 const shape_t *src_rect);
35
581a03196093 Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents: 33
diff changeset
258 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
259 extern void sh_rect_draw(shape_t *shape, mbe_t *cr);
40
Thinker K.F. Li <thinker@branda.to>
parents: 35
diff changeset
260 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
261 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
262 /* @} */
257
50d253d0fcba Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents: 197
diff changeset
263
50d253d0fcba Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents: 197
diff changeset
264 /*! \defgroup shape_image Shape of Image
50d253d0fcba Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents: 197
diff changeset
265 * @{
50d253d0fcba Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents: 197
diff changeset
266 */
50d253d0fcba Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents: 197
diff changeset
267 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
268 co_aix x, co_aix y,
50d253d0fcba Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents: 197
diff changeset
269 co_aix w, co_aix h);
1370
bae104d8d247 Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents: 1062
diff changeset
270 extern shape_t *rdman_shape_image_clone(redraw_man_t *rdman,
bae104d8d247 Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents: 1062
diff changeset
271 const shape_t *src_img);
257
50d253d0fcba Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents: 197
diff changeset
272 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
273 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
274 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
275 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
276 /* @} */
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
277
444
12b117b19c2a Change title of shape_stext group
Thinker K.F. Li <thinker@branda.to>
parents: 429
diff changeset
278 /*! \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
279 * @{
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 */
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
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 /*! \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
283 * @{
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 /*! \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
286 *
448
16116d84bc5e Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents: 444
diff changeset
287 * 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
288 * 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
289 */
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 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
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 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
293 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
294 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
295 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
296 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
297 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
298 };
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
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 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
301 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
302 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
303 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
304 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
305 /* @} */
27774b93521e Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents: 356
diff changeset
306
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 /*! \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
308 *
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 * \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
310 * \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
311 */
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 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
313 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
314 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
315 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
316 } 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
317
27774b93521e Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents: 356
diff changeset
318 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
319 const char *txt,
9d5506968efb Change the interface of rdman_shape_stext_new().
Thinker K.F. Li <thinker@branda.to>
parents: 416
diff changeset
320 co_aix x, co_aix y);
1370
bae104d8d247 Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents: 1062
diff changeset
321 extern shape_t *rdman_shape_stext_clone(redraw_man_t *rdman,
bae104d8d247 Add clone functions for shape types
Thinker K.F. Li <thinker@codemud.net>
parents: 1062
diff changeset
322 const shape_t *_src_txt);
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
323 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
324 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
325 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
326 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
327 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
328 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
329
27774b93521e Add sh_stext_t to implement a simple version of text shape.
Thinker K.F. Li <thinker@branda.to>
parents: 356
diff changeset
330 /* @} */
101
d6f9af55b0d0 More documentation.
Thinker K.F. Li <thinker@branda.to>
parents: 95
diff changeset
331 /* @} */
27
19c603dd6ff9 Add text shape.
Thinker K.F. Li <thinker@branda.to>
parents: 22
diff changeset
332
5
9c331ec9e210 SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
333 #endif /* __SHAPES_H_ */