source: svn/zasc/app_c/DST_WinChannelBanner.c

Last change on this file was 76, checked in by megakiss, 10 years ago

1W 대기전력을 만족시키기 위하여 POWEROFF시 튜너를 Standby 상태로 함

File size: 26.5 KB
Line 
1#include "DST_WinManager.h"
2#include "DST_ChannelTune.h"
3
4#include "DST_DataStrings.h"
5#include "DST_OSDImage.h"
6#include "DST_UserInterface.h"
7#include "DST_ISDBT_ChannelTask.h"
8#include "DST_DB_Engine.h"
9#include "DST_DB.h"
10#include "DST_MemoryDB.h"
11
12#if 0
13____CChannelBannerWin___()
14#endif
15
16bool DST_IsTuneMode();
17
18static DS_U8* NumToImage(DS_U8 num)
19{
20        switch(num)
21        {
22                case 0: return DST_channelbanner_0_480;
23                case 1: return DST_channelbanner_1_480;
24                case 2: return DST_channelbanner_2_480;
25                case 3: return DST_channelbanner_3_480;
26                case 4: return DST_channelbanner_4_480;
27                case 5: return DST_channelbanner_5_480;
28                case 6: return DST_channelbanner_6_480;
29                case 7: return DST_channelbanner_7_480;
30                case 8: return DST_channelbanner_8_480;
31                case 9: return DST_channelbanner_9_480;
32        }
33        return DST_channelbanner_0_480;
34}
35
36static DS_U8* NumToImageSmall(DS_U8 num)
37{
38        switch(num)
39        {
40                case 0: return DST_channelbanner_0_s_480;
41                case 1: return DST_channelbanner_1_s_480;
42                case 2: return DST_channelbanner_2_s_480;
43                case 3: return DST_channelbanner_3_s_480;
44                case 4: return DST_channelbanner_4_s_480;
45                case 5: return DST_channelbanner_5_s_480;
46                case 6: return DST_channelbanner_6_s_480;
47                case 7: return DST_channelbanner_7_s_480;
48                case 8: return DST_channelbanner_8_s_480;
49                case 9: return DST_channelbanner_9_s_480;
50        }
51        return DST_channelbanner_0_s_480;
52}
53
54DS_U32* DST_UTF82Uni(DS_U8 *utf);
55
56//class CChannelBannerWin : public CWindow
57//{
58//private:
59        static int CChannelBannerWin_nCh_Major;
60        static int CChannelBannerWin_nCh_Minor;
61        static DS_U8 CChannelBannerWin_bannerType;
62        static DS_U32 *CChannelBannerWin_chName;
63        static bool CChannelBannerWin_bTuned;
64        static bool CChannelBannerWin_bHyphened;
65        static int CChannelBannerWin_maxMajorPosition;
66        static int CChannelBannerWin_maxMinorPosition;
67//public:
68void CChannelBannerWin_RegisterUnregisterDigitKey(CWindow *this, bool bState);
69int CChannelBannerWin_getPositionNumber(int number);
70
71
72//      CChannelBannerWin(SWinEventMsg event):CWindow(event)
73        void CChannelBannerWin_Constructor(CWindow *this, SWinEventMsg event)
74        {       
75                this->SetWinName(this,  "ChBanner");   
76                CChannelBannerWin_chName = 0;
77                CChannelBannerWin_nCh_Major = 0;
78                CChannelBannerWin_nCh_Minor = 0;
79               
80//              CDB db; NewCDB(&db);
81//              db.GetTable(&db, "select max(major), max(minor) from channel_db");
82                int i;
83                int max_major = 0;
84                int max_minor = 0;
85                DBLock(true);
86                for (i = 0; i < DB_CHANNEL_DB_MAX; i++)
87                {
88                        if (db_channel_db[i].program_number == 0) continue;
89                        if (db_channel_db[i].major > max_major) max_major = db_channel_db[i].major;
90                        if (db_channel_db[i].minor > max_minor) max_minor = db_channel_db[i].minor;
91                }
92                DBLock(false);
93
94                CChannelBannerWin_maxMajorPosition = CChannelBannerWin_getPositionNumber(max_major);
95                CChannelBannerWin_maxMinorPosition = CChannelBannerWin_getPositionNumber(max_minor);
96
97                CChannelBannerWin_bannerType = event.data[2];
98
99                this->rect.w = DST_GetScreenWidth()/2;
100                this->rect.h = DST_GetImageHeight(channel_banner_720480);
101                this->rect.x = DST_GetScreenWidth() - this->rect.w - (DST_GetScreenWidth() / 20);
102                this->rect.y = 10+DST_GetScreenHeight() / 20;
103
104                this->SetTimeOut(this, 3);
105                CChannelBannerWin_bTuned = false;
106                CChannelBannerWin_bHyphened = false;
107                CChannelBannerWin_RegisterUnregisterDigitKey(this, true);
108                switch(CChannelBannerWin_bannerType)
109                {
110                        case BANNER_NORMAL:
111                                this->SetTimeOut(this, event.data[3]);
112                                break;
113                        case BANNER_DIGIT:
114                                if(this->eventInit.data[3] == VK_0) this->Close(this);
115                                this->KeyInput(this, this->eventInit.data[3], false);
116                                break;
117                }
118//              DeleteCDB(&db);
119        }
120
121       
122        void CChannelBannerWin_Destructor(CWindow *this)
123        {
124                if (CChannelBannerWin_chName) DST_OS_Free(&CChannelBannerWin_chName);
125                if(CChannelBannerWin_bannerType == BANNER_DIGIT && this->eventInit.data[3] != VK_0 && CChannelBannerWin_nCh_Major != 0)
126                        DST_CreateWin(WIN_CHANNEL_BANNER, WIN_NULL, BANNER_NORMAL, DST_g_SignalState == SM_AUDIO_ONLY?0:3, 0, 0);
127        }
128       
129        int CChannelBannerWin_getPositionNumber(int number)
130        {
131                int pos = 0;
132                while(number>0)
133                {
134                        number = number/10;
135                        pos++;
136                }
137                return pos;
138        }
139
140        int CChannelBannerWin_getPowerOfTen(int x)
141        {
142                int ret = 1;
143                int i = 0;
144                for( i=0;i<x;i++)
145                        ret*= 10;
146                return ret;
147        }
148
149        int CChannelBannerWin_getMaxTuneNumber(int x)
150        {
151                int ret = 0;
152                int i = 0;
153                for( i=0;i<x;i++)
154                        ret+= CChannelBannerWin_getPowerOfTen(i);
155
156                DST_Printf("ret = %d\n",ret);
157                return 9*ret;   
158        }       
159       
160        void CChannelBannerWin_RegisterUnregisterDigitKey(CWindow *this, bool bState)
161        {
162                this->RegisterKey(this, VK_PREV, bState, 0, 0);
163                this->RegisterKey(this, VK_PREV_CH, bState, 0, 0);
164                this->RegisterKey(this, VK_CH_UP, bState, 0, 0);
165                this->RegisterKey(this, VK_CH_DN, bState, 0, 0);
166                switch(CChannelBannerWin_bannerType)
167                {
168                        case BANNER_NORMAL:
169                                this->RegisterKey(this, VK_CANCEL, bState, 0, 0);
170                                this->RegisterKey(this, VK_OK, bState, 0, 0);
171                                break;
172                        case BANNER_DIGIT:
173                                this->RegisterKey(this, VK_0, bState, 0, 0);
174                                this->RegisterKey(this, VK_1, bState, 0, 0);
175                                this->RegisterKey(this, VK_2, bState, 0, 0);
176                                this->RegisterKey(this, VK_3, bState, 0, 0);
177                                this->RegisterKey(this, VK_4, bState, 0, 0);
178                                this->RegisterKey(this, VK_5, bState, 0, 0);
179                                this->RegisterKey(this, VK_6, bState, 0, 0);
180                                this->RegisterKey(this, VK_7, bState, 0, 0);
181                                this->RegisterKey(this, VK_8, bState, 0, 0);
182                                this->RegisterKey(this, VK_9, bState, 0, 0);
183                                this->RegisterKey(this, VK_OK, bState, 0, 0);
184                                this->RegisterKey(this, VK_CANCEL, bState, 0, 0);
185                                this->RegisterKey(this, VK_HYPHEN, bState, 0, 0);
186                                break;
187                }
188
189        }
190
191//      virtual void Show(WinID id)
192        void CChannelBannerWin_ShowWindow(CWindow *this, WinID id)
193        {
194                switch(id)
195                {
196                        case WIN_EWS:
197                        case WIN_DEBUG_SQL:
198                        case WIN_DEBUG_SQL_SUB:
199                        case WIN_ENGINEER_MODE:
200                        case WIN_FREQUENCY_SETTING:
201                        case WIN_FACTORY_MODE:
202                        case WIN_DIRECT_TUNE:
203//                      case WIN_VOLUME:
204//                      case WIN_VOLUME_MUTE:
205                        case WIN_SIGNAL_METER:
206//                      case WIN_CLOSED_CAPTION_HOT:
207                        case WIN_AUDIO_HOT:
208                        case WIN_DISPLAY_MODE_HOT:
209                        case WIN_FACTORY_RESET:
210                        case WIN_FACTORY_RESET_ASK:
211                        case WIN_INFOR_BANNER:
212                        case WIN_MAIN_MENU:
213                        case WIN_POWER_DOWN_CAUTION:
214                        case WIN_SUB_MENU_2DEPTH:
215                        case WIN_SUB_MENU_3DEPTH:
216                        case WIN_SUB_MENU_4DEPTH:
217                        case WIN_AUTO_SEARCH:
218                        case WIN_MANUAL_SEARCH:
219                        case WIN_CHANNEL_LIST:
220                        case WIN_PROGRAM_GUIDE:
221                        case WIN_OTC_DOWNLOAD:
222                        case WIN_OTC_DOWNLOAD_FAIL:
223                        case WIN_RF_UPDATE:                             
224                                this->Close(this);
225                                break;
226                        default:
227                                break;
228                }
229        }
230
231        void CChannelBannerWin_Draw(CWindow *this)
232        {
233                // ¹è°æÈ­¸é ±×¸®±â
234                int xPos = 0;
235//              CDB db; NewCDB(&db);
236                int nPos = -1;
237                int nChCount = 0;
238                int major =  0;
239                int minor = 0;
240                int majorPosition = 0;
241                int minorPosition = 0;
242                char name[TEXT_LENGTH_MAX] = { 0,};
243
244                DS_U8 *img[9] = {0,};
245                int numberLenth = 0;
246                int nTotalWidth = 0;
247                int index = 0;
248                int i = 0;
249
250                DS_U8 RF = DST_EEPROM_GetRF();
251                DS_U16 PROG_ID = DST_EEPROM_GetProgramNumber();
252               
253//              DST_GetAVState(&RF, &PROG_ID, 0);
254//              this->DrawImage(this, 0, 0, channel_banner_720480, false);
255                this->DrawBox32(this, 0, 0, this->rect.w, this->rect.h, CONV32_16(0x00000000));
256
257                // TVÀÎ °æ¿ì
258                this->setFontStyle(this, 22, 0xFFC8C8C8, ALIGN_MIDDLE, ALIGN_RIGHT);
259                DBLock(true);
260                if(CChannelBannerWin_bannerType == BANNER_NORMAL)
261                {
262                        int max_major = -1;
263                        int max_minor = -1;
264                        nChCount = 0;
265                        for (i=DB_CHANNEL_DB_MAX-1; i >= 0; i--)
266                        {
267                                if (db_channel_db[i].program_number == 0) continue;
268                                if (db_channel_db[i].rf != RF) continue;
269                                if (db_channel_db[i].program_number != PROG_ID) continue;
270
271                                if(max_major < db_channel_db[i].major)
272                                {
273                                        max_major = db_channel_db[i].major;
274                                        max_minor = db_channel_db[i].minor;
275                                        nPos = i;
276                                }
277                                else if(max_major == db_channel_db[i].major)
278                                {
279                                        if(max_minor < db_channel_db[i].minor)
280                                        {
281                                                max_minor = db_channel_db[i].minor;
282                                                nPos = i;
283                                        }
284                                }
285                               
286                                nChCount++;
287                        }
288                        if(nChCount < 1)
289                        {       
290                                max_major = -1;
291                                max_minor = -1;                 
292                                for (i=DB_CHANNEL_DB_MAX-1; i >= 0; i--)
293                                {
294                                        if (db_channel_db[i].program_number == 0) continue;
295                                        if (db_channel_db[i].rf != RF) continue;
296                                        if(max_major < db_channel_db[i].major)
297                                        {
298                                                max_major = db_channel_db[i].major;
299                                                max_minor = db_channel_db[i].minor;
300                                                nPos = i;
301                                        }
302                                        else if(max_major == db_channel_db[i].major)
303                                        {
304                                                if(max_minor < db_channel_db[i].minor)
305                                                {
306                                                        max_minor = db_channel_db[i].minor;
307                                                        nPos = i;
308                                                }
309                                        }
310                                        nChCount++;
311                                }
312                        }
313
314                        major =  DST_GetFrequencyNumberbyIndex(RF);
315                        minor = 0;
316                        if (nChCount)
317                        {
318                                nChCount = 2; // ¸¶ÀÌ³Ê Ç¥½ÃµÇµµ·Ï °­Á¦·Î 2·Î º¯°æÇÔ
319                                major = db_channel_db[nPos].major;
320                                minor = db_channel_db[nPos].minor;
321                                strcpy(name , db_channel_db[nPos].name);
322                                CChannelBannerWin_bHyphened = true;
323                        }
324                }
325                else
326                {
327                        if(CChannelBannerWin_nCh_Minor == 0)
328                        {
329                                nChCount = 1;
330                        }
331                        int max_major = -1;
332                        int max_minor = -1;
333                        bool bFound = true;
334                        int tmp_minor = CChannelBannerWin_nCh_Minor;
335                        nChCount = 0;
336                        int rf = DST_DB_GetRF(CChannelBannerWin_nCh_Major, &tmp_minor, &bFound);
337                        int program_number = DST_DB_GetProgramNumber(CChannelBannerWin_nCh_Major,CChannelBannerWin_nCh_Minor==0?tmp_minor:CChannelBannerWin_nCh_Minor);
338                        for (i=DB_CHANNEL_DB_MAX-1; i >= 0; i--)
339                        {
340                                if (db_channel_db[i].program_number == 0) continue;
341                                if (db_channel_db[i].rf != rf) continue;
342                                if (db_channel_db[i].program_number != program_number) continue;
343                                if(max_major < db_channel_db[i].major)
344                                {
345                                        max_major = db_channel_db[i].major;
346                                        max_minor = db_channel_db[i].minor;
347                                        nPos = i;
348                                }
349                                else if(max_major == db_channel_db[i].major)
350                                {
351                                        if(max_minor < db_channel_db[i].minor)
352                                        {
353                                                max_minor = db_channel_db[i].minor;
354                                                nPos = i;
355                                        }
356                                }
357
358                                nChCount++;
359                        }
360                        major = CChannelBannerWin_nCh_Major;
361                        minor = CChannelBannerWin_nCh_Minor;
362                        if(nPos > -1) strcpy(name , db_channel_db[nPos].name);
363                }
364                DBLock(false);
365                majorPosition = CChannelBannerWin_getPositionNumber(major);
366                minorPosition = CChannelBannerWin_getPositionNumber(minor);
367               
368                // ä³ÎÀ̸§ Ç¥½Ã
369                if (nPos < 0 || strlen(name) == 0) // ä³Î¸Ê¿¡ ¾ø´Â ä³ÎÀÎ °æ¿ì
370                {
371                        this->FontSetColor(this,CONV32_16(0xFF221F1F));
372                        this->DrawTextUni(this, 0, DST_GetImageHeight(DST_channelbanner_0_480)+2, this->rect.w, 47, pz_Digital[OSD_Lang], &(this->font)); // Digital
373                        this->FontSetColor(this,CONV32_16(0xFFC8C8C8));
374                        this->DrawTextUni(this, 0, DST_GetImageHeight(DST_channelbanner_0_480), this->rect.w -2, 47, pz_Digital[OSD_Lang], &(this->font)); // Digital
375                }
376                else
377                {
378                        DS_U32* strText32 = DST_UTF82Uni((DS_U8*)name); 
379                        this->FontSetColor(this,CONV32_16(0xFF221F1F));
380                        this->DrawText32(this, 0, DST_GetImageHeight(DST_channelbanner_0_480) +2, this->rect.w, 47, strText32, &(this->font));
381                        this->FontSetColor(this,CONV32_16(0xFFC8C8C8));
382                        this->DrawText32(this, 0, DST_GetImageHeight(DST_channelbanner_0_480), this->rect.w -2, 47, strText32, &(this->font));
383                }
384               
385                numberLenth = majorPosition+minorPosition+((CChannelBannerWin_bHyphened )?1:0);
386                i = 0;
387                for( i=majorPosition;i>0;i--)
388                {
389                        img[index] = NumToImage((major/CChannelBannerWin_getPowerOfTen(i-1))%10);
390                        nTotalWidth += DST_GetImageWidth(img[index]);
391                        index++;
392                }
393               
394                if(CChannelBannerWin_bHyphened )
395                {
396                        img[index] = DST_channelbanner_dash_480;
397                        nTotalWidth += DST_GetImageWidth(img[majorPosition]);
398                        index++;
399                }
400
401                i = 0;
402                for( i=minorPosition;i>0;i--)
403                {
404                        img[index] = NumToImageSmall((minor/CChannelBannerWin_getPowerOfTen(i-1))%10);
405                        nTotalWidth += DST_GetImageWidth(img[index]);
406                        index++;
407                }       
408
409                xPos = (this->rect.w - nTotalWidth) - 10;
410                i = 0;
411                for( i=0;i<numberLenth;i++)
412                {
413                        int yPos = 0;
414                        if(i < majorPosition)
415                        {
416                                yPos = 0;
417                        }
418                        else
419                        {
420                                if(i == majorPosition && CChannelBannerWin_bHyphened)
421                                        yPos = 18;
422                                else
423                                        yPos = 11;
424                        }
425                        this->DrawImage(this, xPos, yPos, img[i], true);
426                        xPos += DST_GetImageWidth(img[i]);
427                }
428//              DeleteCDB(&db);
429
430        }
431
432//      virtual void Show()
433        void CChannelBannerWin_Show(CWindow *this)
434        {
435                CChannelBannerWin_Draw(this);
436                CChannelBannerWin_RegisterUnregisterDigitKey(this, true);
437        }
438
439//      virtual void OnTimer(char nID)
440        void CChannelBannerWin_OnTimer(CWindow *this, char nID)
441        {
442                switch (nID)
443                {
444                        case 1:
445                                {
446                                        this->KillTimer(this, 1);
447                                        CChannelBannerWin_bTuned = true;
448                                        bool bFound = true;
449                                        int tmp_minor = CChannelBannerWin_nCh_Minor;
450                                        int RF = DST_DB_GetRF(CChannelBannerWin_nCh_Major, &tmp_minor, &bFound);
451//                                      DST_Printf("RF = %d, CChannelBannerWin_nCh_Major=%d, tmp_minor=%d DST_DB_GetProgramNumber(CChannelBannerWin_nCh_Major,tmp_minor)=%d\n",RF, CChannelBannerWin_nCh_Major, tmp_minor,DST_DB_GetProgramNumber(CChannelBannerWin_nCh_Major,tmp_minor));
452                                        if (DST_DB_PresentMatchChannel(RF, CChannelBannerWin_nCh_Major, CChannelBannerWin_nCh_Minor==0?tmp_minor:CChannelBannerWin_nCh_Minor ))
453                                                DST_UI_ChannelTune(bFound?RF:DST_MinRF(), DST_DB_GetProgramNumber(CChannelBannerWin_nCh_Major,CChannelBannerWin_nCh_Minor==0?tmp_minor:CChannelBannerWin_nCh_Minor));
454                                }
455                                break;
456                        default:
457                                break;
458                }
459        }
460
461//      virtual void OnMessage(SWinEventMsg event)
462        void CChannelBannerWin_OnMessage(CWindow *this, SWinEventMsg event)
463        {
464                switch (event.cmd)
465                {
466                        case WM_CT_MSG: // Æ©´× ½ÃÀÛ ¸Þ½ÃÁö¸¦ ¹ÞÀ¸¸é °»½Å
467                                if (event.data32[0] == CT_TUNE_START) 
468                                {
469                                        this->Show(this);
470                                        this->SetTimeOut(this, 3);
471                                }
472                                break;         
473                        case WM_POWER_OFF:
474                                this->Close(this);
475                                break;
476                }
477        }
478
479               
480//              virtual void KeyInput(DS_U8 key, bool /*bRepeat*/)
481        void CChannelBannerWin_KeyInput(CWindow *this, DS_U8 key, bool bRepeat)
482        {
483                bool bMatch = false;
484                int nCount = 0;
485                switch (key)
486                {
487                        case VK_PREV:
488                        case VK_PREV_CH:
489                                if (IsTVHotKeyPossible()) 
490                                {
491                                        CChannelBannerWin_bTuned = true;
492                                        this->KillTimer(this, 1);
493                                        int nCh_Major = DST_DB_GetMajor(DST_g_PrevRF,DST_g_PrevProgramNumber);
494                                        int nCh_Minor = DST_DB_GetMinor(DST_g_PrevRF,DST_g_PrevProgramNumber);
495                                        if(DST_DB_PresentMatchChannel(DST_g_PrevRF, nCh_Major,nCh_Minor ))
496                                        {
497                                                DST_UI_ChannelTune(DST_g_PrevRF, DST_g_PrevProgramNumber);
498                                        }
499                                        else
500                                        {
501                                                DST_g_PrevRF = DST_EEPROM_GetRF();
502                                                DST_g_PrevProgramNumber = DST_EEPROM_GetProgramNumber();
503                                        }
504                                        CChannelBannerWin_bannerType = BANNER_NORMAL;
505                                        CChannelBannerWin_RegisterUnregisterDigitKey(this, false);
506                                        CChannelBannerWin_RegisterUnregisterDigitKey(this, true);
507                                        this->SetTimeOut(this, 3);
508                                        CChannelBannerWin_Draw(this);
509                                }
510                                break;
511                        case VK_CH_UP:
512                        case VK_CH_DN:
513                                CChannelBannerWin_bTuned = true;
514                                this->KillTimer(this, 1);
515                                DST_UI_ChannelUpDn(key==VK_CH_UP?true:false);
516                                CChannelBannerWin_bannerType = BANNER_NORMAL;
517                                CChannelBannerWin_RegisterUnregisterDigitKey(this, false);
518                                CChannelBannerWin_RegisterUnregisterDigitKey(this, true);
519                                this->SetTimeOut(this, 3);
520                                CChannelBannerWin_Draw(this);
521                                break;
522                        case VK_0:
523                        case VK_1:
524                        case VK_2:
525                        case VK_3:
526                        case VK_4:
527                        case VK_5:
528                        case VK_6:
529                        case VK_7:
530                        case VK_8:
531                        case VK_9:
532                                {
533                                        if(CChannelBannerWin_bannerType == BANNER_NORMAL)
534                                        {
535                                                CChannelBannerWin_bHyphened = false;
536                                                CChannelBannerWin_bannerType = BANNER_DIGIT;
537                                                CChannelBannerWin_RegisterUnregisterDigitKey(this, false);
538                                                CChannelBannerWin_RegisterUnregisterDigitKey(this, true);
539                                        }
540                                        if(CChannelBannerWin_nCh_Minor > (DS_U16)CChannelBannerWin_getMaxTuneNumber(CChannelBannerWin_maxMinorPosition))
541                                        {
542                                                CChannelBannerWin_bTuned = false;
543                                                CChannelBannerWin_bHyphened = false;
544                                                CChannelBannerWin_nCh_Major = 0;
545                                                CChannelBannerWin_nCh_Minor = 0;
546                                        }
547                                       
548                                        if(CChannelBannerWin_bHyphened)
549                                                CChannelBannerWin_nCh_Minor = (CChannelBannerWin_nCh_Minor>0)?( CChannelBannerWin_nCh_Minor * 10 + ( key - VK_0)):(key - VK_0);
550                                        else
551                                                CChannelBannerWin_nCh_Major = CChannelBannerWin_nCh_Major * 10 + ( key - VK_0);
552
553                                        if(CChannelBannerWin_bTuned)
554                                        {
555                                                CChannelBannerWin_bTuned = false;
556                                                CChannelBannerWin_bHyphened = false;
557                                                CChannelBannerWin_nCh_Major =  key - VK_0;
558                                                CChannelBannerWin_nCh_Minor = 0;
559                                        }
560
561                                        if(CChannelBannerWin_bHyphened)
562                                        {
563                                                if(CChannelBannerWin_nCh_Minor > (DS_U16)CChannelBannerWin_getMaxTuneNumber(CChannelBannerWin_maxMinorPosition))
564                                                {
565                                                        CChannelBannerWin_bHyphened = false;
566                                                        CChannelBannerWin_nCh_Major =  key - VK_0;
567                                                        CChannelBannerWin_nCh_Minor = 0;
568                                                }
569                                        }
570                                        else
571                                        {
572                                                if(CChannelBannerWin_nCh_Major > (DS_U16)CChannelBannerWin_getMaxTuneNumber(CChannelBannerWin_maxMajorPosition))
573                                                        CChannelBannerWin_nCh_Major =  key - VK_0;
574                                        }
575
576                                        if(CChannelBannerWin_nCh_Major == 0) 
577                                        {
578                                                this->Close(this);
579                                                return;
580                                        }
581                                        nCount = DST_DB_AvailableChannelCount(CChannelBannerWin_nCh_Major);
582                                        if (nCount == 0) // ÀÏÄ¡ÇÏ´Â Á¤º¸°¡ ¾ø´Â °æ¿ì ¹Ù·Î ´Ý´Â´Ù.
583                                        {
584                                                CChannelBannerWin_Draw(this);
585                                                this->KillTimer(this, 1);
586                                                break;
587                                        }
588                                        bool bFound = true;
589                                        int tmp_minor = CChannelBannerWin_nCh_Minor;
590                                        bMatch = DST_DB_PresentMatchChannel(DST_DB_GetRF(CChannelBannerWin_nCh_Major, &tmp_minor, &bFound), CChannelBannerWin_nCh_Major, CChannelBannerWin_nCh_Minor==0?tmp_minor:CChannelBannerWin_nCh_Minor);
591                                        if (bMatch) // Á¤È®È÷ ÀÏÄ¡Çϴ ä³ÎÀÌ ÀÖ´Ù¸é 2ÃÊÈÄ¿¡ Æ©´×ÇÑ´Ù.
592                                        {
593                                                this->SetTimer(this, 1, 2800);
594                                                CChannelBannerWin_Draw(this);
595                                                break;
596                                        }
597                                        CChannelBannerWin_Draw(this);
598                                }
599                                break;
600
601                        case VK_HYPHEN:
602                                CChannelBannerWin_bHyphened = true;
603                                CChannelBannerWin_Draw(this);
604                                break;
605                               
606                        case VK_OK:
607                                if (CChannelBannerWin_bannerType == BANNER_NORMAL) 
608                                {
609                                        if(DST_g_SignalState != SM_AUDIO_ONLY)  this->Close(this);
610                                }       
611                                else
612                                {
613                                        bool bFound = true;
614                                        int tmp_minor = CChannelBannerWin_nCh_Minor;
615                                        int RF = DST_DB_GetRF(CChannelBannerWin_nCh_Major, &tmp_minor, &bFound);
616                                        if (DST_DB_PresentMatchChannel(RF, CChannelBannerWin_nCh_Major, CChannelBannerWin_nCh_Minor==0?tmp_minor:CChannelBannerWin_nCh_Minor ))
617                                                DST_UI_ChannelTune(bFound?RF:DST_MinRF(), DST_DB_GetProgramNumber(CChannelBannerWin_nCh_Major,CChannelBannerWin_nCh_Minor==0?tmp_minor:CChannelBannerWin_nCh_Minor));
618                                        this->Close(this);
619                                }
620                                break;
621                        case VK_CANCEL:
622                                if(DST_g_SignalState != SM_AUDIO_ONLY)  this->Close(this);
623                                break;
624                        default: break;
625                }
626        }
627
628//};
629
630
631void DST_CreateChannelBannerWindow(SWinEventMsg event)
632{
633        if (DST_GetWin(WIN_OTC_DOWNLOAD)) return;
634        if (DST_GetWin(WIN_OTC_DOWNLOAD_FAIL)) return;
635        if (DST_GetWin(WIN_MANUAL_SEARCH)) return;
636        if (DST_GetWin(WIN_AUTO_SEARCH)) return;
637        if (DST_GetWin(WIN_CHANNEL_LIST)) return;
638        if (DST_GetWin(WIN_PROGRAM_GUIDE)) return;
639        if (DST_GetWin(WIN_MAIN_MENU)) return;
640        if (DST_GetWin(WIN_INFOR_BANNER) && event.data[2] == BANNER_NORMAL) return;
641        if (DST_GetWin(WIN_FACTORY_MODE)) return;
642       
643        CWindow*pWin = NewCWindow(event);
644        pWin->Destructor        = CChannelBannerWin_Destructor;
645        pWin->KeyInput          = CChannelBannerWin_KeyInput;
646        pWin->OnMessage         = CChannelBannerWin_OnMessage;
647        pWin->OnTimer           = CChannelBannerWin_OnTimer;
648        pWin->ShowWindow        = CChannelBannerWin_ShowWindow;
649        pWin->Show                      = CChannelBannerWin_Show;
650        // »ý¼ºÀÚ È£Ãâ
651        CChannelBannerWin_Constructor(pWin, event);
652        // À©µµ¿ì ¸Þ´ÏÀú¿¡ µî·Ï
653        DST_AddWin((WinID)(event.data[0]), pWin);       
654}
655
656
657//class CDirectTuneWin : public CWindow
658//{
659//private:
660        static int CDirectTuneWin_nRF;
661        static int CDirectTuneWin_nRFIndex;
662        static int CDirectTuneWin_nRFIndex_Old;
663        static bool CDirectTuneWin_bTuned;
664        static bool CDirectTuneWin_bFirst;
665//public:
666void CDirectTuneWin_RegisterUnregisterDigitKey(CWindow *this, bool bState);
667
668//      CDirectTuneWin(SWinEventMsg event):CWindow(event)
669        void CDirectTuneWin_Constructor(CWindow *this, SWinEventMsg event)
670        {       
671                this->SetWinName(this,  "DirectTune");
672                DS_U8  RF = 0;
673                DS_U16 sID = 0;
674               
675                DST_GetAVState(&RF, 0, &sID);
676               
677                CDirectTuneWin_nRFIndex = RF;
678                CDirectTuneWin_nRFIndex_Old = CDirectTuneWin_nRFIndex;
679               
680                CDirectTuneWin_nRF = DST_GetFrequencyNumberbyIndex(CDirectTuneWin_nRFIndex);
681
682                this->rect.w = DST_GetImageWidth(channel_banner_720480);
683                this->rect.h = DST_GetImageHeight(channel_banner_720480);
684                this->rect.x = DST_GetScreenWidth() - this->rect.w - (DST_GetScreenWidth() / 20);
685                this->rect.y = DST_GetScreenHeight() / 20;
686
687                this->SetTimeOut(this, 3);
688                CDirectTuneWin_bTuned = false;
689                CDirectTuneWin_bFirst = true;
690                CDirectTuneWin_RegisterUnregisterDigitKey(this, true);
691        }
692       
693        void CDirectTuneWin_Destructor(CWindow *this)
694        {
695                if(DST_GetWin(WIN_CHANNEL_BANNER) != 0)
696                        DST_CloseWin(WIN_CHANNEL_BANNER);
697                DST_CreateWin(WIN_CHANNEL_BANNER, WIN_NULL, BANNER_NORMAL, 3, 0, 0);
698        }
699
700        int CDirectTuneWin_getPositionNumber(int number)
701        {
702                int pos = 0;
703                while(number>0)
704                {
705                        number = number/10;
706                        pos++;
707                }
708                return pos;
709        }
710
711        int CDirectTuneWin_getPowerOfTen(int x)
712        {
713                int ret = 1;
714                int i = 0;
715                for( i=0;i<x;i++)
716                        ret*= 10;
717                return ret;
718        }
719       
720        void CDirectTuneWin_RegisterUnregisterDigitKey(CWindow *this, bool bState)
721        {
722                this->RegisterKey(this, VK_0, bState, 0, 0);
723                this->RegisterKey(this, VK_1, bState, 0, 0);
724                this->RegisterKey(this, VK_2, bState, 0, 0);
725                this->RegisterKey(this, VK_3, bState, 0, 0);
726                this->RegisterKey(this, VK_4, bState, 0, 0);
727                this->RegisterKey(this, VK_5, bState, 0, 0);
728                this->RegisterKey(this, VK_6, bState, 0, 0);
729                this->RegisterKey(this, VK_7, bState, 0, 0);
730                this->RegisterKey(this, VK_8, bState, 0, 0);
731                this->RegisterKey(this, VK_9, bState, 0, 0);
732                this->RegisterKey(this, VK_OK, bState, 0, 0);
733                this->RegisterKey(this, VK_CANCEL, bState, 0, 0);
734                this->RegisterKey(this, VK_UP, bState, 0, 0);
735                this->RegisterKey(this, VK_DN, bState, 0, 0);
736                this->RegisterKey(this, VK_HYPHEN, bState, 0, 0);
737        }
738
739//      virtual void Show(WinID id)
740        void CDirectTuneWin_ShowWindow(CWindow *this, WinID id)
741        {
742                switch(id)
743                {
744                        case WIN_FACTORY_MODE:
745                        case WIN_EWS:
746                        case WIN_CHANNEL_BANNER:
747                        case WIN_VOLUME:
748                        case WIN_VOLUME_MUTE:
749                        case WIN_SIGNAL_METER:
750                        case WIN_CLOSED_CAPTION_HOT:
751                        case WIN_AUDIO_HOT:
752                        case WIN_DISPLAY_MODE_HOT:
753                        case WIN_FACTORY_RESET:
754                        case WIN_FACTORY_RESET_ASK:
755                        case WIN_INFOR_BANNER:
756                        case WIN_MAIN_MENU:
757                        case WIN_POWER_DOWN_CAUTION:
758                        case WIN_SUB_MENU_2DEPTH:
759                        case WIN_SUB_MENU_3DEPTH:
760                        case WIN_SUB_MENU_4DEPTH:
761                        case WIN_AUTO_SEARCH:
762                        case WIN_MANUAL_SEARCH:
763                        case WIN_CHANNEL_LIST:
764                        case WIN_PROGRAM_GUIDE:
765                        case WIN_OTC_DOWNLOAD:
766                        case WIN_OTC_DOWNLOAD_FAIL:
767                        case WIN_UPDATE:
768                        case WIN_UPDATE_RESET:                         
769                                this->Close(this);
770                                break;
771                        default:
772                                break;
773                }
774        }
775
776        void CDirectTuneWin_Draw(CWindow *this)
777        {
778                // ¹è°æÈ­¸é ±×¸®±â
779                int xPos = 0;
780                char name[3] = {0,};
781                DS_U32* strText32 = 0;
782               
783                DS_U8 *img[9] = {0,};
784                int numberLenth = 0;
785                int nTotalWidth = 0;
786                int index = 0;
787                int i = 0;
788               
789                this->DrawImage(this, 0, 0, channel_banner_720480, false);
790               
791                // TVÀÎ °æ¿ì
792                this->setFontStyle(this, 20, 0xFFC8C8C8, ALIGN_MIDDLE, ALIGN_CENTER);
793
794                sprintf(name,"%s","RF");
795                // ä³ÎÀ̸§ Ç¥½Ã
796                strText32 = DST_UTF82Uni((DS_U8*)name); // È£ÃâÇÑ ÂÊ¿¡¼­ ¸Þ¸ð¸® ÇØÁ¦
797                this->DrawText32(this, 0, 0, this->rect.w, 47, strText32, &(this->font));
798               
799                // ä³Î ¼ýÀÚ Ç¥½Ã
800                numberLenth = CDirectTuneWin_getPositionNumber(CDirectTuneWin_nRF);
801                i = 0;
802                for( i=numberLenth;i>0;i--)
803                {
804                        img[index] = NumToImage((CDirectTuneWin_nRF/CDirectTuneWin_getPowerOfTen(i-1))%10);
805                        nTotalWidth += DST_GetImageWidth(img[index]);
806                        index++;
807                }
808               
809                xPos = (this->rect.w - nTotalWidth) / 2;
810                i = 0;
811                for( i=0;i<numberLenth;i++)
812                {
813                        this->DrawImage(this, xPos, 68, img[i], true);
814                        xPos += DST_GetImageWidth(img[i]);
815                }
816        }
817
818       
819//      virtual void Show()
820        void CDirectTuneWin_Show(CWindow *this)
821        {
822                CDirectTuneWin_Draw(this);
823                CDirectTuneWin_RegisterUnregisterDigitKey(this, true);
824        }
825
826//      virtual void OnMessage(SWinEventMsg event)
827        void CDirectTuneWin_OnMessage(CWindow *this, SWinEventMsg event)
828        {
829                switch (event.cmd)
830                {
831                        case WM_POWER_OFF:
832                                this->Close(this);
833                                break;
834                }
835        }
836
837//      virtual void OnTimer(char nID)
838        void CDirectTuneWin_OnTimer(CWindow *this, char nID)
839        {
840                switch (nID)
841                {
842                        case 1:
843                                {
844                                        this->KillTimer(this, 1);
845                                        if(CDirectTuneWin_nRFIndex > (DS_U16)DST_MaxRF()|| CDirectTuneWin_nRFIndex < (DS_U16)DST_MinRF())
846                                                CDirectTuneWin_nRFIndex =       CDirectTuneWin_nRFIndex_Old;
847
848
849                                        CDirectTuneWin_Draw(this);
850                                        if(DST_GetIndexByRFNumber(CDirectTuneWin_nRF) >= 0)
851                                        {
852                                                CDirectTuneWin_nRFIndex = DST_GetIndexByRFNumber(CDirectTuneWin_nRF);
853                                                CDirectTuneWin_bTuned = true;
854                                                DST_UI_ChannelTune(CDirectTuneWin_nRFIndex, 0);
855                                        }               
856                                        CDirectTuneWin_nRFIndex_Old = CDirectTuneWin_nRFIndex;                         
857
858                                        this->SetTimer(this, 2,1000);
859                                }
860                                break;
861                        case 2:
862                                this->Close(this);
863                                break;
864                        default:
865                                break;
866                }
867        }
868
869//      virtual void KeyInput(DS_U8 key, bool /*bRepeat*/)
870        void CDirectTuneWin_KeyInput(CWindow *this, DS_U8 key, bool bRepeat)
871        {
872                switch (key)
873                {
874                        case VK_UP:
875                                CDirectTuneWin_nRFIndex += 1;
876                                if(CDirectTuneWin_nRFIndex > (DS_U16)DST_MaxRF()) CDirectTuneWin_nRFIndex = (DS_U16)DST_MinRF();
877                                CDirectTuneWin_nRF = DST_GetFrequencyNumberbyIndex(CDirectTuneWin_nRFIndex);
878                                this->SetTimer(this, 1,10);
879                                break;
880                       
881                        case VK_DN:
882                                CDirectTuneWin_nRFIndex -= 1;
883                                if(CDirectTuneWin_nRFIndex < (DS_U16)DST_MinRF()) CDirectTuneWin_nRFIndex = (DS_U16)DST_MaxRF();
884                                CDirectTuneWin_nRF = DST_GetFrequencyNumberbyIndex(CDirectTuneWin_nRFIndex);
885                                this->SetTimer(this, 1,10);
886                                break;
887
888                        case VK_0:
889                        case VK_1:
890                        case VK_2:
891                        case VK_3:
892                        case VK_4:
893                        case VK_5:
894                        case VK_6:
895                        case VK_7:
896                        case VK_8:
897                        case VK_9:
898                                if(CDirectTuneWin_bFirst)  CDirectTuneWin_nRF = 0;
899                                CDirectTuneWin_nRF = CDirectTuneWin_nRF * 10 + ( key - VK_0);
900                               
901                                if(CDirectTuneWin_bTuned)
902                                {
903                                        CDirectTuneWin_bTuned = false;
904                                        CDirectTuneWin_nRF =  key - VK_0;
905                                }
906
907                                if(CDirectTuneWin_nRF/10 != 0 && DST_GetIndexByRFNumber(CDirectTuneWin_nRF) < 0)
908                                        CDirectTuneWin_nRF =  key - VK_0;
909
910                                this->SetTimer(this, 1, 1000);
911                                CDirectTuneWin_Draw(this);
912                                break;
913
914                        case VK_HYPHEN:
915                                break;
916                               
917                        case VK_OK:
918                                if(CDirectTuneWin_nRFIndex > (DS_U16)DST_MaxRF()|| CDirectTuneWin_nRFIndex < (DS_U16)DST_MinRF())
919                                        CDirectTuneWin_nRFIndex =  CDirectTuneWin_nRFIndex_Old;
920                                this->SetTimer(this, 1,10);
921                                break;
922                        case VK_CANCEL:
923                                this->Close(this);
924                                break;
925                        default: break;
926                }
927
928                CDirectTuneWin_bFirst = false;
929               
930        }
931//};
932
933void DST_CreateDirectTuneWindow(SWinEventMsg event)
934{
935        if (DST_GetWin(WIN_MAIN_MENU)) return;
936        if (DST_GetWin(WIN_FACTORY_MODE)) return;
937        if (DST_IsTuneMode == false) return;
938       
939        CWindow*pWin = NewCWindow(event);
940        pWin->Destructor        = CDirectTuneWin_Destructor;
941        pWin->KeyInput          = CDirectTuneWin_KeyInput;
942        pWin->OnMessage         = CDirectTuneWin_OnMessage;
943        pWin->OnTimer           = CDirectTuneWin_OnTimer;
944        pWin->ShowWindow        = CDirectTuneWin_ShowWindow;
945        pWin->Show                      = CDirectTuneWin_Show;
946        // »ý¼ºÀÚ È£Ãâ
947        CDirectTuneWin_Constructor(pWin, event);
948        // À©µµ¿ì ¸Þ´ÏÀú¿¡ µî·Ï
949        DST_AddWin((WinID)(event.data[0]), pWin);       
950
951}
952
Note: See TracBrowser for help on using the repository browser.