comparison src/shape_text.c @ 292:7270e368ee98

Add more text API
author wycc
date Sun, 01 Feb 2009 02:14:45 +0800
parents 137a73822d48
children 2ca0773cd48d
comparison
equal deleted inserted replaced
291:137a73822d48 292:7270e368ee98
79 buf = strdup(txt); 79 buf = strdup(txt);
80 if(text->data) free(text->data); 80 if(text->data) free(text->data);
81 text->data = buf; 81 text->data = buf;
82 } 82 }
83 83
84 void sh_text_set_color(shape_t *shape, unsigned int color)
85 {
86 PangoAttribute *attr = pango_attr_color_new(color);
87 sh_text_t *text = (sh_text_t *)shape;
88 attr->begin_index = 0;
89 attr->end_index = -1;
90 pango_attr_list_change(text->attrs, attr);
91 }
92 void sh_text_set_bold(shape_t *shape,int bold)
93 {
94 PangoAttribute *attr = pango_attr_weight_new(bold? PANGO_WEIGHT_BOLD:PANGO_WEIGHT_NORMAL);
95 sh_text_t *text = (sh_text_t *)shape;
96 attr->begin_index = 0;
97 attr->end_index = -1;
98 pango_attr_list_change(text->attrs, attr);
99 }
100 void sh_text_set_italic(shape_t *shape,int italic)
101 {
102 PangoAttribute *attr = pango_attr_style_new(italic? PANGO_STYLE_ITALIC:PANGO_STYLE_NORMAL);
103 sh_text_t *text = (sh_text_t *)shape;
104 attr->begin_index = 0;
105 attr->end_index = -1;
106 pango_attr_list_change(text->attrs, attr);
107 }
108 void sh_text_set_underline(shape_t *shape,int underline)
109 {
110 PangoAttribute *attr = pango_attr_underline_new(underline? PANGO_UNDERLINE_SINGLE:PANGO_UNDERLINE_NONE);
111 sh_text_t *text = (sh_text_t *)shape;
112 attr->begin_index = 0;
113 attr->end_index = -1;
114 pango_attr_list_change(text->attrs, attr);
115 }
116 void sh_text_set_font(shape_t *shape,char *family)
117 {
118 PangoAttribute *attr = pango_attr_family_new(family);
119 sh_text_t *text = (sh_text_t *)shape;
120 attr->begin_index = 0;
121 attr->end_index = -1;
122 pango_attr_list_change(text->attrs, attr);
123 }
124
84 void sh_text_set_style(shape_t *shape,int begin,int end,mb_textstyle_t *format) 125 void sh_text_set_style(shape_t *shape,int begin,int end,mb_textstyle_t *format)
85 { 126 {
86 PangoAttribute *attr; 127 PangoAttribute *attr;
87 sh_text_t *text = (sh_text_t *)shape; 128 sh_text_t *text = (sh_text_t *)shape;
88 129