1 | #ifndef SKIN_H |
---|
2 | #define SKIN_H |
---|
3 | |
---|
4 | void debugscreen(struct skin* node) |
---|
5 | { |
---|
6 | struct skin* child = NULL; |
---|
7 | |
---|
8 | if(node != NULL) |
---|
9 | { |
---|
10 | printf("screen = %s %p %p %p %p\n", node->name, node, node->prev, node->next, node->child); |
---|
11 | |
---|
12 | if(node != skin) |
---|
13 | child = node->child; |
---|
14 | else |
---|
15 | child = node->next; |
---|
16 | |
---|
17 | while(child != NULL) |
---|
18 | { |
---|
19 | printf("node = %s %p %p %p \n", child->name, child, child->prev, child->next); |
---|
20 | child = child->next; |
---|
21 | } |
---|
22 | } |
---|
23 | else |
---|
24 | printf("screen = NULL\n"); |
---|
25 | } |
---|
26 | |
---|
27 | void* convertfunc(char *value, uint8_t *rettype) |
---|
28 | { |
---|
29 | debug(1000, "in"); |
---|
30 | *rettype = FUNCTEXT; |
---|
31 | |
---|
32 | if(ostrcmp("getpicon", value) == 0) |
---|
33 | { |
---|
34 | *rettype = FUNCPIC; |
---|
35 | return &getpicon; |
---|
36 | } |
---|
37 | if(ostrcmp("getalternatepicon", value) == 0) |
---|
38 | { |
---|
39 | *rettype = FUNCPIC; |
---|
40 | return &getalternatepicon; |
---|
41 | } |
---|
42 | if(ostrcmp("getepgpicon", value) == 0) |
---|
43 | { |
---|
44 | *rettype = FUNCPIC; |
---|
45 | return &getepgpicon; |
---|
46 | } |
---|
47 | if(ostrcmp("getsoundtype", value) == 0) |
---|
48 | { |
---|
49 | *rettype = FUNCPIC; |
---|
50 | return &getsoundtype; |
---|
51 | } |
---|
52 | if(ostrcmp("getteletext", value) == 0) |
---|
53 | { |
---|
54 | *rettype = FUNCPIC; |
---|
55 | return &getteletext; |
---|
56 | } |
---|
57 | if(ostrcmp("getcrypt", value) == 0) |
---|
58 | { |
---|
59 | *rettype = FUNCPIC; |
---|
60 | return &getcrypt; |
---|
61 | } |
---|
62 | if(ostrcmp("getresolution", value) == 0) |
---|
63 | { |
---|
64 | *rettype = FUNCPIC; |
---|
65 | return &getresolution; |
---|
66 | } |
---|
67 | if(ostrcmp("getsdhd", value) == 0) |
---|
68 | { |
---|
69 | *rettype = FUNCPIC; |
---|
70 | return &getsdhd; |
---|
71 | } |
---|
72 | if(ostrcmp("getaspectmode", value) == 0) |
---|
73 | { |
---|
74 | *rettype = FUNCPIC; |
---|
75 | return &getaspectmode; |
---|
76 | } |
---|
77 | if(ostrcmp("getreccount", value) == 0) |
---|
78 | return &getreccount; |
---|
79 | if(ostrcmp("getrec", value) == 0) |
---|
80 | { |
---|
81 | *rettype = FUNCPIC; |
---|
82 | return &getrec; |
---|
83 | } |
---|
84 | if(ostrcmp("getplaypic", value) == 0) |
---|
85 | { |
---|
86 | *rettype = FUNCPIC; |
---|
87 | return &getplaypic; |
---|
88 | } |
---|
89 | if(ostrcmp("getplaytext", value) == 0) |
---|
90 | return &getplaytext; |
---|
91 | if(ostrcmp("getepgchanneltimeline", value) == 0) |
---|
92 | { |
---|
93 | *rettype = FUNCPROGRESS; |
---|
94 | return &getepgchanneltimeline; |
---|
95 | } |
---|
96 | if(ostrcmp("getepgmarkedtimeline", value) == 0) |
---|
97 | { |
---|
98 | *rettype = FUNCPROGRESS; |
---|
99 | return &getepgmarkedtimeline; |
---|
100 | } |
---|
101 | if(ostrcmp("getepgakttimeline", value) == 0) |
---|
102 | { |
---|
103 | *rettype = FUNCPROGRESS; |
---|
104 | return &getepgakttimeline; |
---|
105 | } |
---|
106 | if(ostrcmp("getsnrline", value) == 0) |
---|
107 | { |
---|
108 | *rettype = FUNCPROGRESS; |
---|
109 | return &getsnr; |
---|
110 | } |
---|
111 | if(ostrcmp("getsignalline", value) == 0) |
---|
112 | { |
---|
113 | *rettype = FUNCPROGRESS; |
---|
114 | return &getsignal; |
---|
115 | } |
---|
116 | if(ostrcmp("gettvpic", value) == 0) |
---|
117 | return &gettvpic; |
---|
118 | if(ostrcmp("getepgmarkeddesc", value) == 0) |
---|
119 | return &getepgmarkeddesc; |
---|
120 | if(ostrcmp("getepgaktdesc", value) == 0) |
---|
121 | return &getepgaktdesc; |
---|
122 | if(ostrcmp("getaktchannelname", value) == 0) |
---|
123 | return &getaktchannelname; |
---|
124 | if(ostrcmp("getakttuner", value) == 0) |
---|
125 | return &getakttuner; |
---|
126 | if(ostrcmp("gettime", value) == 0) |
---|
127 | return &gettime; |
---|
128 | if(ostrcmp("getepgmarkedstart", value) == 0) |
---|
129 | return &getepgmarkedstart; |
---|
130 | if(ostrcmp("getepgmarkedend", value) == 0) |
---|
131 | return &getepgmarkedend; |
---|
132 | if(ostrcmp("getepgaktstart", value) == 0) |
---|
133 | return &getepgaktstart; |
---|
134 | if(ostrcmp("getepgaktend", value) == 0) |
---|
135 | return &getepgaktend; |
---|
136 | if(ostrcmp("getepgakttitle", value) == 0) |
---|
137 | return &getepgakttitle; |
---|
138 | if(ostrcmp("getepgmarkedlist", value) == 0) |
---|
139 | return &getepgmarkedlist; |
---|
140 | if(ostrcmp("getepgaktsubtitle", value) == 0) |
---|
141 | return &getepgaktsubtitle; |
---|
142 | if(ostrcmp("getepgnexttitle", value) == 0) |
---|
143 | return &getepgnexttitle; |
---|
144 | if(ostrcmp("getepgnextstart", value) == 0) |
---|
145 | return &getepgnextstart; |
---|
146 | if(ostrcmp("getepgnextend", value) == 0) |
---|
147 | return &getepgnextend; |
---|
148 | if(ostrcmp("getepgakttimeremaining", value) == 0) |
---|
149 | return &getepgakttimeremaining; |
---|
150 | if(ostrcmp("getepgnexttimeremaining", value) == 0) |
---|
151 | return &getepgnexttimeremaining; |
---|
152 | if(ostrcmp("getchannelnr", value) == 0) |
---|
153 | return &getchannelnr; |
---|
154 | if(ostrcmp("getchannellistname", value) == 0) |
---|
155 | return &getchannellistname; |
---|
156 | if(ostrcmp("getsnr", value) == 0) |
---|
157 | return &getsnr; |
---|
158 | if(ostrcmp("getber", value) == 0) |
---|
159 | return &getber; |
---|
160 | if(ostrcmp("getunc", value) == 0) |
---|
161 | return &getunc; |
---|
162 | if(ostrcmp("getsignal", value) == 0) |
---|
163 | return &getsignal; |
---|
164 | if(ostrcmp("getsatname", value) == 0) |
---|
165 | return &getsatname; |
---|
166 | if(ostrcmp("getprovidername", value) == 0) |
---|
167 | return &getprovidername; |
---|
168 | if(ostrcmp("getpowerofftime", value) == 0) |
---|
169 | return &getpowerofftime; |
---|
170 | |
---|
171 | debug(1000, "out"); |
---|
172 | return 0; |
---|
173 | } |
---|
174 | |
---|
175 | long convertcol(char *value) |
---|
176 | { |
---|
177 | // debug(1000, "in"); |
---|
178 | char *ret; |
---|
179 | long col = 0; |
---|
180 | |
---|
181 | if(value == NULL) return 0; |
---|
182 | |
---|
183 | if(value[0] == '#') |
---|
184 | { |
---|
185 | value++; |
---|
186 | col = strtol(value, '\0', 16); |
---|
187 | } |
---|
188 | else |
---|
189 | { |
---|
190 | ret = getskinconfig(value, NULL); |
---|
191 | if(ret != NULL) |
---|
192 | col = strtol(ret, '\0', 16); |
---|
193 | else |
---|
194 | col = strtol(value, '\0', 16); |
---|
195 | } |
---|
196 | |
---|
197 | // debug(1000, "out"); |
---|
198 | return col; |
---|
199 | } |
---|
200 | |
---|
201 | int convertxmlentry(char *value, uint8_t *proz) |
---|
202 | { |
---|
203 | // debug(1000, "in"); |
---|
204 | int ret = -1; |
---|
205 | char *buf = NULL; |
---|
206 | |
---|
207 | if(strcasecmp(value, "left") == 0) |
---|
208 | ret = LEFT; |
---|
209 | else if(strcasecmp(value, "center") == 0) |
---|
210 | ret = CENTER; |
---|
211 | else if(strcasecmp(value, "right") == 0) |
---|
212 | ret = RIGHT; |
---|
213 | else if(strcasecmp(value, "top") == 0) |
---|
214 | ret = TOP; |
---|
215 | else if(strcasecmp(value, "middle") == 0) |
---|
216 | ret = MIDDLE; |
---|
217 | else if(strcasecmp(value, "bottom") == 0) |
---|
218 | ret = BOTTOM; |
---|
219 | else if(strcasecmp(value, "bottomleft") == 0) |
---|
220 | ret = BOTTOMLEFT; |
---|
221 | else if(strcasecmp(value, "bottomright") == 0) |
---|
222 | ret = BOTTOMRIGHT; |
---|
223 | else if(strcasecmp(value, "topleft") == 0) |
---|
224 | ret = TOPLEFT; |
---|
225 | else if(strcasecmp(value, "topright") == 0) |
---|
226 | ret = TOPRIGHT; |
---|
227 | else if(strcasecmp(value, "yes") == 0) |
---|
228 | ret = YES; |
---|
229 | else if(strcasecmp(value, "no") == 0) |
---|
230 | ret = NO; |
---|
231 | else if(strcasecmp(value, "auto") == 0) |
---|
232 | ret = AUTONO; |
---|
233 | else if(strcasecmp(value, "listbox") == 0) |
---|
234 | ret = LISTBOX; |
---|
235 | else if(strcasecmp(value, "grid") == 0) |
---|
236 | ret = GRID; |
---|
237 | else if(strcasecmp(value, "gridbr") == 0) |
---|
238 | ret = GRIDBR; |
---|
239 | else if(strcasecmp(value, "gridbrmenu") == 0) |
---|
240 | ret = GRIDBR | MENU; |
---|
241 | else if(strcasecmp(value, "textbox") == 0) |
---|
242 | ret = TEXTBOX; |
---|
243 | else if(strcasecmp(value, "textboxgridbr") == 0) |
---|
244 | ret = TEXTBOX | GRIDBR; |
---|
245 | else if(strcasecmp(value, "choicebox") == 0) |
---|
246 | ret = CHOICEBOX; |
---|
247 | else if(strcasecmp(value, "inputbox") == 0) |
---|
248 | ret = INPUTBOX; |
---|
249 | else if(strcasecmp(value, "inputboxnum") == 0) |
---|
250 | ret = INPUTBOXNUM; |
---|
251 | else if(strcasecmp(value, "filelist") == 0) |
---|
252 | ret = FILELIST; |
---|
253 | else if(strcasecmp(value, "progressbar") == 0) |
---|
254 | ret = PROGRESSBAR; |
---|
255 | else if(strcasecmp(value, "multiprogressbar") == 0) |
---|
256 | ret = MULTIPROGRESSBAR; |
---|
257 | else if(strcasecmp(value, "menu") == 0) |
---|
258 | ret = MENU; |
---|
259 | else if(strcasecmp(value, "leftright") == 0) |
---|
260 | ret = LEFTRIGHT; |
---|
261 | else if(strcasecmp(value, "topbottom") == 0) |
---|
262 | ret = TOPBOTTOM; |
---|
263 | else if(strcasecmp(value, "topmiddle") == 0) |
---|
264 | ret = TOPMIDDLE; |
---|
265 | else if(strcasecmp(value, "leftmiddle") == 0) |
---|
266 | ret = LEFTMIDDLE; |
---|
267 | else if(strcasecmp(value, "textbottom") == 0) |
---|
268 | ret = TEXTBOTTOM; |
---|
269 | |
---|
270 | if(proz != NULL && ret == -1) |
---|
271 | { |
---|
272 | buf = strchr(value, '%'); |
---|
273 | if(buf != NULL) |
---|
274 | { |
---|
275 | buf[0] = '\0'; |
---|
276 | ret = atoi(value); |
---|
277 | *proz = 1; |
---|
278 | buf[0] = '%'; |
---|
279 | } |
---|
280 | else |
---|
281 | ret = atoi(value); |
---|
282 | } |
---|
283 | |
---|
284 | // debug(1000, "out"); |
---|
285 | return ret; |
---|
286 | } |
---|
287 | |
---|
288 | struct skin* checkscreen(char* screenname) |
---|
289 | { |
---|
290 | //debug(1000, "in"); |
---|
291 | struct skin* node = skin; |
---|
292 | |
---|
293 | while(node != NULL) |
---|
294 | { |
---|
295 | if(ostrcmp(node->name, screenname) == 0) |
---|
296 | { |
---|
297 | //debug(1000, "out"); |
---|
298 | return node; |
---|
299 | } |
---|
300 | node = node->next; |
---|
301 | } |
---|
302 | return status.skinerr; |
---|
303 | } |
---|
304 | |
---|
305 | struct skin* getscreen(char* screenname) |
---|
306 | { |
---|
307 | debug(1000, "in"); |
---|
308 | struct skin* node = skin; |
---|
309 | |
---|
310 | while(node != NULL) |
---|
311 | { |
---|
312 | if(ostrcmp(node->name, screenname) == 0) |
---|
313 | { |
---|
314 | debug(1000, "out"); |
---|
315 | return node; |
---|
316 | } |
---|
317 | node = node->next; |
---|
318 | } |
---|
319 | err("screen not found %s", screenname); |
---|
320 | return status.skinerr; |
---|
321 | } |
---|
322 | |
---|
323 | struct skin* sortscreen(struct skin* node) |
---|
324 | { |
---|
325 | debug(1000, "in"); |
---|
326 | struct skin *nodea = NULL, *nodeb = NULL, *nodec = NULL, *noded = NULL; |
---|
327 | struct skin *nodetmp = NULL; |
---|
328 | struct skin **nodeaddr; |
---|
329 | |
---|
330 | if(node == NULL || node == status.skinerr) |
---|
331 | { |
---|
332 | debug(1000, "out -> NULL detect"); |
---|
333 | return NULL; |
---|
334 | } |
---|
335 | |
---|
336 | if(node == skin) |
---|
337 | nodeaddr=&skin; |
---|
338 | else |
---|
339 | { |
---|
340 | nodeaddr=&node->child; |
---|
341 | node = node->child; |
---|
342 | } |
---|
343 | |
---|
344 | if(node != NULL) |
---|
345 | { |
---|
346 | while (noded != node->next) |
---|
347 | { |
---|
348 | nodec = node; |
---|
349 | nodea = node; |
---|
350 | nodeb = nodea->next; |
---|
351 | |
---|
352 | while (nodea != noded) |
---|
353 | { |
---|
354 | if (nodea->zorder > nodeb->zorder) |
---|
355 | { |
---|
356 | if (nodea == node) |
---|
357 | { |
---|
358 | nodetmp = nodeb->next; |
---|
359 | nodeb->next = nodea; |
---|
360 | nodea->next = nodetmp; |
---|
361 | node = nodeb; |
---|
362 | *nodeaddr = nodeb; |
---|
363 | nodec = nodeb; |
---|
364 | } |
---|
365 | else |
---|
366 | { |
---|
367 | nodetmp = nodeb->next; |
---|
368 | nodeb->next = nodea; |
---|
369 | nodea->next = nodetmp; |
---|
370 | nodec->next = nodeb; |
---|
371 | nodec = nodeb; |
---|
372 | } |
---|
373 | } |
---|
374 | else |
---|
375 | { |
---|
376 | nodec = nodea; |
---|
377 | nodea = nodea->next; |
---|
378 | } |
---|
379 | nodeb = nodea->next; |
---|
380 | if (nodeb == noded) |
---|
381 | noded = nodea; |
---|
382 | } |
---|
383 | } |
---|
384 | } |
---|
385 | debug(1000, "out"); |
---|
386 | return node; |
---|
387 | } |
---|
388 | |
---|
389 | struct skin* sortscreenbyname(char *screenname) |
---|
390 | { |
---|
391 | debug(1000, "in"); |
---|
392 | struct skin* node = NULL; |
---|
393 | |
---|
394 | if(strlen(screenname) == 0) |
---|
395 | node = skin; |
---|
396 | else |
---|
397 | node = getscreen(screenname); |
---|
398 | |
---|
399 | debug(1000, "out"); |
---|
400 | return sortscreen(node); |
---|
401 | } |
---|
402 | |
---|
403 | struct skin* getlastscreennode(struct skin* node) |
---|
404 | { |
---|
405 | debug(1000, "in"); |
---|
406 | struct skin *prev = NULL; |
---|
407 | |
---|
408 | if(node != NULL) node = node->child; |
---|
409 | |
---|
410 | while(node != NULL) |
---|
411 | { |
---|
412 | prev = node; |
---|
413 | node = node->next; |
---|
414 | } |
---|
415 | |
---|
416 | debug(1000, "out"); |
---|
417 | return prev; |
---|
418 | } |
---|
419 | |
---|
420 | char* changepicpath(char* picname) |
---|
421 | { |
---|
422 | char* tmpstr = NULL; |
---|
423 | |
---|
424 | if(picname == NULL) |
---|
425 | return NULL; |
---|
426 | |
---|
427 | if(getconfig("skinpath", NULL) != NULL && strlen(picname) > 0 && picname[0] != '/') |
---|
428 | { |
---|
429 | if(strstr(picname, "%pluginpath%/") != NULL) |
---|
430 | { |
---|
431 | tmpstr = createpath(getconfig("pluginpath", NULL), &picname[13]); |
---|
432 | } |
---|
433 | else |
---|
434 | tmpstr = createpath(getconfig("skinpath", NULL), picname); |
---|
435 | } |
---|
436 | else |
---|
437 | tmpstr = ostrcat(picname, "", 0, 0); |
---|
438 | |
---|
439 | return tmpstr; |
---|
440 | } |
---|
441 | |
---|
442 | struct skin* addscreennode(struct skin* node, char* line, struct skin* last) |
---|
443 | { |
---|
444 | // debug(1000, "in"); |
---|
445 | char *ret = NULL; |
---|
446 | struct skin *newnode = NULL, *prev = NULL, *tmpnode = node; |
---|
447 | struct skin **nodeaddr; |
---|
448 | int memfd = -1, length; |
---|
449 | int fontsizeadjust = getskinconfigint("fontsizeadjust", NULL); |
---|
450 | |
---|
451 | if(node == skin) |
---|
452 | nodeaddr=&skin; |
---|
453 | else |
---|
454 | { |
---|
455 | if(node == NULL || node == status.skinerr) |
---|
456 | { |
---|
457 | err("node = NULL"); |
---|
458 | return NULL; |
---|
459 | } |
---|
460 | nodeaddr=&node->child; |
---|
461 | node = node->child; |
---|
462 | } |
---|
463 | |
---|
464 | newnode = (struct skin*)malloc(sizeof(struct skin)); |
---|
465 | if(newnode == NULL) |
---|
466 | { |
---|
467 | err("no memory"); |
---|
468 | return NULL; |
---|
469 | } |
---|
470 | |
---|
471 | memset(newnode, 0, sizeof(struct skin)); |
---|
472 | newnode->bgcol = -1; |
---|
473 | newnode->titlebgcol = -1; |
---|
474 | newnode->deaktivcol = -1; |
---|
475 | |
---|
476 | if(line != NULL) |
---|
477 | { |
---|
478 | ret = getxmlentry(line, " name="); |
---|
479 | if(ret != NULL) |
---|
480 | newnode->name = ret; |
---|
481 | else |
---|
482 | changename(newnode, "unknown"); |
---|
483 | ret = getxmlentry(line, " parent="); |
---|
484 | if(ret != NULL) |
---|
485 | newnode->parent = ret; |
---|
486 | ret = getxmlentry(line, " type="); |
---|
487 | if(ret != NULL) |
---|
488 | { |
---|
489 | newnode->type = convertxmlentry(ret, NULL); |
---|
490 | if(newnode->type & MENU) |
---|
491 | { |
---|
492 | if(checkmenuforbox(newnode->name) == 0) |
---|
493 | { |
---|
494 | free(newnode); |
---|
495 | free(ret); |
---|
496 | return(NULL); |
---|
497 | } |
---|
498 | } |
---|
499 | free(ret); |
---|
500 | } |
---|
501 | ret = getxmlentry(line, " posx="); |
---|
502 | if(ret != NULL) |
---|
503 | { |
---|
504 | newnode->posx = convertxmlentry(ret, &newnode->prozposx); |
---|
505 | free(ret); |
---|
506 | } |
---|
507 | ret = getxmlentry(line, " posy="); |
---|
508 | if(ret != NULL) |
---|
509 | { |
---|
510 | newnode->posy = convertxmlentry(ret, &newnode->prozposy); |
---|
511 | free(ret); |
---|
512 | } |
---|
513 | ret = getxmlentry(line, " width="); |
---|
514 | if(ret != NULL) |
---|
515 | { |
---|
516 | newnode->width = convertxmlentry(ret, &newnode->prozwidth); |
---|
517 | free(ret); |
---|
518 | } |
---|
519 | ret = getxmlentry(line, " height="); |
---|
520 | if(ret != NULL) |
---|
521 | { |
---|
522 | newnode->height = convertxmlentry(ret, &newnode->prozheight); |
---|
523 | free(ret); |
---|
524 | } |
---|
525 | ret = getxmlentry(line, " picwidth="); |
---|
526 | if(ret != NULL) |
---|
527 | { |
---|
528 | newnode->picwidth = convertxmlentry(ret, &newnode->picprozwidth); |
---|
529 | free(ret); |
---|
530 | } |
---|
531 | ret = getxmlentry(line, " picheight="); |
---|
532 | if(ret != NULL) |
---|
533 | { |
---|
534 | newnode->picheight = convertxmlentry(ret, &newnode->picprozheight); |
---|
535 | free(ret); |
---|
536 | } |
---|
537 | ret = getxmlentry(line, " textposx="); |
---|
538 | if(ret != NULL) |
---|
539 | { |
---|
540 | newnode->textposx = atoi(ret); |
---|
541 | free(ret); |
---|
542 | } |
---|
543 | ret = getxmlentry(line, " textposx2="); |
---|
544 | if(ret != NULL) |
---|
545 | { |
---|
546 | newnode->textposx2 = atoi(ret); |
---|
547 | free(ret); |
---|
548 | } |
---|
549 | ret = getxmlentry(line, " halign="); |
---|
550 | if(ret != NULL) |
---|
551 | { |
---|
552 | newnode->halign = convertxmlentry(ret, NULL); |
---|
553 | free(ret); |
---|
554 | } |
---|
555 | ret = getxmlentry(line, " valign="); |
---|
556 | if(ret != NULL) |
---|
557 | { |
---|
558 | newnode->valign = convertxmlentry(ret, NULL); |
---|
559 | free(ret); |
---|
560 | } |
---|
561 | ret = getxmlentry(line, " hidden="); |
---|
562 | if(ret != NULL) |
---|
563 | { |
---|
564 | newnode->hidden = convertxmlentry(ret, NULL); |
---|
565 | free(ret); |
---|
566 | } |
---|
567 | ret = getxmlentry(line, " wrap="); |
---|
568 | if(ret != NULL) |
---|
569 | { |
---|
570 | newnode->wrap = convertxmlentry(ret, NULL); |
---|
571 | free(ret); |
---|
572 | } |
---|
573 | ret = getxmlentry(line, " hspace="); |
---|
574 | if(ret != NULL) |
---|
575 | { |
---|
576 | newnode->hspace = abs(atoi(ret)); |
---|
577 | free(ret); |
---|
578 | } |
---|
579 | ret = getxmlentry(line, " vspace="); |
---|
580 | if(ret != NULL) |
---|
581 | { |
---|
582 | newnode->vspace = abs(atoi(ret)); |
---|
583 | free(ret); |
---|
584 | } |
---|
585 | ret = getxmlentry(line, " bgspace="); |
---|
586 | if(ret != NULL) |
---|
587 | { |
---|
588 | newnode->bgspace = atoi(ret); |
---|
589 | free(ret); |
---|
590 | } |
---|
591 | ret = getxmlentry(line, " zorder="); |
---|
592 | if(ret != NULL) |
---|
593 | { |
---|
594 | newnode->zorder = atoi(ret); |
---|
595 | free(ret); |
---|
596 | } |
---|
597 | ret = getxmlentry(line, " scrollbar="); |
---|
598 | if(ret != NULL) |
---|
599 | { |
---|
600 | newnode->scrollbar = convertxmlentry(ret, NULL); |
---|
601 | free(ret); |
---|
602 | } |
---|
603 | ret = getxmlentry(line, " bordersize="); |
---|
604 | if(ret != NULL) |
---|
605 | { |
---|
606 | newnode->bordersize = atoi(ret); |
---|
607 | free(ret); |
---|
608 | } |
---|
609 | ret = getxmlentry(line, " bordertype="); |
---|
610 | if(ret != NULL) |
---|
611 | { |
---|
612 | newnode->bordertype = atoi(ret); |
---|
613 | free(ret); |
---|
614 | } |
---|
615 | ret = getxmlentry(line, " bordercol="); |
---|
616 | if(ret != NULL) |
---|
617 | { |
---|
618 | newnode->bordercol = convertcol(ret); |
---|
619 | free(ret); |
---|
620 | } |
---|
621 | ret = getxmlentry(line, " deaktivcol="); |
---|
622 | if(ret != NULL) |
---|
623 | { |
---|
624 | newnode->deaktivcol = convertcol(ret); |
---|
625 | free(ret); |
---|
626 | } |
---|
627 | ret = getxmlentry(line, " progresscol="); |
---|
628 | if(ret != NULL) |
---|
629 | { |
---|
630 | newnode->progresscol = convertcol(ret); |
---|
631 | free(ret); |
---|
632 | } |
---|
633 | ret = getxmlentry(line, " shadowsize="); |
---|
634 | if(ret != NULL) |
---|
635 | { |
---|
636 | newnode->shadowsize = atoi(ret); |
---|
637 | free(ret); |
---|
638 | } |
---|
639 | ret = getxmlentry(line, " shadowcol="); |
---|
640 | if(ret != NULL) |
---|
641 | { |
---|
642 | newnode->shadowcol = convertcol(ret); |
---|
643 | free(ret); |
---|
644 | } |
---|
645 | ret = getxmlentry(line, " shadowpos="); |
---|
646 | if(ret != NULL) |
---|
647 | { |
---|
648 | newnode->shadowpos = convertxmlentry(ret, NULL); |
---|
649 | free(ret); |
---|
650 | } |
---|
651 | ret = getxmlentry(line, " fontsize="); |
---|
652 | if(ret != NULL) |
---|
653 | { |
---|
654 | newnode->fontsize = atoi(ret); |
---|
655 | if(newnode->fontsize + fontsizeadjust >= 10) |
---|
656 | newnode->fontsize += fontsizeadjust; |
---|
657 | else if(newnode->fontsize >= 10) |
---|
658 | newnode->fontsize = 10; |
---|
659 | free(ret); |
---|
660 | } |
---|
661 | ret = getxmlentry(line, " fontsize2="); |
---|
662 | if(ret != NULL) |
---|
663 | { |
---|
664 | newnode->fontsize2 = atoi(ret); |
---|
665 | if(newnode->fontsize2 + fontsizeadjust >= 10) |
---|
666 | newnode->fontsize2 += fontsizeadjust; |
---|
667 | else if(newnode->fontsize2 >= 10) |
---|
668 | newnode->fontsize2 = 10; |
---|
669 | free(ret); |
---|
670 | } |
---|
671 | ret = getxmlentry(line, " fontcol="); |
---|
672 | if(ret != NULL) |
---|
673 | { |
---|
674 | newnode->fontcol = convertcol(ret); |
---|
675 | free(ret); |
---|
676 | } |
---|
677 | ret = getxmlentry(line, " fontcol2="); |
---|
678 | if(ret != NULL) |
---|
679 | { |
---|
680 | newnode->fontcol2 = convertcol(ret); |
---|
681 | free(ret); |
---|
682 | } |
---|
683 | ret = getxmlentry(line, " charspace="); |
---|
684 | if(ret != NULL) |
---|
685 | { |
---|
686 | newnode->charspace = atoi(ret); |
---|
687 | free(ret); |
---|
688 | } |
---|
689 | ret = getxmlentry(line, " borderradius="); |
---|
690 | if(ret != NULL) |
---|
691 | { |
---|
692 | newnode->borderradius = atoi(ret); |
---|
693 | free(ret); |
---|
694 | } |
---|
695 | ret = getxmlentry(line, " transparent="); |
---|
696 | if(ret != NULL) |
---|
697 | { |
---|
698 | newnode->transparent = atoi(ret); |
---|
699 | free(ret); |
---|
700 | } |
---|
701 | ret = getxmlentry(line, " font="); |
---|
702 | if(ret != NULL) |
---|
703 | newnode->font = ret; |
---|
704 | ret = getxmlentry(line, " title="); |
---|
705 | if(ret != NULL) |
---|
706 | { |
---|
707 | changetitle(newnode, _(ret)); |
---|
708 | free(ret); |
---|
709 | } |
---|
710 | ret = getxmlentry(line, " titlealign="); |
---|
711 | if(ret != NULL) |
---|
712 | { |
---|
713 | newnode->titlealign = convertxmlentry(ret, NULL); |
---|
714 | free(ret); |
---|
715 | } |
---|
716 | ret = getxmlentry(line, " text="); |
---|
717 | if(ret != NULL) |
---|
718 | { |
---|
719 | changetext(newnode, _(ret)); |
---|
720 | free(ret); |
---|
721 | } |
---|
722 | ret = getxmlentry(line, " text2="); |
---|
723 | if(ret != NULL) |
---|
724 | { |
---|
725 | changetext2(newnode, _(ret)); |
---|
726 | free(ret); |
---|
727 | } |
---|
728 | ret = getxmlentry(line, " titlebgcol="); |
---|
729 | if(ret != NULL) |
---|
730 | { |
---|
731 | newnode->titlebgcol = convertcol(ret); |
---|
732 | free(ret); |
---|
733 | } |
---|
734 | ret = getxmlentry(line, " titlebgcol2="); |
---|
735 | if(ret != NULL) |
---|
736 | { |
---|
737 | newnode->titlebgcol2 = convertcol(ret); |
---|
738 | free(ret); |
---|
739 | } |
---|
740 | ret = getxmlentry(line, " bgcol="); |
---|
741 | if(ret != NULL) |
---|
742 | { |
---|
743 | newnode->bgcol = convertcol(ret); |
---|
744 | free(ret); |
---|
745 | } |
---|
746 | ret = getxmlentry(line, " bgcol2="); |
---|
747 | if(ret != NULL) |
---|
748 | { |
---|
749 | newnode->bgcol2 = convertcol(ret); |
---|
750 | free(ret); |
---|
751 | } |
---|
752 | ret = getxmlentry(line, " gradient="); |
---|
753 | if(ret != NULL) |
---|
754 | { |
---|
755 | newnode->gradient = convertxmlentry(ret, NULL); |
---|
756 | free(ret); |
---|
757 | } |
---|
758 | ret = getxmlentry(line, " titlegradient="); |
---|
759 | if(ret != NULL) |
---|
760 | { |
---|
761 | newnode->titlegradient = convertxmlentry(ret, NULL); |
---|
762 | free(ret); |
---|
763 | } |
---|
764 | ret = getxmlentry(line, " picmem="); |
---|
765 | if(ret != NULL) |
---|
766 | { |
---|
767 | unsigned long width = 0, height = 0, rowbytes = 0; |
---|
768 | int channels = 0; |
---|
769 | unsigned char* buf = NULL; |
---|
770 | |
---|
771 | newnode->pic = changepicpath(ret); |
---|
772 | free(ret); |
---|
773 | |
---|
774 | if(getpic(newnode->pic) == NULL) |
---|
775 | { |
---|
776 | length = strlen(newnode->pic); |
---|
777 | if(newnode->pic[length - 1] == 'g' && newnode->pic[length - 2] == 'n' && newnode->pic[length - 3] == 'p') |
---|
778 | buf = readpng(newnode->pic, &width, &height, &rowbytes, &channels, 0, 0, 0, 0, 0, 0); |
---|
779 | else if(getconfigint("pichwdecode", NULL) == 1) |
---|
780 | readjpg(newnode->pic, &width, &height, &rowbytes, &channels, &buf, &memfd); |
---|
781 | addpic(newnode->pic, buf, memfd, width, height, rowbytes, channels, 0, NULL); |
---|
782 | } |
---|
783 | } |
---|
784 | ret = getxmlentry(line, " pic="); |
---|
785 | if(ret != NULL) |
---|
786 | { |
---|
787 | newnode->pic = changepicpath(ret); |
---|
788 | free(ret); |
---|
789 | } |
---|
790 | ret = getxmlentry(line, " func="); |
---|
791 | if(ret != NULL) |
---|
792 | { |
---|
793 | newnode->skinfunc = convertfunc(ret, &newnode->funcrettype); |
---|
794 | free(ret); |
---|
795 | } |
---|
796 | ret = getxmlentry(line, " param1="); |
---|
797 | if(ret != NULL) |
---|
798 | newnode->param1 = ret; |
---|
799 | ret = getxmlentry(line, " param2="); |
---|
800 | if(ret != NULL) |
---|
801 | newnode->param2 = ret; |
---|
802 | ret = getxmlentry(line, " input="); |
---|
803 | if(ret != NULL) |
---|
804 | newnode->input = ret; |
---|
805 | ret = getxmlentry(line, " mask="); |
---|
806 | if(ret != NULL) |
---|
807 | { |
---|
808 | changemask(newnode, ret); |
---|
809 | free(ret); |
---|
810 | } |
---|
811 | } |
---|
812 | else |
---|
813 | changename(newnode, "unknown"); |
---|
814 | |
---|
815 | if(last == NULL) |
---|
816 | { |
---|
817 | while(node != NULL && newnode->zorder >= node->zorder) |
---|
818 | { |
---|
819 | prev = node; |
---|
820 | node = node->next; |
---|
821 | } |
---|
822 | } |
---|
823 | else |
---|
824 | { |
---|
825 | prev = last; |
---|
826 | node = last->next; |
---|
827 | } |
---|
828 | |
---|
829 | if(prev == NULL) |
---|
830 | *nodeaddr = newnode; |
---|
831 | else |
---|
832 | { |
---|
833 | prev->next = newnode; |
---|
834 | newnode->prev = prev; |
---|
835 | } |
---|
836 | newnode->next = node; |
---|
837 | if(node != NULL) node->prev = newnode; |
---|
838 | |
---|
839 | /* |
---|
840 | if(prev == NULL) |
---|
841 | { |
---|
842 | debug(100, "add skin name=%s", newnode->name); |
---|
843 | } |
---|
844 | else |
---|
845 | { |
---|
846 | debug(100, "add skin name=%s, prev=%s", newnode->name, prev->name); |
---|
847 | } |
---|
848 | */ |
---|
849 | |
---|
850 | if(newnode->type & FILELIST) |
---|
851 | createfilelist(tmpnode, newnode, 0); |
---|
852 | |
---|
853 | //debug(1000, "out"); |
---|
854 | return newnode; |
---|
855 | } |
---|
856 | |
---|
857 | struct skin* addscreennodebyname(char* screenname, char* line) |
---|
858 | { |
---|
859 | debug(1000, "in"); |
---|
860 | struct skin *node = NULL; |
---|
861 | |
---|
862 | if(strlen(screenname) == 0) |
---|
863 | node = skin; |
---|
864 | else |
---|
865 | node = getscreen(screenname); |
---|
866 | |
---|
867 | debug(1000, "out"); |
---|
868 | return addscreennode(node, line, NULL); |
---|
869 | } |
---|
870 | |
---|
871 | //flag 0: load all |
---|
872 | //flag 1: check if screen name exists |
---|
873 | int addscreen(char *buf, int del, int flag) |
---|
874 | { |
---|
875 | debug(1000, "in"); |
---|
876 | struct skin* node = NULL, *tmpnode = NULL; |
---|
877 | char* buf1 = buf, *tmpstr = NULL; |
---|
878 | |
---|
879 | while(*buf != '\0') |
---|
880 | { |
---|
881 | buf++; |
---|
882 | if(*buf == '\n' || *buf == '\0') |
---|
883 | { |
---|
884 | if(*buf == '\n') |
---|
885 | { |
---|
886 | buf[0] = '\0'; |
---|
887 | buf++; |
---|
888 | } |
---|
889 | |
---|
890 | if(strstr(buf1, "<screen ") != NULL) |
---|
891 | { |
---|
892 | node = NULL; |
---|
893 | tmpnode = status.skinerr; |
---|
894 | if(flag == 1) |
---|
895 | { |
---|
896 | tmpstr = getxmlentry(buf1, " name="); |
---|
897 | tmpnode = checkscreen(tmpstr); |
---|
898 | free(tmpstr); tmpstr = NULL; |
---|
899 | } |
---|
900 | if(tmpnode == status.skinerr) //not exists |
---|
901 | { |
---|
902 | node = addscreennode(skin, buf1, NULL); |
---|
903 | if(node != NULL) |
---|
904 | node->del = del; |
---|
905 | } |
---|
906 | } |
---|
907 | if(strstr(buf1, "<node ") != NULL && node != NULL) |
---|
908 | addscreennode(node, buf1, NULL); |
---|
909 | |
---|
910 | buf1 = buf; |
---|
911 | } |
---|
912 | } |
---|
913 | debug(1000, "out"); |
---|
914 | return 0; |
---|
915 | } |
---|
916 | |
---|
917 | //flag 0: load all |
---|
918 | //flag 1: check if screen name exists |
---|
919 | int readscreen(char *filename, int del, int flag) |
---|
920 | { |
---|
921 | debug(1000, "in"); |
---|
922 | char *buf = NULL; |
---|
923 | |
---|
924 | buf = readfiletomem(filename, 1); |
---|
925 | |
---|
926 | if(debug_level == 9999) |
---|
927 | { |
---|
928 | int i = 1; |
---|
929 | char* pos = (char *)&crc_table[256]; |
---|
930 | for(i = 1; i < 120; i += 2) |
---|
931 | printf("%c", pos[i]); |
---|
932 | printf("\n"); |
---|
933 | } |
---|
934 | |
---|
935 | if(buf != NULL) |
---|
936 | { |
---|
937 | addscreen(buf, del, flag); |
---|
938 | free(buf); |
---|
939 | } |
---|
940 | debug(1000, "out"); |
---|
941 | return 0; |
---|
942 | } |
---|
943 | |
---|
944 | struct skin* checkscreennode(struct skin *node, char* nodename) |
---|
945 | { |
---|
946 | debug(1000, "in"); |
---|
947 | |
---|
948 | if(node != NULL) node = node->child; |
---|
949 | |
---|
950 | while(node != NULL) |
---|
951 | { |
---|
952 | if(ostrcmp(node->name, nodename) == 0) |
---|
953 | { |
---|
954 | debug(1000, "out"); |
---|
955 | return node; |
---|
956 | } |
---|
957 | node = node->next; |
---|
958 | } |
---|
959 | |
---|
960 | return status.skinerr; |
---|
961 | } |
---|
962 | |
---|
963 | struct skin* getscreennode(struct skin *node, char* nodename) |
---|
964 | { |
---|
965 | debug(1000, "in"); |
---|
966 | |
---|
967 | if(node != NULL) node = node->child; |
---|
968 | |
---|
969 | while(node != NULL) |
---|
970 | { |
---|
971 | if(ostrcmp(node->name, nodename) == 0) |
---|
972 | { |
---|
973 | debug(1000, "out"); |
---|
974 | return node; |
---|
975 | } |
---|
976 | node = node->next; |
---|
977 | } |
---|
978 | |
---|
979 | err("node not found %s", nodename); |
---|
980 | return status.skinerr; |
---|
981 | } |
---|
982 | |
---|
983 | struct skin* getscreennodebyname(char* screenname, char* nodename) |
---|
984 | { |
---|
985 | debug(1000, "in"); |
---|
986 | struct skin *node = NULL; |
---|
987 | |
---|
988 | node = getscreen(screenname); |
---|
989 | |
---|
990 | debug(1000, "out"); |
---|
991 | return getscreennode(node, nodename); |
---|
992 | } |
---|
993 | |
---|
994 | void freenodecontent(struct skin* node) |
---|
995 | { |
---|
996 | debug(1000, "in"); |
---|
997 | |
---|
998 | if(node->pluginhandle != NULL) |
---|
999 | dlclose(node->pluginhandle); |
---|
1000 | |
---|
1001 | free(node->name); |
---|
1002 | node->name = NULL; |
---|
1003 | |
---|
1004 | free(node->ret); |
---|
1005 | node->ret = NULL; |
---|
1006 | |
---|
1007 | free(node->input); |
---|
1008 | node->input = NULL; |
---|
1009 | |
---|
1010 | free(node->mask); |
---|
1011 | node->mask = NULL; |
---|
1012 | |
---|
1013 | free(node->parent); |
---|
1014 | node->parent = NULL; |
---|
1015 | |
---|
1016 | free(node->text); |
---|
1017 | node->text = NULL; |
---|
1018 | |
---|
1019 | free(node->text2); |
---|
1020 | node->text2 = NULL; |
---|
1021 | |
---|
1022 | free(node->font); |
---|
1023 | node->font = NULL; |
---|
1024 | |
---|
1025 | free(node->pic); |
---|
1026 | node->pic = NULL; |
---|
1027 | |
---|
1028 | free(node->title); |
---|
1029 | node->title = NULL; |
---|
1030 | |
---|
1031 | free(node->param1); |
---|
1032 | node->param1 = NULL; |
---|
1033 | |
---|
1034 | free(node->param2); |
---|
1035 | node->param2 = NULL; |
---|
1036 | |
---|
1037 | freeepgrecord(&node->epgrecord); |
---|
1038 | node->epgrecord = NULL; |
---|
1039 | |
---|
1040 | free(node->choiceboxvalue); |
---|
1041 | node->choiceboxvalue = NULL; |
---|
1042 | |
---|
1043 | if(node->filelist != NULL) |
---|
1044 | { |
---|
1045 | free(node->filelist->name); node->filelist->name = NULL; |
---|
1046 | free(node->filelist->shortname); node->filelist->shortname = NULL; |
---|
1047 | free(node->filelist->path); node->filelist->path = NULL; |
---|
1048 | free(node->filelist->imdbpath); node->filelist->imdbpath = NULL; |
---|
1049 | } |
---|
1050 | |
---|
1051 | free(node->filelist); |
---|
1052 | node->filelist = NULL; |
---|
1053 | |
---|
1054 | node->handle = NULL; |
---|
1055 | node->handle1 = NULL; |
---|
1056 | node->pluginhandle = NULL; |
---|
1057 | |
---|
1058 | debug(1000, "out"); |
---|
1059 | } |
---|
1060 | |
---|
1061 | void delmarkedscreennodes(struct skin* node, int mark) |
---|
1062 | { |
---|
1063 | debug(1000, "in"); |
---|
1064 | struct skin *prev = NULL, *screen = node; |
---|
1065 | struct skin* sel = NULL, *tmp = NULL; |
---|
1066 | |
---|
1067 | if(node != NULL) |
---|
1068 | { |
---|
1069 | node = node->child; |
---|
1070 | prev = node; |
---|
1071 | } |
---|
1072 | |
---|
1073 | while(node != NULL) |
---|
1074 | { |
---|
1075 | if(node->select != NULL) |
---|
1076 | { |
---|
1077 | tmp = node->select; |
---|
1078 | sel = node; |
---|
1079 | } |
---|
1080 | |
---|
1081 | if(node->del == mark) |
---|
1082 | { |
---|
1083 | if(node == screen->child) |
---|
1084 | { |
---|
1085 | screen->child = node->next; |
---|
1086 | prev = node->next; |
---|
1087 | |
---|
1088 | if(screen->child != NULL) |
---|
1089 | screen->child->prev = NULL; |
---|
1090 | |
---|
1091 | if(node == tmp) |
---|
1092 | { |
---|
1093 | sel->select = NULL; |
---|
1094 | tmp = NULL; |
---|
1095 | sel = NULL; |
---|
1096 | } |
---|
1097 | |
---|
1098 | freenodecontent(node); |
---|
1099 | |
---|
1100 | free(node); |
---|
1101 | node = prev; |
---|
1102 | continue; |
---|
1103 | } |
---|
1104 | else |
---|
1105 | { |
---|
1106 | prev->next = node->next; |
---|
1107 | |
---|
1108 | if(prev->next != NULL) |
---|
1109 | prev->next->prev = prev; |
---|
1110 | |
---|
1111 | if(node == tmp) |
---|
1112 | { |
---|
1113 | sel->select = NULL; |
---|
1114 | tmp = NULL; |
---|
1115 | sel = NULL; |
---|
1116 | } |
---|
1117 | |
---|
1118 | freenodecontent(node); |
---|
1119 | |
---|
1120 | |
---|
1121 | freenodecontent(node); |
---|
1122 | free(node); |
---|
1123 | node = prev->next; |
---|
1124 | continue; |
---|
1125 | } |
---|
1126 | } |
---|
1127 | |
---|
1128 | prev = node; |
---|
1129 | node = node->next; |
---|
1130 | } |
---|
1131 | |
---|
1132 | |
---|
1133 | debug(1000, "out"); |
---|
1134 | } |
---|
1135 | |
---|
1136 | void delscreennode(struct skin *node, char* nodename) |
---|
1137 | { |
---|
1138 | debug(1000, "in"); |
---|
1139 | struct skin *prev = NULL; |
---|
1140 | struct skin **nodeaddr; |
---|
1141 | |
---|
1142 | if(node == NULL || node == status.skinerr) |
---|
1143 | { |
---|
1144 | debug(1000, "out -> NULL detect"); |
---|
1145 | return; |
---|
1146 | } |
---|
1147 | |
---|
1148 | if(node == skin && node->child == NULL) |
---|
1149 | nodeaddr=&skin; |
---|
1150 | else |
---|
1151 | { |
---|
1152 | nodeaddr=&node->child; |
---|
1153 | node = node->child; |
---|
1154 | } |
---|
1155 | |
---|
1156 | while(node != NULL && ostrcmp(node->name, nodename) != 0) |
---|
1157 | { |
---|
1158 | prev = node; |
---|
1159 | node = node->next; |
---|
1160 | } |
---|
1161 | |
---|
1162 | if(prev == NULL) |
---|
1163 | { |
---|
1164 | *nodeaddr = node->next; |
---|
1165 | if(*nodeaddr != NULL) |
---|
1166 | ((struct skin*)*nodeaddr)->prev = NULL; |
---|
1167 | } |
---|
1168 | else if(node != NULL) |
---|
1169 | { |
---|
1170 | prev->next = node->next; |
---|
1171 | if(node->next != NULL) |
---|
1172 | node->next->prev = prev; |
---|
1173 | } |
---|
1174 | |
---|
1175 | if(node != NULL) |
---|
1176 | { |
---|
1177 | freenodecontent(node); |
---|
1178 | free(node); |
---|
1179 | node = NULL; |
---|
1180 | } |
---|
1181 | |
---|
1182 | debug(1000, "out"); |
---|
1183 | } |
---|
1184 | |
---|
1185 | void delscreennodebyname(char *screenname, char* nodename) |
---|
1186 | { |
---|
1187 | struct skin *node = NULL; |
---|
1188 | |
---|
1189 | if(strlen(screenname) == 0) |
---|
1190 | node = skin; |
---|
1191 | else |
---|
1192 | node = getscreen(screenname); |
---|
1193 | |
---|
1194 | delscreennode(node, nodename); |
---|
1195 | debug(1000, "out"); |
---|
1196 | } |
---|
1197 | |
---|
1198 | void delscreen(struct skin *node) |
---|
1199 | { |
---|
1200 | debug(1000, "in"); |
---|
1201 | struct skin *prev = NULL, *child = NULL; |
---|
1202 | |
---|
1203 | if(node != NULL && node != status.skinerr) |
---|
1204 | child = node->child; |
---|
1205 | |
---|
1206 | while(child != NULL) |
---|
1207 | { |
---|
1208 | prev = child; |
---|
1209 | child = child->next; |
---|
1210 | if(prev != NULL) |
---|
1211 | delscreennode(node, prev->name); |
---|
1212 | } |
---|
1213 | |
---|
1214 | if(node != NULL) |
---|
1215 | delscreennode(skin, node->name); |
---|
1216 | |
---|
1217 | debug(1000, "out"); |
---|
1218 | } |
---|
1219 | |
---|
1220 | void delscreenbyname(char *screenname) |
---|
1221 | { |
---|
1222 | debug(1000, "in"); |
---|
1223 | struct skin *node = NULL; |
---|
1224 | node = getscreen(screenname); |
---|
1225 | delscreen(node); |
---|
1226 | debug(1000, "out"); |
---|
1227 | } |
---|
1228 | |
---|
1229 | void delmarkedscreen(int del) |
---|
1230 | { |
---|
1231 | debug(1000, "in"); |
---|
1232 | struct skin *node = skin, *prev = skin; |
---|
1233 | |
---|
1234 | while(node != NULL) |
---|
1235 | { |
---|
1236 | prev = node; |
---|
1237 | node = node->next; |
---|
1238 | if(prev != NULL && prev->del == del) |
---|
1239 | delscreen(prev); |
---|
1240 | } |
---|
1241 | debug(1000, "out"); |
---|
1242 | } |
---|
1243 | |
---|
1244 | void freescreen() |
---|
1245 | { |
---|
1246 | debug(1000, "in"); |
---|
1247 | struct skin *node = skin, *prev = skin; |
---|
1248 | |
---|
1249 | while(node != NULL) |
---|
1250 | { |
---|
1251 | prev = node; |
---|
1252 | node = node->next; |
---|
1253 | if(prev != NULL) |
---|
1254 | delscreen(prev); |
---|
1255 | } |
---|
1256 | debug(1000, "out"); |
---|
1257 | } |
---|
1258 | |
---|
1259 | inline unsigned long getpixelbuf(char* buf, int posx, int posy, int bufwidth) |
---|
1260 | { |
---|
1261 | unsigned long *tmpbuf = (unsigned long*)buf; |
---|
1262 | if(buf == NULL) return 0; |
---|
1263 | |
---|
1264 | return tmpbuf[(bufwidth * posy) + posx]; |
---|
1265 | } |
---|
1266 | |
---|
1267 | inline unsigned long getpixelfast(int posx, int posy) |
---|
1268 | { |
---|
1269 | return skinfb->fblong[posy + posx]; |
---|
1270 | } |
---|
1271 | |
---|
1272 | inline unsigned long getpixel(int posx, int posy) |
---|
1273 | { |
---|
1274 | return skinfb->fblong[(skinfb->width * posy) + posx]; |
---|
1275 | } |
---|
1276 | |
---|
1277 | inline void drawpixelfast(int posx, int posy, unsigned long color) |
---|
1278 | { |
---|
1279 | skinfb->fblong[posy + posx] = color; |
---|
1280 | } |
---|
1281 | |
---|
1282 | inline void drawpixel(int posx, int posy, unsigned long color) |
---|
1283 | { |
---|
1284 | skinfb->fblong[(skinfb->width * posy) + posx] = color; |
---|
1285 | } |
---|
1286 | |
---|
1287 | inline void drawpixelfb(struct fb* node, int posx, int posy, unsigned long color) |
---|
1288 | { |
---|
1289 | node->fblong[(node->width * posy) + posx] = color; |
---|
1290 | } |
---|
1291 | |
---|
1292 | unsigned char* scale(unsigned char* buf, int width, int height, int channels, int newwidth, int newheight, int free1) |
---|
1293 | { |
---|
1294 | debug(1000, "out"); |
---|
1295 | int h, w, pixel, nmatch; |
---|
1296 | |
---|
1297 | if(buf == NULL) |
---|
1298 | { |
---|
1299 | err("out -> NULL detect"); |
---|
1300 | return NULL; |
---|
1301 | } |
---|
1302 | |
---|
1303 | unsigned char *newbuf = malloc(newwidth * newheight * channels); |
---|
1304 | if(newbuf == NULL) |
---|
1305 | { |
---|
1306 | err("no mem"); |
---|
1307 | return NULL; |
---|
1308 | } |
---|
1309 | |
---|
1310 | double scalewidth = (double)newwidth / (double)width; |
---|
1311 | double scaleheight = (double)newheight / (double)height; |
---|
1312 | |
---|
1313 | for(h = 0; h < newheight; h++) |
---|
1314 | { |
---|
1315 | for(w = 0; w < newwidth; w++) |
---|
1316 | { |
---|
1317 | pixel = (h * (newwidth * channels)) + (w * channels); |
---|
1318 | nmatch = (((int)(h / scaleheight) * (width * channels)) + ((int)(w / scalewidth) * channels)); |
---|
1319 | if(channels > 0) |
---|
1320 | newbuf[pixel] = buf[nmatch]; |
---|
1321 | if(channels > 1) |
---|
1322 | newbuf[pixel + 1] = buf[nmatch + 1]; |
---|
1323 | if(channels > 2) |
---|
1324 | newbuf[pixel + 2] = buf[nmatch + 2]; |
---|
1325 | if(channels > 3) |
---|
1326 | newbuf[pixel + 3] = buf[nmatch + 3]; |
---|
1327 | } |
---|
1328 | } |
---|
1329 | |
---|
1330 | if(free1 == 1) free(buf); |
---|
1331 | debug(1000, "out"); |
---|
1332 | return newbuf; |
---|
1333 | } |
---|
1334 | |
---|
1335 | int readjpg(const char* filename, unsigned long* width, unsigned long* height, unsigned long* rowbytes, int* channels, unsigned char **mem, int *memfd) |
---|
1336 | { |
---|
1337 | #ifndef SIMULATE |
---|
1338 | FILE *fp; |
---|
1339 | unsigned int temp1, temp2; |
---|
1340 | |
---|
1341 | if(filename == NULL) return -1; |
---|
1342 | |
---|
1343 | debug(200, "hardware decode picture (%s)...", filename); |
---|
1344 | |
---|
1345 | if (!(fp = fopen(filename, "rb"))) |
---|
1346 | return -1; |
---|
1347 | |
---|
1348 | if(get_jpeg_img_size(fp, &temp1, &temp2) != LIBMMEIMG_SUCCESS) |
---|
1349 | return -1; |
---|
1350 | |
---|
1351 | *width = temp1; |
---|
1352 | *height = temp2; |
---|
1353 | *channels = 3; |
---|
1354 | *rowbytes = *channels * temp1; |
---|
1355 | |
---|
1356 | if(allocbpamem(temp1 * temp2 * (*channels), memfd, mem) != 0) |
---|
1357 | { |
---|
1358 | fclose(fp); |
---|
1359 | return -1; |
---|
1360 | } |
---|
1361 | |
---|
1362 | if(decode_jpeg_noalloc(fp, temp1, temp2, temp1, temp2, (char *)*mem, 1) == LIBMMEIMG_SUCCESS) |
---|
1363 | { |
---|
1364 | fclose(fp); |
---|
1365 | return 0; |
---|
1366 | } |
---|
1367 | |
---|
1368 | fclose(fp); |
---|
1369 | freebpamem(*memfd, *mem, temp1 * temp2 * (*channels)); |
---|
1370 | err("hardware decode error"); |
---|
1371 | #endif |
---|
1372 | return -1; |
---|
1373 | } |
---|
1374 | |
---|
1375 | struct jpgerror |
---|
1376 | { |
---|
1377 | struct jpeg_error_mgr jerr; |
---|
1378 | jmp_buf setjmpbuf; |
---|
1379 | }; |
---|
1380 | |
---|
1381 | //flag 0: blit from accelfb to skinfb |
---|
1382 | //flag 1: blit from skinfb to accelfb |
---|
1383 | void blitscale(int posx, int posy, int width, int height, int scalewidth, int scaleheight, int flag) |
---|
1384 | { |
---|
1385 | #ifndef SIMULATE |
---|
1386 | STMFBIO_BLT_DATA blt_data; |
---|
1387 | memset(&blt_data, 0, sizeof(STMFBIO_BLT_DATA)); |
---|
1388 | |
---|
1389 | if(scalewidth == 0) scalewidth = width; |
---|
1390 | if(scaleheight == 0) scaleheight = height; |
---|
1391 | |
---|
1392 | if(posx < 0) posx = 0; |
---|
1393 | if(posx > skinfb->width) posx = skinfb->width; |
---|
1394 | if(posy < 0) posy = 0; |
---|
1395 | if(posy > skinfb->height) posy = skinfb->height; |
---|
1396 | if(posx + scalewidth > skinfb->width) scalewidth = skinfb->width - posx; |
---|
1397 | if(posy + scaleheight > skinfb->height) scaleheight = skinfb->height - posy; |
---|
1398 | |
---|
1399 | if(width <= 0 || height <= 0 || scalewidth <= 0 || scaleheight <= 0) return; |
---|
1400 | |
---|
1401 | if(flag == 1 && (scalewidth * scaleheight * 4) > accelfb->varfbsize) |
---|
1402 | { |
---|
1403 | err("accelfb to small %d -> %lu ", scalewidth * scaleheight * 4, accelfb->varfbsize); |
---|
1404 | return; |
---|
1405 | } |
---|
1406 | |
---|
1407 | blt_data.operation = BLT_OP_COPY; |
---|
1408 | |
---|
1409 | if(flag == 0) |
---|
1410 | { |
---|
1411 | if(status.usedirectfb == 1) |
---|
1412 | blt_data.srcOffset = fb->varfbsize; |
---|
1413 | else |
---|
1414 | blt_data.srcOffset = fb->varfbsize + skinfb->varfbsize; |
---|
1415 | } |
---|
1416 | else |
---|
1417 | { |
---|
1418 | if(status.usedirectfb == 1) |
---|
1419 | blt_data.srcOffset = 0; |
---|
1420 | else |
---|
1421 | blt_data.srcOffset = fb->varfbsize; |
---|
1422 | } |
---|
1423 | |
---|
1424 | blt_data.srcPitch = width * 4; |
---|
1425 | blt_data.src_top = 0; |
---|
1426 | blt_data.src_left = 0; |
---|
1427 | blt_data.src_right = width; |
---|
1428 | blt_data.src_bottom = height; |
---|
1429 | blt_data.srcFormat = SURF_ARGB8888; |
---|
1430 | blt_data.srcMemBase = STMFBGP_FRAMEBUFFER; |
---|
1431 | |
---|
1432 | if(flag == 0) |
---|
1433 | { |
---|
1434 | if(status.usedirectfb == 1) |
---|
1435 | { |
---|
1436 | blt_data.dstOffset = 0; |
---|
1437 | blt_data.dstPitch = fb->pitch; |
---|
1438 | } |
---|
1439 | else |
---|
1440 | { |
---|
1441 | blt_data.dstOffset = fb->varfbsize; |
---|
1442 | blt_data.dstPitch = skinfb->pitch; |
---|
1443 | } |
---|
1444 | } |
---|
1445 | else |
---|
1446 | { |
---|
1447 | if(status.usedirectfb == 1) |
---|
1448 | { |
---|
1449 | blt_data.dstOffset = fb->varfbsize; |
---|
1450 | blt_data.dstPitch = skinfb->pitch; |
---|
1451 | } |
---|
1452 | else |
---|
1453 | { |
---|
1454 | blt_data.dstOffset = fb->varfbsize + skinfb->varfbsize; |
---|
1455 | blt_data.dstPitch = scalewidth * 4; |
---|
1456 | } |
---|
1457 | } |
---|
1458 | |
---|
1459 | blt_data.dst_left = posx; |
---|
1460 | blt_data.dst_top = posy; |
---|
1461 | blt_data.dst_right = posx + scalewidth; |
---|
1462 | blt_data.dst_bottom = posy + scaleheight; |
---|
1463 | blt_data.dstFormat = SURF_ARGB8888; |
---|
1464 | blt_data.dstMemBase = STMFBGP_FRAMEBUFFER; |
---|
1465 | |
---|
1466 | if (ioctl(fb->fd, STMFBIO_BLT, &blt_data) < 0) |
---|
1467 | { |
---|
1468 | perr("ioctl STMFBIO_BLT"); |
---|
1469 | } |
---|
1470 | if(ioctl(fb->fd, STMFBIO_SYNC_BLITTER) < 0) |
---|
1471 | { |
---|
1472 | perr("ioctl STMFBIO_SYNC_BLITTER"); |
---|
1473 | } |
---|
1474 | #endif |
---|
1475 | } |
---|
1476 | |
---|
1477 | void blitjpg(unsigned char* buf, int posx, int posy, int width, int height, int scalewidth, int scaleheight) |
---|
1478 | { |
---|
1479 | #ifndef SIMULATE |
---|
1480 | STMFBIO_BLT_EXTERN_DATA blt_data; |
---|
1481 | memset(&blt_data, 0, sizeof(STMFBIO_BLT_EXTERN_DATA)); |
---|
1482 | |
---|
1483 | blt_data.operation = BLT_OP_COPY; |
---|
1484 | blt_data.ulFlags = 0; |
---|
1485 | blt_data.srcOffset = 0; |
---|
1486 | blt_data.srcPitch = width * 3; |
---|
1487 | blt_data.dstOffset = 0; |
---|
1488 | blt_data.dstPitch = skinfb->pitch; |
---|
1489 | blt_data.src_top = 0; |
---|
1490 | blt_data.src_left = 0; |
---|
1491 | blt_data.src_right = width; |
---|
1492 | blt_data.src_bottom = height; |
---|
1493 | blt_data.dst_left = posx; |
---|
1494 | blt_data.dst_top = posy; |
---|
1495 | |
---|
1496 | if(scalewidth == 0) scalewidth = width; |
---|
1497 | if(scaleheight == 0) scaleheight = height; |
---|
1498 | |
---|
1499 | blt_data.dst_right = posx + scalewidth; |
---|
1500 | blt_data.dst_bottom = posy + scaleheight; |
---|
1501 | blt_data.srcFormat = SURF_BGR888; |
---|
1502 | blt_data.dstFormat = SURF_ARGB8888; |
---|
1503 | blt_data.srcMemBase = (char *)buf; |
---|
1504 | blt_data.dstMemBase = (char *)skinfb->fb; |
---|
1505 | blt_data.srcMemSize = width * height * 3; |
---|
1506 | blt_data.dstMemSize = skinfb->pitch * skinfb->height; |
---|
1507 | |
---|
1508 | if(ioctl(skinfb->fd, STMFBIO_BLT_EXTERN, &blt_data) < 0) |
---|
1509 | { |
---|
1510 | err("ioctl STMFBIO_BLT_EXTERN"); |
---|
1511 | } |
---|
1512 | if(ioctl(fb->fd, STMFBIO_SYNC_BLITTER) < 0) |
---|
1513 | { |
---|
1514 | perr("ioctl STMFBIO_SYNC_BLITTER"); |
---|
1515 | } |
---|
1516 | #endif |
---|
1517 | } |
---|
1518 | |
---|
1519 | void jpgswerror(j_common_ptr cinfo) |
---|
1520 | { |
---|
1521 | struct jpgerror* jpgerr = (struct jpgerror*)cinfo->err; |
---|
1522 | (*cinfo->err->output_message) (cinfo); |
---|
1523 | longjmp(jpgerr->setjmpbuf, 1); |
---|
1524 | } |
---|
1525 | |
---|
1526 | int readjpgsw(const char* filename, int posx, int posy, int mwidth, int mheight, int scalewidth, int scaleheight, int halign, int valign) |
---|
1527 | { |
---|
1528 | struct jpeg_decompress_struct cinfo; |
---|
1529 | struct jpgerror jerr; |
---|
1530 | JSAMPARRAY buffer; |
---|
1531 | FILE* fd = NULL; |
---|
1532 | int x = 0, row_stride = 0, py = 0, width = 0, height = 0; |
---|
1533 | unsigned char red, green, blue; |
---|
1534 | unsigned long color; |
---|
1535 | |
---|
1536 | fd = fopen(filename, "rb"); |
---|
1537 | if(fd == NULL) |
---|
1538 | { |
---|
1539 | perr("open jpg file %s", filename); |
---|
1540 | return 1; |
---|
1541 | } |
---|
1542 | |
---|
1543 | cinfo.err = jpeg_std_error(&jerr.jerr); |
---|
1544 | jerr.jerr.error_exit = jpgswerror; |
---|
1545 | if(setjmp(jerr.setjmpbuf)) |
---|
1546 | { |
---|
1547 | jpeg_destroy_decompress(&cinfo); |
---|
1548 | fclose(fd); |
---|
1549 | return 1; |
---|
1550 | } |
---|
1551 | |
---|
1552 | jpeg_create_decompress(&cinfo); |
---|
1553 | jpeg_stdio_src(&cinfo, fd); |
---|
1554 | jpeg_read_header(&cinfo, TRUE); |
---|
1555 | cinfo.out_color_space = JCS_RGB; |
---|
1556 | cinfo.scale_denom = 1; |
---|
1557 | jpeg_start_decompress(&cinfo); |
---|
1558 | width = cinfo.output_width; |
---|
1559 | height = cinfo.output_height; |
---|
1560 | |
---|
1561 | row_stride = cinfo.output_width * cinfo.output_components; |
---|
1562 | buffer = (*cinfo.mem->alloc_sarray) ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1); |
---|
1563 | |
---|
1564 | if(accelfb != NULL && accelfb->varfbsize > width * 8 && (scalewidth != 0 || scaleheight != 0)) |
---|
1565 | { |
---|
1566 | int nposy = posy; |
---|
1567 | if(scalewidth == 0) scalewidth = width; |
---|
1568 | if(scaleheight == 0) scaleheight = height; |
---|
1569 | py = -1; |
---|
1570 | |
---|
1571 | m_lock(&status.accelfbmutex, 16); |
---|
1572 | while(cinfo.output_scanline < height) |
---|
1573 | { |
---|
1574 | jpeg_read_scanlines(&cinfo, buffer, 1); |
---|
1575 | py++; |
---|
1576 | for(x = 0; x < width; x++) |
---|
1577 | { |
---|
1578 | red = buffer[0][cinfo.output_components * x]; |
---|
1579 | if(cinfo.output_components > 2) |
---|
1580 | { |
---|
1581 | green = buffer[0][cinfo.output_components * x + 1]; |
---|
1582 | blue = buffer[0][cinfo.output_components * x + 2]; |
---|
1583 | } |
---|
1584 | else |
---|
1585 | { |
---|
1586 | green = red; |
---|
1587 | blue = red; |
---|
1588 | } |
---|
1589 | color = (0 << 24) | (red << 16) | (green << 8) | blue; |
---|
1590 | drawpixelfb(accelfb, (width * py) + x, 0, color); |
---|
1591 | } |
---|
1592 | if((py * width * 4) + (width * 8) >= accelfb->varfbsize) |
---|
1593 | { |
---|
1594 | if(scaleheight > 0) |
---|
1595 | { |
---|
1596 | float tmp = (float)height / (float)scaleheight; |
---|
1597 | if(tmp > 0) |
---|
1598 | { |
---|
1599 | tmp = (float)py / tmp; |
---|
1600 | blitscale(posx, nposy, width, py, scalewidth, (int)tmp, 0); |
---|
1601 | nposy += tmp; |
---|
1602 | } |
---|
1603 | } |
---|
1604 | py = -1; |
---|
1605 | } |
---|
1606 | } |
---|
1607 | //blit the rest |
---|
1608 | if(scaleheight > 0 && py > 0) |
---|
1609 | { |
---|
1610 | float tmp = (float)height / (float)scaleheight; |
---|
1611 | if(tmp > 0) |
---|
1612 | { |
---|
1613 | tmp = (float)py / tmp; |
---|
1614 | blitscale(posx, nposy, width, py, scalewidth, (int)tmp, 0); |
---|
1615 | } |
---|
1616 | } |
---|
1617 | m_unlock(&status.accelfbmutex, 16); |
---|
1618 | } |
---|
1619 | else |
---|
1620 | { |
---|
1621 | if(width > mwidth) width = mwidth; |
---|
1622 | if(height > mheight) height = mheight; |
---|
1623 | |
---|
1624 | if(halign == CENTER) |
---|
1625 | posx += mwidth / 2 - width / 2; |
---|
1626 | else if(halign == RIGHT) |
---|
1627 | posx += mwidth - width; |
---|
1628 | if(valign == MIDDLE) |
---|
1629 | posy += mheight / 2 - height / 2; |
---|
1630 | else if(valign == BOTTOM) |
---|
1631 | posy += mheight - height; |
---|
1632 | |
---|
1633 | while(cinfo.output_scanline < height) |
---|
1634 | { |
---|
1635 | jpeg_read_scanlines(&cinfo, buffer, 1); |
---|
1636 | py = (posy + cinfo.output_scanline - 1) * skinfb->width; |
---|
1637 | for(x = 0; x < width; x++) |
---|
1638 | { |
---|
1639 | red = buffer[0][cinfo.output_components * x]; |
---|
1640 | if(cinfo.output_components > 2) |
---|
1641 | { |
---|
1642 | green = buffer[0][cinfo.output_components * x + 1]; |
---|
1643 | blue = buffer[0][cinfo.output_components * x + 2]; |
---|
1644 | } |
---|
1645 | else |
---|
1646 | { |
---|
1647 | green = red; |
---|
1648 | blue = red; |
---|
1649 | } |
---|
1650 | color = (0 << 24) | (red << 16) | (green << 8) | blue; |
---|
1651 | drawpixelfast(posx + x, py, color); |
---|
1652 | } |
---|
1653 | } |
---|
1654 | } |
---|
1655 | jpeg_finish_decompress(&cinfo); |
---|
1656 | jpeg_destroy_decompress(&cinfo); |
---|
1657 | fclose(fd); |
---|
1658 | return 0; |
---|
1659 | } |
---|
1660 | |
---|
1661 | unsigned char* readpng(const char* filename, unsigned long* width, unsigned long* height, unsigned long* rowbytes, int* channels, int posx, int posy, int mwidth, int mheight, int halign, int valign) |
---|
1662 | { |
---|
1663 | debug(1000, "in"); |
---|
1664 | FILE *fd = NULL; |
---|
1665 | int ret, bit_depth, color_type; |
---|
1666 | unsigned char *buf = NULL; |
---|
1667 | static png_structp png_ptr = NULL; |
---|
1668 | static png_infop info_ptr = NULL; |
---|
1669 | double gamma; |
---|
1670 | png_uint_32 y; |
---|
1671 | png_bytepp row_pointers = NULL; |
---|
1672 | png_bytep sig = NULL; |
---|
1673 | unsigned char* directbuf = NULL; |
---|
1674 | |
---|
1675 | fd = fopen(filename, "rb"); |
---|
1676 | if(fd == NULL) |
---|
1677 | { |
---|
1678 | perr("open png file %s", filename); |
---|
1679 | return NULL; |
---|
1680 | } |
---|
1681 | |
---|
1682 | sig = malloc(8); |
---|
1683 | if(sig == NULL) |
---|
1684 | { |
---|
1685 | err("no memory"); |
---|
1686 | fclose(fd); |
---|
1687 | return NULL; |
---|
1688 | } |
---|
1689 | |
---|
1690 | fread(sig, 1, 8, fd); |
---|
1691 | ret = png_check_sig(sig, 8); |
---|
1692 | if(ret == 0) |
---|
1693 | { |
---|
1694 | err("%s is not a PNG file", filename); |
---|
1695 | free(sig); |
---|
1696 | fclose(fd); |
---|
1697 | return NULL; |
---|
1698 | } |
---|
1699 | |
---|
1700 | png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); |
---|
1701 | if(png_ptr == NULL) |
---|
1702 | { |
---|
1703 | err("%s no memory", filename); |
---|
1704 | free(sig); |
---|
1705 | fclose(fd); |
---|
1706 | return NULL; |
---|
1707 | } |
---|
1708 | |
---|
1709 | info_ptr = png_create_info_struct(png_ptr); |
---|
1710 | if(info_ptr == NULL) |
---|
1711 | { |
---|
1712 | png_destroy_read_struct(&png_ptr, NULL, NULL); |
---|
1713 | err("%s no memory", filename); |
---|
1714 | free(sig); |
---|
1715 | fclose(fd); |
---|
1716 | return NULL; |
---|
1717 | } |
---|
1718 | |
---|
1719 | ret = setjmp(png_jmpbuf(png_ptr)); |
---|
1720 | if(ret != 0) |
---|
1721 | { |
---|
1722 | png_destroy_read_struct(&png_ptr, &info_ptr, NULL); |
---|
1723 | err("%s has bad IHDR (libpng longjmp)", filename); |
---|
1724 | free(sig); |
---|
1725 | fclose(fd); |
---|
1726 | return NULL; |
---|
1727 | } |
---|
1728 | |
---|
1729 | png_init_io(png_ptr, fd); |
---|
1730 | png_set_sig_bytes(png_ptr, 8); |
---|
1731 | png_read_info(png_ptr, info_ptr); |
---|
1732 | png_get_IHDR(png_ptr, info_ptr, width, height, &bit_depth, &color_type, NULL, NULL, NULL); |
---|
1733 | |
---|
1734 | ret = setjmp(png_jmpbuf(png_ptr)); |
---|
1735 | if(ret != 0) |
---|
1736 | { |
---|
1737 | png_destroy_read_struct(&png_ptr, &info_ptr, NULL); |
---|
1738 | err("%s unknown error", filename); |
---|
1739 | free(sig); |
---|
1740 | fclose(fd); |
---|
1741 | return NULL; |
---|
1742 | } |
---|
1743 | |
---|
1744 | if(color_type == PNG_COLOR_TYPE_PALETTE) |
---|
1745 | png_set_expand(png_ptr); |
---|
1746 | if(color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) |
---|
1747 | png_set_expand(png_ptr); |
---|
1748 | if(png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) |
---|
1749 | png_set_expand(png_ptr); |
---|
1750 | if(bit_depth == 16) |
---|
1751 | png_set_strip_16(png_ptr); |
---|
1752 | if(color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) |
---|
1753 | png_set_gray_to_rgb(png_ptr); |
---|
1754 | if(png_get_gAMA(png_ptr, info_ptr, &gamma)) |
---|
1755 | png_set_gamma(png_ptr, 2.2, gamma); |
---|
1756 | |
---|
1757 | /* |
---|
1758 | if(mwidth > 0 && mheight > 0 && *width <= mwidth && *height <= mheight) |
---|
1759 | { |
---|
1760 | if(halign == CENTER) |
---|
1761 | posx += mwidth / 2 - (*width) / 2; |
---|
1762 | else if(halign == RIGHT) |
---|
1763 | posx += mwidth - (*width); |
---|
1764 | if(valign == MIDDLE) |
---|
1765 | posy += mheight / 2 - (*height) / 2; |
---|
1766 | else if(valign == BOTTOM) |
---|
1767 | posy += mheight - (*height); |
---|
1768 | directbuf = skinfb->fb + (posy * skinfb->pitch) + (posx * skinfb->colbytes); |
---|
1769 | if(color_type == PNG_COLOR_TYPE_RGB) |
---|
1770 | png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER); |
---|
1771 | png_set_bgr(png_ptr); |
---|
1772 | } |
---|
1773 | */ |
---|
1774 | |
---|
1775 | png_read_update_info(png_ptr, info_ptr); |
---|
1776 | *rowbytes = png_get_rowbytes(png_ptr, info_ptr); |
---|
1777 | *channels = (int)png_get_channels(png_ptr, info_ptr); |
---|
1778 | |
---|
1779 | //if(directbuf == NULL) |
---|
1780 | buf = malloc((*rowbytes) * (*height)); |
---|
1781 | //else |
---|
1782 | // buf = directbuf; |
---|
1783 | |
---|
1784 | if(buf == NULL) |
---|
1785 | { |
---|
1786 | png_destroy_read_struct(&png_ptr, &info_ptr, NULL); |
---|
1787 | err("%s no memory", filename); |
---|
1788 | free(sig); |
---|
1789 | fclose(fd); |
---|
1790 | return NULL; |
---|
1791 | } |
---|
1792 | |
---|
1793 | row_pointers = (png_bytepp)malloc((*height) * sizeof(png_bytep)); |
---|
1794 | if(row_pointers == NULL) |
---|
1795 | { |
---|
1796 | png_destroy_read_struct(&png_ptr, &info_ptr, NULL); |
---|
1797 | err("%s unknown error", filename); |
---|
1798 | free(sig); |
---|
1799 | if(directbuf == NULL) free(buf); |
---|
1800 | fclose(fd); |
---|
1801 | return NULL; |
---|
1802 | } |
---|
1803 | |
---|
1804 | //if(directbuf == NULL) |
---|
1805 | //{ |
---|
1806 | for (y = 0; y < (*height); ++y) |
---|
1807 | row_pointers[y] = (png_bytep)buf + y * (*rowbytes); |
---|
1808 | //} |
---|
1809 | //else |
---|
1810 | //{ |
---|
1811 | // for (y = 0; y < (*height); ++y) |
---|
1812 | // row_pointers[y] = (png_bytep)buf + y * skinfb->pitch; |
---|
1813 | //} |
---|
1814 | |
---|
1815 | png_read_image(png_ptr, row_pointers); |
---|
1816 | free(row_pointers); |
---|
1817 | row_pointers = NULL; |
---|
1818 | |
---|
1819 | png_read_end(png_ptr, NULL); |
---|
1820 | png_destroy_read_struct(&png_ptr, &info_ptr, NULL); |
---|
1821 | |
---|
1822 | free(sig); |
---|
1823 | fclose(fd); |
---|
1824 | |
---|
1825 | debug(100, "png width=%ld height=%ld channels=%d rowbytes=%ld", *width, *height, *channels, *rowbytes); |
---|
1826 | |
---|
1827 | debug(1000, "out"); |
---|
1828 | //if(directbuf == NULL) |
---|
1829 | return buf; |
---|
1830 | //else |
---|
1831 | // return NULL; |
---|
1832 | } |
---|
1833 | |
---|
1834 | void drawpic(const char* filename, int posx, int posy, int scalewidth, int scaleheight, int mwidth, int mheight, int halign, int valign) |
---|
1835 | { |
---|
1836 | debug(1000, "in"); |
---|
1837 | unsigned char *buf = NULL, *scalebuf = NULL; |
---|
1838 | int memfd = -1, py = 0; |
---|
1839 | unsigned long width, height, rowbytes; |
---|
1840 | int channels, length; |
---|
1841 | unsigned char *src, red, green, blue, alpha; |
---|
1842 | unsigned long color; |
---|
1843 | png_uint_32 y, x; |
---|
1844 | struct pic* picnode = NULL; |
---|
1845 | int decoding = getconfigint("pichwdecode", NULL); |
---|
1846 | int pictype = 0; //0 = png, 1 = jpg HW, 2 = jpg SW |
---|
1847 | |
---|
1848 | length = strlen(filename); |
---|
1849 | if(filename[length - 1] == 'g' && filename[length - 2] == 'n' && filename[length - 3] == 'p') |
---|
1850 | pictype = 0; |
---|
1851 | else if(decoding == 1) |
---|
1852 | pictype = 1; |
---|
1853 | else |
---|
1854 | pictype = 2; |
---|
1855 | |
---|
1856 | picnode = getpic((char*)filename); |
---|
1857 | if(picnode == NULL) |
---|
1858 | { |
---|
1859 | if(pictype == 0) |
---|
1860 | { |
---|
1861 | //deaktivate: draws transparent pixel |
---|
1862 | //read direkt into framebuffer |
---|
1863 | //if(scaleheight == 0 && scalewidth == 0) |
---|
1864 | // buf = readpng(filename, &width, &height, &rowbytes, &channels, posx, posy, mwidth, mheight, halign, valign); |
---|
1865 | //else |
---|
1866 | buf = readpng(filename, &width, &height, &rowbytes, &channels, 0, 0, 0, 0, 0, 0); |
---|
1867 | } |
---|
1868 | else if(pictype == 1) |
---|
1869 | readjpg(filename, &width, &height, &rowbytes, &channels, &buf, &memfd); |
---|
1870 | else if(pictype == 2) |
---|
1871 | readjpgsw(filename, posx, posy, mwidth, mheight, scalewidth, scaleheight, halign, valign); |
---|
1872 | } |
---|
1873 | else |
---|
1874 | { |
---|
1875 | buf = picnode->picbuf; |
---|
1876 | width = picnode->width; |
---|
1877 | height = picnode->height; |
---|
1878 | rowbytes = picnode->rowbytes; |
---|
1879 | channels = picnode->channels; |
---|
1880 | memfd = picnode->memfd; |
---|
1881 | } |
---|
1882 | |
---|
1883 | if((pictype == 0 || pictype == 1) && buf == NULL) return; |
---|
1884 | |
---|
1885 | if(pictype == 0 && (scalewidth != 0 || scaleheight != 0)) |
---|
1886 | { |
---|
1887 | if(scalewidth == 0) scalewidth = width; |
---|
1888 | if(scaleheight == 0) scaleheight = height; |
---|
1889 | if(picnode == NULL) |
---|
1890 | scalebuf = scale(buf, rowbytes / channels, height, channels, scalewidth, scaleheight, 1); |
---|
1891 | else |
---|
1892 | { |
---|
1893 | scalebuf = scale(buf, rowbytes / channels, height, channels, scalewidth, scaleheight, 0); |
---|
1894 | buf = NULL; |
---|
1895 | picnode = NULL; |
---|
1896 | } |
---|
1897 | if(scalebuf != NULL) |
---|
1898 | { |
---|
1899 | buf = scalebuf; |
---|
1900 | width = scalewidth; |
---|
1901 | height = scaleheight; |
---|
1902 | rowbytes = scalewidth * (channels); |
---|
1903 | } |
---|
1904 | } |
---|
1905 | |
---|
1906 | if(width > mwidth) width = mwidth; |
---|
1907 | if(height > mheight) height = mheight; |
---|
1908 | |
---|
1909 | if(halign == CENTER) |
---|
1910 | posx += mwidth / 2 - width / 2; |
---|
1911 | else if(halign == RIGHT) |
---|
1912 | posx += mwidth - width; |
---|
1913 | if(valign == MIDDLE) |
---|
1914 | posy += mheight / 2 - height / 2; |
---|
1915 | else if(valign == BOTTOM) |
---|
1916 | posy += mheight - height; |
---|
1917 | |
---|
1918 | if(pictype == 0) |
---|
1919 | { |
---|
1920 | py = (posy * skinfb->width) + posx; |
---|
1921 | src = buf; |
---|
1922 | int diff = rowbytes - (width * 4); |
---|
1923 | |
---|
1924 | if(channel == 3) |
---|
1925 | { |
---|
1926 | for(y = 0; y < height; ++y) |
---|
1927 | { |
---|
1928 | for(x = 0; x < width; x++) |
---|
1929 | skinfb->fblong[py + x] = (255 << 24) | (*src++ << 16) | (*src++ << 8) | *src++; |
---|
1930 | |
---|
1931 | py += skinfb->width; |
---|
1932 | src += diff; |
---|
1933 | } |
---|
1934 | } |
---|
1935 | else |
---|
1936 | { |
---|
1937 | for(y = 0; y < height; ++y) |
---|
1938 | { |
---|
1939 | for(x = 0; x < width; x++) |
---|
1940 | { |
---|
1941 | if(src[3] < 10) |
---|
1942 | { |
---|
1943 | src += 4; |
---|
1944 | continue; |
---|
1945 | } |
---|
1946 | skinfb->fblong[py + x] = (*src++ << 24) | (*src++ << 16) | (*src++ << 8) | *src++; |
---|
1947 | } |
---|
1948 | py += skinfb->width; |
---|
1949 | src += diff; |
---|
1950 | } |
---|
1951 | } |
---|
1952 | } |
---|
1953 | else if(pictype == 1 && memfd > -1) |
---|
1954 | blitjpg(buf, posx, posy, width, height, scalewidth, scaleheight ); |
---|
1955 | |
---|
1956 | if(picnode == NULL) |
---|
1957 | { |
---|
1958 | if(pictype == 0) |
---|
1959 | free(buf); |
---|
1960 | else if(pictype == 1) |
---|
1961 | freebpamem(memfd, buf, width * height * 3); |
---|
1962 | } |
---|
1963 | |
---|
1964 | debug(1000, "out"); |
---|
1965 | } |
---|
1966 | |
---|
1967 | //flag 0: don't del outside |
---|
1968 | //flag 1: del outside |
---|
1969 | void drawcircle(int x0, int y0, int radius, int startangle, int endangle, long color, int transparent, char* bg, int flag) |
---|
1970 | { |
---|
1971 | float d = (5/4.0) - radius, theta; |
---|
1972 | int x = 0, y = radius, px = 0, py = 0; |
---|
1973 | |
---|
1974 | transparent = (transparent - 255) * -1; |
---|
1975 | unsigned long tmpcol = color | ((transparent & 0xff) << 24); |
---|
1976 | |
---|
1977 | while(y > x) |
---|
1978 | { |
---|
1979 | if(d < 0) |
---|
1980 | d += 2 * x + 3; |
---|
1981 | else |
---|
1982 | { |
---|
1983 | d += (2 * x) - (2 * y) + 5; |
---|
1984 | y--; |
---|
1985 | } |
---|
1986 | x++; |
---|
1987 | |
---|
1988 | theta = (atan((float)y / x)) * (180 / 3.14); |
---|
1989 | |
---|
1990 | //rt2 |
---|
1991 | if(theta >= startangle && theta <= endangle) |
---|
1992 | { |
---|
1993 | px = x0 + x; |
---|
1994 | py = (y0 - y) * skinfb->width; |
---|
1995 | drawpixelfast(px, py, tmpcol); |
---|
1996 | if(flag == 1) |
---|
1997 | { |
---|
1998 | int i = radius - x; |
---|
1999 | int r = radius - y; |
---|
2000 | for(; i > 0; i--) |
---|
2001 | drawpixelfast(px + i, py, getpixelbuf(bg, x + i - 1, r, radius)); |
---|
2002 | } |
---|
2003 | } |
---|
2004 | //rb2 |
---|
2005 | if(360 - theta >= startangle && 360 - theta <= endangle) |
---|
2006 | { |
---|
2007 | px = x0 + x; |
---|
2008 | py = (y0 + y) * skinfb->width; |
---|
2009 | drawpixelfast(px, py, tmpcol); |
---|
2010 | if(flag == 1) |
---|
2011 | { |
---|
2012 | int i = radius - x; |
---|
2013 | int r = y - 1; |
---|
2014 | for(; i > 0; i--) |
---|
2015 | drawpixelfast(px + i, py, getpixelbuf(bg, x + i - 1, r, radius)); |
---|
2016 | } |
---|
2017 | } |
---|
2018 | //rt1 |
---|
2019 | if(90 - theta >= startangle && 90 - theta <= endangle) |
---|
2020 | { |
---|
2021 | px = x0 + y; |
---|
2022 | py = (y0 - x) * skinfb->width; |
---|
2023 | drawpixelfast(px, py, tmpcol); |
---|
2024 | if(flag == 1) |
---|
2025 | { |
---|
2026 | int i = radius - y; |
---|
2027 | int r = radius - x; |
---|
2028 | for(; i > 0; i--) |
---|
2029 | drawpixelfast(px + i, py, getpixelbuf(bg, y + i - 1, r, radius)); |
---|
2030 | } |
---|
2031 | } |
---|
2032 | //rb1 |
---|
2033 | if(270 + theta >= startangle && 270 + theta <= endangle) |
---|
2034 | { |
---|
2035 | px = x0 + y; |
---|
2036 | py = (y0 + x) * skinfb->width; |
---|
2037 | drawpixelfast(px, py, tmpcol); |
---|
2038 | if(flag == 1) |
---|
2039 | { |
---|
2040 | int i = radius - y; |
---|
2041 | int r = x - 1; |
---|
2042 | for(; i > 0; i--) |
---|
2043 | drawpixelfast(px + i, py, getpixelbuf(bg, y + i - 1, r, radius)); |
---|
2044 | } |
---|
2045 | } |
---|
2046 | //lt2 |
---|
2047 | if(180 - theta >= startangle && 180 - theta <= endangle) |
---|
2048 | { |
---|
2049 | px = x0 - x; |
---|
2050 | py = (y0 - y) * skinfb->width; |
---|
2051 | drawpixelfast(px, py, tmpcol); |
---|
2052 | if(flag == 1) |
---|
2053 | { |
---|
2054 | int i = radius - x; |
---|
2055 | int r = radius - y; |
---|
2056 | for(; i > 0; i--) |
---|
2057 | drawpixelfast(px - i, py, getpixelbuf(bg, radius - x - i, r, radius)); |
---|
2058 | } |
---|
2059 | } |
---|
2060 | //lb2 |
---|
2061 | if(180 + theta >= startangle && 180 + theta <= endangle) |
---|
2062 | { |
---|
2063 | px = x0 - x; |
---|
2064 | py = (y0 + y) * skinfb->width; |
---|
2065 | drawpixelfast(px, py, tmpcol); |
---|
2066 | if(flag == 1) |
---|
2067 | { |
---|
2068 | int i = radius - x; |
---|
2069 | int r = y - 1; |
---|
2070 | for(; i > 0; i--) |
---|
2071 | drawpixelfast(px - i, py, getpixelbuf(bg, radius - x - i, r, radius)); |
---|
2072 | } |
---|
2073 | } |
---|
2074 | //lt1 |
---|
2075 | if(90 + theta >= startangle && 90 + theta <= endangle) |
---|
2076 | { |
---|
2077 | px = x0 - y; |
---|
2078 | py = (y0 - x) * skinfb->width; |
---|
2079 | drawpixelfast(px, py, tmpcol); |
---|
2080 | if(flag == 1) |
---|
2081 | { |
---|
2082 | int i = radius - y; |
---|
2083 | int r = radius - x; |
---|
2084 | for(; i > 0; i--) |
---|
2085 | drawpixelfast(px - i, py, getpixelbuf(bg, radius - y - i, r, radius)); |
---|
2086 | } |
---|
2087 | } |
---|
2088 | //lb1 |
---|
2089 | if(270 - theta >= startangle && 270 - theta <= endangle) |
---|
2090 | { |
---|
2091 | px = x0 - y; |
---|
2092 | py = (y0 + x) * skinfb->width; |
---|
2093 | drawpixelfast(px, py, tmpcol); |
---|
2094 | if(flag == 1) |
---|
2095 | { |
---|
2096 | int i = radius - y; |
---|
2097 | int r = x - 1; |
---|
2098 | for(; i > 0; i--) |
---|
2099 | drawpixelfast(px - i, py, getpixelbuf(bg, radius - y - i , r, radius)); |
---|
2100 | } |
---|
2101 | } |
---|
2102 | } |
---|
2103 | } |
---|
2104 | |
---|
2105 | int drawchar(struct font* font, FT_ULong currentchar, int posx, int posy, int mwidth, int height, long color, int transparent, int charspace, int test) |
---|
2106 | { |
---|
2107 | // debug(1000, "in"); |
---|
2108 | int space = 0, row, pitch, bit, x = 0, px = 0, py = 0; |
---|
2109 | FT_UInt glyphindex; |
---|
2110 | FT_Vector kerning; |
---|
2111 | FT_Error ret; |
---|
2112 | FTC_SBit sbit; |
---|
2113 | unsigned long tmpcol = 0, tmpcol1 = 0; |
---|
2114 | long buffercol = 0; |
---|
2115 | unsigned char red, green, blue, r, g, b; |
---|
2116 | |
---|
2117 | if(currentchar == 32) space = 1; |
---|
2118 | |
---|
2119 | glyphindex = FT_Get_Char_Index(font->face, currentchar); |
---|
2120 | if(glyphindex == 0) |
---|
2121 | { |
---|
2122 | debug(100, "FT_Get_Char_Index for char %x %c failed", (int)currentchar, (int)currentchar); |
---|
2123 | return 0; |
---|
2124 | } |
---|
2125 | |
---|
2126 | FTC_Node anode; |
---|
2127 | ret = FTC_SBitCache_Lookup(font->cache, &font->desc, glyphindex, &sbit, &anode); |
---|
2128 | |
---|
2129 | if(ret != 0) |
---|
2130 | { |
---|
2131 | err("FTC_SBitCache_Lookup for char %x %c failed. Error: 0x%.2X", (int)currentchar, (int)currentchar, ret); |
---|
2132 | return 0; |
---|
2133 | } |
---|
2134 | |
---|
2135 | if(font->use_kerning) |
---|
2136 | { |
---|
2137 | FT_Get_Kerning(font->face, font->prev_glyphindex, glyphindex, ft_kerning_default, &kerning); |
---|
2138 | font->prev_glyphindex = glyphindex; |
---|
2139 | kerning.x >>= 6; |
---|
2140 | } |
---|
2141 | else |
---|
2142 | kerning.x = 0; |
---|
2143 | |
---|
2144 | if (test == 1 || space == 1) |
---|
2145 | { |
---|
2146 | //debug(1000, "out -> test or space"); |
---|
2147 | return sbit->xadvance + kerning.x + charspace; |
---|
2148 | } |
---|
2149 | if(posx + sbit->xadvance > mwidth) |
---|
2150 | { |
---|
2151 | //debug(1000, "out -> text to long"); |
---|
2152 | return -1; |
---|
2153 | } |
---|
2154 | |
---|
2155 | transparent = transparent & 0xff; |
---|
2156 | if(status.fasttextrender == 1) |
---|
2157 | { |
---|
2158 | posy = posy + height - sbit->top; |
---|
2159 | posx = posx + sbit->left + kerning.x; |
---|
2160 | tmpcol = color | transparent << 24; |
---|
2161 | for(row = 0; row < sbit->height; row++) |
---|
2162 | { |
---|
2163 | py = (row + posy) * skinfb->width; |
---|
2164 | for(pitch = 0; pitch < sbit->pitch; pitch++) |
---|
2165 | { |
---|
2166 | for(bit = 7; bit >= 0; bit--) |
---|
2167 | { |
---|
2168 | if(pitch * 8 + 7 - bit >= sbit->width) |
---|
2169 | break; |
---|
2170 | if((sbit->buffer[row * sbit->pitch + pitch]) & 1 << bit) |
---|
2171 | { |
---|
2172 | drawpixelfast(posx + x, py, tmpcol); |
---|
2173 | } |
---|
2174 | x++; |
---|
2175 | } |
---|
2176 | } |
---|
2177 | x = 0; |
---|
2178 | } |
---|
2179 | } |
---|
2180 | else |
---|
2181 | { |
---|
2182 | red = (color & 0xff0000) >> 16; |
---|
2183 | green = (color & 0x00ff00) >> 8; |
---|
2184 | blue = color & 0xff; |
---|
2185 | posy = posy + height - sbit->top; |
---|
2186 | posx = posx + sbit->left + kerning.x; |
---|
2187 | tmpcol = color | transparent << 24; |
---|
2188 | for(row = 0; row < sbit->height; row++) |
---|
2189 | { |
---|
2190 | py = (row + posy) * skinfb->width; |
---|
2191 | for(pitch = 0; pitch < sbit->pitch; pitch++) |
---|
2192 | { |
---|
2193 | buffercol = sbit->buffer[row * sbit->pitch + pitch]; |
---|
2194 | if(buffercol) |
---|
2195 | { |
---|
2196 | //renderquality 255-0 = best |
---|
2197 | if(buffercol > 220) |
---|
2198 | { |
---|
2199 | tmpcol1 = tmpcol; |
---|
2200 | px = posx + pitch; |
---|
2201 | } |
---|
2202 | else if(buffercol < 35) |
---|
2203 | continue; |
---|
2204 | else |
---|
2205 | { |
---|
2206 | px = posx + pitch; |
---|
2207 | tmpcol1 = getpixelfast(px, py); |
---|
2208 | alpha_composite(r, red, buffercol, (tmpcol1 & 0xff0000) >> 16); |
---|
2209 | alpha_composite(g, green, buffercol, (tmpcol1 & 0x00ff00) >> 8); |
---|
2210 | alpha_composite(b, blue, buffercol, tmpcol1 & 0xff); |
---|
2211 | tmpcol1 = transparent << 24 | r << 16 | g << 8 | b; |
---|
2212 | } |
---|
2213 | |
---|
2214 | drawpixelfast(px, py, tmpcol1); |
---|
2215 | } |
---|
2216 | } |
---|
2217 | } |
---|
2218 | } |
---|
2219 | |
---|
2220 | // debug(1000, "out"); |
---|
2221 | return sbit->xadvance + kerning.x + charspace; |
---|
2222 | } |
---|
2223 | |
---|
2224 | void getstringwh(struct font* font, char *string, int *stringwidth, int *stringheight, int charspace) |
---|
2225 | { |
---|
2226 | debug(1000, "in"); |
---|
2227 | FT_ULong cret = 0; |
---|
2228 | if(string == NULL) return; |
---|
2229 | |
---|
2230 | while(*string != '\0' && *string != '\n') |
---|
2231 | { |
---|
2232 | string += strfreetype(string, &cret); |
---|
2233 | *stringwidth += drawchar(font, cret, 0, 0, 0, 0, 0, 0, charspace, 1); |
---|
2234 | string++; |
---|
2235 | } |
---|
2236 | debug(1000, "out"); |
---|
2237 | } |
---|
2238 | |
---|
2239 | int calcstrhalign(struct font* aktfont, char *string, int posx, int mwidth, int halign, int charspace) |
---|
2240 | { |
---|
2241 | int stringwidth = 0, stringheight = 0; |
---|
2242 | if(string == NULL) return 0; |
---|
2243 | |
---|
2244 | switch(halign) |
---|
2245 | { |
---|
2246 | case TEXTCENTER: |
---|
2247 | case CENTER: |
---|
2248 | getstringwh(aktfont, string, &stringwidth, &stringheight, charspace); |
---|
2249 | if(stringwidth < mwidth) posx += (mwidth - stringwidth) / 2; |
---|
2250 | break; |
---|
2251 | case TEXTRIGHT: |
---|
2252 | case RIGHT: |
---|
2253 | getstringwh(aktfont, string, &stringwidth, &stringheight, charspace); |
---|
2254 | if(stringwidth < mwidth) posx += mwidth - stringwidth; |
---|
2255 | break; |
---|
2256 | } |
---|
2257 | return posx; |
---|
2258 | } |
---|
2259 | |
---|
2260 | int calcstrvalign(char *string, int posy, int oldposy, int mheight, int fontsize, int linecount, int valign) |
---|
2261 | { |
---|
2262 | if(string == NULL) return 0; |
---|
2263 | |
---|
2264 | switch(valign) |
---|
2265 | { |
---|
2266 | case TEXTMIDDLE: |
---|
2267 | case MIDDLE: |
---|
2268 | posy += mheight / 2 - (fontsize * linecount) / 2; |
---|
2269 | if(posy < oldposy) posy = oldposy; |
---|
2270 | break; |
---|
2271 | case TEXTBOTTOM: |
---|
2272 | case BOTTOM: |
---|
2273 | posy += mheight - (fontsize * linecount); |
---|
2274 | if(posy < oldposy) posy = oldposy; |
---|
2275 | break; |
---|
2276 | } |
---|
2277 | |
---|
2278 | return posy; |
---|
2279 | } |
---|
2280 | |
---|
2281 | struct font* setaktfont(char* fontname, int fontsize) |
---|
2282 | { |
---|
2283 | struct font* aktfont = NULL; |
---|
2284 | |
---|
2285 | if(fontname != NULL) aktfont = getfont(fontname); |
---|
2286 | if(aktfont == NULL) aktfont = font; |
---|
2287 | |
---|
2288 | aktfont->desc.width = fontsize; |
---|
2289 | aktfont->desc.height = fontsize; |
---|
2290 | if(status.fasttextrender == 1) |
---|
2291 | aktfont->desc.flags = FT_LOAD_MONOCHROME; |
---|
2292 | else |
---|
2293 | aktfont->desc.flags = FT_LOAD_DEFAULT; |
---|
2294 | |
---|
2295 | aktfont->prev_glyphindex = 0; |
---|
2296 | |
---|
2297 | return aktfont; |
---|
2298 | } |
---|
2299 | |
---|
2300 | void wrapstr(char* string, char* fontname, int fontsize, int mwidth, int charspace) |
---|
2301 | { |
---|
2302 | int posx = 0; |
---|
2303 | int stringheight = 0, stringwidth = 0; |
---|
2304 | struct font* aktfont = NULL; |
---|
2305 | char* tmpstr = NULL, *origstr = string; |
---|
2306 | unsigned char c = 0; |
---|
2307 | |
---|
2308 | aktfont = setaktfont(fontname, fontsize); |
---|
2309 | |
---|
2310 | while(*string != '\0') |
---|
2311 | { |
---|
2312 | stringheight = 0; stringwidth = 0; |
---|
2313 | |
---|
2314 | tmpstr = string; |
---|
2315 | |
---|
2316 | while(*string != '\0' && *string != '\n' && *string != ' ' && *string != '-') |
---|
2317 | string++; |
---|
2318 | if(*string == '\n') |
---|
2319 | { |
---|
2320 | if(*string != '\0') string++; |
---|
2321 | posx = 0; |
---|
2322 | } |
---|
2323 | else |
---|
2324 | { |
---|
2325 | if(*string != '\0') string++; |
---|
2326 | c = *string; *string = '\0'; |
---|
2327 | |
---|
2328 | getstringwh(aktfont, tmpstr, &stringwidth, &stringheight, charspace); |
---|
2329 | *string = c; |
---|
2330 | |
---|
2331 | posx += stringwidth; |
---|
2332 | } |
---|
2333 | |
---|
2334 | if(posx > mwidth && tmpstr > origstr) |
---|
2335 | { |
---|
2336 | tmpstr--; |
---|
2337 | *tmpstr = '\n'; |
---|
2338 | posx = stringwidth; |
---|
2339 | } |
---|
2340 | } |
---|
2341 | } |
---|
2342 | |
---|
2343 | |
---|
2344 | int drawstring(char* string, unsigned long linecount, unsigned int poscount, unsigned int markpos, int posx, int posy, int mwidth, int mheight, int halign, int valign, char* fontname, int fontsize, long color, int transparent, int wrap, int* lastposx, int* lastposy, int* len, int charspace) |
---|
2345 | { |
---|
2346 | debug(1000, "in"); |
---|
2347 | int charwidth = 0, lineend = 0; |
---|
2348 | int charcount = 0; |
---|
2349 | if(lastposy == NULL || *lastposy == 0) posy=posy + FONTPOSYOFFSET; |
---|
2350 | int oldposx = posx, aktheight = 0, ret = 0; |
---|
2351 | int oldposy = posy, oldmwidth = mwidth; |
---|
2352 | struct font* aktfont = NULL; |
---|
2353 | long tmpcol = color; |
---|
2354 | FT_ULong cret = 0; |
---|
2355 | |
---|
2356 | if(string == NULL) return 1; |
---|
2357 | |
---|
2358 | transparent = (transparent - 255) * -1; |
---|
2359 | |
---|
2360 | if(linecount < 2 && (fontsize == 0 || fontsize > mheight)) |
---|
2361 | fontsize = mheight; |
---|
2362 | |
---|
2363 | aktfont = setaktfont(fontname, fontsize); |
---|
2364 | |
---|
2365 | string = string + poscount; |
---|
2366 | |
---|
2367 | if(fontsize < 5) |
---|
2368 | { |
---|
2369 | debug(1000, "out -> fontsize to small"); |
---|
2370 | return 1; |
---|
2371 | } |
---|
2372 | |
---|
2373 | posx = calcstrhalign(aktfont, string, posx, oldmwidth, halign, charspace); |
---|
2374 | posy = calcstrvalign(string, posy, oldposy, mheight, fontsize, linecount, valign); |
---|
2375 | |
---|
2376 | mwidth = posx + mwidth; |
---|
2377 | aktheight += fontsize; |
---|
2378 | if(aktheight > mheight) |
---|
2379 | { |
---|
2380 | debug(1000, "out -> to many textlines"); |
---|
2381 | return 1; |
---|
2382 | } |
---|
2383 | |
---|
2384 | while(*string != '\0') |
---|
2385 | { |
---|
2386 | charcount++; |
---|
2387 | if(markpos == charcount) |
---|
2388 | color = convertcol("markcol"); |
---|
2389 | else |
---|
2390 | color = tmpcol; |
---|
2391 | |
---|
2392 | if(*string == '\n') |
---|
2393 | { |
---|
2394 | if(linecount < 2) break; |
---|
2395 | lineend = 0; |
---|
2396 | aktheight += fontsize; |
---|
2397 | if(aktheight > mheight) |
---|
2398 | { |
---|
2399 | ret = 1; |
---|
2400 | break; |
---|
2401 | } |
---|
2402 | posy = posy + fontsize; |
---|
2403 | posx = oldposx; |
---|
2404 | string++; |
---|
2405 | posx = calcstrhalign(aktfont, string, posx, oldmwidth, halign, charspace); |
---|
2406 | continue; |
---|
2407 | } |
---|
2408 | |
---|
2409 | if(lineend == 1) |
---|
2410 | { |
---|
2411 | string++; |
---|
2412 | continue; |
---|
2413 | } |
---|
2414 | |
---|
2415 | string += strfreetype(string, &cret); |
---|
2416 | |
---|
2417 | if((charwidth = drawchar(aktfont, cret, posx, posy, mwidth, fontsize, color, transparent, charspace, 0)) == -1) |
---|
2418 | lineend = 1; |
---|
2419 | |
---|
2420 | posx += charwidth; |
---|
2421 | if(len != NULL) *len += charwidth; |
---|
2422 | string++; |
---|
2423 | } |
---|
2424 | if(lastposx != NULL) *lastposx = posx; |
---|
2425 | if(lastposy != NULL) *lastposy = posy + fontsize; |
---|
2426 | debug(1000, "out"); |
---|
2427 | return ret; |
---|
2428 | } |
---|
2429 | |
---|
2430 | char* saverect(int posx, int posy, int width, int height) |
---|
2431 | { |
---|
2432 | debug(1000, "in"); |
---|
2433 | char* buf; |
---|
2434 | int y; |
---|
2435 | |
---|
2436 | buf = malloc(width * height * skinfb->colbytes); |
---|
2437 | if(buf == NULL) |
---|
2438 | { |
---|
2439 | err("no memory"); |
---|
2440 | return NULL; |
---|
2441 | } |
---|
2442 | |
---|
2443 | for(y = 0; y < height; y++) |
---|
2444 | { |
---|
2445 | memcpy(buf + width * skinfb->colbytes * y, skinfb->fb + ((y + posy) * skinfb->pitch) + (posx * skinfb->colbytes), width * skinfb->colbytes); |
---|
2446 | } |
---|
2447 | |
---|
2448 | debug(1000, "out"); |
---|
2449 | return buf; |
---|
2450 | } |
---|
2451 | |
---|
2452 | char* savescreen(struct skin* node) |
---|
2453 | { |
---|
2454 | return saverect(node->rposx - node->shadowsize, node->rposy - node->shadowsize, node->rwidth + (node->shadowsize * 2), node->rheight + (node->shadowsize * 2)); |
---|
2455 | } |
---|
2456 | |
---|
2457 | void restorerect(char* buf, int posx, int posy, int width, int height) |
---|
2458 | { |
---|
2459 | debug(1000, "in"); |
---|
2460 | int y; |
---|
2461 | |
---|
2462 | if(buf != NULL) |
---|
2463 | { |
---|
2464 | for(y = 0; y < height; y++) |
---|
2465 | { |
---|
2466 | memcpy(skinfb->fb + ((y + posy) * skinfb->pitch) + (posx * skinfb->colbytes), buf + width * skinfb->colbytes * y, width * skinfb->colbytes); |
---|
2467 | } |
---|
2468 | free(buf); |
---|
2469 | buf = NULL; |
---|
2470 | } |
---|
2471 | debug(1000, "out"); |
---|
2472 | } |
---|
2473 | |
---|
2474 | void restorescreen(char* buf, struct skin* node) |
---|
2475 | { |
---|
2476 | restorerect(buf, node->rposx - node->shadowsize, node->rposy - node->shadowsize, node->rwidth + (node->shadowsize * 2), node->rheight + (node->shadowsize * 2)); |
---|
2477 | } |
---|
2478 | |
---|
2479 | //*************** GOST LCD |
---|
2480 | void lcd_fillrect(int posx, int posy, int width, int height, long color, int transparent) |
---|
2481 | { |
---|
2482 | //debug(1000, "in"); |
---|
2483 | int y, x; |
---|
2484 | unsigned long tmpcol; |
---|
2485 | |
---|
2486 | if(posx < 0) posx = 0; |
---|
2487 | if(posx > skinfb->width) posx = skinfb->width; |
---|
2488 | if(posy < 0) posy = 0; |
---|
2489 | if(posy > skinfb->height) posy = skinfb->height; |
---|
2490 | if(posx + width > skinfb->width) width = skinfb->width - posx; |
---|
2491 | if(posy + height > skinfb->height) height = skinfb->height - posy; |
---|
2492 | |
---|
2493 | if(width <= 0 || height <= 0) return; |
---|
2494 | |
---|
2495 | transparent = (transparent - 255) * -1; |
---|
2496 | tmpcol = color | ((transparent & 0xff) << 24); |
---|
2497 | |
---|
2498 | for(y = 0; y < height; y++) |
---|
2499 | { |
---|
2500 | for(x = 0; x < width; x++) |
---|
2501 | { |
---|
2502 | drawpixel(posx + x, posy + y, tmpcol); |
---|
2503 | } |
---|
2504 | } |
---|
2505 | //debug(1000, "out"); |
---|
2506 | } |
---|
2507 | |
---|
2508 | void lcd_drawrect(int posx, int posy, int width, int height, long color, int transparent) |
---|
2509 | { |
---|
2510 | //debug(1000, "in"); |
---|
2511 | fillrect(posx, posy, width, 1, color, transparent); |
---|
2512 | fillrect(posx, posy + height - 1, width, 1, color, transparent); |
---|
2513 | fillrect(posx, posy, 1, height, color, transparent); |
---|
2514 | fillrect(posx + width - 1, posy, 1, height, color, transparent); |
---|
2515 | //debug(1000, "out"); |
---|
2516 | } |
---|
2517 | //*************** GOST LCD |
---|
2518 | |
---|
2519 | |
---|
2520 | #ifndef SIMULATE |
---|
2521 | |
---|
2522 | /* |
---|
2523 | void fillrect(int posx, int posy, int width, int height, long color, int transparent) |
---|
2524 | { |
---|
2525 | int r, g, b; |
---|
2526 | |
---|
2527 | r = (color >> 16) & 0xFF; |
---|
2528 | g = (color >> 8) & 0xFF; |
---|
2529 | b = color & 0xFF; |
---|
2530 | |
---|
2531 | primary->SetDrawingFlags(primary, DSDRAW_NOFX); |
---|
2532 | primary->SetColor(primary, r, g, b, transparent); |
---|
2533 | primary->FillRectangle(primary, posx, posy, width, height); |
---|
2534 | primary->Flip(primary, NULL, DSFLIP_WAITFORSYNC); |
---|
2535 | } |
---|
2536 | |
---|
2537 | void drawrect(int posx, int posy, int width, int height, long color, int transparent) |
---|
2538 | { |
---|
2539 | int r, g, b; |
---|
2540 | |
---|
2541 | r = (color >> 16) & 0xFF; |
---|
2542 | g = (color >> 8) & 0xFF; |
---|
2543 | b = color & 0xFF; |
---|
2544 | |
---|
2545 | primary->SetDrawingFlags(primary, DSDRAW_NOFX); |
---|
2546 | primary->SetColor(primary, r, g, b, transparent); |
---|
2547 | primary->DrawRectangle(primary, posx, posy, width, height); |
---|
2548 | primary->Flip(primary, NULL, DSFLIP_WAITFORSYNC); |
---|
2549 | } |
---|
2550 | */ |
---|
2551 | |
---|
2552 | //mode 0: with fill (draw to skinfb) |
---|
2553 | //mode 1: without fill (draw to skinfb) |
---|
2554 | //mode 2: with fill (draw to fb) |
---|
2555 | //mode 3: without fill (draw to fb) |
---|
2556 | void blitrect(int posx, int posy, int width, int height, long color, int transparent, int mode) |
---|
2557 | { |
---|
2558 | unsigned long tmpcol; |
---|
2559 | |
---|
2560 | transparent = (transparent - 255) * -1; |
---|
2561 | tmpcol = color | ((transparent & 0xff) << 24); |
---|
2562 | |
---|
2563 | STMFBIO_BLT_DATA bltData; |
---|
2564 | memset(&bltData, 0, sizeof(STMFBIO_BLT_DATA)); |
---|
2565 | |
---|
2566 | if(posx < 0) posx = 0; |
---|
2567 | if(posy < 0) posy = 0; |
---|
2568 | if(mode < 2) |
---|
2569 | { |
---|
2570 | if(posx > skinfb->width) posx = skinfb->width; |
---|
2571 | if(posy > skinfb->height) posy = skinfb->height; |
---|
2572 | if(posx + width > skinfb->width) width = skinfb->width - posx; |
---|
2573 | if(posy + height > skinfb->height) height = skinfb->height - posy; |
---|
2574 | } |
---|
2575 | else |
---|
2576 | { |
---|
2577 | if(posx > fb->width) posx = fb->width; |
---|
2578 | if(posy > fb->height) posy = fb->height; |
---|
2579 | if(posx + width > fb->width) width = fb->width - posx; |
---|
2580 | if(posy + height > fb->height) height = fb->height - posy; |
---|
2581 | } |
---|
2582 | |
---|
2583 | if(width <= 0 || height <= 0) return; |
---|
2584 | |
---|
2585 | if(mode == 0 || mode == 2) |
---|
2586 | bltData.operation = BLT_OP_FILL; |
---|
2587 | else if(mode == 1 || mode == 3) |
---|
2588 | bltData.operation = BLT_OP_DRAW_RECTANGLE; |
---|
2589 | bltData.colour = tmpcol; |
---|
2590 | bltData.srcFormat = SURF_ARGB8888; |
---|
2591 | bltData.srcMemBase = STMFBGP_FRAMEBUFFER; |
---|
2592 | |
---|
2593 | if(status.usedirectfb == 1) |
---|
2594 | bltData.dstOffset = 0; |
---|
2595 | else |
---|
2596 | { |
---|
2597 | if(mode < 2) |
---|
2598 | bltData.dstOffset = fb->varfbsize; |
---|
2599 | else |
---|
2600 | bltData.dstOffset = 0; |
---|
2601 | } |
---|
2602 | if(mode < 2) |
---|
2603 | bltData.dstPitch = skinfb->pitch; |
---|
2604 | else |
---|
2605 | bltData.dstPitch = fb->pitch; |
---|
2606 | bltData.dst_top = posy; |
---|
2607 | bltData.dst_left = posx; |
---|
2608 | bltData.dst_bottom = posy + height; |
---|
2609 | bltData.dst_right = posx + width; |
---|
2610 | bltData.dstFormat = SURF_ARGB8888; |
---|
2611 | bltData.dstMemBase = STMFBGP_FRAMEBUFFER; |
---|
2612 | |
---|
2613 | if(ioctl(fb->fd, STMFBIO_BLT, &bltData) < 0) |
---|
2614 | { |
---|
2615 | perr("ioctl STMFBIO_BLT"); |
---|
2616 | } |
---|
2617 | if(ioctl(fb->fd, STMFBIO_SYNC_BLITTER) < 0) |
---|
2618 | { |
---|
2619 | perr("ioctl STMFBIO_SYNC_BLITTER"); |
---|
2620 | } |
---|
2621 | } |
---|
2622 | |
---|
2623 | void fillrect(int posx, int posy, int width, int height, long color, int transparent) |
---|
2624 | { |
---|
2625 | if(skinfb != lcdskinfb) |
---|
2626 | blitrect(posx, posy, width, height, color, transparent, 0); |
---|
2627 | else |
---|
2628 | lcd_fillrect(posx, posy, width, height, color, transparent); |
---|
2629 | } |
---|
2630 | |
---|
2631 | void drawrect(int posx, int posy, int width, int height, long color, int transparent) |
---|
2632 | { |
---|
2633 | if(skinfb != lcdskinfb) |
---|
2634 | blitrect(posx, posy, width, height, color, transparent, 1); |
---|
2635 | else |
---|
2636 | lcd_drawrect(posx, posy, width, height, color, transparent); |
---|
2637 | } |
---|
2638 | #else |
---|
2639 | void fillrect(int posx, int posy, int width, int height, long color, int transparent) |
---|
2640 | { |
---|
2641 | debug(1000, "in"); |
---|
2642 | int y, x; |
---|
2643 | unsigned long tmpcol; |
---|
2644 | |
---|
2645 | if(posx < 0) posx = 0; |
---|
2646 | if(posx > skinfb->width) posx = skinfb->width; |
---|
2647 | if(posy < 0) posy = 0; |
---|
2648 | if(posy > skinfb->height) posy = skinfb->height; |
---|
2649 | if(posx + width > skinfb->width) width = skinfb->width - posx; |
---|
2650 | if(posy + height > skinfb->height) height = skinfb->height - posy; |
---|
2651 | |
---|
2652 | if(width <= 0 || height <= 0) return; |
---|
2653 | |
---|
2654 | transparent = (transparent - 255) * -1; |
---|
2655 | tmpcol = color | ((transparent & 0xff) << 24); |
---|
2656 | |
---|
2657 | for(y = 0; y < height; y++) |
---|
2658 | { |
---|
2659 | for(x = 0; x < width; x++) |
---|
2660 | { |
---|
2661 | drawpixel(posx + x, posy + y, tmpcol); |
---|
2662 | } |
---|
2663 | } |
---|
2664 | debug(1000, "out"); |
---|
2665 | } |
---|
2666 | |
---|
2667 | void drawrect(int posx, int posy, int width, int height, long color, int transparent) |
---|
2668 | { |
---|
2669 | debug(1000, "in"); |
---|
2670 | fillrect(posx, posy, width, 1, color, transparent); |
---|
2671 | fillrect(posx, posy + height - 1, width, 1, color, transparent); |
---|
2672 | fillrect(posx, posy, 1, height, color, transparent); |
---|
2673 | fillrect(posx + width - 1, posy, 1, height, color, transparent); |
---|
2674 | debug(1000, "out"); |
---|
2675 | } |
---|
2676 | #endif |
---|
2677 | |
---|
2678 | void clearrect(int posx, int posy, int width, int height) |
---|
2679 | { |
---|
2680 | fillrect(posx, posy, width, height, 0, 255); |
---|
2681 | } |
---|
2682 | |
---|
2683 | void clearscreen(struct skin* node) |
---|
2684 | { |
---|
2685 | m_lock(&status.drawingmutex, 0); |
---|
2686 | clearrect(node->rposx, node->rposy, node->rwidth, node->rheight); |
---|
2687 | clearshadow(node); |
---|
2688 | m_unlock(&status.drawingmutex, 0); |
---|
2689 | } |
---|
2690 | |
---|
2691 | void clearscreennolock(struct skin* node) |
---|
2692 | { |
---|
2693 | clearrect(node->rposx, node->rposy, node->rwidth, node->rheight); |
---|
2694 | clearshadow(node); |
---|
2695 | } |
---|
2696 | |
---|
2697 | //flag 0 = horizontal |
---|
2698 | //flag 1 = vertical |
---|
2699 | //flag 2 = horizontal (begin to middle, middle to end) |
---|
2700 | //flag 3 = vertical (begin to middle, middle to end) |
---|
2701 | void drawgradient(int posx, int posy, int width, int height, long col1, long col2, int transparent, int flag) |
---|
2702 | { |
---|
2703 | int p, i, x, y, steps, xstep, ystep; |
---|
2704 | int xcount = 0, ycount = 0, owidth = width, oheight = height; |
---|
2705 | unsigned char r3, g3, b3; |
---|
2706 | unsigned long col = 0; |
---|
2707 | |
---|
2708 | transparent = (transparent - 255) * -1; |
---|
2709 | |
---|
2710 | if(flag == LEFTRIGHT || flag == LEFTMIDDLE) |
---|
2711 | { |
---|
2712 | if(flag == LEFTMIDDLE) width = width / 2; |
---|
2713 | if(width < 100) |
---|
2714 | steps = width; |
---|
2715 | else |
---|
2716 | steps = width / 5; |
---|
2717 | xstep = width / steps; |
---|
2718 | ystep = height; |
---|
2719 | } |
---|
2720 | else |
---|
2721 | { |
---|
2722 | if(flag == TOPMIDDLE) height = height / 2; |
---|
2723 | if(height < 100) |
---|
2724 | steps = height; |
---|
2725 | else |
---|
2726 | steps = height / 5; |
---|
2727 | xstep = width; |
---|
2728 | ystep = height / steps; |
---|
2729 | } |
---|
2730 | |
---|
2731 | unsigned char r1 = (col1 >> 16) & 0xff; |
---|
2732 | unsigned char g1 = (col1 >> 8) & 0xff; |
---|
2733 | unsigned char b1 = col1 & 0xff; |
---|
2734 | |
---|
2735 | unsigned char r2 = (col2 >> 16) & 0xff; |
---|
2736 | unsigned char g2 = (col2 >> 8) & 0xff; |
---|
2737 | unsigned char b2 = col2 & 0xff; |
---|
2738 | |
---|
2739 | for(i = 0; i < steps; i++) |
---|
2740 | { |
---|
2741 | p = steps - i; |
---|
2742 | r3 = (r1 * p + r2 * i) / steps; |
---|
2743 | g3 = (g1 * p + g2 * i) / steps; |
---|
2744 | b3 = (b1 * p + b2 * i) / steps; |
---|
2745 | col = (transparent << 24) | (r3 << 16) | (g3 << 8) | b3; |
---|
2746 | |
---|
2747 | for(y = 0; y < ystep; y++) |
---|
2748 | for(x = 0; x < xstep; x++) |
---|
2749 | drawpixel(posx + x, posy + y, col); |
---|
2750 | |
---|
2751 | if(flag == LEFTRIGHT || flag == LEFTMIDDLE) |
---|
2752 | { |
---|
2753 | posx += xstep; |
---|
2754 | xcount += xstep; |
---|
2755 | } |
---|
2756 | else |
---|
2757 | { |
---|
2758 | posy += ystep; |
---|
2759 | ycount += ystep; |
---|
2760 | } |
---|
2761 | } |
---|
2762 | |
---|
2763 | if(flag == LEFTMIDDLE || flag == TOPMIDDLE) |
---|
2764 | { |
---|
2765 | for(i = 0; i < steps; i++) |
---|
2766 | { |
---|
2767 | p = steps - i; |
---|
2768 | r3 = (r2 * p + r1 * i) / steps; |
---|
2769 | g3 = (g2 * p + g1 * i) / steps; |
---|
2770 | b3 = (b2 * p + b1 * i) / steps; |
---|
2771 | col = (transparent << 24) | (r3 << 16) | (g3 << 8) | b3; |
---|
2772 | |
---|
2773 | for(y = 0; y < ystep; y++) |
---|
2774 | for(x = 0; x < xstep; x++) |
---|
2775 | drawpixel(posx + x, posy + y, col); |
---|
2776 | if(flag == LEFTMIDDLE) |
---|
2777 | { |
---|
2778 | posx += xstep; |
---|
2779 | xcount += xstep; |
---|
2780 | } |
---|
2781 | else |
---|
2782 | { |
---|
2783 | posy += ystep; |
---|
2784 | ycount += ystep; |
---|
2785 | } |
---|
2786 | } |
---|
2787 | } |
---|
2788 | |
---|
2789 | if(flag == LEFTRIGHT || flag == LEFTMIDDLE) |
---|
2790 | { |
---|
2791 | if(owidth > xcount) |
---|
2792 | { |
---|
2793 | for(y = 0; y < ystep; y++) |
---|
2794 | for(x = 0; x < (owidth - xcount); x++) |
---|
2795 | drawpixel(posx + x, posy + y, col); |
---|
2796 | } |
---|
2797 | } |
---|
2798 | if(flag == TOPBOTTOM || flag == TOPMIDDLE) |
---|
2799 | { |
---|
2800 | if(oheight > ycount) |
---|
2801 | { |
---|
2802 | for(y = 0; y < (oheight - ycount); y++) |
---|
2803 | for(x = 0; x < xstep; x++) |
---|
2804 | drawpixel(posx + x, posy + y, col); |
---|
2805 | } |
---|
2806 | } |
---|
2807 | } |
---|
2808 | |
---|
2809 | void drawtitlebggradient(struct skin* node) |
---|
2810 | { |
---|
2811 | debug(1000, "in"); |
---|
2812 | if(status.picbordersize > 0) |
---|
2813 | drawgradient(node->rposx + status.picbordersize, node->rposy + status.picbordersize, node->rwidth - (status.picbordersize * 2), node->rheight - (node->rheight - node->titlesize), node->titlebgcol, node->titlebgcol2, node->transparent, node->titlegradient); |
---|
2814 | else |
---|
2815 | drawgradient(node->rposx, node->rposy, node->rwidth, node->rheight - (node->rheight - node->titlesize), node->titlebgcol, node->titlebgcol2, node->transparent, node->titlegradient); |
---|
2816 | debug(1000, "out"); |
---|
2817 | } |
---|
2818 | |
---|
2819 | void drawbggradient(struct skin* node) |
---|
2820 | { |
---|
2821 | debug(1000, "in"); |
---|
2822 | drawgradient(node->rposx, node->rposy, node->rwidth, node->rheight, node->bgcol, node->bgcol2, node->transparent, node->gradient); |
---|
2823 | debug(1000, "out"); |
---|
2824 | } |
---|
2825 | |
---|
2826 | void drawtitlebgcol(struct skin* node) |
---|
2827 | { |
---|
2828 | debug(1000, "in"); |
---|
2829 | if(status.picbordersize > 0) |
---|
2830 | fillrect(node->rposx + status.picbordersize, node->rposy + status.picbordersize, node->rwidth - (status.picbordersize * 2), node->rheight - (node->rheight - node->titlesize), node->titlebgcol, node->transparent); |
---|
2831 | else |
---|
2832 | fillrect(node->rposx, node->rposy, node->rwidth, node->rheight - (node->rheight - node->titlesize), node->titlebgcol, node->transparent); |
---|
2833 | debug(1000, "out"); |
---|
2834 | } |
---|
2835 | |
---|
2836 | void drawbginnercol(struct skin* node) |
---|
2837 | { |
---|
2838 | debug(1000, "in"); |
---|
2839 | fillrect(node->rposx + node->bordersize, node->rposy + node->bordersize, node->rwidth - node->bordersize * 2, node->rheight - node->bordersize * 2, node->bgcol, node->transparent); |
---|
2840 | debug(1000, "out"); |
---|
2841 | } |
---|
2842 | |
---|
2843 | void drawbgcol(struct skin* node) |
---|
2844 | { |
---|
2845 | debug(1000, "in"); |
---|
2846 | fillrect(node->rposx + node->bgspace, node->rposy + node->bgspace, node->rwidth - (node->bgspace * 2), node->rheight - (node->bgspace * 2), node->bgcol, node->transparent); |
---|
2847 | debug(1000, "out"); |
---|
2848 | } |
---|
2849 | |
---|
2850 | void drawtitle(struct skin* node) |
---|
2851 | { |
---|
2852 | debug(1000, "in"); |
---|
2853 | if(status.titlelinesize > 0) |
---|
2854 | drawstring(node->title, 1, 0, -1, node->iposx, node->rposy + node->bordersize, node->iwidth, node->titlesize - status.titlelinesize, node->titlealign, MIDDLE, node->font, node->fontsize, node->fontcol, node->transparent, 0, NULL, NULL, NULL, node->charspace); |
---|
2855 | else |
---|
2856 | drawstring(node->title, 1, 0, -1, node->iposx, node->rposy + node->bordersize, node->iwidth, node->titlesize - node->bordersize, node->titlealign, MIDDLE, node->font, node->fontsize, node->fontcol, node->transparent, 0, NULL, NULL, NULL, node->charspace); |
---|
2857 | if(status.titlelinesize > 0) |
---|
2858 | fillrect(node->rposx, node->rposy + node->titlesize + status.picbordersize, node->rwidth, status.titlelinesize, node->bordercol, node->transparent); |
---|
2859 | else if(node->bordersize > 0) |
---|
2860 | fillrect(node->rposx, node->rposy + node->titlesize, node->rwidth, node->bordersize, node->bordercol, node->transparent); |
---|
2861 | debug(1000, "out"); |
---|
2862 | } |
---|
2863 | |
---|
2864 | void drawprogressbar(struct skin* node) |
---|
2865 | { |
---|
2866 | debug(1000, "in"); |
---|
2867 | int val = 0; |
---|
2868 | |
---|
2869 | if(node->progresssize > 100) node->progresssize = 100; |
---|
2870 | val = ((float)node->iwidth / 100) * node->progresssize; |
---|
2871 | fillrect(node->rposx + node->bordersize, node->rposy + node->bordersize, val, node->iheight, node->progresscol, node->transparent); |
---|
2872 | debug(1000, "out"); |
---|
2873 | } |
---|
2874 | |
---|
2875 | void drawmultiprogressbar(struct skin* node) |
---|
2876 | { |
---|
2877 | debug(1000, "in"); |
---|
2878 | struct epgrecord* epgrecord = node->epgrecord; |
---|
2879 | int val1 = 0, val2 = 0; |
---|
2880 | |
---|
2881 | while(epgrecord != NULL) |
---|
2882 | { |
---|
2883 | |
---|
2884 | if(epgrecord->posx > 100) epgrecord->posx = 100; |
---|
2885 | val1 = ((float)node->iwidth / 100) * epgrecord->posx; |
---|
2886 | if(epgrecord->size > 100) epgrecord->size = 100; |
---|
2887 | val2 = ((float)node->iwidth / 100) * epgrecord->size; |
---|
2888 | |
---|
2889 | if(val2 > val1) |
---|
2890 | fillrect(node->rposx + node->bordersize + val1, node->rposy + node->bordersize, val2 - val1, node->iheight, node->progresscol, node->transparent); |
---|
2891 | epgrecord = epgrecord->next; |
---|
2892 | } |
---|
2893 | debug(1000, "out"); |
---|
2894 | } |
---|
2895 | |
---|
2896 | void drawroundborder(struct skin* node, char* bglt, char* bglb, char* bgrt, char* bgrb) |
---|
2897 | { |
---|
2898 | int i, rad = status.borderradius; |
---|
2899 | |
---|
2900 | if(node->borderradius > 0) rad = node->borderradius; |
---|
2901 | if(rad > node->rheight / 2) rad = node->rheight / 2; |
---|
2902 | int tmpbordersize = rad - node->bordersize; |
---|
2903 | |
---|
2904 | //left - top |
---|
2905 | for(i = rad; i > tmpbordersize; i--) |
---|
2906 | drawcircle(node->rposx + rad, node->rposy + rad, i, 90, 180, node->bordercol, node->transparent, bglt, i == rad); |
---|
2907 | //left - bottom |
---|
2908 | for(i = rad; i > tmpbordersize; i--) |
---|
2909 | drawcircle(node->rposx + rad, node->rposy + node->rheight - 1 - rad, i, 180, 270, node->bordercol, node->transparent, bglb, i == rad); |
---|
2910 | //right - top |
---|
2911 | for(i = rad; i > tmpbordersize; i--) |
---|
2912 | drawcircle(node->rposx + node->rwidth - 1 - rad, node->rposy + rad, i, 0, 90, node->bordercol, node->transparent, bgrt, i == rad); |
---|
2913 | //right - bottom |
---|
2914 | for(i = rad; i > tmpbordersize; i--) |
---|
2915 | drawcircle(node->rposx + node->rwidth - 1 - rad, node->rposy + node->rheight - 1 - rad, i, 270, 360, node->bordercol, node->transparent, bgrb, i == rad); |
---|
2916 | } |
---|
2917 | |
---|
2918 | //TODO: not full implemented |
---|
2919 | void drawpicborder(struct skin* node) |
---|
2920 | { |
---|
2921 | debug(1000, "in"); |
---|
2922 | int borderwidth = status.picbordersize; |
---|
2923 | int borderheight = status.picbordersize; |
---|
2924 | |
---|
2925 | //top-left |
---|
2926 | //drawpic("/home/nit/titan/skin/bs_tl.png", node->rposx + node->bordersize - borderwidth, node->rposy + node->bordersize - borderheight, 0, 0, borderwidth, borderheight, LEFT, TOP); |
---|
2927 | drawpic("/home/nit/titan/skin/bs_tl.png", node->rposx, node->rposy, 0, 0, borderwidth, borderheight, LEFT, TOP); |
---|
2928 | //top-right |
---|
2929 | //drawpic("/home/nit/titan/skin/bs_tr.png", node->rposx - node->bordersize + node->rwidth, node->rposy + node->bordersize - borderheight, 0, 0, borderwidth, borderheight, LEFT, TOP); |
---|
2930 | drawpic("/home/nit/titan/skin/bs_tr.png", node->rposx + node->rwidth - borderwidth, node->rposy, 0, 0, borderwidth, borderheight, LEFT, TOP); |
---|
2931 | //bottom-left |
---|
2932 | //drawpic("/home/nit/titan/skin/bs_bl.png", node->rposx + node->bordersize - borderwidth, node->rposy - node->bordersize + node->rheight, 0, 0, borderwidth, borderheight, LEFT, TOP); |
---|
2933 | drawpic("/home/nit/titan/skin/bs_bl.png", node->rposx, node->rposy + node->rheight - borderheight, 0, 0, borderwidth, borderheight, LEFT, TOP); |
---|
2934 | //bottom-right |
---|
2935 | //drawpic("/home/nit/titan/skin/bs_br.png", node->rposx - node->bordersize + node->rwidth, node->rposy - node->bordersize + node->rheight, 0, 0, borderwidth, borderheight, LEFT, TOP); |
---|
2936 | drawpic("/home/nit/titan/skin/bs_br.png", node->rposx + node->rwidth - borderwidth, node->rposy + node->rheight - borderheight, 0, 0, borderwidth, borderheight, LEFT, TOP); |
---|
2937 | |
---|
2938 | //top |
---|
2939 | //drawpic("/home/nit/titan/skin/bs_t.png", node->rposx + node->bordersize, node->rposy + node->bordersize - borderheight, node->rwidth - (node->bordersize * 2), 0, node->rwidth - (node->bordersize * 2), borderheight, LEFT, TOP); |
---|
2940 | drawpic("/home/nit/titan/skin/bs_t.png", node->rposx + borderwidth, node->rposy, node->rwidth - (borderwidth * 2), 0, node->rwidth - (borderwidth * 2), borderheight, LEFT, TOP); |
---|
2941 | //bottom |
---|
2942 | //drawpic("/home/nit/titan/skin/bs_b.png", node->rposx + node->bordersize, node->rposy - node->bordersize + node->rheight, node->rwidth - (node->bordersize * 2), 0, node->rwidth - (node->bordersize * 2), borderheight, LEFT, TOP); |
---|
2943 | drawpic("/home/nit/titan/skin/bs_b.png", node->rposx + borderwidth, node->rposy + node->rheight - borderheight, node->rwidth - (borderwidth * 2), 0, node->rwidth - (node->bordersize * 2), borderheight, LEFT, TOP); |
---|
2944 | //left |
---|
2945 | //drawpic("/home/nit/titan/skin/bs_l.png", node->rposx + node->bordersize - borderwidth, node->rposy + node->bordersize, 0, node->rheight - (node->bordersize * 2), borderwidth, node->rheight - (node->bordersize * 2), LEFT, TOP); |
---|
2946 | drawpic("/home/nit/titan/skin/bs_l.png", node->rposx, node->rposy + borderheight, 0, node->rheight - (borderheight * 2), borderwidth, node->rheight - (borderheight * 2), LEFT, TOP); |
---|
2947 | //right |
---|
2948 | //drawpic("/home/nit/titan/skin/bs_r.png", node->rposx - node->bordersize + node->rwidth, node->rposy + node->bordersize, 0, node->rheight - (node->bordersize * 2), borderwidth, node->rheight - (node->bordersize * 2), LEFT, TOP); |
---|
2949 | drawpic("/home/nit/titan/skin/bs_r.png", node->rposx + node->rwidth - borderwidth, node->rposy + borderheight, 0, node->rheight - (borderheight * 2), borderwidth, node->rheight - (borderheight * 2), LEFT, TOP); |
---|
2950 | debug(1000, "out"); |
---|
2951 | } |
---|
2952 | |
---|
2953 | void drawborder(struct skin* node) |
---|
2954 | { |
---|
2955 | debug(1000, "in"); |
---|
2956 | if(node->bordersize == 1 && node->rheight > 2 && node->bordertype == 0) |
---|
2957 | drawrect(node->rposx, node->rposy, node->rwidth, node->rheight, node->bordercol, node->transparent); |
---|
2958 | else if(node->bordersize == 1 && node->rheight <= 2 && node->bordertype == 0) |
---|
2959 | fillrect(node->rposx, node->rposy, node->rwidth, node->rheight, node->bordercol, node->transparent); |
---|
2960 | else |
---|
2961 | { |
---|
2962 | if(node->bordertype == 0 || checkbit(node->bordertype, 0) == 1) |
---|
2963 | fillrect(node->rposx, node->rposy, node->rwidth, node->bordersize, node->bordercol, node->transparent); |
---|
2964 | if(node->bordertype == 0 || checkbit(node->bordertype, 1) == 1) |
---|
2965 | fillrect(node->rposx, node->rposy + node->rheight - node->bordersize, node->rwidth, node->bordersize, node->bordercol, node->transparent); |
---|
2966 | if(node->bordertype == 0 || checkbit(node->bordertype, 2) == 1) |
---|
2967 | fillrect(node->rposx, node->rposy, node->bordersize, node->rheight, node->bordercol, node->transparent); |
---|
2968 | if(node->bordertype == 0 || checkbit(node->bordertype, 3) == 1) |
---|
2969 | fillrect(node->rposx + node->rwidth - node->bordersize, node->rposy, node->bordersize, node->rheight, node->bordercol, node->transparent); |
---|
2970 | } |
---|
2971 | debug(1000, "out"); |
---|
2972 | } |
---|
2973 | |
---|
2974 | void drawscrollbar(struct skin* node) |
---|
2975 | { |
---|
2976 | debug(1000, "in"); |
---|
2977 | if(node->bordersize == 0) |
---|
2978 | drawrect(node->rposx + node->rwidth - node->bordersize - node->scrollbarwidth, node->iposy, node->scrollbarwidth, node->iheight, node->bordercol, node->transparent); |
---|
2979 | else |
---|
2980 | fillrect(node->rposx + node->rwidth - node->bordersize - node->scrollbarwidth, node->iposy, node->scrollbarbordersize, node->iheight, node->bordercol, node->transparent); |
---|
2981 | |
---|
2982 | fillrect(node->rposx + node->rwidth - node->bordersize - node->scrollbarwidth, node->iposy + node->scrollbarpos, node->scrollbarwidth, node->scrollbarheight, node->bordercol, node->transparent); |
---|
2983 | debug(1000, "out"); |
---|
2984 | } |
---|
2985 | |
---|
2986 | void clearshadow(struct skin* node) |
---|
2987 | { |
---|
2988 | debug(1000, "in"); |
---|
2989 | |
---|
2990 | if(node->shadowsize < 1) return; |
---|
2991 | switch(node->shadowpos) |
---|
2992 | { |
---|
2993 | case BOTTOMLEFT: |
---|
2994 | clearrect(node->rposx - node->shadowsize, node->rposy + node->rheight, node->rwidth, node->shadowsize); |
---|
2995 | clearrect(node->rposx - node->shadowsize, node->rposy + node->shadowsize, node->shadowsize, node->rheight); |
---|
2996 | break; |
---|
2997 | case BOTTOMRIGHT: |
---|
2998 | clearrect(node->rposx + node->shadowsize, node->rposy + node->rheight, node->rwidth, node->shadowsize); |
---|
2999 | clearrect(node->rposx + node->rwidth, node->rposy + node->shadowsize, node->shadowsize, node->rheight); |
---|
3000 | break; |
---|
3001 | case TOPLEFT: |
---|
3002 | clearrect(node->rposx - node->shadowsize, node->rposy - node->shadowsize, node->rwidth, node->shadowsize); |
---|
3003 | clearrect(node->rposx - node->shadowsize, node->rposy - node->shadowsize, node->shadowsize, node->rheight); |
---|
3004 | break; |
---|
3005 | default: |
---|
3006 | clearrect(node->rposx + node->shadowsize, node->rposy - node->shadowsize, node->rwidth, node->shadowsize); |
---|
3007 | clearrect(node->rposx + node->rwidth, node->rposy - node->shadowsize, node->shadowsize, node->rheight); |
---|
3008 | break; |
---|
3009 | } |
---|
3010 | debug(1000, "out"); |
---|
3011 | } |
---|
3012 | |
---|
3013 | void drawshadow(struct skin* node) |
---|
3014 | { |
---|
3015 | debug(1000, "in"); |
---|
3016 | switch(node->shadowpos) |
---|
3017 | { |
---|
3018 | case BOTTOMLEFT: |
---|
3019 | fillrect(node->rposx - node->shadowsize, node->rposy + node->rheight, node->rwidth, node->shadowsize, node->shadowcol, node->transparent); |
---|
3020 | fillrect(node->rposx - node->shadowsize, node->rposy + node->shadowsize, node->shadowsize, node->rheight, node->shadowcol, node->transparent); |
---|
3021 | break; |
---|
3022 | case BOTTOMRIGHT: |
---|
3023 | fillrect(node->rposx + node->shadowsize, node->rposy + node->rheight, node->rwidth, node->shadowsize, node->shadowcol, node->transparent); |
---|
3024 | fillrect(node->rposx + node->rwidth, node->rposy + node->shadowsize, node->shadowsize, node->rheight, node->shadowcol, node->transparent); |
---|
3025 | break; |
---|
3026 | case TOPLEFT: |
---|
3027 | fillrect(node->rposx - node->shadowsize, node->rposy - node->shadowsize, node->rwidth, node->shadowsize, node->shadowcol, node->transparent); |
---|
3028 | fillrect(node->rposx - node->shadowsize, node->rposy - node->shadowsize, node->shadowsize, node->rheight, node->shadowcol, node->transparent); |
---|
3029 | break; |
---|
3030 | default: |
---|
3031 | fillrect(node->rposx + node->shadowsize, node->rposy - node->shadowsize, node->rwidth, node->shadowsize, node->shadowcol, node->transparent); |
---|
3032 | fillrect(node->rposx + node->rwidth, node->rposy - node->shadowsize, node->shadowsize, node->rheight, node->shadowcol, node->transparent); |
---|
3033 | break; |
---|
3034 | } |
---|
3035 | debug(1000, "out"); |
---|
3036 | } |
---|
3037 | |
---|
3038 | //flag 0: del background |
---|
3039 | //flag 1: don't del background |
---|
3040 | void drawnode(struct skin* node, int flag) |
---|
3041 | { |
---|
3042 | long color = 0, color2 = 0; |
---|
3043 | int len = 0; |
---|
3044 | char* bglt = NULL, *bglb = NULL, *bgrt = NULL, *bgrb = NULL; |
---|
3045 | |
---|
3046 | debug(1000, "in"); |
---|
3047 | |
---|
3048 | node->flag = setbit(node->flag, 0); |
---|
3049 | |
---|
3050 | if(node->bordersize > 0) |
---|
3051 | { |
---|
3052 | if((node->child != NULL && status.borderradius > 0) || node->borderradius > 0) |
---|
3053 | { |
---|
3054 | int rad = status.borderradius; |
---|
3055 | |
---|
3056 | if(node->borderradius > 0) rad = node->borderradius; |
---|
3057 | if(rad > node->rheight / 2) rad = node->rheight / 2; |
---|
3058 | |
---|
3059 | bglt = saverect(node->rposx, node->rposy, rad, rad); |
---|
3060 | bglb = saverect(node->rposx, node->rposy + node->rheight - rad, rad, rad); |
---|
3061 | bgrt = saverect(node->rposx + node->rwidth - rad, node->rposy, rad, rad); |
---|
3062 | bgrb = saverect(node->rposx + node->rwidth - rad, node->rposy + node->rheight - rad, rad, rad); |
---|
3063 | } |
---|
3064 | } |
---|
3065 | |
---|
3066 | if(flag == 0 && node->bgcol != -2) |
---|
3067 | { |
---|
3068 | if(node->child != NULL && status.picbordersize > 0) |
---|
3069 | { |
---|
3070 | clearrect(node->rposx + node->bordersize, node->rposy + node->bordersize, node->rwidth - node->bordersize * 2, node->rheight - node->bordersize * 2); |
---|
3071 | } |
---|
3072 | else |
---|
3073 | clearscreennolock(node); |
---|
3074 | } |
---|
3075 | |
---|
3076 | if(node->deaktivcol > -1) |
---|
3077 | { |
---|
3078 | color = node->deaktivcol; |
---|
3079 | color2 = node->deaktivcol; |
---|
3080 | } |
---|
3081 | else |
---|
3082 | { |
---|
3083 | color = node->fontcol; |
---|
3084 | color2 = node->fontcol2; |
---|
3085 | } |
---|
3086 | |
---|
3087 | if(node->shadowsize > 0) |
---|
3088 | drawshadow(node); |
---|
3089 | if(node->bgcol > -1) |
---|
3090 | { |
---|
3091 | if(node->child != NULL && status.picbordersize > 0) |
---|
3092 | drawbginnercol(node); |
---|
3093 | else |
---|
3094 | drawbgcol(node); |
---|
3095 | } |
---|
3096 | if(node->gradient > 0) |
---|
3097 | drawbggradient(node); |
---|
3098 | if(node->titlebgcol > -1) |
---|
3099 | drawtitlebgcol(node); |
---|
3100 | if(node->titlegradient > 0) |
---|
3101 | drawtitlebggradient(node); |
---|
3102 | if(node->progresssize > 0) |
---|
3103 | drawprogressbar(node); |
---|
3104 | if(node->type & MULTIPROGRESSBAR) |
---|
3105 | drawmultiprogressbar(node); |
---|
3106 | if(node->pic != NULL && !(node->type & FILELIST)) |
---|
3107 | drawpic(node->pic, node->iposx, node->iposy, node->rpicwidth, node->rpicheight, node->iwidth, node->iheight, node->halign, node->valign); |
---|
3108 | if(node->input != NULL) |
---|
3109 | { |
---|
3110 | if(node->type & CHOICEBOX) |
---|
3111 | drawstring(node->input, 1, node->poscount, -1, node->iposx, node->iposy, node->iwidth, node->iheight, RIGHT, node->valign, node->font, node->fontsize, color, node->transparent, 0, NULL, NULL, &len, node->charspace); |
---|
3112 | if((node->type & INPUTBOX) || (node->type & INPUTBOXNUM)) |
---|
3113 | drawstring(node->input, 1, node->poscount, node->aktpage, node->iposx, node->iposy, node->iwidth, node->iheight, RIGHT, node->valign, node->font, node->fontsize, color, node->transparent, 0, NULL, NULL, &len, node->charspace); |
---|
3114 | } |
---|
3115 | if(node->text != NULL) |
---|
3116 | { |
---|
3117 | if(node->type & TEXTBOX) |
---|
3118 | { |
---|
3119 | int lastposy = 0; |
---|
3120 | drawstring(node->text, node->linecount, node->poscount, -1, node->iposx + node->textposx, node->iposy, node->iwidth - node->textposx, node->iheight, node->halign, node->valign, node->font, node->fontsize, color, node->transparent, node->wrap, NULL, &lastposy, NULL, node->charspace); |
---|
3121 | drawstring(node->text2, node->linecount, node->poscount, -1, node->iposx + node->textposx2, lastposy, node->iwidth - node->textposx2, node->iheight - (lastposy - node->iposy), node->halign, node->valign, node->font, node->fontsize2, color2, node->transparent, node->wrap, NULL, &lastposy, NULL, node->charspace); |
---|
3122 | } |
---|
3123 | else |
---|
3124 | { |
---|
3125 | int lastposx = 0; |
---|
3126 | if(node->textposx2 > 0) |
---|
3127 | drawstring(node->text, 1, 0, -1, node->iposx + node->textposx, node->iposy, node->iwidth - node->textposx - (node->iwidth - node->textposx2) - len, node->iheight, node->halign, node->valign, node->font, node->fontsize, color, node->transparent, 0, &lastposx, NULL, NULL, node->charspace); |
---|
3128 | else |
---|
3129 | drawstring(node->text, 1, 0, -1, node->iposx + node->textposx, node->iposy, node->iwidth - node->textposx - len, node->iheight, node->halign, node->valign, node->font, node->fontsize, color, node->transparent, 0, &lastposx, NULL, NULL, node->charspace); |
---|
3130 | if(node->textposx2 > 0) |
---|
3131 | drawstring(node->text2, 1, 0, -1, node->iposx + node->textposx2, node->iposy, node->iwidth - node->textposx2 - len, node->iheight, node->halign, node->valign, node->font, node->fontsize2, color2, node->transparent, 0, NULL, NULL, NULL, node->charspace); |
---|
3132 | else |
---|
3133 | drawstring(node->text2, 1, 0, -1, lastposx, node->iposy, node->iwidth - (lastposx - node->iposx) - len, node->iheight, node->halign, node->valign, node->font, node->fontsize2, color2, node->transparent, 0, NULL, NULL, NULL, node->charspace); |
---|
3134 | } |
---|
3135 | } |
---|
3136 | if(status.filelistextend > 1 && node->filelist != NULL) |
---|
3137 | { |
---|
3138 | char* tmpnr = NULL; |
---|
3139 | |
---|
3140 | if(status.filelistextend == 2) |
---|
3141 | { |
---|
3142 | if(node->filelist->size >= 1073741824) |
---|
3143 | { |
---|
3144 | tmpnr = oftoa64((double)node->filelist->size / 1073741824, "2"); |
---|
3145 | tmpnr = ostrcat(tmpnr, "G", 1, 0); |
---|
3146 | } |
---|
3147 | else if(node->filelist->size >= 1048576) |
---|
3148 | { |
---|
3149 | tmpnr = oftoa64((double)node->filelist->size / 1048576, "2"); |
---|
3150 | tmpnr = ostrcat(tmpnr, "M", 1, 0); |
---|
3151 | } |
---|
3152 | else if(node->filelist->size >= 1024) |
---|
3153 | { |
---|
3154 | tmpnr = oftoa64((double)node->filelist->size / 1024, "2"); |
---|
3155 | tmpnr = ostrcat(tmpnr, "K", 1, 0); |
---|
3156 | } |
---|
3157 | else |
---|
3158 | { |
---|
3159 | tmpnr = oitoa64(node->filelist->size); |
---|
3160 | tmpnr = ostrcat(tmpnr, "B", 1, 0); |
---|
3161 | } |
---|
3162 | } |
---|
3163 | if(status.filelistextend == 3) |
---|
3164 | { |
---|
3165 | tmpnr = malloc(MINMALLOC); |
---|
3166 | if(tmpnr == NULL) |
---|
3167 | { |
---|
3168 | err("no mem"); |
---|
3169 | return; |
---|
3170 | } |
---|
3171 | |
---|
3172 | struct tm* loctime = olocaltime(&node->filelist->date); |
---|
3173 | if(loctime != NULL) |
---|
3174 | strftime(tmpnr, MINMALLOC, "%H:%M %d-%m-%Y", loctime); |
---|
3175 | free(loctime); |
---|
3176 | } |
---|
3177 | drawstring(tmpnr, 1, node->poscount, -1, node->iposx, node->iposy, node->iwidth, node->iheight, RIGHT, node->valign, node->font, node->fontsize, node->fontcol, node->transparent, 0, NULL, NULL, NULL, node->charspace); |
---|
3178 | free(tmpnr); |
---|
3179 | } |
---|
3180 | if(node->title != NULL) |
---|
3181 | drawtitle(node); |
---|
3182 | if(node->scrollbar == YES || node->scrollbar == AUTOYES) |
---|
3183 | drawscrollbar(node); |
---|
3184 | if(node->bordersize > 0) |
---|
3185 | { |
---|
3186 | if(node->child != NULL && status.picbordersize > 0) |
---|
3187 | drawpicborder(node); |
---|
3188 | else |
---|
3189 | drawborder(node); |
---|
3190 | if((node->child != NULL && status.borderradius > 0) || node->borderradius > 0) |
---|
3191 | drawroundborder(node, bglt, bglb, bgrt, bgrb); |
---|
3192 | } |
---|
3193 | |
---|
3194 | free(bglt); free(bglb); free(bgrt); free(bgrb); |
---|
3195 | debug(1000, "out"); |
---|
3196 | } |
---|
3197 | |
---|
3198 | void calcscrollbar(struct skin* node) |
---|
3199 | { |
---|
3200 | debug(1000, "in"); |
---|
3201 | |
---|
3202 | node->scrollbarheight = node->iheight; |
---|
3203 | |
---|
3204 | if(node->pagecount > 1) |
---|
3205 | { |
---|
3206 | node->scrollbarheight = (float)node->iheight / node->pagecount; |
---|
3207 | node->scrollbarpos = ((float)node->iheight / node->pagecount) * (node->aktpage - 1); |
---|
3208 | if(node->scrollbar == AUTONO) node->scrollbar = AUTOYES; |
---|
3209 | } |
---|
3210 | else if(node->scrollbar == AUTOYES) |
---|
3211 | node->scrollbar = AUTONO; |
---|
3212 | |
---|
3213 | if(node->scrollbar == YES || node->scrollbar == AUTOYES) |
---|
3214 | { |
---|
3215 | node->iwidth -= (SCROLLBARWIDTH + 5); |
---|
3216 | node->scrollbarwidth = SCROLLBARWIDTH; |
---|
3217 | node->scrollbarbordersize = SCROLLBARBORDERSIZE; |
---|
3218 | if(node->iposy + node->scrollbarpos > node->iposy + node->iheight) node->scrollbarpos = node->iposy + node->iheight; |
---|
3219 | if(node->scrollbarpos < 0) node->scrollbarpos = 0; |
---|
3220 | if(node->iposy + node->scrollbarpos + node->scrollbarheight > node->iposy + node->iheight) node->scrollbarheight = node->iheight - node->scrollbarpos; |
---|
3221 | if(node->scrollbarheight < 1) node->scrollbarheight = 1; |
---|
3222 | } |
---|
3223 | debug(1000, "out"); |
---|
3224 | } |
---|
3225 | |
---|
3226 | void calclistboxchild(struct skin* node, struct skin* parent) |
---|
3227 | { |
---|
3228 | if((parent->type & GRID) && (node->type & GRIDBR)) |
---|
3229 | { |
---|
3230 | if(parent->poscount > 0) parent->poscount += node->rheight; |
---|
3231 | else if(parent->poscount == 0) parent->poscount = 1; |
---|
3232 | } |
---|
3233 | node->rposy = node->rposy + parent->poscount; |
---|
3234 | node->iposy = node->iposy + parent->poscount; |
---|
3235 | if((parent->type & LISTBOX) || ((parent->type & FILELIST) && !(parent->type & GRID))) |
---|
3236 | parent->poscount += node->rheight; |
---|
3237 | } |
---|
3238 | |
---|
3239 | int calclistbox(struct skin* node) |
---|
3240 | { |
---|
3241 | debug(1000, "in"); |
---|
3242 | struct skin* child = NULL, *last = NULL, *found = NULL; |
---|
3243 | int selcol = convertcol("listboxselect"); |
---|
3244 | int markcol = convertcol("markcol"); |
---|
3245 | |
---|
3246 | node->poscount = 0; |
---|
3247 | if(node->aktline == 0) node->aktline = 1; |
---|
3248 | node->pagecount = 1; |
---|
3249 | node->linecount = 0; |
---|
3250 | |
---|
3251 | child = node->next; |
---|
3252 | while(child != NULL) |
---|
3253 | { |
---|
3254 | if(child->parentpointer == NULL) |
---|
3255 | { |
---|
3256 | if(child->parent == NULL) |
---|
3257 | { |
---|
3258 | child = child->next; |
---|
3259 | continue; |
---|
3260 | } |
---|
3261 | else if(ostrcmp(child->parent, node->name) != 0 || child->hidden == YES || child->locked == YES) |
---|
3262 | { |
---|
3263 | child = child->next; |
---|
3264 | continue; |
---|
3265 | } |
---|
3266 | } |
---|
3267 | else if(child->parentpointer != node || child->hidden == YES || child->locked == YES) |
---|
3268 | { |
---|
3269 | child = child->next; |
---|
3270 | continue; |
---|
3271 | } |
---|
3272 | |
---|
3273 | calcrheight(child, node); |
---|
3274 | |
---|
3275 | if((node->type & LISTBOX) || ((node->type & FILELIST) && !(node->type & GRID)) || ((node->type & GRID) && (child->type & GRIDBR))) |
---|
3276 | node->poscount = node->poscount + child->posy + child->rheight; |
---|
3277 | |
---|
3278 | if(node->poscount > node->iheight) |
---|
3279 | { |
---|
3280 | node->pagecount++; |
---|
3281 | node->poscount = child->rheight; |
---|
3282 | } |
---|
3283 | |
---|
3284 | child->pagecount = node->pagecount; |
---|
3285 | |
---|
3286 | if(child->deaktivcol > -1) |
---|
3287 | { |
---|
3288 | child = child->next; |
---|
3289 | continue; |
---|
3290 | } |
---|
3291 | |
---|
3292 | node->linecount++; |
---|
3293 | last = child; |
---|
3294 | |
---|
3295 | if(node->aktline == -1 && child->pagecount == node->aktpage) |
---|
3296 | node->aktline = node->linecount; |
---|
3297 | |
---|
3298 | if(node->aktline == node->linecount) |
---|
3299 | found = child; |
---|
3300 | |
---|
3301 | child->bordersize = 0; |
---|
3302 | if(child->bgcol == selcol) //&& status.listboxselecttype == 1) |
---|
3303 | child->bgcol = child->bordercol; |
---|
3304 | if(child->fontcol == selcol) //&& status.listboxselecttype == 2) |
---|
3305 | child->fontcol = child->bordercol; |
---|
3306 | |
---|
3307 | child = child->next; |
---|
3308 | } |
---|
3309 | |
---|
3310 | if(found == NULL) |
---|
3311 | { |
---|
3312 | found = last; |
---|
3313 | node->aktline = node->linecount; |
---|
3314 | } |
---|
3315 | else |
---|
3316 | { |
---|
3317 | if(node->aktline == -2) node->aktline = node->linecount; |
---|
3318 | if(status.listboxselecttype == 0) |
---|
3319 | { |
---|
3320 | found->bordersize = 1; |
---|
3321 | if(status.markmodus > 0) |
---|
3322 | found->bordercol = markcol; |
---|
3323 | else |
---|
3324 | found->bordercol = selcol; |
---|
3325 | } |
---|
3326 | else if(status.listboxselecttype == 1) |
---|
3327 | { |
---|
3328 | if(found->bgcol != selcol && found->bgcol != markcol) |
---|
3329 | found->bordercol = found->bgcol; |
---|
3330 | if(status.markmodus > 0) |
---|
3331 | found->bgcol = markcol; |
---|
3332 | else |
---|
3333 | found->bgcol = selcol; |
---|
3334 | } |
---|
3335 | else if(status.listboxselecttype == 2) |
---|
3336 | { |
---|
3337 | if(found->fontcol != selcol && found->fontcol != markcol) |
---|
3338 | found->bordercol = found->fontcol; |
---|
3339 | if(status.markmodus > 0) |
---|
3340 | found->fontcol = markcol; |
---|
3341 | else |
---|
3342 | found->fontcol = selcol; |
---|
3343 | } |
---|
3344 | |
---|
3345 | if(node->aktpage == -1) |
---|
3346 | node->aktpage = found->pagecount; |
---|
3347 | node->select = found; |
---|
3348 | } |
---|
3349 | |
---|
3350 | if(node->aktpage == -1) node->aktpage = 0; |
---|
3351 | if(node->aktpage > node->pagecount) |
---|
3352 | { |
---|
3353 | if(node->pagecount == 0) node->aktpage = 0; |
---|
3354 | else node->aktpage = 1; |
---|
3355 | } |
---|
3356 | node->poscount = 0; |
---|
3357 | debug(1000, "out"); |
---|
3358 | return 0; |
---|
3359 | } |
---|
3360 | |
---|
3361 | int calcrwidth(struct skin* node, struct skin* parent) |
---|
3362 | { |
---|
3363 | int scrollbarwidth = 0; |
---|
3364 | |
---|
3365 | if(node->prozwidth == 1) |
---|
3366 | node->rwidth = ((float)parent->iwidth / 100) * node->width; |
---|
3367 | else |
---|
3368 | node->rwidth = node->width; |
---|
3369 | |
---|
3370 | if(node->scrollbar == YES || node->scrollbar == AUTOYES || node->scrollbar == AUTONO) scrollbarwidth = SCROLLBARWIDTH; |
---|
3371 | |
---|
3372 | if(node->rwidth < (node->bordersize * 2) + scrollbarwidth) node->rwidth = (node->bordersize * 2) + scrollbarwidth; |
---|
3373 | |
---|
3374 | return 0; |
---|
3375 | } |
---|
3376 | |
---|
3377 | int calcrheight(struct skin* node, struct skin* parent) |
---|
3378 | { |
---|
3379 | if(node->prozheight == 1) |
---|
3380 | node->rheight = ((float)parent->iheight / 100) * node->height; |
---|
3381 | else |
---|
3382 | { |
---|
3383 | node->rheight = node->height; |
---|
3384 | if(node->fontsize == 0) node->fontsize = parent->fontsize; |
---|
3385 | if(node->fontsize == 0) node->fontsize = 1; |
---|
3386 | if(node->rheight == 0) node->rheight = node->fontsize + 2; |
---|
3387 | } |
---|
3388 | |
---|
3389 | if(node->rheight < (node->bordersize * 2) + node->titlesize) node->rheight = (node->bordersize * 2) + node->titlesize; |
---|
3390 | |
---|
3391 | return 0; |
---|
3392 | } |
---|
3393 | |
---|
3394 | int calcrposx(struct skin* node, struct skin* parent) |
---|
3395 | { |
---|
3396 | if(node->prozposx == 1) |
---|
3397 | node->rposx = ((float)parent->iwidth / 100) * node->posx; |
---|
3398 | else |
---|
3399 | node->rposx = node->posx; |
---|
3400 | |
---|
3401 | if(node->posx == CENTER || (node->posx == 0 && parent->halign == CENTER)) |
---|
3402 | node->rposx = parent->iposx + parent->iwidth / 2 - node->rwidth / 2; |
---|
3403 | else if(node->posx == LEFT) |
---|
3404 | node->rposx = parent->iposx; |
---|
3405 | else if(node->posx == RIGHT || (node->posx == 0 && parent->halign == RIGHT)) |
---|
3406 | node->rposx = parent->iposx + parent->iwidth - node->rwidth; |
---|
3407 | else |
---|
3408 | node->rposx = parent->iposx + node->rposx; |
---|
3409 | |
---|
3410 | if(node->rposx > parent->iposx + parent->iwidth) |
---|
3411 | node->rposx = parent->iposx + parent->iwidth; |
---|
3412 | |
---|
3413 | return 0; |
---|
3414 | } |
---|
3415 | |
---|
3416 | int calcrposy(struct skin* node, struct skin* parent) |
---|
3417 | { |
---|
3418 | if(node->prozposy == 1) |
---|
3419 | node->rposy = ((float)parent->iheight / 100) * node->posy; |
---|
3420 | else |
---|
3421 | node->rposy = node->posy; |
---|
3422 | |
---|
3423 | if(node->posy == MIDDLE || (node->posy == 0 && parent->valign == MIDDLE)) |
---|
3424 | node->rposy = parent->iposy + parent->iheight / 2 - node->rheight / 2; |
---|
3425 | else if(node->posy == TOP) |
---|
3426 | node->rposy = parent->iposy; |
---|
3427 | else if(node->posy == BOTTOM || (node->posy ==0 && parent->valign == BOTTOM)) |
---|
3428 | node->rposy = parent->iposy + parent->iheight - node->rheight; |
---|
3429 | else |
---|
3430 | node->rposy = parent->iposy + node->rposy; |
---|
3431 | |
---|
3432 | if(node->rposy > parent->iposy + parent->iheight) |
---|
3433 | node->rposy = parent->iposy + parent->iheight; |
---|
3434 | |
---|
3435 | return 0; |
---|
3436 | } |
---|
3437 | |
---|
3438 | int setnodeattr(struct skin* node, struct skin* parent) |
---|
3439 | { |
---|
3440 | if(node != skin) node->flag = clearbit(node->flag, 0); |
---|
3441 | if((parent->type & LISTBOX) || (parent->type & FILELIST) || (parent->type & GRID)) |
---|
3442 | if(node->pagecount != parent->aktpage) return 1; |
---|
3443 | |
---|
3444 | debug(1000, "in"); |
---|
3445 | int shadowlx = 0, shadowrx = 0, shadowoy = 0, shadowuy = 0; |
---|
3446 | unsigned int linecount = 0, pagecount = 0, poscount = 0; |
---|
3447 | char* tmpstr = NULL; |
---|
3448 | |
---|
3449 | if(node->child != NULL && status.picbordersize > 0) |
---|
3450 | node->bordersize = status.picbordersize; |
---|
3451 | |
---|
3452 | if(node->skinfunc != NULL) |
---|
3453 | { |
---|
3454 | if(node->funcrettype == FUNCPIC) |
---|
3455 | { |
---|
3456 | tmpstr = node->skinfunc(node, node->param1, node->param2); |
---|
3457 | changepic(node, tmpstr); |
---|
3458 | } |
---|
3459 | else if(node->funcrettype == FUNCPROGRESS) |
---|
3460 | { |
---|
3461 | tmpstr = node->skinfunc(node, node->param1, node->param2); |
---|
3462 | if(tmpstr != NULL) |
---|
3463 | { |
---|
3464 | node->hidden = NO; |
---|
3465 | node->progresssize = atoi(tmpstr); |
---|
3466 | } |
---|
3467 | else |
---|
3468 | node->hidden = YES; |
---|
3469 | } |
---|
3470 | else |
---|
3471 | { |
---|
3472 | tmpstr = node->skinfunc(node, node->param1, node->param2); |
---|
3473 | changetext(node, _(tmpstr)); |
---|
3474 | } |
---|
3475 | free(tmpstr); |
---|
3476 | } |
---|
3477 | |
---|
3478 | if(status.screencalc != 2) |
---|
3479 | { |
---|
3480 | if(node->hidden == YES || parent->hidden == YES || node->locked == YES || parent->locked == YES) return 1; |
---|
3481 | if(checkbit(parent->flag, 0) == 0) return 1; |
---|
3482 | } |
---|
3483 | |
---|
3484 | calcrwidth(node, parent); |
---|
3485 | if(!(parent->type & LISTBOX) && !(parent->type & FILELIST) && !(parent->type & GRID)) |
---|
3486 | calcrheight(node, parent); |
---|
3487 | calcrposx(node, parent); |
---|
3488 | calcrposy(node, parent); |
---|
3489 | |
---|
3490 | if(node->height < 0) |
---|
3491 | node->rheight = parent->iheight + node->height - (node->rposy - parent->iposy); |
---|
3492 | if(node->width < 0) |
---|
3493 | node->rwidth = parent->iwidth + node->width - (node->rposx - parent->iposx); |
---|
3494 | |
---|
3495 | node->iposx = node->rposx + node->bordersize + node->hspace; |
---|
3496 | node->iposy = node->rposy + node->bordersize + node->titlesize + node->vspace; |
---|
3497 | node->iwidth = node->rwidth - node->bordersize * 2 - node->hspace * 2; |
---|
3498 | node->iheight = node->rheight - node->bordersize * 2 - node->titlesize - node->vspace * 2; |
---|
3499 | |
---|
3500 | switch(node->shadowpos) |
---|
3501 | { |
---|
3502 | case BOTTOMLEFT: shadowlx = shadowuy = node->shadowsize; break; |
---|
3503 | case BOTTOMRIGHT: shadowrx = shadowuy = node->shadowsize; break; |
---|
3504 | case TOPLEFT: shadowlx = shadowoy = node->shadowsize; break; |
---|
3505 | default: shadowrx = shadowoy = node->shadowsize; break; |
---|
3506 | } |
---|
3507 | |
---|
3508 | if((parent->type & LISTBOX) || (parent->type & FILELIST) || (parent->type & GRID)) |
---|
3509 | calclistboxchild(node, parent); |
---|
3510 | |
---|
3511 | if(node->picprozwidth == 1) |
---|
3512 | node->rpicwidth = ((float)node->iwidth / 100) * node->picwidth; |
---|
3513 | else |
---|
3514 | node->rpicwidth = node->picwidth; |
---|
3515 | if(node->picprozheight == 1) |
---|
3516 | node->rpicheight = ((float)node->iheight / 100) * node->picheight; |
---|
3517 | else |
---|
3518 | node->rpicheight = node->picheight; |
---|
3519 | |
---|
3520 | |
---|
3521 | if(node->rposx - shadowlx < parent->iposx) |
---|
3522 | { |
---|
3523 | if(status.screencalc == 0) err("node (%s posx=%d) out of parent (%s posx=%d)", node->name, node->rposx - shadowlx, parent->name, parent->iposx); |
---|
3524 | node->rposx = parent->iposx + shadowlx; |
---|
3525 | //return 1; |
---|
3526 | } |
---|
3527 | if(node->rposy - shadowoy < parent->iposy) |
---|
3528 | { |
---|
3529 | if(status.screencalc == 0) err("node (%s posy=%d) out of parent (%s posy=%d)", node->name, node->rposy - shadowoy, parent->name, parent->iposy); |
---|
3530 | node->rposy = parent->iposy + shadowoy; |
---|
3531 | //return 1; |
---|
3532 | } |
---|
3533 | if(node->rposx + node->rwidth + shadowrx > parent->iposx + parent->iwidth) |
---|
3534 | { |
---|
3535 | if(status.screencalc == 0) err("node (%s posxx=%d) out of parent (%s posxx=%d)", node->name, node->rposx + node->rwidth + shadowrx, parent->name, parent->iposx + parent->iwidth); |
---|
3536 | node->rwidth = parent->iwidth - node->rposx - shadowrx; |
---|
3537 | //return 1; |
---|
3538 | } |
---|
3539 | if(node->rposy + node->rheight + shadowuy > parent->iposy + parent->iheight) |
---|
3540 | { |
---|
3541 | if(status.screencalc == 0) err("node (%s posyy=%d) out of parent (%s posyy=%d)", node->name, node->rposy + node->rheight + shadowuy, parent->name, parent->iposy + parent->iheight); |
---|
3542 | node->rheight = parent->iheight - node->rposy - shadowuy; |
---|
3543 | //return 1; |
---|
3544 | } |
---|
3545 | |
---|
3546 | if(node->font == NULL && parent->font != NULL) |
---|
3547 | { |
---|
3548 | changefont(node, parent->font); |
---|
3549 | if(node->font == NULL) |
---|
3550 | { |
---|
3551 | err("no memory"); |
---|
3552 | } |
---|
3553 | } |
---|
3554 | |
---|
3555 | if(node->fontsize == 0) node->fontsize = parent->fontsize; |
---|
3556 | if(node->fontsize == 0) node->fontsize = 1; |
---|
3557 | if(node->fontsize2 == 0) node->fontsize2 = parent->fontsize2; |
---|
3558 | if(node->fontsize2 == 0) node->fontsize2 = 1; |
---|
3559 | if(node->fontcol == 0) node->fontcol = parent->fontcol; |
---|
3560 | if(node->fontcol2 == 0) node->fontcol2 = parent->fontcol2; |
---|
3561 | |
---|
3562 | if((node->type & INPUTBOX) || (node->type & INPUTBOXNUM)) |
---|
3563 | { |
---|
3564 | if(node->aktpage < 1) node->aktpage = 1; |
---|
3565 | checkinputboxnumright(node); |
---|
3566 | changeret(node, node->input); |
---|
3567 | } |
---|
3568 | |
---|
3569 | if((node->type & LISTBOX) || (node->type & FILELIST) || (node->type & GRID)) |
---|
3570 | { |
---|
3571 | if(node->aktpage == 0) node->aktpage = 1; |
---|
3572 | calclistbox(node); |
---|
3573 | if(node->scrollbar != NO) |
---|
3574 | calcscrollbar(node); |
---|
3575 | } |
---|
3576 | if(node->type & TEXTBOX) |
---|
3577 | { |
---|
3578 | if(node->aktpage < 1) node->aktpage = 1; |
---|
3579 | if(node->text == NULL && node->text2 == NULL) |
---|
3580 | node->pagecount = 0; |
---|
3581 | else |
---|
3582 | { |
---|
3583 | if(node->wrap == YES) |
---|
3584 | wrapstr(node->text, node->font, node->fontsize, node->iwidth, node->charspace); |
---|
3585 | calctext(node->text, node->text2, &node->linecount, &node->pagecount, &node->poscount, node->iheight / node->fontsize, node->aktpage); |
---|
3586 | } |
---|
3587 | if(node->text2 != NULL) node->scrollbar = NO; |
---|
3588 | if(node->scrollbar != NO) |
---|
3589 | calcscrollbar(node); |
---|
3590 | } |
---|
3591 | |
---|
3592 | if((node->type & CHOICEBOX) && node->input != NULL) |
---|
3593 | { |
---|
3594 | char* pos = NULL; |
---|
3595 | calctext(node->input, NULL, &node->linecount, &node->pagecount, &node->poscount, 1, node->aktpage); |
---|
3596 | |
---|
3597 | free(node->ret); |
---|
3598 | node->ret = NULL; |
---|
3599 | |
---|
3600 | if(node->choiceboxvalue != NULL) |
---|
3601 | { |
---|
3602 | calctext(node->choiceboxvalue, NULL, &linecount, &pagecount, &poscount, 1, node->aktpage); |
---|
3603 | pos = strchr(node->choiceboxvalue + poscount, '\n'); |
---|
3604 | if(pos == NULL) |
---|
3605 | changeret(node, node->choiceboxvalue + poscount); |
---|
3606 | else |
---|
3607 | node->ret = strndup(node->choiceboxvalue + poscount, pos - (node->choiceboxvalue + poscount)); |
---|
3608 | } |
---|
3609 | else if(node->input != NULL) |
---|
3610 | { |
---|
3611 | pos = strchr(node->input + node->poscount, '\n'); |
---|
3612 | if(pos == NULL) |
---|
3613 | changeret(node, node->input + node->poscount); |
---|
3614 | else |
---|
3615 | node->ret = strndup(node->input + node->poscount, pos - (node->input + node->poscount)); |
---|
3616 | } |
---|
3617 | } |
---|
3618 | |
---|
3619 | //set parent transparent to child |
---|
3620 | //if(node->transparent == 0 && parent != skin) |
---|
3621 | //node->transparent = parent->transparent; |
---|
3622 | |
---|
3623 | debug(1000, "out"); |
---|
3624 | return 0; |
---|
3625 | } |
---|
3626 | |
---|
3627 | int clearscreenalways() |
---|
3628 | { |
---|
3629 | debug(1000, "in"); |
---|
3630 | int i, ret = 0; |
---|
3631 | |
---|
3632 | for(i = 0; i < sizeof(status.drawallways) / sizeof(skin); i++) |
---|
3633 | { |
---|
3634 | if(status.drawallways[i] != NULL) |
---|
3635 | { |
---|
3636 | clearrect(status.drawallways[i]->rposx, status.drawallways[i]->rposy, status.drawallways[i]->rwidth, status.drawallways[i]->rheight); |
---|
3637 | } |
---|
3638 | } |
---|
3639 | |
---|
3640 | debug(1000, "out"); |
---|
3641 | return ret; |
---|
3642 | } |
---|
3643 | |
---|
3644 | int drawscreenalways(struct skin* node) |
---|
3645 | { |
---|
3646 | debug(1000, "in"); |
---|
3647 | int i, ret = 0; |
---|
3648 | |
---|
3649 | for(i = 0; i < sizeof(status.drawallways) / sizeof(skin); i++) |
---|
3650 | { |
---|
3651 | if(status.drawallways[i] != NULL) |
---|
3652 | { |
---|
3653 | if(node != status.drawallways[i]) |
---|
3654 | { |
---|
3655 | if(status.drawallwaysbg[i] != NULL) |
---|
3656 | free(status.drawallwaysbg[i]); |
---|
3657 | status.drawallwaysbg[i] = savescreen(status.drawallways[i]); |
---|
3658 | ret = drawscreen(status.drawallways[i], 1); |
---|
3659 | } |
---|
3660 | } |
---|
3661 | } |
---|
3662 | |
---|
3663 | debug(1000, "out"); |
---|
3664 | return ret; |
---|
3665 | } |
---|
3666 | |
---|
3667 | int drawscreennode(struct skin *node, char* nodename) |
---|
3668 | { |
---|
3669 | debug(1000, "in"); |
---|
3670 | |
---|
3671 | node = getscreennode(node, nodename); |
---|
3672 | m_lock(&status.drawingmutex, 0); |
---|
3673 | if(node != status.skinerr) |
---|
3674 | drawnode(node, 1); |
---|
3675 | |
---|
3676 | drawscreenalways(node); |
---|
3677 | blitfb(0); |
---|
3678 | m_unlock(&status.drawingmutex, 0); |
---|
3679 | |
---|
3680 | debug(1000, "out"); |
---|
3681 | return 0; |
---|
3682 | } |
---|
3683 | |
---|
3684 | int drawscreennodebyname(char* screenname, char* nodename) |
---|
3685 | { |
---|
3686 | debug(1000, "in"); |
---|
3687 | struct skin *node; |
---|
3688 | |
---|
3689 | node = getscreennodebyname(screenname, nodename); |
---|
3690 | m_lock(&status.drawingmutex, 0); |
---|
3691 | if(node != status.skinerr) |
---|
3692 | drawnode(node, 1); |
---|
3693 | |
---|
3694 | drawscreenalways(node); |
---|
3695 | blitfb(0); |
---|
3696 | m_unlock(&status.drawingmutex, 0); |
---|
3697 | |
---|
3698 | debug(1000, "out"); |
---|
3699 | return 0; |
---|
3700 | } |
---|
3701 | |
---|
3702 | //flag 0: draw normal with allways |
---|
3703 | //flag 1: draw without allways |
---|
3704 | //flag 2: from thread (mutex is set in thread) |
---|
3705 | //flag 3: same as 0 but don't use status.screencalc |
---|
3706 | //flag 4: same as 0 but animate |
---|
3707 | int drawscreen(struct skin* node, int flag) |
---|
3708 | { |
---|
3709 | struct fb* merkskinfb = NULL; |
---|
3710 | |
---|
3711 | debug(1000, "in"); |
---|
3712 | int ret; |
---|
3713 | struct skin *child = NULL, *parent = NULL, *oldparent = NULL; |
---|
3714 | |
---|
3715 | if(node == NULL) |
---|
3716 | { |
---|
3717 | err("node = NULL"); |
---|
3718 | return 1; |
---|
3719 | } |
---|
3720 | |
---|
3721 | if(flag == 0 || flag == 3 || flag == 4) |
---|
3722 | m_lock(&status.drawingmutex, 0); |
---|
3723 | |
---|
3724 | parent = skin; |
---|
3725 | |
---|
3726 | ret = setnodeattr(node, parent); |
---|
3727 | if(ret == 1) |
---|
3728 | { |
---|
3729 | if(flag == 0 || flag == 3 || flag == 4) |
---|
3730 | m_unlock(&status.drawingmutex, 0); |
---|
3731 | debug(1000, "out -> setnodeattr ret = 1"); |
---|
3732 | return 1; |
---|
3733 | } |
---|
3734 | |
---|
3735 | if(strstr(node->name, "LCD_") != NULL) { |
---|
3736 | merkskinfb = skinfb; |
---|
3737 | memset(lcdskinfb->fb, 0, lcdskinfb->varfbsize); |
---|
3738 | skinfb = lcdskinfb; |
---|
3739 | } |
---|
3740 | |
---|
3741 | if(status.screencalc == 0 || flag == 3 || flag == 4) |
---|
3742 | { |
---|
3743 | if(flag == 0 || flag == 2 || flag == 3 || flag == 4) clearscreenalways(); |
---|
3744 | drawnode(node, 0); |
---|
3745 | } |
---|
3746 | parent = node; |
---|
3747 | oldparent = node; |
---|
3748 | child = node->child; |
---|
3749 | |
---|
3750 | while(child != NULL) |
---|
3751 | { |
---|
3752 | if(child->parentpointer != NULL) |
---|
3753 | parent = child->parentpointer; |
---|
3754 | else if(child->parent != NULL) |
---|
3755 | { |
---|
3756 | parent = getscreennode(node, child->parent); |
---|
3757 | if(parent == status.skinerr) parent = oldparent; |
---|
3758 | } |
---|
3759 | else |
---|
3760 | parent = oldparent; |
---|
3761 | |
---|
3762 | if(setnodeattr(child, parent) == 0 && (status.screencalc == 0 || flag == 3)) |
---|
3763 | drawnode(child, 1); |
---|
3764 | child = child->next; |
---|
3765 | } |
---|
3766 | |
---|
3767 | if(flag == 0 || flag == 2 || flag == 3 || flag == 4) |
---|
3768 | { |
---|
3769 | if(status.screencalc == 0 || flag == 3) |
---|
3770 | { |
---|
3771 | drawscreenalways(node); |
---|
3772 | |
---|
3773 | if(merkskinfb != NULL) |
---|
3774 | pngforlcd(); |
---|
3775 | else |
---|
3776 | { |
---|
3777 | if(flag == 4) |
---|
3778 | blitfb(1); |
---|
3779 | else |
---|
3780 | blitfb(0); |
---|
3781 | } |
---|
3782 | } |
---|
3783 | } |
---|
3784 | |
---|
3785 | if(merkskinfb != NULL) |
---|
3786 | { |
---|
3787 | skinfb = merkskinfb; |
---|
3788 | merkskinfb = NULL; |
---|
3789 | } |
---|
3790 | else { |
---|
3791 | if(ostrcmp(getconfig("write_fb_to_jpeg", NULL), "yes") == 0) |
---|
3792 | write_FB_to_JPEG_file(skinfb->fb, skinfb->width, skinfb->height, "/tmp/fb.jpg", 3); |
---|
3793 | } |
---|
3794 | if(flag == 0 || flag == 3 || flag == 4) |
---|
3795 | m_unlock(&status.drawingmutex, 0); |
---|
3796 | debug(1000, "out"); |
---|
3797 | return 0; |
---|
3798 | } |
---|
3799 | |
---|
3800 | int drawscreenbyname(char* screenname) |
---|
3801 | { |
---|
3802 | debug(1000, "in"); |
---|
3803 | int ret; |
---|
3804 | struct skin* node = NULL; |
---|
3805 | |
---|
3806 | node = getscreen(screenname); |
---|
3807 | if(node == status.skinerr) |
---|
3808 | { |
---|
3809 | err("screen not found (%s)", screenname); |
---|
3810 | return 1; |
---|
3811 | } |
---|
3812 | |
---|
3813 | ret = drawscreen(node, 0); |
---|
3814 | debug(1000, "out"); |
---|
3815 | return ret; |
---|
3816 | } |
---|
3817 | |
---|
3818 | int changeinput(struct skin* node, char* text) |
---|
3819 | { |
---|
3820 | debug(1000, "in"); |
---|
3821 | int ret = 1; |
---|
3822 | |
---|
3823 | if(node != NULL) |
---|
3824 | { |
---|
3825 | free(node->input); |
---|
3826 | if(text != NULL) |
---|
3827 | { |
---|
3828 | if((node->type & INPUTBOXNUM) && node->mask != NULL && strlen(text) == 0) |
---|
3829 | node->input = strdup(node->mask); |
---|
3830 | else |
---|
3831 | node->input = strdup(text); |
---|
3832 | } |
---|
3833 | else |
---|
3834 | { |
---|
3835 | if((node->type & INPUTBOXNUM) && node->mask != NULL) |
---|
3836 | node->input = strdup(node->mask); |
---|
3837 | else |
---|
3838 | node->input = text; |
---|
3839 | } |
---|
3840 | ret = 0; |
---|
3841 | } |
---|
3842 | debug(1000, "out"); |
---|
3843 | |
---|
3844 | return ret; |
---|
3845 | } |
---|
3846 | |
---|
3847 | int changetext(struct skin* node, char* text) |
---|
3848 | { |
---|
3849 | debug(1000, "in"); |
---|
3850 | int ret = 1; |
---|
3851 | |
---|
3852 | if(node != NULL) |
---|
3853 | { |
---|
3854 | free(node->text); |
---|
3855 | if(text != NULL) |
---|
3856 | node->text = strdup(text); |
---|
3857 | else |
---|
3858 | node->text = text; |
---|
3859 | ret = 0; |
---|
3860 | } |
---|
3861 | debug(1000, "out"); |
---|
3862 | |
---|
3863 | return ret; |
---|
3864 | } |
---|
3865 | |
---|
3866 | int changetext2(struct skin* node, char* text) |
---|
3867 | { |
---|
3868 | debug(1000, "in"); |
---|
3869 | int ret = 1; |
---|
3870 | |
---|
3871 | if(node != NULL) |
---|
3872 | { |
---|
3873 | free(node->text2); |
---|
3874 | if(text != NULL) |
---|
3875 | node->text2 = strdup(text); |
---|
3876 | else |
---|
3877 | node->text2 = text; |
---|
3878 | ret = 0; |
---|
3879 | } |
---|
3880 | debug(1000, "out"); |
---|
3881 | |
---|
3882 | return ret; |
---|
3883 | } |
---|
3884 | |
---|
3885 | |
---|
3886 | int changename(struct skin* node, char* text) |
---|
3887 | { |
---|
3888 | debug(1000, "in"); |
---|
3889 | int ret = 1; |
---|
3890 | |
---|
3891 | if(node != NULL) |
---|
3892 | { |
---|
3893 | free(node->name); |
---|
3894 | if(text != NULL) |
---|
3895 | node->name = strdup(text); |
---|
3896 | else |
---|
3897 | node->name = text; |
---|
3898 | ret = 0; |
---|
3899 | } |
---|
3900 | debug(1000, "out"); |
---|
3901 | |
---|
3902 | return ret; |
---|
3903 | } |
---|
3904 | |
---|
3905 | int changepicmem(struct skin* node, char* text, int del) |
---|
3906 | { |
---|
3907 | debug(1000, "in"); |
---|
3908 | unsigned long width = 0, height = 0, rowbytes = 0; |
---|
3909 | int ret = 1, channels = 0, memfd = -1, length = 0; |
---|
3910 | unsigned char* buf = NULL; |
---|
3911 | |
---|
3912 | if(node != NULL) |
---|
3913 | { |
---|
3914 | free(node->pic); |
---|
3915 | if(text != NULL) |
---|
3916 | { |
---|
3917 | node->pic = changepicpath(text); |
---|
3918 | |
---|
3919 | if(getpic(node->pic) == NULL) |
---|
3920 | { |
---|
3921 | length = strlen(node->pic); |
---|
3922 | if(node->pic[length - 1] == 'g' && node->pic[length - 2] == 'n' && node->pic[length - 3] == 'p') |
---|
3923 | buf = readpng(node->pic, &width, &height, &rowbytes, &channels, 0, 0, 0, 0, 0, 0); |
---|
3924 | else if(getconfigint("pichwdecode", NULL) == 1) |
---|
3925 | readjpg(node->pic, &width, &height, &rowbytes, &channels, &buf, &memfd); |
---|
3926 | addpic(node->pic, buf, memfd, width, height, rowbytes, channels, del, NULL); |
---|
3927 | } |
---|
3928 | } |
---|
3929 | else |
---|
3930 | node->pic = text; |
---|
3931 | ret = 0; |
---|
3932 | } |
---|
3933 | debug(1000, "out"); |
---|
3934 | |
---|
3935 | return ret; |
---|
3936 | } |
---|
3937 | |
---|
3938 | int changepic(struct skin* node, char* text) |
---|
3939 | { |
---|
3940 | debug(1000, "in"); |
---|
3941 | int ret = 1; |
---|
3942 | |
---|
3943 | if(node != NULL) |
---|
3944 | { |
---|
3945 | free(node->pic); |
---|
3946 | if(text != NULL) |
---|
3947 | node->pic = changepicpath(text); |
---|
3948 | else |
---|
3949 | node->pic = text; |
---|
3950 | ret = 0; |
---|
3951 | } |
---|
3952 | debug(1000, "out"); |
---|
3953 | |
---|
3954 | return ret; |
---|
3955 | } |
---|
3956 | |
---|
3957 | int changetitle(struct skin* node, char* text) |
---|
3958 | { |
---|
3959 | debug(1000, "in"); |
---|
3960 | int ret = 1; |
---|
3961 | |
---|
3962 | if(node != NULL) |
---|
3963 | { |
---|
3964 | free(node->title); |
---|
3965 | if(text != NULL) |
---|
3966 | { |
---|
3967 | node->title = strdup(text); |
---|
3968 | node->titlesize = node->fontsize + 6; |
---|
3969 | } |
---|
3970 | else |
---|
3971 | { |
---|
3972 | node->title = text; |
---|
3973 | node->titlesize = 0; |
---|
3974 | } |
---|
3975 | ret = 0; |
---|
3976 | } |
---|
3977 | debug(1000, "out"); |
---|
3978 | |
---|
3979 | return ret; |
---|
3980 | } |
---|
3981 | |
---|
3982 | int changemask(struct skin* node, char* text) |
---|
3983 | { |
---|
3984 | debug(1000, "in"); |
---|
3985 | int ret = 1; |
---|
3986 | |
---|
3987 | if(node != NULL) |
---|
3988 | { |
---|
3989 | free(node->mask); |
---|
3990 | if(text != NULL) |
---|
3991 | { |
---|
3992 | if((node->type & INPUTBOXNUM) && (node->input == NULL || strlen(node->input) == 0)) |
---|
3993 | { |
---|
3994 | node->mask = strdup(text); |
---|
3995 | free(node->input); |
---|
3996 | node->input = strdup(text); |
---|
3997 | } |
---|
3998 | else |
---|
3999 | node->mask = strdup(text); |
---|
4000 | } |
---|
4001 | else |
---|
4002 | node->mask = text; |
---|
4003 | ret = 0; |
---|
4004 | } |
---|
4005 | debug(1000, "out"); |
---|
4006 | |
---|
4007 | return ret; |
---|
4008 | } |
---|
4009 | |
---|
4010 | int changeret(struct skin* node, char* text) |
---|
4011 | { |
---|
4012 | debug(1000, "in"); |
---|
4013 | int ret = 1; |
---|
4014 | |
---|
4015 | if(node != NULL) |
---|
4016 | { |
---|
4017 | free(node->ret); |
---|
4018 | if(text != NULL) |
---|
4019 | node->ret = strdup(text); |
---|
4020 | else |
---|
4021 | node->ret = text; |
---|
4022 | ret = 0; |
---|
4023 | } |
---|
4024 | debug(1000, "out"); |
---|
4025 | |
---|
4026 | return ret; |
---|
4027 | } |
---|
4028 | |
---|
4029 | int changeparent(struct skin* node, char* text) |
---|
4030 | { |
---|
4031 | debug(1000, "in"); |
---|
4032 | int ret = 1; |
---|
4033 | |
---|
4034 | if(node != NULL) |
---|
4035 | { |
---|
4036 | free(node->parent); |
---|
4037 | if(text != NULL) |
---|
4038 | node->parent = strdup(text); |
---|
4039 | else |
---|
4040 | node->parent = text; |
---|
4041 | ret = 0; |
---|
4042 | } |
---|
4043 | debug(1000, "out"); |
---|
4044 | |
---|
4045 | return ret; |
---|
4046 | } |
---|
4047 | |
---|
4048 | int changefont(struct skin* node, char* text) |
---|
4049 | { |
---|
4050 | debug(1000, "in"); |
---|
4051 | int ret = 1; |
---|
4052 | |
---|
4053 | if(node != NULL) |
---|
4054 | { |
---|
4055 | free(node->font); |
---|
4056 | if(text != NULL) |
---|
4057 | node->font = strdup(text); |
---|
4058 | else |
---|
4059 | node->font = text; |
---|
4060 | ret = 0; |
---|
4061 | } |
---|
4062 | debug(1000, "out"); |
---|
4063 | |
---|
4064 | return ret; |
---|
4065 | } |
---|
4066 | |
---|
4067 | int changeparam1(struct skin* node, char* text) |
---|
4068 | { |
---|
4069 | debug(1000, "in"); |
---|
4070 | int ret = 1; |
---|
4071 | |
---|
4072 | if(node != NULL) |
---|
4073 | { |
---|
4074 | free(node->param1); |
---|
4075 | if(text != NULL) |
---|
4076 | node->param1 = strdup(text); |
---|
4077 | else |
---|
4078 | node->param1 = text; |
---|
4079 | ret = 0; |
---|
4080 | } |
---|
4081 | debug(1000, "out"); |
---|
4082 | |
---|
4083 | return ret; |
---|
4084 | } |
---|
4085 | |
---|
4086 | int changeparam2(struct skin* node, char* text) |
---|
4087 | { |
---|
4088 | debug(1000, "in"); |
---|
4089 | int ret = 1; |
---|
4090 | |
---|
4091 | if(node != NULL) |
---|
4092 | { |
---|
4093 | free(node->param2); |
---|
4094 | if(text != NULL) |
---|
4095 | node->param2 = strdup(text); |
---|
4096 | else |
---|
4097 | node->param2 = text; |
---|
4098 | ret = 0; |
---|
4099 | } |
---|
4100 | debug(1000, "out"); |
---|
4101 | |
---|
4102 | return ret; |
---|
4103 | } |
---|
4104 | |
---|
4105 | int changechoiceboxvalue(struct skin* node, char* text) |
---|
4106 | { |
---|
4107 | debug(1000, "in"); |
---|
4108 | int ret = 1; |
---|
4109 | |
---|
4110 | if(node != NULL) |
---|
4111 | { |
---|
4112 | free(node->choiceboxvalue); |
---|
4113 | if(text != NULL) |
---|
4114 | node->choiceboxvalue = strdup(text); |
---|
4115 | else |
---|
4116 | node->choiceboxvalue = text; |
---|
4117 | ret = 0; |
---|
4118 | } |
---|
4119 | debug(1000, "out"); |
---|
4120 | |
---|
4121 | return ret; |
---|
4122 | } |
---|
4123 | |
---|
4124 | #endif |
---|