comparison include/mb_shapes.h @ 291:137a73822d48

Add sh_text_set_style support to change the style of text element.
author wycc
date Sun, 01 Feb 2009 01:45:53 +0800
parents c8b6ca46950b
children 7270e368ee98
comparison
equal deleted inserted replaced
290:f65c4589549f 291:137a73822d48
76 #define TEXTSTYLE_UNDERLINE 4 76 #define TEXTSTYLE_UNDERLINE 4
77 #define TEXTSTYLE_COLOR 8 77 #define TEXTSTYLE_COLOR 8
78 #define TEXTSTYLE_FONT 0x10 78 #define TEXTSTYLE_FONT 0x10
79 #define TEXTSTYLE_ALIGN 0x20 79 #define TEXTSTYLE_ALIGN 0x20
80 80
81
82 #define TEXTALIGN_START 1
83 #define TEXTALIGN_MIDDLE 2
84 #define TEXTALIGN_END 3
85
81 typedef struct { 86 typedef struct {
82 int property; 87 int property;
83 unsigned int color; 88 unsigned int color;
84 unsigned int align; 89 unsigned int align;
85 char *font; 90 char *font;
101 mb_text_segment_t *segs; 106 mb_text_segment_t *segs;
102 int flag; 107 int flag;
103 cairo_surface_t *surface; 108 cairo_surface_t *surface;
104 } mb_text_t; 109 } mb_text_t;
105 110
106 extern void mb_textstyle_init(mb_textstyle_t *style); 111 extern void sh_text_set_style(shape_t *shape,int begin,int end,mb_textstyle_t *format);
112 static inline void mb_textstyle_init(mb_textstyle_t *style)
113 {
114 style->property = 0;
115 }
107 extern void mb_textstyle_set_font(mb_textstyle_t *style, char *font); 116 extern void mb_textstyle_set_font(mb_textstyle_t *style, char *font);
108 static inline char *mb_textstyle_get_font(mb_textstyle_t *style) 117 static inline char *mb_textstyle_get_font(mb_textstyle_t *style)
109 { 118 {
110 if (style->property & TEXTSTYLE_FONT) 119 if (style->property & TEXTSTYLE_FONT)
111 return style->font; 120 return style->font;
125 extern void mb_textstyle_set_underline(mb_textstyle_t *style, int underline); 134 extern void mb_textstyle_set_underline(mb_textstyle_t *style, int underline);
126 static inline int mb_textstyle_get_undeline(mb_textstyle_t *style) 135 static inline int mb_textstyle_get_undeline(mb_textstyle_t *style)
127 { 136 {
128 return style->property & TEXTSTYLE_UNDERLINE; 137 return style->property & TEXTSTYLE_UNDERLINE;
129 } 138 }
130 extern void mb_textstyle_set_color(mb_textstyle_t *style, unsigned int color); 139 #define TEXTCOLOR_RED(c) (((c)&0xff0000)>>16)
140 #define TEXTCOLOR_GREEN(c) (((c)&0xff00)>>8)
141 #define TEXTCOLOR_BLUE(c) (((c)&0xff))
142 #define TEXTCOLOR_RGB(r,g,b) (((r)<<16)|((g)<<8)|(b))
143 static inline void mb_textstyle_set_color(mb_textstyle_t *style, unsigned int color)
144 {
145 style->property |= TEXTSTYLE_COLOR;
146 style->color = color;
147 }
131 static inline unsigned int mb_textstyle_get_color(mb_textstyle_t *style) 148 static inline unsigned int mb_textstyle_get_color(mb_textstyle_t *style)
132 { 149 {
133 if (style->property & TEXTSTYLE_COLOR) 150 if (style->property & TEXTSTYLE_COLOR)
134 return style->color; 151 return style->color;
135 else 152 else