source: svn/trunk/newcon3bcm2_21bu/dta/src/app/nanotv/bguide.c @ 29

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

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 19.5 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#define MAX_GUIDE_ENTRIES   9
23
24#ifdef CONFIG_DVB
25#include "dvb_parser.h"
26#endif
27
28/* Define to test guide drawing and selection control without PSIP guide data */
29/*
30#define STATIC_GUIDE_TEST
31*/
32
33#define GUIDE_MIN(x,y)      ((x < y) ? x : y)
34#define eSCREEN_GUIDE_X                 82
35#define eSCREEN_GUIDE_Y_OFF             130
36#define eSCREEN_GUIDE_HEIGHT            30
37#define eSCREEN_GUIDE_CH_WIDTH          55
38#define eSCREEN_GUIDE_CALLSIGN_WIDTH    90
39#define eSCREEN_GUIDE_CH_NAME_X         138
40#define eSCREEN_GUIDE_CH_NAME_WIDTH     30
41#define eSCREEN_GUIDE_NEXT_X            445
42#define eSCREEN_GUIDE_CUR_X             235
43#define eSCREEN_GUIDE_NAME_WIDTH        196
44#define eSCREEN_GUIDE_SPACING           30
45
46#define guide_text_box(s,f,x,y,w,h,m,l,cf,cb,o,lsp)  text_box(s,f,x,y,w,h,m,l,cf,lsp)
47
48static void draw_guide_entry(bapp_t *p_app, bscreen_t *p_screen, guide_state_t *p_gs,
49                                                         int idx, chm_info_t *p_info, bool selected);
50static chm_info_t* screen_guide_get_info(bapp_t *p_app, int idx);
51
52guide_state_t g_guide_state = 
53{
54        0,
55        0,
56        1,
57        "",
58        { eS_EVENT_MAX, 0, 0},
59        0,
60        0,
61        0
62};
63/*
64Summary:
65        Guide event handling. return 0 if no redrawing should
66        be done.
67        .
68*/
69int screen_guide_move(bapp_t *p_app, bscreen_t *p_screen, 
70                                          int up)
71{
72        int start_idx,end_idx,num_disp,result,old_sel;
73        guide_state_t *p_gs;
74        p_gs = (guide_state_t*)p_screen->local_state;
75        chm_info_t *p_info;
76        chm_info_t *p_old_info;
77        BDBG_ASSERT(p_gs);
78
79        result = 0;
80
81        if (p_app->settings.ch_map.vch_map.num_vch < 2)
82                return result;
83
84        start_idx = p_gs->offset;
85        end_idx = GUIDE_MIN((p_app->settings.ch_map.vch_map.num_vch - 1),
86                                                (p_gs->offset + (MAX_GUIDE_ENTRIES - 1)));
87        num_disp = (end_idx - start_idx + 1);
88
89        old_sel = p_gs->selection;
90        /* If moving selection up */
91        if (up > 0)
92        {
93                if (p_gs->selection == 0)
94                {
95                        /* already at top */
96                }
97                else
98                        if (up >= MAX_GUIDE_ENTRIES)
99                {
100                        /* jump one page up */
101                        start_idx -= MAX_GUIDE_ENTRIES;
102                        p_gs->selection -= MAX_GUIDE_ENTRIES;
103                        if (start_idx < 0)
104                        {
105                                BDBG_ERR(("start_idx = %d < 0\n", start_idx));
106                                start_idx = 0;
107                                p_gs->selection = start_idx;
108                        }
109
110                        p_gs->offset = start_idx;
111                        result = 1;
112                }
113                else
114                        if (p_gs->selection > start_idx)
115                {
116                        p_gs->selection--;
117                        p_old_info = screen_guide_get_info(p_app,old_sel);
118                        p_info = screen_guide_get_info(p_app,p_gs->selection);
119                        draw_guide_entry(p_app,p_screen,p_gs, p_gs->selection,p_info,true);
120                        draw_guide_entry(p_app,p_screen,p_gs, old_sel,p_old_info,false);
121                        result = 1;
122                }
123                else if (start_idx > 0)
124                {
125                        start_idx -= MAX_GUIDE_ENTRIES;
126                        if (start_idx < 0)
127                        {
128                                BDBG_ERR(("start_idx = %d < 0\n", start_idx));
129                                start_idx = 0;
130                                p_gs->selection = start_idx;
131                        }
132                        p_gs->offset = start_idx;
133                        p_gs->selection--;
134                        result = 1;
135                }
136                else
137                {
138                        /* Do nothing */
139                }
140        }
141        else /* moving selection down */
142        {
143                if (p_gs->selection == (p_app->settings.ch_map.vch_map.num_vch - 1))
144                {
145                        /* already at bottom */
146                }
147                else
148                        if (up <= -MAX_GUIDE_ENTRIES)
149                {
150                        /* jump one page down */
151                        p_gs->offset += MAX_GUIDE_ENTRIES;
152                        p_gs->selection += MAX_GUIDE_ENTRIES;
153                        if (p_gs->offset >= p_app->settings.ch_map.vch_map.num_vch)
154                        {
155                                BDBG_ERR(("p_gs->offset = %d >= %d\n", p_gs->offset,p_app->settings.ch_map.vch_map.num_vch));
156                                p_gs->offset -= MAX_GUIDE_ENTRIES;
157                        }
158
159                        if (p_gs->selection >= p_app->settings.ch_map.vch_map.num_vch)
160                        {
161                                BDBG_ERR(("p_gs->selection = %d >= %d\n", p_gs->selection,p_app->settings.ch_map.vch_map.num_vch));
162                                p_gs->selection = p_app->settings.ch_map.vch_map.num_vch - 1;
163                        }
164
165                        result = 1;
166                }
167                else
168                        if (p_gs->selection < end_idx)
169                {
170                        p_gs->selection++;
171                        p_old_info = screen_guide_get_info(p_app,old_sel);
172                        p_info = screen_guide_get_info(p_app,p_gs->selection);
173                        draw_guide_entry(p_app,p_screen,p_gs, old_sel,p_old_info,false);
174                        draw_guide_entry(p_app,p_screen,p_gs, p_gs->selection,p_info,true);
175                        result = 1;
176                }
177                else
178                        if ((end_idx == p_app->settings.ch_map.vch_map.num_vch) ||
179                                (num_disp < MAX_GUIDE_ENTRIES))
180                {
181                        /* do nothing */
182                }
183                else
184                {
185                        p_gs->offset += MAX_GUIDE_ENTRIES;
186                        p_gs->selection++;
187                        if (p_gs->offset >= p_app->settings.ch_map.vch_map.num_vch)
188                        {
189                                BDBG_ERR(("p_gs->offset = %d >= %d\n", p_gs->offset,p_app->settings.ch_map.vch_map.num_vch));
190                                p_gs->offset -= MAX_GUIDE_ENTRIES;
191                                p_gs->selection = p_app->settings.ch_map.vch_map.num_vch - 1;
192                        }
193                        result = 1;
194                }
195        }
196        return result;
197}
198/*
199Summary:
200        Guide event handling
201        .
202*/
203int screen_guide_event(void *v_app, void *v_screen, 
204                                           bscreen_event_t *p_event)
205{
206        bapp_t *p_app = (bapp_t*)v_app;
207        bscreen_t *p_screen = (bscreen_t*)v_screen;
208        guide_state_t *p_gs;
209        int result = 0;
210
211        p_gs = (guide_state_t*)p_screen->local_state;
212        BDBG_ASSERT(p_gs);
213
214        switch (p_event->type)
215        {
216        case eS_EVENT_SETUP:
217                {
218#ifdef CONFIG_DVB_SUBTITLE
219                        bapp_dsub_enable(p_app->dsub, false, 0);
220#endif
221                        bscreen_default_setup(v_app,v_screen);
222                        p_gs->column = 1;
223                        if (p_app->settings.ch_map.cur_ch)
224                        {
225                                p_gs->offset = (p_app->settings.ch_map.cur_ch/MAX_GUIDE_ENTRIES) * MAX_GUIDE_ENTRIES;
226                                p_gs->selection = p_app->settings.ch_map.cur_ch;
227                        }
228                        else
229                        {
230                                p_gs->selection = 0;
231                                p_gs->offset = 0;
232                        }
233                        memset(&p_gs->event,0,sizeof(p_gs->event));
234                        p_gs->repeat_rate = 1;
235                        p_gs->repeat_timeout = DEFAULT_REPEAT_TIMEOUT/p_gs->repeat_rate;
236                        result = 1;     /* always handle event */
237
238                        bapp_enable_cc(p_app, 0);
239                        bapp_eia708_enable(p_app->eia708, false);
240                        if (p_app->settings.ch_map.vch_map.num_vch == 0)
241                        {
242                                /* set update progress to done since there are no channels */
243                                p_gs->update_progress = 100;
244                        }
245                        else
246                        {
247                                bos_sleep(20); /* give time for command to be processed */
248                        }
249
250                        bapp_audio_do_mute(p_app, true);
251                }
252                break;
253        case eS_EVENT_SETUP_DONE:
254                {
255                }
256                break;
257        case eS_EVENT_PROGRESS:
258                {
259                        p_gs->update_progress = p_event->id;
260
261                        if (p_gs->update_progress < 100)
262                        {
263                                int num_chars = SCREEN_MAX_STR_WIDTH;
264                                int w = 0;
265                                int h = 0;
266
267                                /* draw progress text */
268                                bscreen_get_string(p_app->lang,eTEXT_GUIDE_DL_PROGRESS, p_app->tmp_str, &num_chars);
269                                bgfx_string_info(p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],(const unsigned long *)p_app->tmp_str,num_chars,&w,&h);
270                                text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
271                                                                ePROGRESS_GUIDE_X - w - 7, ePROGRESS_GUIDE_TEXT_Y,
272                                                                w + 3, ePROGRESS_GUIDE_TEXT_HEIGHT,  p_app->tmp_str,
273                                                                num_chars, eCOLOR_MED_YELLOW,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,100);
274
275                                bscreen_draw_progress(v_app, ePROGRESS_GUIDE_X, ePROGRESS_GUIDE_Y, ePROGRESS_GUIDE_WIDTH, ePROGRESS_GUIDE_HEIGHT, 
276                                                                          eBUTTON_VOL_PROGRESS_BORDER, eCOLOR_WHITE, eCOLOR_DRK_BLUE, p_gs->update_progress, 100);
277                        }
278                        else
279                        {
280                                bgfx_fill_rect(&p_app->surf,ePROGRESS_GUIDE_TEXT_X,ePROGRESS_GUIDE_Y,
281                                                           ePROGRESS_GUIDE_X+ePROGRESS_GUIDE_WIDTH-ePROGRESS_GUIDE_TEXT_X+3,ePROGRESS_GUIDE_HEIGHT+3,eCOLOR_LT_BLUE);
282                        }
283
284                        result = 1;
285                }
286                break;
287        case eS_EVENT_REDRAW:
288                {
289                        result = 1;
290                }
291                break;
292        case eS_EVENT_IR:
293                {
294                        switch (p_event->id)
295                        {
296                        case eIR_SELECT:
297
298                                if (p_gs->column == 1)
299                                {
300                                        p_app->chm_cmd.cmd_id = eCHM_CANCEL;
301                                        chm_cmd(&p_app->chm, &p_app->chm_cmd);
302                                        BDBG_WRN(("Current Selection %d\n", p_gs->selection));
303                                        bos_sleep(500); /* Give chance for cancel to take effect - JPF are we sure this is necessary??? */
304                                        bapp_set_channel(p_app, 
305                                                                         p_app->settings.ch_map.vch_map.vch[p_gs->selection].ch_num/*,
306                                                                         p_app->settings.ch_map.vch_map.vch[p_gs->selection].minor*/);
307                                        bapp_set_current_screen(p_app,eSCREEN_BANNER,eSCREEN_NULL);
308                                }
309                                else
310                                {
311                                }
312                                result = 1;
313                                break;
314                        case eIR_MENU:
315                        case eIR_GUIDE:
316#if 0 
317                                p_app->chm_cmd.cmd_id = eCHM_CANCEL;
318                                chm_cmd(&p_app->chm,&p_app->chm_cmd);
319                                BDBG_WRN(("Current Selection %d\n", p_gs->selection));
320                                bos_sleep(500); /* Give chance for cancel to take effect */
321#endif
322/*                p_app->settings.ch_map.cur_ch = p_gs->selection;*/
323                                bapp_goto_last_screen(p_app);
324                                bapp_tune(p_app);
325                                result = 1;
326                                break;
327                        case eIR_CH_UP:
328                                result = screen_guide_move(p_app,p_screen,MAX_GUIDE_ENTRIES);
329                                break;
330                        case eIR_UP:
331                                result = screen_guide_move(p_app,p_screen,1);
332                                break;
333                        case eIR_CH_DOWN:
334                                result = screen_guide_move(p_app,p_screen,-MAX_GUIDE_ENTRIES);
335                                break;
336                        case eIR_DOWN:
337                                result = screen_guide_move(p_app,p_screen,0);
338                                break;
339                        default:
340                                break;
341                        }
342                        p_gs->event = *p_event;
343                        p_gs->repeat_rate = 1;
344                        p_gs->repeat_timeout = bos_getticks() + (DEFAULT_REPEAT_TIMEOUT/p_gs->repeat_rate);
345                }
346                break;
347        case eS_EVENT_IDLE:
348                {
349                        if (p_gs->repeat_timeout < bos_getticks())
350                        {
351                                /* Handle repeating when key is held down */
352                                if (p_gs->event.type == eS_EVENT_IR)
353                                {
354                                        switch (p_gs->event.id)
355                                        {
356                                        case eIR_UP:
357                                        case eIR_CH_UP:
358                                                result = screen_guide_move(p_app,p_screen,1);
359                                                break;
360                                        case eIR_DOWN:
361                                        case eIR_CH_DOWN:
362                                                result = screen_guide_move(p_app,p_screen,0);
363                                                break;
364                                        default: break;
365                                        }
366                                }
367
368                                if (p_gs->repeat_rate < MAX_REPEAT_ACCEL)
369                                {
370                                        p_gs->repeat_rate += REPEAT_INC;
371                                }
372                                p_gs->repeat_timeout = bos_getticks() + (DEFAULT_REPEAT_TIMEOUT/p_gs->repeat_rate);
373                        }
374
375                        if (!result)
376                                result = bscreen_default_idle(v_app,v_screen);
377                }
378                break;
379        default:
380                {
381                        result = bscreen_default_event(v_app,v_screen,p_event);
382                }
383                break;
384        }
385        return result;
386}
387
388/*
389Summary:
390        Draw the guide entry
391        .
392*/
393
394static void draw_guide_entry(bapp_t *p_app, bscreen_t *p_screen, guide_state_t *p_gs,
395                                                         int idx, chm_info_t *p_info, bool selected)
396{
397        int x,y,num_chars,w,h,str_y,l_idx;
398        int bkgnd_color = eCOLOR_MED_BLUE;
399        int offset = 4;
400        int guide_width;
401        l_idx = idx;
402        vch_t vch;
403        st_t st;
404        freq_t freq;
405
406        if (!ch_map_get_current(bapp_cur_ch_map(p_app),&vch,&st,&freq))
407        {
408                BDBG_MSG(("Invalid current channel or map.\n"));
409                return;
410        }
411
412        if (p_app->settings.ch_map.vch_map.num_vch == 0)
413                return;
414
415        /* alternate medium and lt blue background */
416        bkgnd_color = ((l_idx % 2) ? eCOLOR_MED_BLUE : eCOLOR_LT_BLUE);
417        bgfx_fill_rect(&p_app->surf,eSCREEN_ACTION_SAFE_X+offset,eSCREEN_GUIDE_Y_OFF + (eSCREEN_GUIDE_HEIGHT * (l_idx % MAX_GUIDE_ENTRIES)),
418                                   eSCREEN_ACTION_SAFE_WIDTH - (2*offset), eSCREEN_GUIDE_HEIGHT,bkgnd_color);
419
420        /* String for channel column */
421        num_chars = snprintf(p_gs->ch_num_str,24,"%d", 
422                                                 p_app->settings.ch_map.vch_map.vch[idx].ch_num/*,
423                                                 p_app->settings.ch_map.vch_map.vch[idx].minor*/);
424
425        num_chars = c_to_uni_str(p_gs->ch_num_str,p_app->tmp_str,num_chars);
426        bgfx_string_info(p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
427                                         (const unsigned long *)p_app->tmp_str,num_chars,&w,&h);
428
429        /* draw channel number column */
430        if ( l_idx >= MAX_GUIDE_ENTRIES)
431                l_idx = (l_idx % MAX_GUIDE_ENTRIES);
432        x = eSCREEN_GUIDE_X;
433        y = eSCREEN_GUIDE_Y_OFF + (eSCREEN_GUIDE_HEIGHT * l_idx);
434
435        str_y = y + (eSCREEN_GUIDE_HEIGHT - h)/2;
436        guide_text_box(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
437                                   x, str_y, eSCREEN_GUIDE_CH_WIDTH, eSCREEN_GUIDE_HEIGHT, 
438                                   p_app->tmp_str, num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eSCREEN_GUIDE_SPACING);
439
440        /* String for channel short name column */
441        num_chars = MAX_CH_NAME_CHARS;
442        num_chars = c_to_uni_str(st.name,p_app->tmp_str,num_chars);
443        if (num_chars == 0)
444        {
445                num_chars = MAX_CH_NAME_CHARS;
446                bscreen_get_string(p_app->lang,eTEXT_NA_GUIDE_CH, p_app->tmp_str, &num_chars);
447        }
448        /* draw channel short name column */
449        x = eSCREEN_GUIDE_CH_NAME_X;
450        bgfx_fill_rect(&p_app->surf,x, y, eSCREEN_GUIDE_CALLSIGN_WIDTH,eSCREEN_GUIDE_HEIGHT,bkgnd_color);
451        guide_text_box(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
452                                   x, str_y, eSCREEN_GUIDE_CALLSIGN_WIDTH, eSCREEN_GUIDE_HEIGHT, 
453                                   p_app->tmp_str, num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eSCREEN_GUIDE_SPACING);
454
455
456        /* String channel name column */
457        if (p_info)
458                num_chars = c_to_uni_str(p_info->eit_info[EIT_CURRENT].prog_title,p_app->tmp_str,MAX_TITLE_CHARS);
459        else
460                num_chars = 0;
461
462        if (num_chars == 0)
463        {
464/*        num_chars = snprintf(p_gs->ch_num_str,31,"Channel - %d.%d", */
465/*                 p_app->settings.ch_map.vch_map.vch[idx].major,*/
466/*                 p_app->settings.ch_map.vch_map.vch[idx].minor);*/
467/*        num_chars = c_to_uni_str(p_gs->ch_num_str,p_app->tmp_str,num_chars);*/
468
469                num_chars = SCREEN_MAX_STR_WIDTH;
470                bscreen_get_string(p_app->lang,eTEXT_NO_GUIDE_DATA, p_app->tmp_str, &num_chars);
471        }
472
473        x = eSCREEN_GUIDE_CUR_X;
474        guide_width = eSCREEN_GUIDE_NAME_WIDTH;
475
476        bgfx_fill_rect(&p_app->surf,x-1, y, guide_width + 2,eSCREEN_GUIDE_HEIGHT,bkgnd_color);
477        if (selected && (p_gs->column == 1))
478        {
479                bbutton_t button;
480                button.text_id = eTEXT_MAX;
481                button.desc_text_id = eTEXT_MAX;
482                button.type = eBUTTON_MENU;
483                button.x = x-offset;
484                button.y = y;
485                button.width = guide_width+offset;
486                button.height = eSCREEN_GUIDE_HEIGHT;
487
488                bscreen_draw_button_str(p_app,&button,selected,0,p_app->tmp_str,
489                                                                num_chars,NULL,0,eFONT_SIZE_SMALL,0);
490        }
491        else
492        {
493                /* draw channel name column */
494                guide_text_box(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
495                                           x, str_y, guide_width, eSCREEN_GUIDE_HEIGHT, 
496                                           p_app->tmp_str, num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eSCREEN_GUIDE_SPACING);
497        }
498
499        /* String for current column */
500        if (p_info)
501                num_chars = c_to_uni_str(p_info->eit_info[EIT_NEXT].prog_title,p_app->tmp_str,MAX_TITLE_CHARS);
502        else
503                num_chars = 0;
504
505        if (num_chars == 0)
506        {
507                num_chars = SCREEN_MAX_STR_WIDTH;
508                bscreen_get_string(p_app->lang,eTEXT_NO_GUIDE_DATA, p_app->tmp_str, &num_chars);
509        }
510        /* draw channel column */
511        x = eSCREEN_GUIDE_NEXT_X;
512        bgfx_fill_rect(&p_app->surf,x, y, guide_width,eSCREEN_GUIDE_HEIGHT,bkgnd_color);
513        guide_text_box(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
514                                   x, str_y, guide_width, eSCREEN_GUIDE_HEIGHT, 
515                                   p_app->tmp_str, num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eSCREEN_GUIDE_SPACING);
516}
517
518/*
519Summary:
520        Get the guide info for this entry.
521*/
522static chm_info_t* screen_guide_get_info(bapp_t *p_app, int idx)
523{
524        chm_info_t          *p_info; 
525#ifdef CONFIG_DVB
526        int i, eit_cnt;
527        eit_t eit[MAX_EIT_NUM];
528        vch_t vch;
529        st_t st;
530        freq_t freq;
531
532        BKNI_Memset(p_app->tmp_info.eit_info, 0, 2*sizeof(chm_eit_t));
533
534        if (!ch_map_get_current(bapp_cur_ch_map(p_app),&vch,&st,&freq))
535                return &p_app->tmp_info;
536       
537        dvb_get_current_event(vch, &eit_cnt, eit);
538        for (i=0; i<eit_cnt; i++) {
539                p_app->tmp_info.eit_info[i].start_time = eit[i].start_time;
540                p_app->tmp_info.eit_info[i].length = eit[i].duration;
541                p_app->tmp_info.eit_info[i].event_id = eit[i].event_id;
542                if ((eit[i].event_name[0]>0) && (eit[i].event_name[0]<0x20))
543                        BKNI_Memcpy(p_app->tmp_info.eit_info[i].prog_title, &eit[i].event_name[1], strlen(eit[i].event_name)-1);
544                else if (eit[i].event_name[0]>0) 
545                        BKNI_Memcpy(p_app->tmp_info.eit_info[i].prog_title, &eit[i].event_name, strlen(eit[i].event_name));
546                if ((eit[i].event_text[0]>0) && (eit[i].event_text[0]<0x20))
547                        BKNI_Memcpy(p_app->tmp_info.eit_info[i].prog_desc, &eit[i].event_text[1], strlen(eit[i].event_text)-1);
548                else if (eit[i].event_text[0]>0)
549                        BKNI_Memcpy(p_app->tmp_info.eit_info[i].prog_desc, eit[i].event_text, strlen(eit[i].event_text));
550        }
551#endif
552        p_info = &p_app->tmp_info;
553        return p_info;
554}
555
556/*
557Summary:
558        Guide screen drawing function
559        .
560*/
561void bscreen_guide_draw(void *v_app, void *v_screen)
562{
563        bapp_t *p_app = (bapp_t*)v_app;
564        bscreen_t *p_screen = (bscreen_t*)v_screen;
565        guide_state_t *p_gs;
566        unsigned int num_chars;
567        chm_info_t          *p_info;
568        int idx;
569
570        p_gs = (guide_state_t*)p_screen->local_state;
571        BDBG_ASSERT(p_gs);
572
573        bscreen_draw_background(v_app, &p_app->surf, p_screen->top_banner_height);
574
575        /* draw title */
576        num_chars = SCREEN_MAX_STR_WIDTH;
577        bscreen_get_string(p_app->lang,p_screen->title_text_id, p_app->tmp_str, &num_chars);
578        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_LARGE],
579                                        eMENU_TITLE_TEXT_X, eMENU_TITLE_TEXT_Y,
580                                        eMENU_TITLE_TEXT_WIDTH, eMENU_TITLE_TEXT_HEIGHT,  p_app->tmp_str,
581                                        num_chars, eCOLOR_MED_YELLOW,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eSCREEN_GUIDE_SPACING);
582
583        /* draw guide data update progress */
584        if (p_gs->update_progress < 100)
585        {
586                int num_chars = SCREEN_MAX_STR_WIDTH;
587                int w = 0;
588                int h = 0;
589
590                /* draw progress text */
591                bscreen_get_string(p_app->lang,eTEXT_GUIDE_DL_PROGRESS, p_app->tmp_str, &num_chars);
592                bgfx_string_info(p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],(const unsigned long *)p_app->tmp_str,num_chars,&w,&h);
593                text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
594                                                ePROGRESS_GUIDE_X - w - 7, ePROGRESS_GUIDE_TEXT_Y,
595                                                w + 3, ePROGRESS_GUIDE_TEXT_HEIGHT,  p_app->tmp_str,
596                                                num_chars, eCOLOR_MED_YELLOW,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,100);
597
598                bscreen_draw_progress(v_app, ePROGRESS_GUIDE_X, ePROGRESS_GUIDE_Y, ePROGRESS_GUIDE_WIDTH, ePROGRESS_GUIDE_HEIGHT, 
599                                                          eBUTTON_VOL_PROGRESS_BORDER, eCOLOR_WHITE, eCOLOR_DRK_BLUE, p_gs->update_progress, 100);
600        }
601        else
602        {
603                bgfx_fill_rect(&p_app->surf,ePROGRESS_GUIDE_TEXT_X,ePROGRESS_GUIDE_Y,
604                                           ePROGRESS_GUIDE_TEXT_WIDTH+ePROGRESS_GUIDE_WIDTH,ePROGRESS_GUIDE_HEIGHT,eCOLOR_LT_BLUE);
605        }
606
607        /* draw column header bar */
608        bgfx_fill_rect(&p_app->surf,eSCREEN_ACTION_SAFE_X+4,
609                                   eMENU_TITLE_TEXT_Y + eMENU_TITLE_TEXT_HEIGHT + 2,
610                                   eSCREEN_ACTION_SAFE_WIDTH-8,eINFO_AREA_HEIGHT - 6,eCOLOR_DRK_BLUE);
611
612        /* draw column header */
613        num_chars = SCREEN_MAX_STR_WIDTH;
614        bscreen_get_string(p_app->lang,eTEXT_GUIDE_HEADER, p_app->tmp_str, &num_chars);
615        text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
616                                        eSCREEN_GUIDE_X, eMENU_TITLE_TEXT_Y + eMENU_TITLE_TEXT_HEIGHT + 6 ,
617                                        eWIDTH, eINFO_AREA_HEIGHT,  p_app->tmp_str,
618                                        num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eSCREEN_GUIDE_SPACING);
619
620        if (p_app->settings.ch_map.vch_map.num_vch > 0)
621        {
622                unsigned short cur_ch;
623                vch_t vch;
624                st_t    st;
625                freq_t freq;
626                ch_map_t *p_ch_map = bapp_cur_ch_map(p_app);
627
628                ch_map_get_current(p_ch_map,&vch,&st,&freq);
629                cur_ch = vch.ch_num;
630                p_ch_map->cur_ch = p_gs->offset;
631                /* Draw the guide entries */
632                for (idx = p_gs->offset; 
633                        idx < GUIDE_MIN(p_app->settings.ch_map.vch_map.num_vch,
634                                                        (p_gs->offset + MAX_GUIDE_ENTRIES)); ++idx)
635                {
636                        p_ch_map->cur_ch = idx;
637                        p_info = screen_guide_get_info(p_app,idx);
638                        draw_guide_entry(p_app,p_screen,p_gs, idx,p_info, 
639                                                         (idx == p_gs->selection) ? true : false);
640                }
641                ch_map_set_ch(p_ch_map,cur_ch);
642        }
643        else
644        {
645                int w = 0;
646                int h = 0;
647                /* No channels in channel map so show "No Programs Available" */
648                num_chars = SCREEN_MAX_STR_WIDTH;
649                bscreen_get_string(p_app->lang,eTEXT_NO_GUIDE_DATA, p_app->tmp_str, &num_chars);
650                bgfx_string_info(p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],(const unsigned long *)p_app->tmp_str,num_chars,&w,&h);
651                text_box_shadow(&p_app->surf, p_app->p_font[p_app->lang][eFONT_SIZE_SMALL],
652                                                eSCREEN_GUIDE_X+((eWIDTH-(2*eSCREEN_GUIDE_X))/2)-(w/2), 
653                                                eSCREEN_ACTION_SAFE_Y + eSCREEN_ACTION_SAFE_HEIGHT/2,
654                                                w+5, h, p_app->tmp_str,
655                                                num_chars, eCOLOR_WHITE,eCOLOR_BLACK, eMENU_TEXT_DROPSHADOW ,eSCREEN_GUIDE_SPACING);
656        }
657
658        draw_navigation_hints(v_app, v_screen);
659}
660
661
Note: See TracBrowser for help on using the repository browser.