source: svn/trunk/zasc/app_c/DST_WinVolume.c @ 37

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

first commit

File size: 5.7 KB
Line 
1#include "DST_WinManager.h"
2#include "DST_OSDImage.h"
3#include "DST_UserInterface.h"
4#include "DST_DataStrings.h"
5
6#if 0
7____CVolumeWin___()
8#endif
9
10
11//class CVolumeWin : public CWindow
12//{
13        static int CVolumeWin_prev_vol;
14//public:
15//      CVolumeWin(SWinEventMsg event):CWindow(event)
16        void CVolumeWin_Constructor(CWindow *this, SWinEventMsg event)
17        {
18                this->SetWinName(this,  "Volume");
19                this->rect.w = DST_GetImageWidth(volume_back_left) + 194 + DST_GetImageWidth(volume_back_right);
20                this->rect.h = DST_GetImageHeight(volume_back_left);
21                this->rect.x = (DST_GetScreenWidth() - this->rect.w) / 2;
22                this->rect.y = DST_GetScreenHeight()/20; 
23               
24                DST_UI_SetMute(false);
25                this->SetTimeOut(this, 3);
26                CVolumeWin_prev_vol = DST_UI_GetVolume();
27        }
28
29        void CVolumeWin_Destructor(CWindow *this)
30        {               
31                if(DST_g_SignalState == SM_AUDIO_ONLY) DST_CreateWin(WIN_CHANNEL_BANNER, WIN_NULL, BANNER_NORMAL ,0, 0, 0);
32        }
33
34//      virtual void OnMessage(SWinEventMsg event)
35        void CVolumeWin_OnMessage(CWindow *this, SWinEventMsg event)
36        {
37                switch (event.cmd)
38                {
39                        case WM_POWER_OFF:
40                                this->Close(this);
41                                break;
42                }
43        }
44
45//      virtual void Show(WinID id)
46        void CVolumeWin_ShowWindow(CWindow *this, WinID id)
47        {
48                switch(id)
49                {
50                        case WIN_VOLUME_MUTE:
51                                this->Close(this);
52                                break;
53                        default:
54                                break;
55                }
56        }
57
58        void DrawProgressBar(CWindow *this, int x, int y, int w, int range, int pos, int pre_pos)
59        {
60                int position    = (w*pos)/(range);
61                int pre_position = (w*pre_pos)/(range);
62                int i = 0;
63                if (pre_position > position)
64                {
65                        for(i = x; i < x+(pre_position-position);i++)
66                                this->DrawImage(this, i+position, 0, volume_back_mid, false);
67                }
68                if (DST_UI_GetVolume() > 0)
69                {
70                        for (i = x; i < x+position; i++)
71                        {
72                                this->DrawImage(this, i, y, volume_seg, false);
73                        }
74                }
75        }
76
77
78        void CVolumeWin_Draw(CWindow *this)
79        {
80                char vol[4];
81                sprintf(vol, "%d", DST_UI_GetVolume()); 
82                this->DrawBox32(this, 56, 6, 40, 20, CONV32_16(0xFF000000));
83                this->DrawText(this, 56, 8, 40, 15, vol, &(this->font));
84//              DrawBox32(106, 11, 280, DST_GetImageHeight(imgvolume_seg), CONV32_16(0x00000000));
85                DrawProgressBar(this, 106, 11, 204, 50, DST_UI_GetVolume(),CVolumeWin_prev_vol);
86                CVolumeWin_prev_vol = DST_UI_GetVolume();
87                       
88        }
89
90//      virtual void Show()
91        void CVolumeWin_Show(CWindow *this)
92        {
93               
94                this->DrawImage(this, 0, 0, volume_back_left, false);
95                this->DrawImage(this, DST_GetImageWidth(volume_back_left) + 194, 0, volume_back_right, false);
96
97                int i = 0;
98                for(i=DST_GetImageWidth(volume_back_left);i<DST_GetImageWidth(volume_back_left)+194;i++) 
99                        this->DrawImage(this, i, 0, volume_back_mid, false);
100                this->setFontStyle(this, 20,0xFFE1E1E1,ALIGN_MIDDLE,ALIGN_RIGHT);
101                char vol[4];
102                sprintf(vol, "%d", DST_UI_GetVolume()); 
103                this->DrawText(this, 56, 8, 40, 15, vol, &(this->font));
104                DrawProgressBar(this, 106, 11, 204, 50, DST_UI_GetVolume(),CVolumeWin_prev_vol);
105
106                this->RegisterKey(this, VK_VOL_DN, true, 0, 0);
107                this->RegisterKey(this, VK_VOL_UP, true, 0, 0);
108        }
109
110//      virtual void KeyInput(DS_U8 key, bool /*bRepeat*/)
111        void CVolumeWin_KeyInput(CWindow *this, DS_U8 key, bool bRepeat)
112        {
113                switch (key)
114                {
115                        case VK_VOL_DN:
116                                if (DST_UI_GetVolume() == 0) break;
117                                DST_UI_SetVolume(DST_UI_GetVolume()-1);
118                                CVolumeWin_Draw(this);
119                                break;
120                        case VK_VOL_UP:
121                                if (DST_UI_GetVolume() == 50) break;
122                                DST_UI_SetVolume(DST_UI_GetVolume()+1);
123                                CVolumeWin_Draw(this);
124                                break;
125                        default:
126                                this->Close(this);
127                                if(DST_g_SignalState == SM_AUDIO_ONLY) DST_CreateWin(WIN_CHANNEL_BANNER, WIN_NULL, BANNER_NORMAL ,0, 0, 0);
128                                break;
129
130                }
131        }
132
133//};
134void DST_CreateVolumeWindow(SWinEventMsg event)
135{
136        CWindow*pWin = NewCWindow(event);
137        pWin->Destructor = CVolumeWin_Destructor;
138        pWin->OnMessage = CVolumeWin_OnMessage; 
139        pWin->KeyInput = CVolumeWin_KeyInput;
140        pWin->ShowWindow = CVolumeWin_ShowWindow;
141        pWin->Show = CVolumeWin_Show;
142        // »ý¼ºÀÚ È£Ãâ
143        CVolumeWin_Constructor(pWin, event);
144        // À©µµ¿ì ¸Þ´ÏÀú¿¡ µî·Ï
145        DST_AddWin((WinID)(event.data[0]), pWin);
146}
147
148
149
150//class CVolumeMuteWin : public CWindow
151//{
152//private:
153//public:
154//      CVolumeMuteWin(SWinEventMsg event):CWindow(event)
155        void CVolumeMuteWin_Constructor(CWindow *this, SWinEventMsg event)
156        {
157                this->SetWinName(this,  "Mute");
158                this->rect.w = DST_GetImageWidth(mute);
159                this->rect.h = DST_GetImageHeight(mute);
160                this->rect.x = 9 + (DST_GetScreenWidth()) / 20;
161                this->rect.y = DST_GetScreenHeight()/20;
162                this->SetTimeOut(this, 0);
163        }
164
165        void CVolumeMuteWin_Destructor(CWindow *this)
166        {
167                if(DST_g_SignalState == SM_AUDIO_ONLY) DST_CreateWin(WIN_CHANNEL_BANNER, WIN_NULL, BANNER_NORMAL ,0, 0, 0);
168        }
169
170//      virtual void Show(WinID id)
171        void CVolumeMuteWin_ShowWindow(CWindow *this, WinID id)
172        {
173                switch(id)
174                {
175                        case WIN_VOLUME:
176                                this->Close(this);
177                                break;
178                        default:
179                                break;
180                }
181        }
182
183       
184//      virtual void Show()
185        void CVolumeMuteWin_Show(CWindow *this)
186        {
187
188                this->DrawImage(this, 0, 0, mute, false);
189                this->RegisterKey(this, VK_VOL_DN, true, 0, 0);
190                this->RegisterKey(this, VK_VOL_UP, true, 0, 0);
191
192        }
193
194//      virtual void KeyInput(DS_U8 key, bool /*bRepeat*/)
195        void CVolumeMuteWin_KeyInput(CWindow *this, DS_U8 key, bool bRepeat)
196        {
197                switch (key)
198                {
199                        case VK_VOL_UP:
200                        case VK_VOL_DN:
201                                DST_CreateWin(WIN_VOLUME, WIN_NULL, 0, 0, 0, 0);
202                                break;
203                        default:
204                                this->Close(this);
205                                if(DST_g_SignalState == SM_AUDIO_ONLY) DST_CreateWin(WIN_CHANNEL_BANNER, WIN_NULL, BANNER_NORMAL ,0, 0, 0);
206                                break;
207
208                }
209        }
210
211
212//};
213
214
215void DST_CreateVolumeMuteWindow(SWinEventMsg event)
216{
217        CWindow*pWin = NewCWindow(event);
218        pWin->Destructor        = CVolumeMuteWin_Destructor;
219        pWin->KeyInput          = CVolumeMuteWin_KeyInput;
220        pWin->ShowWindow        = CVolumeMuteWin_ShowWindow;
221        pWin->Show                      = CVolumeMuteWin_Show;
222        // »ý¼ºÀÚ È£Ãâ
223        CVolumeMuteWin_Constructor(pWin, event);
224        // À©µµ¿ì ¸Þ´ÏÀú¿¡ µî·Ï
225        DST_AddWin((WinID)(event.data[0]), pWin);
226}
227
Note: See TracBrowser for help on using the repository browser.