source: svn/trunk/zasc/app_c/DST_WinChannelBanner.c @ 2

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

first commit

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