4
CTheme::CTheme(int _width, int _height)
4
CTheme::CTheme(int _width, int _height):
11
13
void CTheme::clear() {
16
cairo_surface_destroy(surface);
18
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
19
dc = cairo_create(surface);
14
if (dc) cairo_destroy(dc);
15
if (surface) cairo_surface_destroy(surface);
16
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
17
dc = cairo_create(surface);
21
20
cairo_surface_t *CTheme::PrintText(TThemeTxt *text) {
23
cairo_scale(dc, width/text->svg_width, height/text->svg_height);
24
cairo_select_font_face(dc, text->fontfamily, text->fontstyle, text->fontweight);
25
cairo_set_font_size(dc, text->fontsize);
26
cairo_move_to(dc, text->x, text->y);
27
cairo_text_extents(dc, text->text, &(text->extents));
28
cairo_move_to(dc, text->x - (text->extents.width - text->extents.width/text->scale)/2, text->y - (text->extents.height - text->extents.height/text->scale)/2);
29
cairo_set_font_size(dc, text->fontsize * text->scale);
30
cairo_text_path(dc, text->text);
31
if (text->fill_col.r != -1 && text->fill_col.g != -1 && text->fill_col.b != -1) {
32
cairo_set_source_rgba(dc, text->fill_col.r, text->fill_col.g, text->fill_col.b, text->fill_col.a);
33
if (text->stroke_col.r != -1 && text->stroke_col.g != -1 && text->stroke_col.b != -1)
34
cairo_fill_preserve(dc);
38
if (text->stroke_col.r != -1 && text->stroke_col.g != -1 && text->stroke_col.b != -1) {
39
cairo_set_line_width(dc, text->stroke_width);
40
cairo_set_source_rgba(dc, text->stroke_col.r, text->stroke_col.b, text->stroke_col.g, text->stroke_col.a);
21
PangoFontDescription *desc = pango_font_description_new();
22
PangoLayout *layout = pango_cairo_create_layout(dc);
23
pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER );
28
pango_font_description_set_family(desc, text->fontfamily.c_str());
29
pango_font_description_set_style (desc,PANGO_STYLE_NORMAL);
30
pango_font_description_set_absolute_size (desc,text->fontsize * PANGO_SCALE);
31
pango_layout_set_font_description (layout, desc);
32
pango_layout_set_text (layout, text->text.c_str(), -1);
33
pango_layout_get_pixel_extents (layout,NULL,&rec);
34
text->extents.width = rec.width;
35
text->extents.height = rec.height;
36
text->extents.x_advance = rec.width+rec.x;
37
text->extents.y_advance = rec.height+rec.y;
38
pango_font_description_set_absolute_size (desc,text->fontsize * text->scale * PANGO_SCALE);
39
pango_layout_set_font_description (layout, desc);
40
pango_cairo_update_layout (dc, layout);
41
cairo_scale(dc, width/text->svg_width, height/text->svg_height);
42
cairo_move_to(dc,text->x - (rec.width-rec.width/text->scale)/2,text->y-text->fontsize * text->scale);
43
pango_cairo_show_layout (dc, layout);
44
pango_cairo_layout_path(dc,layout);
45
if (text->fill_col.r != -1 && text->fill_col.g != -1 && text->fill_col.b != -1) {
46
cairo_set_source_rgba(dc, text->fill_col.r, text->fill_col.g, text->fill_col.b, text->fill_col.a);
47
if (text->stroke_col.r != -1 && text->stroke_col.g != -1 && text->stroke_col.b != -1) cairo_fill_preserve(dc);
50
if (text->stroke_col.r != -1 && text->stroke_col.g != -1 && text->stroke_col.b != -1) {
51
cairo_set_line_width(dc, text->stroke_width);
52
cairo_set_source_rgba(dc, text->stroke_col.r, text->stroke_col.g, text->stroke_col.b, text->stroke_col.a);
57
g_object_unref(layout);
58
pango_font_description_free(desc);
46
62
cairo_surface_t *CTheme::DrawRect(TThemeRect rect) {
48
cairo_scale(dc, width/rect.svg_width, height/rect.svg_height);
49
cairo_rectangle(dc, rect.x, rect.y, rect.width, rect.height);
50
if (rect.fill_col.r != -1 && rect.fill_col.g != -1 && rect.fill_col.b != -1) {
51
cairo_set_source_rgba(dc, rect.fill_col.r, rect.fill_col.g, rect.fill_col.b, rect.fill_col.a);
52
if (rect.stroke_col.r != -1 && rect.stroke_col.g != -1 && rect.stroke_col.b != -1)
53
cairo_fill_preserve(dc);
57
if (rect.stroke_col.r != -1 && rect.stroke_col.g != -1 && rect.stroke_col.b != -1) {
58
cairo_set_line_width(dc, rect.stroke_width);
59
cairo_set_source_rgba(dc, rect.stroke_col.r, rect.stroke_col.b, rect.stroke_col.g, rect.stroke_col.a);
64
cairo_scale(dc, width/rect.svg_width, height/rect.svg_height);
65
cairo_rectangle(dc, rect.x, rect.y, rect.width, rect.height);
66
if (rect.fill_col.r != -1 && rect.fill_col.g != -1 && rect.fill_col.b != -1) {
67
cairo_set_source_rgba(dc, rect.fill_col.r, rect.fill_col.g, rect.fill_col.b, rect.fill_col.a);
68
if (rect.stroke_col.r != -1 && rect.stroke_col.g != -1 && rect.stroke_col.b != -1) cairo_fill_preserve(dc);
71
if (rect.stroke_col.r != -1 && rect.stroke_col.g != -1 && rect.stroke_col.b != -1) {
72
cairo_set_line_width(dc, rect.stroke_width);
73
cairo_set_source_rgba(dc, rect.stroke_col.r, rect.stroke_col.g, rect.stroke_col.b, rect.stroke_col.a);
65
80
cairo_text_extents_t CTheme::GetTextExtents(TThemeTxt text) {
66
cairo_text_extents_t extents;
67
cairo_select_font_face(dc, text.fontfamily, text.fontstyle, text.fontweight);
68
cairo_set_font_size(dc, text.fontsize);
69
cairo_move_to(dc, text.x, text.y);
70
cairo_text_extents(dc, text.text, &extents);
73
void CTheme::ParseSVGForText(char *filename, TThemeTxt *text) {
75
xmlNode *root_element = NULL;
76
doc = xmlReadFile(filename, NULL, 0);
77
root_element = xmlDocGetRootElement(doc);
79
/* set some defaults */
81
text->fontfamily[0] ='\0';
82
strncat(text->fontfamily,"Sans",4);
83
text->fontstyle = CAIRO_FONT_SLANT_NORMAL;
84
text->fontweight = CAIRO_FONT_WEIGHT_NORMAL;
85
text->stroke_width = 0;
87
walk_tree(root_element, text);
91
void CTheme::ParseSVGForRect(char *filename, TThemeRect *rect) {
93
xmlNode *root_element = NULL;
94
doc = xmlReadFile(filename, NULL, 0);
95
root_element = xmlDocGetRootElement(doc);
96
/* set some defaults */
97
rect->stroke_width = 0;
99
walk_tree(root_element, rect);
103
void CTheme::walk_tree(xmlNode * a_node, TThemeTxt *text)
105
xmlNode *cur_node = NULL;
106
xmlAttr *attr = NULL;
108
for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
109
if (cur_node->type == XML_ELEMENT_NODE) {
110
if (cur_node->properties != NULL) {
111
attr = cur_node->properties;
112
while (attr != NULL) {
113
if (!strcasecmp((char *) cur_node->name, "text")) {
114
if (!strcasecmp((char *) attr->name, "x")) {
115
string = (char *) xmlGetProp(cur_node, attr->name);
116
sscanf(string,"%lf",&(text->x));
118
} else if (!strcasecmp((char *) attr->name, "y")) {
119
string = (char *) xmlGetProp(cur_node, attr->name);
120
sscanf(string,"%lf",&(text->y));
122
} else if (!strcasecmp((char *) attr->name, "transform")) {
123
double x_trans, y_trans;
124
char tmp_string[10], *p;
125
tmp_string[0] = '\0';
126
string = (char *) xmlGetProp(cur_node, attr->name);
127
if(!strncasecmp(string, "translate(", 10)) {
129
p = strchr(string, ',');
130
strncat(tmp_string, string, p - string);
131
sscanf(tmp_string, "%lf", &x_trans);
133
p = strchr(string, ')');
134
tmp_string[0] = '\0';
135
strncat(tmp_string, string, p - string);
136
sscanf(tmp_string, "%lf", &y_trans);
141
} else if (!strcasecmp((char *) attr->name, "style")) {
142
string = strtok((char *) xmlGetProp(cur_node, attr->name), ";");
143
while (string != NULL) {
144
if (!strncasecmp(string, "font-size:", 10)) {
145
sscanf((string + 10),"%lf", &(text->fontsize));
146
} else if (!strncasecmp(string, "font-family:", 12)) {
147
text->fontfamily[0] ='\0';
148
strncat((*text).fontfamily, (string + 12), 31); /* copy no more than 31 bytes to not caue buffer overrun */
149
} else if (!strncasecmp(string, "font-style:", 11)) {
150
if(!strncasecmp((string + 11), "normal", 6)) {
151
text->fontstyle = CAIRO_FONT_SLANT_NORMAL;
152
} else if(!strncasecmp((string + 11), "italic", 6)) {
153
text->fontstyle = CAIRO_FONT_SLANT_ITALIC;
154
} else if(!strncasecmp((string + 11), "oblique", 7)) {
155
text->fontstyle = CAIRO_FONT_SLANT_OBLIQUE;
157
} else if (!strncasecmp(string, "font-weight:", 12)) {
158
if(!strncasecmp((string + 12), "normal", 6)) {
159
text->fontweight = CAIRO_FONT_WEIGHT_NORMAL;
160
} else if(!strncasecmp((string + 12), "bold", 4)) {
161
text->fontweight = CAIRO_FONT_WEIGHT_BOLD;
163
} else if (!strncasecmp(string, "fill:", 5)) {
164
getcolor((string + 5), &(text->fill_col));
165
} else if (!strncasecmp(string, "fill-opacity:", 13)) {
166
sscanf((string + 13), "%lf", &(text->fill_col.a));
167
} else if (!strncasecmp(string, "stroke:", 7)) {
168
getcolor((string + 7), &(text->stroke_col));
169
} else if (!strncasecmp(string, "stroke-opacity:", 15)) {
170
sscanf((string + 15), "%lf", &(text->stroke_col.a));
171
} else if (!strncasecmp(string, "stroke-width:", 13)) {
172
sscanf((string + 13),"%lf", &(text->stroke_width));
174
string = strtok(NULL, ";");
180
} else if (!strcasecmp((char *) cur_node->name, "svg")) {
181
if (!strcasecmp((char *) attr->name, "width")) {
182
string = (char *) xmlGetProp(cur_node, attr->name);
183
sscanf(string,"%lf",&(text->svg_width));
185
} else if (!strcasecmp((char *) attr->name, "height")) {
186
string = (char *) xmlGetProp(cur_node, attr->name);
187
sscanf(string,"%lf",&(text->svg_height));
195
walk_tree(cur_node->children, text);
198
void CTheme::walk_tree(xmlNode * a_node, TThemeRect *rect)
200
xmlNode *cur_node = NULL;
201
xmlAttr *attr = NULL;
203
for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
204
if (cur_node->type == XML_ELEMENT_NODE) {
205
if (cur_node->properties != NULL) {
206
attr = cur_node->properties;
207
while (attr != NULL) {
208
if (!strcasecmp((char *) cur_node->name, "rect")) {
209
if (!strcasecmp((char *) attr->name, "x")) {
210
string = (char *) xmlGetProp(cur_node, attr->name);
211
sscanf(string,"%lf",&(rect->x));
213
} else if (!strcasecmp((char *) attr->name, "y")) {
214
string = (char *) xmlGetProp(cur_node, attr->name);
215
sscanf(string,"%lf",&(rect->y));
217
} else if (!strcasecmp((char *) attr->name, "width")) {
218
string = (char *) xmlGetProp(cur_node, attr->name);
219
sscanf(string,"%lf",&(rect->final_width));
221
rect->width = rect->final_width;
222
} else if (!strcasecmp((char *) attr->name, "height")) {
223
string = (char *) xmlGetProp(cur_node, attr->name);
224
sscanf(string,"%lf",&(rect->final_height));
226
rect->height = rect->final_height;
227
} else if (!strcasecmp((char *) attr->name, "style")) {
228
string = (char *) xmlGetProp(cur_node, attr->name);
229
char * string_tmp = strtok(string, ";");
230
while (string_tmp != NULL) {
231
if (!strncasecmp(string_tmp, "fill:", 5)) {
232
getcolor((string_tmp + 5), &(rect->fill_col));
233
} else if (!strncasecmp(string_tmp, "fill-opacity:", 13)) {
234
sscanf((string_tmp + 13), "%lf", &(rect->fill_col.a));
235
} else if (!strncasecmp(string_tmp, "stroke:", 7)) {
236
getcolor((string_tmp + 7), &(rect->stroke_col));
237
} else if (!strncasecmp(string_tmp, "stroke-opacity:", 15)) {
238
sscanf((string_tmp + 15), "%lf", &(rect->stroke_col.a));
239
} else if (!strncasecmp(string_tmp, "stroke-width:", 13)) {
240
sscanf((string_tmp + 13),"%lf", &(rect->stroke_width));
242
string_tmp = strtok(NULL, ";");
248
} else if (!strcasecmp((char *) cur_node->name, "svg")) {
249
if (!strcasecmp((char *) attr->name, "width")) {
250
string = (char *) xmlGetProp(cur_node, attr->name);
251
sscanf(string,"%lf",&(rect->svg_width));
253
} else if (!strcasecmp((char *) attr->name, "height")) {
254
string = (char *) xmlGetProp(cur_node, attr->name);
255
sscanf(string,"%lf",&(rect->svg_height));
263
walk_tree(cur_node->children, rect);
81
cairo_text_extents_t extents;
83
PangoContext* ctx=NULL;
84
ctx = pango_cairo_font_map_create_context ((PangoCairoFontMap*)pango_cairo_font_map_get_default());
85
PangoFontDescription *desc = pango_font_description_new();
86
PangoLayout *layout = pango_layout_new(ctx);
87
pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER );
90
pango_font_description_set_family(desc, text.fontfamily.c_str());
91
pango_font_description_set_style (desc,PANGO_STYLE_NORMAL);
92
pango_font_description_set_absolute_size (desc,text.fontsize * PANGO_SCALE);
93
pango_layout_set_font_description (layout, desc);
94
pango_layout_set_text (layout, text.text.c_str(), -1);
95
pango_layout_get_pixel_extents (layout,NULL,&rec);
96
extents.width = rec.width;
97
extents.height = rec.height;
98
extents.x_advance = rec.width+rec.x;
99
extents.y_advance = rec.height+rec.y;
101
g_object_unref (layout);
102
pango_font_description_free (desc);
103
g_object_unref (ctx);
108
void CTheme::ParseSVGForText(std::string const& filename, TThemeTxt *text) {
110
xmlNode *root_element = NULL;
111
doc = xmlReadFile(filename.c_str(), NULL, 0);
112
root_element = xmlDocGetRootElement(doc);
114
/* set some defaults */
116
text->fontfamily = "Sans";
117
text->fontstyle = CAIRO_FONT_SLANT_NORMAL;
118
text->fontweight = CAIRO_FONT_WEIGHT_NORMAL;
119
text->stroke_width = 0;
121
walk_tree(root_element, text);
126
void CTheme::ParseSVGForRect(std::string const& filename, TThemeRect *rect) {
128
xmlNode *root_element = NULL;
129
doc = xmlReadFile(filename.c_str(), NULL, 0);
130
root_element = xmlDocGetRootElement(doc);
131
/* set some defaults */
132
rect->stroke_width = 0;
134
walk_tree(root_element, rect);
139
void CTheme::walk_tree(xmlNode * a_node, TThemeTxt *text) {
140
xmlNode *cur_node = NULL;
141
xmlAttr *attr = NULL;
143
for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
144
if (cur_node->type == XML_ELEMENT_NODE) {
145
if (cur_node->properties != NULL) {
146
attr = cur_node->properties;
147
while (attr != NULL) {
148
if (!strcasecmp((char *) cur_node->name, "text")) {
149
if (!strcasecmp((char *) attr->name, "x")) {
150
string = (char *) xmlGetProp(cur_node, attr->name);
151
sscanf(string,"%lf",&(text->x));
153
} else if (!strcasecmp((char *) attr->name, "y")) {
154
string = (char *) xmlGetProp(cur_node, attr->name);
155
sscanf(string,"%lf",&(text->y));
157
} else if (!strcasecmp((char *) attr->name, "transform")) {
158
double x_trans, y_trans;
159
char tmp_string[10], *p;
160
tmp_string[0] = '\0';
161
string = (char *) xmlGetProp(cur_node, attr->name);
162
if (!strncasecmp(string, "translate(", 10)) {
164
p = strchr(string, ',');
165
strncat(tmp_string, string, p - string);
166
sscanf(tmp_string, "%lf", &x_trans);
168
p = strchr(string, ')');
169
tmp_string[0] = '\0';
170
strncat(tmp_string, string, p - string);
171
sscanf(tmp_string, "%lf", &y_trans);
176
} else if (!strcasecmp((char *) attr->name, "style")) {
177
char * orig = (char *) xmlGetProp(cur_node, attr->name);
178
string = strtok(orig, ";");
179
while (string != NULL) {
180
if (!strncasecmp(string, "font-size:", 10)) {
181
sscanf((string + 10),"%lf", &(text->fontsize));
182
} else if (!strncasecmp(string, "font-family:", 12)) {
183
text->fontfamily = string + 12;
184
} else if (!strncasecmp(string, "font-style:", 11)) {
185
if (!strncasecmp((string + 11), "normal", 6)) {
186
text->fontstyle = CAIRO_FONT_SLANT_NORMAL;
187
} else if (!strncasecmp((string + 11), "italic", 6)) {
188
text->fontstyle = CAIRO_FONT_SLANT_ITALIC;
189
} else if (!strncasecmp((string + 11), "oblique", 7)) {
190
text->fontstyle = CAIRO_FONT_SLANT_OBLIQUE;
192
} else if (!strncasecmp(string, "font-weight:", 12)) {
193
if (!strncasecmp((string + 12), "normal", 6)) {
194
text->fontweight = CAIRO_FONT_WEIGHT_NORMAL;
195
} else if (!strncasecmp((string + 12), "bold", 4)) {
196
text->fontweight = CAIRO_FONT_WEIGHT_BOLD;
198
} else if (!strncasecmp(string, "fill:", 5)) {
199
getcolor((string + 5), &(text->fill_col));
200
} else if (!strncasecmp(string, "fill-opacity:", 13)) {
201
sscanf((string + 13), "%lf", &(text->fill_col.a));
202
} else if (!strncasecmp(string, "stroke:", 7)) {
203
getcolor((string + 7), &(text->stroke_col));
204
} else if (!strncasecmp(string, "stroke-opacity:", 15)) {
205
sscanf((string + 15), "%lf", &(text->stroke_col.a));
206
} else if (!strncasecmp(string, "stroke-width:", 13)) {
207
sscanf((string + 13),"%lf", &(text->stroke_width));
209
string = strtok(NULL, ";");
215
} else if (!strcasecmp((char *) cur_node->name, "svg")) {
216
if (!strcasecmp((char *) attr->name, "width")) {
217
string = (char *) xmlGetProp(cur_node, attr->name);
218
sscanf(string,"%lf",&(text->svg_width));
220
} else if (!strcasecmp((char *) attr->name, "height")) {
221
string = (char *) xmlGetProp(cur_node, attr->name);
222
sscanf(string,"%lf",&(text->svg_height));
230
walk_tree(cur_node->children, text);
234
void CTheme::walk_tree(xmlNode * a_node, TThemeRect *rect) {
235
xmlNode *cur_node = NULL;
236
xmlAttr *attr = NULL;
238
for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
239
if (cur_node->type == XML_ELEMENT_NODE) {
240
if (cur_node->properties != NULL) {
241
attr = cur_node->properties;
242
while (attr != NULL) {
243
if (!strcasecmp((char *) cur_node->name, "rect")) {
244
if (!strcasecmp((char *) attr->name, "x")) {
245
string = (char *) xmlGetProp(cur_node, attr->name);
246
sscanf(string,"%lf",&(rect->x));
248
} else if (!strcasecmp((char *) attr->name, "y")) {
249
string = (char *) xmlGetProp(cur_node, attr->name);
250
sscanf(string,"%lf",&(rect->y));
252
} else if (!strcasecmp((char *) attr->name, "width")) {
253
string = (char *) xmlGetProp(cur_node, attr->name);
254
sscanf(string,"%lf",&(rect->final_width));
256
rect->width = rect->final_width;
257
} else if (!strcasecmp((char *) attr->name, "height")) {
258
string = (char *) xmlGetProp(cur_node, attr->name);
259
sscanf(string,"%lf",&(rect->final_height));
261
rect->height = rect->final_height;
262
} else if (!strcasecmp((char *) attr->name, "style")) {
263
string = (char *) xmlGetProp(cur_node, attr->name);
264
char * string_tmp = strtok(string, ";");
265
while (string_tmp != NULL) {
266
if (!strncasecmp(string_tmp, "fill:", 5)) {
267
getcolor((string_tmp + 5), &(rect->fill_col));
268
} else if (!strncasecmp(string_tmp, "fill-opacity:", 13)) {
269
sscanf((string_tmp + 13), "%lf", &(rect->fill_col.a));
270
} else if (!strncasecmp(string_tmp, "stroke:", 7)) {
271
getcolor((string_tmp + 7), &(rect->stroke_col));
272
} else if (!strncasecmp(string_tmp, "stroke-opacity:", 15)) {
273
sscanf((string_tmp + 15), "%lf", &(rect->stroke_col.a));
274
} else if (!strncasecmp(string_tmp, "stroke-width:", 13)) {
275
sscanf((string_tmp + 13),"%lf", &(rect->stroke_width));
277
string_tmp = strtok(NULL, ";");
283
} else if (!strcasecmp((char *) cur_node->name, "svg")) {
284
if (!strcasecmp((char *) attr->name, "width")) {
285
string = (char *) xmlGetProp(cur_node, attr->name);
286
sscanf(string,"%lf",&(rect->svg_width));
288
} else if (!strcasecmp((char *) attr->name, "height")) {
289
string = (char *) xmlGetProp(cur_node, attr->name);
290
sscanf(string,"%lf",&(rect->svg_height));
298
walk_tree(cur_node->children, rect);
266
302
void CTheme::getcolor(char *string, TRGBA *col) {
268
if (string[0] == '#') {
269
if(strlen(string) == 7) {
270
sscanf((string+1), "%02x %02x %02x", &r, &g, &b);
271
col->r = (double) r / 255;
272
col->g = (double) g / 255;
273
col->b = (double) b / 255;
275
} else if(!strcasecmp(string, "red")) {
278
} else if(!strcasecmp(string, "lime")) {
281
} else if(!strcasecmp(string, "blue")) {
284
} else if(!strcasecmp(string, "black")) {
285
col->r = col->g = col->b = 0;
286
} else if(!strcasecmp(string, "silver")) {
287
col->r = col->g = col->b = 0.75;
288
} else if(!strcasecmp(string, "gray")) {
289
col->r = col->g = col->b = 0.5;
290
} else if(!strcasecmp(string, "white")) {
291
col->r = col->g = col->b = 1;
292
} else if(!strcasecmp(string, "maroon")) {
295
} else if(!strcasecmp(string, "purple")) {
297
col->r = col->b = 0.5;
298
} else if(!strcasecmp(string, "fuchsia")) {
301
} else if(!strcasecmp(string, "green")) {
304
} else if(!strcasecmp(string, "olive")) {
306
col->r = col->g = 0.5;
307
} else if(!strcasecmp(string, "yellow")) {
310
} else if(!strcasecmp(string, "navy")) {
313
} else if(!strcasecmp(string, "teal")) {
315
col->g = col->b = 0.5;
316
} else if(!strcasecmp(string, "aqua")) {
319
} else if(!strcasecmp((string), "none")) {
320
col->r = col->g = col->b = -1;
304
if (string[0] == '#') {
305
if (strlen(string) == 7) {
306
sscanf((string+1), "%02x %02x %02x", &r, &g, &b);
307
col->r = (double) r / 255;
308
col->g = (double) g / 255;
309
col->b = (double) b / 255;
311
} else if (!strcasecmp(string, "red")) {
314
} else if (!strcasecmp(string, "lime")) {
317
} else if (!strcasecmp(string, "blue")) {
320
} else if (!strcasecmp(string, "black")) {
321
col->r = col->g = col->b = 0;
322
} else if (!strcasecmp(string, "silver")) {
323
col->r = col->g = col->b = 0.75;
324
} else if (!strcasecmp(string, "gray")) {
325
col->r = col->g = col->b = 0.5;
326
} else if (!strcasecmp(string, "white")) {
327
col->r = col->g = col->b = 1;
328
} else if (!strcasecmp(string, "maroon")) {
331
} else if (!strcasecmp(string, "purple")) {
333
col->r = col->b = 0.5;
334
} else if (!strcasecmp(string, "fuchsia")) {
337
} else if (!strcasecmp(string, "green")) {
340
} else if (!strcasecmp(string, "olive")) {
342
col->r = col->g = 0.5;
343
} else if (!strcasecmp(string, "yellow")) {
346
} else if (!strcasecmp(string, "navy")) {
349
} else if (!strcasecmp(string, "teal")) {
351
col->g = col->b = 0.5;
352
} else if (!strcasecmp(string, "aqua")) {
355
} else if (!strcasecmp((string), "none")) {
356
col->r = col->g = col->b = -1;
324
361
CTheme::~CTheme() {
329
cairo_surface_destroy(surface);
332
CThemeSongs::CThemeSongs() {
333
char * theme_path = new char[1024];
334
CScreenManager * sm = CScreenManager::getSingletonPtr();
336
sm->getThemePathFile(theme_path,"songs_bg.svg");
337
bg = new CairoSVG(theme_path, sm->getWidth(), sm->getHeight());
339
theme = new CTheme(sm->getWidth(), sm->getHeight());
340
sm->getThemePathFile(theme_path,"songs_song.svg");
341
theme->ParseSVGForText(theme_path, &song);
342
sm->getThemePathFile(theme_path,"songs_order.svg");
343
theme->ParseSVGForText(theme_path, &order);
362
if (dc) cairo_destroy(dc);
363
if (surface) cairo_surface_destroy(surface);
366
CThemeSongs::CThemeSongs(unsigned int width, unsigned int height) {
367
CScreenManager* sm = CScreenManager::getSingletonPtr();
368
bg = new CairoSVG(sm->getThemePathFile("songs_bg.svg"), width, height);
369
theme = new CTheme(width, height);
370
theme->ParseSVGForText(sm->getThemePathFile("songs_song.svg"), &song);
371
theme->ParseSVGForText(sm->getThemePathFile("songs_order.svg"), &order);
347
374
CThemeSongs::~CThemeSongs() {
351
CThemePractice::CThemePractice() {
352
char * theme_path = new char[1024];
379
CThemePractice::CThemePractice(unsigned int width, unsigned int height) {
353
380
CScreenManager * sm = CScreenManager::getSingletonPtr();
355
sm->getThemePathFile(theme_path,"practice_bg.svg");
356
bg = new CairoSVG(theme_path, sm->getWidth(), sm->getHeight());
358
theme = new CTheme(sm->getWidth(), sm->getHeight());
359
sm->getThemePathFile(theme_path,"practice_txt.svg");
360
theme->ParseSVGForText(theme_path, ¬etxt);
381
bg = new CairoSVG(sm->getThemePathFile("practice_bg.svg"), width, height);
382
theme = new CTheme(width, height);
383
theme->ParseSVGForText(sm->getThemePathFile("practice_txt.svg"), ¬etxt);
384
theme->ParseSVGForRect(sm->getThemePathFile("practice_peak.svg"), &peak);
364
387
CThemePractice::~CThemePractice() {
368
CThemeSing::CThemeSing() {
369
char * theme_path = new char[1024];
392
CThemeSing::CThemeSing(unsigned int width, unsigned int height) {
370
393
CScreenManager * sm = CScreenManager::getSingletonPtr();
372
sm->getThemePathFile(theme_path,"sing_bg.svg");
373
bg = new CairoSVG(theme_path, sm->getWidth(), sm->getHeight());
374
sm->getThemePathFile(theme_path,"sing_p1box.svg");
375
p1box = new CairoSVG(theme_path, sm->getWidth(), sm->getHeight());
376
theme = new CTheme(sm->getWidth(), sm->getHeight());
377
sm->getThemePathFile(theme_path,"sing_timetxt.svg");
378
theme->ParseSVGForText(theme_path, &timertxt);
379
sm->getThemePathFile(theme_path,"sing_p1score.svg");
380
theme->ParseSVGForText(theme_path, &p1score);
381
sm->getThemePathFile(theme_path,"sing_lyricscurrent.svg");
382
theme->ParseSVGForText(theme_path, &lyricspast);
383
sm->getThemePathFile(theme_path,"sing_lyricscurrent.svg");
384
theme->ParseSVGForText(theme_path, &lyricsfuture);
385
sm->getThemePathFile(theme_path,"sing_lyricshighlight.svg");
386
theme->ParseSVGForText(theme_path, &lyricshighlight);
387
sm->getThemePathFile(theme_path,"sing_lyricsnext.svg");
388
theme->ParseSVGForText(theme_path, &lyricsnextsentence);
389
sm->getThemePathFile(theme_path,"sing_progressfg.svg");
390
theme->ParseSVGForRect(theme_path, &progressfg);
391
sm->getThemePathFile(theme_path,"sing_tostartfg.svg");
392
theme->ParseSVGForRect(theme_path, &tostartfg);
394
bg = new CairoSVG(sm->getThemePathFile("sing_bg.svg"), width, height);
395
p1box = new CairoSVG(sm->getThemePathFile("sing_p1box.svg"), width, height);
396
theme = new CTheme(width, height);
397
theme->ParseSVGForText(sm->getThemePathFile("sing_timetxt.svg"), &timertxt);
398
theme->ParseSVGForText(sm->getThemePathFile("sing_p1score.svg"), &p1score);
399
theme->ParseSVGForText(sm->getThemePathFile("sing_lyricscurrent.svg"), &lyricspast);
400
theme->ParseSVGForText(sm->getThemePathFile("sing_lyricscurrent.svg"), &lyricsfuture);
401
theme->ParseSVGForText(sm->getThemePathFile("sing_lyricshighlight.svg"), &lyricshighlight);
402
theme->ParseSVGForText(sm->getThemePathFile("sing_lyricsnext.svg"), &lyricsnextsentence);
403
theme->ParseSVGForRect(sm->getThemePathFile("sing_progressfg.svg"), &progressfg);
404
theme->ParseSVGForRect(sm->getThemePathFile("sing_tostartfg.svg"), &tostartfg);
396
407
CThemeSing::~CThemeSing() {
413
CThemeScore::CThemeScore(unsigned int width, unsigned int height) {
414
CScreenManager * sm = CScreenManager::getSingletonPtr();
415
bg = new CairoSVG(sm->getThemePathFile("score_bg.svg"), width, height);
416
theme = new CTheme(width, height);
417
theme->ParseSVGForText(sm->getThemePathFile("score_txt.svg"), &normal_score);
418
theme->ParseSVGForText(sm->getThemePathFile("score_rank.svg"), &rank);
419
theme->ParseSVGForRect(sm->getThemePathFile("score_level.svg"), &level);
422
CThemeScore::~CThemeScore() {
427
CThemeConfiguration::CThemeConfiguration(unsigned int width, unsigned int height) {
428
CScreenManager * sm = CScreenManager::getSingletonPtr();
429
bg = new CairoSVG(sm->getThemePathFile("configuration_bg.svg"), width, height);
430
theme = new CTheme(width, height);
431
theme->ParseSVGForText(sm->getThemePathFile("configuration_item.svg"), &item);
432
theme->ParseSVGForText(sm->getThemePathFile("configuration_value.svg"), &value);
435
CThemeConfiguration::~CThemeConfiguration() {