source: svn/trunk/zasc/app_c/DST_WinFrequencySetting.c @ 25

Last change on this file since 25 was 25, checked in by jglee, 11 years ago
File size: 9.0 KB
Line 
1#include "DST_Window.h"
2#include "DST_WinManager.h"
3#include "DST_CommonAPI.h"
4#include "DST_UserInterface.h"
5#include "DST_DataStrings.h"
6#include "DST_ISDBT_ChannelTask.h"
7#include "DST_DB.h"
8#include "DST_ChannelTune.h"
9#include "DST_SignalMonitor.h"
10
11#ifndef DSTAR
12#include "DHL_OSAL.h"
13#include "DHL_OSAL_Priv.h"
14#include "bcmmemmgr.h"
15#endif
16
17extern DS_U8 newcon2_gui_banner_4line_back[];
18
19#if 0
20____CFrequncySettingWin___()
21#endif
22
23static int nPos = 0;
24
25//class CFrequncySettingWin : public CWindow
26//{
27//private:
28//     
29//public:
30//      CFrequncySettingWin(SWinEventMsg event):CWindow(event)
31        void CFrequncySettingWin_Constructor(CWindow *this, SWinEventMsg event)
32        {
33                this->SetWinName(this,  "FrequencySetting");
34                this->setFontStyle(this, 22, 0xFFFFFFFF, ALIGN_MIDDLE, ALIGN_LEFT);
35                this->rect.w = DST_GetImageWidth(newcon2_gui_banner_4line_back);
36                this->rect.h = DST_GetImageHeight(newcon2_gui_banner_4line_back);;
37                this->rect.x = (DST_GetScreenWidth() - this->rect.w) / 2;
38                this->rect.y = (DST_GetScreenHeight() - this->rect.h) / 2;
39
40                this->SetTimeOut(this, 0);
41        }
42
43        void CFrequncySettingWin_Destructor(CWindow *this)
44        {
45        }
46       
47//      virtual void OnTimer(char nID)
48        void CFrequncySettingWin_OnTimer(CWindow *this, char nID)
49        {
50        }
51
52//      virtual void Show(WinID id)
53        void CFrequncySettingWin_ShowWindow(CWindow *this, WinID id)
54        {
55                switch(id)
56                {
57                        case WIN_EWS:
58                        case WIN_ENGINEER_MODE:
59                        case WIN_DEBUG_SQL:
60                        case WIN_DEBUG_SQL_SUB:
61                        case WIN_DIRECT_TUNE:
62                        case WIN_VOLUME:
63                        case WIN_VOLUME_MUTE:
64                        case WIN_SIGNAL_METER:
65                        case WIN_CLOSED_CAPTION_HOT:
66                        case WIN_AUDIO_HOT:
67                        case WIN_DISPLAY_MODE_HOT:
68                        case WIN_FACTORY_RESET:
69                        case WIN_FACTORY_RESET_ASK:
70                        case WIN_INFOR_BANNER:
71                        case WIN_POWER_DOWN_CAUTION:
72                        case WIN_MAIN_MENU:
73                        case WIN_SUB_MENU_2DEPTH:
74                        case WIN_SUB_MENU_3DEPTH:
75                        case WIN_SUB_MENU_4DEPTH:
76                        case WIN_AUTO_SEARCH:
77                        case WIN_MANUAL_SEARCH:
78                        case WIN_CHANNEL_LIST:
79                        case WIN_PROGRAM_GUIDE:
80                        case WIN_PASSWD_CHANGE:
81                        case WIN_PASSWD_CHECK:
82                        case WIN_PASSWD_CONFIRM:
83                        case WIN_AGE_RATING:
84                                this->Close(this);
85                                break;
86                        default:
87                                break;
88                }
89        }
90
91//      virtual void Show()
92        void CFrequncySettingWin_Show(CWindow *this)
93        {
94                this->RegisterAllKey(this);
95                // background
96                this->DrawImage(this, 0, 0, newcon2_gui_banner_4line_back, false);
97       
98                char strText[256];
99               
100                int nLineHeight = (this->rect.h) / 7;
101                // title
102                this->setFontStyle(this, 18, 0xFFC8C8C8, ALIGN_MIDDLE, ALIGN_CENTER);
103                this->DrawText(this, 0, 0, this->rect.w, nLineHeight*2, (char*)"Frequency Range Setting", &(this->font));
104                int isOn = DST_EEPROM_GetFrequencySetting();
105                sprintf(strText, "< %s >", isOn == 1?(char*)"ON":(char*)"OFF");
106                switch(nPos)
107                {
108                        case 0:
109                                this->setFontStyle(this, 17, 0xFFFFFFFF, ALIGN_MIDDLE, ALIGN_CENTER);
110                                break;
111                        case 1:
112                                this->setFontStyle(this, 15, 0xFFAAAAAA, ALIGN_MIDDLE, ALIGN_CENTER);
113                                break;
114                        case 2:
115                                this->setFontStyle(this, 15, 0xFFAAAAAA, ALIGN_MIDDLE, ALIGN_CENTER);
116                                break;
117                        default:break;
118                }
119                this->DrawText(this, 0, nLineHeight * 2, this->rect.w, nLineHeight, (char*)strText, &(this->font));
120                // display max
121                switch(nPos)
122                {
123                        case 0:
124                                this->setFontStyle(this, 15, 0xFFAAAAAA, ALIGN_MIDDLE, ALIGN_CENTER);
125                                if(isOn == 0) this->setFontStyle(this, 15, 0xFF666666, ALIGN_MIDDLE, ALIGN_CENTER);
126                                break;
127                        case 1:
128                                this->setFontStyle(this, 17, 0xFFFFFFFF, ALIGN_MIDDLE, ALIGN_CENTER);
129                                if(isOn == 0) this->setFontStyle(this, 15, 0xFF666666, ALIGN_MIDDLE, ALIGN_CENTER);
130                                break;
131                        case 2:
132                                this->setFontStyle(this, 15, 0xFFAAAAAA, ALIGN_MIDDLE, ALIGN_CENTER);
133                                if(isOn == 0) this->setFontStyle(this, 15, 0xFF666666, ALIGN_MIDDLE, ALIGN_CENTER);
134                                break;
135                        default:break;
136                }
137
138                int num = DST_EEPROM_GetMinRF();
139               
140                        int rf = DST_GetFrequencyNumberbyIndex(num);
141                        int freq = DST_GetMHzFrequencybyIndex(num);
142                        sprintf(strText, "< Min : %d ( %dMHz ) >", rf, freq);
143
144                this->DrawText(this, 0, nLineHeight * 3, this->rect.w, nLineHeight, (char*)strText, &(this->font));
145                // display min
146                switch(nPos)
147                {
148                        case 0:
149                                this->setFontStyle(this, 15, 0xFFAAAAAA, ALIGN_MIDDLE, ALIGN_CENTER);
150                                if(isOn == 0) this->setFontStyle(this, 15, 0xFF666666, ALIGN_MIDDLE, ALIGN_CENTER);
151                                break;
152                        case 1:
153                                this->setFontStyle(this, 15, 0xFFAAAAAA, ALIGN_MIDDLE, ALIGN_CENTER);
154                                if(isOn == 0) this->setFontStyle(this, 15, 0xFF666666, ALIGN_MIDDLE, ALIGN_CENTER);
155                                break;
156                        case 2:
157                                this->setFontStyle(this, 17, 0xFFFFFFFF, ALIGN_MIDDLE, ALIGN_CENTER);
158                                if(isOn == 0) this->setFontStyle(this, 15, 0xFF666666, ALIGN_MIDDLE, ALIGN_CENTER);
159                                break;
160                        default:break;
161                }
162
163                num = DST_EEPROM_GetMaxRF();
164
165                rf = DST_GetFrequencyNumberbyIndex(num);
166                freq = DST_GetMHzFrequencybyIndex(num);
167                sprintf(strText, "< Max : %d ( %dMHz ) >", rf, freq);
168
169
170                this->DrawText(this, 0, nLineHeight * 4, this->rect.w, nLineHeight, (char*)strText, &(this->font));
171                // descriptor
172                this->setFontStyle(this, 15, 0xFF666666, ALIGN_MIDDLE, ALIGN_CENTER);
173                this->DrawText(this, 0, nLineHeight * 6, this->rect.w, nLineHeight, (char*)"Channel/Volume : Next", &(this->font));
174        }
175
176
177//      virtual void KeyInput(DS_U8 key, bool /*bRepeat*/)
178        void IncreaseMaxRF()
179        {
180                if (DST_EEPROM_GetMaxRF() >= DST_MaxRF()) 
181                {
182                        DST_EEPROM_SetMaxRF(DST_MaxRF());
183                        return;
184                }
185                else if (DST_EEPROM_GetMinRF() > DST_EEPROM_GetMaxRF())
186                {
187                        DST_EEPROM_SetMaxRF(DST_EEPROM_GetMinRF());
188                        return;
189                }
190                DST_EEPROM_SetMaxRF(DST_EEPROM_GetMaxRF() + 1);
191        }
192        void DecreaseMinRF()
193        {
194                if (DST_EEPROM_GetMinRF() <= DST_MinRF()) 
195                {
196                        DST_EEPROM_SetMinRF(DST_MinRF());
197                        return;
198                }
199                else if (DST_EEPROM_GetMinRF() > DST_EEPROM_GetMaxRF())
200                {
201                        DST_EEPROM_SetMinRF(DST_EEPROM_GetMaxRF());
202                        return;
203                }
204                DST_EEPROM_SetMinRF(DST_EEPROM_GetMinRF() - 1);
205        }
206        void IncreaseMinRF()
207        {
208                if (DST_EEPROM_GetMinRF() >= DST_MaxRF()) 
209                {
210                        DST_EEPROM_SetMinRF(DST_MaxRF());
211                        return;
212                }
213                else if (DST_EEPROM_GetMinRF() >= DST_EEPROM_GetMaxRF())
214                {
215                        DST_EEPROM_SetMinRF(DST_EEPROM_GetMaxRF());
216                        return;
217                }
218
219                DST_EEPROM_SetMinRF(DST_EEPROM_GetMinRF() + 1);
220        }
221        void DecreaseMaxRF()
222        {
223                if (DST_EEPROM_GetMaxRF() <= DST_MinRF()) 
224                {
225                        DST_EEPROM_SetMaxRF(DST_MinRF());
226                        return;
227                }
228                else if (DST_EEPROM_GetMinRF() >= DST_EEPROM_GetMaxRF())
229                {
230                        DST_EEPROM_SetMaxRF(DST_EEPROM_GetMinRF());
231                        return;
232                }
233
234                DST_EEPROM_SetMaxRF(DST_EEPROM_GetMaxRF() - 1);
235        }
236        void CFrequncySettingWin_KeyInput(CWindow *this, DS_U8 key, bool bRepeat)
237        {
238                int i = 0;
239                int isOn = DST_EEPROM_GetFrequencySetting();
240                switch(key)
241                {
242                        case VK_UP:
243                                switch(nPos)
244                                {
245                                        case 0:
246                                                isOn = isOn ? 0 : 1;
247                                                DST_EEPROM_SetFrequncySetting(isOn);
248                                                break;
249                                        case 1:
250                                                if(isOn == 1)
251                                                {
252                                                        for (i=0; i < 10; i++) IncreaseMinRF();
253                                                }
254                                                break;
255                                        case 2:
256                                                if(isOn == 1)
257                                                {
258                                                        for (i=0; i < 10; i++) IncreaseMaxRF();
259                                                }
260                                                break;
261                                                default:break;
262                                }
263
264                                this->Show(this);
265                                break;
266                               
267                        case VK_DN:
268                                switch(nPos)
269                                {
270                                        case 0:
271                                                isOn = isOn ? 0 : 1;
272                                                DST_EEPROM_SetFrequncySetting(isOn);
273                                                break;
274                                        case 1:
275                                                if(isOn == 1)
276                                                {
277                                                        for (i=0; i < 10; i++) DecreaseMinRF();
278                                                }
279                                                break;
280                                        case 2:
281                                                if(isOn == 1)
282                                                {
283                                                        for (i=0; i < 10; i++) DecreaseMaxRF();
284                                                }
285                                                break;
286                                                default:break;
287                                }
288
289                                this->Show(this);
290                                break;
291                               
292                        case VK_VOL_UP:
293                        case VK_CH_UP:
294                                if(isOn == 1) nPos = (nPos+1)>2?0:(nPos+1);
295                                this->Show(this);       
296                                break;
297                        case VK_VOL_DN:
298                        case VK_CH_DN:
299                                if(isOn == 1) nPos = (nPos-1)<0?2:(nPos-1);
300                                this->Show(this);                       
301                                break;
302                               
303                        case VK_LEFT:
304                                switch(nPos)
305                                {
306                                        case 0:
307                                                isOn = isOn ? 0 : 1;
308                                                DST_EEPROM_SetFrequncySetting(isOn);
309                                                break;
310                                        case 1:
311                                                if(isOn == 1) DecreaseMinRF();
312                                                break;
313                                        case 2:
314                                                if(isOn == 1) DecreaseMaxRF();
315                                                break;
316                                                default:break;
317                                }
318
319                                this->Show(this);
320                                break;
321                       
322                        case VK_RIGHT:
323                                switch(nPos)
324                                {
325                                        case 0:
326                                                isOn = isOn ? 0 : 1;
327                                                DST_EEPROM_SetFrequncySetting(isOn);
328                                                break;
329                                        case 1:
330                                                if(isOn == 1) IncreaseMinRF();
331                                                break;
332                                        case 2:
333                                                if(isOn == 1) IncreaseMaxRF();
334                                                break;
335                                                default:break;
336                                }
337
338                                this->Show(this);
339                                break;
340                               
341                        default:
342                                this->Close(this);
343                                break;
344                }
345        }
346
347//};
348
349void DST_CreateFrequencySettingWin(SWinEventMsg event)
350{
351        DST_RemoveAllWindowExceptBasicWin();
352        CWindow*pWin = NewCWindow(event);
353        pWin->Destructor        = CFrequncySettingWin_Destructor;
354        pWin->KeyInput          = CFrequncySettingWin_KeyInput;
355        pWin->OnTimer           = CFrequncySettingWin_OnTimer;
356        pWin->ShowWindow        = CFrequncySettingWin_ShowWindow;
357        pWin->Show                      = CFrequncySettingWin_Show;
358        // »ý¼ºÀÚ È£Ãâ
359        CFrequncySettingWin_Constructor(pWin, event);
360        // À©µµ¿ì ¸Þ´ÏÀú¿¡ µî·Ï
361        DST_AddWin((WinID)(event.data[0]), pWin);
362}
363
364
Note: See TracBrowser for help on using the repository browser.