Mercurial > MadButterfly
comparison include/mb_shapes.h @ 278:a90fd749af82 mbtext
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
author | wycc |
---|---|
date | Sat, 31 Jan 2009 09:41:04 +0800 |
parents | bcad1ccdf45c |
children | c8b6ca46950b |
comparison
equal
deleted
inserted
replaced
277:5006e4abdda5 | 278:a90fd749af82 |
---|---|
8 #define __SHAPES_H_ | 8 #define __SHAPES_H_ |
9 | 9 |
10 #include <cairo.h> | 10 #include <cairo.h> |
11 #include "mb_types.h" | 11 #include "mb_types.h" |
12 #include "mb_redraw_man.h" | 12 #include "mb_redraw_man.h" |
13 #include <pango/pangocairo.h> | |
13 | 14 |
14 /*! \page define_shape How to Define Shapes | 15 /*! \page define_shape How to Define Shapes |
15 * | 16 * |
16 * A shape implementation must include | 17 * A shape implementation must include |
17 * - rdman_shape_*_new() | 18 * - rdman_shape_*_new() |
48 * @{ | 49 * @{ |
49 */ | 50 */ |
50 extern shape_t *rdman_shape_text_new(redraw_man_t *rdman, | 51 extern shape_t *rdman_shape_text_new(redraw_man_t *rdman, |
51 const char *txt, co_aix x, co_aix y, | 52 const char *txt, co_aix x, co_aix y, |
52 co_aix font_size, | 53 co_aix font_size, |
53 cairo_font_face_t *face); | 54 cairo_font_face_t *face,PangoAttrList *attrs); |
54 extern void sh_text_set_text(shape_t *shape, const char *txt); | 55 extern void sh_text_set_text(shape_t *shape, const char *txt); |
55 extern void sh_text_transform(shape_t *shape); | 56 extern void sh_text_transform(shape_t *shape); |
56 extern void sh_text_draw(shape_t *shape, cairo_t *cr); | 57 extern void sh_text_draw(shape_t *shape, cairo_t *cr); |
58 /* @} */ | |
59 | |
60 /*! \defgroup mb_text_t Shape of Text | |
61 * @{ | |
62 */ | |
63 #define TEXTSTYLE_BOLD 1 | |
64 #define TEXTSTYLE_ITALIC 2 | |
65 #define TEXTSTYLE_UNDERLINE 4 | |
66 #define TEXTSTYLE_COLOR 8 | |
67 #define TEXTSTYLE_FONT 0x10 | |
68 #define TEXTSTYLE_ALIGN 0x20 | |
69 | |
70 typedef struct { | |
71 int property; | |
72 unsigned int color; | |
73 unsigned int align; | |
74 char *font; | |
75 } mb_textstyle_t; | |
76 | |
77 typedef struct _textsegment { | |
78 int x; | |
79 int y; | |
80 mb_textstyle_t style; | |
81 int size; | |
82 char *buf; | |
83 struct _textsegment *next; | |
84 } mb_text_segment_t; | |
85 | |
86 #define MBTEXT_DIRTY 1 | |
87 | |
88 typedef struct { | |
89 int nseg; | |
90 mb_text_segment_t *segs; | |
91 int flag; | |
92 cairo_surface_t *surface; | |
93 } mb_text_t; | |
94 | |
95 extern void mb_textstyle_init(mb_textstyle_t *style); | |
96 extern void mb_textstyle_set_font(mb_textstyle_t *style, char *font); | |
97 static inline char *mb_textstyle_get_font(mb_textstyle_t *style) | |
98 { | |
99 if (style->property & TEXTSTYLE_FONT) | |
100 return style->font; | |
101 else | |
102 return NULL; | |
103 } | |
104 extern void mb_textstyle_set_bold(mb_textstyle_t *style, int bold); | |
105 static inline int mb_textstyle_get_bold(mb_textstyle_t *style) | |
106 { | |
107 return style->property & TEXTSTYLE_BOLD; | |
108 } | |
109 extern void mb_textstyle_set_italic(mb_textstyle_t *style, int italic); | |
110 static inline int mb_textstyle_get_italic(mb_textstyle_t *style) | |
111 { | |
112 return style->property & TEXTSTYLE_ITALIC; | |
113 } | |
114 extern void mb_textstyle_set_underline(mb_textstyle_t *style, int underline); | |
115 static inline int mb_textstyle_get_undeline(mb_textstyle_t *style) | |
116 { | |
117 return style->property & TEXTSTYLE_UNDERLINE; | |
118 } | |
119 extern void mb_textstyle_set_color(mb_textstyle_t *style, unsigned int color); | |
120 static inline unsigned int mb_textstyle_get_color(mb_textstyle_t *style) | |
121 { | |
122 if (style->property & TEXTSTYLE_COLOR) | |
123 return style->color; | |
124 else | |
125 return 0; | |
126 } | |
127 | |
128 static inline int mb_textstyle_has_color(mb_textstyle_t *style) | |
129 { | |
130 return style->property & TEXTSTYLE_COLOR; | |
131 } | |
132 extern void mb_textstyle_set_alignment(mb_textstyle_t *style, int alignment); | |
133 extern int mb_textstyle_get_alignment(mb_textstyle_t *style); | |
134 | |
135 | |
136 | |
137 extern void mb_text_set_style(mb_text_t *text, int begin,int end,mb_textstyle_t *style); | |
138 extern void mb_text_get_style(mb_text_t *text, int n,mb_textstyle_t *style); | |
139 extern void mb_text_set_text(mb_text_t *text, char *string,int begin,int end); | |
140 extern void mb_text_get_text(mb_text_t *text, int begin,int end, char *string); | |
141 | |
142 | |
57 /* @} */ | 143 /* @} */ |
58 | 144 |
59 /*! \defgroup shape_rect Shape of Rectangle | 145 /*! \defgroup shape_rect Shape of Rectangle |
60 * @{ | 146 * @{ |
61 */ | 147 */ |