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

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

first commit

File size: 8.8 KB
Line 
1#include "DST_WinManager.h"
2#include "DST_OSDImage.h"
3#include "DST_UserInterface.h"
4#include "DST_SignalMonitor.h"
5#include "DST_ChannelTune.h"
6#include "DST_GlobalVariables.h"
7#include "DST_DataStrings.h"
8#include "DST_DB.h"
9#include "DST_ISDBT_ChannelTask.h"
10#include "DST_DB_Engine.h"
11#include "DST_MemoryDB.h"
12
13OSD_PIXEL_T DST_GetAribColor(DS_U8 n);
14DS_U32* DST_UTF82Uni(DS_U8 *utf);
15
16#if 0
17____CInfobannerWin___()
18#endif
19
20//class CInfobannerWin : public CWindow
21//{
22// public:
23//      CInfobannerWin(SWinEventMsg event):CWindow(event)
24        void CInfobannerWin_Constructor(CWindow *this, SWinEventMsg event)
25        {
26                this->SetWinName(this,  "Infobanner");
27                this->rect.w = DST_GetImageWidth(newcon2_gui_infobanner_back);
28                this->rect.h = DST_GetImageHeight(newcon2_gui_infobanner_back);
29                this->rect.x = (DST_GetScreenWidth() - this->rect.w) / 2;
30                this->rect.y = DST_GetScreenHeight() / 20;
31                this->SetTimeOut(this, 100);
32        }
33
34        void CInfobannerWin_Destructor(CWindow *tis)
35        {
36               
37        }
38
39//      virtual void Show(WinID id)
40        void CInfobannerWin_ShowWindow(CWindow *this, WinID id)
41        {
42                switch(id)
43                {
44                        case WIN_DEBUG_SQL:
45                        case WIN_DEBUG_SQL_SUB:
46                        case WIN_ENGINEER_MODE:         
47                        case WIN_EWS:
48                        case WIN_CHANNEL_BANNER:
49                        case WIN_DIRECT_TUNE:
50                        case WIN_VOLUME:
51                        case WIN_VOLUME_MUTE:
52                        case WIN_SIGNAL_METER:
53                        case WIN_CLOSED_CAPTION_HOT:
54                        case WIN_AUDIO_HOT:
55                        case WIN_DISPLAY_MODE_HOT:
56                        case WIN_FACTORY_RESET:
57                        case WIN_FACTORY_RESET_ASK:
58//                      case WIN_INFOR_BANNER:
59                        case WIN_MAIN_MENU:
60                        case WIN_POWER_DOWN_CAUTION:
61                        case WIN_SUB_MENU_2DEPTH:
62                        case WIN_SUB_MENU_3DEPTH:
63                        case WIN_SUB_MENU_4DEPTH:
64                        case WIN_AUTO_SEARCH:
65                        case WIN_MANUAL_SEARCH:
66                        case WIN_CHANNEL_LIST:
67                        case WIN_PROGRAM_GUIDE:
68                                this->Close(this);
69                                break;
70                        default:
71                                break;
72                }
73        }
74
75        void CInfobannerWin_DrawProgram(CWindow *this, int RF, DS_U16 source_id)
76        {
77#if EPG_SUPPORT
78                DS_U16 time[110] = {0,};
79               
80                if (source_id == 0) return;
81               
82//              CDB db; NewCDB(&db);
83                // ÇöÀç ¹æ¼ÛÁßÀÎ ÇÁ·Î±×·¥À» ã´Â´Ù. ÀÌ¹Ì Á¾·áµÈ ¹æ¼ÛÀ» Á¦¿ÜÇÏ°í °¡Àå ½ÃÀ۽ð£ÀÌ ºü¸¥°É·Î Çϳª °í¸¥´Ù
84//              db.GetTable(&db, "select start_time, length_in_seconds, title from eit_sub "
85//                              "where rf = %d and source_id = %d "
86//                              "and start_time+length_in_seconds >  %d "
87//                              "order by start_time limit 1", RF, source_id, DST_GetCurrentUTCTime());
88                int i;
89                int nPos = -1;
90                DS_U32 min_start_time = 0xFFFFFFFF;             
91                for (i=0; i < DB_EIT_SUB_MAX; i++)
92                {
93                        if (db_eit_sub[i].source_id == 0) continue;
94                        if (db_eit_sub[i].rf != RF) continue;
95                        if (db_eit_sub[i].source_id != source_id) continue;
96                        //DST_Printf("db_eit_sub[%d].rf = %d source_id = %d\n", i, db_eit_sub[i].rf, db_eit_sub[i].source_id);
97                        if (db_eit_sub[i].start_time + db_eit_sub[i].length_in_seconds <= DST_GetCurrentUTCTime()) continue;
98                        if (db_eit_sub[i].start_time < min_start_time)
99                        {
100                                min_start_time = db_eit_sub[i].start_time;
101                                nPos = i;
102                        }
103                }               
104                if(nPos < 0) 
105                {
106                        return;
107                }
108                       
109                this->setFontStyle(this, 20,0xFFC8C8C8,ALIGN_MIDDLE,ALIGN_LEFT);
110                this->DrawTextUTF8(this, 12, 35, 540, 20, db_eit_sub[nPos].title, &(this->font));
111
112                strcpy16(time, DST_GetTimeString(db_eit_sub[nPos].start_time, DATE_NO_YEAR_TIME_NO_SEC_DETAIL,true,DST_g_TimeOffset[RF]));
113                strcat16_8(time, (char *)" - ");
114                strcat16(time, DST_GetTimeString(db_eit_sub[nPos].start_time+ db_eit_sub[nPos].length_in_seconds,TIME_NO_SEC,true,DST_g_TimeOffset[RF]));
115                this->DrawTextUni(this, 12, 65, 540, 20 , time, &(this->font));         
116//              DeleteCDB(&db);
117#endif
118        }
119
120        void CInfobannerWin_DrawTime(CWindow *this, int RF)
121        {
122                DS_U32 curTime = DST_GetCurrentUTCTime();
123                // ÇöÀç½Ã°£ Ç¥½Ã
124                this->setFontStyle(this, 20,0xFFC8C8C8,ALIGN_MIDDLE,ALIGN_RIGHT);
125                // DST_Printf("curTime = %d\n", curTime);
126                if (curTime > 0)
127                {
128                        DS_U16 time[50] = {0,};
129                        strcpy16(time, DST_GetTimeString(curTime,DATE_NO_YEAR_TIME_NO_SEC_DETAIL,true,DST_g_TimeOffset[RF]));
130                        this->DrawTextUni(this, 12, 5, 540, 20, time, &(this->font));
131                }
132        }
133       
134        void CInfobannerWin_DrawChannel(CWindow *this)
135        {
136                // ä³Î À̸§ Ç¥½Ã                       
137                DS_U32 ChInfo[100]={0};
138                DST_UI_GetCurrentChannelInfo(ChInfo);
139                this->setFontStyle(this, 20,0xFFC8C8C8,ALIGN_MIDDLE,ALIGN_LEFT);
140                this->DrawText32(this, 12, 5, 298, 20, ChInfo,  &(this->font));
141        }
142
143        void CInfobannerWin_DrawResolution(CWindow *this)
144        {
145                DS_U8 *image = newcon2_gui_infobanner_hdtv_disable;
146                switch (DST_GetResolutionInfo())
147                {
148                        case  1: image = DST_IsVideoPlay() ? newcon2_gui_infobanner_hdtv_disable : newcon2_gui_infobanner_hdtv_disable; break;
149                        case  2: image = DST_IsVideoPlay() ? newcon2_gui_infobanner_hdtv_disable : newcon2_gui_infobanner_hdtv_disable; break;
150                        case  3: image = DST_IsVideoPlay() ? newcon2_gui_infobanner_hdtv_disable : newcon2_gui_infobanner_hdtv_disable; break;
151                        case  4: image = DST_IsVideoPlay() ? newcon2_gui_infobanner_hdtv_disable : newcon2_gui_infobanner_hdtv_disable; break;
152                        case  5: image = DST_IsVideoPlay() ? newcon2_gui_infobanner_hdtv_disable : newcon2_gui_infobanner_hdtv_disable; break;
153                        case  6: image = DST_IsVideoPlay() ? newcon2_gui_infobanner_hdtv_disable : newcon2_gui_infobanner_hdtv_disable; break;
154                        case  7: image = DST_IsVideoPlay() ? newcon2_gui_infobanner_hdtv_disable : newcon2_gui_infobanner_hdtv_disable; break;
155                        case  8: image = DST_IsVideoPlay() ? newcon2_gui_infobanner_hdtv_enable : newcon2_gui_infobanner_hdtv_disable; break;
156                        case  9: image = DST_IsVideoPlay() ? newcon2_gui_infobanner_hdtv_enable : newcon2_gui_infobanner_hdtv_disable; break;
157                        case 10: image = DST_IsVideoPlay() ? newcon2_gui_infobanner_hdtv_enable : newcon2_gui_infobanner_hdtv_disable; break;
158                }
159                this->DrawImage(this, 12, 128, image, false);
160        }
161       
162        void CInfobannerWin_DrawIcon(CWindow *this, DS_U8 RF, DS_U16 program_number)
163        {
164                DS_U8* image  = newcon2_gui_infobanner_stereo_disable;
165               
166                CInfobannerWin_DrawResolution(this);
167                this->DrawImage(this, 163, 128, DST_UI_GetCCInfo() ? newcon2_gui_infobanner_cc_enable:newcon2_gui_infobanner_cc_disable, false);
168
169                this->DrawImage(this, 118, 128, (CT_GetAudioCount(RF, program_number) > 1) ? newcon2_gui_infobanner_multi_enable : newcon2_gui_infobanner_multi_disable, false);
170                switch (DST_AUD_GetMode())
171                {
172                        case DHL_AUDIO_MONO: image = newcon2_gui_infobanner_stereo_disable; break;// Mono
173                        case DHL_AUDIO_DUAL_MONO: image = newcon2_gui_infobanner_stereo_enable; break; // Dual Mono
174                        case DHL_AUDIO_STEREO:  image = newcon2_gui_infobanner_stereo_enable; break;// Stereo
175                        case DHL_AUDIO_5_1: image = newcon2_gui_infobanner_stereo_disable; break;// 5.1
176                        default: break;
177                }
178                this->DrawImage(this, 73, 128, image, false);
179        }
180       
181        void CInfobannerWin_DrawSignalBar(CWindow *this)
182        {
183                int xPos        = 358;
184                int yPos        = 133;
185                int width   = 183;
186                int range       = 100;
187                int signal      = DST_GetSignalStrength();
188
189                int division =  width/3;
190                int position = (width*signal)/(range);
191
192                int i = 0;
193                //signal meter
194                for ( i=xPos; i < xPos+position; i++)
195                {
196                        if ((i-xPos) <= division)
197                                this->DrawImage(this, i, yPos, newcon2_gui_progress_red, false);
198                        else if ((i-xPos) <= (division*2))
199                                this->DrawImage(this, i, yPos, newcon2_gui_progress_yellow, false);
200                        else
201                                this->DrawImage(this, i, yPos, newcon2_gui_progress_green, false);
202                }
203        }
204
205
206//  virtual void Show(void)
207        void CInfobannerWin_Show(CWindow *this)
208        {       
209                DS_U8 RF = 0;
210                DS_U16 source_id = 0;
211               
212                this->DrawImage(this, 0, 0, newcon2_gui_infobanner_back, false);
213                DST_GetAVState(&RF, 0, &source_id);
214               
215                CInfobannerWin_DrawChannel(this);
216                CInfobannerWin_DrawTime(this, RF);
217                CInfobannerWin_DrawProgram(this, RF, source_id);
218                CInfobannerWin_DrawSignalBar(this);
219                CInfobannerWin_DrawIcon(this, RF, source_id);
220               
221                this->SetTimer(this, 1, 500); // 500ms ¸¶´Ù °»½Å
222                this->RegisterKey(this, VK_OK, true, 0, 0);
223                this->RegisterKey(this, VK_CANCEL, true, 0, 0);
224        }
225
226//      virtual void OnMessage(SWinEventMsg event)
227        void CInfobannerWin_OnMessage(CWindow *this, SWinEventMsg event)
228        {
229                switch (event.cmd)
230                {
231                        case WM_POWER_OFF:
232                                this->Close(this);
233                                break;
234                        case WM_CT_MSG: // Æ©´× ½ÃÀÛ ¸Þ½ÃÁö¸¦ ¹ÞÀ¸¸é °»½Å
235                                if (event.data32[0] == CT_TUNE_START) this->Show(this);
236                                this->SetTimeOut(this, 100);
237                                break;
238                }
239        }
240       
241//      virtual void OnTimer(char /*nID*/)
242        void CInfobannerWin_OnTimer(CWindow *this, char nID)
243        {
244                this->Show(this);
245        }
246
247
248//      virtual void KeyInput(DS_U8 key, bool /*bRepeat*/)
249        void CInfobannerWin_KeyInput(CWindow *this, DS_U8 key, bool bRepeat)
250        {
251                switch (key)
252                {
253                        case VK_OK:
254                        case VK_CANCEL:
255                          this->Close(this);
256                          break;
257                }
258        }
259//};
260
261void DST_CreateInforbannerWindow(SWinEventMsg event)
262{
263        CWindow*pWin = NewCWindow(event);
264        pWin->Destructor        = CInfobannerWin_Destructor;
265        pWin->KeyInput          = CInfobannerWin_KeyInput;
266        pWin->OnMessage         = CInfobannerWin_OnMessage;
267        pWin->OnTimer           = CInfobannerWin_OnTimer;
268        pWin->ShowWindow        = CInfobannerWin_ShowWindow;
269        pWin->Show                      = CInfobannerWin_Show;
270        // »ý¼ºÀÚ È£Ãâ
271        CInfobannerWin_Constructor(pWin, event);
272        // À©µµ¿ì ¸Þ´ÏÀú¿¡ µî·Ï
273        DST_AddWin((WinID)(event.data[0]), pWin);
274}
Note: See TracBrowser for help on using the repository browser.