source: svn/trunk/newcon3bcm2_21bu/nexus/app/nanotv/bscreen.c @ 2

Last change on this file since 2 was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 234.7 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003-2006, Broadcom Corporation
3 *     All Rights Reserved
4 *     Confidential Property of Broadcom Corporation
5 *
6 *  THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *  AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *  EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile:  $
11 * $brcm_Revision:  $
12 * $brcm_Date: $
13 *
14 * Module Description:
15 *
16 * Revision History:
17 *
18 * $brcm_Log:  $
19 *
20 ***************************************************************************/
21
22#include "bapp.h"
23#include "bstd.h"
24#include "bapp_util.h"
25#include "bgfx.h"
26#include "chan_mgr.h"
27#include "bsmart.h"
28
29BDBG_MODULE(bscreen);      /* Register software module with debug interface */
30
31//#define TEST_RRT
32/* local function declarations */
33void screen_null_draw(void *v_app, void *v_screen);
34void banner_null_draw(void *v_app, void *v_screen);
35void popup_null_draw(void *v_app, void *v_screen);
36void bscreen_popup_draw(void *v_app, void *v_screen, btext_id_t title, btext_id_t desc);
37static void adjust_button_orientation(void *v_app, 
38                                                                          bbutton_t *p_button);
39
40#define SCREEN_MIN(a,b) ((a)<(b) ? (a) : (b))   /* min macro */
41
42screensaver_state_t g_screensaver_state = 
43{
44        0
45};
46
47banner_state_t g_banner_state = 
48{
49        { 0, 0, 0},
50        { 0, 0, 0},
51        0,
52        0,
53        false,
54        false,
55        eLS_BANNER_OFF,
56        { eS_EVENT_MAX, 0, 0},
57        0,
58        0,
59        0,
60        0,
61        0,
62        0
63};
64
65/*
66Summary:
67        screen button arrays.
68*/
69
70
71bbutton_t g_buttons_main[] =
72{
73        {eBUTTON_MENU,eMENU_FIRST_BUTTON_X,eMENU_FIRST_BUTTON_Y + 0 * eMENU_BUTTON_INC_Y,eMENU_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_GUIDE_BUTTON,eTEXT_GUIDE_INFO,eSCREEN_GUIDE, eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
74        {eBUTTON_MENU,eMENU_FIRST_BUTTON_X,eMENU_FIRST_BUTTON_Y + 1 * eMENU_BUTTON_INC_Y,eMENU_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_AV_BUTTON,eTEXT_AV_INFO,eSCREEN_AV, eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
75        {eBUTTON_MENU,eMENU_FIRST_BUTTON_X,eMENU_FIRST_BUTTON_Y + 2 * eMENU_BUTTON_INC_Y,eMENU_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_RATINGS_BUTTON,eTEXT_RATINGS_INFO,eSCREEN_PIN_VERIFY_RATINGS,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
76#ifdef CONFIG_EIA_708
77        {eBUTTON_MENU,eMENU_FIRST_BUTTON_X,eMENU_FIRST_BUTTON_Y + 3 * eMENU_BUTTON_INC_Y,eMENU_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CAPTIONS_BUTTON,eTEXT_CAPTIONS_INFO,eSCREEN_CAPTIONS_ADVANCED,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
78        {eBUTTON_MENU,eMENU_FIRST_BUTTON_X,eMENU_FIRST_BUTTON_Y + 4 * eMENU_BUTTON_INC_Y,eMENU_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_SETUP_BUTTON,eTEXT_SETUP_INFO,eSCREEN_SETUP,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
79#else
80        {eBUTTON_MENU,eMENU_FIRST_BUTTON_X,eMENU_FIRST_BUTTON_Y + 3 * eMENU_BUTTON_INC_Y,eMENU_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_SETUP_BUTTON,eTEXT_SETUP_INFO,eSCREEN_SETUP,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
81        {eBUTTON_MENU,eMENU_FIRST_BUTTON_X,eMENU_FIRST_BUTTON_Y + 4 * eMENU_BUTTON_INC_Y,eMENU_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_RESET_BUTTON,eTEXT_RESET_INFO,eSCREEN_PIN_VERIFY_RESET,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
82#endif
83};
84
85bbutton_t g_buttons_picture[] =
86{
87        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_PICTURES_FIRST_BUTTON_X,eMENU_PICTURES_FIRST_BUTTON_Y,eMENU_PICTURES_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_WIDESCREEN_BUTTON,eTEXT_WIDESCREEN_INFO,eSCREEN_AV,eSCREEN_MAIN, 1, eCOLOR_MED_BLUE},
88        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_PICTURES_FIRST_BUTTON_X,eMENU_PICTURES_FIRST_BUTTON_Y + eMENU_PICTURES_BUTTON_INC_Y,eMENU_PICTURES_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_FULLSCREEN_BUTTON,eTEXT_FULLSCREEN_INFO,eSCREEN_AV,eSCREEN_MAIN, 1, eCOLOR_MED_BLUE},
89};
90
91bbutton_t g_buttons_timezone[] =
92{
93        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_TIMEZONE_FIRST_BUTTON_X,eMENU_TIMEZONE_FIRST_BUTTON_Y,eMENU_TIMEZONE_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_TIMEZONE_AUTO_BUTTON,eTEXT_TIMEZONE_AUTO_BUTTON_INFO,eSCREEN_SETUP,eSCREEN_MAIN, 1, eCOLOR_MED_BLUE},
94        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_TIMEZONE_FIRST_BUTTON_X,eMENU_TIMEZONE_FIRST_BUTTON_Y + 1 * eMENU_TIMEZONE_BUTTON_INC_Y,eMENU_TIMEZONE_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_TIMEZONE_EAST_BUTTON,eTEXT_TIMEZONE_EAST_BUTTON_INFO,eSCREEN_SETUP,eSCREEN_MAIN, 1, eCOLOR_MED_BLUE},
95        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_TIMEZONE_FIRST_BUTTON_X,eMENU_TIMEZONE_FIRST_BUTTON_Y + 2 * eMENU_TIMEZONE_BUTTON_INC_Y-6,eMENU_TIMEZONE_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_TIMEZONE_CENTRAL_BUTTON,eTEXT_TIMEZONE_CENTRAL_BUTTON_INFO,eSCREEN_SETUP,eSCREEN_MAIN, 1, eCOLOR_MED_BLUE},
96        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_TIMEZONE_FIRST_BUTTON_X,eMENU_TIMEZONE_FIRST_BUTTON_Y + 3 * eMENU_TIMEZONE_BUTTON_INC_Y-6,eMENU_TIMEZONE_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_TIMEZONE_MOUNTAIN_BUTTON,eTEXT_TIMEZONE_MOUNTAIN_BUTTON_INFO,eSCREEN_SETUP,eSCREEN_MAIN, 1, eCOLOR_MED_BLUE},
97        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_TIMEZONE_FIRST_BUTTON_X,eMENU_TIMEZONE_FIRST_BUTTON_Y + 4 * eMENU_TIMEZONE_BUTTON_INC_Y-6,eMENU_TIMEZONE_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_TIMEZONE_PACIFIC_BUTTON,eTEXT_TIMEZONE_PACIFIC_BUTTON_INFO,eSCREEN_SETUP,eSCREEN_MAIN, 1, eCOLOR_MED_BLUE},
98        {eBUTTON_CHECK,eMENU_TIMEZONE_FIRST_BUTTON_X,eMENU_TIMEZONE_FIRST_BUTTON_Y + 5 * eMENU_TIMEZONE_BUTTON_INC_Y-6,eMENU_TIMEZONE_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_TIMEZONE_DST_BUTTON,eTEXT_TIMEZONE_DST_BUTTON_INFO,eSCREEN_SETUP,eSCREEN_MAIN, 1, eCOLOR_MED_BLUE},
99};
100
101bbutton_t g_buttons_sound[] =
102{
103        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_SOUND_FIRST_BUTTON_X,eMENU_SOUND_FIRST_BUTTON_Y,eMENU_SOUND_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_STEREO_BUTTON,eTEXT_STEREO_INFO ,eSCREEN_AV,eSCREEN_MAIN, 1, eCOLOR_MED_BLUE},
104        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_SOUND_FIRST_BUTTON_X,eMENU_SOUND_FIRST_BUTTON_Y + 1 * eMENU_SOUND_BUTTON_INC_Y,eMENU_SOUND_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_SAP_BUTTON,eTEXT_SAP_INFO,eSCREEN_AV,eSCREEN_MAIN, 1, eCOLOR_MED_BLUE},
105};
106bbutton_t g_buttons_av[] =
107{
108        {eBUTTON_MENU,eMENU_AV_FIRST_BUTTON_X,eMENU_AV_FIRST_BUTTON_Y,eMENU_AV_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_PICTURE_BUTTON,eTEXT_PICTURE_INFO ,eSCREEN_PICTURE,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
109        {eBUTTON_MENU,eMENU_AV_FIRST_BUTTON_X,eMENU_AV_FIRST_BUTTON_Y + eMENU_AV_BUTTON_INC_Y,eMENU_AV_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_SOUND_BUTTON,eTEXT_SOUND_INFO,eSCREEN_SOUND,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
110};
111
112bbutton_t g_buttons_language[] =
113{
114        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_LANGUAGE_FIRST_BUTTON_X,eMENU_LANGUAGE_FIRST_BUTTON_Y,eMENU_LANGUAGE_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_ENGLISH_BUTTON,eTEXT_ENGLISH_INFO ,eSCREEN_SETUP,eSCREEN_MAIN, 1, eCOLOR_MED_BLUE},
115        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_LANGUAGE_FIRST_BUTTON_X,eMENU_LANGUAGE_FIRST_BUTTON_Y + eMENU_LANGUAGE_BUTTON_INC_Y,eMENU_LANGUAGE_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_SPANISH_BUTTON,eTEXT_SPANISH_INFO,eSCREEN_SETUP,eSCREEN_MAIN, 1, eCOLOR_MED_BLUE},
116        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_LANGUAGE_FIRST_BUTTON_X,eMENU_LANGUAGE_FIRST_BUTTON_Y + 2 * eMENU_LANGUAGE_BUTTON_INC_Y,eMENU_LANGUAGE_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_FRENCH_BUTTON,eTEXT_FRENCH_INFO,eSCREEN_SETUP,eSCREEN_MAIN, 1, eCOLOR_MED_BLUE},
117};
118
119bbutton_t g_buttons_captions_advanced[] =
120{
121        {eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,(eMENU_CAPTIONS_FIRST_BUTTON_Y),eMENU_CAPTIONS_ADVANCED_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CAPTIONS_FONT_OPTIONS_BUTTON,eTEXT_CAPTIONS_FONT_OPTIONS_INFO,eSCREEN_CAPTIONS_FONT_OPTIONS,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
122        {eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,(eMENU_CAPTIONS_FIRST_BUTTON_Y + 12) + eMENU_CAPTIONS_BUTTON_INC_Y,eMENU_CAPTIONS_ADVANCED_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CAPTIONS_BACK_OPTIONS_BUTTON,eTEXT_CAPTIONS_BACK_OPTIONS_INFO,eSCREEN_CAPTIONS_BACK_OPTIONS,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
123        {eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,(eMENU_CAPTIONS_FIRST_BUTTON_Y + 12) + 2 * eMENU_CAPTIONS_BUTTON_INC_Y,eMENU_CAPTIONS_ADVANCED_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CAPTIONS_DEFAULT_BUTTON,eTEXT_CAPTIONS_DEFAULT_INFO,eSCREEN_CAPTIONS_RESET,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
124};
125
126bbutton_t g_buttons_captions_font_options[] =
127{
128        {eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_OPTIONS_FIRST_BUTTON_Y,eMENU_CAPTIONS_FONT_OPTIONS_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_OPTIONS_BUTTON_HEIGHT,eTEXT_CAPTIONS_FONT_BUTTON,eTEXT_CAPTIONS_FONT_INFO,eSCREEN_CAPTIONS_FONT,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
129        {eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_OPTIONS_FIRST_BUTTON_Y + eMENU_CAPTIONS_FONT_OPTIONS_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_OPTIONS_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_OPTIONS_BUTTON_HEIGHT,eTEXT_CAPTIONS_FONT_SIZE_BUTTON,eTEXT_CAPTIONS_FONT_SIZE_INFO,eSCREEN_CAPTIONS_FONT_SIZE,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
130        {eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_OPTIONS_FIRST_BUTTON_Y + 2 * eMENU_CAPTIONS_FONT_OPTIONS_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_OPTIONS_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_OPTIONS_BUTTON_HEIGHT,eTEXT_CAPTIONS_FONT_STYLE_BUTTON,eTEXT_CAPTIONS_FONT_STYLE_INFO,eSCREEN_CAPTIONS_FONT_STYLE,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
131        {eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_OPTIONS_FIRST_BUTTON_Y + 3 * eMENU_CAPTIONS_FONT_OPTIONS_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_OPTIONS_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_OPTIONS_BUTTON_HEIGHT,eTEXT_CAPTIONS_FONT_COLOR_BUTTON,eTEXT_CAPTIONS_FONT_COLOR_INFO,eSCREEN_CAPTIONS_FONT_COLOR,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
132        {eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_OPTIONS_FIRST_BUTTON_Y + 4 * eMENU_CAPTIONS_FONT_OPTIONS_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_OPTIONS_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_OPTIONS_BUTTON_HEIGHT,eTEXT_CAPTIONS_FONT_OPACITY_BUTTON,eTEXT_CAPTIONS_FONT_OPACITY_INFO,eSCREEN_CAPTIONS_FONT_OPACITY,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
133};
134
135bbutton_t g_buttons_captions_back_options[] =
136{
137        {eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_BACK_OPTIONS_FIRST_BUTTON_Y,eMENU_CAPTIONS_BACK_OPTIONS_BUTTON_WIDTH,eMENU_CAPTIONS_BACK_OPTIONS_BUTTON_HEIGHT,eTEXT_CAPTIONS_EDGE_COLOR_BUTTON,eTEXT_CAPTIONS_EDGE_COLOR_INFO,eSCREEN_CAPTIONS_EDGE_COLOR,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
138        {eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_BACK_OPTIONS_FIRST_BUTTON_Y + eMENU_CAPTIONS_BUTTON_INC_Y,eMENU_CAPTIONS_BACK_OPTIONS_BUTTON_WIDTH,eMENU_CAPTIONS_BACK_OPTIONS_BUTTON_HEIGHT,eTEXT_CAPTIONS_EDGE_TYPE_BUTTON,eTEXT_CAPTIONS_EDGE_TYPE_INFO,eSCREEN_CAPTIONS_EDGE_TYPE,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
139        {eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_BACK_OPTIONS_FIRST_BUTTON_Y + 2 * eMENU_CAPTIONS_BUTTON_INC_Y,eMENU_CAPTIONS_BACK_OPTIONS_BUTTON_WIDTH,eMENU_CAPTIONS_BACK_OPTIONS_BUTTON_HEIGHT,eTEXT_CAPTIONS_BACKGROUND_COLOR_BUTTON,eTEXT_CAPTIONS_BACKGROUND_COLOR_INFO,eSCREEN_CAPTIONS_BACK_COLOR,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
140        {eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_BACK_OPTIONS_FIRST_BUTTON_Y + 3 * eMENU_CAPTIONS_BUTTON_INC_Y,eMENU_CAPTIONS_BACK_OPTIONS_BUTTON_WIDTH,eMENU_CAPTIONS_BACK_OPTIONS_BUTTON_HEIGHT,eTEXT_CAPTIONS_BACKGROUND_OPACITY_BUTTON,eTEXT_CAPTIONS_BACKGROUND_OPACITY_INFO,eSCREEN_CAPTIONS_BACK_OPACITY,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
141};
142
143bbutton_t g_buttons_captions_font[] =
144{
145        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_BUTTON_HEIGHT,eTEXT_CAPTIONS_FONT_DEFAULT_BUTTON,eTEXT_CAPTIONS_FONT_DEFAULT_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
146        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + eMENU_CAPTIONS_FONT_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_BUTTON_HEIGHT,eTEXT_CAPTIONS_FONT_MONO_SERIF_BUTTON,eTEXT_CAPTIONS_FONT_MONO_SERIF_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
147        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + 2 * eMENU_CAPTIONS_FONT_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_BUTTON_HEIGHT,eTEXT_CAPTIONS_FONT_PROP_SERIF_BUTTON,eTEXT_CAPTIONS_FONT_PROP_SERIF_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
148        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + 3 * eMENU_CAPTIONS_FONT_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_BUTTON_HEIGHT,eTEXT_CAPTIONS_FONT_MONOSPACE_BUTTON,eTEXT_CAPTIONS_FONT_MONOSPACE_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
149        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + 4 * eMENU_CAPTIONS_FONT_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_BUTTON_HEIGHT,eTEXT_CAPTIONS_FONT_PROPORTIONAL_BUTTON,eTEXT_CAPTIONS_FONT_PROPORTIONAL_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
150        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + 5 * eMENU_CAPTIONS_FONT_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_BUTTON_HEIGHT,eTEXT_CAPTIONS_FONT_CASUAL_BUTTON,eTEXT_CAPTIONS_FONT_CASUAL_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
151        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + 6 * eMENU_CAPTIONS_FONT_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_BUTTON_HEIGHT,eTEXT_CAPTIONS_FONT_CURSIVE_BUTTON,eTEXT_CAPTIONS_FONT_CURSIVE_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
152        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + 7 * eMENU_CAPTIONS_FONT_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_BUTTON_HEIGHT,eTEXT_CAPTIONS_FONT_SMALL_CAPS_BUTTON,eTEXT_CAPTIONS_FONT_SMALL_CAPS_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
153};
154
155bbutton_t g_buttons_captions_font_size[] =
156{
157        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_SIZE_BUTTON_Y,eMENU_CAPTIONS_FONT_STYLE_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CAPTIONS_FONT_DEFAULT_BUTTON,eTEXT_CAPTIONS_FONT_DEFAULT_SIZE_INFO ,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
158        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_SIZE_BUTTON_Y + 1 * eMENU_CAPTIONS_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_STYLE_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CAPTIONS_FONT_SMALL_BUTTON,eTEXT_CAPTIONS_FONT_SMALL_INFO ,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
159        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_SIZE_BUTTON_Y + 2 * eMENU_CAPTIONS_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_STYLE_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CAPTIONS_FONT_STANDARD_BUTTON,eTEXT_CAPTIONS_FONT_STANDARD_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
160        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_SIZE_BUTTON_Y + 3 * eMENU_CAPTIONS_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_STYLE_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CAPTIONS_FONT_LARGE_BUTTON,eTEXT_CAPTIONS_FONT_LARGE_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
161};
162
163bbutton_t g_buttons_captions_font_style[] =
164{
165        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_STYLE_BUTTON_Y + 0 * eMENU_CAPTIONS_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_STYLE_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CAPTIONS_FONT_NORMAL_BUTTON,eTEXT_CAPTIONS_FONT_NORMAL_INFO ,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
166        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_STYLE_BUTTON_Y + 1 * eMENU_CAPTIONS_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_STYLE_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CAPTIONS_FONT_ITALIC_BUTTON,eTEXT_CAPTIONS_FONT_ITALIC_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
167        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_STYLE_BUTTON_Y + 2 * eMENU_CAPTIONS_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_STYLE_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CAPTIONS_FONT_UNDERLINE_BUTTON,eTEXT_CAPTIONS_FONT_UNDERLINE_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
168};
169
170bbutton_t g_buttons_captions_font_color[] =
171{
172        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_COLOR_BUTTON_HEIGHT,eTEXT_CAPTIONS_FONT_DEFAULT_BUTTON,eTEXT_CAPTIONS_COLOR_DEFAULT_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
173        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + eMENU_CAPTIONS_FONT_COLOR_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_COLOR_BUTTON_HEIGHT,eTEXT_CAPTIONS_COLOR_WHITE_BUTTON,eTEXT_CAPTIONS_COLOR_WHITE_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
174        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + 2 * eMENU_CAPTIONS_FONT_COLOR_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_COLOR_BUTTON_HEIGHT,eTEXT_CAPTIONS_COLOR_BLACK_BUTTON,eTEXT_CAPTIONS_COLOR_BLACK_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
175        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + 3 * eMENU_CAPTIONS_FONT_COLOR_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_COLOR_BUTTON_HEIGHT,eTEXT_CAPTIONS_COLOR_RED_BUTTON,eTEXT_CAPTIONS_COLOR_RED_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
176        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + 4 * eMENU_CAPTIONS_FONT_COLOR_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_COLOR_BUTTON_HEIGHT,eTEXT_CAPTIONS_COLOR_GREEN_BUTTON,eTEXT_CAPTIONS_COLOR_GREEN_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
177        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + 5 * eMENU_CAPTIONS_FONT_COLOR_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_COLOR_BUTTON_HEIGHT,eTEXT_CAPTIONS_COLOR_BLUE_BUTTON,eTEXT_CAPTIONS_COLOR_BLUE_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
178        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + 6 * eMENU_CAPTIONS_FONT_COLOR_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_COLOR_BUTTON_HEIGHT,eTEXT_CAPTIONS_COLOR_YELLOW_BUTTON,eTEXT_CAPTIONS_COLOR_YELLOW_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
179        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + 7 * eMENU_CAPTIONS_FONT_COLOR_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_COLOR_BUTTON_HEIGHT,eTEXT_CAPTIONS_COLOR_MAGENTA_BUTTON,eTEXT_CAPTIONS_COLOR_MAGENTA_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
180        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + 8 * eMENU_CAPTIONS_FONT_COLOR_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_COLOR_BUTTON_HEIGHT,eTEXT_CAPTIONS_COLOR_CYAN_BUTTON,eTEXT_CAPTIONS_COLOR_CYAN_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
181};
182
183bbutton_t g_buttons_captions_edge_color[] =
184{
185        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_COLOR_BUTTON_HEIGHT,eTEXT_CAPTIONS_FONT_DEFAULT_BUTTON,eTEXT_CAPTIONS_EDGE_COLOR_DEFAULT_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
186        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + eMENU_CAPTIONS_FONT_COLOR_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_COLOR_BUTTON_HEIGHT,eTEXT_CAPTIONS_COLOR_WHITE_BUTTON,eTEXT_CAPTIONS_EDGE_COLOR_WHITE_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
187        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + 2 * eMENU_CAPTIONS_FONT_COLOR_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_COLOR_BUTTON_HEIGHT,eTEXT_CAPTIONS_COLOR_BLACK_BUTTON,eTEXT_CAPTIONS_EDGE_COLOR_BLACK_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
188        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + 3 * eMENU_CAPTIONS_FONT_COLOR_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_COLOR_BUTTON_HEIGHT,eTEXT_CAPTIONS_COLOR_RED_BUTTON,eTEXT_CAPTIONS_EDGE_COLOR_RED_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
189        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + 4 * eMENU_CAPTIONS_FONT_COLOR_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_COLOR_BUTTON_HEIGHT,eTEXT_CAPTIONS_COLOR_GREEN_BUTTON,eTEXT_CAPTIONS_EDGE_COLOR_GREEN_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
190        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + 5 * eMENU_CAPTIONS_FONT_COLOR_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_COLOR_BUTTON_HEIGHT,eTEXT_CAPTIONS_COLOR_BLUE_BUTTON,eTEXT_CAPTIONS_EDGE_COLOR_BLUE_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
191        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + 6 * eMENU_CAPTIONS_FONT_COLOR_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_COLOR_BUTTON_HEIGHT,eTEXT_CAPTIONS_COLOR_YELLOW_BUTTON,eTEXT_CAPTIONS_EDGE_COLOR_YELLOW_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
192        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + 7 * eMENU_CAPTIONS_FONT_COLOR_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_COLOR_BUTTON_HEIGHT,eTEXT_CAPTIONS_COLOR_MAGENTA_BUTTON,eTEXT_CAPTIONS_EDGE_COLOR_MAGENTA_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
193        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + 8 * eMENU_CAPTIONS_FONT_COLOR_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_COLOR_BUTTON_HEIGHT,eTEXT_CAPTIONS_COLOR_CYAN_BUTTON,eTEXT_CAPTIONS_EDGE_COLOR_CYAN_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
194};
195
196bbutton_t g_buttons_captions_color[] =
197{
198        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_COLOR_BUTTON_HEIGHT,eTEXT_CAPTIONS_FONT_DEFAULT_BUTTON,eTEXT_CAPTIONS_BACK_COLOR_DEFAULT_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
199        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + eMENU_CAPTIONS_FONT_COLOR_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_COLOR_BUTTON_HEIGHT,eTEXT_CAPTIONS_COLOR_WHITE_BUTTON,eTEXT_CAPTIONS_BACK_COLOR_WHITE_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
200        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + 2 * eMENU_CAPTIONS_FONT_COLOR_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_COLOR_BUTTON_HEIGHT,eTEXT_CAPTIONS_COLOR_BLACK_BUTTON,eTEXT_CAPTIONS_BACK_COLOR_BLACK_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
201        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + 3 * eMENU_CAPTIONS_FONT_COLOR_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_COLOR_BUTTON_HEIGHT,eTEXT_CAPTIONS_COLOR_RED_BUTTON,eTEXT_CAPTIONS_BACK_COLOR_RED_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
202        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + 4 * eMENU_CAPTIONS_FONT_COLOR_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_COLOR_BUTTON_HEIGHT,eTEXT_CAPTIONS_COLOR_GREEN_BUTTON,eTEXT_CAPTIONS_BACK_COLOR_GREEN_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
203        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + 5 * eMENU_CAPTIONS_FONT_COLOR_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_COLOR_BUTTON_HEIGHT,eTEXT_CAPTIONS_COLOR_BLUE_BUTTON,eTEXT_CAPTIONS_BACK_COLOR_BLUE_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
204        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + 6 * eMENU_CAPTIONS_FONT_COLOR_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_COLOR_BUTTON_HEIGHT,eTEXT_CAPTIONS_COLOR_YELLOW_BUTTON,eTEXT_CAPTIONS_BACK_COLOR_YELLOW_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
205        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + 7 * eMENU_CAPTIONS_FONT_COLOR_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_COLOR_BUTTON_HEIGHT,eTEXT_CAPTIONS_COLOR_MAGENTA_BUTTON,eTEXT_CAPTIONS_BACK_COLOR_MAGENTA_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
206        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_FONT_FIRST_BUTTON_Y + 8 * eMENU_CAPTIONS_FONT_COLOR_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_BUTTON_WIDTH,eMENU_CAPTIONS_FONT_COLOR_BUTTON_HEIGHT,eTEXT_CAPTIONS_COLOR_CYAN_BUTTON,eTEXT_CAPTIONS_BACK_COLOR_CYAN_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
207};
208
209bbutton_t g_buttons_captions_font_opacity[] =
210{
211        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_OPACITY_FIRST_BUTTON_Y,eMENU_CAPTIONS_FONT_OPACITY_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CAPTIONS_FONT_DEFAULT_BUTTON,eTEXT_CAPTIONS_FONT_OPACITY_DEFAULT_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
212        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_OPACITY_FIRST_BUTTON_Y + eMENU_CAPTIONS_OPACITY_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_OPACITY_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CAPTIONS_TRANSPARENT_BUTTON,eTEXT_CAPTIONS_FONT_TRANSPARENT_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
213        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_OPACITY_FIRST_BUTTON_Y + 2 * eMENU_CAPTIONS_OPACITY_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_OPACITY_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CAPTIONS_TRANSLUCENT_BUTTON,eTEXT_CAPTIONS_FONT_TRANSLUCENT_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
214        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_OPACITY_FIRST_BUTTON_Y + 3 * eMENU_CAPTIONS_OPACITY_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_OPACITY_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CAPTIONS_SOLID_BUTTON,eTEXT_CAPTIONS_FONT_SOLID_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
215        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_OPACITY_FIRST_BUTTON_Y + 4 * eMENU_CAPTIONS_OPACITY_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_OPACITY_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CAPTIONS_FLASHING_BUTTON,eTEXT_CAPTIONS_FONT_FLASHING_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
216};
217
218bbutton_t g_buttons_captions_back_opacity[] =
219{
220        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_OPACITY_FIRST_BUTTON_Y,eMENU_CAPTIONS_FONT_OPACITY_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CAPTIONS_FONT_DEFAULT_BUTTON,eTEXT_CAPTIONS_FONT_OPACITY_DEFAULT_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
221        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_OPACITY_FIRST_BUTTON_Y + eMENU_CAPTIONS_OPACITY_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_OPACITY_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CAPTIONS_TRANSPARENT_BUTTON,eTEXT_CAPTIONS_BACK_TRANSPARENT_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
222        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_OPACITY_FIRST_BUTTON_Y + 2 * eMENU_CAPTIONS_OPACITY_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_OPACITY_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CAPTIONS_TRANSLUCENT_BUTTON,eTEXT_CAPTIONS_BACK_TRANSLUCENT_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
223        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_OPACITY_FIRST_BUTTON_Y + 3 * eMENU_CAPTIONS_OPACITY_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_OPACITY_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CAPTIONS_SOLID_BUTTON,eTEXT_CAPTIONS_BACK_SOLID_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
224        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_OPACITY_FIRST_BUTTON_Y + 4 * eMENU_CAPTIONS_OPACITY_BUTTON_INC_Y,eMENU_CAPTIONS_FONT_OPACITY_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CAPTIONS_FLASHING_BUTTON,eTEXT_CAPTIONS_BACK_FLASHING_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
225};
226
227bbutton_t g_buttons_captions_edge_type[] =
228{
229        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_EDGE_TYPE_FIRST_BUTTON_Y,eMENU_CAPTIONS_EDGE_TYPE_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CAPTIONS_FONT_DEFAULT_BUTTON,eTEXT_CAPTIONS_EDGE_TYPE_DEFAULT_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
230        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_EDGE_TYPE_FIRST_BUTTON_Y + eMENU_CAPTIONS_EDGE_TYPE_BUTTON_INC_Y,eMENU_CAPTIONS_EDGE_TYPE_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CAPTIONS_RAISED_BUTTON,eTEXT_CAPTIONS_RAISED_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
231        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_EDGE_TYPE_FIRST_BUTTON_Y + 2 * eMENU_CAPTIONS_EDGE_TYPE_BUTTON_INC_Y,eMENU_CAPTIONS_EDGE_TYPE_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CAPTIONS_DEPRESSED_BUTTON,eTEXT_CAPTIONS_DEPRESSED_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
232        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_EDGE_TYPE_FIRST_BUTTON_Y + 3 * eMENU_CAPTIONS_EDGE_TYPE_BUTTON_INC_Y,eMENU_CAPTIONS_EDGE_TYPE_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CAPTIONS_UNIFORM_BUTTON,eTEXT_CAPTIONS_UNIFORM_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
233        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_EDGE_TYPE_FIRST_BUTTON_Y + 4 * eMENU_CAPTIONS_EDGE_TYPE_BUTTON_INC_Y,eMENU_CAPTIONS_EDGE_TYPE_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CAPTIONS_SHADOW_LEFT_BUTTON,eTEXT_CAPTIONS_SHADOW_LEFT_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
234        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_CAPTIONS_FIRST_BUTTON_X,eMENU_CAPTIONS_EDGE_TYPE_FIRST_BUTTON_Y + 5 * eMENU_CAPTIONS_EDGE_TYPE_BUTTON_INC_Y,eMENU_CAPTIONS_EDGE_TYPE_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CAPTIONS_SHADOW_RIGHT_BUTTON,eTEXT_CAPTIONS_SHADOW_RIGHT_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
235};
236
237bbutton_t g_buttons_captions_reset[] =
238{
239        {eBUTTON_MENU,eMENU_RESET_FIRST_BUTTON_X,eMENU_CAPTIONS_RESET_FIRST_BUTTON_Y,eMENU_RESET_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CANCEL_BUTTON,eTEXT_CANCEL_INFO ,eSCREEN_SETUP,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
240        {eBUTTON_MENU,eMENU_RESET_FIRST_BUTTON_X,eMENU_CAPTIONS_RESET_FIRST_BUTTON_Y + eMENU_RESET_BUTTON_INC_Y,eMENU_RESET_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_RESET_CONFIRM_BUTTON,eTEXT_RESET_CAPTIONS_CONFIRM_INFO,eSCREEN_NULL,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
241};
242
243
244bbutton_t g_buttons_setup[] =
245{
246        {eBUTTON_MENU,eMENU_SETUP_FIRST_BUTTON_X,eMENU_SETUP_FIRST_BUTTON_Y,eMENU_SETUP_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CH_SCAN_BUTTON,eTEXT_CH_SCAN_INFO ,eSCREEN_NULL,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
247        {eBUTTON_MENU,eMENU_SETUP_FIRST_BUTTON_X,eMENU_SETUP_FIRST_BUTTON_Y + eMENU_SETUP_BUTTON_INC_Y,eMENU_SETUP_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_LANGUAGE_BUTTON,eTEXT_LANGUAGE_INFO,eSCREEN_LANGUAGE,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
248        {eBUTTON_MENU,eMENU_SETUP_FIRST_BUTTON_X,eMENU_SETUP_FIRST_BUTTON_Y + 2 * eMENU_SETUP_BUTTON_INC_Y,eMENU_SETUP_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_AUTO_POWER_BUTTON,eTEXT_AUTO_POWER_INFO,eSCREEN_AUTO_POWER,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
249        {eBUTTON_MENU,eMENU_SETUP_FIRST_BUTTON_X,eMENU_SETUP_FIRST_BUTTON_Y + 3 * eMENU_SETUP_BUTTON_INC_Y,eMENU_SETUP_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_ANTENNA_BUTTON,eTEXT_ANTENNA_INFO,eSCREEN_ANTENNA,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
250        {eBUTTON_MENU,eMENU_SETUP_FIRST_BUTTON_X,eMENU_SETUP_FIRST_BUTTON_Y + 4 * eMENU_SETUP_BUTTON_INC_Y,eMENU_SETUP_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_SETTINGS_TIMEZONE_BUTTON,eTEXT_SETTINGS_TIMEZONE_INFO,eSCREEN_TIMEZONE,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
251#ifdef CONFIG_EIA_708
252        {eBUTTON_MENU,eMENU_SETUP_FIRST_BUTTON_X,eMENU_SETUP_FIRST_BUTTON_Y + 5 * eMENU_SETUP_BUTTON_INC_Y,eMENU_SETUP_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_RESET_BUTTON,eTEXT_RESET_INFO,eSCREEN_PIN_VERIFY_RESET,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
253#endif
254};
255
256bbutton_t g_buttons_ch_scan[] =
257{
258        {eBUTTON_MENU,eMENU_CH_SCAN_FIRST_BUTTON_X,eMENU_CH_SCAN_FIRST_BUTTON_Y,eMENU_CH_SCAN_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_BEGIN_BUTTON,eTEXT_BEGIN_SCAN_INFO ,eSCREEN_CH_SCAN_PROGRESS,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
259        {eBUTTON_CHECK,eMENU_CH_SCAN_FIRST_BUTTON_X,eMENU_CH_SCAN_FIRST_BUTTON_Y + eMENU_SMART_CH_SCAN_BUTTON_INC_Y,eMENU_CH_SCAN_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_SCAN_ADD_BUTTON,eTEXT_SCAN_ADD_INFO ,eSCREEN_CH_SCAN_PROGRESS,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
260};
261
262bbutton_t g_buttons_smart_ch_scan[] =
263{
264        {eBUTTON_MENU,eMENU_SMART_CH_SCAN_FIRST_BUTTON_X,eMENU_SMART_CH_SCAN_FIRST_BUTTON_Y,eMENU_SMART_CH_SCAN_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_QUICK_SCAN_BUTTON,eTEXT_QUICK_SCAN_INFO ,eSCREEN_CH_SCAN_PROGRESS,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
265        {eBUTTON_MENU,eMENU_SMART_CH_SCAN_FIRST_BUTTON_X,eMENU_SMART_CH_SCAN_FIRST_BUTTON_Y + eMENU_SMART_CH_SCAN_BUTTON_INC_Y,eMENU_SMART_CH_SCAN_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_FULL_SCAN_BUTTON,eTEXT_FULL_SCAN_INFO,eSCREEN_CH_SCAN_PROGRESS,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
266        {eBUTTON_CHECK,eMENU_SMART_CH_SCAN_FIRST_BUTTON_X,eMENU_SMART_CH_SCAN_FIRST_BUTTON_Y + 2 * eMENU_SMART_CH_SCAN_BUTTON_INC_Y,eMENU_SMART_CH_SCAN_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_SCAN_ADD_BUTTON,eTEXT_SCAN_ADD_INFO ,eSCREEN_CH_SCAN_PROGRESS,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
267};
268
269bbutton_t g_buttons_reset[] =
270{
271        {eBUTTON_MENU,eMENU_RESET_FIRST_BUTTON_X,eMENU_RESET_FIRST_BUTTON_Y,eMENU_RESET_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CANCEL_BUTTON,eTEXT_CANCEL_INFO ,eSCREEN_SETUP,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
272        {eBUTTON_MENU,eMENU_RESET_FIRST_BUTTON_X,eMENU_RESET_FIRST_BUTTON_Y + eMENU_RESET_BUTTON_INC_Y,eMENU_RESET_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_RESET_CONFIRM_BUTTON,eTEXT_RESET_CONFIRM_INFO,eSCREEN_NULL,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
273};
274
275bbutton_t g_buttons_wiz_welcome[] =
276{
277        {eBUTTON_MENU,eMENU_WIZ_WELCOME_FIRST_BUTTON_X,eMENU_WIZ_WELCOME_FIRST_BUTTON_Y,eMENU_WIZ_WELCOME_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_BEGIN_BUTTON,eTEXT_BEGIN_INFO ,eSCREEN_WIZ_LANGUAGE,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
278};
279
280bbutton_t g_buttons_wiz_language[] =
281{
282        {eBUTTON_MENU,eMENU_LANGUAGE_FIRST_BUTTON_X,eMENU_LANGUAGE_FIRST_BUTTON_Y,eMENU_LANGUAGE_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_ENGLISH_BUTTON,eTEXT_ENGLISH_INFO ,eSCREEN_NULL,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
283        {eBUTTON_MENU,eMENU_LANGUAGE_FIRST_BUTTON_X,eMENU_LANGUAGE_FIRST_BUTTON_Y + eMENU_LANGUAGE_BUTTON_INC_Y,eMENU_LANGUAGE_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_SPANISH_BUTTON,eTEXT_SPANISH_INFO,eSCREEN_NULL,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
284        {eBUTTON_MENU,eMENU_LANGUAGE_FIRST_BUTTON_X,eMENU_LANGUAGE_FIRST_BUTTON_Y + 2 * eMENU_LANGUAGE_BUTTON_INC_Y,eMENU_LANGUAGE_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_FRENCH_BUTTON,eTEXT_FRENCH_INFO,eSCREEN_NULL,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
285};
286
287bbutton_t g_buttons_wiz_ch_scan[] =
288{
289        {eBUTTON_MENU,eMENU_WIZ_CH_SCAN_FIRST_BUTTON_X,eMENU_WIZ_CH_SCAN_FIRST_BUTTON_Y,eMENU_WIZ_CH_SCAN_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_BEGIN_BUTTON,eTEXT_BEGIN_SCAN_INFO ,eSCREEN_CH_SCAN_PROGRESS,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
290        {eBUTTON_MENU,eMENU_WIZ_CH_SCAN_FIRST_BUTTON_X,eMENU_WIZ_CH_SCAN_FIRST_BUTTON_Y + eMENU_WIZ_CH_SCAN_BUTTON_INC_Y,eMENU_WIZ_CH_SCAN_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_DONE_BUTTON,eTEXT_DONE_INFO,eSCREEN_GUIDE,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
291};
292
293bbutton_t g_buttons_wiz_smart_ch_scan[] =
294{
295        {eBUTTON_MENU,eMENU_WIZ_SMART_CH_SCAN_FIRST_BUTTON_X,eMENU_WIZ_SMART_CH_SCAN_FIRST_BUTTON_Y,eMENU_WIZ_SMART_CH_SCAN_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_QUICK_SCAN_BUTTON,eTEXT_QUICK_SCAN_INFO ,eSCREEN_CH_SCAN_PROGRESS,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
296        {eBUTTON_MENU,eMENU_WIZ_SMART_CH_SCAN_FIRST_BUTTON_X,eMENU_WIZ_SMART_CH_SCAN_FIRST_BUTTON_Y + eMENU_WIZ_SMART_CH_SCAN_BUTTON_INC_Y,eMENU_WIZ_SMART_CH_SCAN_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_FULL_SCAN_BUTTON,eTEXT_FULL_SCAN_INFO,eSCREEN_CH_SCAN_PROGRESS,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
297        {eBUTTON_MENU,eMENU_WIZ_SMART_CH_SCAN_FIRST_BUTTON_X,eMENU_WIZ_SMART_CH_SCAN_FIRST_BUTTON_Y + 2 * eMENU_WIZ_SMART_CH_SCAN_BUTTON_INC_Y,eMENU_WIZ_SMART_CH_SCAN_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_DONE_BUTTON,eTEXT_DONE_INFO,eSCREEN_GUIDE,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
298};
299
300bbutton_t g_buttons_auto_power[] =
301{
302        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_AUTO_POWER_FIRST_BUTTON_X,eMENU_AUTO_POWER_FIRST_BUTTON_Y,eMENU_AUTO_POWER_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_AUTO_POWER_ON_BUTTON_4H,eTEXT_AUTO_POWER_ON_INFO_4H ,eSCREEN_SETUP,eSCREEN_MAIN, 1, eCOLOR_MED_BLUE},
303        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_AUTO_POWER_FIRST_BUTTON_X,eMENU_AUTO_POWER_FIRST_BUTTON_Y + eMENU_AUTO_POWER_BUTTON_INC_Y,eMENU_AUTO_POWER_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_AUTO_POWER_ON_BUTTON_8H,eTEXT_AUTO_POWER_ON_INFO_8H,eSCREEN_SETUP,eSCREEN_MAIN, 1, eCOLOR_MED_BLUE},
304        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_AUTO_POWER_FIRST_BUTTON_X,eMENU_AUTO_POWER_FIRST_BUTTON_Y + 2 * eMENU_AUTO_POWER_BUTTON_INC_Y,eMENU_AUTO_POWER_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_AUTO_POWER_ON_BUTTON_12H,eTEXT_AUTO_POWER_ON_INFO_12H,eSCREEN_SETUP,eSCREEN_MAIN, 1, eCOLOR_MED_BLUE},
305        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_AUTO_POWER_FIRST_BUTTON_X,eMENU_AUTO_POWER_FIRST_BUTTON_Y + 3 * eMENU_AUTO_POWER_BUTTON_INC_Y,eMENU_AUTO_POWER_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_OFF_BUTTON,eTEXT_AUTO_POWER_OFF_INFO,eSCREEN_SETUP,eSCREEN_MAIN, 1, eCOLOR_MED_BLUE},
306};
307
308bbutton_t g_buttons_wiz_mismatched_pins[] =
309{
310        {eBUTTON_MENU,eMENU_WRONG_PIN_FIRST_BUTTON_X,eMENU_WRONG_PIN_FIRST_BUTTON_Y,eMENU_RETRY_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_RETRY_BUTTON,eTEXT_RETRY_INFO,eSCREEN_WIZ_PIN_NEW,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
311};
312
313bbutton_t g_buttons_wiz_done[] =
314{
315        {eBUTTON_MENU,eMENU_WIZ_DONE_FIRST_BUTTON_X,eMENU_WIZ_DONE_FIRST_BUTTON_Y,eMENU_WIZ_DONE_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_FINISH_BUTTON,eTEXT_FINISH_INFO ,eSCREEN_NULL,eSCREEN_NULL, 1, eCOLOR_MED_BLUE},
316};
317
318bbutton_t g_buttons_ratings[] =
319{
320        {eBUTTON_MENU,eMENU_RATINGS_FIRST_BUTTON_X,eMENU_RATINGS_FIRST_BUTTON_Y,eMENU_RATINGS_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_LOCK_UNLOCK_BUTTON,eTEXT_LOCK_UNLOCK_INFO ,eSCREEN_RATINGS_LOCK,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
321        {eBUTTON_MENU,eMENU_RATINGS_FIRST_BUTTON_X,eMENU_RATINGS_FIRST_BUTTON_Y + eMENU_RATINGS_BUTTON_INC_Y,eMENU_RATINGS_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_LIMITS_BUTTON,eTEXT_LIMITS_INFO,eSCREEN_RATINGS_LIMITS,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
322        {eBUTTON_MENU,eMENU_RATINGS_FIRST_BUTTON_X,eMENU_RATINGS_FIRST_BUTTON_Y + 2 * eMENU_RATINGS_BUTTON_INC_Y,eMENU_RATINGS_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CHANGE_PIN_BUTTON,eTEXT_CHANGE_PIN_INFO,eSCREEN_PIN_NEW,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
323};
324
325bbutton_t g_buttons_ratings_lock[] =
326{
327        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_RATINGS_LOCK_FIRST_BUTTON_X,eMENU_RATINGS_LOCK_FIRST_BUTTON_Y + 0 * eMENU_RATINGS_LOCK_BUTTON_INC_Y,eMENU_RATINGS_LOCK_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_OFF_BUTTON,eTEXT_OFF_INFO,eSCREEN_RATINGS,eSCREEN_MAIN, 1, eCOLOR_MED_BLUE},
328        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_RATINGS_LOCK_FIRST_BUTTON_X,eMENU_RATINGS_LOCK_FIRST_BUTTON_Y + 1 * eMENU_RATINGS_LOCK_BUTTON_INC_Y,eMENU_RATINGS_LOCK_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_ON_BUTTON,eTEXT_ON_INFO,eSCREEN_RATINGS,eSCREEN_MAIN, 1, eCOLOR_MED_BLUE},
329        {eBUTTON_RADIO|eBUTTON_MENU,eMENU_RATINGS_LOCK_FIRST_BUTTON_X,eMENU_RATINGS_LOCK_FIRST_BUTTON_Y + 2 * eMENU_RATINGS_LOCK_BUTTON_INC_Y,eMENU_RATINGS_LOCK_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_ON_RRT_BUTTON,eTEXT_ON_RRT_INFO,eSCREEN_RATINGS,eSCREEN_MAIN, 1, eCOLOR_MED_BLUE},
330};
331
332bbutton_t g_buttons_ratings_limits[] =
333{
334        {eBUTTON_MENU,eMENU_RATINGS_LIMITS_FIRST_BUTTON_X,eMENU_RATINGS_LIMITS_FIRST_BUTTON_Y,eMENU_RATINGS_LIMITS_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_TV_SHOWS_BUTTON,eTEXT_TV_SHOWS_INFO ,eSCREEN_RATINGS_TV,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
335        {eBUTTON_MENU,eMENU_RATINGS_LIMITS_FIRST_BUTTON_X,eMENU_RATINGS_LIMITS_FIRST_BUTTON_Y + eMENU_RATINGS_LIMITS_BUTTON_INC_Y,eMENU_RATINGS_LIMITS_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_MOVIES_BUTTON,eTEXT_MOVIES_INFO,eSCREEN_RATINGS_MOVIES,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
336        {eBUTTON_MENU,eMENU_RATINGS_LIMITS_FIRST_BUTTON_X,eMENU_RATINGS_LIMITS_FIRST_BUTTON_Y + 2 * eMENU_RATINGS_LIMITS_BUTTON_INC_Y,eMENU_RATINGS_LIMITS_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_RRT_DIM_BUTTON,eTEXT_RRT_DIM_INFO,eSCREEN_RATINGS_RRT_DIM,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
337};
338
339bbutton_t g_buttons_ratings_tv[] =
340{
341        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_TV_FIRST_BUTTON_X,      eMENU_RATINGS_TV_FIRST_BUTTON_Y + 0 * eMENU_RATINGS_TV_BUTTON_INC_Y,eMENU_RATINGS_TV_GRID_BUTTON_WIDTH,     eBUTTON_HEIGHT_RATINGS,eTEXT_TV_Y_BUTTON,eTEXT_MAX,    eSCREEN_RATINGS_LIMITS,eSCREEN_MAX, 0, eCOLOR_MED_BLUE},
342        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_TV_FIRST_BUTTON_X      ,eMENU_RATINGS_TV_FIRST_BUTTON_Y + 1 * eMENU_RATINGS_TV_BUTTON_INC_Y,eMENU_RATINGS_TV_GRID_BUTTON_WIDTH,     eBUTTON_HEIGHT_RATINGS,eTEXT_TV_Y7_BUTTON,eTEXT_MAX,    eSCREEN_RATINGS_LIMITS,eSCREEN_MAX, 0, eCOLOR_MED_BLUE},
343        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_TV_DLSV_FIRST_BUTTON_X + 5 * eMENU_RATINGS_TV_DLSV_GRID_BUTTON_WIDTH, eMENU_RATINGS_TV_FIRST_BUTTON_Y + 1 * eMENU_RATINGS_TV_BUTTON_INC_Y,eMENU_RATINGS_TV_DLSV_GRID_BUTTON_WIDTH,eBUTTON_HEIGHT_RATINGS,eTEXT_FV_BUTTON,    eTEXT_MAX,    eSCREEN_RATINGS_LIMITS,eSCREEN_MAX, 0, eCOLOR_MED_BLUE},
344        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_TV_FIRST_BUTTON_X      ,eMENU_RATINGS_TV_FIRST_BUTTON_Y + 2 * eMENU_RATINGS_TV_BUTTON_INC_Y,eMENU_RATINGS_TV_GRID_BUTTON_WIDTH,     eBUTTON_HEIGHT_RATINGS,eTEXT_TV_G_BUTTON, eTEXT_MAX,    eSCREEN_RATINGS_LIMITS,eSCREEN_MAX, 0, eCOLOR_MED_BLUE},
345        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_TV_FIRST_BUTTON_X      ,eMENU_RATINGS_TV_FIRST_BUTTON_Y + 3 * eMENU_RATINGS_TV_BUTTON_INC_Y,eMENU_RATINGS_TV_GRID_BUTTON_WIDTH,     eBUTTON_HEIGHT_RATINGS,eTEXT_TV_PG_BUTTON,eTEXT_MAX,    eSCREEN_RATINGS_LIMITS,eSCREEN_MAX, 0, eCOLOR_MED_BLUE},
346        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_TV_DLSV_FIRST_BUTTON_X + 1 * eMENU_RATINGS_TV_DLSV_GRID_BUTTON_WIDTH, eMENU_RATINGS_TV_FIRST_BUTTON_Y + 3 * eMENU_RATINGS_TV_BUTTON_INC_Y,eMENU_RATINGS_TV_DLSV_GRID_BUTTON_WIDTH,eBUTTON_HEIGHT_RATINGS,eTEXT_D_BUTTON,    eTEXT_MAX,    eSCREEN_RATINGS_LIMITS,eSCREEN_MAX, 0, eCOLOR_MED_BLUE},
347        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_TV_DLSV_FIRST_BUTTON_X + 2 * eMENU_RATINGS_TV_DLSV_GRID_BUTTON_WIDTH, eMENU_RATINGS_TV_FIRST_BUTTON_Y + 3 * eMENU_RATINGS_TV_BUTTON_INC_Y,eMENU_RATINGS_TV_DLSV_GRID_BUTTON_WIDTH,eBUTTON_HEIGHT_RATINGS,eTEXT_L_BUTTON,    eTEXT_MAX,    eSCREEN_RATINGS_LIMITS,eSCREEN_MAX, 0, eCOLOR_MED_BLUE},
348        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_TV_DLSV_FIRST_BUTTON_X + 3 * eMENU_RATINGS_TV_DLSV_GRID_BUTTON_WIDTH, eMENU_RATINGS_TV_FIRST_BUTTON_Y + 3 * eMENU_RATINGS_TV_BUTTON_INC_Y,eMENU_RATINGS_TV_DLSV_GRID_BUTTON_WIDTH,eBUTTON_HEIGHT_RATINGS,eTEXT_S_BUTTON,    eTEXT_MAX,    eSCREEN_RATINGS_LIMITS,eSCREEN_MAX, 0, eCOLOR_MED_BLUE},
349        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_TV_DLSV_FIRST_BUTTON_X + 4 * eMENU_RATINGS_TV_DLSV_GRID_BUTTON_WIDTH, eMENU_RATINGS_TV_FIRST_BUTTON_Y + 3 * eMENU_RATINGS_TV_BUTTON_INC_Y,eMENU_RATINGS_TV_DLSV_GRID_BUTTON_WIDTH,eBUTTON_HEIGHT_RATINGS,eTEXT_V_BUTTON,    eTEXT_MAX,    eSCREEN_RATINGS_LIMITS,eSCREEN_MAX, 0, eCOLOR_MED_BLUE},
350        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_TV_FIRST_BUTTON_X      ,eMENU_RATINGS_TV_FIRST_BUTTON_Y + 4 * eMENU_RATINGS_TV_BUTTON_INC_Y,eMENU_RATINGS_TV_GRID_BUTTON_WIDTH,     eBUTTON_HEIGHT_RATINGS,eTEXT_TV_14_BUTTON,eTEXT_MAX,    eSCREEN_RATINGS_LIMITS,eSCREEN_MAX, 0, eCOLOR_MED_BLUE},
351        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_TV_DLSV_FIRST_BUTTON_X + 1 * eMENU_RATINGS_TV_DLSV_GRID_BUTTON_WIDTH, eMENU_RATINGS_TV_FIRST_BUTTON_Y + 4 * eMENU_RATINGS_TV_BUTTON_INC_Y,eMENU_RATINGS_TV_DLSV_GRID_BUTTON_WIDTH,eBUTTON_HEIGHT_RATINGS,eTEXT_D_BUTTON,    eTEXT_MAX,    eSCREEN_RATINGS_LIMITS,eSCREEN_MAX, 0, eCOLOR_MED_BLUE},
352        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_TV_DLSV_FIRST_BUTTON_X + 2 * eMENU_RATINGS_TV_DLSV_GRID_BUTTON_WIDTH, eMENU_RATINGS_TV_FIRST_BUTTON_Y + 4 * eMENU_RATINGS_TV_BUTTON_INC_Y,eMENU_RATINGS_TV_DLSV_GRID_BUTTON_WIDTH,eBUTTON_HEIGHT_RATINGS,eTEXT_L_BUTTON,    eTEXT_MAX,    eSCREEN_RATINGS_LIMITS,eSCREEN_MAX, 0, eCOLOR_MED_BLUE},
353        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_TV_DLSV_FIRST_BUTTON_X + 3 * eMENU_RATINGS_TV_DLSV_GRID_BUTTON_WIDTH, eMENU_RATINGS_TV_FIRST_BUTTON_Y + 4 * eMENU_RATINGS_TV_BUTTON_INC_Y,eMENU_RATINGS_TV_DLSV_GRID_BUTTON_WIDTH,eBUTTON_HEIGHT_RATINGS,eTEXT_S_BUTTON,    eTEXT_MAX,    eSCREEN_RATINGS_LIMITS,eSCREEN_MAX, 0, eCOLOR_MED_BLUE},
354        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_TV_DLSV_FIRST_BUTTON_X + 4 * eMENU_RATINGS_TV_DLSV_GRID_BUTTON_WIDTH, eMENU_RATINGS_TV_FIRST_BUTTON_Y + 4 * eMENU_RATINGS_TV_BUTTON_INC_Y,eMENU_RATINGS_TV_DLSV_GRID_BUTTON_WIDTH,eBUTTON_HEIGHT_RATINGS,eTEXT_V_BUTTON,    eTEXT_MAX,    eSCREEN_RATINGS_LIMITS,eSCREEN_MAX, 0, eCOLOR_MED_BLUE},
355        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_TV_FIRST_BUTTON_X      ,eMENU_RATINGS_TV_FIRST_BUTTON_Y + 5 * eMENU_RATINGS_TV_BUTTON_INC_Y,eMENU_RATINGS_TV_GRID_BUTTON_WIDTH,     eBUTTON_HEIGHT_RATINGS,eTEXT_TV_MA_BUTTON,eTEXT_MAX,    eSCREEN_RATINGS_LIMITS,eSCREEN_MAX, 0, eCOLOR_MED_BLUE},
356        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_TV_DLSV_FIRST_BUTTON_X + 2 * eMENU_RATINGS_TV_DLSV_GRID_BUTTON_WIDTH, eMENU_RATINGS_TV_FIRST_BUTTON_Y + 5 * eMENU_RATINGS_TV_BUTTON_INC_Y,eMENU_RATINGS_TV_DLSV_GRID_BUTTON_WIDTH,eBUTTON_HEIGHT_RATINGS,eTEXT_L_BUTTON,    eTEXT_MAX,    eSCREEN_RATINGS_LIMITS,eSCREEN_MAX, 0, eCOLOR_MED_BLUE},
357        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_TV_DLSV_FIRST_BUTTON_X + 3 * eMENU_RATINGS_TV_DLSV_GRID_BUTTON_WIDTH, eMENU_RATINGS_TV_FIRST_BUTTON_Y + 5 * eMENU_RATINGS_TV_BUTTON_INC_Y,eMENU_RATINGS_TV_DLSV_GRID_BUTTON_WIDTH,eBUTTON_HEIGHT_RATINGS,eTEXT_S_BUTTON,    eTEXT_MAX,    eSCREEN_RATINGS_LIMITS,eSCREEN_MAX, 0, eCOLOR_MED_BLUE},
358        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_TV_DLSV_FIRST_BUTTON_X + 4 * eMENU_RATINGS_TV_DLSV_GRID_BUTTON_WIDTH, eMENU_RATINGS_TV_FIRST_BUTTON_Y + 5 * eMENU_RATINGS_TV_BUTTON_INC_Y,eMENU_RATINGS_TV_DLSV_GRID_BUTTON_WIDTH,eBUTTON_HEIGHT_RATINGS,eTEXT_V_BUTTON,    eTEXT_MAX,    eSCREEN_RATINGS_LIMITS,eSCREEN_MAX, 0, eCOLOR_MED_BLUE},
359};
360
361bbutton_t g_buttons_ratings_movies[] =
362{
363        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_MOVIES_FIRST_BUTTON_X,eMENU_RATINGS_MOVIES_FIRST_BUTTON_Y,eMENU_RATINGS_MOVIES_BUTTON_WIDTH,eBUTTON_HEIGHT_RATINGS,eTEXT_G_BUTTON,eTEXT_G_INFO,eSCREEN_RATINGS_LIMITS,eSCREEN_RATINGS, 1, eCOLOR_MED_BLUE},
364        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_MOVIES_FIRST_BUTTON_X,eMENU_RATINGS_MOVIES_FIRST_BUTTON_Y + eMENU_RATINGS_MOVIES_BUTTON_INC_Y,eMENU_RATINGS_MOVIES_BUTTON_WIDTH,eBUTTON_HEIGHT_RATINGS,eTEXT_PG_BUTTON,eTEXT_PG_INFO,eSCREEN_RATINGS_LIMITS,eSCREEN_RATINGS, 1, eCOLOR_MED_BLUE},
365        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_MOVIES_FIRST_BUTTON_X,eMENU_RATINGS_MOVIES_FIRST_BUTTON_Y + 2 * eMENU_RATINGS_MOVIES_BUTTON_INC_Y,eMENU_RATINGS_MOVIES_BUTTON_WIDTH,eBUTTON_HEIGHT_RATINGS,eTEXT_PG_13_BUTTON,eTEXT_PG_13_INFO,eSCREEN_RATINGS_LIMITS,eSCREEN_RATINGS, 1, eCOLOR_MED_BLUE},
366        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_MOVIES_FIRST_BUTTON_X,eMENU_RATINGS_MOVIES_FIRST_BUTTON_Y + 3 * eMENU_RATINGS_MOVIES_BUTTON_INC_Y,eMENU_RATINGS_MOVIES_BUTTON_WIDTH,eBUTTON_HEIGHT_RATINGS,eTEXT_R_BUTTON,eTEXT_R_INFO,eSCREEN_RATINGS_LIMITS,eSCREEN_RATINGS, 1, eCOLOR_MED_BLUE},
367        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_MOVIES_FIRST_BUTTON_X,eMENU_RATINGS_MOVIES_FIRST_BUTTON_Y + 4 * eMENU_RATINGS_MOVIES_BUTTON_INC_Y,eMENU_RATINGS_MOVIES_BUTTON_WIDTH,eBUTTON_HEIGHT_RATINGS,eTEXT_NC_17_BUTTON,eTEXT_NC_17_INFO,eSCREEN_RATINGS_LIMITS,eSCREEN_RATINGS, 1, eCOLOR_MED_BLUE},
368        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_MOVIES_FIRST_BUTTON_X,eMENU_RATINGS_MOVIES_FIRST_BUTTON_Y + 5 * eMENU_RATINGS_MOVIES_BUTTON_INC_Y,eMENU_RATINGS_MOVIES_BUTTON_WIDTH,eBUTTON_HEIGHT_RATINGS,eTEXT_X_BUTTON,eTEXT_X_INFO,eSCREEN_RATINGS_LIMITS,eSCREEN_RATINGS, 1, eCOLOR_MED_BLUE},
369        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_MOVIES_FIRST_BUTTON_X,eMENU_RATINGS_MOVIES_FIRST_BUTTON_Y + 6 * eMENU_RATINGS_MOVIES_BUTTON_INC_Y,eMENU_RATINGS_MOVIES_BUTTON_WIDTH,eBUTTON_HEIGHT_RATINGS,eTEXT_NOT_RATED_BUTTON,eTEXT_NOT_RATED_INFO,eSCREEN_RATINGS_LIMITS,eSCREEN_RATINGS, 1, eCOLOR_MED_BLUE},
370};
371
372
373/* this button array changes dynamically based on received RRT dimension data */
374bbutton_t g_buttons_ratings_rrt_dim[] =
375{
376        {eBUTTON_MENU,eMENU_RATINGS_RRT_DIM_FIRST_BUTTON_X,eMENU_RATINGS_RRT_DIM_FIRST_BUTTON_Y,eMENU_RATINGS_RRT_DIM_BUTTON_WIDTH,eMENU_RATINGS_RRT_DIM_BUTTON_HEIGHT,eTEXT_MAX,eTEXT_MAX ,eSCREEN_RATINGS_RRT_VAL,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
377        {eBUTTON_MENU,eMENU_RATINGS_RRT_DIM_FIRST_BUTTON_X,eMENU_RATINGS_RRT_DIM_FIRST_BUTTON_Y + 1 * eMENU_RATINGS_RRT_DIM_BUTTON_INC_Y,eMENU_RATINGS_RRT_DIM_BUTTON_WIDTH,eMENU_RATINGS_RRT_DIM_BUTTON_HEIGHT,eTEXT_MAX,eTEXT_MAX ,eSCREEN_RATINGS_RRT_VAL,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
378        {eBUTTON_MENU,eMENU_RATINGS_RRT_DIM_FIRST_BUTTON_X,eMENU_RATINGS_RRT_DIM_FIRST_BUTTON_Y + 2 * eMENU_RATINGS_RRT_DIM_BUTTON_INC_Y,eMENU_RATINGS_RRT_DIM_BUTTON_WIDTH,eMENU_RATINGS_RRT_DIM_BUTTON_HEIGHT,eTEXT_MAX,eTEXT_MAX ,eSCREEN_RATINGS_RRT_VAL,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
379        {eBUTTON_MENU,eMENU_RATINGS_RRT_DIM_FIRST_BUTTON_X,eMENU_RATINGS_RRT_DIM_FIRST_BUTTON_Y + 3 * eMENU_RATINGS_RRT_DIM_BUTTON_INC_Y,eMENU_RATINGS_RRT_DIM_BUTTON_WIDTH,eMENU_RATINGS_RRT_DIM_BUTTON_HEIGHT,eTEXT_MAX,eTEXT_MAX ,eSCREEN_RATINGS_RRT_VAL,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
380        {eBUTTON_MENU,eMENU_RATINGS_RRT_DIM_FIRST_BUTTON_X,eMENU_RATINGS_RRT_DIM_FIRST_BUTTON_Y + 4 * eMENU_RATINGS_RRT_DIM_BUTTON_INC_Y,eMENU_RATINGS_RRT_DIM_BUTTON_WIDTH,eMENU_RATINGS_RRT_DIM_BUTTON_HEIGHT,eTEXT_MAX,eTEXT_MAX ,eSCREEN_RATINGS_RRT_VAL,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
381        {eBUTTON_MENU,eMENU_RATINGS_RRT_DIM_FIRST_BUTTON_X,eMENU_RATINGS_RRT_DIM_FIRST_BUTTON_Y + 5 * eMENU_RATINGS_RRT_DIM_BUTTON_INC_Y,eMENU_RATINGS_RRT_DIM_BUTTON_WIDTH,eMENU_RATINGS_RRT_DIM_BUTTON_HEIGHT,eTEXT_MAX,eTEXT_MAX ,eSCREEN_RATINGS_RRT_VAL,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
382        {eBUTTON_MENU,eMENU_RATINGS_RRT_DIM_FIRST_BUTTON_X,eMENU_RATINGS_RRT_DIM_FIRST_BUTTON_Y + 6 * eMENU_RATINGS_RRT_DIM_BUTTON_INC_Y,eMENU_RATINGS_RRT_DIM_BUTTON_WIDTH,eMENU_RATINGS_RRT_DIM_BUTTON_HEIGHT,eTEXT_MAX,eTEXT_MAX ,eSCREEN_RATINGS_RRT_VAL,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
383        {eBUTTON_MENU,eMENU_RATINGS_RRT_DIM_FIRST_BUTTON_X,eMENU_RATINGS_RRT_DIM_FIRST_BUTTON_Y + 7 * eMENU_RATINGS_RRT_DIM_BUTTON_INC_Y,eMENU_RATINGS_RRT_DIM_BUTTON_WIDTH,eMENU_RATINGS_RRT_DIM_BUTTON_HEIGHT,eTEXT_MAX,eTEXT_MAX ,eSCREEN_RATINGS_RRT_VAL,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
384        {eBUTTON_MENU,eMENU_RATINGS_RRT_DIM_FIRST_BUTTON_X,eMENU_RATINGS_RRT_DIM_FIRST_BUTTON_Y + 8 * eMENU_RATINGS_RRT_DIM_BUTTON_INC_Y,eMENU_RATINGS_RRT_DIM_BUTTON_WIDTH,eMENU_RATINGS_RRT_DIM_BUTTON_HEIGHT,eTEXT_MAX,eTEXT_MAX ,eSCREEN_RATINGS_RRT_VAL,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
385};
386
387/* this button array changes dynamically based on received RRT value data */
388bbutton_t g_buttons_ratings_rrt_val[] = 
389{
390        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_RRT_VAL_FIRST_BUTTON_X,eMENU_RATINGS_RRT_VAL_FIRST_BUTTON_Y,eMENU_RATINGS_RRT_VAL_BUTTON_WIDTH,eMENU_RATINGS_RRT_VAL_BUTTON_HEIGHT,eTEXT_MAX,eTEXT_MAX ,eSCREEN_RATINGS_LIMITS,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
391        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_RRT_VAL_FIRST_BUTTON_X,eMENU_RATINGS_RRT_VAL_FIRST_BUTTON_Y + 1 * eMENU_RATINGS_RRT_VAL_BUTTON_INC_Y,eMENU_RATINGS_RRT_VAL_BUTTON_WIDTH,eMENU_RATINGS_RRT_VAL_BUTTON_HEIGHT,eTEXT_MAX,eTEXT_MAX ,eSCREEN_RATINGS_LIMITS,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
392        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_RRT_VAL_FIRST_BUTTON_X,eMENU_RATINGS_RRT_VAL_FIRST_BUTTON_Y + 2 * eMENU_RATINGS_RRT_VAL_BUTTON_INC_Y,eMENU_RATINGS_RRT_VAL_BUTTON_WIDTH,eMENU_RATINGS_RRT_VAL_BUTTON_HEIGHT,eTEXT_MAX,eTEXT_MAX ,eSCREEN_RATINGS_LIMITS,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
393        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_RRT_VAL_FIRST_BUTTON_X,eMENU_RATINGS_RRT_VAL_FIRST_BUTTON_Y + 3 * eMENU_RATINGS_RRT_VAL_BUTTON_INC_Y,eMENU_RATINGS_RRT_VAL_BUTTON_WIDTH,eMENU_RATINGS_RRT_VAL_BUTTON_HEIGHT,eTEXT_MAX,eTEXT_MAX ,eSCREEN_RATINGS_LIMITS,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
394        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_RRT_VAL_FIRST_BUTTON_X,eMENU_RATINGS_RRT_VAL_FIRST_BUTTON_Y + 4 * eMENU_RATINGS_RRT_VAL_BUTTON_INC_Y,eMENU_RATINGS_RRT_VAL_BUTTON_WIDTH,eMENU_RATINGS_RRT_VAL_BUTTON_HEIGHT,eTEXT_MAX,eTEXT_MAX ,eSCREEN_RATINGS_LIMITS,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
395        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_RRT_VAL_FIRST_BUTTON_X,eMENU_RATINGS_RRT_VAL_FIRST_BUTTON_Y + 5 * eMENU_RATINGS_RRT_VAL_BUTTON_INC_Y,eMENU_RATINGS_RRT_VAL_BUTTON_WIDTH,eMENU_RATINGS_RRT_VAL_BUTTON_HEIGHT,eTEXT_MAX,eTEXT_MAX ,eSCREEN_RATINGS_LIMITS,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
396        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_RRT_VAL_FIRST_BUTTON_X,eMENU_RATINGS_RRT_VAL_FIRST_BUTTON_Y + 6 * eMENU_RATINGS_RRT_VAL_BUTTON_INC_Y,eMENU_RATINGS_RRT_VAL_BUTTON_WIDTH,eMENU_RATINGS_RRT_VAL_BUTTON_HEIGHT,eTEXT_MAX,eTEXT_MAX ,eSCREEN_RATINGS_LIMITS,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
397        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_RRT_VAL_FIRST_BUTTON_X,eMENU_RATINGS_RRT_VAL_FIRST_BUTTON_Y + 7 * eMENU_RATINGS_RRT_VAL_BUTTON_INC_Y,eMENU_RATINGS_RRT_VAL_BUTTON_WIDTH,eMENU_RATINGS_RRT_VAL_BUTTON_HEIGHT,eTEXT_MAX,eTEXT_MAX ,eSCREEN_RATINGS_LIMITS,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
398        {eBUTTON_CHECK|eBUTTON_CHECK_LOCK,eMENU_RATINGS_RRT_VAL_FIRST_BUTTON_X,eMENU_RATINGS_RRT_VAL_FIRST_BUTTON_Y + 8 * eMENU_RATINGS_RRT_VAL_BUTTON_INC_Y,eMENU_RATINGS_RRT_VAL_BUTTON_WIDTH,eMENU_RATINGS_RRT_VAL_BUTTON_HEIGHT,eTEXT_MAX,eTEXT_MAX ,eSCREEN_RATINGS_LIMITS,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
399};
400
401bbutton_t g_buttons_ratings_rrt_update[] = 
402{
403        {eBUTTON_MENU,eMENU_RATINGS_RRT_UPDATE_FIRST_BUTTON_X,eMENU_RATINGS_RRT_UPDATE_FIRST_BUTTON_Y,eMENU_RATINGS_RRT_UPDATE_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_LIMITS_BUTTON,eTEXT_LIMITS_INFO,eSCREEN_PIN_VERIFY_RATINGS,eSCREEN_MAIN, 1, eCOLOR_MED_BLUE},
404        {eBUTTON_MENU,eMENU_RATINGS_RRT_UPDATE_FIRST_BUTTON_X,eMENU_RATINGS_RRT_UPDATE_FIRST_BUTTON_Y + eMENU_RATINGS_RRT_UPDATE_BUTTON_INC_Y,eMENU_RATINGS_RRT_UPDATE_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CANCEL_BUTTON,eTEXT_CANCEL_INFO,eSCREEN_MAX,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
405};
406
407bbutton_t g_buttons_wrong_pin_live[] =
408{
409        {eBUTTON_MENU,eMENU_WRONG_PIN_FIRST_BUTTON_X,eMENU_WRONG_PIN_FIRST_BUTTON_Y,eMENU_WRONG_PIN_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_RETRY_BUTTON,eTEXT_RETRY_INFO ,eSCREEN_PIN_VERIFY_LIVE,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
410};
411
412bbutton_t g_buttons_wrong_pin_ratings[] =
413{
414        {eBUTTON_MENU,eMENU_WRONG_PIN_FIRST_BUTTON_X,eMENU_WRONG_PIN_FIRST_BUTTON_Y,eMENU_WRONG_PIN_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CANCEL_BUTTON,eTEXT_CANCEL_INFO ,eSCREEN_MAIN,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
415        {eBUTTON_MENU,eMENU_WRONG_PIN_FIRST_BUTTON_X,eMENU_WRONG_PIN_FIRST_BUTTON_Y + eMENU_WRONG_PIN_BUTTON_INC_Y,eMENU_RETRY_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_RETRY_BUTTON,eTEXT_RETRY_INFO,eSCREEN_PIN_VERIFY_RATINGS,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
416};
417
418bbutton_t g_buttons_wrong_pin_reset[] =
419{
420        {eBUTTON_MENU,eMENU_WRONG_PIN_FIRST_BUTTON_X,eMENU_WRONG_PIN_FIRST_BUTTON_Y,eMENU_WRONG_PIN_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CANCEL_BUTTON,eTEXT_CANCEL_INFO ,eSCREEN_MAIN,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
421        {eBUTTON_MENU,eMENU_WRONG_PIN_FIRST_BUTTON_X,eMENU_WRONG_PIN_FIRST_BUTTON_Y + eMENU_WRONG_PIN_BUTTON_INC_Y,eMENU_RETRY_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_RETRY_BUTTON,eTEXT_RETRY_INFO,eSCREEN_PIN_VERIFY_RESET,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
422};
423
424bbutton_t g_buttons_mismatched_pins[] =
425{
426        {eBUTTON_MENU,eMENU_WRONG_PIN_FIRST_BUTTON_X,eMENU_WRONG_PIN_FIRST_BUTTON_Y,eMENU_WRONG_PIN_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_CANCEL_BUTTON,eTEXT_CANCEL_INFO ,eSCREEN_RATINGS,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
427        {eBUTTON_MENU,eMENU_WRONG_PIN_FIRST_BUTTON_X,eMENU_WRONG_PIN_FIRST_BUTTON_Y + eMENU_WRONG_PIN_BUTTON_INC_Y,eMENU_RETRY_BUTTON_WIDTH,eBUTTON_HEIGHT,eTEXT_RETRY_BUTTON,eTEXT_RETRY_INFO,eSCREEN_PIN_NEW,eSCREEN_MAX, 1, eCOLOR_MED_BLUE},
428};
429
430
431/*
432Summary:
433        show/hide banner
434Description:
435        if mode is eLS_BANNER_MAX then the last banner mode used when it lasted timed out is displayed
436        returns 1 if banner mode changed, 0 otherwise
437*/
438static int set_banner(bscreen_t *p_screen, banner_mode_t mode, bool save_last_mode)
439{
440        banner_state_t *p_bs = (banner_state_t*)p_screen->local_state;
441        static banner_mode_t last_mode = eLS_BANNER_SMALL;
442
443        if ((save_last_mode) &&
444                ((p_bs->mode == eLS_BANNER_SMALL) || (p_bs->mode == eLS_BANNER_BIG)))
445                last_mode = p_bs->mode;
446
447        if (mode == eLS_BANNER_MAX)
448                mode = last_mode;
449
450        if (mode == p_bs->mode)
451                return 0;
452
453        p_bs->mode = mode;
454
455        return 1;
456}
457/*
458Summary:
459        copy string and remove spaces.
460        .
461*/
462void strncpy_no_spaces(char* dst_str, char* src_str,int len)
463{
464        int idx = 0;
465        int dst_idx = 0;
466        while (src_str[idx] && (idx < len))
467        {
468                if (src_str[idx] != ' ')
469                {
470                        dst_str[dst_idx++] = src_str[idx];
471                }
472                idx++;
473        }
474        dst_str[dst_idx] = 0;
475}
476
477/*
478Summary:
479        If a button is selected set the next screen_id.
480Description:
481        If a button is selected set the next screen_id. Return non-
482        zero on sucess and 0 when no selection exists
483*/
484static int select_button(
485                                                void *v_app,                    /* Opaque app reference */
486                                                void *v_screen                  /* Opaque screen reference */
487                                                )
488{
489        bapp_t *p_app = (bapp_t*)v_app;
490        bscreen_t *p_screen = (bscreen_t*)v_screen;
491        int retval = 1;
492
493        if (p_screen->p_button_array[p_screen->button_selection].type & eBUTTON_RADIO)
494        {
495                if (p_screen->button_checked == p_screen->button_selection)
496                        retval = 0;
497                else
498                {
499                        int prev_checked;
500                        const bbutton_t *p_button;
501
502                        prev_checked = p_screen->button_checked;
503                        p_screen->button_checked = p_screen->button_selection;
504                        p_button = &(p_screen->p_button_array[prev_checked]);
505                        bapp_sync(p_app);
506
507                        bscreen_draw_button(p_app,p_button, 0,0,prev_checked);
508
509                        p_button = &(p_screen->p_button_array[p_screen->button_checked]);
510                        bscreen_draw_button(p_app,p_button, 1,1,p_screen->button_checked);
511
512                        bapp_flush_screen(p_app);
513                        if (p_screen->p_button_array[p_screen->button_selection].type & eBUTTON_MENU)
514                                bapp_sleep(250); /* slight delay so user can see radio/check box change displayed */
515                        retval = 1;
516                }
517
518        } else if (p_screen->p_button_array[p_screen->button_selection].type & eBUTTON_CHECK)
519        {
520                bscreen_event_t event;
521                const bbutton_t *p_button;
522                int checked = 0;
523
524                event.id = p_screen->button_selection;
525                event.type = eS_EVENT_CHECKED;
526                checked = p_screen->handle_event(p_app,p_screen,&event);
527
528                p_screen->button_checked = p_screen->button_selection;
529
530                p_button = &(p_screen->p_button_array[p_screen->button_checked]);
531                /* any time we draw we need to sync first */
532                bapp_sync(p_app);
533                bscreen_draw_button(p_app,p_button, 1,checked,p_screen->button_checked);
534                bapp_flush_screen(p_app);
535                if (p_screen->p_button_array[p_screen->button_selection].type & eBUTTON_MENU)
536                        bapp_sleep(250); /* slight delay so user can see radio/check box change displayed */
537                retval = 1;
538        }
539
540        if (p_screen->p_button_array[p_screen->button_selection].type & eBUTTON_MENU)
541        {
542                bapp_set_current_screen(p_app, 
543                                                                p_screen->p_button_array[p_screen->button_selection].next_screen_id, 
544                                                                p_screen->p_button_array[p_screen->button_selection].next_screen_back_id);
545                retval = 1;
546        }
547
548        return retval;
549}
550
551/*
552Summary:
553        Move highlight from one button to another
554Description:
555        Unfocus the current button and focus the next one.
556        Return non- zero on sucess and 0 when no focus exists
557*/
558static int focus_button(
559                                           void *v_app,                    /* Opaque app reference */
560                                           void *v_screen,                 /* Opaque screen reference */
561                                           int button_idx                  /* Index into g_buttons_XXX[] to set focus to */
562                                           )
563{
564        bapp_t *p_app = (bapp_t*)v_app;
565        bscreen_t *p_screen = (bscreen_t*)v_screen;
566        unsigned int prev_button = p_screen->button_selection;
567        int checked;
568        bscreen_event_t event;
569        const bbutton_t *p_button;
570
571        p_screen->button_selection = button_idx;
572
573        if (prev_button != p_screen->button_selection)
574        {
575                event.id = prev_button;
576                event.type = eS_EVENT_CHECKED;
577                bapp_sync(p_app);
578                checked = p_screen->handle_event(p_app,p_screen,&event);
579                p_button = &(p_screen->p_button_array[prev_button]);
580                bscreen_draw_button(p_app,p_button, 0,checked,prev_button);
581                event.id = p_screen->button_selection;
582                event.type = eS_EVENT_CHECKED;
583                checked = p_screen->handle_event(p_app,p_screen,&event);
584                p_button = &(p_screen->p_button_array[p_screen->button_selection]);
585                bscreen_draw_button(p_app,p_button, 1,checked,p_screen->button_selection);
586                bapp_flush_screen(p_app);
587                return 0;
588        }
589
590        return 1;
591}
592
593/*
594Summary:
595        Unselect the current button and select the next one.
596Description:
597        Unselect the current button and select the next one.
598        Return non- zero on sucess and 0 when no selection exists
599*/
600static int next_button(
601                                          void *v_app,                    /* Opaque app reference */
602                                          void *v_screen,                 /* Opaque screen reference */
603                                          int dir                                 /* 0 - down, 1 - up */
604                                          )
605{
606        bscreen_t *p_screen = (bscreen_t*)v_screen;
607        int next_button = p_screen->button_selection;
608        if (dir)
609        {
610                if (p_screen->button_selection == 0)
611                        next_button = p_screen->num_buttons - 1;
612                else
613                        next_button--;
614        } else
615        {
616                if (p_screen->button_selection == (p_screen->num_buttons - 1))
617                        next_button = 0;
618                else
619                        next_button++;
620        }
621
622        return focus_button(v_app,v_screen,next_button);
623}
624
625
626/*
627Summary:
628        Use the this function to get a UNI string.
629*/
630
631void bscreen_get_string(
632                                           bapp_lang_t e_lang,             /* Language enum */
633                                           btext_id_t e_text_id,           /* Text enum */
634                                           unsigned int *p_uni_str,        /* Buffer to put UNI string into */
635                                           unsigned int *str_len           /* On input the max length in words on output the actual size in characters. */
636                                           )
637{
638        char *p_str;
639
640        if ((e_text_id >= eTEXT_MAX) || (e_lang >= eLANG_MAX))
641        {
642                *str_len = 0;
643                return;
644        }
645
646        p_str = (char*)g_p_dsp->ui_comp.str_table[e_lang][e_text_id];
647//    p_str = (char*)s_str_table[e_lang][e_text_id];
648        /*BDBG_MSG(("get text id: %d - %s\n", e_text_id, p_str));*/
649        *str_len = c_to_uni_str(p_str,p_uni_str,*str_len);
650}
651
652/*
653Summary:
654        Draw the screen background.
655Description:
656        Draw the screen background.
657*/
658void bscreen_draw_background(void *v_app, bgfx_surf_t *p_surf, uint16_t title_area_height)
659{
660        bapp_t *p_app = (bapp_t*)v_app;
661        int i = 0;
662        int offset = 4;
663
664        /* adjust title_area_height based on language choice */
665        if (p_app->lang == eLANG_SPANISH)
666        {
667                switch (p_app->screen_id)
668                {
669                case eSCREEN_PIN_VERIFY_LIVE:
670                case eSCREEN_PIN_VERIFY_RATINGS:
671                case eSCREEN_PIN_VERIFY_RESET:
672                case eSCREEN_MISMATCHED_PINS:
673                case eSCREEN_RATINGS_LOCK:
674                case eSCREEN_RATINGS_LIMITS:
675                case eSCREEN_RATINGS_TV:
676                case eSCREEN_RATINGS_RRT_DIM:
677                case eSCREEN_RATINGS_RRT_UPDATE:
678                case eSCREEN_ANTENNA:
679                case eSCREEN_AUTO_POWER:
680                case eSCREEN_WIZ_PIN_NEW:
681                case eSCREEN_WIZ_MISMATCHED_PINS:
682                case eSCREEN_CH_SCAN:
683                case eSCREEN_WIZ_CH_SCAN:
684                case eSCREEN_SMART_CH_SCAN:
685                case eSCREEN_WIZ_SMART_CH_SCAN:
686                case eSCREEN_CAPTIONS_RESET:
687                case eSCREEN_CAPTIONS_FONT_STYLE:
688                case eSCREEN_CAPTIONS_FONT_SIZE:
689                        title_area_height += (eMENU_TITLE_AREA_HEIGHT_1_LINE - 
690                                                                  eMENU_TITLE_AREA_HEIGHT_0_LINE);
691                        break;
692                default:
693                        break;
694                }
695        } else
696                if (p_app->lang == eLANG_FRENCH)
697        {
698                switch (p_app->screen_id)
699                {
700                case eSCREEN_PICTURE:
701                case eSCREEN_PIN_VERIFY_LIVE:
702                case eSCREEN_PIN_VERIFY_RATINGS:
703                case eSCREEN_PIN_VERIFY_RESET:
704                case eSCREEN_MISMATCHED_PINS:
705                case eSCREEN_RATINGS_LIMITS:
706                case eSCREEN_RATINGS_TV:
707                case eSCREEN_RATINGS_MOVIES:
708                case eSCREEN_RATINGS_RRT_DIM:
709                case eSCREEN_RATINGS_RRT_VAL:
710                case eSCREEN_AUTO_POWER:
711                case eSCREEN_ANTENNA:
712                case eSCREEN_WIZ_MISMATCHED_PINS:
713                case eSCREEN_SMART_CH_SCAN:
714                case eSCREEN_WIZ_SMART_CH_SCAN:
715                case eSCREEN_CAPTIONS_FONT_STYLE:
716                case eSCREEN_CAPTIONS_BACK_OPTIONS:
717                case eSCREEN_CAPTIONS_FONT_OPTIONS:
718                case eSCREEN_CAPTIONS_FONT_SIZE:
719                case eSCREEN_CAPTIONS_RESET:
720                        title_area_height += (eMENU_TITLE_AREA_HEIGHT_1_LINE - 
721                                                                  eMENU_TITLE_AREA_HEIGHT_0_LINE);
722                        break;
723                case eSCREEN_CAPTIONS_BACK_COLOR:
724                        title_area_height += (eMENU_TITLE_AREA_HEIGHT_1_LINE - 
725                                                                  eMENU_TITLE_AREA_HEIGHT_0_LINE - 8);
726                        break;
727                case eSCREEN_CAPTIONS_FONT:
728                        title_area_height -= 18;
729                        break;
730                default:
731                        break;
732                }
733        }
734
735        /* TODO: do we need to do this since video is muted anyways? */
736        /*bgfx_fill_rect(p_surf,0,0,eWIDTH,eHEIGHT,eCOLOR_BLACK);*/
737
738        /* draw 3 window fields */
739        bgfx_fill_rect(p_surf,eSCREEN_ACTION_SAFE_X+offset,eSCREEN_ACTION_SAFE_Y+offset,eSCREEN_ACTION_SAFE_WIDTH-(2*offset),title_area_height-offset,eCOLOR_LT_BLUE);
740        bgfx_fill_rect(p_surf,eSCREEN_ACTION_SAFE_X+offset,eSCREEN_ACTION_SAFE_Y+offset + title_area_height-offset,eSCREEN_ACTION_SAFE_WIDTH-(2*offset),eSCREEN_ACTION_SAFE_HEIGHT - eINFO_AREA_HEIGHT - title_area_height,eCOLOR_MED_BLUE);
741        bgfx_fill_rect(p_surf,eSCREEN_ACTION_SAFE_X+offset,eINFO_AREA_Y,eSCREEN_ACTION_SAFE_WIDTH-(2*offset),eINFO_AREA_HEIGHT-offset,eCOLOR_DRK_BLUE);
742
743        /* draw border */
744        for (i = 3; i < 7; i++)
745        {
746                bgfx_h_draw_line(p_surf,eSCREEN_ACTION_SAFE_X-i+1,eSCREEN_ACTION_SAFE_X+eSCREEN_ACTION_SAFE_WIDTH+i+1,eSCREEN_ACTION_SAFE_Y-i,eCOLOR_WHITE);
747                bgfx_h_draw_line(p_surf,eSCREEN_ACTION_SAFE_X-i+1,eSCREEN_ACTION_SAFE_X+eSCREEN_ACTION_SAFE_WIDTH+i+1,eSCREEN_ACTION_SAFE_Y+eSCREEN_ACTION_SAFE_HEIGHT+i,eCOLOR_WHITE);
748                bgfx_v_draw_line(p_surf,eSCREEN_ACTION_SAFE_X-i,eSCREEN_ACTION_SAFE_Y-i,eSCREEN_ACTION_SAFE_Y+eSCREEN_ACTION_SAFE_HEIGHT+i,eCOLOR_WHITE);
749                bgfx_v_draw_line(p_surf,eSCREEN_ACTION_SAFE_X+eSCREEN_ACTION_SAFE_WIDTH+i,eSCREEN_ACTION_SAFE_Y-i,eSCREEN_ACTION_SAFE_Y+eSCREEN_ACTION_SAFE_HEIGHT+i,eCOLOR_WHITE);
750        }
751}
752
753/*
754Summary:
755        Picture screen event handler
756Description:
757        Picture screen event handler.
758        .
759*/
760int screen_picture_event(void *v_app, void *v_screen, 
761                                                 bscreen_event_t *p_event)
762{
763        bapp_t *p_app = (bapp_t*)v_app;
764        bscreen_t *p_screen = (bscreen_t*)v_screen;
765        int result = 0;
766
767        if (p_event->type == eS_EVENT_SETUP)
768        {
769                bscreen_default_setup(v_app,v_screen);
770                p_screen->button_checked = (p_app->settings.picture == 0) ? 1 : 0;
771                result = 1;     /* always handle event */
772        } else if (p_event->type == eS_EVENT_IR)
773        {
774                switch (p_event->id)
775                {
776                case eIR_RIGHT:
777                case eIR_SELECT:
778                        result = select_button(v_app,v_screen);
779                        p_app->settings.picture = ((p_screen->button_checked == 0) ? 1 : 0);
780                        p_app->settings_dirty = true;
781                        break;
782                case eIR_LEFT:
783                case eIR_MENU:
784                        result = 1;
785                        bapp_goto_last_screen(p_app);
786                        break;
787                default:
788                        result = bscreen_default_event(v_app,v_screen,p_event);
789                        break;
790                }
791        } else
792        {
793                result = bscreen_default_event(v_app,v_screen,p_event);
794        }
795
796        return result;
797}
798
799/*
800Summary:
801        Picture screen event handler
802Description:
803        Picture screen event handler.
804        .
805*/
806extern const char g_tz_map[];
807int bscreen_timezone_event(void *v_app, void *v_screen, 
808                                                 bscreen_event_t *p_event)
809{
810        bapp_t *p_app = (bapp_t*)v_app;
811        bscreen_t *p_screen = (bscreen_t*)v_screen;
812        int result = 0;
813
814        if (p_event->type == eS_EVENT_SETUP)
815        {
816                bscreen_default_setup(v_app,v_screen);
817                p_screen->button_checked = p_app->settings.time_zone;
818                BDBG_ERR(("p_app->settings.time_zone = %d\n",p_app->settings.time_zone));
819                result = 1;     /* always handle event */
820        } else if (p_event->type == eS_EVENT_CHECKED)
821        {
822                if (p_event->id == 5)
823                {
824                        result = (p_app->settings.dst) ? 1 : 0;
825                }
826                else
827                {
828                        result = bscreen_default_event(v_app,v_screen,p_event);
829                }
830        } else if (p_event->type == eS_EVENT_IR)
831        {
832                switch (p_event->id)
833                {
834                case eIR_RIGHT:
835                case eIR_SELECT:
836                        if (p_screen->button_selection == 5)
837                        {
838                                const bbutton_t *p_button;
839                                p_app->settings.dst = (p_app->settings.dst) ? 0 : 1;
840                                p_button = &(p_screen->p_button_array[5]);
841                                bapp_sync(p_app);
842                                bscreen_draw_button(p_app,p_button, p_screen->button_selection,
843                                                                        p_app->settings.dst,p_screen->button_selection);
844                                bapp_flush_screen(p_app);
845                                result = 0;
846                        }
847                        else
848                        {
849                                result = select_button(v_app,v_screen);
850                                p_app->settings.time_zone = p_screen->button_checked;
851                                if (p_app->settings.time_zone != 0)
852                                {
853                                        p_app->chm.local_time_source = eTS_FIXED;
854                                        p_app->chm.local_offset = 0 - (int)g_tz_map[p_app->settings.time_zone];
855                                        p_app->chm.local_offset *= 3600;
856                                        p_app->chm.local_dst_obs = p_app->settings.dst;
857                                        BDBG_ERR(("### Local time %d Fixed(%d) dst %d ###\n",p_app->chm.local_offset,p_app->settings.time_zone,p_app->chm.local_dst_obs));
858                                }
859                                else
860                                        p_app->chm.local_time_source = eTS_NONE;
861                        }
862                        p_app->settings_dirty = true;
863                        break;
864                case eIR_LEFT:
865                case eIR_MENU:
866                        result = 1;
867                        bapp_goto_last_screen(p_app);
868                        break;
869                default:
870                        result = bscreen_default_event(v_app,v_screen,p_event);
871                        break;
872                }
873        } else
874        {
875                result = bscreen_default_event(v_app,v_screen,p_event);
876        }
877
878        return result;
879}
880
881/*
882Summary:
883        Sound screen event handler
884Description:
885        Sound screen event handler.
886        .
887*/
888int screen_sound_event(void *v_app, void *v_screen, 
889                                           bscreen_event_t *p_event)
890{
891        bapp_t *p_app = (bapp_t*)v_app;
892        bscreen_t *p_screen = (bscreen_t*)v_screen;
893        int result = 0;
894
895        if (p_event->type == eS_EVENT_SETUP)
896        {
897                bscreen_default_setup(v_app,v_screen);
898                p_screen->button_checked = p_app->settings.sound;
899                result = 1;     /* always handle event */
900        } else if (p_event->type == eS_EVENT_IR)
901        {
902                switch (p_event->id)
903                {
904                case eIR_RIGHT:
905                case eIR_SELECT:
906                        result = select_button(v_app,v_screen);
907                        p_app->settings.sound = p_screen->button_checked;
908                        p_app->settings_dirty = true;
909                        break;
910                case eIR_LEFT:
911                case eIR_MENU:
912                        result = 1;
913                        bapp_goto_last_screen(p_app);
914                        break;
915                default:
916                        result = bscreen_default_event(v_app,v_screen,p_event);
917                        break;
918                }
919        } else
920        {
921                result = bscreen_default_event(v_app,v_screen,p_event);
922        }
923
924        return result;
925}
926
927/*
928Summary:
929        Setup screen event handler
930Description:
931        Setup screen event handler.
932        .
933*/
934int screen_setup_event(void *v_app, void *v_screen, 
935                                           bscreen_event_t *p_event)
936{
937        bapp_t *p_app = (bapp_t*)v_app;
938        bscreen_t *p_screen = (bscreen_t*)v_screen;
939        int result = 0;
940
941        if (p_event->type == eS_EVENT_SETUP)
942        {
943                bscreen_default_setup(v_app,v_screen);
944                result = 1;     /* always handle event */
945        } else if (p_event->type == eS_EVENT_IR)
946        {
947                switch (p_event->id)
948                {
949                case eIR_RIGHT:
950                case eIR_SELECT:
951                        if (p_screen->button_selection)
952                        {
953                                result = select_button(v_app,v_screen);
954                        } else
955                        {
956                                /* decide what type of channel scan to do (quick or full)
957                                   we cannot blindly call select_button() here since we need to go to
958                                   different scan screens depending on the type of antenna attached */
959                                bapp_set_current_screen(
960                                                                           p_app, 
961                                                                           (bant_detect() ? eSCREEN_SMART_CH_SCAN : eSCREEN_CH_SCAN),
962                                                                           p_screen->p_button_array[p_screen->button_selection].next_screen_back_id);
963                                result = 1;
964                        }
965                        break;
966                case eIR_LEFT:
967                case eIR_MENU:
968                        result = 1;
969                        bapp_goto_last_screen(p_app);
970                        break;
971                default:
972                        result = bscreen_default_event(v_app,v_screen,p_event);
973                        break;
974                }
975        } else
976        {
977                result = bscreen_default_event(v_app,v_screen,p_event);
978        }
979
980        return result;
981}
982
983/*
984Summary:
985        Ch Scan screen event handler
986Description:
987        Ch Scan screen event handler.
988        .
989*/
990int screen_ch_scan_event(void *v_app, void *v_screen, 
991                                                 bscreen_event_t *p_event)
992{
993        bapp_t *p_app = (bapp_t*)v_app;
994        bscreen_t *p_screen = (bscreen_t*)v_screen;
995        int result = 0;
996
997        if (p_event->type == eS_EVENT_SETUP)
998        {
999                bscreen_default_setup(v_app,v_screen);
1000                result = 1;     /* always handle event */
1001                p_screen->button_checked = 0;
1002                p_screen->local_state = 0;
1003        } else if (p_event->type == eS_EVENT_CHECKED)
1004        {
1005                result = (p_screen->local_state) ?  1 : 0;
1006        } else if (p_event->type == eS_EVENT_IR)
1007        {
1008                switch (p_event->id)
1009                {
1010                case eIR_RIGHT:
1011                case eIR_SELECT:
1012                        if (((p_app->screen_id == eSCREEN_CH_SCAN) && (p_screen->button_selection == 1)) ||
1013                                ((p_app->screen_id == eSCREEN_SMART_CH_SCAN) && (p_screen->button_selection == 2)))
1014                                p_screen->local_state = (p_screen->local_state) ? 0 : 1;
1015                        result = select_button(v_app,v_screen);
1016                        if (bant_detect())
1017                                p_app->ch_scan_type = (p_screen->button_selection ? eFULL_SCAN : eQUICK_SCAN);
1018                        else
1019                                p_app->ch_scan_type     = eFULL_SCAN;
1020
1021                        if ((p_screen->local_state == 1) && (p_app->ch_scan_type < eFULL_RESCAN))
1022                        {
1023                                p_app->ch_scan_type += 2;
1024                        }
1025                        break;
1026                case eIR_LEFT:
1027                case eIR_MENU:
1028                        result = 1;
1029                        bapp_goto_last_screen(p_app);
1030                        break;
1031                default:
1032                        result = bscreen_default_event(v_app,v_screen,p_event);
1033                        break;
1034                }
1035        } else
1036        {
1037                result = bscreen_default_event(v_app,v_screen,p_event);
1038        }
1039
1040        return result;
1041}
1042
1043/*
1044Summary:
1045        Antenna screen event handler
1046Description:
1047        Antenna screen event handler.
1048        .
1049*/
1050int screen_antenna_event(void *v_app, void *v_screen, 
1051                                                 bscreen_event_t *p_event)
1052{
1053        bapp_t *p_app = (bapp_t*)v_app;
1054        int result = 0;
1055        baudio_decode_config config;
1056
1057        if (p_event->type == eS_EVENT_SETUP)
1058        {
1059                p_app->tmp_value = 0; /* progress set at 0% */
1060                result = 1;     /* always handle event */
1061                bapp_stop_decode(p_app);
1062                chm_cmd(&p_app->chm,eCHM_CHECK_SIGNAL);
1063        } else if (p_event->type == eS_EVENT_PROGRESS)
1064        {
1065                int w, h;
1066                unsigned int num_chars;
1067                char strPercent[5];
1068
1069                bapp_audio_mute(p_app, 0);
1070
1071                baudio_decode_get_config(p_app->audio, &config);
1072                config.tone = p_event->id;
1073                baudio_decode_set_config(p_app->audio, &config);
1074                result = 0;     /* don't want top cause redraw */
1075                /* draw progress meter */
1076                bscreen_draw_progress(v_app, ePROGRESS_X, ePROGRESS_Y, ePROGRESS_WIDTH, ePROGRESS_HEIGHT, 
1077                                                          eBUTTON_PROGRESS_BORDER, eCOLOR_WHITE, eCOLOR_DRK_BLUE, p_event->id);
1078
1079                /* draw percent compete text */
1080                num_chars = SCREEN_MAX_STR_WIDTH;
1081                snprintf(strPercent, 4, "%3d", p_event->id);
1082                strPercent[4] = 0;
1083                strPercent[3] = '%';
1084
1085                num_chars = c_to_uni_str(strPercent,p_app->tmp_str,num_chars);
1086                bgfx_string_info(p_app->p_font[p_app->lang][eFONT_SIZE_LARGE],(const unsigned long *)p_app->tmp_str,num_chars,&w,&h);
1087                bapp_sync(p_app);
1088                bgfx_fill_rect(&p_app->surf,ePROGRESS_X + ePROGRESS_WIDTH + ePROGRESS_LABEL_SPACING,
1089                                           ePROGRESS_Y + (ePROGRESS_HEIGHT / 2) - (h / 2),w + 12, h + 2,eCOLOR_MED_BLUE);
1090                text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_MED],
1091                                                ePROGRESS_X + ePROGRESS_WIDTH + ePROGRESS_LABEL_SPACING, ePROGRESS_Y + (ePROGRESS_HEIGHT / 2) - (h / 2), 
1092                                                w + 10, h,  p_app->tmp_str,
1093                                                num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_DESC_TEXT_SPACING);
1094
1095                bapp_flush_screen(p_app);
1096        } else if (p_event->type == eS_EVENT_IR)
1097        {
1098                switch (p_event->id)
1099                {
1100                case eIR_RIGHT:
1101                case eIR_SELECT:
1102                        if (p_app->settings.wiz_completed)
1103                        {
1104                                bapp_audio_mute(p_app,1);
1105                                baudio_decode_get_config(p_app->audio, &config);
1106                                config.tone = 0xFFFFFFFF;
1107                                baudio_decode_set_config(p_app->audio, &config);
1108                                bapp_tune(p_app);
1109                                /* in setup wizard */
1110                                result = 1;
1111                                bapp_set_current_screen(p_app, eSCREEN_NULL, eSCREEN_NULL);
1112                        }
1113                        break;
1114
1115                case eIR_LEFT:
1116                case eIR_MENU:
1117                        result = 1;
1118                        bapp_audio_mute(p_app, 1);
1119                        baudio_decode_get_config(p_app->audio, &config);
1120                        config.tone = 0xFFFFFFFF;
1121                        baudio_decode_set_config(p_app->audio, &config);
1122                        bapp_tune(p_app);
1123                        bapp_goto_last_screen(p_app);
1124                        break;
1125                }
1126        } else if ((p_event->type != eS_EVENT_SELECTED) &&
1127                           (p_event->type != eS_EVENT_CHECKED))
1128        {
1129                result = bscreen_default_event(v_app,v_screen,p_event);
1130        }
1131
1132        return result;
1133}
1134
1135#if 0
1136
1137/*
1138Summary:
1139        Captions screen event handler
1140Description:
1141        Captions screen event handler.
1142        .
1143*/
1144int screen_captions_event(void *v_app, void *v_screen,
1145                                                  bscreen_event_t *p_event)
1146{
1147        bapp_t *p_app = (bapp_t*)v_app;
1148        int result = 0;
1149
1150        if (p_event->type == eS_EVENT_SETUP)
1151        {
1152                bscreen_default_setup(v_app,v_screen);
1153                result = 1;     /* always handle event */
1154        } else if (p_event->type == eS_EVENT_IR)
1155        {
1156                switch (p_event->id)
1157                {
1158                case eIR_RIGHT:
1159                case eIR_SELECT:
1160                        result = select_button(v_app,v_screen);
1161                        break;
1162                case eIR_LEFT:
1163                case eIR_MENU:
1164                        result = 1;
1165                        bapp_goto_last_screen(p_app);
1166                        break;
1167                default:
1168                        result = bscreen_default_event(v_app,v_screen,p_event);
1169                        break;
1170                }
1171        } else
1172        {
1173                result = bscreen_default_event(v_app,v_screen,p_event);
1174        }
1175
1176        return result;
1177}
1178/*
1179Summary:
1180        Captions on/off screen event handler
1181Description:
1182        Captions on/off screen event handler.
1183        .
1184*/
1185int screen_captions_on_off_event(void *v_app, void *v_screen,
1186                                                                 bscreen_event_t *p_event)
1187{
1188        bapp_t *p_app = (bapp_t*)v_app;
1189        bscreen_t *p_screen = (bscreen_t*)v_screen;
1190        int result = 0;
1191
1192        if (p_event->type == eS_EVENT_SETUP)
1193        {
1194                bscreen_default_setup(v_app,v_screen);
1195                p_screen->button_checked = !p_app->settings.captions_on_off;
1196                result = 1;     /* always handle event */
1197        } else if (p_event->type == eS_EVENT_IR)
1198        {
1199                switch (p_event->id)
1200                {
1201                case eIR_RIGHT:
1202                case eIR_SELECT:
1203                        result = select_button(v_app,v_screen);
1204                        p_app->settings.captions_on_off = !p_screen->button_checked;
1205                        p_app->settings_dirty = true;
1206                        break;
1207                case eIR_LEFT:
1208                case eIR_MENU:
1209                        result = 1;
1210                        bapp_goto_last_screen(p_app);
1211                        break;
1212                default:
1213                        result = bscreen_default_event(v_app,v_screen,p_event);
1214                        break;
1215                }
1216        } else
1217        {
1218                result = bscreen_default_event(v_app,v_screen,p_event);
1219        }
1220
1221        return result;
1222}
1223
1224/*
1225Summary:
1226        Basic captions screen event handler
1227Description:
1228        Basic captions screen event handler.
1229        .
1230*/
1231int screen_captions_basic_event(void *v_app, void *v_screen,
1232                                                                bscreen_event_t *p_event)
1233{
1234        bapp_t *p_app = (bapp_t*)v_app;
1235        bscreen_t *p_screen = (bscreen_t*)v_screen;
1236        int result = 0;
1237
1238        if (p_event->type == eS_EVENT_SETUP)
1239        {
1240                bscreen_default_setup(v_app,v_screen);
1241                p_screen->button_checked = p_app->settings.captions_basic;
1242                result = 1;     /* always handle event */
1243        } else if (p_event->type == eS_EVENT_IR)
1244        {
1245                switch (p_event->id)
1246                {
1247                case eIR_RIGHT:
1248                case eIR_SELECT:
1249                        result = select_button(v_app,v_screen);
1250                        p_app->settings.captions_basic = p_screen->button_checked;
1251                        p_app->settings_dirty = true;
1252                        break;
1253                case eIR_LEFT:
1254                case eIR_MENU:
1255                        result = 1;
1256                        bapp_goto_last_screen(p_app);
1257                        break;
1258                default:
1259                        result = bscreen_default_event(v_app,v_screen,p_event);
1260                        break;
1261                }
1262        } else
1263        {
1264                result = bscreen_default_event(v_app,v_screen,p_event);
1265        }
1266
1267        return result;
1268}
1269#endif
1270/*
1271Summary:
1272        Advanced captions screen event handler
1273Description:
1274        Advanced captions screen event handler.
1275        .
1276*/
1277int screen_captions_advanced_event(void *v_app, void *v_screen, 
1278                                                                   bscreen_event_t *p_event)
1279{
1280        bapp_t *p_app = (bapp_t*)v_app;
1281        int result = 0;
1282
1283        if (p_event->type == eS_EVENT_SETUP)
1284        {
1285                bscreen_default_setup(v_app,v_screen);
1286                result = 1;     /* always handle event */
1287        } else if (p_event->type == eS_EVENT_IR)
1288        {
1289                switch (p_event->id)
1290                {
1291                case eIR_RIGHT:
1292                case eIR_SELECT:
1293                        result = select_button(v_app,v_screen);
1294                        break;
1295                case eIR_LEFT:
1296                case eIR_MENU:
1297                        result = 1;
1298                        bapp_goto_last_screen(p_app);
1299                        break;
1300                default:
1301                        result = bscreen_default_event(v_app,v_screen,p_event);
1302                        break;
1303                }
1304        } else
1305        {
1306                result = bscreen_default_event(v_app,v_screen,p_event);
1307        }
1308
1309        return result;
1310}
1311
1312/*
1313Summary:
1314        font options captions screen event handler
1315Description:
1316        font options captions screen event handler.
1317        .
1318*/
1319int screen_captions_font_options_event(void *v_app, void *v_screen, 
1320                                                                           bscreen_event_t *p_event)
1321{
1322        bapp_t *p_app = (bapp_t*)v_app;
1323        int result = 0;
1324
1325        if (p_event->type == eS_EVENT_SETUP)
1326        {
1327                bscreen_default_setup(v_app,v_screen);
1328                result = 1;     /* always handle event */
1329        } else if (p_event->type == eS_EVENT_IR)
1330        {
1331                switch (p_event->id)
1332                {
1333                case eIR_RIGHT:
1334                case eIR_SELECT:
1335                        result = select_button(v_app,v_screen);
1336                        break;
1337                case eIR_LEFT:
1338                case eIR_MENU:
1339                        result = 1;
1340                        bapp_goto_last_screen(p_app);
1341                        break;
1342                default:
1343                        result = bscreen_default_event(v_app,v_screen,p_event);
1344                        break;
1345                }
1346        } else
1347        {
1348                result = bscreen_default_event(v_app,v_screen,p_event);
1349        }
1350
1351        return result;
1352}
1353
1354/*
1355Summary:
1356        background options captions screen event handler
1357Description:
1358        background options captions screen event handler.
1359        .
1360*/
1361int screen_captions_back_options_event(void *v_app, void *v_screen, 
1362                                                                           bscreen_event_t *p_event)
1363{
1364        bapp_t *p_app = (bapp_t*)v_app;
1365        int result = 0;
1366
1367        if (p_event->type == eS_EVENT_SETUP)
1368        {
1369                bscreen_default_setup(v_app,v_screen);
1370                result = 1;     /* always handle event */
1371        } else if (p_event->type == eS_EVENT_IR)
1372        {
1373                switch (p_event->id)
1374                {
1375                case eIR_RIGHT:
1376                case eIR_SELECT:
1377                        result = select_button(v_app,v_screen);
1378                        break;
1379                case eIR_LEFT:
1380                case eIR_MENU:
1381                        result = 1;
1382                        bapp_goto_last_screen(p_app);
1383                        break;
1384                default:
1385                        result = bscreen_default_event(v_app,v_screen,p_event);
1386                        break;
1387                }
1388        } else
1389        {
1390                result = bscreen_default_event(v_app,v_screen,p_event);
1391        }
1392
1393        return result;
1394}
1395
1396/*
1397Summary:
1398        Advanced captions font screen event handler
1399Description:
1400        Advanced captions font screen event handler.
1401        .
1402*/
1403int screen_captions_font_event(void *v_app, void *v_screen, 
1404                                                           bscreen_event_t *p_event)
1405{
1406        bapp_t *p_app = (bapp_t*)v_app;
1407        bscreen_t *p_screen = (bscreen_t*)v_screen;
1408        int result = 0;
1409
1410        if (p_event->type == eS_EVENT_SETUP)
1411        {
1412                bscreen_default_setup(v_app,v_screen);
1413                p_screen->button_checked = p_app->settings.captions_font;
1414                result = 1;     /* always handle event */
1415        } else if (p_event->type == eS_EVENT_IR)
1416        {
1417                switch (p_event->id)
1418                {
1419                case eIR_RIGHT:
1420                case eIR_SELECT:
1421                        result = select_button(v_app,v_screen);
1422                        p_app->settings.captions_font = p_screen->button_checked;
1423                        p_app->settings_dirty = true;
1424                        break;
1425                case eIR_LEFT:
1426                case eIR_MENU:
1427                        result = 1;
1428                        bapp_goto_last_screen(p_app);
1429                        break;
1430                default:
1431                        result = bscreen_default_event(v_app,v_screen,p_event);
1432                        break;
1433                }
1434        } else
1435        {
1436                result = bscreen_default_event(v_app,v_screen,p_event);
1437        }
1438
1439        return result;
1440}
1441
1442/*
1443Summary:
1444        Advanced captions font size screen event handler
1445Description:
1446        Advanced captions font size screen event handler.
1447        .
1448*/
1449int screen_captions_font_size_event(void *v_app, void *v_screen, 
1450                                                                        bscreen_event_t *p_event)
1451{
1452        bapp_t *p_app = (bapp_t*)v_app;
1453        bscreen_t *p_screen = (bscreen_t*)v_screen;
1454        int result = 0;
1455
1456        if (p_event->type == eS_EVENT_SETUP)
1457        {
1458                bscreen_default_setup(v_app,v_screen);
1459                p_screen->button_checked = p_app->settings.captions_font_size;
1460                result = 1;     /* always handle event */
1461        } else if (p_event->type == eS_EVENT_IR)
1462        {
1463                switch (p_event->id)
1464                {
1465                case eIR_RIGHT:
1466                case eIR_SELECT:
1467                        result = select_button(v_app,v_screen);
1468                        p_app->settings.captions_font_size = p_screen->button_checked;
1469                        p_app->settings_dirty = true;
1470                        break;
1471                case eIR_LEFT:
1472                case eIR_MENU:
1473                        result = 1;
1474                        bapp_goto_last_screen(p_app);
1475                        break;
1476                default:
1477                        result = bscreen_default_event(v_app,v_screen,p_event);
1478                        break;
1479                }
1480        } else
1481        {
1482                result = bscreen_default_event(v_app,v_screen,p_event);
1483        }
1484
1485        return result;
1486}
1487
1488/*
1489Summary:
1490        Advanced captions font style screen event handler
1491Description:
1492        Advanced captions font style screen event handler.
1493        .
1494*/
1495int screen_captions_font_style_event(void *v_app, void *v_screen, 
1496                                                                         bscreen_event_t *p_event)
1497{
1498        bapp_t *p_app = (bapp_t*)v_app;
1499        bscreen_t *p_screen = (bscreen_t*)v_screen;
1500        int result = 0;
1501
1502        if (p_event->type == eS_EVENT_SETUP)
1503        {
1504                bscreen_default_setup(v_app,v_screen);
1505                p_screen->button_checked = p_app->settings.captions_font_style;
1506                result = 1;     /* always handle event */
1507        } else if (p_event->type == eS_EVENT_IR)
1508        {
1509                switch (p_event->id)
1510                {
1511                case eIR_RIGHT:
1512                case eIR_SELECT:
1513                        result = select_button(v_app,v_screen);
1514                        p_app->settings.captions_font_style = p_screen->button_checked;
1515                        p_app->settings_dirty = true;
1516                        break;
1517                case eIR_LEFT:
1518                case eIR_MENU:
1519                        result = 1;
1520                        bapp_goto_last_screen(p_app);
1521                        break;
1522                default:
1523                        result = bscreen_default_event(v_app,v_screen,p_event);
1524                        break;
1525                }
1526        } else
1527        {
1528                result = bscreen_default_event(v_app,v_screen,p_event);
1529        }
1530
1531        return result;
1532}
1533
1534/*
1535Summary:
1536        Advanced captions font color screen event handler
1537Description:
1538        Advanced captions font color screen event handler.
1539        .
1540*/
1541int screen_captions_font_color_event(void *v_app, void *v_screen, 
1542                                                                         bscreen_event_t *p_event)
1543{
1544        bapp_t *p_app = (bapp_t*)v_app;
1545        bscreen_t *p_screen = (bscreen_t*)v_screen;
1546        int result = 0;
1547
1548        if (p_event->type == eS_EVENT_SETUP)
1549        {
1550                bscreen_default_setup(v_app,v_screen);
1551                p_screen->button_checked = p_app->settings.captions_font_color;
1552                result = 1;     /* always handle event */
1553        } else if (p_event->type == eS_EVENT_IR)
1554        {
1555                switch (p_event->id)
1556                {
1557                case eIR_RIGHT:
1558                case eIR_SELECT:
1559                        result = select_button(v_app,v_screen);
1560                        p_app->settings.captions_font_color = p_screen->button_checked;
1561                        p_app->settings_dirty = true;
1562                        break;
1563                case eIR_LEFT:
1564                case eIR_MENU:
1565                        result = 1;
1566                        bapp_goto_last_screen(p_app);
1567                        break;
1568                default:
1569                        result = bscreen_default_event(v_app,v_screen,p_event);
1570                        break;
1571                }
1572        } else
1573        {
1574                result = bscreen_default_event(v_app,v_screen,p_event);
1575        }
1576
1577        return result;
1578}
1579
1580/*
1581Summary:
1582        Advanced captions font opacity screen event handler
1583Description:
1584        Advanced captions font opacity screen event handler.
1585        .
1586*/
1587int screen_captions_font_opacity_event(void *v_app, void *v_screen, 
1588                                                                           bscreen_event_t *p_event)
1589{
1590        bapp_t *p_app = (bapp_t*)v_app;
1591        bscreen_t *p_screen = (bscreen_t*)v_screen;
1592        int result = 0;
1593
1594        if (p_event->type == eS_EVENT_SETUP)
1595        {
1596                bscreen_default_setup(v_app,v_screen);
1597                p_screen->button_checked = p_app->settings.captions_font_opacity;
1598                result = 1;     /* always handle event */
1599        } else if (p_event->type == eS_EVENT_IR)
1600        {
1601                switch (p_event->id)
1602                {
1603                case eIR_RIGHT:
1604                case eIR_SELECT:
1605                        result = select_button(v_app,v_screen);
1606                        p_app->settings.captions_font_opacity = p_screen->button_checked;
1607                        p_app->settings_dirty = true;
1608                        break;
1609                case eIR_LEFT:
1610                case eIR_MENU:
1611                        result = 1;
1612                        bapp_goto_last_screen(p_app);
1613                        break;
1614                default:
1615                        result = bscreen_default_event(v_app,v_screen,p_event);
1616                        break;
1617                }
1618        } else
1619        {
1620                result = bscreen_default_event(v_app,v_screen,p_event);
1621        }
1622
1623        return result;
1624}
1625
1626/*
1627Summary:
1628        Advanced captions background color screen event handler
1629Description:
1630        Advanced captions background color screen event handler.
1631        .
1632*/
1633int screen_captions_back_color_event(void *v_app, void *v_screen, 
1634                                                                         bscreen_event_t *p_event)
1635{
1636        bapp_t *p_app = (bapp_t*)v_app;
1637        bscreen_t *p_screen = (bscreen_t*)v_screen;
1638        int result = 0;
1639
1640        if (p_event->type == eS_EVENT_SETUP)
1641        {
1642                bscreen_default_setup(v_app,v_screen);
1643                p_screen->button_checked = p_app->settings.captions_back_color;
1644                result = 1;     /* always handle event */
1645        } else if (p_event->type == eS_EVENT_IR)
1646        {
1647                switch (p_event->id)
1648                {
1649                case eIR_RIGHT:
1650                case eIR_SELECT:
1651                        result = select_button(v_app,v_screen);
1652                        p_app->settings.captions_back_color = p_screen->button_checked;
1653                        p_app->settings_dirty = true;
1654                        break;
1655                case eIR_LEFT:
1656                case eIR_MENU:
1657                        result = 1;
1658                        bapp_goto_last_screen(p_app);
1659                        break;
1660                default:
1661                        result = bscreen_default_event(v_app,v_screen,p_event);
1662                        break;
1663                }
1664        } else
1665        {
1666                result = bscreen_default_event(v_app,v_screen,p_event);
1667        }
1668
1669        return result;
1670}
1671
1672/*
1673Summary:
1674        Advanced captions background opacity screen event handler
1675Description:
1676        Advanced captions background opacity screen event handler.
1677        .
1678*/
1679int screen_captions_back_opacity_event(void *v_app, void *v_screen, 
1680                                                                           bscreen_event_t *p_event)
1681{
1682        bapp_t *p_app = (bapp_t*)v_app;
1683        bscreen_t *p_screen = (bscreen_t*)v_screen;
1684        int result = 0;
1685
1686        if (p_event->type == eS_EVENT_SETUP)
1687        {
1688                bscreen_default_setup(v_app,v_screen);
1689                p_screen->button_checked = p_app->settings.captions_back_opacity;
1690                result = 1;     /* always handle event */
1691        } else if (p_event->type == eS_EVENT_IR)
1692        {
1693                switch (p_event->id)
1694                {
1695                case eIR_RIGHT:
1696                case eIR_SELECT:
1697                        result = select_button(v_app,v_screen);
1698                        p_app->settings.captions_back_opacity = p_screen->button_checked;
1699                        p_app->settings_dirty = true;
1700                        break;
1701                case eIR_LEFT:
1702                case eIR_MENU:
1703                        result = 1;
1704                        bapp_goto_last_screen(p_app);
1705                        break;
1706                default:
1707                        result = bscreen_default_event(v_app,v_screen,p_event);
1708                        break;
1709                }
1710        } else
1711        {
1712                result = bscreen_default_event(v_app,v_screen,p_event);
1713        }
1714
1715        return result;
1716}
1717
1718/*
1719Summary:
1720        background edge color screen event handler
1721Description:
1722        background edge color screen event handler
1723        .
1724*/
1725int screen_captions_edge_color_event(void *v_app, void *v_screen, 
1726                                                                         bscreen_event_t *p_event)
1727{
1728        bapp_t *p_app = (bapp_t*)v_app;
1729        bscreen_t *p_screen = (bscreen_t*)v_screen;
1730        int result = 0;
1731
1732        if (p_event->type == eS_EVENT_SETUP)
1733        {
1734                bscreen_default_setup(v_app,v_screen);
1735                p_screen->button_checked = p_app->settings.captions_edge_color;
1736                result = 1;     /* always handle event */
1737        } else if (p_event->type == eS_EVENT_IR)
1738        {
1739                switch (p_event->id)
1740                {
1741                case eIR_RIGHT:
1742                case eIR_SELECT:
1743                        result = select_button(v_app,v_screen);
1744                        p_app->settings.captions_edge_color = p_screen->button_checked;
1745                        p_app->settings_dirty = true;
1746                        break;
1747                case eIR_LEFT:
1748                case eIR_MENU:
1749                        result = 1;
1750                        bapp_goto_last_screen(p_app);
1751                        break;
1752                default:
1753                        result = bscreen_default_event(v_app,v_screen,p_event);
1754                        break;
1755                }
1756        } else
1757        {
1758                result = bscreen_default_event(v_app,v_screen,p_event);
1759        }
1760
1761        return result;
1762}
1763
1764/*
1765Summary:
1766        background edge type screen event handler
1767Description:
1768        background edge type screen event handler
1769        .
1770*/
1771int screen_captions_edge_type_event(void *v_app, void *v_screen, 
1772                                                                        bscreen_event_t *p_event)
1773{
1774        bapp_t *p_app = (bapp_t*)v_app;
1775        bscreen_t *p_screen = (bscreen_t*)v_screen;
1776        int result = 0;
1777
1778        if (p_event->type == eS_EVENT_SETUP)
1779        {
1780                bscreen_default_setup(v_app,v_screen);
1781                p_screen->button_checked = p_app->settings.captions_edge_type;
1782                result = 1;     /* always handle event */
1783        } else if (p_event->type == eS_EVENT_IR)
1784        {
1785                switch (p_event->id)
1786                {
1787                case eIR_RIGHT:
1788                case eIR_SELECT:
1789                        result = select_button(v_app,v_screen);
1790                        p_app->settings.captions_edge_type = p_screen->button_checked;
1791                        p_app->settings_dirty = true;
1792                        break;
1793                case eIR_LEFT:
1794                case eIR_MENU:
1795                        result = 1;
1796                        bapp_goto_last_screen(p_app);
1797                        break;
1798                default:
1799                        result = bscreen_default_event(v_app,v_screen,p_event);
1800                        break;
1801                }
1802        } else
1803        {
1804                result = bscreen_default_event(v_app,v_screen,p_event);
1805        }
1806
1807        return result;
1808}
1809
1810/*
1811Summary:
1812        Advanced captions reset screen event handler
1813Description:
1814        Advanced captions reset screen event handler
1815        .
1816*/
1817int screen_captions_reset_event(void *v_app, void *v_screen, 
1818                                                                bscreen_event_t *p_event)
1819{
1820        bapp_t *p_app = (bapp_t*)v_app;
1821        bscreen_t *p_screen = (bscreen_t*)v_screen;
1822        int result = 0;
1823
1824        if (p_event->type == eS_EVENT_SETUP)
1825        {
1826                bscreen_default_setup(v_app,v_screen);
1827                result = 1;     /* always handle event */
1828        } else if (p_event->type == eS_EVENT_IR)
1829        {
1830                switch (p_event->id)
1831                {
1832                case eIR_RIGHT:
1833                case eIR_SELECT:
1834                        if (p_screen->p_button_array[p_screen->button_selection].desc_text_id == eTEXT_CANCEL_INFO)
1835                        {
1836                                result = 1;
1837                                /* cannot call select_button() in this case since we do not want to save button history
1838                                 * this is unique for the eTEXT_CANCEL button since the button duplicates the 'back' functionality
1839                                 */
1840                                bapp_goto_last_screen(p_app);
1841                                //bapp_set_current_screen(p_app, p_screen->p_button_array[p_screen->button_selection].next_screen_id, eSCREEN_NULL);
1842                        } else
1843                        {
1844                                bapp_reset_cc_settings(p_app);
1845                                bapp_save_settings(p_app);
1846                                bapp_goto_last_screen(p_app);
1847                                result = 1;
1848                        }
1849                        break;
1850                case eIR_LEFT:
1851                case eIR_MENU:
1852                        result = 1;
1853                        bapp_goto_last_screen(p_app);
1854                        break;
1855                default:
1856                        result = bscreen_default_event(v_app,v_screen,p_event);
1857                        break;
1858                }
1859        } else
1860        {
1861                result = bscreen_default_event(v_app,v_screen,p_event);
1862        }
1863
1864        return result;
1865}
1866
1867/*
1868Summary:
1869        Ch scan progress screen event handler
1870Description:
1871        Ch scan progress screen event handler.
1872        .
1873*/
1874int screen_ch_scan_progress_event(void *v_app, void *v_screen, 
1875                                                                  bscreen_event_t *p_event)
1876{
1877        bapp_t *p_app = (bapp_t*)v_app;
1878        int result = 0;
1879
1880        if (p_event->type == eS_EVENT_SETUP)
1881        {
1882                p_app->tmp_value = 0; /* progress set at 0% */
1883                p_app->settings_dirty = true;
1884                result = 1;     /* always handle event */
1885        } else if (p_event->type == eS_EVENT_SETUP_DONE)
1886        {
1887                result = 1;     /* always handle event */
1888                if (p_app->ch_scan_type == eQUICK_SCAN)
1889                {
1890                        BDBG_MSG(("Doing QUICK scan using smart antenna\n"));
1891                } else /* eFULL_SCAN */
1892                {
1893                        BDBG_MSG(("Doing FULL scan using %s antenna\n", bant_detect() ? "smart" : "basic"));
1894                }
1895                bapp_channel_scan(p_app);
1896        } else if (p_event->type == eS_EVENT_PROGRESS)
1897        {
1898                int w, h;
1899                unsigned int num_chars;
1900                char strPercent[5];
1901                char strChFound[5];
1902
1903                /* reset screensaver timeout since we are making progress */
1904#ifdef CONFIG_SCREENSAVER
1905                p_app->last_keypress_tick = bos_getticks();
1906                printf("#### %s:%d 0x%08x ####\n",__FUNCTION__,__LINE__,TICKS_TO_MS(p_app->last_keypress_tick));
1907#endif
1908
1909                result = 0;     /* don't want top cause redraw */
1910                /* draw progress meter */
1911                bscreen_draw_progress(v_app, ePROGRESS_X, ePROGRESS_Y, ePROGRESS_WIDTH, ePROGRESS_HEIGHT, 
1912                                                          eBUTTON_PROGRESS_BORDER, eCOLOR_WHITE, eCOLOR_DRK_BLUE, p_event->id);
1913
1914                bapp_sync(p_app);
1915                /* draw percent compete text */
1916                num_chars = SCREEN_MAX_STR_WIDTH;
1917                snprintf(strPercent, 4, "%3d", p_event->id);
1918                strPercent[4] = 0;
1919                strPercent[3] = '%';
1920
1921                num_chars = c_to_uni_str(strPercent,p_app->tmp_str,num_chars);
1922                bgfx_string_info(p_app->p_font[p_app->lang][eFONT_SIZE_LARGE],(const unsigned long *)p_app->tmp_str,num_chars,&w,&h);
1923                bgfx_fill_rect(&p_app->surf,ePROGRESS_X + ePROGRESS_WIDTH + ePROGRESS_LABEL_SPACING,
1924                                           ePROGRESS_Y + (ePROGRESS_HEIGHT / 2) - (h / 2),w + 12, h + 2,eCOLOR_MED_BLUE);
1925                text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_MED],
1926                                                ePROGRESS_X + ePROGRESS_WIDTH + ePROGRESS_LABEL_SPACING, ePROGRESS_Y + (ePROGRESS_HEIGHT / 2) - (h / 2), 
1927                                                w + 10, h,  p_app->tmp_str,
1928                                                num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_DESC_TEXT_SPACING);
1929
1930                /* draw number of channels found */
1931                num_chars = SCREEN_MAX_STR_WIDTH;
1932                bscreen_get_string(p_app->lang,eTEXT_CH_SCAN_FOUND, p_app->tmp_str, &num_chars);
1933                bgfx_string_info(p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],(const unsigned long *)p_app->tmp_str,num_chars,&w,&h);
1934                snprintf(strChFound, 4, "%3d", p_app->settings.num_channels);
1935                num_chars = c_to_uni_str(strChFound,p_app->tmp_str,num_chars);
1936                bgfx_fill_rect(&p_app->surf,ePROGRESS_X + w,
1937                                           ePROGRESS_Y + (ePROGRESS_HEIGHT * 2),ePROGRESS_WIDTH - w - ePROGRESS_X + 2, h + 2,eCOLOR_MED_BLUE);
1938                text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
1939                                                ePROGRESS_X + w, ePROGRESS_Y + (ePROGRESS_HEIGHT * 2) , ePROGRESS_WIDTH - w - ePROGRESS_X, h,  p_app->tmp_str,
1940                                                num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_DESC_TEXT_SPACING);
1941                bapp_flush_screen(p_app);
1942
1943                if (p_event->id == 100)
1944                {
1945                        bapp_set_current_screen(p_app, eSCREEN_GUIDE, eSCREEN_CH_SCAN);
1946                        bapp_new_screen(p_app); /* Because the app event handling for progress will not cause new screen draw */
1947                        p_app->settings.wiz_completed = true;
1948                        result = 1;
1949                }
1950        } else if (p_event->type == eS_EVENT_IR)
1951        {
1952                switch (p_event->id)
1953                {
1954                case eIR_LEFT:
1955                case eIR_MENU:
1956                        result = 1;
1957                        chm_cmd(&p_app->chm,eCHM_CANCEL);
1958                        bapp_goto_last_screen(p_app);
1959                        break;
1960                }
1961        } else if ((p_event->type != eS_EVENT_SELECTED) &&
1962                           (p_event->type != eS_EVENT_CHECKED))
1963        {
1964                result = bscreen_default_event(v_app,v_screen,p_event);
1965        }
1966
1967        return result;
1968}
1969
1970/*
1971Summary:
1972        Language screen event handler
1973Description:
1974        Language screen event handler.
1975        .
1976*/
1977int screen_language_event(void *v_app, void *v_screen, 
1978                                                  bscreen_event_t *p_event)
1979{
1980        bapp_t *p_app = (bapp_t*)v_app;
1981        bscreen_t *p_screen = (bscreen_t*)v_screen;
1982        int result = 0;
1983
1984        if (p_event->type == eS_EVENT_SETUP)
1985        {
1986                bscreen_default_setup(v_app,v_screen);
1987                p_screen->button_checked = p_app->settings.language;
1988                result = 1;     /* always handle event */
1989        } else if (p_event->type == eS_EVENT_IR)
1990        {
1991                switch (p_event->id)
1992                {
1993                case eIR_RIGHT:
1994                case eIR_SELECT:
1995                        result = select_button(v_app,v_screen);
1996                        p_app->settings.language = p_screen->button_checked;
1997                        p_app->lang              = p_screen->button_checked;
1998                        p_app->settings_dirty    = true;
1999                        break;
2000                case eIR_LEFT:
2001                case eIR_MENU:
2002                        result = 1;
2003                        bapp_goto_last_screen(p_app);
2004                        break;
2005                default:
2006                        result = bscreen_default_event(v_app,v_screen,p_event);
2007                        break;
2008                }
2009        } else
2010        {
2011                result = bscreen_default_event(v_app,v_screen,p_event);
2012        }
2013
2014        return result;
2015}
2016
2017/*
2018Summary:
2019        Reset screen event handler
2020Description:
2021        Reset screen event handler.
2022        .
2023*/
2024int screen_reset_event(void *v_app, void *v_screen, 
2025                                           bscreen_event_t *p_event)
2026{
2027        bapp_t *p_app = (bapp_t*)v_app;
2028        bscreen_t *p_screen = (bscreen_t*)v_screen;
2029        int result = 0;
2030
2031        if (p_event->type == eS_EVENT_SETUP)
2032        {
2033                bscreen_default_setup(v_app,v_screen);
2034                result = 1;     /* always handle event */
2035        } else if (p_event->type == eS_EVENT_IR)
2036        {
2037                switch (p_event->id)
2038                {
2039                case eIR_RIGHT:
2040                case eIR_SELECT:
2041                        if (p_screen->p_button_array[p_screen->button_selection].desc_text_id == eTEXT_CANCEL_INFO)
2042                        {
2043                                result = 1;
2044                                /* cannot call select_button() in this case since we do not want to save button history
2045                                 * this is unique for the eTEXT_CANCEL button since the button duplicates the 'back' functionality
2046                                 */
2047                                bapp_set_current_screen(p_app, p_screen->p_button_array[p_screen->button_selection].next_screen_id, eSCREEN_NULL);
2048                        } else
2049                        {
2050                                bapp_reset_settings(p_app);
2051                                bapp_av_mute(p_app, 1);
2052                                bapp_save_settings(p_app);
2053                                bapp_set_current_screen(p_app, eSCREEN_WIZ_LANGUAGE, eSCREEN_NULL);
2054                                result = 1;
2055                        }
2056                        break;
2057                case eIR_LEFT:
2058                case eIR_MENU:
2059                        result = 1;
2060                        bapp_goto_last_screen(p_app);
2061                        break;
2062                default:
2063                        result = bscreen_default_event(v_app,v_screen,p_event);
2064                        break;
2065                }
2066        } else
2067        {
2068                result = bscreen_default_event(v_app,v_screen,p_event);
2069        }
2070
2071        return result;
2072}
2073
2074/*
2075Summary:
2076        Wiz welcome screen event handler
2077Description:
2078        Wiz welcome screen event handler.
2079        .
2080*/
2081int screen_wiz_welcome_event(void *v_app, void *v_screen, 
2082                                                         bscreen_event_t *p_event)
2083{
2084        bapp_t *p_app = (bapp_t*)v_app;
2085        int result = 0;
2086
2087        if (p_event->type == eS_EVENT_SETUP)
2088        {
2089                bscreen_default_setup(v_app,v_screen);
2090                p_app->settings_dirty = true;
2091                result = 1;     /* always handle event */
2092        } else if (p_event->type == eS_EVENT_IR)
2093        {
2094                switch (p_event->id)
2095                {
2096                case eIR_CH_UP:
2097                case eIR_RIGHT:
2098                case eIR_SELECT:
2099                        result = select_button(v_app,v_screen);
2100                        break;
2101                case eIR_LEFT:
2102                case eIR_MENU:
2103                        /*result = 1;*/
2104                        /*bapp_goto_last_screen(p_app);*/
2105                        break;
2106                case eIR_CH_DOWN:
2107                        result = next_button(v_app,v_screen,0); 
2108                        break;
2109                case eIR_UP:
2110                case eIR_DOWN:
2111                        break;
2112                default:
2113                        result = bscreen_default_event(v_app,v_screen,p_event);
2114                        break;
2115                }
2116        } else
2117        {
2118                result = bscreen_default_event(v_app,v_screen,p_event);
2119        }
2120
2121        return result;
2122}
2123
2124/*
2125Summary:
2126        Wiz Language screen event handler
2127Description:
2128        Wiz Language screen event handler.
2129        .
2130*/
2131int screen_wiz_language_event(void *v_app, void *v_screen, 
2132                                                          bscreen_event_t *p_event)
2133{
2134        bapp_t *p_app = (bapp_t*)v_app;
2135        bscreen_t *p_screen = (bscreen_t*)v_screen;
2136        int result = 0;
2137
2138        if (p_event->type == eS_EVENT_SETUP)
2139        {
2140                bscreen_default_setup(v_app,v_screen);
2141                result = 1;     /* always handle event */
2142        } else if (p_event->type == eS_EVENT_IR)
2143        {
2144                switch (p_event->id)
2145                {
2146                case eIR_CH_UP:
2147                case eIR_RIGHT:
2148                case eIR_SELECT:
2149                        /* we cannot blindly call select_button() here since we need to go to
2150                           different scan screens depending on the type of antenna attached */
2151                        bapp_set_current_screen(
2152                                                                   p_app, 
2153                                                                   (bant_detect() ? eSCREEN_WIZ_SMART_CH_SCAN : eSCREEN_WIZ_CH_SCAN),
2154                                                                   p_screen->p_button_array[p_screen->button_selection].next_screen_back_id);
2155
2156                        p_app->settings.language = p_screen->button_selection;
2157                        p_app->lang              = p_screen->button_selection;
2158                        p_app->settings_dirty    = true;
2159                        result = 1;
2160                        break;
2161                case eIR_CH_DOWN:
2162                        result = next_button(v_app,v_screen,0); 
2163                        break;
2164                case eIR_LEFT:
2165                case eIR_MENU:
2166                        /* do nothing since language screen is the 1st screen in thomson's wizard */
2167                        break;
2168                default:
2169                        result = bscreen_default_event(v_app,v_screen,p_event);
2170                        break;
2171                }
2172        } else
2173        {
2174                result = bscreen_default_event(v_app,v_screen,p_event);
2175        }
2176
2177        return result;
2178}
2179
2180/*
2181Summary:
2182        Wiz ch scan screen event handler
2183Description:
2184        Wiz ch scan screen event handler.
2185        .
2186*/
2187int screen_wiz_ch_scan_event(void *v_app, void *v_screen, 
2188                                                         bscreen_event_t *p_event)
2189{
2190        bapp_t *p_app = (bapp_t*)v_app;
2191        bscreen_t *p_screen = (bscreen_t*)v_screen;
2192        int result = 0;
2193
2194        if (p_event->type == eS_EVENT_SETUP)
2195        {
2196                bscreen_default_setup(v_app,v_screen);
2197                result = 1;     /* always handle event */
2198        } else if (p_event->type == eS_EVENT_IR)
2199        {
2200                switch (p_event->id)
2201                {
2202                case eIR_CH_UP:
2203                case eIR_RIGHT:
2204                case eIR_SELECT:
2205                        result = select_button(v_app,v_screen);
2206                        if (bant_detect())
2207                                p_app->ch_scan_type = (p_screen->button_selection ? eFULL_SCAN : eQUICK_SCAN);
2208                        else
2209                                p_app->ch_scan_type     = eFULL_SCAN;
2210                        break;
2211                case eIR_CH_DOWN:
2212                        result = next_button(v_app,v_screen,0); 
2213                        break;
2214                case eIR_LEFT:
2215                case eIR_MENU:
2216                        result = 1;
2217                        bapp_goto_last_screen(p_app);
2218                        break;
2219                default:
2220                        result = bscreen_default_event(v_app,v_screen,p_event);
2221                        break;
2222                }
2223        } else
2224        {
2225                result = bscreen_default_event(v_app,v_screen,p_event);
2226        }
2227
2228        return result;
2229}
2230
2231/*
2232Summary:
2233        Wiz done screen event handler
2234Description:
2235        Wiz done screen event handler.
2236        .
2237*/
2238int screen_wiz_done_event(void *v_app, void *v_screen, 
2239                                                  bscreen_event_t *p_event)
2240{
2241        bapp_t *p_app = (bapp_t*)v_app;
2242        int result = 0;
2243
2244        if (p_event->type == eS_EVENT_SETUP)
2245        {
2246                bscreen_default_setup(v_app,v_screen);
2247                result = 1;     /* always handle event */
2248        } else if (p_event->type == eS_EVENT_IR)
2249        {
2250                switch (p_event->id)
2251                {
2252                case eIR_CH_UP:
2253                case eIR_RIGHT:
2254                case eIR_SELECT:
2255                        result = select_button(v_app,v_screen);
2256                        p_app->settings.wiz_completed = true;
2257                        /* select exits to live tv so we must clear all the button selection history for all screens */
2258                        bapp_clear_screen_selection_history(p_app);
2259                        screen_null_draw(v_app, v_screen);
2260                        break;
2261                case eIR_CH_DOWN:
2262                        result = next_button(v_app,v_screen,0); 
2263                        break;
2264                case eIR_LEFT:
2265                case eIR_MENU:
2266                        result = 1;
2267                        bapp_goto_last_screen(p_app);
2268                        break;
2269                case eIR_UP:
2270                case eIR_DOWN:
2271                        break;
2272                default:
2273                        result = bscreen_default_event(v_app,v_screen,p_event);
2274                        break;
2275                }
2276        } else
2277        {
2278                result = bscreen_default_event(v_app,v_screen,p_event);
2279        }
2280
2281        return result;
2282}
2283
2284/*
2285Summary:
2286        auto power off screen event handler
2287Description:
2288        auto power off screen event handler.
2289        .
2290*/
2291int screen_auto_power_event(void *v_app, void *v_screen, 
2292                                                        bscreen_event_t *p_event)
2293{
2294        bapp_t *p_app = (bapp_t*)v_app;
2295        bscreen_t *p_screen = (bscreen_t*)v_screen;
2296        int result = 0;
2297
2298        if (p_event->type == eS_EVENT_SETUP)
2299        {
2300                bscreen_default_setup(v_app,v_screen);
2301                p_screen->button_checked = p_app->settings.auto_power;
2302                result = 1;     /* always handle event */
2303        } else if (p_event->type == eS_EVENT_IR)
2304        {
2305                switch (p_event->id)
2306                {
2307                case eIR_RIGHT:
2308                case eIR_SELECT:
2309                        result = select_button(v_app,v_screen);
2310                        p_app->settings.auto_power = p_screen->button_checked;
2311                        p_app->settings_dirty = true;
2312                        if (p_app->settings.auto_power_off)
2313                        {
2314                                p_app->settings.auto_power_off = 0;
2315                                bapp_save_settings(p_app);
2316                                bapp_set_current_screen(p_app, eSCREEN_BANNER_SMALL, eSCREEN_NULL);
2317                        }
2318                        result = 1;
2319                        break;
2320                case eIR_LEFT:
2321                case eIR_MENU:
2322                        result = 1;
2323                        if (p_app->settings.auto_power_off)
2324                        {
2325                                p_app->settings.auto_power_off = 0;
2326                                bapp_save_settings(p_app);
2327                                bapp_set_current_screen(p_app, eSCREEN_BANNER_SMALL, eSCREEN_NULL);
2328                        } else
2329                                bapp_goto_last_screen(p_app);
2330                        break;
2331                default:
2332                        result = bscreen_default_event(v_app,v_screen,p_event);
2333                        break;
2334                }
2335        } else
2336        {
2337                result = bscreen_default_event(v_app,v_screen,p_event);
2338        }
2339
2340        return result;
2341}
2342
2343/*
2344Summary:
2345        Ratings screen event handler
2346Description:
2347        Ratings screen event handler.
2348        .
2349*/
2350int screen_ratings_event(void *v_app, void *v_screen, 
2351                                                 bscreen_event_t *p_event)
2352{
2353        bapp_t *p_app = (bapp_t*)v_app;
2354        int result = 0;
2355
2356        if (p_event->type == eS_EVENT_SETUP)
2357        {
2358                bscreen_default_setup(v_app,v_screen);
2359
2360                result = 1;     /* always handle event */
2361        } else if (p_event->type == eS_EVENT_IR)
2362        {
2363                switch (p_event->id)
2364                {
2365                case eIR_RIGHT:
2366                case eIR_SELECT:
2367                        result = select_button(v_app,v_screen);
2368                        break;
2369                case eIR_LEFT:
2370                case eIR_MENU:
2371                        result = 1;
2372                        bapp_goto_last_screen(p_app);
2373                        break;
2374                default:
2375                        result = bscreen_default_event(v_app,v_screen,p_event);
2376                        break;
2377                }
2378        } else
2379        {
2380                result = bscreen_default_event(v_app,v_screen,p_event);
2381        }
2382
2383        return result;
2384}
2385
2386/*
2387Summary:
2388        Ratings Lock screen event handler
2389Description:
2390        Ratings Lock screen event handler.
2391        .
2392*/
2393int screen_ratings_lock_event(void *v_app, void *v_screen, 
2394                                                          bscreen_event_t *p_event)
2395{
2396        bapp_t *p_app = (bapp_t*)v_app;
2397        bscreen_t *p_screen = (bscreen_t*)v_screen;
2398        int result = 0;
2399
2400        if (p_event->type == eS_EVENT_SETUP)
2401        {
2402                bscreen_default_setup(v_app,v_screen);
2403                p_screen->button_checked = p_app->settings.ratings_lock;
2404                result = 1;     /* always handle event */
2405        } else if (p_event->type == eS_EVENT_IR)
2406        {
2407                switch (p_event->id)
2408                {
2409                case eIR_RIGHT:
2410                case eIR_SELECT:
2411                        result = select_button(v_app,v_screen);
2412                        p_app->settings.ratings_lock = p_screen->button_checked;
2413                        p_app->settings_dirty = true;
2414                        break;
2415                case eIR_LEFT:
2416                case eIR_MENU:
2417                        result = 1;
2418                        bapp_goto_last_screen(p_app);
2419                        break;
2420                default:
2421                        result = bscreen_default_event(v_app,v_screen,p_event);
2422                        break;
2423                }
2424        } else
2425        {
2426                result = bscreen_default_event(v_app,v_screen,p_event);
2427        }
2428
2429        return result;
2430}
2431
2432/*
2433Summary:
2434        Ratings limits screen event handler
2435Description:
2436        Ratings limits screen event handler.
2437        .
2438*/
2439int screen_ratings_limits_event(void *v_app, void *v_screen, 
2440                                                                bscreen_event_t *p_event)
2441{
2442        bapp_t *p_app = (bapp_t*)v_app;
2443        bscreen_t *p_screen = (bscreen_t*)v_screen;
2444        int result = 0;
2445
2446        if (p_event->type == eS_EVENT_SETUP)
2447        {
2448                /* remove rrt ratings button if unavailable */
2449                if (p_app->settings.ratings_lock != 2)
2450                        p_screen->num_buttons = g_buttons_ratings_limits_num - 1;
2451                else
2452                        p_screen->num_buttons = g_buttons_ratings_limits_num;
2453
2454                bscreen_default_setup(v_app,v_screen);
2455                result = 1;     /* always handle event */
2456        } else if (p_event->type == eS_EVENT_IR)
2457        {
2458                switch (p_event->id)
2459                {
2460                case eIR_RIGHT:
2461                case eIR_SELECT:
2462                        result = select_button(v_app,v_screen);
2463                        break;
2464                case eIR_LEFT:
2465                case eIR_MENU:
2466                        result = 1;
2467                        bapp_goto_last_screen(p_app);
2468                        break;
2469                default:
2470                        result = bscreen_default_event(v_app,v_screen,p_event);
2471                        break;
2472                }
2473        } else
2474        {
2475                result = bscreen_default_event(v_app,v_screen,p_event);
2476        }
2477
2478        return result;
2479}
2480
2481/*
2482Summary:
2483        Convert from button position to RRT TV ratings dimension
2484Description:
2485        Convert from button position to RRT TV ratings dimension
2486*/
2487const int screen_ratings_tv_pos2dim(int button_position)
2488{
2489        const int pos2dim[g_buttons_ratings_tv_num] = { 
2490                /*  rat D  L  S  V  FV */
2491                /* tv-y  */ 5,
2492                /* tv-y7 */ 5,              6,
2493                /* tv-g  */ 0,
2494                /* tv-pg */ 0,  1, 2, 3, 4,
2495                /* tv-14 */ 0,  1, 2, 3, 4,
2496                /* tv-ma */ 0,     2, 3, 4
2497        };
2498
2499        if ((button_position < 0) || (button_position > sizeof(pos2dim)))
2500                return -1;
2501
2502        return(pos2dim[button_position]);
2503}
2504
2505/*
2506Summary:
2507        Convert from button position to RRT TV ratings value
2508Description:
2509        Convert from button position to RRT TV ratings value
2510*/
2511const int screen_ratings_tv_pos2value(int button_position)
2512{
2513        const int pos2value[g_buttons_ratings_tv_num] = {
2514                /*  rat D  L  S  V  FV */
2515                /* tv-y  */ 1,
2516                /* tv-y7 */ 2,              1,
2517                /* tv-g  */ 2,
2518                /* tv-pg */ 3,  1, 1, 1, 1,
2519                /* tv-14 */ 4,  1, 1, 1, 1,
2520                /* tv-ma */ 5,     1, 1, 1
2521        };
2522
2523        if ((button_position < 0) || (button_position > sizeof(pos2value)))
2524                return -1;
2525
2526        return(pos2value[button_position]);
2527}
2528
2529/*
2530Summary:
2531        Convert xds tv ratings to psip grid position
2532Description:
2533        Convert xds tv ratings to psip grid position
2534*/
2535const int screen_ratings_tv_xds2pos(int xds_tv_rating)
2536{
2537        const int tv_xds2pos[8] = {
2538                /* none  */ -1,
2539                /* tv-y  */ ePOS_TV_Y, 
2540                /* tv-y7 */ ePOS_TV_Y7, 
2541                /* tv-g  */ ePOS_TV_G, 
2542                /* tv-pg */ ePOS_TV_PG, 
2543                /* tv-14 */ ePOS_TV_14, 
2544                /* tv-ma */ ePOS_TV_MA,
2545                /* none  */ -1
2546        };
2547
2548        if ((xds_tv_rating < 0) || (xds_tv_rating > sizeof(tv_xds2pos)))
2549                return -1;
2550
2551        return(tv_xds2pos[xds_tv_rating]);
2552}
2553
2554/*
2555Summary:
2556        Convert xds movie ratings to psip grid position
2557Description:
2558        Convert xds movie ratings to psip grid position
2559*/
2560const int screen_ratings_movie_xds2pos(int xds_movie_rating)
2561{
2562        const int movie_xds2pos[8] = {
2563                /* none  */ -1,
2564                /* G     */ 0, 
2565                /* PG    */ 1, 
2566                /* PG-13 */ 2, 
2567                /* R     */ 3, 
2568                /* NC-17 */ 4, 
2569                /* X     */ 5,
2570                /* NR    */ 6
2571        };
2572
2573        if ((xds_movie_rating < 0) || (xds_movie_rating > sizeof(movie_xds2pos)))
2574                return -1;
2575
2576        return(movie_xds2pos[xds_movie_rating]);
2577}
2578
2579/*
2580Summary:
2581        Ratings TV screen event handler
2582Description:
2583        Ratings TV screen event handler.
2584        .
2585*/
2586int screen_ratings_tv_event(void *v_app, void *v_screen, 
2587                                                        bscreen_event_t *p_event)
2588{
2589        bapp_t *p_app = (bapp_t*)v_app;
2590        bscreen_t *p_screen = (bscreen_t*)v_screen;
2591        int result = 0;
2592
2593        if (p_event->type == eS_EVENT_SETUP)
2594        {
2595                bscreen_default_setup(v_app,v_screen);
2596                result = 1;     /* always handle event */
2597        } else if (p_event->type == eS_EVENT_IR)
2598        {
2599                /* button layout is fixed for US tv ratings.  button position is used
2600                   in the following tables for navigation and auto block/unblock. 
2601                   this is what the button numbering looks like:
2602
2603                                        rat  D   L   S   V   FV
2604                                       
2605                        tv-y    0
2606                        tv-y7   1                    2
2607                        tv-g    3
2608                        tv-pg   4    5   6   7   8
2609                        tv-14   9   10  11  12  13
2610                        tv-ma  14       15  16  17
2611                */
2612
2613                /* define button navigation in up direction */
2614                const int up[g_buttons_ratings_tv_num] = { 
2615                        /* rat   D   L   S   V  FV */
2616/* tv-y  */ 14,
2617/* tv-y7 */  0,                  0,
2618/* tv-g  */  1,
2619/* tv-pg */  3,  3,  3,  2,  2,
2620/* tv-14 */  4,  5,  6,  7,  8,
2621/* tv-ma */  9,     11, 12, 13
2622                };
2623
2624                /* define button navigation in down direction */
2625                const int down[g_buttons_ratings_tv_num] = {
2626                        /* rat   D   L   S   V  FV */
2627/* tv-y  */  1,
2628/* tv-y7 */  3,                  8,
2629/* tv-g  */  4,
2630/* tv-pg */  9, 10, 11, 12, 13,
2631/* tv-14 */ 14, 14, 15, 16, 17,
2632/* tv-ma */  0,      0,  0,  0
2633                };
2634
2635                /* define auto block for each button */
2636                const int block[g_buttons_ratings_tv_num][g_buttons_ratings_tv_num + 1] = {
2637                        /*  rat                                                     D            L               S               V               FV */
2638/* tv-y  */ {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, -1},
2639/* tv-y7 */ {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, -1},                                                     {2, -1},
2640/* tv-g  */ {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, -1}, 
2641/* tv-pg */ {4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, -1}, {5, 10, -1}, {6, 11, 15, -1},{7, 12, 16, -1},{8, 13, 17, -1},
2642/* tv-14 */ {9, 10, 11, 12, 13, 14, 15, 16, 17, -1},                {10, -1},    {11, 15, -1},   {12, 16, -1},   {13, 17, -1},
2643/* tv-ma */ {14, 15, 16, 17, -1},                                                {15, -1},       {16, -1},       {17, -1}
2644                };
2645
2646                /* define auto unblock for each button */
2647                const int unblock[g_buttons_ratings_tv_num][g_buttons_ratings_tv_num + 1] = {
2648                        /*  rat                                                                 D                               L                                    S                                    V                                    FV */
2649/* tv-y  */ {0, -1},
2650/* tv-y7 */ {0, 1, 2, -1},                                                                                                                                                                                                     {0, 1, 2, -1},
2651/* tv-g  */ {0, 1, 2, 3, -1},
2652/* tv-pg */ {0, 1, 2, 3, 4, 5, 6, 7, 8, -1},                                    {0, 1, 3, 4, 5, -1},            {0, 1, 3, 4, 6, -1},                {0, 1, 3, 4, 7, -1},                  {0, 1, 3, 4, 8, -1},
2653/* tv-14 */ {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, -1},                 {0, 1, 3, 4, 5, 9, 10, -1},     {0, 1, 3, 4, 6, 9, 11, -1},         {0, 1, 3, 4, 7, 9, 12, -1},           {0, 1, 3, 4, 8, 9, 13, -1},
2654/* tv-ma */ {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, -1},                                 {0, 1, 3, 4, 6, 9, 11, 14, 15, -1}, {0, 1, 3, 4, 7, 9, 12, 14, 16, -1},   {0, 1, 3, 4, 8, 9, 13, 14, 17, -1}
2655                };
2656
2657                switch (p_event->id)
2658                {
2659                case eIR_SELECT:
2660                        {
2661                                int i = 0;
2662
2663                                if (p_app->settings.ratings_tv & ((0 | (0x1) << p_screen->button_selection)))
2664                                {
2665                                        /* selected rating already blocked so unblock it */
2666                                        for (i = 0; unblock[p_screen->button_selection][i] >= 0; i++)
2667                                        {
2668                                                p_app->settings.ratings_tv &= ~(0 | (0x1) << unblock[p_screen->button_selection][i]);
2669                                        }
2670                                } else
2671                                {
2672                                        /* selected rating unblocked so block it */
2673                                        for (i = 0; block[p_screen->button_selection][i] >= 0; i++)
2674                                        {
2675                                                p_app->settings.ratings_tv |= (0 | (0x1) << block[p_screen->button_selection][i]);
2676                                        }
2677                                }
2678
2679                                p_app->settings_dirty = true;
2680                                result = select_button(v_app,v_screen);
2681
2682                                p_app->ratings_override         = false;
2683                                /* reset so ratings will be re-evaluated when returned to full tv */
2684                                p_app->last_rating_block_status = -1;
2685                                /* assume psip unblock */
2686                                p_app->last_psip_rating_block_status = 0;
2687                        }
2688                        break;
2689                case eIR_RIGHT:
2690                        result = next_button(v_app,v_screen,0);
2691                        break;
2692                case eIR_LEFT:
2693                        result = next_button(v_app,v_screen,1);
2694                        break;
2695                case eIR_UP:
2696                        result = focus_button(v_app,v_screen,up[p_screen->button_selection]);
2697                        break;
2698                case eIR_DOWN:
2699                        result = focus_button(v_app,v_screen,down[p_screen->button_selection]);
2700                        break;
2701                case eIR_MENU:
2702                        result = 1;
2703                        bapp_goto_last_screen(p_app);
2704                        break;
2705                case eIR_0:  case eIR_1: case eIR_2: case eIR_3:
2706                case eIR_4: case eIR_5: case eIR_6: case eIR_7: case eIR_8: case eIR_9:
2707                        result = 0;
2708                        break;
2709
2710                default:
2711                        result = bscreen_default_event(v_app,v_screen,p_event);
2712                        break;
2713                }
2714        } else if (p_event->type == eS_EVENT_CHECKED)
2715        {
2716                result = ((p_app->settings.ratings_tv >> p_event->id) & (0 | (0x1)));
2717                BDBG_MSG(("checked status button#: %d checked:%d", p_event->id, result));
2718        } else
2719        {
2720                result = bscreen_default_event(v_app,v_screen,p_event);
2721        }
2722
2723        return result;
2724}
2725
2726
2727/*
2728Summary:
2729        Ratings TV screen event handler
2730Description:
2731        Ratings TV screen event handler.
2732        .
2733*/
2734int screen_ratings_movies_event(void *v_app, void *v_screen, 
2735                                                                bscreen_event_t *p_event)
2736{
2737        bapp_t *p_app = (bapp_t*)v_app;
2738        bscreen_t *p_screen = (bscreen_t*)v_screen;
2739        int result = 0;
2740
2741        if (p_event->type == eS_EVENT_SETUP)
2742        {
2743                bscreen_default_setup(v_app,v_screen);
2744                result = 1;     /* always handle event */
2745        } else if (p_event->type == eS_EVENT_IR)
2746        {
2747                switch (p_event->id)
2748                {
2749                case eIR_RIGHT:
2750                case eIR_SELECT:
2751                        {
2752                                int i = 0;
2753                                if (p_app->settings.ratings_movies & ((0 | (0x1) << p_screen->button_selection)))
2754                                {
2755                                        /* selected rating already blocked so unblock it */
2756                                        for (i = p_screen->button_selection; i >= 0; i--)
2757                                        {
2758                                                p_app->settings.ratings_movies &= ~(0 | (0x1) << i);
2759                                        }
2760                                } else
2761                                {
2762                                        /* selected rating unblocked so block it */
2763                                        for (i = p_screen->button_selection; i < g_buttons_ratings_movies_num; i++)
2764                                        {
2765                                                p_app->settings.ratings_movies |= (0 | (0x1) << i);
2766                                        }
2767                                }
2768                        }
2769
2770                        p_app->settings_dirty = true;
2771                        result = select_button(v_app,v_screen);
2772                        /* ratings changed so invalidate current rating */
2773                        p_app->last_cad            = 0;
2774                        p_app->last_rating_tick    = 0;
2775                        break;
2776                case eIR_LEFT:
2777                case eIR_MENU:
2778                        result = 1;
2779                        bapp_goto_last_screen(p_app);
2780                        break;
2781                default:
2782                        result = bscreen_default_event(v_app,v_screen,p_event);
2783                        break;
2784                }
2785        } else if (p_event->type == eS_EVENT_CHECKED)
2786        {
2787                result = ((p_app->settings.ratings_movies >> p_event->id) & (0 | (0x1)));
2788        } else
2789        {
2790                result = bscreen_default_event(v_app,v_screen,p_event);
2791        }
2792
2793        return result;
2794}
2795
2796/*
2797Summary:
2798        Ratings RRT dimension screen event handler
2799Description:
2800        Ratings RRT dimension screen event handler.
2801        .
2802*/
2803int screen_ratings_rrt_dim_event(void *v_app, void *v_screen, 
2804                                                                 bscreen_event_t *p_event)
2805{
2806        bapp_t *p_app = (bapp_t*)v_app;
2807        bscreen_t *p_screen = (bscreen_t*)v_screen;
2808        int result = 0;
2809        PSIP_RRT_header header;
2810        int num_buttons;
2811
2812        if (p_event->type == eS_EVENT_SETUP)
2813        {
2814                bscreen_default_setup(v_app,v_screen);
2815#ifdef TEST_RRT
2816                header.dimensions_defined = MAX_RRT_DIM;
2817#else
2818                PSIP_RRT_getHeader(p_app->settings.rrt, &header);
2819#endif
2820                num_buttons = SCREEN_MIN(p_screen->num_buttons,header.dimensions_defined);
2821                if ((p_screen->local_state + MAX_RRT_DIM_BUTTONS) >= header.dimensions_defined)
2822                {
2823                        p_screen->local_state = 0;
2824                }
2825                if (p_screen->button_selection >= num_buttons)
2826                {
2827                        p_screen->button_selection = 0;
2828                }
2829                result = 1;     /* always handle event */
2830        } else if (p_event->type == eS_EVENT_IR)
2831        {
2832                switch (p_event->id)
2833                {
2834                case eIR_RIGHT:
2835                case eIR_SELECT:
2836                        result = select_button(v_app,v_screen);
2837                        break;
2838                case eIR_LEFT:
2839                case eIR_MENU:
2840                        result = 1;
2841                        bapp_goto_last_screen(p_app);
2842                        break;
2843                case eIR_UP:
2844                        {
2845                                unsigned int next_button = p_screen->button_selection;
2846
2847                                if (p_screen->button_selection == 0)
2848                                {
2849                                        if (p_screen->local_state > 0)
2850                                        {
2851                                                p_screen->local_state--;
2852                                        }
2853                                }
2854                                else
2855                                        next_button--;
2856
2857                                p_screen->button_selection = next_button;
2858                                result = 1;
2859                        }
2860                        break;
2861                case eIR_DOWN:
2862                        {
2863                                unsigned int next_button = p_screen->button_selection;
2864#ifdef TEST_RRT
2865                                header.dimensions_defined = MAX_RRT_DIM;
2866#else
2867                                PSIP_RRT_getHeader(p_app->settings.rrt, &header);
2868#endif
2869                                num_buttons = SCREEN_MIN(p_screen->num_buttons,header.dimensions_defined);
2870                                if (p_screen->button_selection == (num_buttons - 1))
2871                                {
2872#ifdef TEST_RRT
2873                                        if ((p_screen->local_state + MAX_RRT_DIM_BUTTONS) < MAX_RRT_DIM)
2874                                                p_screen->local_state++;
2875#else
2876                                        PSIP_RRT_getHeader(p_app->settings.rrt, &header);
2877                                        if ((p_screen->local_state + MAX_RRT_DIM_BUTTONS) < header.dimensions_defined)
2878                                                p_screen->local_state++;
2879#endif
2880                                }
2881                                else
2882                                        next_button++;
2883
2884                                p_screen->button_selection = next_button;
2885                                result = 1;
2886                        }
2887                        break;
2888                case eIR_0:  case eIR_1: case eIR_2: case eIR_3:
2889                case eIR_4: case eIR_5: case eIR_6: case eIR_7: case eIR_8: case eIR_9:
2890                        result = 0;
2891                        break;
2892
2893                default:
2894                        result = bscreen_default_event(v_app,v_screen,p_event);
2895                        break;
2896                }
2897        } else
2898        {
2899                result = bscreen_default_event(v_app,v_screen,p_event);
2900        }
2901
2902        return result;
2903}
2904
2905/*
2906Summary:
2907        Ratings RRT value screen event handler
2908Description:
2909        Ratings RRT value screen event handler.  buttons for the rrt value screen are
2910        dynamically created - so we cannot use the typical navigation functions other "event"
2911        functions use. 
2912        .
2913*/
2914int screen_ratings_rrt_val_event(void *v_app, void *v_screen, 
2915                                                                 bscreen_event_t *p_event)
2916{
2917        bapp_t    * p_app    = (bapp_t*)v_app;
2918        bscreen_t * p_screen = (bscreen_t*)v_screen;
2919        int         dim_idx  = p_app->p_screens[eSCREEN_RATINGS_RRT_DIM].button_selection + p_app->p_screens[eSCREEN_RATINGS_RRT_DIM].local_state;
2920        int         result   = 0;
2921        PSIP_RRT_dimension dim;
2922        int i = 0;
2923        int grad = 0;
2924        unsigned int num_buttons = 0;
2925
2926        if (p_event->type != eS_EVENT_IDLE)
2927        {
2928        #ifdef TEST_RRT
2929                dim.values_defined = MAX_RRT_VAL;
2930                if (dim_idx & 1)
2931                        grad = 0 ;
2932                else
2933                        grad = 1;
2934        #else
2935                if (PSIP_RRT_getDimension(p_app->settings.rrt, dim_idx,&dim) != BERR_SUCCESS)
2936                {
2937                        dim.values_defined = 0;
2938                }
2939                else
2940                {
2941                        grad = dim.graduated_scale;
2942                }
2943        #endif
2944                num_buttons = SCREEN_MIN(p_screen->num_buttons,dim.values_defined);
2945        }
2946
2947        if (p_event->type == eS_EVENT_SETUP)
2948        {
2949                bscreen_default_setup(v_app,v_screen);
2950                if ((p_screen->local_state + MAX_RRT_VAL_BUTTONS) >= dim.values_defined)
2951                {
2952                        p_screen->local_state = 0;
2953                }
2954                if (p_screen->button_selection >= num_buttons)
2955                {
2956                        p_screen->button_selection = 0;
2957                }
2958                result = 1;     /* always handle event */
2959        } else if (p_event->type == eS_EVENT_IR)
2960        {
2961                switch (p_event->id)
2962                {
2963                case eIR_RIGHT:
2964                case eIR_SELECT:
2965                        {
2966                                BDBG_MSG(("rating dimension graduated_scale:%d\n", grad));
2967
2968                                if (p_app->settings.ratings_rrt[dim_idx] & (1 << (p_screen->local_state + p_screen->button_selection)))
2969                                {
2970                                        /* selected rating already blocked so unblock it */
2971                                        if (grad)
2972                                        {
2973                                                for (i = (p_screen->local_state + p_screen->button_selection); i >= 0; i--)
2974                                                {
2975                                                        p_app->settings.ratings_rrt[dim_idx] &= ~(1 << i);
2976                                                }
2977                                        } else
2978                                        {
2979                                                p_app->settings.ratings_rrt[dim_idx] &= ~(1 << (p_screen->local_state + p_screen->button_selection));
2980                                        }
2981                                } else
2982                                {
2983                                        /* selected rating unblocked so block it */
2984                                        if (grad)
2985                                        {
2986                                                for (i = (p_screen->local_state + p_screen->button_selection); i < dim.values_defined; i++)
2987                                                {
2988                                                        p_app->settings.ratings_rrt[dim_idx] |= (1 << i);
2989                                                }
2990                                        } else
2991                                        {
2992                                                p_app->settings.ratings_rrt[dim_idx] |= (1 << (p_screen->local_state + p_screen->button_selection));
2993                                        }
2994                                }
2995
2996                                p_app->settings_dirty = true;
2997                                //result = select_button(v_app,v_screen);
2998                                {
2999                                        bscreen_event_t event;
3000                                        int checked = 0;
3001
3002                                        event.id = p_screen->button_selection;
3003                                        event.type = eS_EVENT_CHECKED;
3004                                        checked = p_screen->handle_event(p_app,p_screen,&event);
3005
3006                                        p_screen->button_checked = p_screen->button_selection;
3007                                }
3008                                p_app->ratings_override         = false;
3009                                /* reset so ratings will be re-evaluated when returned to full tv */
3010                                p_app->last_rating_block_status    =    -1;
3011                                /* assume psip unblock */
3012                                p_app->last_psip_rating_block_status = 0;
3013                                result = 1;     /* always handle event */
3014                        }
3015                        break;
3016                case eIR_LEFT:
3017                case eIR_MENU:
3018                        result = 1;
3019                        bapp_goto_last_screen(p_app);
3020                        break;
3021                case eIR_UP:
3022                        {
3023                                unsigned int next_button = p_screen->button_selection;
3024
3025                                if (p_screen->button_selection == 0)
3026                                {
3027                                        if (p_screen->local_state > 0)
3028                                        {
3029                                                p_screen->local_state--;
3030                                        }
3031                                }
3032                                else
3033                                        next_button--;
3034
3035                                p_screen->button_selection = next_button;
3036                                result = 1;
3037                        }
3038                        break;
3039                case eIR_DOWN:
3040                        {
3041                                unsigned int next_button = p_screen->button_selection;
3042                                if (p_screen->button_selection == (num_buttons - 1))
3043                                {
3044#ifdef TEST_RRT
3045                                        if ((p_screen->local_state + MAX_RRT_VAL_BUTTONS) < MAX_RRT_VAL)
3046                                                p_screen->local_state++;
3047#else
3048                                        PSIP_RRT_dimension dim;
3049                                        if (PSIP_RRT_getDimension(p_app->settings.rrt,dim_idx,&dim) != BERR_SUCCESS)
3050                                                dim.values_defined = 0;
3051                                        if ((p_screen->local_state + MAX_RRT_VAL_BUTTONS) < dim.values_defined)
3052                                                p_screen->local_state++;
3053#endif
3054                                }
3055                                else
3056                                        next_button++;
3057
3058                                p_screen->button_selection = next_button;
3059                                result = 1;
3060                        }
3061                        break;
3062               
3063                case eIR_0:  case eIR_1: case eIR_2: case eIR_3:
3064                case eIR_4: case eIR_5: case eIR_6: case eIR_7: case eIR_8: case eIR_9:
3065                        result = 0;
3066                        break;
3067               
3068                default:
3069                        result = bscreen_default_event(v_app,v_screen,p_event);
3070                        break;
3071                }
3072        } else if (p_event->type == eS_EVENT_CHECKED)
3073        {
3074                result = (p_app->settings.ratings_rrt[dim_idx] & (1 << p_screen->button_selection)) ? 1 : 0;
3075        } else
3076        {
3077                result = bscreen_default_event(v_app,v_screen,p_event);
3078        }
3079
3080        return result;
3081}
3082
3083/*
3084Summary:
3085        RRT Ratings update screen event handler
3086Description:
3087        RRT Ratings update screen event handler
3088        .
3089*/
3090int screen_ratings_rrt_update_event(void *v_app, void *v_screen, 
3091                                                                        bscreen_event_t *p_event)
3092{
3093        bapp_t *p_app = (bapp_t*)v_app;
3094        int result = 0;
3095
3096        if (p_event->type == eS_EVENT_SETUP)
3097        {
3098                bscreen_default_setup(v_app,v_screen);
3099                result = 1;     /* always handle event */
3100        } else if (p_event->type == eS_EVENT_IR)
3101        {
3102                switch (p_event->id)
3103                {
3104                case eIR_RIGHT:
3105                case eIR_SELECT:
3106                        result = select_button(v_app,v_screen);
3107                        break;
3108                case eIR_LEFT:
3109                case eIR_MENU:
3110                        result = 1;
3111                        bapp_goto_last_screen(p_app);
3112                        break;
3113                default:
3114                        result = bscreen_default_event(v_app,v_screen,p_event);
3115                        break;
3116                }
3117        } else
3118        {
3119                result = bscreen_default_event(v_app,v_screen,p_event);
3120        }
3121
3122        return result;
3123}
3124
3125/*
3126Summary:
3127        pin entry screen event handler                     
3128Description:
3129        pin entry screen event handler.
3130        .
3131*/
3132int screen_pin_event(void *v_app, void *v_screen, 
3133                                         bscreen_event_t *p_event)
3134{
3135        bapp_t *p_app = (bapp_t*)v_app;
3136        bscreen_t *p_screen = (bscreen_t*)v_screen;
3137        int result = 0;
3138        static unsigned int pin = 0;
3139        static unsigned int pin_pending = 0;
3140        static unsigned int pin_override = 0;
3141
3142        if (p_event->type == eS_EVENT_SETUP)
3143        {
3144                /* this popup may display without a corresponding keypress
3145                   so reset screensaver timeout value manually */
3146#ifdef CONFIG_SCREENSAVER
3147                p_app->last_keypress_tick = bos_getticks(); 
3148                printf("#### %s:%d 0x%08x ####\n",__FUNCTION__,__LINE__,TICKS_TO_MS(p_app->last_keypress_tick));
3149#endif
3150                p_app->tmp_value = 0; /* select first pin digit field */
3151                result = 1;     /* always handle event */
3152        } else if (p_event->type == eS_EVENT_REDRAW)
3153        {
3154                bapp_sync(p_app);
3155                p_app->p_screens[p_app->screen_id].draw(p_app,(void*)&(p_app->p_screens[p_app->screen_id]));
3156                bapp_flush_screen(p_app);
3157        } else if (p_event->type == eS_EVENT_IR)
3158        {
3159                BDBG_MSG(("event ir id: %d\n", p_event->id));
3160                switch (p_event->id)
3161                {
3162                case eIR_MENU:
3163                        /* disable 'back' functionality for live pin verification */
3164                        if ((p_app->screen_id == eSCREEN_PIN_VERIFY_LIVE) ||
3165                                (p_app->screen_id == eSCREEN_WRONG_PIN_LIVE))
3166                        {
3167                                bapp_set_current_screen(p_app, eSCREEN_MAIN, eSCREEN_NULL);
3168                        } else
3169                        {
3170                                bapp_goto_last_screen(p_app);
3171                        }
3172                        result = 1;
3173                        break;
3174                case eIR_CH_UP:
3175                        if (p_app->screen_id == eSCREEN_PIN_VERIFY_LIVE)
3176                        {
3177                                bapp_change_channel(p_app,1,1);
3178                                bapp_set_current_screen(p_app, eSCREEN_NULL, eSCREEN_NULL);
3179                                result = 1;
3180                        } else if (p_app->screen_id == eSCREEN_WIZ_PIN_NEW)
3181                        {
3182                                /*  + key will skip pin entry using 0000 as pin,
3183                                this is to handle operation without remote on ACB335 per Aonvision request. */
3184                                bapp_set_current_screen(p_app, eSCREEN_WIZ_DONE, eSCREEN_PIN_NEW);
3185
3186                                p_app->settings.pin = 0;
3187                                p_app->settings_dirty = true;
3188                                result = 1;
3189                                /* reset pin values */
3190                                pin = 0;
3191                                p_app->tmp_value = 0; /* select first pin digit field */
3192                        }
3193
3194                        break;
3195                case eIR_CH_DOWN:
3196                        if (p_app->screen_id == eSCREEN_PIN_VERIFY_LIVE)
3197                        {
3198                                bapp_change_channel(p_app,0,1);
3199                                bapp_set_current_screen(p_app, eSCREEN_NULL, eSCREEN_NULL);
3200                                result = 1;
3201                        }
3202                        break;
3203                case eIR_ENTER:
3204                        if (p_app->screen_id == eSCREEN_PIN_VERIFY_LIVE)
3205                        {
3206                                /* channel jump - swap last and current channel numbers */
3207                                unsigned int tmp_ch_num = p_app->cur_ch_num;
3208                                p_app->cur_ch_num = p_app->last_ch_num;
3209                                p_app->last_ch_num = tmp_ch_num;
3210                                bapp_tune(p_app);
3211                                bapp_set_current_screen(p_app, eSCREEN_NULL, eSCREEN_NULL);
3212                                result = 1;
3213                        }
3214                        break;
3215                case eIR_LEFT:
3216                        if (p_app->tmp_value > 0)
3217                        {
3218                                result = 1;
3219                                (p_app->tmp_value)--; /* erase one entered pin digit */
3220                                pin &= ~(0 | (0xff)<<(p_app->tmp_value * 8));
3221
3222                                /* force draw of only changed pin fields */
3223                                bscreen_draw_pin(v_app, ePIN_X, ePIN_Y+(p_screen->top_banner_height-eMENU_TITLE_AREA_HEIGHT_1_LINE)/2, 
3224                                                                 ePIN_WIDTH, ePIN_HEIGHT, ePIN_INC_X, p_app->tmp_value, p_app->tmp_value + 1);
3225                                bscreen_draw_pin(v_app, ePIN_X, ePIN_Y+(p_screen->top_banner_height-eMENU_TITLE_AREA_HEIGHT_1_LINE)/2, 
3226                                                                 ePIN_WIDTH, ePIN_HEIGHT, ePIN_INC_X, p_app->tmp_value, p_app->tmp_value);
3227                                bapp_flush_screen(p_app);
3228                                result = 0;
3229                        } else
3230                        {
3231                                /* no pin digits entered so function as 'back' unless verifying pin live */
3232                                if ((p_app->screen_id == eSCREEN_PIN_VERIFY_LIVE) ||
3233                                        (p_app->screen_id == eSCREEN_WRONG_PIN_LIVE))
3234                                {
3235                                        bapp_set_current_screen(p_app, eSCREEN_MAIN, eSCREEN_NULL);
3236                                } else
3237                                {
3238                                        bapp_goto_last_screen(p_app);
3239                                }
3240                                result = 1;
3241                        }
3242                        break;
3243                case eIR_0:
3244                case eIR_1:
3245                case eIR_2:
3246                case eIR_3:
3247                case eIR_4:
3248                case eIR_5:
3249                case eIR_6:
3250                case eIR_7:
3251                case eIR_8:
3252                case eIR_9:
3253                        result = 1;
3254                        pin |= (p_event->id)<<(p_app->tmp_value * 8);
3255                        (p_app->tmp_value)++;
3256
3257                        /* force draw of only changed pin fields */
3258                        bscreen_draw_pin(v_app, ePIN_X, ePIN_Y+(p_screen->top_banner_height-eMENU_TITLE_AREA_HEIGHT_1_LINE)/2, 
3259                                                         ePIN_WIDTH, ePIN_HEIGHT, ePIN_INC_X, p_app->tmp_value, p_app->tmp_value - 1);
3260
3261                        if (p_app->tmp_value < 4)
3262                        {
3263                                bscreen_draw_pin(v_app, ePIN_X, ePIN_Y+(p_screen->top_banner_height-eMENU_TITLE_AREA_HEIGHT_1_LINE)/2, 
3264                                                                 ePIN_WIDTH, ePIN_HEIGHT, ePIN_INC_X, p_app->tmp_value, p_app->tmp_value);
3265                        }
3266                        bapp_flush_screen(p_app);
3267                        result = 0;
3268                        break;
3269                }
3270
3271                if (p_app->tmp_value == 4)
3272                {
3273                        /* force drawing of last digit indicator */
3274                        /* any time we draw we need to sync first */
3275                        bscreen_draw_pin(v_app, ePIN_X, ePIN_Y+(p_screen->top_banner_height-eMENU_TITLE_AREA_HEIGHT_1_LINE)/2, 
3276                                                         ePIN_WIDTH, ePIN_HEIGHT, ePIN_INC_X, p_app->tmp_value, p_app->tmp_value - 1);
3277
3278                        bapp_sleep(250); /* slight delay so user can see 4th digit displayed */
3279
3280                        /* handle all pin based screens */
3281                        switch (p_app->screen_id)
3282                        {
3283                        case eSCREEN_PIN_NEW:
3284                                /* save entered pin and query user to confirm entry */
3285                                pin_pending = pin;
3286                                BDBG_MSG(("saving new pin: %x\n", pin_pending));
3287                                /* force "last screen" to be identical to that of the eSCREEN_PIN_NEW */
3288                                bapp_set_current_screen(p_app, eSCREEN_PIN_CONFIRM, p_screen->last_screen_id);
3289                                break;
3290                        case eSCREEN_WIZ_PIN_NEW:
3291                                /* save entered pin and query user to confirm entry */
3292                                pin_pending = pin;
3293                                BDBG_MSG(("saving new pin: %x\n", pin_pending));
3294                                /* force "last screen" to be identical to that of the eSCREEN_PIN_NEW */
3295                                bapp_set_current_screen(p_app, eSCREEN_WIZ_PIN_CONFIRM, p_screen->last_screen_id);
3296                                break;
3297                        case eSCREEN_PIN_CONFIRM:
3298                                BDBG_MSG(("comparing new/confirm pins: %x %x\n", pin_pending, pin));
3299                                /* verify against previously entered pin */
3300                                if (pin == pin_pending)
3301                                {
3302                                        /* traditional screen flow was interrupted by pin new/confirm windows, so force "last screen" to be main menu screen. */
3303                                        bapp_set_current_screen(p_app, eSCREEN_RATINGS, eSCREEN_MAIN);
3304                                        p_app->settings.pin = pin;
3305                                        p_app->settings_dirty = true;
3306                                } else
3307                                {
3308                                        /* user entered pins do not match...start over */
3309                                        bapp_set_current_screen(p_app, eSCREEN_MISMATCHED_PINS, p_screen->last_screen_id);
3310                                }
3311                                break;
3312                        case eSCREEN_WIZ_PIN_CONFIRM:
3313                                BDBG_MSG(("comparing new/confirm pins: %x %x\n", pin_pending, pin));
3314                                /* verify against previously entered pin */
3315                                if (pin == pin_pending)
3316                                {
3317                                        /* still in wizard so continue to next step */
3318                                        bapp_set_current_screen(p_app, eSCREEN_WIZ_DONE, eSCREEN_WIZ_PIN_NEW);
3319
3320                                        p_app->settings.pin = pin;
3321                                        p_app->settings_dirty = true;
3322                                } else
3323                                {
3324                                        /* user entered pins do not match...start over */
3325                                        bapp_set_current_screen(p_app, eSCREEN_WIZ_MISMATCHED_PINS, p_screen->last_screen_id);
3326                                }
3327                                break;
3328                        case eSCREEN_PIN_VERIFY_LIVE:
3329                        case eSCREEN_PIN_VERIFY_RATINGS:
3330                        case eSCREEN_PIN_VERIFY_RESET:
3331                                /* keep count of consecutive pin entries that equal backup pin (thomson = 3308) */
3332                                BDBG_ERR(("verify entered/stored pins: %x %x\n", pin, p_app->settings.pin));
3333                                BDBG_ERR(("backup_pin: %x\n", g_p_dsp->ui_comp.backup_pin));
3334                                if ((pin == g_p_dsp->ui_comp.backup_pin) && (p_app->screen_id == eSCREEN_PIN_VERIFY_RATINGS))
3335                                        pin_override = 3;
3336                                else
3337                                        pin_override = 0;
3338
3339                                /* if user enters BRCM 3 times as the pin allow entry! */
3340                                if (pin_override == 3)
3341                                        pin = p_app->settings.pin;
3342
3343                                BDBG_MSG(("verify entered/stored pins: %x %x\n", pin, p_app->settings.pin));
3344                                /* verify against previously stored pin */
3345                                if (pin == p_app->settings.pin)
3346                                {
3347                                        if (p_app->screen_id == eSCREEN_PIN_VERIFY_LIVE)
3348                                        {
3349                                                p_app->ratings_override = true; /* will be reset when changing channels */
3350                                                p_app->ratings_override_set = true;
3351                                                bapp_set_current_screen(p_app, eSCREEN_NULL, eSCREEN_NULL);
3352                                        } else
3353                                                if (p_app->screen_id == eSCREEN_PIN_VERIFY_RATINGS)
3354                                        {
3355                                                bapp_set_current_screen(p_app, eSCREEN_RATINGS, eSCREEN_MAIN);
3356                                        } else
3357                                                if (p_app->screen_id == eSCREEN_PIN_VERIFY_RESET)
3358                                        {
3359                                                bapp_set_current_screen(p_app, eSCREEN_RESET, eSCREEN_SETUP);
3360                                        }
3361                                } else
3362                                {
3363                                        // This is not necessary JPF bapp_sleep(3000); /* slow down possible brute force attack */
3364
3365                                        /* user entered pin is incorrect */
3366                                        if (p_app->screen_id == eSCREEN_PIN_VERIFY_LIVE)
3367                                        {
3368                                                bapp_set_current_screen(p_app, eSCREEN_WRONG_PIN_LIVE, eSCREEN_NULL);
3369                                        } else
3370                                                if (p_app->screen_id == eSCREEN_PIN_VERIFY_RATINGS)
3371                                        {
3372                                                bapp_set_current_screen(p_app, eSCREEN_WRONG_PIN_RATINGS, p_screen->last_screen_id);
3373                                        } else
3374                                                if (p_app->screen_id == eSCREEN_PIN_VERIFY_RESET)
3375                                        {
3376                                                bapp_set_current_screen(p_app, eSCREEN_WRONG_PIN_RESET, p_screen->last_screen_id);
3377                                        }
3378                                }
3379                                break;
3380                        default:
3381                                BDBG_ASSERT(0);
3382                        }
3383
3384                        /* reset pin values */
3385                        pin = 0;
3386                        p_app->tmp_value = 0; /* select first pin digit field */
3387                        result = 1;     /* always handle event */
3388                }
3389        } else if ((p_event->type != eS_EVENT_SELECTED) &&
3390                           (p_event->type != eS_EVENT_CHECKED))
3391        {
3392                result = bscreen_default_event(v_app,v_screen,p_event);
3393        }
3394
3395        return result;
3396}
3397
3398/*
3399Summary:
3400        Wrong PIN screen event handler
3401Description:
3402        Wrong PIN screen event handler.
3403        .
3404*/
3405int screen_wrong_pin_event(void *v_app, void *v_screen, 
3406                                                   bscreen_event_t *p_event)
3407{
3408        bapp_t *p_app = (bapp_t*)v_app;
3409        bscreen_t *p_screen = (bscreen_t*)v_screen;
3410        int result = 0;
3411
3412        if (p_event->type == eS_EVENT_SETUP)
3413        {
3414                /* this popup may display without a corresponding keypress
3415                   so reset screensaver timeout value manually */
3416#ifdef CONFIG_SCREENSAVER
3417                p_app->last_keypress_tick = bos_getticks();
3418                printf("#### %s:%d 0x%08x ####\n",__FUNCTION__,__LINE__,TICKS_TO_MS(p_app->last_keypress_tick));
3419#endif
3420                bscreen_default_setup(v_app,v_screen);
3421                result = 1;     /* always handle event */
3422        } else if (p_event->type == eS_EVENT_IR)
3423        {
3424                switch (p_event->id)
3425                {
3426                case eIR_RIGHT:
3427                case eIR_SELECT:
3428                        if (p_screen->p_button_array[p_screen->button_selection].desc_text_id == eTEXT_CANCEL_INFO)
3429                        {
3430                                result = 1;
3431                                /* cannot call select_button() in this case since we do not want to save button history
3432                                 * this is unique for the eTEXT_CANCEL button since the button duplicates the 'back' functionality
3433                                 */
3434                                bapp_goto_last_screen(p_app);
3435                        } else /* retry */
3436                        {
3437                                bapp_set_current_screen(p_app, p_screen->p_button_array[p_screen->button_selection].next_screen_id, p_screen->last_screen_id);
3438                                result = 1;
3439                        }
3440                        break;
3441                case eIR_LEFT:
3442                case eIR_MENU:
3443                        if (p_app->screen_id == eSCREEN_WIZ_MISMATCHED_PINS)
3444                        {
3445                                /* cancel option not available in wizard so retry */
3446                                bapp_set_current_screen(p_app, p_screen->p_button_array[p_screen->button_selection].next_screen_id, p_screen->last_screen_id);
3447                                result = 1;
3448                        } else /* disable 'back' functionality for live pin verification */
3449                                if (p_app->screen_id != eSCREEN_WRONG_PIN_LIVE)
3450                        {
3451                                result = 1;
3452                                bapp_goto_last_screen(p_app);
3453                        }
3454                        break;
3455                default:
3456                        result = bscreen_default_event(v_app,v_screen,p_event);
3457                        break;
3458                }
3459        } else
3460        {
3461                result = bscreen_default_event(v_app,v_screen,p_event);
3462        }
3463
3464        return result;
3465}
3466
3467#if 0
3468/*
3469Summary:
3470        Setup RRT ratings screen.
3471        .
3472*/
3473int bscreen_rrt_init(void *v_app)
3474{
3475        bapp_t *p_app         = (bapp_t*)v_app;
3476/* setup rrt screen buttons */
3477        PSIP_RRT_header header;
3478        PSIP_RRT_dimension dim;
3479        int dim_idx     = 0;
3480        int num_rrt_dim = 0;
3481
3482        PSIP_RRT_getHeader(p_app->settings.rrt, &header);
3483        for (dim_idx = 0; dim_idx < header.dimensions_defined; dim_idx++)
3484        {
3485                if (PSIP_RRT_getDimension(p_app->settings.rrt,dim_idx,&dim) == BERR_SUCCESS)
3486                {
3487                        /* create button on rrt dimensions screen */
3488                        if (dim_idx < MAX_RRT_DIM_BUTTONS)
3489                        {
3490                                g_buttons_ratings_rrt_dim[dim_idx].type                = eBUTTON_MENU;
3491                                g_buttons_ratings_rrt_dim[dim_idx].x                   = eMENU_RATINGS_RRT_DIM_FIRST_BUTTON_X;
3492                                g_buttons_ratings_rrt_dim[dim_idx].y                   = eMENU_RATINGS_RRT_DIM_FIRST_BUTTON_Y + dim_idx * eMENU_RATINGS_RRT_DIM_BUTTON_INC_Y;
3493                                g_buttons_ratings_rrt_dim[dim_idx].width               = eMENU_RATINGS_RRT_DIM_BUTTON_WIDTH;
3494                                g_buttons_ratings_rrt_dim[dim_idx].height              = eMENU_RATINGS_RRT_DIM_BUTTON_HEIGHT;
3495                                g_buttons_ratings_rrt_dim[dim_idx].text_id             = eTEXT_MAX;
3496                                g_buttons_ratings_rrt_dim[dim_idx].desc_text_id        = eTEXT_MAX;
3497                                g_buttons_ratings_rrt_dim[dim_idx].next_screen_id      = eSCREEN_RATINGS_RRT_VAL;
3498                                g_buttons_ratings_rrt_dim[dim_idx].next_screen_back_id = eSCREEN_MAX;
3499                                g_buttons_ratings_rrt_dim[dim_idx].right_justify_text  = 1;
3500                                g_buttons_ratings_rrt_dim[dim_idx].background_color    = eCOLOR_MED_BLUE;
3501
3502                                num_rrt_dim++;
3503                        }
3504                }
3505        }
3506        return num_rrt_dim;
3507}
3508#endif
3509/*
3510Summary:
3511        Default screen idle handler
3512Description:
3513        Default screen idle handler.
3514        .
3515*/
3516int bscreen_default_idle(void *v_app, void *v_screen)
3517{
3518        bapp_t *p_app         = (bapp_t*)v_app;
3519        bscreen_t *p_screen   = (bscreen_t*)v_screen;
3520        uint32_t current_tick = bos_getticks();
3521        bool show_screensaver = false;
3522
3523        /* check for auto power off */
3524        if ((p_app->screen_id != eSCREEN_POWER_OFF) &&
3525                (p_app->settings.auto_power != 3)       &&
3526                (current_tick >= (p_app->last_keypress_tick + MS_TO_TICKS(AUTO_POWER_OFF_TIMEOUT) * (1 + p_app->settings.auto_power))))
3527        {
3528                bapp_power(p_app, false);
3529                return 0;
3530        }
3531
3532        /* check for screen timeout when 'no signal' popup is displayed */
3533        if ((p_app->screen_id == eSCREEN_BANNER_SMALL) && 
3534                (!bapp_get_signal_status(p_app)) &&
3535                (current_tick >= (p_app->last_keypress_tick + MS_TO_TICKS(SCREEN_DEFAULT_TIMEOUT))))
3536        {
3537                show_screensaver = true;
3538        } else /* check for screen timeout when 'mute' popup is displayed */
3539                if ((p_app->screen_id == eSCREEN_BANNER_SMALL) &&
3540                        (p_app->audio_mute)                        &&
3541                        (current_tick >= (p_app->last_keypress_tick + MS_TO_TICKS(SCREEN_DEFAULT_TIMEOUT))))
3542        {
3543                show_screensaver = true;
3544        } else /* check for screen timeout when a menu screen is displayed */
3545                if ((p_app->screen_id != eSCREEN_SCREENSAVER)  &&
3546                        (p_app->screen_id != eSCREEN_POWER_OFF)    &&
3547                        (p_app->screen_id != eSCREEN_NULL)         &&
3548                        (p_app->screen_id != eSCREEN_BANNER_SMALL) && 
3549                        (p_screen->idle_timeout > 0)               &&
3550                        (current_tick >= (p_app->last_keypress_tick + MS_TO_TICKS(p_screen->idle_timeout))))
3551        {
3552                show_screensaver = true;
3553        }
3554
3555#ifndef CONFIG_SCREENSAVER
3556        if (show_screensaver)
3557        {
3558                return 0; /* don't cause screen redraw */
3559        }
3560#else
3561//#error "No screensaver mode for Thomson"
3562        if (show_screensaver)
3563        {
3564                bapp_set_current_screen(p_app, eSCREEN_SCREENSAVER, eSCREEN_MAX);
3565                p_app->last_keypress_tick = current_tick;
3566                printf("#### %s:%d 0x%08x ####\n",__FUNCTION__,__LINE__,TICKS_TO_MS(p_app->last_keypress_tick));
3567                return 1; /* cause screen redraw */
3568        }
3569#endif
3570        return 0;
3571}
3572
3573static void reset_volume_timeout(bscreen_t *p_screen)
3574{
3575        banner_state_t *p_bs = (banner_state_t*)p_screen->local_state;
3576        if (p_bs->volume_dirty)
3577                p_bs->volume_timeout = bos_getticks() + MS_TO_TICKS(BANNER_VOLUME_TIMEOUT);
3578        else
3579                p_bs->volume_timeout = 0;
3580}
3581
3582static void reset_SAP_timeout(bscreen_t *p_screen)
3583{
3584        banner_state_t *p_bs = (banner_state_t*)p_screen->local_state;
3585        if (p_bs->SAP_dirty)
3586                p_bs->SAP_timeout = bos_getticks() + MS_TO_TICKS(BANNER_SAP_TIMEOUT);
3587        else
3588                p_bs->SAP_timeout = 0;
3589}
3590
3591static void reset_CC_timeout(bscreen_t *p_screen)
3592{
3593        banner_state_t *p_bs = (banner_state_t*)p_screen->local_state;
3594        if (p_bs->CC_dirty)
3595                p_bs->CC_timeout = bos_getticks() + MS_TO_TICKS(BANNER_CC_TIMEOUT);
3596        else
3597                p_bs->CC_timeout = 0;
3598}
3599
3600static void reset_auto_power_restart_timeout(bapp_t *p_app, bscreen_t *p_screen)
3601{
3602        banner_state_t *p_bs = (banner_state_t*)p_screen->local_state;
3603        if (p_app->settings.auto_power_off)
3604                p_bs->auto_power_restart_timeout = bos_getticks() + MS_TO_TICKS(AUTO_POWER_OFF_RESTART_TIMEOUT);
3605        else
3606                p_bs->auto_power_restart_timeout = 0;
3607}
3608
3609static void reset_10_key_timeout(bscreen_t *p_screen)
3610{
3611        banner_state_t *p_bs = (banner_state_t*)p_screen->local_state;
3612
3613        if (p_bs->majorChIndex > 0)
3614                p_bs->ten_key_timeout = bos_getticks() + MS_TO_TICKS(BANNER_10_KEY_TIMEOUT);
3615        else
3616                p_bs->ten_key_timeout = 0;
3617}
3618
3619static void reset_banner_timeout(bscreen_t *p_screen)
3620{
3621        banner_state_t *p_bs = (banner_state_t*)p_screen->local_state;
3622
3623        /* reset banner timeout */
3624        if (p_bs->mode == eLS_BANNER_SMALL)
3625                p_bs->timeout = bos_getticks() + MS_TO_TICKS(BANNER_SMALL_TIMEOUT);
3626        else
3627                if (p_bs->mode == eLS_BANNER_BIG)
3628                p_bs->timeout = bos_getticks() + MS_TO_TICKS(BANNER_BIG_TIMEOUT);
3629        else
3630                p_bs->timeout = 0;
3631}
3632
3633static void reset_10_key(bscreen_t *p_screen)
3634{
3635        banner_state_t *p_bs = (banner_state_t*)p_screen->local_state;
3636
3637        BDBG_ASSERT(p_bs);
3638
3639        memset(p_bs->majorCh, 0, sizeof(p_bs->majorCh));
3640        memset(p_bs->minorCh, 0, sizeof(p_bs->minorCh));
3641        p_bs->majorChIndex  = 0;
3642        p_bs->minorChIndex  = 0;
3643        p_bs->dot           = false;
3644        p_bs->enter         = false;
3645
3646        reset_10_key_timeout(p_screen);
3647}
3648
3649static int my_atoi(const char *s)
3650{
3651        int i=0;
3652
3653        while ((*s >= '0') && (*s <='9'))
3654                i = i*10 + *(s++) - '0';
3655
3656        return i;
3657}
3658
3659/*
3660Summary:
3661        Banner screen event handler
3662Description:
3663        Banner screen event handler.
3664        .
3665*/
3666int screen_banner_event(void *v_app, void *v_screen, 
3667                                                bscreen_event_t *p_event)
3668{
3669        bapp_t *p_app = (bapp_t*)v_app;
3670        bscreen_t *p_screen = (bscreen_t*)v_screen;
3671        banner_state_t *p_bs;
3672        int result = 0;
3673
3674        p_bs = (banner_state_t*)p_screen->local_state;
3675
3676        BDBG_ASSERT(p_bs);
3677
3678        switch (p_event->type)
3679        {
3680        case eS_EVENT_REDRAW:
3681                if (!bapp_eia708_enabled(p_app->eia708) && (p_bs->mode > eLS_BANNER_OFF))
3682                {
3683
3684                        BDBG_MSG(("%s bapp_eia708_enabled %d, mode = %d\n",__FUNCTION__,bapp_eia708_enabled(p_app->eia708),p_bs->mode));
3685                        bapp_sync(p_app);
3686                        p_app->p_screens[p_app->screen_id].draw(p_app,(void*)&(p_app->p_screens[p_app->screen_id]));
3687                        bapp_flush_screen(p_app);
3688                }
3689                break;
3690
3691        case eS_EVENT_SETUP:
3692                {
3693                        result = 1;     /* always handle event */
3694                        /* if showing banner because of 10key, do not reset value */
3695                        if (!((p_event->id >= eIR_0) && (p_event->id <= eIR_9)))
3696                                reset_10_key(p_screen);
3697
3698                        set_banner(p_screen, eLS_BANNER_MAX, false);
3699
3700                        /* reset key repeat timeout */
3701                        p_bs->repeat_rate = 1;
3702                        p_bs->repeat_timeout = DEFAULT_REPEAT_TIMEOUT/p_bs->repeat_rate;
3703
3704                        reset_banner_timeout(p_screen);
3705                        reset_10_key_timeout(p_screen);
3706                        screen_null_draw(v_app, v_screen);
3707
3708                        if (p_app->settings_dirty)
3709                        {
3710                                /* user settings have changed so update and retune */
3711                                bapp_save_settings(p_app);
3712                                bapp_apply_settings(p_app);
3713                        }
3714
3715                        bapp_tune(p_app);
3716                        bapp_av_mute(p_app, 0);
3717                        bapp_audio_mute(p_app, p_app->audio_mute);
3718                }
3719                break;
3720        case eS_EVENT_SETUP_DONE:
3721                break;
3722        case eS_EVENT_IDLE:
3723                {
3724                        uint32_t current_tick = bos_getticks();
3725
3726                        if ((p_bs->auto_power_one_min_warning) &&
3727                                (current_tick < (p_app->last_keypress_tick + MS_TO_TICKS(AUTO_POWER_OFF_TIMEOUT) * (1 + p_app->settings.auto_power) - MS_TO_TICKS(1000 * 60))))
3728                        {
3729                                /* auto power off cancelled */
3730                                p_bs->auto_power_one_min_warning = false;
3731                                bscreen_popup(v_app,v_screen);
3732                        } else
3733                                if ((p_app->settings.auto_power != 3) &&
3734                                        (current_tick >= (p_app->last_keypress_tick + MS_TO_TICKS(AUTO_POWER_OFF_TIMEOUT) * (1 + p_app->settings.auto_power) - MS_TO_TICKS(1000 * 60))))
3735                        {
3736                                /* show one minute warning before auto power off */
3737                                p_bs->auto_power_one_min_warning = true;
3738                                bscreen_popup(v_app,v_screen);
3739                        }
3740
3741                        /* Handle repeating when key is held down */
3742                        if (p_bs->repeat_timeout < current_tick)
3743                        {
3744                                BDBG_MSG(("%s repeat %d\n",__FUNCTION__,p_bs->event.id));
3745                                if (p_bs->event.type == eS_EVENT_IR)
3746                                {
3747                                        switch (p_bs->event.id)
3748                                        {
3749                                        case eIR_UP:
3750                                        case eIR_CH_UP:
3751                                                bapp_change_channel(p_app,1,1);
3752                                                reset_banner_timeout(p_screen);
3753                                                result = 1;
3754                                                break;
3755                                        case eIR_DOWN:
3756                                        case eIR_CH_DOWN:
3757                                                bapp_change_channel(p_app,0,1);
3758                                                reset_banner_timeout(p_screen);
3759                                                result = 1;
3760                                                break;
3761                                        case eIR_VOL_UP:
3762                                                bapp_set_audio_volume(p_app, p_app->audio_vol + VOLUME_INCREMENT);
3763                                                p_bs->volume_dirty = true;
3764                                                reset_volume_timeout(p_screen);
3765                                                bscreen_popup_draw(v_app,v_screen,eTEXT_VOLUME_TITLE,eTEXT_MAX);
3766                                                break;
3767                                        case eIR_VOL_DOWN:
3768                                                bapp_set_audio_volume(p_app, p_app->audio_vol - VOLUME_INCREMENT);
3769                                                p_bs->volume_dirty = true;
3770                                                reset_volume_timeout(p_screen);
3771                                                bscreen_popup_draw(v_app,v_screen,eTEXT_VOLUME_TITLE,eTEXT_MAX);
3772                                                break;
3773                                        default: break;
3774                                        }
3775                                }
3776
3777                                if (p_bs->repeat_rate < MAX_REPEAT_ACCEL)
3778                                {
3779                                        p_bs->repeat_rate += REPEAT_INC;
3780                                }
3781                                p_bs->repeat_timeout = current_tick + (DEFAULT_REPEAT_TIMEOUT/p_bs->repeat_rate);
3782                        }
3783
3784                        /* check signal level */
3785                        {
3786                                static bool last_signal_status    = true;
3787                                bool current_signal_status        = false;
3788                                btuner_ds_status ds_status;
3789
3790                                /* update banner signal level meter if shown */
3791                                ///btuner_get_ds_status(p_app->tuner, &ds_status);
3792                                ds_status.signal_strength = p_app->signal_level;
3793                                if (p_bs->mode != eLS_BANNER_OFF)
3794                                {
3795                                        /* draw signal level */
3796                                        bscreen_draw_banner_signal_level(p_app, ds_status.signal_strength);
3797                                }
3798
3799                                /* check for no signal - display/hide popup as necessary */
3800                                current_signal_status = bapp_get_signal_status(p_app);
3801                                if ((!last_signal_status) && (current_signal_status))
3802                                {
3803                                        /* going from no signal to valid signal - hide popup */
3804                                        set_banner(p_screen, eLS_BANNER_MAX, false);
3805                                        reset_banner_timeout(p_screen);
3806                                        /* no need to re-enable cc since we are displaying banner */
3807                                        bapp_audio_mute(p_app, p_app->audio_mute);
3808                                        bscreen_popup(v_app,v_screen);
3809                                        result = 1;
3810                                } else
3811                                        if ((last_signal_status) && (!current_signal_status))
3812                                {
3813                                        /* going from valid signal to no signal - show popup */
3814                                        bscreen_popup(v_app, v_screen);
3815
3816                                        /* reset screensaver timeout since we will show no signal popup */
3817#ifdef CONFIG_SCREENSAVER
3818                                        p_app->last_keypress_tick = bos_getticks();
3819                                        printf("#### %s:%d 0x%08x ####\n",__FUNCTION__,__LINE__,TICKS_TO_MS(p_app->last_keypress_tick));
3820#endif
3821                                }
3822
3823                                last_signal_status = current_signal_status;
3824                        }
3825
3826                        /* handle volume timeout */
3827                        if ((p_bs->volume_dirty)   &&
3828                                (p_bs->volume_timeout) && 
3829                                (current_tick >= p_bs->volume_timeout))
3830                        {
3831                                p_bs->volume_dirty = false;
3832                                reset_volume_timeout(p_screen);
3833                                bscreen_popup(v_app,v_screen);
3834                                result = 1;
3835                        }
3836
3837                        /* handle SAP timeout */
3838                        if ((p_bs->SAP_dirty)   &&
3839                                (p_bs->SAP_timeout) && 
3840                                (current_tick >= p_bs->SAP_timeout))
3841                        {
3842                                p_bs->SAP_dirty = false;
3843                                reset_SAP_timeout(p_screen);
3844                                bscreen_popup(v_app,v_screen);
3845                                result = 1;
3846                        }
3847
3848                        /* handle CC timeout */
3849                        if ((p_bs->CC_dirty)   &&
3850                                (p_bs->CC_timeout) && 
3851                                (current_tick >= p_bs->CC_timeout))
3852                        {
3853                                bapp_set_captions_options(p_app);
3854
3855                                p_bs->CC_dirty = false;
3856                                reset_CC_timeout(p_screen);
3857                                bscreen_popup(v_app,v_screen);
3858                                result = 1;
3859                        }
3860
3861                        /* handle auto power restart timeout */
3862                        if (p_app->settings.auto_power_off)
3863                        {
3864                                if (p_bs->auto_power_restart_timeout == 0)
3865                                {
3866                                        reset_auto_power_restart_timeout(p_app, p_screen);
3867                                        bscreen_popup(v_app,v_screen);
3868                                } else
3869                                        if (current_tick >= p_bs->auto_power_restart_timeout)
3870                                {
3871                                        p_app->settings.auto_power_off = 0;
3872                                        p_app->settings_dirty = true;
3873
3874                                        reset_auto_power_restart_timeout(p_app, p_screen);
3875                                        bscreen_popup(v_app,v_screen);
3876                                }
3877                        }
3878
3879                        /* handle 10key timeout */
3880                        if ((p_bs->ten_key_timeout) && (current_tick >= p_bs->ten_key_timeout))
3881                        {
3882                                /* user has entered some 10key so attempt tune */
3883
3884                                /* force drawing of last digit indicator */
3885                                p_bs->enter = true;
3886                                if (p_bs->minorChIndex == 0)
3887                                {
3888                                        p_bs->minorCh[0]   = '1';
3889                                        p_bs->minorChIndex = 1;
3890                                }
3891
3892                                bapp_set_channel(p_app, my_atoi(p_bs->majorCh), my_atoi(p_bs->minorCh));
3893                                reset_10_key(p_screen);
3894                                set_banner(p_screen, eLS_BANNER_MAX, true);
3895                                reset_banner_timeout(p_screen);
3896                                result = 1;
3897                        }
3898
3899                        /* handle timeout of banner */
3900                        if ((p_bs->timeout) && (current_tick >= p_bs->timeout))
3901                        {
3902                                set_banner(p_screen, eLS_BANNER_OFF, true);
3903                                reset_banner_timeout(p_screen);
3904                                result = 1;
3905                        }
3906
3907                        result |= bscreen_default_idle(v_app, v_screen);
3908                }
3909                break;
3910        case eS_EVENT_IR:
3911                {
3912
3913                        /* cancel auto power restart popup */
3914                        if ((p_app->settings.auto_power_off) && ((p_event->id & KEY_UP) == 0))
3915                        {
3916                                p_app->settings.auto_power_off = 0; 
3917                                reset_auto_power_restart_timeout(p_app, p_screen);
3918                                bscreen_popup(v_app,v_screen);
3919                        } else
3920                                if (bos_getticks() < (p_app->last_keypress_tick + MS_TO_TICKS(AUTO_POWER_OFF_TIMEOUT) * (1 + p_app->settings.auto_power)))
3921                        {
3922                                /* cancel auto power off popup */
3923                                bscreen_popup(v_app,v_screen);
3924                        }
3925
3926                        /* cancel partial 10key entry if user presses any invalid key */
3927                        if ((p_bs->majorChIndex > 0) &&
3928                                ((p_event->id & KEY_UP) == 0))
3929                        {
3930                                if ((p_event->id != eIR_0)     &&
3931                                        (p_event->id != eIR_1)     &&
3932                                        (p_event->id != eIR_2)     &&
3933                                        (p_event->id != eIR_3)     &&
3934                                        (p_event->id != eIR_4)     &&
3935                                        (p_event->id != eIR_5)     &&
3936                                        (p_event->id != eIR_6)     &&
3937                                        (p_event->id != eIR_7)     &&
3938                                        (p_event->id != eIR_8)     &&
3939                                        (p_event->id != eIR_9)     &&
3940                                        (p_event->id != eIR_DOT)   &&
3941                                        (p_event->id != eIR_SELECT) &&
3942                                        (p_event->id != eIR_ENTER))
3943                                {
3944                                        reset_10_key(p_screen);
3945                                        result = 1;
3946                                }
3947                        }
3948
3949                        switch (p_event->id)
3950                        {
3951                        case eIR_VOL_UP:
3952                                bapp_set_audio_volume(p_app, p_app->audio_vol + VOLUME_INCREMENT);
3953                                p_bs->volume_dirty = true;
3954                                reset_volume_timeout(p_screen);
3955                                p_app->audio_mute = false;
3956                                bscreen_popup(v_app, v_screen);
3957                                break;
3958                        case eIR_VOL_DOWN:
3959                                bapp_set_audio_volume(p_app, p_app->audio_vol - VOLUME_INCREMENT);
3960                                p_bs->volume_dirty = true;
3961                                reset_volume_timeout(p_screen);
3962                                p_app->audio_mute = false;
3963                                bscreen_popup(v_app, v_screen);
3964                                break;
3965                        case eIR_LEFT:
3966                                break;
3967                        case eIR_MENU:
3968                                result = 1;
3969                                set_banner(p_screen, eLS_BANNER_OFF, true);
3970                                reset_banner_timeout(p_screen);
3971                                bapp_set_current_screen(p_app, eSCREEN_MAIN, eSCREEN_NULL);
3972                                break;
3973
3974                        case eIR_INFO:
3975                                if (p_bs->mode == eLS_BANNER_OFF)
3976                                        set_banner(p_screen, eLS_BANNER_SMALL, false);
3977                                else
3978                                        if (p_bs->mode == eLS_BANNER_SMALL)
3979                                        set_banner(p_screen, eLS_BANNER_BIG, false);
3980                                else
3981                                        set_banner(p_screen, eLS_BANNER_OFF, false);
3982
3983                                reset_banner_timeout(p_screen);
3984                                result = 1;
3985                                break;
3986                        case eIR_GUIDE:
3987#if (BCHP_CHIP==3543)
3988                                if (!(ReadReg32(BCHP_GIO_DATA_HI) & STRP_PROG_LIST_MASK))
3989#endif
3990                                {
3991                                        result = 1;
3992                                        bapp_set_current_screen(p_app, eSCREEN_GUIDE, eSCREEN_NULL);
3993                                }
3994                                break;
3995                        case eIR_UP:
3996                        case eIR_CH_UP:
3997                                bapp_change_channel(p_app,1,1);
3998                                set_banner(p_screen, eLS_BANNER_MAX, true);
3999                                reset_banner_timeout(p_screen);
4000                                result = 1;
4001                                break;
4002                        case eIR_DOWN:
4003                        case eIR_CH_DOWN:
4004                                bapp_change_channel(p_app,0,1);
4005                                set_banner(p_screen, eLS_BANNER_MAX, true);
4006                                reset_banner_timeout(p_screen);
4007                                result = 1;
4008                                break;
4009                        case eIR_DOT:
4010                                if (p_bs->majorChIndex > 0)
4011                                {
4012                                        p_bs->dot = true;
4013                                        reset_banner_timeout(p_screen);
4014                                        reset_10_key_timeout(p_screen);
4015                                        result = 1;
4016                                }
4017#ifdef CONFIG_EIA_708
4018                                else
4019                                {
4020                                        if (p_bs->CC_dirty)
4021                                        {
4022                                                p_app->captions_basic++;
4023                                                if (p_app->captions_basic > MAX_CC_SERVICES)
4024                                                {
4025                                                        p_app->captions_basic = 0;
4026                                                }
4027                                        }
4028
4029                                        p_bs->CC_dirty = true;
4030                                        reset_CC_timeout(p_screen);
4031                                        /* reset screensaver timeout since we will show CC popup */
4032#ifdef CONFIG_SCREENSAVER
4033                                        p_app->last_keypress_tick = bos_getticks();
4034                                        printf("#### %s:%d 0x%08x ####\n",__FUNCTION__,__LINE__,TICKS_TO_MS(p_app->last_keypress_tick));
4035#endif
4036                                        bscreen_popup(v_app, v_screen);
4037                                }
4038#endif
4039                                break;
4040                        case eIR_0:
4041                        case eIR_1:
4042                        case eIR_2:
4043                        case eIR_3:
4044                        case eIR_4:
4045                        case eIR_5:
4046                        case eIR_6:
4047                        case eIR_7:
4048                        case eIR_8:
4049                        case eIR_9:
4050                                if (p_bs->majorChIndex >= 2)
4051                                {
4052                                        /* max number of major channel digits have been entered
4053                                           so skip to minor channel digit entry */
4054                                        p_bs->dot = true;
4055                                }
4056
4057                                if (!p_bs->dot)
4058                                {
4059                                        /* major channel number digit entered */
4060                                        p_bs->majorCh[p_bs->majorChIndex] = '0' + (p_event->id - eIR_0);
4061                                        p_bs->majorChIndex++;
4062                                } else
4063                                {
4064                                        /* minor channel number digit entered */
4065                                        p_bs->minorCh[p_bs->minorChIndex] = '0' + (p_event->id - eIR_0);
4066                                        p_bs->minorChIndex++;
4067
4068                                        if (p_bs->minorChIndex >= 2)
4069                                        {
4070                                                /* max number of minor channel digits have been entered
4071                                                   so immediately tune */
4072
4073                                                /* force drawing of last digit indicator */
4074                                                p_bs->enter = true;
4075                                                if (p_bs->minorChIndex == 0)
4076                                                {
4077                                                        p_bs->minorCh[0]   = '1';
4078                                                        p_bs->minorChIndex = 1;
4079                                                }
4080
4081                                                bapp_set_channel(p_app, my_atoi(p_bs->majorCh), my_atoi(p_bs->minorCh));
4082
4083                                                reset_10_key(p_screen);
4084                                        }
4085                                }
4086
4087                                set_banner(p_screen, eLS_BANNER_MAX, true);
4088                                reset_banner_timeout(p_screen);
4089                                reset_10_key_timeout(p_screen);
4090                                result = 1;
4091                                break;
4092
4093                        case eIR_ENTER:
4094                                if (p_bs->majorChIndex > 0)
4095                                {
4096                                        /* force drawing of channel without '_' */
4097                                        p_bs->enter = true;
4098                                        if (p_bs->minorChIndex == 0)
4099                                        {
4100                                                p_bs->minorCh[0]   = '1';
4101                                                p_bs->minorChIndex = 1;
4102                                        }
4103
4104                                        bapp_set_channel(p_app, my_atoi(p_bs->majorCh), my_atoi(p_bs->minorCh));
4105                                        reset_10_key(p_screen);
4106                                } else
4107                                {
4108                                        /* channel jump - swap last and current channel numbers */
4109                                        unsigned int tmp_ch_num = p_app->cur_ch_num;
4110                                        p_app->cur_ch_num = p_app->last_ch_num;
4111                                        p_app->last_ch_num = tmp_ch_num;
4112                                        bapp_tune(p_app);
4113                                }
4114
4115                                set_banner(p_screen, eLS_BANNER_MAX, true);
4116                                reset_banner_timeout(p_screen);
4117                                result = 1;
4118                                break;
4119                        case eIR_PRECH:
4120                                {
4121                                        /* channel jump - swap last and current channel numbers */
4122                                        unsigned int tmp_ch_num = p_app->cur_ch_num;
4123                                        p_app->cur_ch_num = p_app->last_ch_num;
4124                                        p_app->last_ch_num = tmp_ch_num;
4125                                        bapp_tune(p_app);
4126                                        set_banner(p_screen, eLS_BANNER_MAX, true);
4127                                        reset_banner_timeout(p_screen);
4128                                        result = 1;
4129                                }
4130                                break;
4131                        case eIR_MUTE:
4132                                p_app->audio_mute = !p_app->audio_mute;
4133                                bapp_audio_mute(p_app, p_app->audio_mute);
4134                                p_bs->volume_dirty = false;     /* override recent previous volume change */
4135                                reset_volume_timeout(p_screen);
4136                                /* reset screensaver timeout if we will show mute popup */
4137#ifdef CONFIG_SCREENSAVER
4138                                if (p_app->audio_mute)
4139                                        p_app->last_keypress_tick = bos_getticks();
4140                                printf("#### %s:%d 0x%08x ####\n",__FUNCTION__,__LINE__,TICKS_TO_MS(p_app->last_keypress_tick));
4141#endif
4142                                bscreen_popup(v_app, v_screen);
4143                                break;
4144                        case eIR_SELECT:
4145                                if (p_bs->majorChIndex > 0)
4146                                {
4147                                        /* force drawing of channel without '_' */
4148                                        p_bs->enter = true;
4149                                        if (p_bs->minorChIndex == 0)
4150                                        {
4151                                                p_bs->minorCh[0]   = '1';
4152                                                p_bs->minorChIndex = 1;
4153                                        }
4154
4155                                        bapp_set_channel(p_app, my_atoi(p_bs->majorCh), my_atoi(p_bs->minorCh));
4156                                        reset_10_key(p_screen);
4157                                        set_banner(p_screen, eLS_BANNER_MAX, true);
4158                                        reset_banner_timeout(p_screen);
4159                                        result = 1;
4160                                }
4161                                else if (p_app->settings.sound == 1)
4162                                {
4163                                        bapp_rotate_audio_sap(p_app);
4164
4165                                        p_bs->SAP_dirty = true;
4166                                        reset_SAP_timeout(p_screen);
4167                                        /* reset screensaver timeout since we will show SAP popup */
4168#ifdef CONFIG_SCREENSAVER
4169                                        p_app->last_keypress_tick = bos_getticks();
4170#endif
4171                                        bscreen_popup(v_app, v_screen);
4172                                }
4173                                break;
4174                        }
4175                }
4176                p_bs->event = *p_event;
4177
4178                /* reset key repeat timeout */
4179                p_bs->repeat_rate = 1;
4180                p_bs->repeat_timeout = bos_getticks() + (DEFAULT_REPEAT_TIMEOUT/p_bs->repeat_rate);
4181
4182                /* Since the tuning time can be greater than the repeat timeout increase it to handle these cases */
4183                switch (p_event->id)
4184                {
4185                case eIR_UP: case eIR_CH_UP: case eIR_DOWN: case eIR_CH_DOWN:
4186                        p_bs->repeat_timeout += (DEFAULT_REPEAT_TIMEOUT/p_bs->repeat_rate); 
4187#ifdef BQAM_SCRIPT
4188/* Since 3409 can take so long to tune increase further */
4189                        p_bs->repeat_timeout += (DEFAULT_REPEAT_TIMEOUT/p_bs->repeat_rate); 
4190#endif
4191                        break;
4192                default: break;
4193                }
4194                break;
4195
4196        default:
4197        case eS_EVENT_SELECTED:
4198        case eS_EVENT_CHECKED:
4199                {
4200                        result = bscreen_default_event(v_app,v_screen,p_event);
4201                }
4202                break;
4203        }
4204
4205        return result;
4206}
4207
4208/*
4209Summary:
4210        screensaver screen event handler
4211Description:
4212        screensaver screen event handler.
4213        .
4214*/
4215int screen_screensaver_event(void *v_app, void *v_screen, 
4216                                                         bscreen_event_t *p_event)
4217{
4218        bapp_t *p_app = (bapp_t*)v_app;
4219        bscreen_t *p_screen = (bscreen_t*)v_screen;
4220        int result = 0;
4221        screensaver_state_t *p_ss = (screensaver_state_t*)p_screen->local_state;
4222        BDBG_ASSERT(p_ss);
4223
4224        switch (p_event->type)
4225        {
4226        case eS_EVENT_IDLE:
4227                if (bos_getticks() >= p_ss->image_swap_timeout)
4228                {
4229                        /* redraw window */
4230                        result = 1;
4231
4232                        p_ss->image_swap_timeout = bos_getticks() + MS_TO_TICKS(SCREENSAVER_IMAGE_TIMEOUT);
4233                }
4234
4235                if (!result)
4236                        result = bscreen_default_idle(v_app, v_screen);
4237                break;
4238        case eS_EVENT_SETUP:
4239                {
4240                        p_ss->image_swap_timeout = bos_getticks() + MS_TO_TICKS(SCREENSAVER_IMAGE_TIMEOUT);
4241                        bapp_set_palette(p_app, ePALETTE_SCREENSAVER);
4242                }
4243                break;
4244        case eS_EVENT_IR:
4245                if ((p_event->id & KEY_UP) == 0)
4246                {
4247                        bapp_set_palette(p_app, ePALETTE_DEFAULT);
4248                        screen_null_draw(v_app, v_screen);
4249                        bapp_goto_last_screen(p_app);
4250                        /* recheck ratings block status which may have changed while in screensaver */
4251                        bapp_handle_blocking(p_app);
4252                        result = 1;
4253                }
4254                break;
4255        default:
4256                break;
4257        }
4258        return result; /* always handle event */
4259}
4260
4261/*
4262Summary:
4263        Power off screen event handler
4264Description:
4265        Power off screen event handler.
4266        .
4267*/
4268int screen_power_off_event(void *v_app, void *v_screen, 
4269                                                   bscreen_event_t *p_event)
4270{
4271#ifdef CONFIG_SCREENSAVER
4272        bapp_t *p_app = (bapp_t*)v_app;
4273#endif
4274        int result = 0;
4275
4276        switch (p_event->type)
4277        {
4278        case eS_EVENT_SETUP:
4279#ifdef CONFIG_SCREENSAVER
4280                p_app->last_keypress_tick = bos_getticks();
4281                printf("#### %s:%d 0x%08x ####\n",__FUNCTION__,__LINE__,TICKS_TO_MS(p_app->last_keypress_tick));
4282#endif
4283                result = 1;
4284                break;
4285        default:
4286                break;
4287        }
4288        return result; /* always handle event */
4289}
4290
4291/*
4292Summary:
4293        Default screen event handler
4294Description:
4295        Default screen event handler.
4296        .
4297*/
4298int bscreen_default_event(void *v_app, void *v_screen, 
4299                                                  bscreen_event_t *p_event)
4300{
4301        bapp_t *p_app = (bapp_t*)v_app;
4302        bscreen_t *p_screen = (bscreen_t*)v_screen;
4303        int result = 0;
4304        switch (p_event->type)
4305        {
4306        default:
4307        case eS_EVENT_IDLE:
4308                result = bscreen_default_idle(v_app,v_screen);
4309                break;
4310
4311        case eS_EVENT_REDRAW:
4312                break;
4313
4314        case eS_EVENT_SETUP:
4315                bscreen_default_setup(v_app,v_screen);
4316                result = 1;
4317                break;
4318
4319        case eS_EVENT_SELECTED:
4320                result = (p_screen->button_selection == p_event->id) ? 1 : 0;
4321                break;
4322
4323        case eS_EVENT_CHECKED:
4324                result = (p_screen->button_checked == p_event->id) ? 1 : 0;
4325                break;
4326
4327        case eS_EVENT_IR:
4328                switch (p_event->id)
4329                {
4330                case eIR_INFO:
4331                        break;
4332                case eIR_LEFT:
4333                case eIR_MENU:
4334                        result = 1;
4335                        if (p_app->screen_id == eSCREEN_MAIN)
4336                                bapp_set_current_screen(p_app, eSCREEN_NULL, eSCREEN_NULL);
4337                        else
4338                                bapp_goto_last_screen(p_app);
4339
4340                        break;
4341                case eIR_RIGHT:
4342                case eIR_SELECT:
4343                        result = select_button(v_app,v_screen);
4344                        break;
4345                case eIR_UP:
4346                        result = next_button(v_app,v_screen,1);
4347                        break;
4348                case eIR_DOWN:
4349                        result = next_button(v_app,v_screen,0); 
4350                        break;
4351                case eIR_1:
4352                case eIR_2:
4353                case eIR_3:
4354                case eIR_4:
4355                case eIR_5:
4356                case eIR_6:
4357                case eIR_7:
4358                case eIR_8:
4359                case eIR_9:
4360                        if ((p_event->id - 1)  < p_screen->num_buttons)
4361                        {
4362                                bscreen_event_t event;
4363                                p_screen->button_selection = p_event->id - 1;
4364
4365                                event.id = eIR_SELECT;
4366                                event.type = eS_EVENT_IR;
4367                                result = p_screen->handle_event(p_app,p_screen,&event);
4368                        }
4369                        break;
4370                default:
4371                        /* Do nothing */
4372                        break;
4373                }
4374                break;
4375        }
4376        return result; /* always handle event */
4377}
4378/*
4379Summary:
4380        NULL screen drawing function
4381Description:
4382        NULL screen drawing function.
4383        .
4384*/
4385void screen_null_draw(void *v_app, void *v_screen)
4386{
4387        bapp_t *p_app = (bapp_t*)v_app;
4388        bgfx_fill_rect(&p_app->surf,0,0,eWIDTH,eHEIGHT,eCOLOR_CLEAR);
4389}
4390
4391/*
4392Summary:
4393        NULL screen drawing function for banner
4394Description:
4395        NULL screen drawing function for banner
4396        .
4397*/
4398void banner_null_draw(void *v_app, void *v_screen)
4399{
4400        bapp_t *p_app = (bapp_t*)v_app;
4401        if (bapp_eia708_enabled(p_app->eia708))
4402                return;
4403        bgfx_fill_rect(&p_app->surf,eBANNER_X,eBANNER_Y,
4404                                   eBANNER_WIDTH,eBANNER_SMALL_HEIGHT+eBANNER_LARGE_HEIGHT,eCOLOR_CLEAR);
4405}
4406
4407/*
4408Summary:
4409        NULL screen drawing function for status popup
4410Description:
4411        NULL screen drawing function for status popup
4412        .
4413*/
4414void popup_null_draw(void *v_app, void *v_screen)
4415{
4416        bapp_t *p_app = (bapp_t*)v_app;
4417        // bscreen_t *p_screen = (bscreen_t*)v_screen;
4418
4419        bgfx_fill_rect(&p_app->surf,eBANNER_STATUS_X,eBANNER_STATUS_Y,
4420                                   eBANNER_STATUS_WIDTH,eBANNER_STATUS_HEIGHT,eCOLOR_CLEAR);
4421}
4422
4423static void draw_navigation_hints(void *v_app, void *v_screen)
4424{
4425        bapp_t       * p_app     = (bapp_t*)v_app;
4426        bscreen_t    * p_screen  = (bscreen_t*)v_screen;
4427        unsigned int   num_chars = SCREEN_MAX_STR_WIDTH;
4428        int            w         = 0;
4429        int            h         = 0;
4430        int i;
4431
4432        bscreen_get_string(p_app->lang,p_screen->help_text_id, p_app->tmp_str, &num_chars);
4433        for (i = 0; i < num_chars; ++i)
4434        {
4435                if (p_app->tmp_str[i] == 0x00000031)
4436                {
4437                        p_app->tmp_str[i] = 0x193;/* up */
4438                }
4439                else if (p_app->tmp_str[i] == 0x00000032)
4440                {
4441                        p_app->tmp_str[i] = 0x194;/* down */
4442                }
4443                else if (p_app->tmp_str[i] == 0x00000033)
4444                {
4445                        p_app->tmp_str[i] = 0x195;/* left */
4446                }
4447                else if (p_app->tmp_str[i] == 0x00000034)
4448                {
4449                        p_app->tmp_str[i] = 0x196;/* right */
4450                }
4451        }
4452
4453        bgfx_string_info(p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],(const unsigned long *)p_app->tmp_str,num_chars,&w,&h);
4454        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
4455                                        ((eWIDTH/2)-(w/2)), eMENU_INFO_Y,
4456                                        w+5, eMENU_TITLE_TEXT_HEIGHT,  p_app->tmp_str,
4457                                        num_chars, eCOLOR_DK_YELLOW,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_TEXT_HEIGHT);
4458}
4459
4460/*
4461Summary:
4462        Default screen setup function
4463Description:
4464        Default screen setup function used to set initial state before drawing.
4465*/
4466void bscreen_default_setup(void *v_app, void *v_screen)
4467{
4468        bscreen_t *p_screen = (bscreen_t*)v_screen;
4469
4470        if ((p_screen->button_selection + 1) > p_screen->num_buttons)
4471                p_screen->button_selection = 0;
4472
4473        p_screen->button_checked = 0;
4474}
4475
4476/*
4477Summary:
4478        Default screen drawing function
4479Description:
4480        Default screen drawing function.
4481        .
4482*/
4483void bscreen_default_draw(void *v_app, void *v_screen)
4484{
4485        bapp_t *p_app = (bapp_t*)v_app;
4486        bscreen_t *p_screen = (bscreen_t*)v_screen;
4487        unsigned int num_chars;
4488        int yoff = 0;
4489        bscreen_draw_background(v_app, &p_app->surf, p_screen->top_banner_height);
4490
4491        if ((p_app->lang == eLANG_FRENCH) && (p_app->screen_id == eSCREEN_CAPTIONS_FONT))
4492                yoff += 7;
4493
4494        /* draw title */
4495        num_chars = SCREEN_MAX_STR_WIDTH;
4496        bscreen_get_string(p_app->lang,p_screen->title_text_id, p_app->tmp_str, &num_chars);
4497        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_LARGE],
4498                                        eMENU_TITLE_TEXT_X, eMENU_TITLE_TEXT_Y - yoff,
4499                                        eMENU_TITLE_TEXT_WIDTH, eMENU_TITLE_TEXT_HEIGHT,  p_app->tmp_str,
4500                                        num_chars, eCOLOR_DK_YELLOW,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_TEXT_HEIGHT);
4501
4502        if ((p_app->lang == eLANG_FRENCH) && (p_app->screen_id == eSCREEN_CAPTIONS_FONT))
4503                yoff += 4;
4504        /* draw description */
4505        num_chars = SCREEN_MAX_STR_WIDTH;
4506        bscreen_get_string(p_app->lang,p_screen->desc_text_id, p_app->tmp_str, &num_chars);
4507        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
4508                                        eMENU_TITLE_DESC_TEXT_X, eMENU_TITLE_DESC_TEXT_Y - yoff,
4509                                        eMENU_TITLE_DESC_TEXT_WIDTH, eMENU_TITLE_DESC_TEXT_HEIGHT,  p_app->tmp_str,
4510                                        num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_DESC_TEXT_SPACING);
4511
4512        bscreen_draw_buttons(v_app,v_screen);
4513
4514        draw_navigation_hints(v_app, v_screen);
4515}
4516
4517/*
4518Summary:
4519        Antenna screen drawing function
4520Description:
4521        Antenna screen drawing function.
4522        .
4523*/
4524void bscreen_antenna_draw(void *v_app, void *v_screen)
4525{
4526        bapp_t *p_app = (bapp_t*)v_app;
4527        bscreen_t *p_screen = (bscreen_t*)v_screen;
4528        int w, h;
4529        unsigned int num_chars;
4530        char strPercent[] = "100%";
4531        static char version[128];
4532
4533        bscreen_draw_background(v_app, &p_app->surf, p_screen->top_banner_height);
4534
4535        /* draw title */
4536        num_chars = SCREEN_MAX_STR_WIDTH;
4537        bscreen_get_string(p_app->lang,p_screen->title_text_id, p_app->tmp_str, &num_chars);
4538        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_LARGE],
4539                                        eMENU_TITLE_TEXT_X, eMENU_TITLE_TEXT_Y,
4540                                        eMENU_TITLE_TEXT_WIDTH, eMENU_TITLE_TEXT_HEIGHT,  p_app->tmp_str,
4541                                        num_chars, eCOLOR_MED_YELLOW,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_TEXT_HEIGHT);
4542
4543        /* draw description */
4544        num_chars = SCREEN_MAX_STR_WIDTH;
4545        bscreen_get_string(p_app->lang,p_screen->desc_text_id, p_app->tmp_str, &num_chars);
4546        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
4547                                        eMENU_TITLE_DESC_TEXT_X, eMENU_TITLE_DESC_TEXT_Y,
4548                                        eMENU_TITLE_DESC_TEXT_WIDTH, eMENU_TITLE_DESC_TEXT_HEIGHT,  p_app->tmp_str,
4549                                        num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_DESC_TEXT_SPACING);
4550
4551        /* draw progress meter label */
4552        num_chars = SCREEN_MAX_STR_WIDTH;
4553        bscreen_get_string(p_app->lang,eTEXT_SIGNAL_LEVEL, p_app->tmp_str, &num_chars);
4554        bgfx_string_info(p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],(const unsigned long *)p_app->tmp_str,num_chars,&w,&h);
4555        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
4556                                        ePROGRESS_X, ePROGRESS_Y - h - ePROGRESS_LABEL_SPACING, w + 1, h,  p_app->tmp_str,
4557                                        num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_DESC_TEXT_SPACING);
4558
4559        /* draw progress meter */
4560        bscreen_draw_progress(v_app, ePROGRESS_X, ePROGRESS_Y, ePROGRESS_WIDTH, ePROGRESS_HEIGHT, 
4561                                                  eBUTTON_PROGRESS_BORDER, eCOLOR_WHITE, eCOLOR_DRK_BLUE, p_app->tmp_value);
4562
4563        /* draw percent compete text */
4564        num_chars = SCREEN_MAX_STR_WIDTH;
4565        snprintf(strPercent, strlen(strPercent), "%3d%%", p_app->tmp_value);
4566        num_chars = c_to_uni_str(strPercent,p_app->tmp_str,num_chars);
4567        bgfx_string_info(p_app->p_font[p_app->lang][eFONT_SIZE_MED],(const unsigned long *)p_app->tmp_str,num_chars,&w,&h);
4568        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_MED],
4569                                        ePROGRESS_X + ePROGRESS_WIDTH + ePROGRESS_LABEL_SPACING, ePROGRESS_Y + (ePROGRESS_HEIGHT / 2) - (h / 2), 
4570                                        w + 10, h,  p_app->tmp_str,
4571                                        num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_DESC_TEXT_SPACING);
4572
4573        draw_navigation_hints(v_app, v_screen);
4574
4575        num_chars = SCREEN_MAX_STR_WIDTH;
4576        snprintf(version, 128, "Version:  %d.%d.%d, %s", MAJOR_VERSION,MINOR_VERSION,SUB_VERSION,__DATE__);
4577        num_chars = c_to_uni_str(version,p_app->tmp_str,num_chars);
4578        bgfx_string_info(p_app->p_font[p_app->lang][eFONT_SIZE_MED],(const unsigned long *)p_app->tmp_str,num_chars,&w,&h);
4579        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
4580                                        ePROGRESS_X, eMENU_INFO_Y - (2 * h), 
4581                                        w, h,  p_app->tmp_str,
4582                                        num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_DESC_TEXT_SPACING);
4583}
4584
4585/*
4586Summary:
4587        Ch scan progress screen drawing function
4588Description:
4589        Ch scan progress screen drawing function.
4590        .
4591*/
4592void bscreen_ch_scan_progress_draw(void *v_app, void *v_screen)
4593{
4594        bapp_t *p_app = (bapp_t*)v_app;
4595        bscreen_t *p_screen = (bscreen_t*)v_screen;
4596        int w, h;
4597        unsigned int num_chars;
4598        char strPercent[] = "100%";
4599
4600        bscreen_draw_background(v_app, &p_app->surf, p_screen->top_banner_height);
4601
4602        /* draw title */
4603        num_chars = SCREEN_MAX_STR_WIDTH;
4604        bscreen_get_string(p_app->lang,p_screen->title_text_id, p_app->tmp_str, &num_chars);
4605        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_LARGE],
4606                                        eMENU_TITLE_TEXT_X, eMENU_TITLE_TEXT_Y,
4607                                        eMENU_TITLE_TEXT_WIDTH, eMENU_TITLE_TEXT_HEIGHT,  p_app->tmp_str,
4608                                        num_chars, eCOLOR_MED_YELLOW,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_TEXT_HEIGHT);
4609
4610        /* draw description */
4611        num_chars = SCREEN_MAX_STR_WIDTH;
4612        bscreen_get_string(p_app->lang,p_screen->desc_text_id, p_app->tmp_str, &num_chars);
4613        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
4614                                        eMENU_TITLE_DESC_TEXT_X, eMENU_TITLE_DESC_TEXT_Y,
4615                                        eMENU_TITLE_DESC_TEXT_WIDTH, eMENU_TITLE_DESC_TEXT_HEIGHT,  p_app->tmp_str,
4616                                        num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_DESC_TEXT_SPACING);
4617
4618        /* draw progress meter label */
4619        num_chars = SCREEN_MAX_STR_WIDTH;
4620        bscreen_get_string(p_app->lang,eTEXT_CH_SCAN_COMPLETE_LEVEL, p_app->tmp_str, &num_chars);
4621        bgfx_string_info(p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],(const unsigned long *)p_app->tmp_str,num_chars,&w,&h);
4622        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
4623                                        ePROGRESS_X, ePROGRESS_Y - h - ePROGRESS_LABEL_SPACING, w + 1, h,  p_app->tmp_str,
4624                                        num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_DESC_TEXT_SPACING);
4625
4626        /* draw progress meter */
4627        bscreen_draw_progress(v_app, ePROGRESS_X, ePROGRESS_Y, ePROGRESS_WIDTH, ePROGRESS_HEIGHT, 
4628                                                  eBUTTON_PROGRESS_BORDER, eCOLOR_WHITE, eCOLOR_DRK_BLUE, p_app->tmp_value);
4629
4630        /* draw percent compete text */
4631        num_chars = SCREEN_MAX_STR_WIDTH;
4632        snprintf(strPercent, strlen(strPercent), "%3d%%", p_app->tmp_value);
4633        num_chars = c_to_uni_str(strPercent,p_app->tmp_str,num_chars);
4634        bgfx_string_info(p_app->p_font[p_app->lang][eFONT_SIZE_MED],(const unsigned long *)p_app->tmp_str,num_chars,&w,&h);
4635        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_MED],
4636                                        ePROGRESS_X + ePROGRESS_WIDTH + ePROGRESS_LABEL_SPACING, ePROGRESS_Y + (ePROGRESS_HEIGHT / 2) - (h / 2), 
4637                                        w + 10, h,  p_app->tmp_str,
4638                                        num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_DESC_TEXT_SPACING);
4639
4640        /* draw number of channels found */
4641        num_chars = SCREEN_MAX_STR_WIDTH;
4642        bscreen_get_string(p_app->lang,eTEXT_CH_SCAN_FOUND, p_app->tmp_str, &num_chars);
4643        bgfx_string_info(p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],(const unsigned long *)p_app->tmp_str,num_chars,&w,&h);
4644        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
4645                                        ePROGRESS_X, ePROGRESS_Y + (ePROGRESS_HEIGHT * 2) , w + 1, h,  p_app->tmp_str,
4646                                        num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_DESC_TEXT_SPACING);
4647
4648        draw_navigation_hints(v_app, v_screen);
4649}
4650
4651/*
4652Summary:
4653        Wizard welcome screen drawing function
4654Description:
4655        Wizard welcome screen drawing function.
4656        .
4657*/
4658void bscreen_wiz_welcome_draw(void *v_app, void *v_screen)
4659{
4660        bapp_t *p_app = (bapp_t*)v_app;
4661        bscreen_t *p_screen = (bscreen_t*)v_screen;
4662        unsigned int num_chars;
4663#ifndef CONFIG_LOGO
4664#else
4665#error "No Logo"
4666        bin_read_t br;
4667        br.cnt = 0;
4668        br.data = (void*)g_p_dsp->ui_comp.logo;
4669        br.size = g_p_dsp->ui_comp.logo_size;
4670#endif
4671        bscreen_draw_background(v_app, &p_app->surf, p_screen->top_banner_height);
4672
4673        /* draw title */
4674        num_chars = SCREEN_MAX_STR_WIDTH;
4675        bscreen_get_string(p_app->lang,p_screen->title_text_id, p_app->tmp_str, &num_chars);
4676        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_LARGE],
4677                                        eMENU_TITLE_TEXT_X, eMENU_TITLE_TEXT_Y,
4678                                        eMENU_TITLE_TEXT_WIDTH, eMENU_TITLE_TEXT_HEIGHT,  p_app->tmp_str,
4679                                        num_chars, eCOLOR_MED_YELLOW,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_TEXT_HEIGHT);
4680
4681        /* draw description */
4682        num_chars = SCREEN_MAX_STR_WIDTH;
4683        bscreen_get_string(p_app->lang,p_screen->desc_text_id, p_app->tmp_str, &num_chars);
4684        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
4685                                        eMENU_TITLE_DESC_TEXT_X, eMENU_TITLE_DESC_TEXT_Y,
4686                                        eMENU_TITLE_DESC_TEXT_WIDTH, eMENU_TITLE_DESC_TEXT_HEIGHT,  p_app->tmp_str,
4687                                        num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_DESC_TEXT_SPACING);
4688
4689        bscreen_draw_buttons(v_app,v_screen);
4690
4691        /* TODO: draw logo */
4692#ifdef CONFIG_LOGO
4693        bgfx_render_file(&(p_app->surf), eLOGO_X, eLOGO_Y, &br, 0);
4694#endif
4695
4696        draw_navigation_hints(v_app, v_screen);
4697}
4698
4699/*
4700Summary:
4701        Wizard done screen drawing function
4702Description:
4703        Wizard done screen drawing function.
4704        .
4705*/
4706void bscreen_wiz_done_draw(void *v_app, void *v_screen)
4707{
4708        bapp_t *p_app = (bapp_t*)v_app;
4709        bscreen_t *p_screen = (bscreen_t*)v_screen;
4710        unsigned int num_chars;
4711#ifndef CONFIG_LOGO
4712#else
4713        bin_read_t br;
4714        br.cnt = 0;
4715        br.data = (void*)g_p_dsp->ui_comp.logo;
4716        br.size = g_p_dsp->ui_comp.logo_size;
4717#endif
4718        bscreen_draw_background(v_app, &p_app->surf, p_screen->top_banner_height);
4719
4720        /* draw title */
4721        num_chars = SCREEN_MAX_STR_WIDTH;
4722        bscreen_get_string(p_app->lang,p_screen->title_text_id, p_app->tmp_str, &num_chars);
4723        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_LARGE],
4724                                        eMENU_TITLE_TEXT_X, eMENU_TITLE_TEXT_Y,
4725                                        eMENU_TITLE_TEXT_WIDTH, eMENU_TITLE_TEXT_HEIGHT,  p_app->tmp_str,
4726                                        num_chars, eCOLOR_MED_YELLOW,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_TEXT_HEIGHT);
4727
4728        /* draw description */
4729        num_chars = SCREEN_MAX_STR_WIDTH;
4730        bscreen_get_string(p_app->lang,p_screen->desc_text_id, p_app->tmp_str, &num_chars);
4731        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
4732                                        eMENU_TITLE_DESC_TEXT_X, eMENU_TITLE_DESC_TEXT_Y,
4733                                        eMENU_TITLE_DESC_TEXT_WIDTH, eMENU_TITLE_DESC_TEXT_HEIGHT,  p_app->tmp_str,
4734                                        num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_DESC_TEXT_SPACING);
4735
4736        bscreen_draw_buttons(v_app,v_screen);
4737
4738        /* TODO: draw logo */
4739#ifdef CONFIG_LOGO
4740        bgfx_render_file(&(p_app->surf), eLOGO_X, eLOGO_Y, &br, 0);
4741#endif
4742
4743        draw_navigation_hints(v_app, v_screen);
4744}
4745
4746/*
4747Summary:
4748        Wiz ch scan screen drawing function
4749Description:
4750        Wiz ch scan screen drawing function.
4751        .
4752*/
4753void bscreen_wiz_ch_scan_draw(void *v_app, void *v_screen)
4754{
4755        bapp_t *p_app = (bapp_t*)v_app;
4756        bscreen_t *p_screen = (bscreen_t*)v_screen;
4757        unsigned int num_chars;
4758        int w, h;
4759        char strChFound[5];
4760
4761        bscreen_draw_background(v_app, &p_app->surf, p_screen->top_banner_height);
4762
4763        /* draw title */
4764        num_chars = SCREEN_MAX_STR_WIDTH;
4765        bscreen_get_string(p_app->lang,p_screen->title_text_id, p_app->tmp_str, &num_chars);
4766        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_LARGE],
4767                                        eMENU_TITLE_TEXT_X, eMENU_TITLE_TEXT_Y,
4768                                        eMENU_TITLE_TEXT_WIDTH, eMENU_TITLE_TEXT_HEIGHT,  p_app->tmp_str,
4769                                        num_chars, eCOLOR_MED_YELLOW,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_TEXT_HEIGHT);
4770
4771        /* draw description */
4772        num_chars = SCREEN_MAX_STR_WIDTH;
4773        bscreen_get_string(p_app->lang,p_screen->desc_text_id, p_app->tmp_str, &num_chars);
4774        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
4775                                        eMENU_TITLE_DESC_TEXT_X, eMENU_TITLE_DESC_TEXT_Y,
4776                                        eMENU_TITLE_DESC_TEXT_WIDTH, eMENU_TITLE_DESC_TEXT_HEIGHT,  p_app->tmp_str,
4777                                        num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_DESC_TEXT_SPACING);
4778
4779        bscreen_draw_buttons(v_app,v_screen);
4780
4781        /* draw number of channels found (text) */
4782        num_chars = SCREEN_MAX_STR_WIDTH;
4783        bscreen_get_string(p_app->lang,eTEXT_WIZ_CH_SCAN_NUM_CHANNELS, p_app->tmp_str, &num_chars);
4784        bgfx_string_info(p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],(const unsigned long *)p_app->tmp_str,num_chars,&w,&h);
4785        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
4786                                        ePROGRESS_X, eMENU_INFO_Y - ePROGRESS_HEIGHT + 8 , w + 1, h,  p_app->tmp_str,
4787                                        num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_DESC_TEXT_SPACING);
4788
4789        /* draw number of channels found (number) */
4790        num_chars = SCREEN_MAX_STR_WIDTH;
4791        snprintf(strChFound, 4, "%3d", p_app->settings.num_channels);
4792        num_chars = c_to_uni_str(strChFound,p_app->tmp_str,num_chars);
4793        bgfx_fill_rect(&p_app->surf,ePROGRESS_X + w,
4794                                   eMENU_INFO_Y - ePROGRESS_HEIGHT, 40, eMENU_TITLE_TEXT_HEIGHT,eCOLOR_MED_BLUE);
4795        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
4796                                        ePROGRESS_X + w, eMENU_INFO_Y - ePROGRESS_HEIGHT + 8 , 40, eMENU_TITLE_TEXT_HEIGHT, p_app->tmp_str,
4797                                        num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_DESC_TEXT_SPACING);
4798
4799        draw_navigation_hints(v_app, v_screen);
4800}
4801
4802
4803/*
4804Summary:
4805        PIN screen drawing function
4806Description:
4807        PIN screen drawing function.
4808        .
4809*/
4810void bscreen_pin_draw(void *v_app, void *v_screen)
4811{
4812        bapp_t *p_app = (bapp_t*)v_app;
4813        bscreen_t *p_screen = (bscreen_t*)v_screen;
4814        unsigned int num_chars,w,h;
4815        unsigned int field = 0;
4816        static char tmp_prog[64];
4817
4818        bscreen_draw_background(v_app, &p_app->surf, p_screen->top_banner_height);
4819
4820        /* draw title */
4821        num_chars = SCREEN_MAX_STR_WIDTH;
4822        bscreen_get_string(p_app->lang,p_screen->title_text_id, p_app->tmp_str, &num_chars);
4823        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_LARGE],
4824                                        eMENU_TITLE_TEXT_X, eMENU_TITLE_TEXT_Y,
4825                                        eMENU_TITLE_TEXT_WIDTH, eMENU_TITLE_TEXT_HEIGHT,  p_app->tmp_str,
4826                                        num_chars, eCOLOR_MED_YELLOW,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_TEXT_HEIGHT);
4827
4828        /* draw description */
4829        num_chars = SCREEN_MAX_STR_WIDTH;
4830        bscreen_get_string(p_app->lang,p_screen->desc_text_id, p_app->tmp_str, &num_chars);
4831        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
4832                                        eMENU_TITLE_DESC_TEXT_X, eMENU_TITLE_DESC_TEXT_Y,
4833                                        eMENU_TITLE_DESC_TEXT_WIDTH, eMENU_TITLE_DESC_TEXT_HEIGHT,  p_app->tmp_str,
4834                                        num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_DESC_TEXT_SPACING);
4835
4836        if (p_app->screen_id == eSCREEN_PIN_VERIFY_LIVE)
4837        {
4838                /* draw ratings - show blocked rating, if no blocked ratings then show received
4839                        xds or psip rating if corresponding rating string exists */
4840                num_chars = SCREEN_MAX_STR_WIDTH;
4841                tmp_prog[0] = 0;
4842                bscreen_get_string(p_app->lang,eTEXT_RATINGS_BUTTON, p_app->tmp_str, &num_chars);
4843                p_app->tmp_str[num_chars++] = (unsigned int)':';
4844                p_app->tmp_str[num_chars++] = (unsigned int)' ';
4845                p_app->tmp_str[num_chars++] = (unsigned int)' ';
4846                text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_MED],
4847                                                eMENU_TITLE_DESC_TEXT_X, eMENU_TITLE_DESC_TEXT_Y + 60, eMENU_TITLE_DESC_TEXT_WIDTH, eMENU_TITLE_DESC_TEXT_HEIGHT, 
4848                                                p_app->tmp_str, num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,0);
4849                bgfx_string_info(p_app->p_font[p_app->lang][eFONT_SIZE_MED],(const unsigned long *)p_app->tmp_str,num_chars,&w,&h);
4850                if (p_app->prog_rating_str[0] != 0)
4851                {
4852                        strncpy_no_spaces(tmp_prog,(char*)p_app->prog_rating_str,63);
4853                        BDBG_WRN(("%s - analog: %s\n",__FUNCTION__, tmp_prog));
4854                }
4855
4856                if (p_app->psip_rating_str[0] != 0)
4857                {
4858                        strncpy_no_spaces(tmp_prog,(char*)p_app->psip_rating_str,63);
4859                        BDBG_WRN(("%s - digital: %s\n",__FUNCTION__, tmp_prog));
4860                }
4861
4862                num_chars = strlen(tmp_prog);
4863                if (num_chars)
4864                {
4865                        num_chars = c_to_uni_str(tmp_prog,p_app->tmp_str,num_chars);
4866                        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_MED],
4867                                                        eMENU_TITLE_DESC_TEXT_X + w, eMENU_TITLE_DESC_TEXT_Y + 60, eMENU_TITLE_DESC_TEXT_WIDTH, eBANNER_TITLE_HEIGHT, 
4868                                                        p_app->tmp_str, num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,0);
4869                }
4870                else
4871                {
4872                        BDBG_WRN(("%s - rating string empty\n",__FUNCTION__));
4873                }
4874        }
4875
4876        /* draw pin fields */
4877        for (field = 0; field < 4; field++)
4878        {
4879                bscreen_draw_pin(v_app, ePIN_X, ePIN_Y+(p_screen->top_banner_height-eMENU_TITLE_AREA_HEIGHT_1_LINE)/2, 
4880                                                 ePIN_WIDTH, ePIN_HEIGHT, ePIN_INC_X, p_app->tmp_value, field);
4881        }
4882
4883        draw_navigation_hints(v_app, v_screen);
4884}
4885
4886
4887/*
4888Summary:
4889        Popup screen drawing function
4890Description:
4891        Popup screen drawing function. 
4892        If 'desc' is set to eTEXT_MAX then banner height is adjusted to show the title only.
4893        If 'title' is set to eTEXT_VOLUME_TITLE then volume slider is displayed next to title.
4894        If 'title' and 'desc' are set to eTEXT_MAX then popup is hidden.
4895        .
4896*/
4897
4898#define TMP_BUF_CHAR_MAX        16
4899static char tmp_buf[TMP_BUF_CHAR_MAX];
4900void bscreen_popup_draw(void *v_app, void *v_screen, btext_id_t title, btext_id_t desc)
4901{
4902        bapp_t *p_app = (bapp_t*)v_app;
4903        int i = 0;
4904        unsigned int progress_width = 0;
4905        int w = 0;
4906        int h = 0;
4907        unsigned int num_chars;
4908        unsigned int banner_height  = eBANNER_STATUS_HEIGHT;
4909        unsigned int banner_y       = eBANNER_STATUS_Y;
4910        unsigned int banner_title_y = eBANNER_POPUP_TITLE_Y;
4911        unsigned int title_newX     = eBANNER_POPUP_TITLE_X;
4912        static unsigned int last_title = eTEXT_MAX;
4913        static bapp_lang_t  last_lang  = eLANG_MAX;
4914
4915        if (bapp_eia708_enabled(p_app->eia708))
4916                return;
4917
4918        if (p_app->screen_id != eSCREEN_BANNER_SMALL)
4919                return;
4920
4921#ifndef CONFIG_ORIG_SYNC
4922        bapp_sync(p_app);
4923#endif
4924
4925        if ((title == eTEXT_MAX) && (desc == eTEXT_MAX))
4926        {
4927                popup_null_draw(v_app,v_screen);
4928                last_title = eTEXT_MAX;
4929                last_lang  = eLANG_MAX;
4930#ifndef CONFIG_ORIG_SYNC
4931                bapp_flush_screen(p_app);
4932#endif
4933                return;
4934        }
4935
4936        if ((last_title != title) || (last_lang != p_app->lang))
4937                popup_null_draw(v_app,v_screen);
4938
4939        if (desc == eTEXT_MAX)
4940        {
4941                /* resize banner for title only display */
4942                banner_y       += eBANNER_STATUS_TITLE_ONLY_Y_OFFSET;
4943                banner_height  =  eBANNER_STATUS_TITLE_ONLY_HEIGHT;
4944                banner_title_y += eBANNER_STATUS_TITLE_ONLY_Y_OFFSET;
4945        }
4946
4947        /* do not draw these parts if already shown */
4948        /* JPF if ((last_title != title) || (last_lang != p_app->lang)) */
4949        {
4950#ifdef CONFIG_ORIG_SYNC
4951                bapp_sync(p_app);
4952#endif
4953
4954                /* draw popup with semi-transparent background */
4955                bgfx_fill_rect(&p_app->surf,eBANNER_STATUS_X,banner_y,
4956                                           eBANNER_STATUS_WIDTH,banner_height,eCOLOR_BLACK);
4957
4958                for (i = 0; i < 4; i++)
4959                {
4960                        bgfx_h_draw_line(&p_app->surf,eBANNER_STATUS_X+i,eBANNER_STATUS_X+eBANNER_STATUS_WIDTH-i,
4961                                                         banner_y+i,eCOLOR_BLACK);
4962                        bgfx_h_draw_line(&p_app->surf,eBANNER_STATUS_X+i,eBANNER_STATUS_X+eBANNER_STATUS_WIDTH-i,
4963                                                         banner_y+banner_height-1-i,eCOLOR_BLACK);
4964                }
4965
4966                /* draw popup title */
4967                if (title != eTEXT_MAX)
4968                {
4969                        num_chars = MAX_TITLE_CHARS;
4970                        bscreen_get_string(p_app->lang,title, p_app->tmp_str, &num_chars);
4971                        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
4972                                                        title_newX, banner_title_y, 
4973                                                        eBANNER_POPUP_TITLE_WIDTH, eBANNER_POPUP_TITLE_HEIGHT, 
4974                                                        p_app->tmp_str, num_chars, eCOLOR_DK_YELLOW,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,100);
4975                }
4976
4977#ifdef CONFIG_ORIG_SYNC
4978                bapp_flush_screen(p_app);
4979#endif
4980
4981                /* draw popup description field */
4982                if (desc != eTEXT_MAX)
4983                {
4984                        static char strAutoPower[1024];
4985                        char* p_str;
4986#ifdef CONFIG_ORIG_SYNC
4987                        bapp_sync(p_app);
4988#endif
4989                        num_chars = MAX_DESC_CHARS;
4990                        if (desc == eTEXT_AUTO_POWER_RESTART_DESC)
4991                        {
4992                                p_str = (char*)g_p_dsp->ui_comp.str_table[p_app->lang][eTEXT_AUTO_POWER_RESTART_DESC];
4993                                snprintf(strAutoPower, 1024, p_str, (p_app->settings.auto_power + 1) * 4);
4994                                num_chars = c_to_uni_str(strAutoPower, p_app->tmp_str, MAX_DESC_CHARS);
4995                        } else
4996                                if (desc == eTEXT_AUTO_POWER_POPUP_DESC)
4997                        {
4998                                p_str = (char*)g_p_dsp->ui_comp.str_table[p_app->lang][eTEXT_AUTO_POWER_POPUP_DESC];
4999                                snprintf(strAutoPower, 1024, p_str, (p_app->settings.auto_power + 1) * 4);
5000                                num_chars = c_to_uni_str(strAutoPower, p_app->tmp_str, MAX_DESC_CHARS);
5001                        } else
5002                        {
5003                                bscreen_get_string(p_app->lang,desc, p_app->tmp_str, &num_chars);
5004                        }
5005                        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
5006                                                        eBANNER_POPUP_DESC_X, 
5007                                                        (title == eTEXT_MAX ? banner_title_y : eBANNER_POPUP_DESC_Y), 
5008                                                        eBANNER_POPUP_DESC_WIDTH, 
5009                                                        (title == eTEXT_MAX ? eBANNER_POPUP_DESC_HEIGHT + 10 : eBANNER_POPUP_DESC_HEIGHT), 
5010                                                        p_app->tmp_str, num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,5);
5011#ifdef CONFIG_ORIG_SYNC
5012                        bapp_flush_screen(p_app);
5013#endif
5014                }
5015        }
5016
5017        /* add SAP language if necessary */
5018        if ((title == eTEXT_SAP_TITLE) || (title == eTEXT_VOLUME_TITLE))
5019        {
5020                w = h = 0;
5021                /* move title_newX past title */
5022                num_chars = MAX_TITLE_CHARS;
5023                bscreen_get_string(p_app->lang,title, p_app->tmp_str, &num_chars);
5024                bgfx_string_info(p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],(const unsigned long *)p_app->tmp_str,num_chars,&w,&h);
5025                title_newX += w;
5026
5027                num_chars = MAX_TITLE_CHARS;
5028                if (p_app->settings.ch[p_app->cur_ch_num].has_lang & (1 << p_app->current_sap))
5029                {
5030                        switch (p_app->current_sap)
5031                        {
5032                        case eLANG_SPANISH:
5033                                bscreen_get_string(p_app->current_sap,eTEXT_SPANISH_BUTTON, p_app->tmp_str, &num_chars);
5034                                break;
5035                        case eLANG_FRENCH:
5036                                bscreen_get_string(p_app->current_sap,eTEXT_FRENCH_BUTTON, p_app->tmp_str, &num_chars);
5037                                break;
5038                        case eLANG_ENGLISH:
5039                        default:
5040                                bscreen_get_string(p_app->current_sap,eTEXT_ENGLISH_BUTTON, p_app->tmp_str, &num_chars);
5041                                break;
5042                        }
5043                } else
5044                {
5045                        memset(tmp_buf,0,TMP_BUF_CHAR_MAX);
5046                        num_chars = TMP_BUF_CHAR_MAX - 1;
5047                        snprintf(tmp_buf, num_chars, "Audio-%d", p_app->current_sap + 1);
5048                        num_chars = c_to_uni_str(tmp_buf,p_app->tmp_str,MAX_TITLE_CHARS);
5049                }
5050
5051                /* add ending parenthesis if volume popup */
5052                if ((title == eTEXT_VOLUME_TITLE) && (num_chars < MAX_TITLE_CHARS))
5053                {
5054                        c_to_uni_str(")",&p_app->tmp_str[num_chars],2);
5055                        num_chars++;
5056                }
5057
5058                /* erase last language text */
5059                bgfx_fill_rect(&p_app->surf,eBANNER_POPUP_TITLE_X + w,banner_title_y,
5060                                           eBANNER_POPUP_TITLE_WIDTH - w, eBANNER_POPUP_TITLE_HEIGHT, eCOLOR_BLACK);
5061
5062                text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
5063                                                title_newX, banner_title_y, 
5064                                                eBANNER_POPUP_TITLE_WIDTH - w, eBANNER_POPUP_TITLE_HEIGHT, 
5065                                                p_app->tmp_str, num_chars, eCOLOR_DK_YELLOW,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,100);
5066        }
5067
5068        /* add CC language if necessary */
5069        if (title == eTEXT_CC_TITLE)
5070        {
5071                int w = 0;
5072                int h = 0;
5073
5074                /* move title_newX past title */
5075                num_chars = MAX_TITLE_CHARS;
5076                bscreen_get_string(p_app->lang,title, p_app->tmp_str, &num_chars);
5077                bgfx_string_info(p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],(const unsigned long *)p_app->tmp_str,num_chars,&w,&h);
5078                title_newX += w;
5079
5080                num_chars = MAX_TITLE_CHARS;
5081
5082                if (p_app->captions_basic > 0)
5083                {
5084                        char strCC[16];
5085                        PSIP_CSD_service *cc_service = &(p_app->tmp_info.eit_info[EIT_CURRENT].cc_service[p_app->captions_basic - 1]);
5086                        if (cc_service->cc_type)
5087                        {
5088                                snprintf(strCC, 15, "%d (%c%c%c)", p_app->captions_basic,cc_service->language[0],cc_service->language[1],cc_service->language[2]);
5089                        } else
5090                                snprintf(strCC, 15, "%d", p_app->captions_basic);
5091                        num_chars = c_to_uni_str(strCC, p_app->tmp_str, MAX_TITLE_CHARS);
5092                } else
5093                {
5094                        num_chars = c_to_uni_str("Captions Off", p_app->tmp_str, MAX_TITLE_CHARS);
5095                }
5096
5097                /* erase last caption popup text */
5098                bgfx_fill_rect(&p_app->surf,eBANNER_POPUP_TITLE_X + w,banner_title_y,
5099                                           eBANNER_POPUP_TITLE_WIDTH - w, eBANNER_POPUP_TITLE_HEIGHT, eCOLOR_BLACK);
5100
5101                text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
5102                                                title_newX, banner_title_y, 
5103                                                eBANNER_POPUP_TITLE_WIDTH - w, eBANNER_POPUP_TITLE_HEIGHT, 
5104                                                p_app->tmp_str, num_chars, eCOLOR_DK_YELLOW,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,100);
5105        }
5106
5107        /* draw volume slider if necessary */
5108        if (title == eTEXT_VOLUME_TITLE)
5109        {
5110                w = h = 0;
5111
5112                bgfx_string_info(p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],(const unsigned long *)p_app->tmp_str,num_chars,&w,&h);
5113                title_newX += w + 10;
5114                progress_width = eBANNER_STATUS_X + eBANNER_STATUS_WIDTH - title_newX - 75;
5115                bscreen_draw_progress(v_app, title_newX, banner_title_y-2, progress_width, ePROGRESS_VOLUME_HEIGHT, 
5116                                                          eBUTTON_VOL_PROGRESS_BORDER, eCOLOR_WHITE, eCOLOR_BLACK, p_app->audio_vol);
5117
5118                /* draw volume level text */
5119                memset(tmp_buf,0,sizeof(TMP_BUF_CHAR_MAX));
5120                num_chars = TMP_BUF_CHAR_MAX - 1;
5121                snprintf(tmp_buf, num_chars, "%3u", p_app->audio_vol);
5122                num_chars = c_to_uni_str(tmp_buf,p_app->tmp_str,MAX_TITLE_CHARS);
5123#ifdef CONFIG_ORIG_SYNC
5124                bapp_sync(p_app);
5125#endif
5126                bgfx_fill_rect(&p_app->surf,ePROGRESS_VOLUME_X+ePROGRESS_VOLUME_WIDTH+10,banner_title_y,
5127                                           eBANNER_POPUP_VOL_TITLE_WIDTH,eBANNER_POPUP_TITLE_HEIGHT,eCOLOR_BLACK);
5128                text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
5129                                                ePROGRESS_VOLUME_X+ePROGRESS_VOLUME_WIDTH+10, banner_title_y, 
5130                                                eBANNER_POPUP_VOL_TITLE_WIDTH, eBANNER_POPUP_TITLE_HEIGHT, 
5131                                                p_app->tmp_str, num_chars, eCOLOR_DK_YELLOW,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,0);
5132#ifdef CONFIG_ORIG_SYNC
5133                bapp_flush_screen(p_app);
5134#endif
5135        }
5136#ifndef CONFIG_ORIG_SYNC
5137        bapp_flush_screen(p_app);
5138#endif
5139
5140        last_title = title;
5141        last_lang  = p_app->lang;
5142}
5143
5144
5145/*
5146Summary:
5147        RRT dimensions screen drawing function
5148Description:
5149        RRT dimensions screen drawing function.
5150        .
5151*/
5152void bscreen_rrt_dim_draw(void *v_app, void *v_screen)
5153{
5154        bapp_t *p_app = (bapp_t*)v_app;
5155        bscreen_t *p_screen = (bscreen_t*)v_screen;
5156        int idx,selected,checked, max_rrt_num;
5157        unsigned int num_chars;
5158        bbutton_t tmp_button;
5159        PSIP_RRT_dimension dim;
5160        PSIP_RRT_header rrt_header;
5161        char dim_str[64];
5162       
5163        bscreen_draw_background(v_app, &p_app->surf, p_screen->top_banner_height);
5164
5165        /* draw title */
5166        num_chars = SCREEN_MAX_STR_WIDTH;
5167        bscreen_get_string(p_app->lang,p_screen->title_text_id, p_app->tmp_str, &num_chars);
5168        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_LARGE],
5169                                        eMENU_TITLE_TEXT_X, eMENU_TITLE_TEXT_Y,
5170                                        eMENU_TITLE_TEXT_WIDTH, eMENU_TITLE_TEXT_HEIGHT,  p_app->tmp_str,
5171                                        num_chars, eCOLOR_DK_YELLOW,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_TEXT_HEIGHT);
5172
5173        /* draw description */
5174        num_chars = SCREEN_MAX_STR_WIDTH;
5175        bscreen_get_string(p_app->lang,p_screen->desc_text_id, p_app->tmp_str, &num_chars);
5176        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
5177                                        eMENU_TITLE_DESC_TEXT_X, eMENU_TITLE_DESC_TEXT_Y,
5178                                        eMENU_TITLE_DESC_TEXT_WIDTH, eMENU_TITLE_DESC_TEXT_HEIGHT,  p_app->tmp_str,
5179                                        num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_DESC_TEXT_SPACING);
5180
5181#ifdef TEST_RRT
5182        max_rrt_num = MAX_RRT_DIM;
5183#else
5184        PSIP_RRT_getHeader(p_app->settings.rrt,&rrt_header);
5185        max_rrt_num = SCREEN_MIN((p_screen->local_state + MAX_RRT_DIM_BUTTONS), rrt_header.dimensions_defined);
5186#endif
5187        /* draw buttons (replace text with strings from the RRT) */
5188        for (idx = p_screen->local_state; idx < max_rrt_num; idx++)
5189        {
5190                if ((idx - p_screen->local_state) >= MAX_RRT_DIM_BUTTONS)
5191                {
5192                        BDBG_WRN(("%s invalid button index %d, %d, %d\n",__FUNCTION__,idx,p_screen->local_state,max_rrt_num));
5193                        break;
5194                }
5195                tmp_button = p_screen->p_button_array[(idx - p_screen->local_state)];
5196
5197#ifdef TEST_RRT
5198                snprintf(dim_str,64,"DIM-%d",idx);
5199#else
5200                if (PSIP_RRT_getDimension(p_app->settings.rrt,idx,&dim) == BERR_SUCCESS)
5201                {
5202                        if (chm_process_mss(&p_app->chm,dim.p_dimension_name_text,dim_str,sizeof(dim_str)) != 0)
5203                                dim_str[0] = 0;
5204                } else
5205                        dim_str[0] = 0;
5206#endif
5207                selected = (p_screen->button_selection == (idx - p_screen->local_state));
5208                checked  = 0;
5209
5210                bscreen_draw_button_custom_text(p_app,&tmp_button,dim_str,NULL,selected,checked,(idx - p_screen->local_state));
5211        }
5212 
5213        draw_navigation_hints(v_app, v_screen);
5214}
5215
5216
5217/*
5218Summary:
5219        RRT values screen drawing function
5220Description:
5221        RRT values screen drawing function.
5222        .
5223*/
5224void bscreen_rrt_val_draw(void *v_app, void *v_screen)
5225{
5226        bapp_t *p_app = (bapp_t*)v_app;
5227        bscreen_t *p_screen = (bscreen_t*)v_screen;
5228        unsigned int num_chars;
5229        int idx,max_val_num,selected,checked;
5230        PSIP_RRT_dimension dim;
5231        PSIP_RRT_value   val;
5232        bbutton_t tmp_button;
5233        int  dim_idx = p_app->p_screens[eSCREEN_RATINGS_RRT_DIM].button_selection + p_app->p_screens[eSCREEN_RATINGS_RRT_DIM].local_state;
5234        const int VAL_STR_LEN = 64;
5235        char val_str[VAL_STR_LEN];
5236        char abbr_val_str[VAL_STR_LEN];
5237       
5238        bscreen_draw_background(v_app, &p_app->surf, p_screen->top_banner_height);
5239
5240        /* draw title */
5241        num_chars = SCREEN_MAX_STR_WIDTH;
5242        bscreen_get_string(p_app->lang,p_screen->title_text_id, p_app->tmp_str, &num_chars);
5243        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_LARGE],
5244                                        eMENU_TITLE_TEXT_X, eMENU_TITLE_TEXT_Y,
5245                                        eMENU_TITLE_TEXT_WIDTH, eMENU_TITLE_TEXT_HEIGHT,  p_app->tmp_str,
5246                                        num_chars, eCOLOR_DK_YELLOW,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_TEXT_HEIGHT);
5247
5248        /* draw description */
5249        num_chars = SCREEN_MAX_STR_WIDTH;
5250        bscreen_get_string(p_app->lang,p_screen->desc_text_id, p_app->tmp_str, &num_chars);
5251        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
5252                                        eMENU_TITLE_DESC_TEXT_X, eMENU_TITLE_DESC_TEXT_Y,
5253                                        eMENU_TITLE_DESC_TEXT_WIDTH, eMENU_TITLE_DESC_TEXT_HEIGHT,  p_app->tmp_str,
5254                                        num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_DESC_TEXT_SPACING);
5255#ifdef TEST_RRT
5256        max_val_num = MAX_RRT_VAL;
5257#else
5258        if (PSIP_RRT_getDimension(p_app->settings.rrt,dim_idx,&dim) != BERR_SUCCESS)
5259                dim.values_defined = 0;
5260        max_val_num = SCREEN_MIN((p_screen->local_state + MAX_RRT_VAL_BUTTONS), dim.values_defined);
5261#endif
5262       
5263        /* draw buttons (replace text with strings from the RRT) */
5264        for (idx = p_screen->local_state; idx < max_val_num; idx++)
5265        {
5266                if ((idx - p_screen->local_state) >= MAX_RRT_VAL_BUTTONS)
5267                {
5268                        BDBG_WRN(("%s invalid button index %d, %d, %d\n",__FUNCTION__,idx,p_screen->local_state,max_val_num));
5269                        break;
5270                }
5271                tmp_button = p_screen->p_button_array[(idx - p_screen->local_state)];
5272#ifdef TEST_RRT
5273                snprintf(val_str,64,"VALUE-%d",idx);
5274                snprintf(abbr_val_str,64,"VAL-%d",idx);
5275#else
5276                if (PSIP_RRT_getValue(p_app->settings.rrt,dim_idx,idx,&val) == BERR_SUCCESS)
5277                {
5278                        if (chm_process_mss(&p_app->chm,val.p_rating_value_text,val_str,VAL_STR_LEN) != 0)
5279                                val_str[0] = 0;
5280                        if (chm_process_mss(&p_app->chm,val.p_abbrev_rating_value_text,abbr_val_str,VAL_STR_LEN) != 0)
5281                                abbr_val_str[0] = 0;
5282                } else
5283                {
5284                        val_str[0]      = 0;
5285                        abbr_val_str[0] = 0;
5286                }
5287#endif
5288               
5289                BDBG_MSG(("drawing RRT abbr_val_str:%s val_str:%s\n",abbr_val_str, val_str));
5290                selected = (p_screen->button_selection == (idx - p_screen->local_state));
5291                checked  = (p_app->settings.ratings_rrt[dim_idx] & (1 << idx));
5292                bscreen_draw_button_custom_text(p_app,&p_screen->p_button_array[(idx - p_screen->local_state)],abbr_val_str,NULL,selected,checked,(idx - p_screen->local_state));
5293        }
5294
5295        draw_navigation_hints(v_app, v_screen);
5296}
5297
5298void bscreen_popup(void *v_app, void *v_screen)
5299{
5300        bapp_t *p_app = (bapp_t*)v_app;
5301        bscreen_t *p_screen = (bscreen_t*)v_screen;
5302        bool signal_status = false;
5303        btuner_ds_status ds_status;
5304        banner_state_t *p_bs = (banner_state_t*)p_screen->local_state;
5305        BDBG_ASSERT(p_bs);
5306
5307        if (p_app->screen_id != eSCREEN_BANNER_SMALL)
5308                return;
5309
5310        signal_status = bapp_get_signal_status(p_app);
5311//      btuner_get_ds_status(p_app->tuner, &ds_status);
5312        ds_status.signal_strength = p_app->signal_level;
5313
5314        /* set CC state */
5315        if ((p_bs->volume_dirty)             ||
5316                (!signal_status)                 ||
5317                (p_app->audio_mute)              ||
5318                (p_bs->SAP_dirty)                ||
5319                (p_bs->CC_dirty)                 ||
5320                (p_bs->mode != eLS_BANNER_OFF))
5321                bapp_enable_cc(p_app, 0);
5322        else
5323                bapp_enable_cc(p_app, 1);
5324#ifdef CONFIG_ORIG_SYNC
5325
5326        /* resync because enable/disable cc takes a long time */
5327        bapp_flush_screen(p_app);
5328        bapp_sync(p_app);
5329#endif
5330
5331        if (bapp_eia708_enabled(p_app->eia708))
5332                return;
5333
5334        /* draw popup - order dictates priority */
5335        if (p_bs->volume_dirty)
5336        {
5337                BDBG_MSG(("%s p_bs->volume_dirty %d\n",__FUNCTION__,p_bs->volume_dirty));
5338                /* draw 'volume' popup if necessary */
5339                bscreen_popup_draw(v_app,v_screen,eTEXT_VOLUME_TITLE,eTEXT_MAX);
5340        } else
5341                if (p_bs->SAP_dirty)
5342        {
5343                BDBG_MSG(("%s p_bs->SAP_dirty %d\n",__FUNCTION__,p_bs->SAP_dirty));
5344                /* draw SAP popup if necessary */
5345                bscreen_popup_draw(v_app,v_screen,eTEXT_SAP_TITLE,eTEXT_MAX);
5346        } else
5347                if (p_bs->CC_dirty)
5348        {
5349                BDBG_MSG(("%s p_bs->SAP_dirty %d\n",__FUNCTION__,p_bs->CC_dirty));
5350                /* draw CC popup if necessary */
5351                bscreen_popup_draw(v_app,v_screen,eTEXT_CC_TITLE,eTEXT_MAX);
5352        } else
5353                if (p_app->settings.auto_power_off)
5354        {
5355                /* show auto power off reason on startup */
5356                BDBG_MSG(("%s p_app->settings.auto_power_off %d\n",__FUNCTION__,p_app->settings.auto_power_off));
5357                bscreen_popup_draw(v_app,v_screen,eTEXT_MAX,eTEXT_AUTO_POWER_RESTART_DESC);
5358        } else
5359        if (p_bs->auto_power_one_min_warning && 
5360                (bos_getticks() >= (p_app->last_keypress_tick + MS_TO_TICKS(AUTO_POWER_OFF_TIMEOUT) * (1 + p_app->settings.auto_power) - MS_TO_TICKS(1000 * 60))))
5361        {
5362                /* one minute warning before auto power off */
5363                bscreen_popup_draw(v_app,v_screen,eTEXT_AUTO_POWER_MENU,eTEXT_AUTO_POWER_POPUP_DESC);
5364        } else
5365                if (!signal_status && (p_app->settings.ch[p_app->cur_ch_num].freq_idx != 0x7F))
5366        {
5367                /* draw 'no signal' popup if necessary */
5368                BDBG_MSG(("%s signal_status %d\n",__FUNCTION__,signal_status));
5369                bapp_audio_mute(p_app, 1);
5370                bscreen_popup_draw(v_app,v_screen,eTEXT_NO_SIGNAL_TITLE,eTEXT_NO_SIGNAL_DESC);
5371        } else
5372                if (p_app->audio_mute)
5373        {
5374                /* draw 'mute' popup if necessary */
5375                bscreen_popup_draw(v_app,v_screen,eTEXT_MAX,eTEXT_MAX);
5376                bscreen_popup_draw(v_app,v_screen,eTEXT_MUTE_TITLE,eTEXT_MAX);
5377        } else
5378        {
5379                BDBG_MSG(("%s%d bscreen_popup_draw\n",__FUNCTION__,__LINE__));
5380                bscreen_popup_draw(v_app,v_screen,eTEXT_MAX,eTEXT_MAX);
5381        }
5382}
5383/*
5384Summary:
5385        Banner screen drawing function
5386Description:
5387        Banner screen drawing function.
5388        .
5389*/
5390void bscreen_banner_draw(void *v_app, void *v_screen)
5391{
5392        bapp_t *p_app = (bapp_t*)v_app;
5393        bscreen_t *p_screen = (bscreen_t*)v_screen;
5394        unsigned int num_chars,w,h;
5395        unsigned char *p_str;
5396        bstream_mpeg mpeg;
5397        static char tbuf[16];
5398        int i = 0;
5399        bool dst;
5400        unsigned utc_time;
5401        int offset;
5402        static struct tm s_tm;
5403        banner_state_t *p_bs = (banner_state_t*)p_screen->local_state;
5404        BDBG_ASSERT(p_bs);
5405        static int last_mode = eLS_BANNER_OFF;
5406        btuner_ds_status ds_status;
5407        static char tmp_prog[MAX_RATING_STR];
5408
5409        num_chars = 0;
5410        BDBG_MSG(("%s:%d, mode = %d, last = %d\n",__FUNCTION__,__LINE__,p_bs->mode,last_mode));
5411
5412        if (((last_mode == eLS_BANNER_BIG) && (p_bs->mode != eLS_BANNER_BIG)) ||
5413                (p_bs->mode == eLS_BANNER_OFF))
5414                banner_null_draw(v_app,v_screen);
5415
5416        bscreen_popup(v_app, v_screen);
5417
5418        if (bapp_eia708_enabled(p_app->eia708))
5419                return;
5420
5421        /* get the current banner info */
5422        chm_get_cur_ch_info(&p_app->chm,&p_app->tmp_info,&mpeg);
5423
5424        /* don't redraw small banner if going from small -> large banner */
5425        if (((last_mode != eLS_BANNER_SMALL) || (p_bs->mode != eLS_BANNER_BIG)) && (p_bs->mode != eLS_BANNER_OFF))
5426        {
5427                /* resync before drawing small banner data */
5428#ifdef CONFIG_ORIG_SYNC
5429                bapp_sync(p_app);
5430#endif
5431
5432                /* draw small banner with semi-transparent background */
5433                bgfx_fill_rect(&p_app->surf,eBANNER_X,eBANNER_Y,
5434                                           eBANNER_WIDTH,eBANNER_SMALL_HEIGHT,eCOLOR_BLACK);
5435
5436                for (i = 0; i < 4; i++)
5437                {
5438                        bgfx_h_draw_line(&p_app->surf,eBANNER_X+i,eBANNER_X+eBANNER_WIDTH-i,
5439                                                         eBANNER_Y+i,eCOLOR_BLACK);
5440                        bgfx_h_draw_line(&p_app->surf,eBANNER_X+i,eBANNER_X+eBANNER_WIDTH-i,
5441                                                         eBANNER_Y+eBANNER_SMALL_HEIGHT-1-i,eCOLOR_BLACK);
5442                }
5443
5444#ifdef CONFIG_ORIG_SYNC
5445                /* resync before drawing small banner data */
5446                bapp_flush_screen(p_app);
5447                bapp_sync(p_app);
5448#endif
5449
5450                /* draw program title */
5451                p_str = (unsigned char*)p_app->tmp_info.eit_info[EIT_CURRENT].prog_title;
5452                num_chars = c_to_uni_str(p_str,p_app->tmp_str,MAX_TITLE_CHARS);
5453                if (num_chars == 0)
5454                {
5455                        num_chars = MAX_TITLE_CHARS;
5456                        bscreen_get_string(p_app->lang,eTEXT_BANNER_PROGRAM_TITLE, p_app->tmp_str, &num_chars);
5457                }
5458
5459                text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
5460                                                eBANNER_TITLE_X, eBANNER_TITLE_Y, eBANNER_TITLE_WIDTH, eBANNER_TITLE_HEIGHT, 
5461                                                p_app->tmp_str, num_chars, eCOLOR_DK_YELLOW,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,100);
5462
5463                /* draw channel num */
5464                num_chars = SCREEN_MAX_STR_WIDTH;
5465                if (p_bs->enter)
5466                {
5467                        /* user has finish 10keying in a new channel num */
5468                        snprintf(tbuf,6,"%s - %s",p_bs->majorCh,p_bs->minorCh);
5469                } else
5470                        if (p_bs->majorChIndex > 0)
5471                {
5472                        /* user is 10keying in new channel num */
5473                        if (p_bs->minorChIndex == 0)
5474                                if (p_bs->dot)
5475                                        snprintf(tbuf,7,"%s - _", p_bs->majorCh);
5476                                else
5477                                        snprintf(tbuf,4,"%s_", p_bs->majorCh);
5478                        else
5479                                snprintf(tbuf,9,"%s - %s_", p_bs->majorCh,p_bs->minorCh);
5480                } else
5481                {
5482                        /* display current channel */
5483                        snprintf(tbuf,9,"%d - %d", p_app->settings.ch[p_app->cur_ch_num].major,p_app->settings.ch[p_app->cur_ch_num].minor);
5484                }
5485
5486                num_chars = c_to_uni_str(tbuf,p_app->tmp_str,num_chars);
5487#ifdef BQAM_SCRIPT
5488                text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
5489                                                eBANNER_CH_NUM_X - 20, eBANNER_CH_NUM_Y, eBANNER_CH_NUM_WIDTH + 25, eBANNER_CH_NUM_HEIGHT, 
5490                                                p_app->tmp_str, num_chars, eCOLOR_DK_YELLOW,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,0);
5491#else
5492                text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
5493                                                eBANNER_CH_NUM_X, eBANNER_CH_NUM_Y, eBANNER_CH_NUM_WIDTH, eBANNER_CH_NUM_HEIGHT, 
5494                                                p_app->tmp_str, num_chars, eCOLOR_DK_YELLOW,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,0);
5495#endif
5496
5497                /* draw call sign */
5498                num_chars = MAX_CH_NAME_CHARS;
5499                num_chars = utf16_to_uni_str(p_app->settings.ch[p_app->cur_ch_num].ch_name,p_app->tmp_str,num_chars);
5500                text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
5501                                                eBANNER_CALLSIGN_X, eBANNER_CALLSIGN_Y, eBANNER_CALLSIGN_WIDTH, eBANNER_CALLSIGN_HEIGHT, 
5502                                                p_app->tmp_str, num_chars, eCOLOR_DK_YELLOW,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,0);
5503
5504                /* draw next program title */
5505                p_str = (unsigned char*)p_app->tmp_info.eit_info[EIT_NEXT].prog_title;
5506                num_chars = c_to_uni_str(p_str,p_app->tmp_str,MAX_TITLE_CHARS);
5507                if (num_chars > 0)
5508                {
5509                        int w = 0;
5510                        int h = 0;
5511
5512                        num_chars = MAX_TITLE_CHARS;
5513                        bscreen_get_string(p_app->lang,eTEXT_BANNER_NEXT_PROGRAM_TITLE_PREFIX, p_app->tmp_str, &num_chars);
5514                        bgfx_string_info(p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
5515                                                         (const unsigned long *)p_app->tmp_str,num_chars,&w,&h);
5516                        w += 3;
5517                        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
5518                                                        eBANNER_TITLE_X, eBANNER_NEXT_TITLE_Y, w, eBANNER_TITLE_HEIGHT, 
5519                                                        p_app->tmp_str, num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,100);
5520
5521                        p_str = (unsigned char*)p_app->tmp_info.eit_info[EIT_NEXT].prog_title;
5522                        num_chars = c_to_uni_str(p_str,p_app->tmp_str,MAX_TITLE_CHARS);
5523                        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
5524                                                        eBANNER_TITLE_X + w, eBANNER_NEXT_TITLE_Y, 
5525                                                        eBANNER_TITLE_WIDTH - w, eBANNER_TITLE_HEIGHT, 
5526                                                        p_app->tmp_str, num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,100);
5527                }
5528
5529                /* draw time */
5530                num_chars = MAX_TIME_STR;
5531                p_app->prog_time_str[0] = 0;
5532                if (chm_get_time_info(&p_app->chm,&utc_time,&offset,&dst) == 0)
5533                {
5534                        utc_time += offset;
5535
5536                        utctime(utc_time,&s_tm);
5537
5538                        if (s_tm.tm_hour >= 12)
5539                        {
5540                        if (s_tm.tm_hour > 12)
5541                                s_tm.tm_hour -= 12;
5542                                snprintf(p_app->prog_time_str,MAX_TIME_STR,"%d:%02dPM",s_tm.tm_hour,s_tm.tm_min);
5543                        } else
5544                                if (s_tm.tm_hour == 0)
5545                        {
5546                                s_tm.tm_hour = 12;
5547                                snprintf(p_app->prog_time_str,MAX_TIME_STR,"%d:%02dAM",s_tm.tm_hour,s_tm.tm_min);
5548                        } else
5549                        {
5550                                snprintf(p_app->prog_time_str,MAX_TIME_STR,"%d:%02dAM",s_tm.tm_hour,s_tm.tm_min);
5551                        }
5552                }
5553                num_chars = c_to_uni_str(p_app->prog_time_str,p_app->tmp_str,num_chars);
5554                text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
5555                                                eBANNER_TIME_X, eBANNER_TIME_Y, eBANNER_TIME_WIDTH, eBANNER_TIME_HEIGHT, 
5556                                                p_app->tmp_str, num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,0);
5557
5558                /* draw program start/end time if exists */
5559                if ((chm_get_time_info(&p_app->chm,&utc_time,&offset,&dst) == 0) &&
5560                        (p_app->tmp_info.eit_info[EIT_CURRENT].start_time > 0) &&
5561                        (p_app->tmp_info.eit_info[EIT_CURRENT].length > 0))
5562                {
5563                        unsigned char prog_time_str[MAX_TIME_STR * 2];
5564                        unsigned char prog_start_time_str[MAX_TIME_STR];
5565                        unsigned char prog_end_time_str[MAX_TIME_STR];
5566                        struct tm tm_start;
5567                        struct tm tm_end;
5568
5569                        num_chars = MAX_TIME_STR;
5570
5571                        if (dst)
5572                        {
5573                                offset += 3600; /* utc_time is already offset for dst but offset is not */
5574                        }
5575
5576                        utctime(p_app->tmp_info.eit_info[EIT_CURRENT].start_time + offset, &tm_start);
5577                        if (tm_start.tm_hour >= 12)
5578                        {
5579                        if (tm_start.tm_hour > 12)
5580                                tm_start.tm_hour -= 12;
5581                                snprintf(prog_start_time_str,MAX_TIME_STR,"%d:%02dPM",tm_start.tm_hour,tm_start.tm_min);
5582                        } else
5583                                if (tm_start.tm_hour == 0)
5584                        {
5585                                tm_start.tm_hour = 12;
5586                                snprintf(prog_start_time_str,MAX_TIME_STR,"%d:%02dAM",tm_start.tm_hour,tm_start.tm_min);
5587                        } else
5588                        {
5589                                snprintf(prog_start_time_str,MAX_TIME_STR,"%d:%02dAM",tm_start.tm_hour,tm_start.tm_min);
5590                        }
5591
5592                        num_chars = MAX_TIME_STR;
5593                        utctime(p_app->tmp_info.eit_info[EIT_CURRENT].start_time + p_app->tmp_info.eit_info[EIT_CURRENT].length + offset, &tm_end);
5594                        if (tm_end.tm_hour >= 12)
5595                        {
5596                        if (tm_end.tm_hour > 12)
5597                                tm_end.tm_hour -= 12;
5598                                snprintf(prog_end_time_str,MAX_TIME_STR,"%d:%02dPM",tm_end.tm_hour,tm_end.tm_min);
5599                        } else
5600                                if (tm_end.tm_hour == 0)
5601                        {
5602                                tm_end.tm_hour = 12;
5603                                snprintf(prog_end_time_str,MAX_TIME_STR,"%d:%02dAM",tm_end.tm_hour,tm_end.tm_min);
5604                        } else
5605                        {
5606                                snprintf(prog_end_time_str,MAX_TIME_STR,"%d:%02dAM",tm_end.tm_hour,tm_end.tm_min);
5607                        }
5608
5609                        snprintf(prog_time_str, (MAX_TIME_STR * 2), "%s-%s",prog_start_time_str,prog_end_time_str);
5610                        num_chars = c_to_uni_str(prog_time_str,p_app->tmp_str,num_chars);
5611
5612                        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
5613                                                        eBANNER_START_END_TIME_X, eBANNER_START_END_TIME_Y, eBANNER_START_END_TIME_WIDTH, eBANNER_START_END_TIME_HEIGHT, 
5614                                                        p_app->tmp_str, num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,0);
5615                }
5616
5617                tmp_prog[0] = 0;
5618                if (p_app->prog_rating_str[0] != 0)
5619                {
5620                        strncpy_no_spaces(tmp_prog,(char*)p_app->prog_rating_str,MAX_RATING_STR);
5621                        BDBG_WRN(("%s - analog: %s\n",__FUNCTION__, tmp_prog));
5622                }
5623
5624                if (p_app->psip_rating_str[0] != 0)
5625                {
5626                        strncpy_no_spaces(tmp_prog,(char*)p_app->psip_rating_str,MAX_RATING_STR);
5627                        BDBG_WRN(("%s - digital: %s\n",__FUNCTION__, tmp_prog));
5628                }
5629
5630                num_chars = strlen(tmp_prog);
5631                if (num_chars)
5632                {
5633                        /* draw ratings - show blocked rating, if no blocked ratings then show received
5634                                xds or psip rating if corresponding rating string exists */
5635                        num_chars = SCREEN_MAX_STR_WIDTH;
5636                        bscreen_get_string(p_app->lang,eTEXT_RATINGS_BUTTON, p_app->tmp_str, &num_chars);
5637                        p_app->tmp_str[num_chars++] = (unsigned int)':';
5638                        p_app->tmp_str[num_chars++] = (unsigned int)' ';
5639                        p_app->tmp_str[num_chars++] = (unsigned int)' ';
5640                        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
5641                                                        eBANNER_RATINGS_X, eBANNER_RATINGS_Y, eBANNER_RATINGS_WIDTH, eBANNER_RATINGS_HEIGHT, 
5642                                                        p_app->tmp_str, num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,0);
5643                        bgfx_string_info(p_app->p_font[p_app->lang][eFONT_SIZE_MED],(const unsigned long *)p_app->tmp_str,num_chars,&w,&h);
5644                       
5645                        num_chars = strlen(tmp_prog);
5646                        num_chars = c_to_uni_str(tmp_prog,p_app->tmp_str,num_chars);
5647                        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
5648                                                        eBANNER_RATINGS_X + w, eBANNER_RATINGS_Y, eBANNER_RATINGS_WIDTH, eBANNER_RATINGS_HEIGHT, 
5649                                                        p_app->tmp_str, num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,0);
5650                }
5651                else
5652                {
5653                        BDBG_WRN(("%s - rating string empty\n",__FUNCTION__));
5654                        num_chars = 0;
5655                }
5656
5657                /* draw sap indicator if necessary */
5658                if ((p_app->num_sap) > 1 && (p_app->current_sap != p_app->lang))
5659                {
5660                        num_chars = MAX_TITLE_CHARS;
5661                        bscreen_get_string(p_app->lang,eTEXT_BANNER_SAP, p_app->tmp_str, &num_chars);
5662                        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
5663                                                        eBANNER_SAP_X, eBANNER_SAP_Y, eBANNER_SAP_WIDTH, eBANNER_SAP_HEIGHT, 
5664                                                        p_app->tmp_str, num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,0);
5665                }
5666
5667
5668#ifdef CONFIG_ORIG_SYNC
5669                /* resync before drawing signal level and large banner */
5670                bapp_flush_screen(p_app);
5671#endif
5672
5673                /* draw signal level */
5674//              btuner_get_ds_status(p_app->tuner, &ds_status);
5675                ds_status.signal_strength = p_app->signal_level;
5676                bscreen_draw_banner_signal_level(p_app, ds_status.signal_strength);
5677        }
5678
5679        /* draw large banner if necessary */
5680        if (p_bs->mode == eLS_BANNER_BIG)
5681        {
5682                /* resync before drawing signal level and large banner */
5683#ifdef CONFIG_ORIG_SYNC
5684                bapp_sync(p_app);
5685#endif
5686
5687                /* draw large banner with semi-transparent background */
5688                bgfx_fill_rect(&p_app->surf,eBANNER_X,eBANNER_Y+eBANNER_SMALL_HEIGHT,eBANNER_WIDTH,eBANNER_LARGE_HEIGHT,eCOLOR_BLACK);
5689                for (i = 0; i < 4; i++)
5690                {
5691                        bgfx_h_draw_line(&p_app->surf,eBANNER_X+i,eBANNER_X+eBANNER_WIDTH-i,eBANNER_Y+eBANNER_SMALL_HEIGHT-1+eBANNER_LARGE_HEIGHT-1-i,eCOLOR_BLACK);
5692                }
5693
5694#ifdef CONFIG_ORIG_SYNC
5695                bapp_flush_screen(p_app);
5696                bapp_sync(p_app);
5697#endif
5698
5699                /* draw program description */
5700                num_chars = MAX_DESC_CHARS;
5701                p_str = (unsigned char*)p_app->tmp_info.eit_info[EIT_CURRENT].prog_desc;
5702                num_chars = c_to_uni_str(p_str,p_app->tmp_str,num_chars);
5703                if (strlen(p_str) == 0)
5704                {
5705                        num_chars = MAX_DESC_CHARS;
5706                        bscreen_get_string(p_app->lang,eTEXT_BANNER_PROGRAM_DESC, p_app->tmp_str, &num_chars);
5707                }
5708                text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
5709                                                eBANNER_DESC_X, eBANNER_DESC_Y, eBANNER_DESC_WIDTH, eBANNER_DESC_HEIGHT, 
5710                                                p_app->tmp_str, num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eBANNER_DESC_LINE_SPACING);
5711#ifdef CONFIG_ORIG_SYNC
5712                bapp_flush_screen(p_app);
5713#endif
5714        }
5715
5716        last_mode = p_bs->mode;
5717}
5718
5719
5720/*
5721Summary:
5722        Screensaver screen drawing function
5723Description:
5724        Screensaver screen drawing function. 
5725*/
5726void bscreen_screensaver_draw(void *v_app, void *v_screen)
5727{
5728#ifndef CONFIG_SCREENSAVER
5729        BDBG_ERR(("NO SCREENSAVER.\n"));
5730#else
5731//#error "Do not include screensaver in Thomson build"
5732        bapp_t *p_app = (bapp_t*)v_app;
5733        bin_read_t br;
5734        bcm_raw_8_t *p_header = (bcm_raw_8_t*)g_p_dsp->ui_comp.logo;
5735        br.cnt = 0;
5736        br.data = (void*)g_p_dsp->ui_comp.logo;
5737        br.size = g_p_dsp->ui_comp.logo_size;
5738
5739        screen_null_draw(v_app, v_screen);
5740        bgfx_render_file(&p_app->surf, 
5741                                         eSCREEN_ACTION_SAFE_X + RAND_INT(eSCREEN_ACTION_SAFE_WIDTH-p_header->width), 
5742                                         eSCREEN_ACTION_SAFE_Y + RAND_INT(eSCREEN_ACTION_SAFE_HEIGHT-p_header->height), 
5743                                         &br, 0);
5744#endif
5745}
5746
5747/*
5748Summary:
5749        Power off screen drawing function
5750Description:
5751        Power off screen drawing function. 
5752*/
5753void bscreen_power_off_draw(void *v_app, void *v_screen)
5754{
5755        screen_null_draw(v_app, v_screen);
5756}
5757
5758/*
5759Summary:
5760        Draw banner signal level
5761Description:
5762        Draw banner signal level
5763*/
5764void bscreen_draw_banner_signal_level(void *v_app, unsigned int signal)
5765{
5766        bapp_t *p_app                = (bapp_t*)v_app;
5767        const uint32_t icon_center_x = eBANNER_SIGNAL_X + 5;
5768        const uint8_t icon_triangle  = 4;
5769        const uint8_t icon_bars_x    = icon_center_x;
5770        const uint8_t sig_level_x    = eBANNER_SIGNAL_X + 25;
5771        int i                        = 0;
5772
5773#ifdef CONFIG_ORIG_SYNC
5774        bapp_sync(p_app);
5775#endif
5776        bcolor_idx_t color = eCOLOR_WHITE;
5777        if (bant_detect())
5778                color = eCOLOR_DK_YELLOW;
5779
5780        /* draw antenna symbol */
5781        bgfx_v_draw_line(&p_app->surf, icon_center_x, eBANNER_SIGNAL_Y, 
5782                                         eBANNER_SIGNAL_Y+eBANNER_SIGNAL_HEIGHT, color);
5783        bgfx_v_draw_line(&p_app->surf, icon_center_x-1, eBANNER_SIGNAL_Y, 
5784                                         eBANNER_SIGNAL_Y+eBANNER_SIGNAL_HEIGHT, color);
5785        for (i = icon_triangle; i > 0; i--)
5786        {
5787                bgfx_h_draw_line(&p_app->surf, icon_center_x-i, icon_center_x+1+i, 
5788                                                 eBANNER_SIGNAL_Y+icon_triangle-i, color);
5789        }
5790
5791        /* draw signal bars */
5792        for (i = 1; i < 4; i++)
5793        {
5794                bgfx_v_draw_line(&p_app->surf,icon_bars_x+(i*4),eBANNER_SIGNAL_Y+eBANNER_SIGNAL_HEIGHT-(i*3),
5795                                                 eBANNER_SIGNAL_Y+eBANNER_SIGNAL_HEIGHT,color);
5796                bgfx_v_draw_line(&p_app->surf,icon_bars_x+(i*4)+1,eBANNER_SIGNAL_Y+eBANNER_SIGNAL_HEIGHT-(i*3),
5797                                                 eBANNER_SIGNAL_Y+eBANNER_SIGNAL_HEIGHT,color);
5798        }
5799
5800        /* draw level control outline */
5801        for (i = 0; i < 2; i++)
5802        {
5803                bgfx_h_draw_line(&p_app->surf,sig_level_x,sig_level_x+eBANNER_SIGNAL_WIDTH,
5804                                                 eBANNER_SIGNAL_Y+i,eCOLOR_WHITE);
5805                bgfx_h_draw_line(&p_app->surf,sig_level_x,sig_level_x+eBANNER_SIGNAL_WIDTH,
5806                                                 eBANNER_SIGNAL_Y+eBANNER_SIGNAL_HEIGHT-1-i,eCOLOR_WHITE);
5807                bgfx_v_draw_line(&p_app->surf,sig_level_x-i,eBANNER_SIGNAL_Y,
5808                                                 eBANNER_SIGNAL_Y+eBANNER_SIGNAL_HEIGHT-1,eCOLOR_WHITE);
5809                bgfx_v_draw_line(&p_app->surf,sig_level_x+eBANNER_SIGNAL_WIDTH-1-i,eBANNER_SIGNAL_Y,
5810                                                 eBANNER_SIGNAL_Y+eBANNER_SIGNAL_HEIGHT-1,eCOLOR_WHITE);
5811        }
5812
5813        /* draw signal level */
5814        bgfx_fill_rect(&p_app->surf,sig_level_x+3,eBANNER_SIGNAL_Y+4,100*(eBANNER_SIGNAL_WIDTH-8)/100,
5815                                   eBANNER_SIGNAL_HEIGHT-8,eCOLOR_BLACK);
5816        if (signal <= 100)
5817                bgfx_fill_rect(&p_app->surf,sig_level_x+3,eBANNER_SIGNAL_Y+4,signal*(eBANNER_SIGNAL_WIDTH-8)/100,
5818                                           eBANNER_SIGNAL_HEIGHT-8,eCOLOR_NEON_GREEN);
5819#ifdef CONFIG_ORIG_SYNC
5820        bapp_flush_screen(p_app);
5821#endif
5822}
5823
5824/*
5825Summary:
5826        Draw a button.
5827Description:
5828        Draw a button.
5829*/
5830void bscreen_draw_button_str(void *v_app,                                       /* application structure */
5831                                                         const bbutton_t *p_button,                      /* button info structure */
5832                                                         int selected,                                           /* Button selected when non-zero */
5833                                                         int checked,                                             /* Button checked when non-zero */
5834                                                         unsigned int *p_str,                             /* button UNI string */
5835                                                         unsigned int num_chars,                          /* length of text string */
5836                                                         unsigned int *p_desc_str,                        /* description UNI string */
5837                                                         unsigned int num_desc_chars,             /* length of description text string */
5838                                                         bapp_font_size_t  font_size,             /* button text font size */
5839                                                         int  font_just                                           /* button text justification, 0 - left, 1 - right */
5840                                                        )
5841{
5842        bapp_t *p_app = (bapp_t*)v_app;
5843        int w,h,margin,bulletw;
5844        uint16_t str_x,str_y,check_x,check_y;
5845
5846        if (!p_button)
5847                return;
5848
5849#ifdef CONFIG_ORIG_SYNC
5850        bapp_sync(p_app);
5851#endif
5852        if (selected)
5853        {
5854                int newY = p_button->y;
5855                /* draw black outline to minimize dot crawl on crappy tvs */
5856                bgfx_fill_rect(&p_app->surf,p_button->x - 1,p_button->y - 1,
5857                                           p_button->width + 2,p_button->height + 2,eCOLOR_BLACK);
5858
5859                /* draw top bevel */
5860                bgfx_fill_rect(&p_app->surf,p_button->x,p_button->y,
5861                                           p_button->width,eBUTTON_BEVEL_GRADIENT_STEP,eCOLOR_DK_YELLOW);
5862                newY += eBUTTON_BEVEL_GRADIENT_STEP;
5863                bgfx_fill_rect(&p_app->surf,p_button->x,newY,
5864                                           p_button->width,eBUTTON_BEVEL_GRADIENT_STEP,eCOLOR_PALE_YELLOW);
5865                newY += eBUTTON_BEVEL_GRADIENT_STEP;
5866                bgfx_fill_rect(&p_app->surf,p_button->x,newY,
5867                                           p_button->width,eBUTTON_BEVEL_GRADIENT_STEP,eCOLOR_MED_YELLOW);
5868                newY += eBUTTON_BEVEL_GRADIENT_STEP;
5869                bgfx_fill_rect(&p_app->surf,p_button->x,newY,
5870                                           p_button->width,eBUTTON_BEVEL_GRADIENT_STEP,eCOLOR_LT_YELLOW);
5871                newY += eBUTTON_BEVEL_GRADIENT_STEP;
5872
5873                /* draw middle */
5874                bgfx_fill_rect(&p_app->surf,p_button->x,newY,
5875                                           p_button->width,p_button->height - (7 * eBUTTON_BEVEL_GRADIENT_STEP),eCOLOR_BRT_YELLOW);
5876
5877                /* draw bottom bevel */
5878                newY = p_button->y + p_button->height - eBUTTON_BEVEL_GRADIENT_STEP;
5879
5880                bgfx_fill_rect(&p_app->surf,p_button->x,newY,
5881                                           p_button->width,eBUTTON_BEVEL_GRADIENT_STEP,eCOLOR_DK_YELLOW);
5882                newY -= eBUTTON_BEVEL_GRADIENT_STEP;
5883                bgfx_fill_rect(&p_app->surf,p_button->x,newY,
5884                                           p_button->width,eBUTTON_BEVEL_GRADIENT_STEP,eCOLOR_MED_YELLOW);
5885                newY -= eBUTTON_BEVEL_GRADIENT_STEP;
5886                bgfx_fill_rect(&p_app->surf,p_button->x,newY,
5887                                           p_button->width,eBUTTON_BEVEL_GRADIENT_STEP,eCOLOR_LT_YELLOW);
5888                newY -= eBUTTON_BEVEL_GRADIENT_STEP;
5889        } else
5890        {
5891                /* erase dot crawl reducing outline if not selected */ 
5892                bgfx_fill_rect(&p_app->surf,p_button->x - 1,p_button->y - 1,
5893                                           p_button->width + 2,p_button->height + 2,p_button->background_color);
5894        }
5895#ifdef CONFIG_ORIG_SYNC
5896        bapp_flush_screen(p_app);
5897#endif
5898        margin = eBUTTON_MARGIN_X;
5899
5900        /* add space for check box */
5901        if ((p_button->type & eBUTTON_RADIO) ||
5902                (p_button->type & eBUTTON_CHECK))
5903        {
5904#ifdef CONFIG_ORIG_SYNC
5905                bapp_sync(p_app);
5906#endif
5907                check_x = p_button->x + eBUTTON_RADIO_BOX_MARGIN_X;
5908                check_y = p_button->y + (p_button->height - eBUTTON_RADIO_BOX_WIDTH)/2;
5909                if (checked)
5910                {
5911                        if (p_button->type & eBUTTON_CHECK_LOCK)
5912                        {
5913                                /* draw lock icon */
5914                                bgfx_h_draw_line(&p_app->surf,check_x + 7, check_x + 14, check_y + 2, selected ? eCOLOR_BLACK : eCOLOR_WHITE);
5915                                bgfx_h_draw_line(&p_app->surf,check_x + 6, check_x + 15, check_y + 3, selected ? eCOLOR_BLACK : eCOLOR_WHITE);
5916                                bgfx_h_draw_line(&p_app->surf,check_x + 5, check_x + 16, check_y + 4, selected ? eCOLOR_BLACK : eCOLOR_WHITE);
5917                                bgfx_h_draw_line(&p_app->surf,check_x + 5, check_x + 7, check_y + 5, selected ? eCOLOR_BLACK : eCOLOR_WHITE);
5918                                bgfx_h_draw_line(&p_app->surf,check_x + 5, check_x + 7, check_y + 6, selected ? eCOLOR_BLACK : eCOLOR_WHITE);
5919                                bgfx_h_draw_line(&p_app->surf,check_x + 5, check_x + 7, check_y + 7, selected ? eCOLOR_BLACK : eCOLOR_WHITE);
5920                                bgfx_h_draw_line(&p_app->surf,check_x + 5, check_x + 7, check_y + 8, selected ? eCOLOR_BLACK : eCOLOR_WHITE);
5921                                bgfx_h_draw_line(&p_app->surf,check_x + 14, check_x + 16, check_y + 5, selected ? eCOLOR_BLACK : eCOLOR_WHITE);
5922                                bgfx_h_draw_line(&p_app->surf,check_x + 14, check_x + 16, check_y + 6, selected ? eCOLOR_BLACK : eCOLOR_WHITE);
5923                                bgfx_h_draw_line(&p_app->surf,check_x + 14, check_x + 16, check_y + 7, selected ? eCOLOR_BLACK : eCOLOR_WHITE);
5924                                bgfx_h_draw_line(&p_app->surf,check_x + 14, check_x + 16, check_y + 8, selected ? eCOLOR_BLACK : eCOLOR_WHITE);
5925                                bgfx_h_draw_line(&p_app->surf,check_x + 3, check_x + 18, check_y + 9, selected ? eCOLOR_BLACK : eCOLOR_WHITE);
5926
5927                                bgfx_fill_rect(&p_app->surf,check_x + 1, check_y + 10, 18, 11, selected ? eCOLOR_BLACK : eCOLOR_LT_YELLOW);
5928
5929                                bgfx_h_draw_line(&p_app->surf,check_x + 6, check_x + 15, check_y + 12, selected ? eCOLOR_DK_YELLOW : eCOLOR_BLACK);
5930                                bgfx_h_draw_line(&p_app->surf,check_x + 6, check_x + 15, check_y + 15, selected ? eCOLOR_DK_YELLOW : eCOLOR_BLACK);
5931                                bgfx_h_draw_line(&p_app->surf,check_x + 6, check_x + 15, check_y + 18, selected ? eCOLOR_DK_YELLOW : eCOLOR_BLACK);
5932                        } else
5933                        {
5934                                /* draw BLACK outline */
5935                                bgfx_fill_rect(&p_app->surf,check_x,check_y,
5936                                                           eBUTTON_RADIO_BOX_WIDTH,eBUTTON_RADIO_BOX_WIDTH,eCOLOR_BLACK);
5937
5938                                /* draw GREEN checkbox background */
5939                                bgfx_fill_rect(&p_app->surf,check_x + eBUTTON_RADIO_BOX_BORDER,check_y + eBUTTON_RADIO_BOX_BORDER,
5940                                                           eBUTTON_RADIO_BOX_WIDTH - (2 * eBUTTON_RADIO_BOX_BORDER),
5941                                                           eBUTTON_RADIO_BOX_WIDTH - (2 * eBUTTON_RADIO_BOX_BORDER),eCOLOR_NEON_GREEN);
5942                                /* draw dot in middle for colorblind users */
5943                                bgfx_fill_rect(&p_app->surf,check_x + (eBUTTON_RADIO_BOX_WIDTH / 2) - (eBUTTON_RADIO_BOX_DOT_WIDTH / 2),
5944                                                           check_y + (eBUTTON_RADIO_BOX_WIDTH / 2) - (eBUTTON_RADIO_BOX_DOT_WIDTH / 2),
5945                                                           eBUTTON_RADIO_BOX_DOT_WIDTH, eBUTTON_RADIO_BOX_DOT_WIDTH, eCOLOR_BLACK);
5946                        }
5947                } else
5948                {
5949                        /* draw BLACK outline */
5950                        bgfx_fill_rect(&p_app->surf,check_x,check_y,
5951                                                   eBUTTON_RADIO_BOX_WIDTH,eBUTTON_RADIO_BOX_WIDTH,eCOLOR_BLACK);
5952
5953                        /* draw WHITE checkbox background */
5954                        bgfx_fill_rect(&p_app->surf,check_x + eBUTTON_RADIO_BOX_BORDER,check_y + eBUTTON_RADIO_BOX_BORDER,
5955                                                   eBUTTON_RADIO_BOX_WIDTH - (2 * eBUTTON_RADIO_BOX_BORDER),
5956                                                   eBUTTON_RADIO_BOX_WIDTH - (2 * eBUTTON_RADIO_BOX_BORDER),eCOLOR_WHITE);
5957                }
5958#ifdef CONFIG_ORIG_SYNC
5959                bapp_flush_screen(p_app);
5960#endif
5961        }
5962
5963        if (num_chars > 0)
5964        {
5965                bgfx_string_info(p_app->p_font[p_app->lang][font_size],(const unsigned long *)p_str,num_chars,&w,&h);
5966
5967                if (((w + margin) > p_button->width) || (h > p_button->height))
5968                {
5969                        BDBG_MSG(("String too large for button. (%d,%d),(%d,%d)\n",
5970                                          w + margin, h, p_button->width, p_button->height));
5971                        /* Handled by text box draw */
5972                }
5973
5974                if (font_just)
5975                {
5976                        str_x = p_button->x + p_button->width - w - margin;     /* Right justify string */
5977                } else
5978                {
5979                        str_x = p_button->x + margin; /* Left justify string */
5980
5981                        if ((p_button->type & eBUTTON_RADIO) || (p_button->type & eBUTTON_CHECK))
5982                        {
5983                                str_x += eBUTTON_RADIO_BOX_MARGIN_X + eBUTTON_RADIO_BOX_WIDTH; /* adjust if check box is visible */
5984                        }
5985                }
5986                str_y = p_button->y + (p_button->height - h)/2; /* Center string verticaly */
5987
5988#ifdef CONFIG_ORIG_SYNC
5989                bapp_sync(p_app);
5990#endif
5991                if (selected)
5992                        text_box(&p_app->surf, p_app->p_font[p_app->lang][font_size],
5993                                         str_x, str_y, p_button->width - margin, h, p_str,
5994                                         num_chars, eCOLOR_BLACK, 20);
5995                else
5996                        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][font_size],
5997                                                        str_x, str_y, p_button->width - margin, h, p_str,
5998                                                        num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,20);
5999        }
6000
6001        /* Draw description text */
6002        if ((p_desc_str) && (num_desc_chars > 0))
6003        {
6004                /* TODO: draw given description text string */
6005        } else
6006                if (p_button->desc_text_id < eTEXT_MAX)
6007        {
6008                int y_desc_offset,addnl;
6009                int spacing = eMENU_INFO_LINE_SPACING;
6010
6011                addnl = 0;
6012
6013                if ((p_app->screen_id == eSCREEN_SOUND) || (p_app->screen_id == eSCREEN_PICTURE) || (p_app->screen_id == eSCREEN_RATINGS_LOCK))
6014                        addnl += 60;
6015                /* draw description text string based on button's default description text id */
6016                num_chars = SCREEN_MAX_STR_WIDTH;
6017                bscreen_get_string(p_app->lang,eTEXT_BULLET, p_app->tmp_str, &num_chars);
6018                bgfx_string_info(p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],(const unsigned long *)p_app->tmp_str,num_chars,&bulletw,&h);
6019                text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
6020                                                p_button->x + p_button->width + eBUTTON_MARGIN_X,
6021                                                p_button->y + (p_button->height - h * 3)/2, bulletw + 1, p_button->height, p_app->tmp_str,
6022                                                num_chars, eCOLOR_WHITE, eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_INFO_LINE_SPACING);
6023
6024                num_chars = SCREEN_MAX_STR_WIDTH;
6025                bscreen_get_string(p_app->lang,p_button->desc_text_id, p_app->tmp_str, &num_chars);
6026                bgfx_string_info(p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],(const unsigned long *)p_app->tmp_str,num_chars,&w,&h);
6027                w = eWIDTH - (p_button->x + p_button->width + eBUTTON_MARGIN_X + bulletw + eBUTTON_MARGIN_RIGHT + 15);
6028
6029                y_desc_offset = p_button->y + (p_button->height - h)/2;
6030                if (num_chars > 65)
6031                {
6032                        y_desc_offset -= 10;
6033                }
6034
6035                if ((p_app->lang == eLANG_FRENCH) && (p_app->screen_id == eSCREEN_CAPTIONS_FONT) && (num_chars > 34))
6036                {
6037                        y_desc_offset -= 6;
6038                        spacing = 0;
6039                }
6040                text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
6041                                                p_button->x + p_button->width + eBUTTON_MARGIN_X + bulletw + 1,
6042                                                y_desc_offset, w, p_button->height + addnl, p_app->tmp_str,
6043                                                num_chars, eCOLOR_WHITE, eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,spacing);
6044#ifdef BCM_DEBUG
6045                if (p_app->ui_debug_mode)
6046                {
6047                        char *p_str = (char*)g_p_dsp->ui_comp.str_table[p_app->lang][p_button->desc_text_id];
6048                        if (p_str)
6049                        {
6050                                printf("%s (%d,%d,%d,%d)\n", 
6051                                           p_str,p_button->x + p_button->width + eBUTTON_MARGIN_X + bulletw + 1,
6052                                           p_button->y + (p_button->height - h)/2,w,p_button->height);
6053                        }
6054                }
6055#endif
6056        }
6057#ifdef CONFIG_ORIG_SYNC
6058        bapp_flush_screen(p_app);
6059#endif
6060}
6061
6062/*
6063Summary:
6064        Adjust the given button orientation to account for given language
6065Description:
6066        Adjust the given button orientation to account for given language
6067        Note that button orientation is designed assuming english is the default.
6068        This function simply modifies the button if a different language is specified.
6069*/
6070static void adjust_button_orientation(void *v_app, 
6071                                                                          bbutton_t *p_button)
6072{
6073        bapp_t *p_app = (bapp_t*)v_app;
6074
6075        if (p_app->lang == eLANG_ENGLISH)
6076        {
6077                switch (p_app->screen_id)
6078                {
6079                case eSCREEN_MAIN:
6080                        p_button->x      += -18;
6081                        p_button->width  += 48;
6082                        break;
6083                case eSCREEN_SOUND:
6084                        p_button->x      -= 20;
6085                        p_button->width  += 70;
6086                        break;
6087                default:
6088                        break;
6089                }
6090        } else
6091                if (p_app->lang == eLANG_SPANISH)
6092        {
6093                switch (p_app->screen_id)
6094                {
6095                case eSCREEN_AV:
6096                        p_button->x      -= 40;
6097                        p_button->width  += 50;
6098                        break;
6099                case eSCREEN_CAPTIONS_BACK_OPTIONS:
6100                        p_button->x      -= 4;
6101                        p_button->width  += 24;
6102                        break;
6103                case eSCREEN_CAPTIONS_BACK_OPACITY:
6104                case eSCREEN_CAPTIONS_FONT_OPACITY:
6105                        p_button->width  += 4;
6106                        break;
6107
6108                case eSCREEN_CAPTIONS_FONT_STYLE:
6109                        p_button->width  += 6;
6110                        p_button->+= 20;
6111                        break;
6112                case eSCREEN_CAPTIONS_EDGE_TYPE:
6113                        p_button->x      -= 6;
6114                        p_button->width  += 36;
6115                        break;
6116                case eSCREEN_CAPTIONS_FONT_SIZE:
6117                        p_button->+= 10;
6118                        break;
6119
6120                case eSCREEN_MAIN:
6121                        p_button->x      += -20;
6122                        p_button->width  += 62;
6123                        p_button->height += 0;
6124                        break;
6125                case eSCREEN_PICTURE:
6126                        p_button->y      -= 20;
6127                        p_button->width  += 30;
6128                        break;
6129                case eSCREEN_SOUND:
6130                        p_button->x      -= 20;
6131                        p_button->width  += 40;
6132                        break;
6133                case eSCREEN_WIZ_CH_SCAN:
6134                case eSCREEN_CH_SCAN:
6135                        p_button->y      -= 15;
6136                        break;
6137                case eSCREEN_WIZ_SMART_CH_SCAN:
6138                case eSCREEN_SMART_CH_SCAN:
6139                        p_button->y      -= 5;
6140                        break;
6141                case eSCREEN_RESET:
6142                        p_button->x      += 25;
6143                        p_button->width  += 25;
6144                        break;
6145                case eSCREEN_RATINGS:
6146                        p_button->x      += 5;
6147                        p_button->y      -= 15;
6148                        p_button->width  += 50;
6149                        break;
6150                case eSCREEN_RATINGS_TV:
6151                        p_button->y      += 10;
6152                        break;
6153                case eSCREEN_RATINGS_RRT_DIM:
6154                        p_button->y      += 14;
6155                        break;
6156                case eSCREEN_RATINGS_RRT_UPDATE:
6157                        p_button->width  += 60;
6158                        break;
6159                case eSCREEN_RATINGS_LOCK:
6160                        p_button->width  += -10;
6161                        break;
6162                case eSCREEN_RATINGS_LIMITS:
6163                        p_button->width  += 20;
6164                        break;
6165                case eSCREEN_AUTO_POWER:
6166                        p_button->y      += 15;
6167                        p_button->width  -= 20;
6168                        break;
6169                case eSCREEN_SETUP:
6170                        p_button->width  -= 30;
6171                        break;
6172                case eSCREEN_WRONG_PIN_LIVE:
6173                case eSCREEN_WRONG_PIN_RATINGS:
6174                case eSCREEN_WRONG_PIN_RESET:
6175                case eSCREEN_MISMATCHED_PINS:
6176                        p_button->width += 140;
6177                        p_button->y     -= 20;
6178                        break;
6179                case eSCREEN_WIZ_MISMATCHED_PINS:
6180                        p_button->width += 140;
6181                        break;
6182                case eSCREEN_CAPTIONS_ADVANCED:
6183                        p_button->width += 70;
6184                        break;
6185#if 0
6186                case eSCREEN_CAPTIONS_ON_OFF:
6187                        p_button->width += 20;
6188                        break;
6189#endif
6190                case eSCREEN_CAPTIONS_RESET:
6191                        p_button->width += 15;
6192                        break;
6193                default:
6194                        break;
6195                }
6196        } else
6197                if (p_app->lang == eLANG_FRENCH)
6198        {
6199                switch (p_app->screen_id)
6200                {
6201                case eSCREEN_AV:
6202                        p_button->x      -= 52;
6203                        p_button->width  += 36;
6204                        break;
6205                case eSCREEN_SOUND:
6206                        p_button->x      -= 24;
6207                        p_button->width  += 110;
6208                        break;
6209                case eSCREEN_CAPTIONS_ADVANCED:
6210                        p_button->x      -= 6;
6211                        p_button->width  += 120;
6212                        break;
6213                case eSCREEN_CAPTIONS_RESET:
6214                        p_button->x      -= 8;
6215                        p_button->width  += 34;
6216                        break;
6217                case eSCREEN_CAPTIONS_FONT_COLOR:
6218                case eSCREEN_CAPTIONS_EDGE_COLOR:
6219                        break;
6220                case eSCREEN_CAPTIONS_BACK_COLOR:
6221                        p_button->y      += 6;
6222                        p_button->x      -= 16;
6223                        break;
6224                case eSCREEN_CAPTIONS_FONT:
6225                        p_button->y      += -23;
6226                        p_button->x      -= 16;
6227                        p_button->width  -= 4;
6228                        break;
6229                case eSCREEN_CAPTIONS_FONT_SIZE:
6230                        p_button->+= 10;
6231                        p_button->width  += 12;
6232                        p_button->y      += 6;
6233                        break;
6234                case eSCREEN_CAPTIONS_FONT_STYLE:
6235                        p_button->width  += 55;
6236                        p_button->y      += 20;
6237                        break;
6238                case eSCREEN_CAPTIONS_FONT_OPACITY:
6239                case eSCREEN_CAPTIONS_BACK_OPACITY:
6240                        p_button->x     += -6;
6241                        p_button->width  += -8;
6242                        break;
6243                case eSCREEN_CAPTIONS_FONT_OPTIONS:
6244                        p_button->x      -= 16;
6245                        p_button->y      += 8;
6246                        p_button->width  += 84;
6247                        break;
6248                case eSCREEN_CAPTIONS_BACK_OPTIONS:
6249                        p_button->x      -= 16;
6250                        p_button->y      += -2;
6251                        p_button->width  += 140;
6252                        break;
6253                case eSCREEN_CAPTIONS_EDGE_TYPE:
6254                        p_button->x      += -10;
6255                        p_button->width  += 26;
6256                        break;
6257
6258                case eSCREEN_MAIN:
6259                        p_button->x      += -20;
6260                        p_button->width  += 35;
6261                        p_button->height += 0;
6262                        break;
6263                case eSCREEN_RESET:
6264                        p_button->x      += 25;
6265                        p_button->width  += 30;
6266                        break;
6267                case eSCREEN_RATINGS:
6268                        p_button->x      += 5;
6269                        p_button->width  += 40;
6270                        break;
6271                case eSCREEN_RATINGS_LIMITS:
6272                        p_button->width  += 30;
6273                        break;
6274                case eSCREEN_RATINGS_TV:
6275                        p_button->y      += 10;
6276                        break;
6277                case eSCREEN_RATINGS_RRT_DIM:
6278                case eSCREEN_RATINGS_RRT_VAL:
6279                        p_button->y      += 10;
6280                        break;
6281                case eSCREEN_RATINGS_MOVIES:
6282                        p_button->y      += 10;
6283                        break;
6284                case eSCREEN_WRONG_PIN_LIVE:
6285                case eSCREEN_WRONG_PIN_RATINGS:
6286                case eSCREEN_MISMATCHED_PINS:
6287                case eSCREEN_WIZ_MISMATCHED_PINS:
6288                        p_button->width  += 110; 
6289                        break; 
6290                case eSCREEN_WRONG_PIN_RESET:
6291                        p_button->y      -= 20;
6292                        p_button->width  += 110; 
6293                        break;
6294                case eSCREEN_AUTO_POWER:
6295                        p_button->y      += 5;
6296                        break;
6297                default:
6298                        break;
6299                }
6300        }
6301#ifdef NUMBER_BUTTONS
6302        p_button->width += 20;
6303#endif
6304
6305        if (p_app->screen_id == eSCREEN_RATINGS_TV)
6306                p_button->width -= 10;
6307
6308}
6309
6310
6311/*
6312Summary:
6313        Draw a button.
6314Description:
6315        Draw a button.
6316*/
6317void bscreen_draw_button(void *v_app,                                   /* application structure */
6318                                                 const bbutton_t *p_button,             /* button info structure */
6319                                                 int selected,                                  /* Button selected when non-zero */
6320                                                 int checked,                                   /* Button checked when non-zero */
6321                                                 int idx                                                /* button index or -1 for non index button */
6322                                                )
6323{
6324        bapp_t *p_app = (bapp_t*)v_app;
6325        bbutton_t tmp_button;
6326        unsigned int num_chars;
6327        num_chars = SCREEN_MAX_STR_WIDTH;
6328        bscreen_get_string(p_app->lang,p_button->text_id, p_app->tmp_str, &num_chars);
6329
6330#ifdef NUMBER_BUTTONS
6331        if (p_app->screen_id != eSCREEN_RATINGS_TV)
6332        {
6333                if (p_app->button_numbers && (idx >= 0))
6334                {
6335                        char cstr[16];
6336                        int clen;
6337                        clen = snprintf(cstr,16," - %d",idx + 1);
6338                        if ((clen + num_chars) < SCREEN_MAX_STR_WIDTH)
6339                        {
6340                                num_chars += c_to_uni_str(cstr,&p_app->tmp_str[num_chars],clen);
6341                        }
6342                }
6343        }
6344#endif
6345
6346        /* adjust button size/position based on language choice */
6347        tmp_button = *p_button;
6348        adjust_button_orientation(v_app, &tmp_button);
6349
6350#ifdef BCM_DEBUG
6351        if (p_app->ui_debug_mode)
6352        {
6353                char *p_str = g_p_dsp->ui_comp.str_table[p_app->lang][p_button->text_id];
6354                if (p_str)
6355                {
6356                        printf("%s (%d,%d,%d,%d) - (%d,%d,%d,%d) %d\n", 
6357                                   p_str,p_button->x,p_button->y,p_button->width,p_button->height,tmp_button.x,tmp_button.y,tmp_button.width,tmp_button.height,num_chars);
6358                }
6359        }
6360#endif
6361        if ((p_app->lang == eLANG_FRENCH) && (p_app->screen_id == eSCREEN_CAPTIONS_FONT))
6362        {
6363                tmp_button.y += (idx * 4);
6364        }
6365
6366        if ((p_app->screen_id == eSCREEN_PICTURE) && (p_app->lang == eLANG_SPANISH))
6367        {
6368                tmp_button.y += (idx * 16);
6369        }
6370        bscreen_draw_button_str(v_app,&tmp_button,selected,checked,p_app->tmp_str,num_chars,NULL,0,eFONT_SIZE_MED,p_button->right_justify_text);
6371}
6372
6373#if 1
6374/*
6375Summary:
6376        Draw a button but override the p_button->text_id text with str_text.
6377Description:
6378        Draw a button but override the p_button->text_id text with str_text.
6379*/
6380void bscreen_draw_button_custom_text(void *v_app,                                       /* application structure */
6381                                                                         const bbutton_t *p_button,             /* button info structure */
6382                                                                         char *str_text,                                /* button text to use (overrides p_button->text_id) */
6383                                                                         char *str_desc_text,                   /* description text to use (overrides p_button->desc_text_id) */
6384                                                                         int selected,                                  /* Button selected when non-zero */
6385                                                                         int checked,                                   /* Button checked when non-zero */
6386                                                                         int idx                                                /* button index or -1 for non index button */
6387                                                                        )
6388{
6389        bapp_t *p_app = (bapp_t*)v_app;
6390        bbutton_t tmp_button;
6391        unsigned int num_chars = 0;
6392        unsigned int num_desc_chars = 0;
6393        const int MAX_DESC_LEN = 64;
6394        unsigned int tmp_desc_str[MAX_DESC_LEN];
6395        bapp_font_size_t  font_size = eFONT_SIZE_MED;
6396#ifdef RRT_BUTTON_NUM
6397        char cstr[16];
6398        int clen = 0;
6399#endif
6400        int margin = eBUTTON_MARGIN_X;
6401        int str_width = 0;
6402        int pixels_per_char = 0;
6403        int w = 0;
6404        int h = 0;
6405
6406        if (!str_text)
6407                str_text = " ";
6408
6409        if (strlen(str_text) == 0)
6410                str_text = " ";
6411
6412        num_chars = strlen(str_text);
6413#ifdef RRT_BUTTON_NUM
6414        clen = snprintf(cstr,16," - %d",idx + 1);
6415#endif
6416        num_chars = c_to_uni_str(str_text,p_app->tmp_str, strlen(str_text));
6417        bgfx_string_info(p_app->p_font[p_app->lang][font_size],(const unsigned long *)p_app->tmp_str,num_chars,&w,&h);
6418
6419        /* calc width of entire string (includes index if necessary) in pixels */
6420        pixels_per_char = ((w + margin) / num_chars);
6421        str_width = w + margin;
6422
6423#ifdef RRT_BUTTON_NUM
6424        if (p_app->button_numbers)
6425                str_width += (clen * pixels_per_char);
6426#endif
6427
6428        if (str_width > p_button->width)
6429        {
6430                /* trim string characters if too big for button */
6431                int excess_pixels = (str_width - p_button->width);
6432
6433                num_chars -= excess_pixels / pixels_per_char; 
6434                bgfx_string_info(p_app->p_font[p_app->lang][font_size],(const unsigned long *)p_app->tmp_str,num_chars,&w,&h);
6435
6436#ifdef RRT_BUTTON_NUM
6437                /* copy string into p_app->tmp-str - index number will be copied later if necessary */
6438                c_to_uni_str(str_text,p_app->tmp_str, num_chars - clen);
6439#endif
6440
6441                BDBG_MSG(("%s : too wide for button - adjusting from %d chars to %d chars\n", __FUNCTION__,(num_chars + excess_pixels / pixels_per_char), num_chars));
6442        } else
6443        {
6444                /* string fits in button - no trimming necesary */
6445                /* copy string into p_app->tmp_str - index number will be copied later if necesary */
6446                num_chars = c_to_uni_str(str_text,p_app->tmp_str, strlen(str_text));
6447        }
6448
6449#ifdef RRT_BUTTON_NUM
6450        /* copy index number into tmp_str if necessary */
6451        if (p_app->button_numbers && (idx >= 0))
6452                num_chars += c_to_uni_str(cstr,&p_app->tmp_str[num_chars],clen);
6453#endif
6454
6455        if (str_desc_text)
6456        {
6457                num_desc_chars = SCREEN_MAX_STR_WIDTH;
6458                num_desc_chars = c_to_uni_str(str_desc_text,tmp_desc_str, MAX_DESC_LEN);
6459        }
6460
6461        /* adjust button size/position based on language choice */
6462        //tmp_button = *p_button;
6463        memcpy(&tmp_button, p_button, sizeof(tmp_button));
6464        adjust_button_orientation(v_app, &tmp_button);
6465
6466        bscreen_draw_button_str(v_app,&tmp_button,selected,checked,p_app->tmp_str,num_chars,tmp_desc_str,num_desc_chars,eFONT_SIZE_MED,tmp_button.right_justify_text);
6467}
6468#endif
6469/*
6470Summary:
6471        Draw the buttons for the screen.
6472Description:
6473        Draw the buttons for the screen.
6474*/
6475void bscreen_draw_buttons(
6476                                                 void *v_app,                    /* Opaque app reference */
6477                                                 void *v_screen                  /* Opaque screen reference */
6478                                                 )
6479{
6480        bapp_t *p_app = (bapp_t*)v_app;
6481        bscreen_t *p_screen = (bscreen_t*)v_screen;
6482        bscreen_event_t event;
6483        int button_idx,selected,checked;
6484
6485        for (button_idx = 0; button_idx < p_screen->num_buttons; button_idx++)
6486        {
6487                event.type = eS_EVENT_SELECTED;
6488                event.id = button_idx;
6489                selected = p_screen->handle_event(p_app,p_screen,&event);
6490                event.type = eS_EVENT_CHECKED;
6491                checked = p_screen->handle_event(p_app,p_screen,&event);
6492
6493                bscreen_draw_button(p_app,&p_screen->p_button_array[button_idx], selected,checked,button_idx);
6494        }
6495}
6496
6497/*
6498Summary:
6499        Draw a progress meter for the screen.
6500Description:
6501        Draw a progress meter for the screen.
6502*/
6503void bscreen_draw_progress(void * v_app, 
6504                                                   unsigned int x,
6505                                                   unsigned int y,
6506                                                   unsigned int width,
6507                                                   unsigned int height,
6508                                                   unsigned int border_width,
6509                                                   unsigned int border_color,
6510                                                   unsigned int background_color,
6511                                                   unsigned int percent)
6512{
6513        bapp_t *p_app = (bapp_t*)v_app;
6514        int newX = x;
6515        int newY = y;
6516        int newW = width;
6517        int newH = height;
6518
6519#ifdef CONFIG_ORIG_SYNC
6520        bapp_sync(p_app);
6521#endif
6522
6523        /* draw border */
6524        //bgfx_fill_rect(&p_app->surf, newX, newY, newW, newH, border_color);
6525        bgfx_fill_rect(&p_app->surf,newX,newY,newW,border_width,eCOLOR_WHITE);
6526        bgfx_fill_rect(&p_app->surf,newX,newY+newH-border_width,newW+border_width,border_width,eCOLOR_WHITE);
6527        bgfx_fill_rect(&p_app->surf,newX,newY,border_width,newH,eCOLOR_WHITE);
6528        bgfx_fill_rect(&p_app->surf,newX+newW,newY,border_width,newH,eCOLOR_WHITE);
6529
6530        /* draw progress background */
6531        newX += border_width;
6532        newY += border_width;
6533        newW -= (2 * border_width);
6534        newH -= (2 * border_width);
6535        bgfx_fill_rect(&p_app->surf, newX, newY, newW, newH, background_color);
6536
6537        /* draw thumb */
6538        newX += border_width;
6539        newY += border_width;
6540        newW = (newW - (2 * border_width)) * percent / 100;
6541        newH -= (2 * border_width);
6542
6543        if (newW)
6544        {
6545                /* draw top bevel */
6546                bgfx_fill_rect(&p_app->surf,newX,newY, newW,eBUTTON_BEVEL_GRADIENT_STEP,eCOLOR_DK_YELLOW);
6547                newY += eBUTTON_BEVEL_GRADIENT_STEP;
6548                bgfx_fill_rect(&p_app->surf,newX,newY, newW,eBUTTON_BEVEL_GRADIENT_STEP,eCOLOR_PALE_YELLOW);
6549                newY += eBUTTON_BEVEL_GRADIENT_STEP;
6550                bgfx_fill_rect(&p_app->surf,newX,newY, newW,eBUTTON_BEVEL_GRADIENT_STEP,eCOLOR_MED_YELLOW);
6551                newY += eBUTTON_BEVEL_GRADIENT_STEP;
6552                bgfx_fill_rect(&p_app->surf,newX,newY, newW,eBUTTON_BEVEL_GRADIENT_STEP,eCOLOR_LT_YELLOW);
6553                newY += eBUTTON_BEVEL_GRADIENT_STEP;
6554
6555                /* draw middle */
6556                bgfx_fill_rect(&p_app->surf,newX,newY,
6557                                           newW,newH - (7 * eBUTTON_BEVEL_GRADIENT_STEP),eCOLOR_BRT_YELLOW);
6558
6559                /* draw bottom bevel */
6560                newY = y + height - (2 * border_width) - eBUTTON_BEVEL_GRADIENT_STEP;
6561                bgfx_fill_rect(&p_app->surf,newX,newY, newW,eBUTTON_BEVEL_GRADIENT_STEP,eCOLOR_DK_YELLOW);
6562                newY -= eBUTTON_BEVEL_GRADIENT_STEP;
6563                bgfx_fill_rect(&p_app->surf,newX,newY, newW,eBUTTON_BEVEL_GRADIENT_STEP,eCOLOR_MED_YELLOW);
6564                newY -= eBUTTON_BEVEL_GRADIENT_STEP;
6565                bgfx_fill_rect(&p_app->surf,newX,newY, newW,eBUTTON_BEVEL_GRADIENT_STEP,eCOLOR_LT_YELLOW);
6566                newY -= eBUTTON_BEVEL_GRADIENT_STEP;
6567        }
6568
6569#ifdef CONFIG_ORIG_SYNC
6570        bapp_flush_screen(p_app);
6571#endif
6572}
6573
6574/*
6575Summary:
6576        Draw pin fields for the screen.
6577Description:
6578        Draw pin fields for the screen.
6579*/
6580void bscreen_draw_pin(void * v_app, 
6581                                          unsigned int x,
6582                                          unsigned int y,
6583                                          unsigned int width,
6584                                          unsigned int height,
6585                                          unsigned int inc_x,
6586                                          unsigned int selection,
6587                                          unsigned int field)
6588{
6589        bapp_t *p_app = (bapp_t*)v_app;
6590        int newX = x;
6591        int newY = y;
6592        int newW = width;
6593        int newH = height;
6594        unsigned int i    = field;
6595        unsigned int j    = 0;
6596
6597        for (j = 0; j < field; j++)
6598        {
6599                newX += width + inc_x;
6600                newY = y;
6601                newW = width;
6602                newH = height;
6603        }
6604
6605#ifdef CONFIG_ORIG_SYNC
6606        bapp_sync(p_app);
6607#endif
6608
6609        /* draw border */
6610        bgfx_fill_rect(&p_app->surf, newX, newY, newW, newH, eCOLOR_WHITE);
6611
6612        /* draw progress background */
6613        newX += eBUTTON_PROGRESS_BORDER;
6614        newY += eBUTTON_PROGRESS_BORDER;
6615        newW -= (2 * eBUTTON_PROGRESS_BORDER);
6616        newH -= (2 * eBUTTON_PROGRESS_BORDER);
6617        bgfx_fill_rect(&p_app->surf, newX, newY, newW, newH, eCOLOR_DRK_BLUE);
6618
6619        /* draw highlight */
6620        if (i == selection)
6621        {
6622                newX += eBUTTON_PROGRESS_BORDER;
6623                newY += eBUTTON_PROGRESS_BORDER;
6624                newW = (newW - (2 * eBUTTON_PROGRESS_BORDER));
6625                newH -= (2 * eBUTTON_PROGRESS_BORDER);
6626
6627                /* draw top bevel */
6628                bgfx_fill_rect(&p_app->surf,newX,newY, newW,eBUTTON_BEVEL_GRADIENT_STEP,eCOLOR_DK_YELLOW);
6629                newY += eBUTTON_BEVEL_GRADIENT_STEP;
6630                bgfx_fill_rect(&p_app->surf,newX,newY, newW,eBUTTON_BEVEL_GRADIENT_STEP,eCOLOR_PALE_YELLOW);
6631                newY += eBUTTON_BEVEL_GRADIENT_STEP;
6632                bgfx_fill_rect(&p_app->surf,newX,newY, newW,eBUTTON_BEVEL_GRADIENT_STEP,eCOLOR_MED_YELLOW);
6633                newY += eBUTTON_BEVEL_GRADIENT_STEP;
6634                bgfx_fill_rect(&p_app->surf,newX,newY, newW,eBUTTON_BEVEL_GRADIENT_STEP,eCOLOR_LT_YELLOW);
6635                newY += eBUTTON_BEVEL_GRADIENT_STEP;
6636
6637                /* draw middle */
6638                bgfx_fill_rect(&p_app->surf,newX,newY,
6639                                           newW,newH - (7 * eBUTTON_BEVEL_GRADIENT_STEP),eCOLOR_BRT_YELLOW);
6640
6641                /* draw bottom bevel */
6642                newY = y + height - (2 * eBUTTON_PROGRESS_BORDER) - eBUTTON_BEVEL_GRADIENT_STEP;
6643
6644                bgfx_fill_rect(&p_app->surf,newX,newY, newW,eBUTTON_BEVEL_GRADIENT_STEP,eCOLOR_DK_YELLOW);
6645                newY -= eBUTTON_BEVEL_GRADIENT_STEP;
6646                bgfx_fill_rect(&p_app->surf,newX,newY, newW,eBUTTON_BEVEL_GRADIENT_STEP,eCOLOR_MED_YELLOW);
6647                newY -= eBUTTON_BEVEL_GRADIENT_STEP;
6648                bgfx_fill_rect(&p_app->surf,newX,newY, newW,eBUTTON_BEVEL_GRADIENT_STEP,eCOLOR_LT_YELLOW);
6649                newY -= eBUTTON_BEVEL_GRADIENT_STEP;
6650        } else
6651                if (i < selection)
6652        {
6653                /* draw hidden value indicator */
6654                unsigned int num_chars = SCREEN_MAX_STR_WIDTH;
6655                int w = 0;
6656                int h = 0;
6657
6658                bscreen_get_string(p_app->lang,eTEXT_HIDDEN_PIN_DIGIT, p_app->tmp_str, &num_chars);
6659                bgfx_string_info(p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],(const unsigned long *)p_app->tmp_str,num_chars,&w,&h);
6660                text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_LARGE],
6661                                                newX + ((newW / 2) - (w / 2)) - 5, y + ((newH / 2) - (h / 2)), w, h, p_app->tmp_str,
6662                                                num_chars, eCOLOR_WHITE, eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_INFO_LINE_SPACING);
6663        }
6664#ifdef CONFIG_ORIG_SYNC
6665        bapp_flush_screen(p_app);
6666#endif
6667}
6668/*
6669Summary:
6670        Default screen drawing function
6671Description:
6672        Default screen drawing function.
6673        .
6674*/
6675void bscreen_auto_power_draw(void *v_app, void *v_screen)
6676{
6677        bapp_t *p_app = (bapp_t*)v_app;
6678        bscreen_t *p_screen = (bscreen_t*)v_screen;
6679        unsigned int num_chars;
6680        uint16_t title_area_height = p_screen->top_banner_height;
6681
6682        if (p_app->settings.auto_power_off)
6683        {
6684                title_area_height += 32;
6685        }
6686        bscreen_draw_background(v_app, &p_app->surf, title_area_height);
6687
6688        /* draw title */
6689        num_chars = SCREEN_MAX_STR_WIDTH;
6690        bscreen_get_string(p_app->lang,p_screen->title_text_id, p_app->tmp_str, &num_chars);
6691        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_LARGE],
6692                                        eMENU_TITLE_TEXT_X, eMENU_TITLE_TEXT_Y,
6693                                        eMENU_TITLE_TEXT_WIDTH, eMENU_TITLE_TEXT_HEIGHT,  p_app->tmp_str,
6694                                        num_chars, eCOLOR_DK_YELLOW,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_TEXT_HEIGHT);
6695
6696        /* draw description */
6697        num_chars = SCREEN_MAX_STR_WIDTH;
6698        if (p_app->settings.auto_power_off)
6699                bscreen_get_string(p_app->lang,eTEXT_AUTO_POWERED_OFF, p_app->tmp_str, &num_chars);
6700        else
6701                bscreen_get_string(p_app->lang,p_screen->desc_text_id, p_app->tmp_str, &num_chars);
6702        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
6703                                        eMENU_TITLE_DESC_TEXT_X, eMENU_TITLE_DESC_TEXT_Y,
6704                                        eMENU_TITLE_DESC_TEXT_WIDTH, eMENU_TITLE_DESC_TEXT_HEIGHT,  p_app->tmp_str,
6705                                        num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eMENU_TITLE_DESC_TEXT_SPACING);
6706
6707
6708        bscreen_draw_buttons(v_app,v_screen);
6709
6710        draw_navigation_hints(v_app, v_screen);
6711}
6712
6713#include "bguide.c"
6714
Note: See TracBrowser for help on using the repository browser.