source: svn/trunk/zasc/app_c/DST_WinMainMenu.c @ 29

Last change on this file since 29 was 29, checked in by phkim, 10 years ago
  1. phkim
  2. app
  3. 변경 내용
    • 채널 편집 기능 활성화
    • 프로그램ID, RF 기능을 Major, Minor 로 변경
    • Skip_list 저장 위치를 TVCT_SUB 아래로 변경
    • define 이름 변경 -> SUPPORT_CHANNEL_EDIT
File size: 20.6 KB
Line 
1#include "DST_Window.h"
2#include "DST_WinManager.h"
3#include "DST_CommonAPI.h"
4#include "DST_DataStrings.h"
5#include "DST_UserInterface.h"
6#include "DST_CCTask.h"
7#include "DST_ChannelTune.h"
8#include "DST_DB.h"
9#include "DST_OSDImage.h"
10#include "DST_SignalMonitor.h"
11#include "DST_EEPROM.h"
12
13
14typedef struct 
15{
16        MainMenuLists menu;
17        bool bEnable;
18}MAIN_MENU;
19
20static MAIN_MENU CMainMenu_tv_menu[] = {
21        {       MN_AUTO_SCAN,   true    },
22        {       MN_MANUAL_SCAN, true    },
23        {       MN_SIGNAL_METER,        false   },
24        {       MN_AV_DISPLAY_MODE,     true    },
25        {       MN_AV_AUDIO_PREF,       true    },
26#if SUPPORT_CHANNEL_EDIT
27        {       MN_CHANNEL_EDIT,        true    },
28#endif
29        {       MN_AV_VI,       true    },
30        {       MN_CC_DISPLAY,  true    },
31        {       MN_SLEEP_TIMER, false   },
32        {       MN_AV_PREFERRED_CONN,   true    },
33        {       MN_FACTORY_RESET,       true    },
34        {       MN_STB_INFO,    true    },
35        { MN_MAX_NUM, false}
36};
37
38
39//class CZASMainMenu: public CWindow
40//{
41//private:
42
43        static DS_U16 CMainMenu_g_nPos;
44        static DS_U16 CMainMenu_g_nTop;
45        static DS_U16 CMainMenu_mainSelect;
46        static DS_U16 CMainMenu_mainListNum;
47        static DS_U16 CMainMenu_mainItemNum;
48       
49
50        static DS_U16 CMainMenu_cursor[20];
51        static DS_U16 CMainMenu_select[20];
52        static DS_U16 CMainMenu_userSavedValue[20];
53
54        static DS_U16 CMainMenu_listNum[20];
55        static DS_U16 CMainMenu_itemNum[20];
56        static DS_U16 CMainMenu_SubTop[20];
57
58        static int  CMainMenu_MenuIdx;
59       
60        void CMainMenu_InitValues();
61        void CMainMenu_SetSize(CWindow *this);
62        int CMainMenu_GetCount();
63        void CMainMenu_GetValuse(DS_U16 menu, DS_U16 *value);
64
65#if SUPPORT_CHANNEL_EDIT
66        void CMainMenu_ChannelEdit_Change_Enable();
67#endif
68
69//public:
70//      CZASMainMenu(SWinEventMsg event):CWindow(event)
71        void CMainMenu_Constructor(CWindow *this, SWinEventMsg event)
72        {
73                CMainMenu_InitValues();
74                CMainMenu_SetSize(this);
75                this->SetTimeOut(this, 100);
76               
77        }
78
79//      virtual ~CZASMainMenu()
80        void CMainMenu_Desnstructor(CWindow *this)
81        {
82                if(DST_GetWin(WIN_FACTORY_RESET)) DST_CreateWin(WIN_MAIN_MENU, 0, 0, 0, 0, 0);
83                if(DST_GetWin(WIN_FACTORY_RESET_ASK)) DST_CreateWin(WIN_MAIN_MENU, 0, 0, 0, 0, 0);
84                if(DST_g_SignalState == SM_AUDIO_ONLY) DST_CreateWin(WIN_CHANNEL_BANNER, WIN_NULL, BANNER_NORMAL ,0, 0, 0);
85        }
86
87        bool CMainMenu_getTR_AspectRatio()
88        {
89                DS_U16 w = 0, h = 0, fps = 0;
90                bool bWide = false, bInterlace = false;
91                DST_GetVideoSize(&w, &h, &fps, &bInterlace, &bWide);
92               
93                return (!bWide);
94        }
95
96        DS_U8 CMainMenu_getAspectRatioIndex()
97        {
98                if(CMainMenu_getTR_AspectRatio()) return 1;
99                else return 3;
100        }
101
102        MainMenuLists CMainMenu_Index2MenuLists(int index)
103        {
104                int nPos = -1;
105                int i = 0;
106                MainMenuLists menu = MN_AUTO_SCAN;
107                if (index < CMainMenu_mainItemNum)
108                {
109                        for (i = 0; i < 20; i++)
110                        {
111                               
112                                if (CMainMenu_tv_menu[i].bEnable) nPos++;
113                                if (nPos != index) continue;
114                                menu = CMainMenu_tv_menu[i].menu;
115                                break;
116                        }
117                }
118                return menu;
119        }
120       
121        DS_U16 CMainMenu_GetSubCount(DS_U16 menu)
122        {
123                switch(CMainMenu_Index2MenuLists(menu))
124                {
125                        case MN_AUTO_SCAN: return 1;
126                        case MN_MANUAL_SCAN: return 1;
127                        case MN_SIGNAL_METER: return 1;
128                        case MN_AV_DISPLAY_MODE: return CMainMenu_getAspectRatioIndex();
129                        case MN_AV_AUDIO_PREF: return 2;
130#if SUPPORT_CHANNEL_EDIT
131                        case MN_CHANNEL_EDIT: return 1;
132#endif
133                        case MN_AV_VI: return 2;
134                        case MN_CC_DISPLAY: return 2;
135                        case MN_SLEEP_TIMER: return SLEEP_TIMER_MAX_NUM;
136                        case MN_AV_PREFERRED_CONN: return PREFERRED_CONN_MAX_NUM;
137                        case MN_FACTORY_RESET: return 1;
138                        case MN_STB_INFO: return 1;
139                        default: break;
140                }
141                return 0;
142        }
143
144        void CMainMenu_InitSubValues()
145        {
146                int i = 0;
147                for(i = 0 ; i < CMainMenu_mainItemNum ; i++)
148                {
149                        CMainMenu_cursor[i]             =0;
150                        CMainMenu_select[i]             =0;
151                        CMainMenu_userSavedValue[i] =0;
152
153                        CMainMenu_listNum[i] = 0;
154                        CMainMenu_itemNum[i] = 0;
155                        CMainMenu_SubTop[i] = 0;
156               
157                        CMainMenu_listNum[i] = 6;
158                        CMainMenu_itemNum[i]  = CMainMenu_GetSubCount(i);
159                        if (CMainMenu_itemNum[i] < CMainMenu_listNum[i]) CMainMenu_listNum[i] = CMainMenu_itemNum[i];
160                        CMainMenu_GetValuse(i, &CMainMenu_select[i]);
161                        CMainMenu_userSavedValue[i] = CMainMenu_select[i];
162                        InitItemValues(CMainMenu_listNum[i], CMainMenu_select[i], &CMainMenu_SubTop[i], &CMainMenu_cursor[i]);
163                }
164        }
165       
166#if SUPPORT_CHANNEL_EDIT
167        void CMainMenu_ChannelEdit_Change_Enable()
168        {
169                int i = 0;
170                for (i = 0; i < MN_MAX_NUM; i++)
171                {
172                        if (CMainMenu_tv_menu[i].menu == MN_CHANNEL_EDIT)
173                        {
174                                CMainMenu_tv_menu[i].bEnable = DST_g_ChannelEdit;
175                                break;
176                        }
177                }
178        }
179#endif
180
181
182        void CMainMenu_InitValues()
183        {
184                CMainMenu_MenuIdx = 0;/*DST_UI_GetSource();*/
185
186#if SUPPORT_CHANNEL_EDIT
187                CMainMenu_ChannelEdit_Change_Enable();
188#endif
189
190                CMainMenu_mainItemNum = CMainMenu_GetCount();
191                CMainMenu_g_nTop = MenuTop[CMainMenu_MenuIdx];
192                CMainMenu_g_nPos = MenuPos[CMainMenu_MenuIdx];
193                CMainMenu_mainSelect = MenuSelect[CMainMenu_MenuIdx];
194                CMainMenu_mainListNum = 6;
195                if (CMainMenu_mainItemNum < CMainMenu_mainListNum) CMainMenu_mainListNum = CMainMenu_mainItemNum;
196                CMainMenu_InitSubValues();
197               
198        }
199
200        int CMainMenu_GetCount()
201        {
202                int MenuCount = 0;
203                int i = 0;
204                for (i = 0; i < 20; i++)
205                {
206                        if (CMainMenu_tv_menu[i].menu == MN_MAX_NUM) break;
207                        if (CMainMenu_tv_menu[i].bEnable) MenuCount++;
208                }
209                return MenuCount;
210        }
211       
212        void CMainMenu_GetValuse(DS_U16 menu, DS_U16 *value)
213        {
214                switch(CMainMenu_Index2MenuLists(menu))
215                {
216                        case MN_AUTO_SCAN: *value = 0; break;
217                        case MN_MANUAL_SCAN: *value = 0; break;
218                        case MN_SIGNAL_METER: *value = 0; break;
219                        case MN_AV_DISPLAY_MODE: *value = DST_UI_GetAspect(); break;
220                        case MN_AV_AUDIO_PREF: *value = DST_UI_GetMTS(); break;
221#if SUPPORT_CHANNEL_EDIT
222                        case MN_CHANNEL_EDIT: *value = 0; break;
223#endif
224                        case MN_AV_VI: *value = DST_UI_GetVI(); break;
225                        case MN_CC_DISPLAY: *value = DST_EEPROM_GetCC(); break;
226                        case MN_SLEEP_TIMER: *value = DST_GetSleepTimer(); break;
227                        case MN_AV_PREFERRED_CONN: *value = DST_UI_GetCh34(); break;
228                        case MN_FACTORY_RESET: *value = 0; break;
229                        case MN_STB_INFO: *value = 0; break;
230                        default: break;
231                }
232        }
233
234        void CMainMenu_SetValuse(DS_U16 menu, DS_U16 value)
235        {
236                switch(CMainMenu_Index2MenuLists(menu))
237                {
238                        case MN_AUTO_SCAN:break;
239                        case MN_MANUAL_SCAN: break;
240                        case MN_SIGNAL_METER: break;
241                        case MN_AV_DISPLAY_MODE: DST_UI_SetAspect(value); break;
242                        case MN_AV_AUDIO_PREF: DST_UI_SetMTS(value); break;
243#if SUPPORT_CHANNEL_EDIT
244                        case MN_CHANNEL_EDIT: break;
245#endif
246                        case MN_AV_VI: DST_UI_SetVI(value); break;
247                        case MN_CC_DISPLAY: DST_UI_SetCloseCaption(value); break;
248                        case MN_SLEEP_TIMER:
249                                if(0 < value && value < 5 )DST_g_sleepTimercheckTime = DST_OS_GetTickCount(); 
250                                DST_SetSleepTimer(value); 
251                                break; 
252                        case MN_AV_PREFERRED_CONN: DST_UI_SetCh34(value); break;
253                        case MN_FACTORY_RESET: break;
254                        case MN_STB_INFO: break;
255                        default: break;
256                }
257        }
258       
259
260       
261        DS_U16* CMainMenu_GetString(int nPos)
262        {
263                switch (CMainMenu_Index2MenuLists(nPos))
264                {
265                        case MN_AUTO_SCAN: return pz_Sub_AutoScan[OSD_Lang]; break;
266                        case MN_MANUAL_SCAN: return pz_ManualSearch[OSD_Lang]; break;
267                        case MN_SIGNAL_METER: return pz_Sub_SignalMeter[OSD_Lang]; break;
268                        case MN_AV_DISPLAY_MODE: return pz_Sub_DisplayMode[OSD_Lang]; break;
269                        case MN_AV_AUDIO_PREF: return pz_Sub_AudioPref[OSD_Lang]; break;
270#if SUPPORT_CHANNEL_EDIT
271                        case MN_CHANNEL_EDIT: return pz_Sub_ChannelEdit_E1[OSD_Lang]; break;
272#endif
273                        case MN_AV_VI: return pz_Sub_DVS[OSD_Lang]; break;
274                        case MN_CC_DISPLAY: return pz_Sub_CC[OSD_Lang]; break;
275                        case MN_SLEEP_TIMER: return pz_Sub_SleepTime[OSD_Lang]; break;
276                        case MN_AV_PREFERRED_CONN: return pz_Sub_PrefConn[OSD_Lang]; break;
277                        case MN_FACTORY_RESET: return pz_Sub_Factory[OSD_Lang]; break;
278                        case MN_STB_INFO: return pz_Sub_STB_Info[OSD_Lang];
279                        default: break;
280                }
281                return 0;
282        }
283
284        DS_U16* CMainMenu_GetSubString(int itemIdx, int nPos)
285        {
286                static DS_U16 strText[32];
287                unsigned i = 0;
288                // ±âº»°ª..À̰ªÀÌ ¶á´Ù¸é ¹ö±×
289                for (i = 0; i < 40; i++)
290                {
291                        strText[i] = pz_Unknown[OSD_Lang][i];
292                        if (strText[i] == 0) break;
293                }
294
295                switch (CMainMenu_Index2MenuLists(itemIdx))
296                {
297
298                        case MN_AV_DISPLAY_MODE:
299                                switch(nPos)
300                                {
301                                        case DISPLAY_MODE_WIDE: return pz_Wide[OSD_Lang]; break;
302                                        case DISPLAY_MODE_NORMAL: return pz_Normal[OSD_Lang]; break;
303                                        case DISPLAY_MODE_ZOOM: return pz_Zoom[OSD_Lang]; break;
304                                        default: break;
305                                }
306                                break;
307
308                        case MN_AV_AUDIO_PREF:
309                                switch (nPos)
310                                {
311                                        case  0: return pz_MTS_Main[OSD_Lang];
312                                        case  1: return pz_MTS_Sub[OSD_Lang];
313                                        default: break;
314                                }
315                                break;
316                               
317                        case MN_AV_VI:
318                                switch (nPos)
319                                {
320                                        case  0: return pz_VI_Off[OSD_Lang];
321                                        case  1: return pz_VI_On[OSD_Lang];
322                                        default: break;
323
324                                }
325                                break;
326                               
327                        case MN_CC_DISPLAY:
328                                switch (nPos)
329                                {
330                                        case  0: return pz_Off[OSD_Lang]; break;
331                                        case  1: return pz_On[OSD_Lang]; break;
332                                        default: break;
333                                }
334                                break;
335                               
336                        case MN_SLEEP_TIMER:
337                                switch(nPos)
338                                {
339                                        case SLEEP_TIMER_OFF: return pz_Off[OSD_Lang]; break;
340                                        case SLEEP_TIMER_15M: return pz_Sub_SleepTime_15[OSD_Lang]; break;
341                                        case SLEEP_TIMER_30M: return pz_Sub_SleepTime_30[OSD_Lang]; break;
342                                        case SLEEP_TIMER_60M: return pz_Sub_SleepTime_60[OSD_Lang]; break;
343                                        case SLEEP_TIMER_120M: return pz_Sub_SleepTime_120[OSD_Lang]; break;
344                                        default: break;
345                                }
346                                break;
347                               
348                        case MN_AV_PREFERRED_CONN:
349                                switch(nPos)
350                                {
351                                        case PREFERRED_CONN_LINE_OUT: return pz_Sub_LineOut[OSD_Lang]; break;
352                                        case PREFERRED_CONN_CH34: return pz_Sub_CH34[OSD_Lang]; break;
353                                        default: break;
354                                }
355                                break;
356                               
357                        case MN_AUTO_SCAN:
358                        case MN_MANUAL_SCAN:
359                        case MN_SIGNAL_METER:
360                        case MN_FACTORY_RESET:
361                        case MN_STB_INFO:
362#if SUPPORT_CHANNEL_EDIT
363                        case MN_CHANNEL_EDIT:
364#endif
365                                switch (nPos)
366                                {
367                                        case  0: return pz_Empty[OSD_Lang];
368                                }
369                                break;
370                        default:
371                                break;
372                }
373                return 0;
374        }
375
376        void CMainMenu_SetSize(CWindow *this)
377        {
378                this->rect.w = DST_GetImageWidth(back);
379                this->rect.h = DST_GetImageHeight(back);
380                this->rect.x = (DST_GetScreenWidth() - this->rect.w)/2;
381                this->rect.y = ((DST_GetScreenHeight() - this->rect.h)/2)+10;
382        }
383
384//      virtual void Focus(bool bVal)
385        void CMainMenu_Focus(CWindow *this, bool bVal)
386        {
387                this->RegisterKey(this, VK_MENU, bVal, 0, 0);
388                this->RegisterKey(this, VK_CANCEL, bVal, 0, 0);
389                this->RegisterKey(this, VK_LEFT, bVal, 0, 0);
390                this->RegisterKey(this, VK_RIGHT, bVal, 0, 0);
391                this->RegisterKey(this, VK_UP, bVal, 0, 0);
392                this->RegisterKey(this, VK_DN, bVal, 0, 0);
393                this->RegisterKey(this, VK_OK, bVal, 0, 0);
394                this->RegisterKey(this, VK_CH_UP, bVal, 0, 0);
395                this->RegisterKey(this, VK_CH_DN, bVal, 0, 0);
396                this->RegisterKey(this, VK_PREV, bVal, 0, 0);
397                this->RegisterKey(this, VK_PREV_CH, bVal, 0, 0);
398                this->RegisterKey(this, VK_PREV_MENU, bVal, 0, 0);
399        }
400       
401//      virtual void Show(WinID id)
402        void CMainMenu_ShowWindow(CWindow *this, WinID id)
403        {
404                switch(id)
405                {
406                        case WIN_DEBUG_SQL:
407                        case WIN_DEBUG_SQL_SUB:
408                        case WIN_ENGINEER_MODE:
409                        case WIN_FREQUENCY_SETTING:     
410                        case WIN_EWS:
411                        case WIN_DIRECT_TUNE:
412                        case WIN_CLOSED_CAPTION_HOT:
413                        case WIN_AUDIO_HOT:
414                        case WIN_DISPLAY_MODE_HOT:
415                        case WIN_FACTORY_RESET:
416                        case WIN_FACTORY_RESET_ASK:
417                        case WIN_INFOR_BANNER:
418                        case WIN_POWER_DOWN_CAUTION:
419                        case WIN_AUTO_SEARCH:
420                        case WIN_MANUAL_SEARCH:
421                        case WIN_CHANNEL_LIST:
422                        case WIN_PROGRAM_GUIDE:
423                        case WIN_AGE_RATING:
424                                this->Close(this);
425                                break;
426                        default:
427                                break;         
428                }
429        }
430       
431         void CMainMenu_DrawScrollBar(CWindow *this, int x, int y, int h, int total_count, int page_count, int page_start)
432         {
433                 if (total_count <= page_count) return;
434                 // ¼±Åà ±×¸®±â
435                 int nTop = DST_GetImageHeight(scroll_p_1);
436                 int nBot = DST_GetImageHeight(scroll_p_3);
437                 int nMinHeight = nTop + nBot + 1; // ÃÖ¼Ò ³ôÀÌ
438                 int nHeight = (h * page_count) / total_count; // ³ôÀÌ
439                 if (nHeight < nMinHeight) nHeight = nMinHeight; 
440                 int nStart = (h * page_start) / total_count;
441                 if (nStart + nHeight > h) nStart = h - nHeight; // ¾Æ·¡·Î »ßÁ®³ª¿À´Â°Í ¹æÁö
442                 if (total_count == page_start + page_count) nStart = h - nHeight; // ¾Æ·¡ ÇÑÇȼ¿ »ù ¹æÁö
443                 int nMid = nHeight - nTop - nBot;       
444                 this->DrawImage(this, x, y+nStart, scroll_p_1, true);
445                 int yy = 0;
446                 for (yy = 0; yy < nMid; yy++)
447                 {
448                         this->DrawImage(this, x,y+yy+nStart+nTop,scroll_p_2,false);
449                 }
450                 this->DrawImage(this, x,y+nStart+nTop+nMid,scroll_p_3,true);
451         }
452
453         //ȯ°æ¼³Á¤ ¸Þ´º ŸÀÌÆ² ±×¸®±â
454        void CMainMenu_DrawTitle(CWindow *this)
455        {
456                this->setFontStyle(this, 22,0xFFE1E1E1,ALIGN_MIDDLE,ALIGN_CENTER);
457                this->DrawTextUni(this, 323-313, 82-78, 312, 42, pz_Empty[OSD_Lang], &(this->font));
458        }
459
460         //³×ºñ°ÔÀÌ¼Ç ±×¸®±â
461        void CMainMenu_DrawNavigation(CWindow *this)
462        {
463                this->setFontStyle(this, 20,0xFF7B7B7B,this->FontGetVerAlign(this),ALIGN_LEFT);
464
465                DS_U16  final[20];
466
467                this->DrawImage(this, 433-313,426-78, arrow_ud, false);
468                str2uni(final, (char *)": ");
469                strcpy16(&final[strlen16(final)], pz_Move[OSD_Lang]);
470                this->DrawTextUni(this, 454-313, 428-78, 79, 22, final, &(this->font));
471
472                this->DrawImage(this, 545-313,426-77,arrow_lr, false);
473                str2uni(final, (char *)": ");
474                strcpy16(&final[strlen16(final)], pz_Select[OSD_Lang]);
475                this->DrawTextUni(this,569-313, 428-78, 79, 22, final, &(this->font));
476        }
477
478         //È­¸é¿¡ ³ªÅ¸³ª´Â ¸ÞÀÎÇ׸ñ ±×¸²
479        void CMainMenu_DrawCategory(CWindow *this, int index)
480        {
481                int y_Constant=157;
482                int y_Multiplier=42;
483                int width=163;
484                if(MenuPos[CMainMenu_MenuIdx] == index)
485                        this->setFontStyle(this, 21,0xFFFFFFFF,this->FontGetVerAlign(this),ALIGN_LEFT);
486                else 
487                        this->setFontStyle(this, 21,0xFFC8C8C8,this->FontGetVerAlign(this),ALIGN_LEFT);
488
489                this->DrawTextUni(this, 344-313, (y_Constant-78)+index*y_Multiplier, width, 20, CMainMenu_GetString(index+CMainMenu_g_nTop), &(this->font));
490
491                if(MenuPos[CMainMenu_MenuIdx] == index)
492                {
493                        int i = 0;
494                        this->DrawImage(this, 333-313, (145-76)+index*y_Multiplier, hl_orange_l,true);
495                        for( i=0;i<255;i++)
496                        {
497                                this->DrawImage(this, (333-313)+15+i, (145-76)+index*y_Multiplier, hl_orange_mid, false);
498                        }
499                        this->DrawImage(this, (333-313)+270, (145-76)+index*y_Multiplier, hl_orange_r,true);
500
501                        this->DrawTextUni(this, 344-313, (y_Constant-78)+index*y_Multiplier, width, 20, CMainMenu_GetString(index+CMainMenu_g_nTop), &(this->font));   
502
503                        //Aspect Ratio°¡ Çϳª¹Û¿¡ ¼±ÅøøÇÒ°æ¿ì, ȤÀº ºñµð¿À°¡ Ç÷¹ÀÌ µÇÁö ¾Ê´Â °æ¿ì ´ÙÀ½À» ±×¸®Áö ¾ÊÀ½
504                        if(CMainMenu_Index2MenuLists(MenuSelect[CMainMenu_MenuIdx]) == MN_AV_DISPLAY_MODE)
505                        {
506                                if(CMainMenu_getAspectRatioIndex() == 1 || DST_IsVideoPlay() == false) return;
507                                       
508                        }
509                       
510                        this->DrawImage(this, 601-313,(160-76)+index*y_Multiplier,arrow_right,true);
511                        switch(CMainMenu_Index2MenuLists(MenuSelect[CMainMenu_MenuIdx]))
512                        {
513                                case MN_AUTO_SCAN:
514                                case MN_MANUAL_SCAN:
515                                case MN_SIGNAL_METER:
516                                case MN_FACTORY_RESET:
517                                case MN_STB_INFO:
518#if SUPPORT_CHANNEL_EDIT
519                                case MN_CHANNEL_EDIT:
520#endif
521                                        break;
522                                default:
523                                        this->DrawImage(this, 514-313,(160-76)+index*y_Multiplier,arrow_left,true);
524                                        break;
525                                               
526                        }
527                       
528                }
529        }
530         //È­¸é¿¡ ³ªÅ¸³ª´Â ¼¼ºÎÇ׸ñ ±×¸²
531        void CMainMenu_DrawItems(CWindow *this, int mainIndex,int subIndex)
532        {
533                int y_Constant=157;
534                int y_Multiplier=42;
535                int width=80;
536                int nFontSize=20;
537                if(MenuPos[CMainMenu_MenuIdx] == mainIndex)
538                        this->setFontStyle(this, 21,0xFFFFFFFF,this->FontGetVerAlign(this),ALIGN_CENTER);
539                else 
540                        this->setFontStyle(this, 21,0xFFF06E03,this->FontGetVerAlign(this),ALIGN_LEFT);
541                DS_U16* strText16 = CMainMenu_GetSubString(mainIndex+CMainMenu_g_nTop,subIndex);
542                int k = 0;
543                for (k = nFontSize; k > 10; k--)
544                {
545                        int nWidth = DST_GetTextWidthUni(strText16, k);
546                        if (nWidth > width) continue;
547                        nFontSize = k;
548                        break;
549                }
550                this->FontSetSize(this, nFontSize); 
551               
552                this->DrawTextUni(this, 522-313, (y_Constant-78)+mainIndex*y_Multiplier,        width, 20, strText16, &(this->font));
553               
554        }
555
556        void CMainMenu_DrawMenu(CWindow *this, int categoryIndex)
557        {
558                this->setFontStyle(this, 21,this->FontGetColor(this),ALIGN_MIDDLE,this->FontGetHorAlign(this));
559               
560                CMainMenu_DrawCategory(this, categoryIndex);
561                CMainMenu_DrawItems(this, categoryIndex,CMainMenu_userSavedValue[categoryIndex+CMainMenu_g_nTop]);
562        }
563
564        void CMainMenu_Draw(CWindow *this)
565        {
566                this->DrawImage(this,0,0, (DS_U8*)back,false);
567               
568                CMainMenu_DrawScrollBar(this, 622-313, 145-77, 42*CMainMenu_mainListNum-1, CMainMenu_mainItemNum, CMainMenu_mainListNum, CMainMenu_g_nTop);
569
570                int i = 0;
571                for(i=0;i<CMainMenu_mainListNum;i++)
572                        CMainMenu_DrawMenu(this, i);
573                CMainMenu_DrawNavigation(this);
574               
575        }
576
577        void CMainMenu_DrawSubMenu(CWindow *this, DS_U8 key)
578        {
579                switch(key)
580                {
581                        case VK_RIGHT:
582                        case VK_OK:
583                                switch(CMainMenu_Index2MenuLists(CMainMenu_mainSelect))
584                                {
585                                        case MN_AUTO_SCAN:
586                                                DST_CreateWin(WIN_AUTO_SEARCH, WIN_MAIN_MENU, 0, 0, 0, 0); 
587                                                this->Close(this);
588                                                break;
589                                        case MN_MANUAL_SCAN:
590                                                DST_CreateWin(WIN_MANUAL_SEARCH, WIN_MAIN_MENU,0 ,0 ,0 ,0);
591                                                this->Close(this);
592                                                break;
593                                        case MN_SIGNAL_METER:
594                                                DST_CreateWin(WIN_SIGNAL_METER, WIN_NULL,0,0,0,0);
595                                                this->Close(this);
596                                                break;
597                                        case MN_FACTORY_RESET:
598                                                DST_CreateWin(WIN_FACTORY_RESET_ASK, WIN_MAIN_MENU, 0, 0, 0, 0);
599                                                this->Close(this);
600                                                break;
601                                        case MN_STB_INFO:
602                                                DST_CreateWin(WIN_STB_INFO, WIN_NULL, 0, 0, 0, 0);
603                                                break;
604#if SUPPORT_CHANNEL_EDIT
605                                        case MN_CHANNEL_EDIT:
606                                                DST_CreateWin(WIN_CHANNEL_LIST, WIN_NULL, 0, 0, 0, 0);
607                                                break;
608#endif
609
610                                        default:
611                                                break;
612                                }
613                                break;
614                        default:
615                                break;
616                }
617               
618        }
619
620//      virtual void Show(void)
621        void CMainMenu_Show(CWindow *this)
622        {
623                CMainMenu_Draw(this);
624                this->DoFocus(this, true);
625        }
626
627//      virtual void OnMessage(SWinEventMsg event)
628        void CMainMenu_OnMessage(CWindow *this, SWinEventMsg event)
629        {
630                switch (event.cmd)
631                {
632                         //¸Þ´º°¡ ¶°ÀÖ´Â »óÅ¿¡¼­ ¹æ¼Û È­¸éºñÀ² ¼Ò½º°¡ º¯°æÀÌ µÇ¸é ÇØ´ç»çÇ× ¾÷µ¥ÀÌÆ®
633                        case WM_SOURCE_FORMAT_DONE:
634                                CMainMenu_InitSubValues(); //¸ðµå¿¡ ¸Â°Ô UI°ª º¯°æ
635                                DST_UI_SetAspect( DST_UI_GetAspect());//¹Ù²ï È­¸éºñÀ²·Î ¼¼ÆÃ
636                                CMainMenu_Draw(this);
637                                break;
638                }
639        }       
640//      virtual void KeyInput(DS_U8 key, bool /*bRepeat*/)
641        void CMainMenu_KeyInput(CWindow *this, DS_U8 key, bool bRepeat)
642        {
643                switch (key)
644                {
645                         //¿À¸¥ÂÊ ¿ÞÂÊÀ¸·Î ¹Ù·Î ¼±ÅÃ
646                        case VK_RIGHT:
647                        case VK_LEFT:
648                               
649                                if(key == VK_LEFT)
650                                        ItemDecrease(CMainMenu_itemNum[MenuSelect[CMainMenu_MenuIdx]], CMainMenu_itemNum[MenuSelect[CMainMenu_MenuIdx]], &CMainMenu_SubTop[MenuSelect[CMainMenu_MenuIdx]], &CMainMenu_select[MenuSelect[CMainMenu_MenuIdx]], &CMainMenu_cursor[MenuSelect[CMainMenu_MenuIdx]],1);
651                                else
652                                        ItemIncrease(CMainMenu_itemNum[MenuSelect[CMainMenu_MenuIdx]], CMainMenu_itemNum[MenuSelect[CMainMenu_MenuIdx]], &CMainMenu_SubTop[MenuSelect[CMainMenu_MenuIdx]], &CMainMenu_select[MenuSelect[CMainMenu_MenuIdx]], &CMainMenu_cursor[MenuSelect[CMainMenu_MenuIdx]],1);
653                               
654                                CMainMenu_userSavedValue[MenuSelect[CMainMenu_MenuIdx]] = CMainMenu_select[MenuSelect[CMainMenu_MenuIdx]];
655                                CMainMenu_SetValuse(MenuSelect[CMainMenu_MenuIdx], CMainMenu_select[MenuSelect[CMainMenu_MenuIdx]]);
656                                CMainMenu_InitSubValues();
657                               
658                                CMainMenu_Draw(this);
659                                CMainMenu_DrawSubMenu(this, key);
660                                break;
661
662                        case VK_UP:
663                        case VK_DN:
664                                if(key == VK_DN)
665                                        ItemIncrease(CMainMenu_mainItemNum, CMainMenu_mainListNum, &CMainMenu_g_nTop, &CMainMenu_mainSelect, &CMainMenu_g_nPos, 1);
666                                else
667                                        ItemDecrease(CMainMenu_mainItemNum, CMainMenu_mainListNum, &CMainMenu_g_nTop, &CMainMenu_mainSelect, &CMainMenu_g_nPos, 1);
668                                MenuTop[CMainMenu_MenuIdx] = CMainMenu_g_nTop;
669                                MenuPos[CMainMenu_MenuIdx] = CMainMenu_g_nPos;
670                                MenuSelect[CMainMenu_MenuIdx] = CMainMenu_mainSelect;
671                                CMainMenu_InitSubValues();
672                                CMainMenu_Draw(this);
673                                break;
674                               
675                        case VK_OK:
676                                CMainMenu_DrawSubMenu(this, key);
677                                break;
678                        case VK_CANCEL:
679                        case VK_MENU:
680                        case VK_PREV:
681                        case VK_PREV_CH:
682                        case VK_PREV_MENU:
683                                if(DST_UI_GetMute() && DST_GetWin(WIN_VOLUME_MUTE)==0) DST_CreateWin(WIN_VOLUME_MUTE, 0, 0, 0, 0, 0);
684                                this->Close(this);
685                                if(DST_g_SignalState == SM_AUDIO_ONLY) DST_CreateWin(WIN_CHANNEL_BANNER, WIN_NULL, BANNER_NORMAL ,0, 0, 0);
686                                break;
687
688                        default:
689                                break;
690                }
691        }
692//};
693
694void DST_CreateMainMenu(SWinEventMsg event)
695{
696        CWindow*pWin = NewCWindow(event);
697        pWin->Destructor = CMainMenu_Desnstructor;
698        pWin->OnMessage = CMainMenu_OnMessage; 
699        pWin->KeyInput = CMainMenu_KeyInput;
700        pWin->Focus = CMainMenu_Focus;
701        pWin->ShowWindow = CMainMenu_ShowWindow;
702        pWin->Show = CMainMenu_Show;
703        // »ý¼ºÀÚ È£Ãâ
704        CMainMenu_Constructor(pWin, event);
705        // À©µµ¿ì ¸Þ´ÏÀú¿¡ µî·Ï
706        DST_AddWin((WinID)(event.data[0]), pWin);
707}
708
Note: See TracBrowser for help on using the repository browser.