summaryrefslogtreecommitdiff
path: root/tools/checkwps/checkwps.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/checkwps/checkwps.c')
-rw-r--r--tools/checkwps/checkwps.c120
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
32bool debug_wps = true; 33bool debug_wps = true;
33int wps_verbose_level = 0; 34int 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
323extern const char* parse_list(const char *fmt, uint32_t *set_vals,
324 const char sep, const char* str, ...);
325
326const 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
416int main(int argc, char **argv) 298int main(int argc, char **argv)
417{ 299{
418 int res; 300 int res;