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

Last change on this file since 28 was 28, 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                                this->RegisterKey(this, VK_PWR, false, 0, 0);
96                // background
97                this->DrawImage(this, 0, 0, newcon2_gui_banner_4line_back, false);
98       
99                char strText[256];
100               
101                int nLineHeight = (this->rect.h) / 7;
102                // title
103                this->setFontStyle(this, 18, 0xFFC8C8C8, ALIGN_MIDDLE, ALIGN_CENTER);
104                this->DrawText(this, 0, 0, this->rect.w, nLineHeight*2, (char*)"Frequency Setting", &(this->font));
105                int isOn = DST_EEPROM_GetFrequencySetting();
106                sprintf(strText, "< %s >", isOn == 1?(char*)"ON":(char*)"OFF");
107                switch(nPos)
108                {
109                        case 0:
110                                this->setFontStyle(this, 17, 0xFFFFFFFF, ALIGN_MIDDLE, ALIGN_CENTER);
111                                break;
112                        case 1:
113                                this->setFontStyle(this, 15, 0xFFAAAAAA, ALIGN_MIDDLE, ALIGN_CENTER);
114                                break;
115                        case 2:
116                                this->setFontStyle(this, 15, 0xFFAAAAAA, ALIGN_MIDDLE, ALIGN_CENTER);
117                                break;
118                        default:break;
119                }
120                this->DrawText(this, 0, nLineHeight * 2, this->rect.w, nLineHeight, (char*)strText, &(this->font));
121                // display max
122                switch(nPos)
123                {
124                        case 0:
125                                this->setFontStyle(this, 15, 0xFFAAAAAA, ALIGN_MIDDLE, ALIGN_CENTER);
126                                if(isOn == 0) this->setFontStyle(this, 15, 0xFF666666, ALIGN_MIDDLE, ALIGN_CENTER);
127                                break;
128                        case 1:
129                                this->setFontStyle(this, 17, 0xFFFFFFFF, ALIGN_MIDDLE, ALIGN_CENTER);
130                                if(isOn == 0) this->setFontStyle(this, 15, 0xFF666666, ALIGN_MIDDLE, ALIGN_CENTER);
131                                break;
132                        case 2:
133                                this->setFontStyle(this, 15, 0xFFAAAAAA, ALIGN_MIDDLE, ALIGN_CENTER);
134                                if(isOn == 0) this->setFontStyle(this, 15, 0xFF666666, ALIGN_MIDDLE, ALIGN_CENTER);
135                                break;
136                        default:break;
137                }
138
139                int num = DST_EEPROM_GetMinRF();
140               
141                        int rf = DST_GetFrequencyNumberbyIndex(num);
142                        int freq = DST_GetMHzFrequencybyIndex(num);
143                        sprintf(strText, "< Min : %d ( %dMHz ) >", rf, freq);
144
145                this->DrawText(this, 0, nLineHeight * 3, this->rect.w, nLineHeight, (char*)strText, &(this->font));
146                // display min
147                switch(nPos)
148                {
149                        case 0:
150                                this->setFontStyle(this, 15, 0xFFAAAAAA, ALIGN_MIDDLE, ALIGN_CENTER);
151                                if(isOn == 0) this->setFontStyle(this, 15, 0xFF666666, ALIGN_MIDDLE, ALIGN_CENTER);
152                                break;
153                        case 1:
154                                this->setFontStyle(this, 15, 0xFFAAAAAA, ALIGN_MIDDLE, ALIGN_CENTER);
155                                if(isOn == 0) this->setFontStyle(this, 15, 0xFF666666, ALIGN_MIDDLE, ALIGN_CENTER);
156                                break;
157                        case 2:
158                                this->setFontStyle(this, 17, 0xFFFFFFFF, ALIGN_MIDDLE, ALIGN_CENTER);
159                                if(isOn == 0) this->setFontStyle(this, 15, 0xFF666666, ALIGN_MIDDLE, ALIGN_CENTER);
160                                break;
161                        default:break;
162                }
163
164                num = DST_EEPROM_GetMaxRF();
165
166                rf = DST_GetFrequencyNumberbyIndex(num);
167                freq = DST_GetMHzFrequencybyIndex(num);
168                sprintf(strText, "< Max : %d ( %dMHz ) >", rf, freq);
169
170
171                this->DrawText(this, 0, nLineHeight * 4, this->rect.w, nLineHeight, (char*)strText, &(this->font));
172                // descriptor
173                this->setFontStyle(this, 15, 0xFF666666, ALIGN_MIDDLE, ALIGN_CENTER);
174                this->DrawText(this, 0, nLineHeight * 6, this->rect.w, nLineHeight, (char*)"Channel/Volume : Next", &(this->font));
175        }
176
177
178//      virtual void KeyInput(DS_U8 key, bool /*bRepeat*/)
179        void IncreaseMaxRF()
180        {
181                if (DST_EEPROM_GetMaxRF() >= DST_MaxRF()) 
182                {
183                        DST_EEPROM_SetMaxRF(DST_MaxRF());
184                        return;
185                }
186                else if (DST_EEPROM_GetMinRF() > DST_EEPROM_GetMaxRF())
187                {
188                        DST_EEPROM_SetMaxRF(DST_EEPROM_GetMinRF());
189                        return;
190                }
191                DST_EEPROM_SetMaxRF(DST_EEPROM_GetMaxRF() + 1);
192        }
193        void DecreaseMinRF()
194        {
195                if (DST_EEPROM_GetMinRF() <= DST_MinRF()) 
196                {
197                        DST_EEPROM_SetMinRF(DST_MinRF());
198                        return;
199                }
200                else if (DST_EEPROM_GetMinRF() > DST_EEPROM_GetMaxRF())
201                {
202                        DST_EEPROM_SetMinRF(DST_EEPROM_GetMaxRF());
203                        return;
204                }
205                DST_EEPROM_SetMinRF(DST_EEPROM_GetMinRF() - 1);
206        }
207        void IncreaseMinRF()
208        {
209                if (DST_EEPROM_GetMinRF() >= DST_MaxRF()) 
210                {
211                        DST_EEPROM_SetMinRF(DST_MaxRF());
212                        return;
213                }
214                else if (DST_EEPROM_GetMinRF() >= DST_EEPROM_GetMaxRF())
215                {
216                        DST_EEPROM_SetMinRF(DST_EEPROM_GetMaxRF());
217                        return;
218                }
219
220                DST_EEPROM_SetMinRF(DST_EEPROM_GetMinRF() + 1);
221        }
222        void DecreaseMaxRF()
223        {
224                if (DST_EEPROM_GetMaxRF() <= DST_MinRF()) 
225                {
226                        DST_EEPROM_SetMaxRF(DST_MinRF());
227                        return;
228                }
229                else if (DST_EEPROM_GetMinRF() >= DST_EEPROM_GetMaxRF())
230                {
231                        DST_EEPROM_SetMaxRF(DST_EEPROM_GetMinRF());
232                        return;
233                }
234
235                DST_EEPROM_SetMaxRF(DST_EEPROM_GetMaxRF() - 1);
236        }
237        void CFrequncySettingWin_KeyInput(CWindow *this, DS_U8 key, bool bRepeat)
238        {
239                int i = 0;
240                int isOn = DST_EEPROM_GetFrequencySetting();
241                switch(key)
242                {
243                        case VK_UP:
244                                switch(nPos)
245                                {
246                                        case 0:
247                                                isOn = isOn ? 0 : 1;
248                                                DST_EEPROM_SetFrequncySetting(isOn);
249                                                break;
250                                        case 1:
251                                                if(isOn == 1)
252                                                {
253                                                        for (i=0; i < 10; i++) IncreaseMinRF();
254                                                }
255                                                break;
256                                        case 2:
257                                                if(isOn == 1)
258                                                {
259                                                        for (i=0; i < 10; i++) IncreaseMaxRF();
260                                                }
261                                                break;
262                                                default:break;
263                                }
264
265                                this->Show(this);
266                                break;
267                               
268                        case VK_DN:
269                                switch(nPos)
270                                {
271                                        case 0:
272                                                isOn = isOn ? 0 : 1;
273                                                DST_EEPROM_SetFrequncySetting(isOn);
274                                                break;
275                                        case 1:
276                                                if(isOn == 1)
277                                                {
278                                                        for (i=0; i < 10; i++) DecreaseMinRF();
279                                                }
280                                                break;
281                                        case 2:
282                                                if(isOn == 1)
283                                                {
284                                                        for (i=0; i < 10; i++) DecreaseMaxRF();
285                                                }
286                                                break;
287                                                default:break;
288                                }
289
290                                this->Show(this);
291                                break;
292                               
293                        case VK_VOL_UP:
294                        case VK_CH_UP:
295                                if(isOn == 1) nPos = (nPos+1)>2?0:(nPos+1);
296                                this->Show(this);       
297                                break;
298                        case VK_VOL_DN:
299                        case VK_CH_DN:
300                                if(isOn == 1) nPos = (nPos-1)<0?2:(nPos-1);
301                                this->Show(this);                       
302                                break;
303                               
304                        case VK_LEFT:
305                                switch(nPos)
306                                {
307                                        case 0:
308                                                isOn = isOn ? 0 : 1;
309                                                DST_EEPROM_SetFrequncySetting(isOn);
310                                                break;
311                                        case 1:
312                                                if(isOn == 1) DecreaseMinRF();
313                                                break;
314                                        case 2:
315                                                if(isOn == 1) DecreaseMaxRF();
316                                                break;
317                                                default:break;
318                                }
319
320                                this->Show(this);
321                                break;
322                       
323                        case VK_RIGHT:
324                                switch(nPos)
325                                {
326                                        case 0:
327                                                isOn = isOn ? 0 : 1;
328                                                DST_EEPROM_SetFrequncySetting(isOn);
329                                                break;
330                                        case 1:
331                                                if(isOn == 1) IncreaseMinRF();
332                                                break;
333                                        case 2:
334                                                if(isOn == 1) IncreaseMaxRF();
335                                                break;
336                                                default:break;
337                                }
338
339                                this->Show(this);
340                                break;
341                               
342                        default:
343                                this->Close(this);
344                                break;
345                }
346        }
347
348//};
349
350void DST_CreateFrequencySettingWin(SWinEventMsg event)
351{
352        DST_RemoveAllWindowExceptBasicWin();
353        CWindow*pWin = NewCWindow(event);
354        pWin->Destructor        = CFrequncySettingWin_Destructor;
355        pWin->KeyInput          = CFrequncySettingWin_KeyInput;
356        pWin->OnTimer           = CFrequncySettingWin_OnTimer;
357        pWin->ShowWindow        = CFrequncySettingWin_ShowWindow;
358        pWin->Show                      = CFrequncySettingWin_Show;
359        // »ý¼ºÀÚ È£Ãâ
360        CFrequncySettingWin_Constructor(pWin, event);
361        // À©µµ¿ì ¸Þ´ÏÀú¿¡ µî·Ï
362        DST_AddWin((WinID)(event.data[0]), pWin);
363}
364
365
Note: See TracBrowser for help on using the repository browser.