Mercurial > MadButterfly
annotate include/mb_shapes.h @ 275:40c0c907c6dd
Add button placeholder
author | wycc |
---|---|
date | Thu, 29 Jan 2009 22:34:24 +0800 |
parents | b42ee279669e |
children | c8b6ca46950b |
rev | line source |
---|---|
101 | 1 /*! \file |
2 * \brief Declare interfaces of shapes. | |
3 * | |
4 * \todo Add ellipse shape. | |
5 * \todo Add circle shape. | |
6 */ | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
7 #ifndef __SHAPES_H_ |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
8 #define __SHAPES_H_ |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
9 |
12 | 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" |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
14 |
101 | 15 /*! \page define_shape How to Define Shapes |
27 | 16 * |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
17 * A shape implementation must include |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
108
diff
changeset
|
18 * - rdman_shape_*_new() |
35
581a03196093
Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents:
33
diff
changeset
|
19 * - clear memory for shape_t member. |
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
|
20 * - 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
|
21 * - 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
|
22 * - 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
|
23 * - *_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
|
24 * - assigned to \ref shape_t::free. |
27 | 25 * - *_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
|
26 * - *_draw() |
260
29acbd8a0dd0
Integrate sh_image with svg2code.py.
Thinker K.F. Li <thinker@branda.to>
parents:
257
diff
changeset
|
27 * - *_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
|
28 * or stroked is defined by paint. |
108 | 29 * - 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
|
30 * |
581a03196093
Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents:
33
diff
changeset
|
31 * Must modify |
101 | 32 * - event.c::draw_shape_path() |
33 * - redraw_man.c::clean_shape() | |
34 * - redraw_man.c::draw_shape() | |
257
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
35 * |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
36 * \section shape_transform Shape Transform |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
37 * |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
38 * 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
|
39 * 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
|
40 * 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
|
41 * update geo_t. |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
42 * |
27 | 43 */ |
44 | |
101 | 45 /*! \defgroup shapes Shapes |
46 * @{ | |
47 */ | |
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
|
48 |
101 | 49 /*! \defgroup shape_path Shape of Path |
50 * @{ | |
51 */ | |
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
|
52 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
|
53 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 | 54 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
|
55 extern void sh_path_draw(shape_t *shape, cairo_t *cr); |
101 | 56 /* @} */ |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
57 |
101 | 58 /*! \defgroup shape_text Shape of Text |
59 * @{ | |
60 */ | |
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
|
61 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
|
62 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
|
63 co_aix font_size, |
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 cairo_font_face_t *face); |
88
dd813dcc232c
New example, calculator.
Thinker K.F. Li <thinker@branda.to>
parents:
73
diff
changeset
|
65 extern void sh_text_set_text(shape_t *shape, const char *txt); |
27 | 66 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
|
67 extern void sh_text_draw(shape_t *shape, cairo_t *cr); |
101 | 68 /* @} */ |
27 | 69 |
101 | 70 /*! \defgroup shape_rect Shape of Rectangle |
71 * @{ | |
72 */ | |
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
|
73 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
|
74 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
|
75 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
|
76 co_aix rx, co_aix ry); |
35
581a03196093
Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents:
33
diff
changeset
|
77 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
|
78 extern void sh_rect_draw(shape_t *shape, cairo_t *cr); |
40 | 79 extern void sh_rect_set(shape_t *shape, co_aix x, co_aix y, |
80 co_aix w, co_aix h, co_aix rx, co_aix ry); | |
101 | 81 /* @} */ |
257
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
82 |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
83 /*! \defgroup shape_image Shape of Image |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
84 * @{ |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
85 */ |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
86 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
|
87 mb_img_data_t *img_data, |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
88 co_aix x, co_aix y, |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
89 co_aix w, co_aix h); |
50d253d0fcba
Simple image loader and image shape.
Thinker K.F. Li <thinker@branda.to>
parents:
197
diff
changeset
|
90 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
|
91 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
|
92 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
|
93 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
|
94 /* @} */ |
101 | 95 /* @} */ |
27 | 96 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
97 #endif /* __SHAPES_H_ */ |