| [2] | 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 | |
|---|
| 11 | #if 0 |
|---|
| 12 | ____CChannelBannerWin___() |
|---|
| 13 | #endif |
|---|
| 14 | |
|---|
| 15 | static DS_U8* NumToImage(DS_U8 num) |
|---|
| 16 | { |
|---|
| 17 | switch(num) |
|---|
| 18 | { |
|---|
| 19 | case 0: return DST_channelbanner_0_480; |
|---|
| 20 | case 1: return DST_channelbanner_1_480; |
|---|
| 21 | case 2: return DST_channelbanner_2_480; |
|---|
| 22 | case 3: return DST_channelbanner_3_480; |
|---|
| 23 | case 4: return DST_channelbanner_4_480; |
|---|
| 24 | case 5: return DST_channelbanner_5_480; |
|---|
| 25 | case 6: return DST_channelbanner_6_480; |
|---|
| 26 | case 7: return DST_channelbanner_7_480; |
|---|
| 27 | case 8: return DST_channelbanner_8_480; |
|---|
| 28 | case 9: return DST_channelbanner_9_480; |
|---|
| 29 | } |
|---|
| 30 | return DST_channelbanner_0_480; |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | static DS_U8* NumToImageSmall(DS_U8 num) |
|---|
| 34 | { |
|---|
| 35 | switch(num) |
|---|
| 36 | { |
|---|
| 37 | case 0: return DST_channelbanner_0_s_480; |
|---|
| 38 | case 1: return DST_channelbanner_1_s_480; |
|---|
| 39 | case 2: return DST_channelbanner_2_s_480; |
|---|
| 40 | case 3: return DST_channelbanner_3_s_480; |
|---|
| 41 | case 4: return DST_channelbanner_4_s_480; |
|---|
| 42 | case 5: return DST_channelbanner_5_s_480; |
|---|
| 43 | case 6: return DST_channelbanner_6_s_480; |
|---|
| 44 | case 7: return DST_channelbanner_7_s_480; |
|---|
| 45 | case 8: return DST_channelbanner_8_s_480; |
|---|
| 46 | case 9: return DST_channelbanner_9_s_480; |
|---|
| 47 | } |
|---|
| 48 | return DST_channelbanner_0_s_480; |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | DS_U32* DST_UTF82Uni(DS_U8 *utf); |
|---|
| 52 | void DST_Tune(DS_U8 RF, DS_U16 program_number); |
|---|
| 53 | |
|---|
| 54 | class CChannelBannerWin : public CWindow |
|---|
| 55 | { |
|---|
| 56 | private: |
|---|
| 57 | int nCh_Major; |
|---|
| 58 | int nCh_Minor; |
|---|
| 59 | DS_U8 bannerType; |
|---|
| 60 | DS_U32 *chName; |
|---|
| 61 | // SourceChange sc; |
|---|
| 62 | bool bPrimaryChannel; |
|---|
| 63 | int nChIndex; |
|---|
| 64 | int nStrLen; |
|---|
| 65 | DS_U8 pImage[72*36]; |
|---|
| 66 | char strLogo[6]; |
|---|
| 67 | DS_U8 nWidth; |
|---|
| 68 | DS_U8 nHeight; |
|---|
| 69 | int nLogoState; |
|---|
| 70 | bool bTuned; |
|---|
| 71 | bool bHyphened; |
|---|
| 72 | bool bNeedBack2CurrentChannel; |
|---|
| 73 | int maxMajorPosition; |
|---|
| 74 | int maxMinorPosition; |
|---|
| 75 | public: |
|---|
| 76 | CChannelBannerWin(SWinEventMsg event):CWindow(event) |
|---|
| 77 | { |
|---|
| 78 | T(); |
|---|
| 79 | chName = 0; |
|---|
| 80 | nCh_Major = 0; |
|---|
| 81 | nCh_Minor = 0; |
|---|
| 82 | CDB db; |
|---|
| 83 | db.GetTable("select max(major), max(minor) from channel_db"); |
|---|
| 84 | maxMajorPosition = getPositionNumber(atoi(db.GetResult(2))); |
|---|
| 85 | maxMinorPosition = getPositionNumber(atoi(db.GetResult(3))); |
|---|
| 86 | // sc = GetLastSendMsg(); |
|---|
| 87 | bNeedBack2CurrentChannel = false; |
|---|
| 88 | |
|---|
| 89 | bannerType = event.data[2]; |
|---|
| 90 | |
|---|
| 91 | rect.w = DST_GetImageWidth(channel_banner_720480); |
|---|
| 92 | rect.h = DST_GetImageHeight(channel_banner_720480); |
|---|
| 93 | rect.x = DST_GetScreenWidth() - rect.w - (DST_GetScreenWidth() / 20); |
|---|
| 94 | rect.y = DST_GetScreenHeight() / 20; |
|---|
| 95 | |
|---|
| 96 | SetTimeOut(3); |
|---|
| 97 | bTuned = false; |
|---|
| 98 | bHyphened = false; |
|---|
| 99 | RegisterUnregisterDigitKey(true); |
|---|
| 100 | switch(bannerType) |
|---|
| 101 | { |
|---|
| 102 | case BANNER_NORMAL: |
|---|
| 103 | SetTimeOut(event.data[3]); |
|---|
| 104 | break; |
|---|
| 105 | case BANNER_DIGIT: |
|---|
| 106 | SetTimeOut(3); |
|---|
| 107 | KeyInput(eventInit.data[3], false); |
|---|
| 108 | break; |
|---|
| 109 | } |
|---|
| 110 | } |
|---|
| 111 | virtual ~CChannelBannerWin() |
|---|
| 112 | { |
|---|
| 113 | if (chName) DST_OS_Free(&chName); |
|---|
| 114 | if(bannerType == BANNER_DIGIT && bNeedBack2CurrentChannel == true) |
|---|
| 115 | { |
|---|
| 116 | DST_CreateWin(WIN_CHANNEL_BANNER, WIN_NULL, BANNER_NORMAL, 3); |
|---|
| 117 | } |
|---|
| 118 | } |
|---|
| 119 | virtual void OnMessage(SWinEventMsg event) |
|---|
| 120 | { |
|---|
| 121 | switch (event.cmd) |
|---|
| 122 | { |
|---|
| 123 | case WM_CT_MSG: // Æ©´× ½ÃÀÛ ¸Þ½ÃÁö¸¦ ¹ÞÀ¸¸é °»½Å |
|---|
| 124 | if (event.data32[0] == CT_TUNE_START) |
|---|
| 125 | { |
|---|
| 126 | T(); |
|---|
| 127 | Show(); |
|---|
| 128 | SetTimeOut(3); |
|---|
| 129 | } |
|---|
| 130 | break; |
|---|
| 131 | case WM_POWER_OFF: |
|---|
| 132 | Close(); |
|---|
| 133 | break; |
|---|
| 134 | } |
|---|
| 135 | } |
|---|
| 136 | void RegisterUnregisterDigitKey(bool bState) |
|---|
| 137 | { |
|---|
| 138 | switch(bannerType) |
|---|
| 139 | { |
|---|
| 140 | case BANNER_NORMAL: |
|---|
| 141 | RegisterKey(VK_CANCEL, bState); |
|---|
| 142 | break; |
|---|
| 143 | case BANNER_DIGIT: |
|---|
| 144 | RegisterKey(VK_0, bState); |
|---|
| 145 | RegisterKey(VK_1, bState); |
|---|
| 146 | RegisterKey(VK_2, bState); |
|---|
| 147 | RegisterKey(VK_3, bState); |
|---|
| 148 | RegisterKey(VK_4, bState); |
|---|
| 149 | RegisterKey(VK_5, bState); |
|---|
| 150 | RegisterKey(VK_6, bState); |
|---|
| 151 | RegisterKey(VK_7, bState); |
|---|
| 152 | RegisterKey(VK_8, bState); |
|---|
| 153 | RegisterKey(VK_9, bState); |
|---|
| 154 | RegisterKey(VK_OK, bState); |
|---|
| 155 | RegisterKey(VK_CANCEL, bState); |
|---|
| 156 | RegisterKey(VK_HYPHEN, bState); |
|---|
| 157 | break; |
|---|
| 158 | } |
|---|
| 159 | |
|---|
| 160 | } |
|---|
| 161 | |
|---|
| 162 | |
|---|
| 163 | virtual void Show(WinID id) |
|---|
| 164 | { |
|---|
| 165 | switch(id) |
|---|
| 166 | { |
|---|
| 167 | case WIN_EWS: |
|---|
| 168 | case WIN_FACTORY_MODE: |
|---|
| 169 | //case WIN_CHANNEL_BANNER: |
|---|
| 170 | case WIN_DIRECT_TUNE: |
|---|
| 171 | case WIN_VOLUME: |
|---|
| 172 | case WIN_VOLUME_MUTE: |
|---|
| 173 | case WIN_SIGNAL_METER: |
|---|
| 174 | case WIN_CLOSED_CAPTION_HOT: |
|---|
| 175 | case WIN_AUDIO_HOT: |
|---|
| 176 | case WIN_DISPLAY_MODE_HOT: |
|---|
| 177 | case WIN_FACTORY_RESET: |
|---|
| 178 | case WIN_FACTORY_RESET_ASK: |
|---|
| 179 | case WIN_INFOR_BANNER: |
|---|
| 180 | case WIN_MAIN_MENU: |
|---|
| 181 | case WIN_POWER_DOWN_CAUTION: |
|---|
| 182 | case WIN_SUB_MENU_2DEPTH: |
|---|
| 183 | case WIN_SUB_MENU_3DEPTH: |
|---|
| 184 | case WIN_SUB_MENU_4DEPTH: |
|---|
| 185 | case WIN_AUTO_SEARCH: |
|---|
| 186 | case WIN_MANUAL_SEARCH: |
|---|
| 187 | case WIN_CHANNEL_LIST: |
|---|
| 188 | case WIN_PROGRAM_GUIDE: |
|---|
| 189 | case WIN_OTC_DOWNLOAD: |
|---|
| 190 | case WIN_OTC_DOWNLOAD_FAIL: |
|---|
| 191 | case WIN_RF_UPDATE: |
|---|
| 192 | Close(); |
|---|
| 193 | break; |
|---|
| 194 | default: |
|---|
| 195 | break; |
|---|
| 196 | } |
|---|
| 197 | } |
|---|
| 198 | |
|---|
| 199 | virtual void Show() |
|---|
| 200 | { |
|---|
| 201 | Draw(); |
|---|
| 202 | RegisterUnregisterDigitKey(true); |
|---|
| 203 | } |
|---|
| 204 | |
|---|
| 205 | void Draw() |
|---|
| 206 | { |
|---|
| 207 | // ¹è°æÈ¸é ±×¸®±â |
|---|
| 208 | int xPos = 0; |
|---|
| 209 | DrawImage(0, 0, channel_banner_720480); |
|---|
| 210 | |
|---|
| 211 | // TVÀÎ °æ¿ì |
|---|
| 212 | setFontStyle(20, 0xFFC8C8C8, ALIGN_MIDDLE, ALIGN_CENTER); |
|---|
| 213 | |
|---|
| 214 | CDB db; |
|---|
| 215 | int nPos = -1; |
|---|
| 216 | int nChCount = 0; |
|---|
| 217 | int major = 0; |
|---|
| 218 | int minor = 0; |
|---|
| 219 | int majorPosition = 0; |
|---|
| 220 | int minorPosition = 0; |
|---|
| 221 | char *name = 0; |
|---|
| 222 | if(bannerType == BANNER_NORMAL) |
|---|
| 223 | { |
|---|
| 224 | |
|---|
| 225 | db.GetTable("select major, minor, name from channel_db where rf = %d and program_number = %d order by major, minor, rf", DST_EEPROM_GetRF(), DST_EEPROM_GetProgramNumber()); |
|---|
| 226 | if(db.GetRow() < 1) |
|---|
| 227 | { |
|---|
| 228 | db.GetTable("select major, minor, name from channel_db where rf = %d order by major, minor, rf", DST_EEPROM_GetRF()); |
|---|
| 229 | } |
|---|
| 230 | |
|---|
| 231 | nChCount = db.GetRow(); |
|---|
| 232 | DST_Printf("nChCount = %d\n",nChCount); |
|---|
| 233 | major = DST_GetFrequencyNumberbyIndex(DST_EEPROM_GetRF()); |
|---|
| 234 | minor = 0; |
|---|
| 235 | if (nChCount) |
|---|
| 236 | { |
|---|
| 237 | nPos = 0; |
|---|
| 238 | nChCount = 2; // ¸¶ÀÌ³Ê Ç¥½ÃµÇµµ·Ï °Á¦·Î 2·Î º¯°æÇÔ |
|---|
| 239 | major = atoi(db.GetResult(3)); |
|---|
| 240 | minor = atoi(db.GetResult(4)); |
|---|
| 241 | name = db.GetResult(5); |
|---|
| 242 | bHyphened = true; |
|---|
| 243 | } |
|---|
| 244 | } |
|---|
| 245 | else |
|---|
| 246 | { |
|---|
| 247 | nPos = 0; |
|---|
| 248 | if(nCh_Minor == 0) |
|---|
| 249 | { |
|---|
| 250 | nChCount = 1; |
|---|
| 251 | } |
|---|
| 252 | bool bFound = true; |
|---|
| 253 | db.GetTable("select name from channel_db where rf=%d and program_number=%d order by major, minor, rf", DST_DB_GetRF(nCh_Major, nCh_Minor, &bFound), DST_DB_GetProgramNumber(nCh_Major,nCh_Minor)); |
|---|
| 254 | major = nCh_Major; |
|---|
| 255 | minor = nCh_Minor; |
|---|
| 256 | if(db.GetRow() > 0) |
|---|
| 257 | name = db.GetResult(1); |
|---|
| 258 | |
|---|
| 259 | } |
|---|
| 260 | majorPosition = getPositionNumber(major); |
|---|
| 261 | minorPosition = getPositionNumber(minor); |
|---|
| 262 | |
|---|
| 263 | // ä³ÎÀ̸§ Ç¥½Ã |
|---|
| 264 | if (nPos < 0 || name == 0) // ä³Î¸Ê¿¡ ¾ø´Â ä³ÎÀÎ °æ¿ì |
|---|
| 265 | { |
|---|
| 266 | bNeedBack2CurrentChannel = true; |
|---|
| 267 | DrawTextUni(0, 0, rect.w, 47, pz_Digital[OSD_Lang], &font); // Digital |
|---|
| 268 | |
|---|
| 269 | } |
|---|
| 270 | else |
|---|
| 271 | { |
|---|
| 272 | bNeedBack2CurrentChannel = false; |
|---|
| 273 | DS_U32* strText32 = DST_UTF82Uni((DS_U8*)name); |
|---|
| 274 | DrawText32(0, 0, rect.w, 47, strText32, &font); |
|---|
| 275 | |
|---|
| 276 | //DST_OS_Free(&strText32); |
|---|
| 277 | } |
|---|
| 278 | DS_U8 *img[9] = {0,}; |
|---|
| 279 | int numberLenth = majorPosition+minorPosition+((bHyphened && minor != 0)?1:0); |
|---|
| 280 | int nTotalWidth = 0; |
|---|
| 281 | int index = 0; |
|---|
| 282 | for(int i=majorPosition;i>0;i--) |
|---|
| 283 | { |
|---|
| 284 | img[index] = NumToImage((major/getPowerOfTen(i-1))%10); |
|---|
| 285 | nTotalWidth += DST_GetImageWidth(img[index]); |
|---|
| 286 | index++; |
|---|
| 287 | } |
|---|
| 288 | |
|---|
| 289 | if(bHyphened && minor != 0) |
|---|
| 290 | { |
|---|
| 291 | img[index] = DST_channelbanner_dash_480; |
|---|
| 292 | nTotalWidth += DST_GetImageWidth(img[majorPosition]); |
|---|
| 293 | index++; |
|---|
| 294 | } |
|---|
| 295 | |
|---|
| 296 | for(int i=minorPosition;i>0;i--) |
|---|
| 297 | { |
|---|
| 298 | img[index] = NumToImageSmall((minor/getPowerOfTen(i-1))%10); |
|---|
| 299 | nTotalWidth += DST_GetImageWidth(img[index]); |
|---|
| 300 | index++; |
|---|
| 301 | } |
|---|
| 302 | |
|---|
| 303 | xPos = (rect.w - nTotalWidth) / 2; |
|---|
| 304 | for(int i=0;i<numberLenth;i++) |
|---|
| 305 | { |
|---|
| 306 | int yPos = 0; |
|---|
| 307 | if(i < majorPosition) |
|---|
| 308 | { |
|---|
| 309 | yPos = 68; |
|---|
| 310 | } |
|---|
| 311 | else |
|---|
| 312 | { |
|---|
| 313 | if(i == majorPosition && bHyphened) |
|---|
| 314 | yPos = 86; |
|---|
| 315 | else |
|---|
| 316 | yPos = 79; |
|---|
| 317 | } |
|---|
| 318 | DrawImage(xPos, yPos, img[i], true); |
|---|
| 319 | xPos += DST_GetImageWidth(img[i]); |
|---|
| 320 | } |
|---|
| 321 | |
|---|
| 322 | } |
|---|
| 323 | |
|---|
| 324 | virtual void OnTimer(char nID) |
|---|
| 325 | { |
|---|
| 326 | switch (nID) |
|---|
| 327 | { |
|---|
| 328 | case 1: |
|---|
| 329 | { |
|---|
| 330 | KillTimer(1); |
|---|
| 331 | bTuned = true; |
|---|
| 332 | bool bFound = true; |
|---|
| 333 | int RF = DST_DB_GetRF(nCh_Major, nCh_Minor, &bFound); |
|---|
| 334 | T(); |
|---|
| 335 | if (DST_DB_PresentMatchChannel(RF, nCh_Major, nCh_Minor )) |
|---|
| 336 | DST_UI_ChannelTune(bFound?RF:DST_MinRF(), DST_DB_GetProgramNumber(nCh_Major,nCh_Minor)); |
|---|
| 337 | } |
|---|
| 338 | break; |
|---|
| 339 | default: |
|---|
| 340 | break; |
|---|
| 341 | } |
|---|
| 342 | } |
|---|
| 343 | |
|---|
| 344 | int getPositionNumber(int number) |
|---|
| 345 | { |
|---|
| 346 | int pos = 0; |
|---|
| 347 | while(number>0) |
|---|
| 348 | { |
|---|
| 349 | number = number/10; |
|---|
| 350 | pos++; |
|---|
| 351 | } |
|---|
| 352 | return pos; |
|---|
| 353 | } |
|---|
| 354 | |
|---|
| 355 | int getPowerOfTen(int x) |
|---|
| 356 | { |
|---|
| 357 | int ret = 1; |
|---|
| 358 | for(int i=0;i<x;i++) |
|---|
| 359 | ret*= 10; |
|---|
| 360 | return ret; |
|---|
| 361 | } |
|---|
| 362 | |
|---|
| 363 | int getMaxTuneNumber(int x) |
|---|
| 364 | { |
|---|
| 365 | int ret = 0; |
|---|
| 366 | for(int i=0;i<x;i++) |
|---|
| 367 | ret+= getPowerOfTen(i); |
|---|
| 368 | |
|---|
| 369 | DST_Printf("ret = %d\n",ret); |
|---|
| 370 | return 9*ret; |
|---|
| 371 | } |
|---|
| 372 | |
|---|
| 373 | virtual void KeyInput(DS_U8 key, bool /*bRepeat*/) |
|---|
| 374 | { |
|---|
| 375 | bool bMatch = false; |
|---|
| 376 | int nCount = 0; |
|---|
| 377 | // DST_Printf("\n banner key:%d, key:%d\n",key,key-VK_0); |
|---|
| 378 | switch (key) |
|---|
| 379 | { |
|---|
| 380 | case VK_0: |
|---|
| 381 | case VK_1: |
|---|
| 382 | case VK_2: |
|---|
| 383 | case VK_3: |
|---|
| 384 | case VK_4: |
|---|
| 385 | case VK_5: |
|---|
| 386 | case VK_6: |
|---|
| 387 | case VK_7: |
|---|
| 388 | case VK_8: |
|---|
| 389 | case VK_9: |
|---|
| 390 | { |
|---|
| 391 | |
|---|
| 392 | if(nCh_Minor > (DS_U16)getMaxTuneNumber(maxMinorPosition)) |
|---|
| 393 | { |
|---|
| 394 | bTuned = false; |
|---|
| 395 | bHyphened = false; |
|---|
| 396 | nCh_Major = 0; |
|---|
| 397 | nCh_Minor = 0; |
|---|
| 398 | } |
|---|
| 399 | |
|---|
| 400 | if(bHyphened) |
|---|
| 401 | nCh_Minor = (nCh_Minor>0)?( nCh_Minor * 10 + ( key - VK_0)):(key - VK_0); |
|---|
| 402 | else |
|---|
| 403 | nCh_Major = nCh_Major * 10 + ( key - VK_0); |
|---|
| 404 | |
|---|
| 405 | DST_Printf("nCh_Minor=%d,nCh_Major=%d\n",nCh_Minor,nCh_Major); |
|---|
| 406 | if(bTuned) |
|---|
| 407 | { |
|---|
| 408 | bTuned = false; |
|---|
| 409 | bHyphened = false; |
|---|
| 410 | nCh_Major = key - VK_0; |
|---|
| 411 | nCh_Minor = 0; |
|---|
| 412 | } |
|---|
| 413 | |
|---|
| 414 | if(bHyphened) |
|---|
| 415 | { |
|---|
| 416 | if(nCh_Minor > (DS_U16)getMaxTuneNumber(maxMinorPosition)) |
|---|
| 417 | { |
|---|
| 418 | bHyphened = false; |
|---|
| 419 | nCh_Major = key - VK_0; |
|---|
| 420 | nCh_Minor = 0; |
|---|
| 421 | } |
|---|
| 422 | } |
|---|
| 423 | else |
|---|
| 424 | { |
|---|
| 425 | if(nCh_Major > (DS_U16)getMaxTuneNumber(maxMajorPosition)) |
|---|
| 426 | nCh_Major = key - VK_0; |
|---|
| 427 | } |
|---|
| 428 | |
|---|
| 429 | |
|---|
| 430 | nCount = DST_DB_AvailableChannelCount(nCh_Major); |
|---|
| 431 | DST_Printf("nCount = %d \n\n",nCount); |
|---|
| 432 | if (nCount == 0) // ÀÏÄ¡ÇÏ´Â Á¤º¸°¡ ¾ø´Â °æ¿ì ¹Ù·Î ´Ý´Â´Ù. |
|---|
| 433 | { |
|---|
| 434 | Draw(); |
|---|
| 435 | KillTimer(1); |
|---|
| 436 | break; |
|---|
| 437 | } |
|---|
| 438 | bool bFound = true; |
|---|
| 439 | bMatch = DST_DB_PresentMatchChannel(DST_DB_GetRF(nCh_Major, nCh_Minor, &bFound), nCh_Major, bFound==true?nCh_Minor:1); |
|---|
| 440 | // if ((bMatch && nCount ==1 && nCh_Minor !=0) || (bMatch && nCh_Minor !=0)) // ÀÏÄ¡Çϴ ä³ÎÀÌ À¯ÀÏÇÑ °æ¿ì Áï½Ã Æ©´× |
|---|
| 441 | // { |
|---|
| 442 | // SetTimer(1, 50); |
|---|
| 443 | // Draw(); |
|---|
| 444 | // break; |
|---|
| 445 | // } |
|---|
| 446 | if (bMatch) // Á¤È®È÷ ÀÏÄ¡Çϴ ä³ÎÀÌ ÀÖ´Ù¸é 2ÃÊÈÄ¿¡ Æ©´×ÇÑ´Ù. |
|---|
| 447 | { |
|---|
| 448 | SetTimer(1, 2000); |
|---|
| 449 | Draw(); |
|---|
| 450 | break; |
|---|
| 451 | } |
|---|
| 452 | Draw(); |
|---|
| 453 | } |
|---|
| 454 | break; |
|---|
| 455 | |
|---|
| 456 | case VK_HYPHEN: |
|---|
| 457 | bHyphened = true; |
|---|
| 458 | Draw(); |
|---|
| 459 | break; |
|---|
| 460 | |
|---|
| 461 | case VK_OK: |
|---|
| 462 | { |
|---|
| 463 | bool bFound = true; |
|---|
| 464 | int RF = DST_DB_GetRF(nCh_Major, nCh_Minor, &bFound); |
|---|
| 465 | if (DST_DB_PresentMatchChannel(RF, nCh_Major, nCh_Minor )) |
|---|
| 466 | DST_UI_ChannelTune(bFound?RF:DST_MinRF(), DST_DB_GetProgramNumber(nCh_Major,nCh_Minor)); |
|---|
| 467 | Close(); |
|---|
| 468 | } |
|---|
| 469 | break; |
|---|
| 470 | case VK_CANCEL: |
|---|
| 471 | Close(); |
|---|
| 472 | break; |
|---|
| 473 | } |
|---|
| 474 | } |
|---|
| 475 | |
|---|
| 476 | }; |
|---|
| 477 | |
|---|
| 478 | bool DST_IsTuneMode(); |
|---|
| 479 | |
|---|
| 480 | void DST_CreateChannelBannerWindow(SWinEventMsg event) |
|---|
| 481 | { |
|---|
| 482 | |
|---|
| 483 | if (DST_GetWin(WIN_OTC_DOWNLOAD)) return; |
|---|
| 484 | if (DST_GetWin(WIN_OTC_DOWNLOAD_FAIL)) return; |
|---|
| 485 | if (DST_GetWin(WIN_MANUAL_SEARCH)) return; |
|---|
| 486 | if (DST_GetWin(WIN_AUTO_SEARCH)) return; |
|---|
| 487 | if (DST_GetWin(WIN_CHANNEL_LIST)) return; |
|---|
| 488 | if (DST_GetWin(WIN_PROGRAM_GUIDE)) return; |
|---|
| 489 | if (DST_GetWin(WIN_MAIN_MENU)) return; |
|---|
| 490 | if (DST_GetWin(WIN_INFOR_BANNER) && event.data[2] == BANNER_NORMAL) return; |
|---|
| 491 | if (DST_GetWin(WIN_FACTORY_MODE)) return; |
|---|
| 492 | |
|---|
| 493 | // if (DST_GetWin(WIN_DIRECT_TUNE)) return; |
|---|
| 494 | |
|---|
| 495 | // SourceChange sc=GetLastSendMsg(); |
|---|
| 496 | // if(sc.AutoScan) return; |
|---|
| 497 | // if(sc.RF == 0) return; |
|---|
| 498 | // if (DST_IsTuneMode() == false) return; |
|---|
| 499 | DST_AddWin((WinID)(event.data[0]), new CChannelBannerWin(event)); |
|---|
| 500 | } |
|---|
| 501 | |
|---|
| 502 | |
|---|
| 503 | class CDirectTuneWin : public CWindow |
|---|
| 504 | { |
|---|
| 505 | private: |
|---|
| 506 | int nRF; |
|---|
| 507 | int nRFIndex; |
|---|
| 508 | int nRFIndex_Old; |
|---|
| 509 | DS_U32 *chName; |
|---|
| 510 | // SourceChange sc; |
|---|
| 511 | bool bPrimaryChannel; |
|---|
| 512 | int nStrLen; |
|---|
| 513 | DS_U8 pImage[72*36]; |
|---|
| 514 | char strLogo[6]; |
|---|
| 515 | DS_U8 nWidth; |
|---|
| 516 | DS_U8 nHeight; |
|---|
| 517 | int nLogoState; |
|---|
| 518 | bool bTuned; |
|---|
| 519 | bool bFirst; |
|---|
| 520 | bool bNeedBack2CurrentChannel; |
|---|
| 521 | public: |
|---|
| 522 | CDirectTuneWin(SWinEventMsg event):CWindow(event) |
|---|
| 523 | { |
|---|
| 524 | chName = 0; |
|---|
| 525 | // sc = GetLastSendMsg(); |
|---|
| 526 | |
|---|
| 527 | DS_U8 RF = 0; |
|---|
| 528 | DS_U16 sID = 0; |
|---|
| 529 | DST_GetAVState(&RF, 0, &sID); |
|---|
| 530 | nRFIndex = RF; |
|---|
| 531 | nRFIndex_Old = nRFIndex; |
|---|
| 532 | nRF = DST_GetFrequencyNumberbyIndex(nRFIndex); |
|---|
| 533 | |
|---|
| 534 | rect.w = DST_GetImageWidth(channel_banner_720480); |
|---|
| 535 | rect.h = DST_GetImageHeight(channel_banner_720480); |
|---|
| 536 | rect.x = DST_GetScreenWidth() - rect.w - (DST_GetScreenWidth() / 20); |
|---|
| 537 | rect.y = DST_GetScreenHeight() / 20; |
|---|
| 538 | |
|---|
| 539 | SetTimeOut(3); |
|---|
| 540 | bTuned = false; |
|---|
| 541 | bFirst = true; |
|---|
| 542 | bNeedBack2CurrentChannel = false; |
|---|
| 543 | RegisterUnregisterDigitKey(true); |
|---|
| 544 | } |
|---|
| 545 | virtual ~CDirectTuneWin() |
|---|
| 546 | { |
|---|
| 547 | if (chName) DST_OS_Free(&chName); |
|---|
| 548 | // if (bNeedBack2CurrentChannel) |
|---|
| 549 | // { |
|---|
| 550 | if(DST_GetWin(WIN_CHANNEL_BANNER) != 0) |
|---|
| 551 | DST_CloseWin(WIN_CHANNEL_BANNER); |
|---|
| 552 | DST_CreateWin(WIN_CHANNEL_BANNER, WIN_NULL, BANNER_NORMAL, 3); |
|---|
| 553 | // } |
|---|
| 554 | |
|---|
| 555 | } |
|---|
| 556 | virtual void OnMessage(SWinEventMsg event) |
|---|
| 557 | { |
|---|
| 558 | switch (event.cmd) |
|---|
| 559 | { |
|---|
| 560 | case WM_POWER_OFF: |
|---|
| 561 | Close(); |
|---|
| 562 | break; |
|---|
| 563 | } |
|---|
| 564 | } |
|---|
| 565 | void RegisterUnregisterDigitKey(bool bState) |
|---|
| 566 | { |
|---|
| 567 | RegisterKey(VK_0, bState); |
|---|
| 568 | RegisterKey(VK_1, bState); |
|---|
| 569 | RegisterKey(VK_2, bState); |
|---|
| 570 | RegisterKey(VK_3, bState); |
|---|
| 571 | RegisterKey(VK_4, bState); |
|---|
| 572 | RegisterKey(VK_5, bState); |
|---|
| 573 | RegisterKey(VK_6, bState); |
|---|
| 574 | RegisterKey(VK_7, bState); |
|---|
| 575 | RegisterKey(VK_8, bState); |
|---|
| 576 | RegisterKey(VK_9, bState); |
|---|
| 577 | RegisterKey(VK_OK, bState); |
|---|
| 578 | RegisterKey(VK_CANCEL, bState); |
|---|
| 579 | RegisterKey(VK_UP, bState); |
|---|
| 580 | RegisterKey(VK_DN, bState); |
|---|
| 581 | RegisterKey(VK_HYPHEN, bState); |
|---|
| 582 | |
|---|
| 583 | } |
|---|
| 584 | |
|---|
| 585 | |
|---|
| 586 | virtual void Show(WinID id) |
|---|
| 587 | { |
|---|
| 588 | switch(id) |
|---|
| 589 | { |
|---|
| 590 | case WIN_FACTORY_MODE: |
|---|
| 591 | case WIN_EWS: |
|---|
| 592 | case WIN_CHANNEL_BANNER: |
|---|
| 593 | case WIN_VOLUME: |
|---|
| 594 | case WIN_VOLUME_MUTE: |
|---|
| 595 | case WIN_SIGNAL_METER: |
|---|
| 596 | case WIN_CLOSED_CAPTION_HOT: |
|---|
| 597 | case WIN_AUDIO_HOT: |
|---|
| 598 | case WIN_DISPLAY_MODE_HOT: |
|---|
| 599 | case WIN_FACTORY_RESET: |
|---|
| 600 | case WIN_FACTORY_RESET_ASK: |
|---|
| 601 | case WIN_INFOR_BANNER: |
|---|
| 602 | case WIN_MAIN_MENU: |
|---|
| 603 | case WIN_POWER_DOWN_CAUTION: |
|---|
| 604 | case WIN_SUB_MENU_2DEPTH: |
|---|
| 605 | case WIN_SUB_MENU_3DEPTH: |
|---|
| 606 | case WIN_SUB_MENU_4DEPTH: |
|---|
| 607 | case WIN_AUTO_SEARCH: |
|---|
| 608 | case WIN_MANUAL_SEARCH: |
|---|
| 609 | case WIN_CHANNEL_LIST: |
|---|
| 610 | case WIN_PROGRAM_GUIDE: |
|---|
| 611 | case WIN_OTC_DOWNLOAD: |
|---|
| 612 | case WIN_OTC_DOWNLOAD_FAIL: |
|---|
| 613 | case WIN_UPDATE: |
|---|
| 614 | case WIN_UPDATE_RESET: |
|---|
| 615 | Close(); |
|---|
| 616 | break; |
|---|
| 617 | default: |
|---|
| 618 | break; |
|---|
| 619 | } |
|---|
| 620 | } |
|---|
| 621 | |
|---|
| 622 | virtual void Show() |
|---|
| 623 | { |
|---|
| 624 | Draw(); |
|---|
| 625 | RegisterUnregisterDigitKey(true); |
|---|
| 626 | } |
|---|
| 627 | |
|---|
| 628 | void Draw() |
|---|
| 629 | { |
|---|
| 630 | // ¹è°æÈ¸é ±×¸®±â |
|---|
| 631 | int xPos = 0; |
|---|
| 632 | DrawImage(0, 0, channel_banner_720480); |
|---|
| 633 | |
|---|
| 634 | // TVÀÎ °æ¿ì |
|---|
| 635 | setFontStyle(20, 0xFFC8C8C8, ALIGN_MIDDLE, ALIGN_CENTER); |
|---|
| 636 | |
|---|
| 637 | CDB db; |
|---|
| 638 | char name[3] = {0,}; |
|---|
| 639 | sprintf(name,"%s","RF"); |
|---|
| 640 | // ä³ÎÀ̸§ Ç¥½Ã |
|---|
| 641 | DS_U32* strText32 = DST_UTF82Uni((DS_U8*)name); // È£ÃâÇÑ ÂÊ¿¡¼ ¸Þ¸ð¸® ÇØÁ¦ |
|---|
| 642 | DrawText32(0, 0, rect.w, 47, strText32, &font); |
|---|
| 643 | |
|---|
| 644 | // ä³Î ¼ýÀÚ Ç¥½Ã |
|---|
| 645 | DS_U8 *img[9] = {0,}; |
|---|
| 646 | int numberLenth = getPositionNumber(nRF); |
|---|
| 647 | int nTotalWidth = 0; |
|---|
| 648 | int index = 0; |
|---|
| 649 | for(int i=numberLenth;i>0;i--) |
|---|
| 650 | { |
|---|
| 651 | img[index] = NumToImage((nRF/getPowerOfTen(i-1))%10); |
|---|
| 652 | nTotalWidth += DST_GetImageWidth(img[index]); |
|---|
| 653 | index++; |
|---|
| 654 | } |
|---|
| 655 | |
|---|
| 656 | xPos = (rect.w - nTotalWidth) / 2; |
|---|
| 657 | for(int i=0;i<numberLenth;i++) |
|---|
| 658 | { |
|---|
| 659 | DrawImage(xPos, 68, img[i], true); |
|---|
| 660 | xPos += DST_GetImageWidth(img[i]); |
|---|
| 661 | } |
|---|
| 662 | |
|---|
| 663 | |
|---|
| 664 | |
|---|
| 665 | } |
|---|
| 666 | |
|---|
| 667 | int getPositionNumber(int number) |
|---|
| 668 | { |
|---|
| 669 | int pos = 0; |
|---|
| 670 | while(number>0) |
|---|
| 671 | { |
|---|
| 672 | number = number/10; |
|---|
| 673 | pos++; |
|---|
| 674 | } |
|---|
| 675 | return pos; |
|---|
| 676 | } |
|---|
| 677 | |
|---|
| 678 | int getPowerOfTen(int x) |
|---|
| 679 | { |
|---|
| 680 | int ret = 1; |
|---|
| 681 | for(int i=0;i<x;i++) |
|---|
| 682 | ret*= 10; |
|---|
| 683 | return ret; |
|---|
| 684 | } |
|---|
| 685 | |
|---|
| 686 | |
|---|
| 687 | virtual void OnTimer(char nID) |
|---|
| 688 | { |
|---|
| 689 | switch (nID) |
|---|
| 690 | { |
|---|
| 691 | case 1: |
|---|
| 692 | { |
|---|
| 693 | KillTimer(1); |
|---|
| 694 | if(nRFIndex > (DS_U16)DST_MaxRF()|| nRFIndex < (DS_U16)DST_MinRF()) |
|---|
| 695 | nRFIndex = nRFIndex_Old; |
|---|
| 696 | |
|---|
| 697 | |
|---|
| 698 | Draw(); |
|---|
| 699 | if(DST_GetIndexByRFNumber(nRF) != 0) |
|---|
| 700 | { |
|---|
| 701 | nRFIndex = DST_GetIndexByRFNumber(nRF); |
|---|
| 702 | bNeedBack2CurrentChannel = false; |
|---|
| 703 | bTuned = true; |
|---|
| 704 | DST_UI_ChannelTune(nRFIndex, 0); |
|---|
| 705 | } |
|---|
| 706 | else |
|---|
| 707 | { |
|---|
| 708 | bNeedBack2CurrentChannel = true; |
|---|
| 709 | } |
|---|
| 710 | nRFIndex_Old = nRFIndex; |
|---|
| 711 | |
|---|
| 712 | SetTimer(2,1000); |
|---|
| 713 | } |
|---|
| 714 | break; |
|---|
| 715 | case 2: |
|---|
| 716 | Close(); |
|---|
| 717 | break; |
|---|
| 718 | default: |
|---|
| 719 | break; |
|---|
| 720 | } |
|---|
| 721 | } |
|---|
| 722 | |
|---|
| 723 | virtual void KeyInput(DS_U8 key, bool /*bRepeat*/) |
|---|
| 724 | { |
|---|
| 725 | // bool bMatch = false; |
|---|
| 726 | // int nCount = 0; |
|---|
| 727 | // DST_Printf("\n banner key:%d, key:%d\n",key,key-VK_0); |
|---|
| 728 | switch (key) |
|---|
| 729 | { |
|---|
| 730 | case VK_UP: |
|---|
| 731 | nRFIndex += 1; |
|---|
| 732 | if(nRFIndex > (DS_U16)DST_MaxRF()) nRFIndex = (DS_U16)DST_MinRF(); |
|---|
| 733 | nRF = DST_GetFrequencyNumberbyIndex(nRFIndex); |
|---|
| 734 | SetTimer(1,10); |
|---|
| 735 | break; |
|---|
| 736 | |
|---|
| 737 | case VK_DN: |
|---|
| 738 | nRFIndex -= 1; |
|---|
| 739 | if(nRFIndex < (DS_U16)DST_MinRF()) nRFIndex = (DS_U16)DST_MaxRF(); |
|---|
| 740 | nRF = DST_GetFrequencyNumberbyIndex(nRFIndex); |
|---|
| 741 | SetTimer(1,10); |
|---|
| 742 | |
|---|
| 743 | break; |
|---|
| 744 | |
|---|
| 745 | case VK_0: |
|---|
| 746 | case VK_1: |
|---|
| 747 | case VK_2: |
|---|
| 748 | case VK_3: |
|---|
| 749 | case VK_4: |
|---|
| 750 | case VK_5: |
|---|
| 751 | case VK_6: |
|---|
| 752 | case VK_7: |
|---|
| 753 | case VK_8: |
|---|
| 754 | case VK_9: |
|---|
| 755 | if(bFirst) nRF = 0; |
|---|
| 756 | nRF = nRF * 10 + ( key - VK_0); |
|---|
| 757 | |
|---|
| 758 | if(bTuned) |
|---|
| 759 | { |
|---|
| 760 | bTuned = false; |
|---|
| 761 | nRF = key - VK_0; |
|---|
| 762 | } |
|---|
| 763 | |
|---|
| 764 | if(DST_GetIndexByRFNumber(nRF) > (DS_U16)DST_MaxRF()|| DST_GetIndexByRFNumber(nRF) < (DS_U16)DST_MinRF()) |
|---|
| 765 | nRF = key - VK_0; |
|---|
| 766 | |
|---|
| 767 | SetTimer(1, 1000); |
|---|
| 768 | Draw(); |
|---|
| 769 | break; |
|---|
| 770 | |
|---|
| 771 | case VK_HYPHEN: |
|---|
| 772 | break; |
|---|
| 773 | |
|---|
| 774 | case VK_OK: |
|---|
| 775 | if(nRFIndex > (DS_U16)DST_MaxRF()|| nRFIndex < (DS_U16)DST_MinRF()) |
|---|
| 776 | nRFIndex = nRFIndex_Old; |
|---|
| 777 | SetTimer(1,10); |
|---|
| 778 | break; |
|---|
| 779 | case VK_CANCEL: |
|---|
| 780 | Close(); |
|---|
| 781 | break; |
|---|
| 782 | } |
|---|
| 783 | |
|---|
| 784 | bFirst = false; |
|---|
| 785 | |
|---|
| 786 | } |
|---|
| 787 | |
|---|
| 788 | |
|---|
| 789 | }; |
|---|
| 790 | |
|---|
| 791 | |
|---|
| 792 | |
|---|
| 793 | void DST_CreateDirectTuneWindow(SWinEventMsg event) |
|---|
| 794 | { |
|---|
| 795 | // if (DST_GetWin(WIN_AUTO_SEARCH)) return; |
|---|
| 796 | // if (DST_GetWin(WIN_CHANNEL_LIST)) return; |
|---|
| 797 | // if (DST_GetWin(WIN_PROGRAM_GUIDE)) return; |
|---|
| 798 | if (DST_GetWin(WIN_MAIN_MENU)) return; |
|---|
| 799 | if (DST_GetWin(WIN_FACTORY_MODE)) return; |
|---|
| 800 | // if (DST_GetWin(WIN_INFOR_BANNER)) return; |
|---|
| 801 | |
|---|
| 802 | // SourceChange sc=GetLastSendMsg(); |
|---|
| 803 | // if(sc.AutoScan) return; |
|---|
| 804 | // if(sc.RF == 0) return; |
|---|
| 805 | if (DST_IsTuneMode == false) return; |
|---|
| 806 | DST_AddWin((WinID)(event.data[0]), new CDirectTuneWin(event)); |
|---|
| 807 | } |
|---|
| 808 | |
|---|
| 809 | |
|---|