diff options
Diffstat (limited to 'apps/gui/skin_engine/wps_parser.c')
-rw-r--r-- | apps/gui/skin_engine/wps_parser.c | 97 |
1 files changed, 8 insertions, 89 deletions
diff --git a/apps/gui/skin_engine/wps_parser.c b/apps/gui/skin_engine/wps_parser.c index 440133327a..3df2c5f0aa 100644 --- a/apps/gui/skin_engine/wps_parser.c +++ b/apps/gui/skin_engine/wps_parser.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include "file.h" | 25 | #include "file.h" |
26 | #include "misc.h" | 26 | #include "misc.h" |
27 | #include "plugin.h" | 27 | #include "plugin.h" |
28 | #include "viewport.h" | ||
28 | 29 | ||
29 | #ifdef __PCTOOL__ | 30 | #ifdef __PCTOOL__ |
30 | #ifdef WPSEDITOR | 31 | #ifdef WPSEDITOR |
@@ -587,26 +588,12 @@ static int parse_viewport(const char *wps_bufptr, | |||
587 | { | 588 | { |
588 | (void)token; /* Kill warnings */ | 589 | (void)token; /* Kill warnings */ |
589 | const char *ptr = wps_bufptr; | 590 | const char *ptr = wps_bufptr; |
590 | struct viewport* vp; | 591 | |
591 | int depth; | 592 | const int screen = |
592 | uint32_t set = 0; | ||
593 | enum { | ||
594 | PL_X = 0, | ||
595 | PL_Y, | ||
596 | PL_WIDTH, | ||
597 | PL_HEIGHT, | ||
598 | PL_FONT, | ||
599 | PL_FG, | ||
600 | PL_BG, | ||
601 | }; | ||
602 | int lcd_width = LCD_WIDTH, lcd_height = LCD_HEIGHT; | ||
603 | #ifdef HAVE_REMOTE_LCD | 593 | #ifdef HAVE_REMOTE_LCD |
604 | if (wps_data->remote_wps) | 594 | wps_data->remote_wps ? SCREEN_REMOTE : |
605 | { | ||
606 | lcd_width = LCD_REMOTE_WIDTH; | ||
607 | lcd_height = LCD_REMOTE_HEIGHT; | ||
608 | } | ||
609 | #endif | 595 | #endif |
596 | SCREEN_MAIN; | ||
610 | 597 | ||
611 | if (wps_data->num_viewports >= WPS_MAX_VIEWPORTS) | 598 | if (wps_data->num_viewports >= WPS_MAX_VIEWPORTS) |
612 | return WPS_ERROR_INVALID_PARAM; | 599 | return WPS_ERROR_INVALID_PARAM; |
@@ -635,87 +622,19 @@ static int parse_viewport(const char *wps_bufptr, | |||
635 | return WPS_ERROR_INVALID_PARAM; | 622 | return WPS_ERROR_INVALID_PARAM; |
636 | 623 | ||
637 | ptr++; | 624 | ptr++; |
638 | vp = &wps_data->viewports[wps_data->num_viewports].vp; | 625 | struct viewport *vp = &wps_data->viewports[wps_data->num_viewports].vp; |
639 | /* format: %V|x|y|width|height|font|fg_pattern|bg_pattern| */ | 626 | /* format: %V|x|y|width|height|font|fg_pattern|bg_pattern| */ |
640 | 627 | ||
641 | /* Set the defaults for fields not user-specified */ | 628 | /* Set the defaults for fields not user-specified */ |
642 | vp->drawmode = DRMODE_SOLID; | 629 | vp->drawmode = DRMODE_SOLID; |
643 | 630 | ||
644 | /* Work out the depth of this display */ | 631 | if (!(ptr = viewport_parse_viewport(vp, screen, ptr, '|'))) |
645 | #ifdef HAVE_REMOTE_LCD | 632 | return WPS_ERROR_INVALID_PARAM; |
646 | depth = (wps_data->remote_wps ? LCD_REMOTE_DEPTH : LCD_DEPTH); | ||
647 | #else | ||
648 | depth = LCD_DEPTH; | ||
649 | #endif | ||
650 | |||
651 | #ifdef HAVE_LCD_COLOR | ||
652 | if (depth == 16) | ||
653 | { | ||
654 | if (!(ptr = parse_list("dddddcc", &set, '|', ptr, &vp->x, &vp->y, &vp->width, | ||
655 | &vp->height, &vp->font, &vp->fg_pattern,&vp->bg_pattern))) | ||
656 | return WPS_ERROR_INVALID_PARAM; | ||
657 | } | ||
658 | else | ||
659 | #endif | ||
660 | #if (LCD_DEPTH == 2) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH == 2) | ||
661 | if (depth == 2) { | ||
662 | /* Default to black on white */ | ||
663 | vp->fg_pattern = 0; | ||
664 | vp->bg_pattern = 3; | ||
665 | if (!(ptr = parse_list("dddddgg", &set, '|', ptr, &vp->x, &vp->y, &vp->width, | ||
666 | &vp->height, &vp->font, &vp->fg_pattern, &vp->bg_pattern))) | ||
667 | return WPS_ERROR_INVALID_PARAM; | ||
668 | } | ||
669 | else | ||
670 | #endif | ||
671 | #if (LCD_DEPTH == 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH == 1) | ||
672 | if (depth == 1) | ||
673 | { | ||
674 | if (!(ptr = parse_list("ddddd", &set, '|', ptr, &vp->x, &vp->y, | ||
675 | &vp->width, &vp->height, &vp->font))) | ||
676 | return WPS_ERROR_INVALID_PARAM; | ||
677 | } | ||
678 | else | ||
679 | #endif | ||
680 | {} | ||
681 | 633 | ||
682 | /* Check for trailing | */ | 634 | /* Check for trailing | */ |
683 | if (*ptr != '|') | 635 | if (*ptr != '|') |
684 | return WPS_ERROR_INVALID_PARAM; | 636 | return WPS_ERROR_INVALID_PARAM; |
685 | 637 | ||
686 | if (!LIST_VALUE_PARSED(set, PL_X) || !LIST_VALUE_PARSED(set, PL_Y)) | ||
687 | return WPS_ERROR_INVALID_PARAM; | ||
688 | |||
689 | /* fix defaults */ | ||
690 | if (!LIST_VALUE_PARSED(set, PL_WIDTH)) | ||
691 | vp->width = lcd_width - vp->x; | ||
692 | if (!LIST_VALUE_PARSED(set, PL_HEIGHT)) | ||
693 | vp->height = lcd_height - vp->y; | ||
694 | |||
695 | /* Default to using the user font if the font was an invalid number */ | ||
696 | if (!LIST_VALUE_PARSED(set, PL_FONT) || | ||
697 | ((vp->font != FONT_SYSFIXED) && (vp->font != FONT_UI))) | ||
698 | vp->font = FONT_UI; | ||
699 | |||
700 | /* Validate the viewport dimensions - we know that the numbers are | ||
701 | non-negative integers */ | ||
702 | if ((vp->x >= lcd_width) || | ||
703 | ((vp->x + vp->width) > lcd_width) || | ||
704 | (vp->y >= lcd_height) || | ||
705 | ((vp->y + vp->height) > lcd_height)) | ||
706 | { | ||
707 | return WPS_ERROR_INVALID_PARAM; | ||
708 | } | ||
709 | |||
710 | #ifdef HAVE_LCD_COLOR | ||
711 | if (depth == 16) | ||
712 | { | ||
713 | if (!LIST_VALUE_PARSED(set, PL_FG)) | ||
714 | vp->fg_pattern = global_settings.fg_color; | ||
715 | if (!LIST_VALUE_PARSED(set, PL_BG)) | ||
716 | vp->bg_pattern = global_settings.bg_color; | ||
717 | } | ||
718 | #endif | ||
719 | 638 | ||
720 | wps_data->viewports[wps_data->num_viewports-1].last_line = wps_data->num_lines - 1; | 639 | wps_data->viewports[wps_data->num_viewports-1].last_line = wps_data->num_lines - 1; |
721 | 640 | ||