comparison include/mb_shapes.h @ 293:a171b94582ae

Add document for TextField API.
author wycc
date Sun, 01 Feb 2009 02:34:24 +0800
parents 7270e368ee98
children 6a1b36738d3d
comparison
equal deleted inserted replaced
292:7270e368ee98 293:a171b94582ae
61 */ 61 */
62 extern shape_t *rdman_shape_text_new(redraw_man_t *rdman, 62 extern shape_t *rdman_shape_text_new(redraw_man_t *rdman,
63 const char *txt, co_aix x, co_aix y, 63 const char *txt, co_aix x, co_aix y,
64 co_aix font_size, 64 co_aix font_size,
65 cairo_font_face_t *face,PangoAttrList *attrs); 65 cairo_font_face_t *face,PangoAttrList *attrs);
66 /*! \brief Change the content of the text element.
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
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
69 * not keep the SVG text tree. Instead, all attributes will be expanded into a list.
70 *
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
72 * them seperately.
73 *
74 */
66 extern void sh_text_set_text(shape_t *shape, const char *txt); 75 extern void sh_text_set_text(shape_t *shape, const char *txt);
76
67 extern void sh_text_transform(shape_t *shape); 77 extern void sh_text_transform(shape_t *shape);
68 extern void sh_text_draw(shape_t *shape, cairo_t *cr); 78 extern void sh_text_draw(shape_t *shape, cairo_t *cr);
69 /* @} */ 79 /* @} */
70 80
71 /*! \defgroup mb_text_t Shape of Text 81 /*! \defgroup mb_text_t Shape of Text
106 mb_text_segment_t *segs; 116 mb_text_segment_t *segs;
107 int flag; 117 int flag;
108 cairo_surface_t *surface; 118 cairo_surface_t *surface;
109 } mb_text_t; 119 } mb_text_t;
110 120
121 /*! \brief Change the style of the text.
122 *
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
124 * will be applied to the whole text field. The @style should be initialized by using the mb_textstyle_xxx functions. All attributes
125 * which is not initialized will not be changed. It means that the @style will be added into all existing style instead of reaplcing
126 * it.
127 */
111 extern void sh_text_set_style(shape_t *shape,int begin,int end,mb_textstyle_t *format); 128 extern void sh_text_set_style(shape_t *shape,int begin,int end,mb_textstyle_t *format);
129 /*! \brief Change the color of the text field
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
131 * field only, please use the sh_text_set_style instead.
132 */
112 extern void sh_text_set_color(shape_t *shape, unsigned color); 133 extern void sh_text_set_color(shape_t *shape, unsigned color);
134 /*! \brief Turn on/off the bold attribute.
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
136 * field only, please use the sh_text_set_style instead.
137 */
113 extern void sh_text_set_bold(shape_t *shape, int bold); 138 extern void sh_text_set_bold(shape_t *shape, int bold);
139 /*! \brief Turn on/off the italic attribute.
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
141 * field only, please use the sh_text_set_style instead.
142 */
114 extern void sh_text_set_italic(shape_t *shape, int italic); 143 extern void sh_text_set_italic(shape_t *shape, int italic);
144 /*! \brief Turn on/off the underline attribute.
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
146 * field only, please use the sh_text_set_style instead.
147 */
115 extern void sh_text_set_underline(shape_t *shape, int underline); 148 extern void sh_text_set_underline(shape_t *shape, int underline);
149 /*! \brief Change the font of the text field.
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
151 * field only, please use the sh_text_set_style instead.
152 */
116 extern void sh_text_set_font(shape_t *shape, char *family); 153 extern void sh_text_set_font(shape_t *shape, char *family);
154 /*! \brief Init the text style data structure.
155 *
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
157 * property will not change when the sh_text_set_style is called.
158 *
159 */
117 static inline void mb_textstyle_init(mb_textstyle_t *style) 160 static inline void mb_textstyle_init(mb_textstyle_t *style)
118 { 161 {
119 style->property = 0; 162 style->property = 0;
120 } 163 }
121 extern void mb_textstyle_set_font(mb_textstyle_t *style, char *font); 164 extern void mb_textstyle_set_font(mb_textstyle_t *style, char *font);