diff options
author | Thomas Martitz <kugel@rockbox.org> | 2009-09-13 13:40:58 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2009-09-13 13:40:58 +0000 |
commit | c0f1c49178b4c205e1c990ea2fb25a417305528c (patch) | |
tree | 637fdedd15f2119125cdaa257fbf7798e8687e74 /tools/checkwps/checkwps.c | |
parent | 541dd6fda5ae93073a0b9c499f62af2cf46f3529 (diff) | |
download | rockbox-c0f1c49178b4c205e1c990ea2fb25a417305528c.tar.gz rockbox-c0f1c49178b4c205e1c990ea2fb25a417305528c.zip |
Get rid of some of the code duplication from checkwps, it still duplicates a lot though.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22695 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools/checkwps/checkwps.c')
-rw-r--r-- | tools/checkwps/checkwps.c | 120 |
1 files changed, 1 insertions, 119 deletions
diff --git a/tools/checkwps/checkwps.c b/tools/checkwps/checkwps.c index 6e985195fb..079454def1 100644 --- a/tools/checkwps/checkwps.c +++ b/tools/checkwps/checkwps.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include "wps.h" | 28 | #include "wps.h" |
29 | #include "wps_internals.h" | 29 | #include "wps_internals.h" |
30 | #include "settings.h" | 30 | #include "settings.h" |
31 | #include "viewport.h" | ||
31 | 32 | ||
32 | bool debug_wps = true; | 33 | bool debug_wps = true; |
33 | int wps_verbose_level = 0; | 34 | int wps_verbose_level = 0; |
@@ -294,125 +295,6 @@ struct skin_viewport* find_viewport(char label, struct wps_data *data) | |||
294 | return NULL; | 295 | return NULL; |
295 | } | 296 | } |
296 | 297 | ||
297 | /* From viewport.c & misc.h */ | ||
298 | #define LIST_VALUE_PARSED(setvals, position) ((setvals) & BIT_N(position)) | ||
299 | |||
300 | /*some short cuts for fg/bg/line selector handling */ | ||
301 | #ifdef HAVE_LCD_COLOR | ||
302 | #define LINE_SEL_FROM_SETTINGS(vp) \ | ||
303 | do { \ | ||
304 | vp->lss_pattern = global_settings.lss_color; \ | ||
305 | vp->lse_pattern = global_settings.lse_color; \ | ||
306 | vp->lst_pattern = global_settings.lst_color; \ | ||
307 | } while (0) | ||
308 | #define FG_FALLBACK global_settings.fg_color | ||
309 | #define BG_FALLBACK global_settings.bg_color | ||
310 | #else | ||
311 | /* mono/greyscale doesn't have most of the above */ | ||
312 | #define LINE_SEL_FROM_SETTINGS(vp) | ||
313 | #define FG_FALLBACK LCD_DEFAULT_FG | ||
314 | #define BG_FALLBACK LCD_DEFAULT_BG | ||
315 | #endif | ||
316 | |||
317 | #ifdef HAVE_LCD_COLOR | ||
318 | #define ARG_STRING(_depth) ((_depth) == 2 ? "dddddgg":"dddddcc") | ||
319 | #else | ||
320 | #define ARG_STRING(_depth) "dddddgg" | ||
321 | #endif | ||
322 | |||
323 | extern const char* parse_list(const char *fmt, uint32_t *set_vals, | ||
324 | const char sep, const char* str, ...); | ||
325 | |||
326 | const char* viewport_parse_viewport(struct viewport *vp, | ||
327 | enum screen_type screen, | ||
328 | const char *bufptr, | ||
329 | const char separator) | ||
330 | { | ||
331 | /* parse the list to the viewport struct */ | ||
332 | const char *ptr = bufptr; | ||
333 | int depth; | ||
334 | uint32_t set = 0; | ||
335 | |||
336 | enum { | ||
337 | PL_X = 0, | ||
338 | PL_Y, | ||
339 | PL_WIDTH, | ||
340 | PL_HEIGHT, | ||
341 | PL_FONT, | ||
342 | PL_FG, | ||
343 | PL_BG, | ||
344 | }; | ||
345 | |||
346 | /* Work out the depth of this display */ | ||
347 | depth = screens[screen].depth; | ||
348 | #if (LCD_DEPTH == 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH == 1) | ||
349 | if (depth == 1) | ||
350 | { | ||
351 | #ifdef HAVE_LCD_BITMAP | ||
352 | if (!(ptr = parse_list("ddddd", &set, separator, ptr, | ||
353 | &vp->x, &vp->y, &vp->width, &vp->height, &vp->font))) | ||
354 | return NULL; | ||
355 | #endif | ||
356 | } | ||
357 | else | ||
358 | #endif | ||
359 | #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1) | ||
360 | if (depth >= 2) | ||
361 | { | ||
362 | if (!(ptr = parse_list(ARG_STRING(depth), &set, separator, ptr, | ||
363 | &vp->x, &vp->y, &vp->width, &vp->height, &vp->font, | ||
364 | &vp->fg_pattern,&vp->bg_pattern))) | ||
365 | return NULL; | ||
366 | } | ||
367 | else | ||
368 | #endif | ||
369 | {} | ||
370 | #undef ARG_STRING | ||
371 | |||
372 | /* X and Y *must* be set */ | ||
373 | if (!LIST_VALUE_PARSED(set, PL_X) || !LIST_VALUE_PARSED(set, PL_Y)) | ||
374 | return NULL; | ||
375 | |||
376 | /* fix defaults */ | ||
377 | if (!LIST_VALUE_PARSED(set, PL_WIDTH)) | ||
378 | vp->width = screens[screen].lcdwidth - vp->x; | ||
379 | if (!LIST_VALUE_PARSED(set, PL_HEIGHT)) | ||
380 | vp->height = screens[screen].lcdheight - vp->y; | ||
381 | |||
382 | #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1) | ||
383 | if (!LIST_VALUE_PARSED(set, PL_FG)) | ||
384 | vp->fg_pattern = FG_FALLBACK; | ||
385 | if (!LIST_VALUE_PARSED(set, PL_BG)) | ||
386 | vp->bg_pattern = BG_FALLBACK; | ||
387 | #endif /* LCD_DEPTH > 1 || LCD_REMOTE_DEPTH > 1 */ | ||
388 | |||
389 | LINE_SEL_FROM_SETTINGS(vp); | ||
390 | |||
391 | /* Validate the viewport dimensions - we know that the numbers are | ||
392 | non-negative integers, ignore bars and assume the viewport takes them | ||
393 | * into account */ | ||
394 | if ((vp->x >= screens[screen].lcdwidth) || | ||
395 | ((vp->x + vp->width) > screens[screen].lcdwidth) || | ||
396 | (vp->y >= screens[screen].lcdheight) || | ||
397 | ((vp->y + vp->height) > screens[screen].lcdheight)) | ||
398 | { | ||
399 | return NULL; | ||
400 | } | ||
401 | |||
402 | #ifdef HAVE_LCD_BITMAP | ||
403 | /* Default to using the user font if the font was an invalid number or '-'*/ | ||
404 | if (((vp->font != FONT_SYSFIXED) && (vp->font != FONT_UI)) | ||
405 | || !LIST_VALUE_PARSED(set, PL_FONT) | ||
406 | ) | ||
407 | vp->font = FONT_UI; | ||
408 | |||
409 | /* Set the defaults for fields not user-specified */ | ||
410 | vp->drawmode = DRMODE_SOLID; | ||
411 | #endif | ||
412 | |||
413 | return ptr; | ||
414 | } | ||
415 | |||
416 | int main(int argc, char **argv) | 298 | int main(int argc, char **argv) |
417 | { | 299 | { |
418 | int res; | 300 | int res; |