]> git.vomp.tv Git - vompclient.git/blob - wwinmp3audiofilter.cc
Compile fix for MVP re: location change of hmsf
[vompclient.git] / wwinmp3audiofilter.cc
1 /*
2     Copyright 2004-2007 Chris Tallon, Marten Richter
3
4     This file is part of VOMP.
5
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP; if not, write to the Free Software
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20
21 #include "wwinmp3audiofilter.h"
22 #include "audiowin.h"
23 #include "i18n.h"
24 #include "remote.h"
25 #include "boxstack.h"
26
27 WWinMp3AudioFilter::WWinMp3AudioFilter()
28 {
29   add(&sl);
30   initSelectList(true);
31   sl.setShowSelOption(false);
32   sl.setPosition(15,30+15);
33   
34
35
36 }
37
38 WWinMp3AudioFilter::~WWinMp3AudioFilter()
39 {
40   
41 }
42
43 void WWinMp3AudioFilter::initSelectList(bool startup)
44 {
45     ULONG selection=0;
46     ULONG top=0;
47     if (!startup)
48     {
49         selection=sl.getCurrentOption();
50         top=sl.getTopOption();
51         
52     }
53     sl.addColumn(0);
54     
55     ULONG i;
56     AudioWin *aw=(AudioWin*) Audio::getInstance();
57     int filselected;
58     const AudioFilterDescList *list=aw->getMp3AudioFilterList(filselected);
59     for (i = 0; i < list->size();i++)
60     {
61       const char * name = (*list)[i].friendlyname;
62       if (name!=NULL)
63       {
64         char * desc=new char [strlen(name)+1];
65         strcpy(desc,name);
66         sl.addOption(desc,i,0);
67       }
68       
69     }
70     if (!startup)
71     {
72         sl.hintSetCurrent(selection);
73         sl.hintSetTop(top);
74     }
75 }
76
77 void WWinMp3AudioFilter::setSize(UINT w, UINT h)
78 {
79     Boxx::setSize(w, h);
80     sl.setSize(area.w - 240, area.h - 30-15-30);
81 }
82
83
84 void WWinMp3AudioFilter::draw()
85 {
86   Boxx::draw();
87   
88   drawText(tr("Selected Filter:"), 15, 15, DrawStyle::LIGHTTEXT);
89   int filselected;
90   AudioWin *aw=(AudioWin*) Audio::getInstance();
91   const AudioFilterDescList *list=aw->getMp3AudioFilterList(filselected);
92   if (filselected!=-1) drawText((*list)[filselected].friendlyname,215,15,DrawStyle::LIGHTTEXT);
93   sl.draw();
94   
95 /*  if (!(*list)[sl.getCurrentOptionData()].vmr9tested)
96   {
97       rectangle(area.w - 220, 160, 200, 20, DrawStyle::YELLOW);
98       drawText(tr("VMR 9 support: ?"), area.w - 220, 160, DrawStyle::DARKTEXT);
99   }
100   else if ((*list)[sl.getCurrentOptionData()].vmr9)
101   {
102       rectangle(area.w - 220, 160, 200, 20, DrawStyle::GREEN);
103       drawText(tr("VMR 9 support: yes"), area.w - 220, 160, DrawStyle::DARKTEXT);
104   } 
105   else 
106   {
107       rectangle(area.w - 220, 160, 200, 20, DrawStyle::RED);
108       drawText(tr("VMR 9 support: no"), area.w - 220, 160, DrawStyle::DARKTEXT);
109   } */
110  
111   drawText(tr("Press [ok] to select filter! "), 15, area.h - 30, DrawStyle::LIGHTTEXT);
112   
113
114   
115
116   
117 }
118
119 bool WWinMp3AudioFilter::mouseLBDOWN(int x, int y)
120 {
121     if (sl.mouseLBDOWN(x,y))
122     {
123       BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press
124       return true;
125     }
126     return false;
127 }
128
129 bool WWinMp3AudioFilter::mouseMove(int x, int y) 
130 {
131     if (sl.mouseMove(x,y))
132     {
133       sl.setShowSelOption(true);
134       sl.draw();
135       return true;
136     }
137     return false;
138 }
139
140 /*
141 void WWinMp3AudioFilter::processMessage(Message* m)
142 {
143   Log::getInstance()->log("VRecordingList", Log::DEBUG, "Got message value %lu", m->message);
144
145   if (m->message == Message::MOUSE_MOVE)
146   {
147     if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
148     {
149       sl.setShowSelOption(true);
150       sl.draw();
151       draw();
152       viewman->updateView(this);
153     }
154   }
155   else if (m->message == Message::MOUSE_LBDOWN)
156   {
157     if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
158     {
159       ViewMan::getInstance()->handleCommand(Remote::OK); //simulate OK press
160     }
161     else
162     {
163       //check if press is outside this view! then simulate cancel
164       int x=(m->parameter>>16)-getScreenX();
165       int y=(m->parameter&0xFFFF)-getScreenY();
166       if (x<0 || y <0 || x>getWidth() || y>getHeight())
167       {
168         ViewMan::getInstance()->handleCommand(Remote::BACK); //simulate cancel press
169       }
170     }
171   }
172   
173 }*/
174
175
176 /*void WWinMp3AudioFilter::doSave()
177 {
178     Message* m = new Message();
179     m->message = Message::CHANGED_DEVICEOPTIONS;
180     m->to = parent;
181     m->parameter = 0;
182     Command::getInstance()->postMessageNoLock(m);
183     
184 }*/
185
186
187 int WWinMp3AudioFilter::handleCommand(int command)
188 {
189   
190   switch(command)
191   {
192     case Remote::DF_UP:
193     case Remote::UP:
194     {
195       if (sl.getCurrentOption() != 0)
196       {
197           sl.up();
198           sl.setShowSelOption(true);
199           return 1;
200       }
201       else
202       {
203           sl.setShowSelOption(false);
204           return 4; //Control to vpots control
205       }
206     }
207     case Remote::DF_DOWN:
208     case Remote::DOWN:
209     {
210       
211       sl.down();
212       sl.setShowSelOption(true);
213       return 1;
214     }
215     case Remote::SKIPBACK:
216     {
217       sl.pageUp();
218       sl.draw();
219
220       return 1;
221     }
222     case Remote::SKIPFORWARD:
223     {
224       sl.pageDown();
225       sl.draw();
226
227       
228       return 1;
229     }
230     case Remote::OK:
231     {
232         AudioWin*aw=(AudioWin*)Audio::getInstance();
233         aw->selectMp3AudioFilter(sl.getCurrentOptionData());
234        
235       return 1;
236     }
237     case Remote::BACK:
238     {
239       return 0;
240       
241     }
242    
243
244     
245   }
246   // stop command getting to any more views
247   return 0;
248 }
249 //#endif