2 Copyright 2004-2005 Chris Tallon
4 This file is part of VOMP.
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "voptionsmenu.h"
23 VOptionsMenu::VOptionsMenu()
25 viewman = ViewMan::getInstance();
28 if (Video::getInstance()->getFormat() == Video::PAL)
30 setScreenPos(140, 170);
34 setScreenPos(130, 140);
37 setBackgroundColour(Colour::VIEWBACKGROUND);
39 setTitleBarColour(Colour::TITLEBARBACKGROUND);
40 setTitleText(tr("Options"));
42 int fontHeight = surface->getFontHeight();
48 wb->setText(tr("General"));
49 wb->setSurface(surface);
50 wb->setSurfaceOffset(160, 60);
51 wb->setDimensions(140, fontHeight);
53 buttons.push_back(wb);
56 wb->setText(tr("Timers"));
57 wb->setSurface(surface);
58 wb->setSurfaceOffset(160, 100);
59 wb->setDimensions(140, fontHeight);
61 buttons.push_back(wb);
64 wb->setText(tr("Advanced"));
65 wb->setSurface(surface);
66 wb->setSurfaceOffset(160, 140);
67 wb->setDimensions(140, fontHeight);
69 buttons.push_back(wb);
72 selectedButton = buttons.begin();
73 (*selectedButton)->setActive(1);
76 VOptionsMenu::~VOptionsMenu()
78 while (!buttons.empty())
80 delete buttons.back();
85 void VOptionsMenu::draw()
89 vector<WButton*>::iterator i;
90 for(i = buttons.begin(); i != buttons.end(); i++)
96 int VOptionsMenu::handleCommand(int command)
103 if (selectedButton == buttons.begin()) return 2;
104 (*selectedButton)->setActive(0);
106 (*selectedButton)->setActive(1);
107 draw(); // fixme - just draw buttons
108 viewman->updateView(this);
111 case Remote::DF_DOWN:
114 if (selectedButton == (buttons.end() - 1)) return 2;
115 (*selectedButton)->setActive(0);
117 (*selectedButton)->setActive(1);
118 draw(); // fixme - just draw buttons
119 viewman->updateView(this);
128 switch((*selectedButton)->getTag())
130 case 1: doGeneral(); break;
131 case 2: doTimers(); break;
132 case 3: doAdvanced(); break;
141 void VOptionsMenu::processMessage(Message* m)
143 if (m->message == Message::MOUSE_MOVE)
145 int x=(m->parameter>>16)-getScreenX();
146 int y=(m->parameter&0xFFFF)-getScreenY();
147 vector<WButton*>::iterator i;
148 for (i=buttons.begin(); i!=buttons.end();i++)
150 if ((*i)->mouseMove(x,y))
152 (*selectedButton)->setActive(0);
155 ViewMan::getInstance()->updateView(this);
160 else if (m->message == Message::MOUSE_LBDOWN)
162 int x=(m->parameter>>16)-getScreenX();
163 int y=(m->parameter&0xFFFF)-getScreenY();
164 vector<WButton*>::iterator i;
166 for (i=buttons.begin(); i!=buttons.end();i++)
168 if ((*i)->mouseLBDOWN(x,y))
170 ViewMan::getInstance()->handleCommand(Remote::OK); //simulate OK press
177 //check if press is outside this view! then simulate cancel
178 if (x<0 || y <0 || x>getWidth() || y>getHeight())
180 ViewMan::getInstance()->handleCommand(Remote::BACK); //simulate cancel press
184 else if (m->message == Message::CHANGED_OPTIONS)
186 doApplyChanges((map<int,int>*)m->parameter);
187 //viewman->removeView(this);
189 if (!VDR::getInstance()->isConnected()) Command::getInstance()->connectionLost();
193 void VOptionsMenu::doApplyChanges(map<int,int>* changedOptions)
195 Video* video = Video::getInstance();
196 map<int,int>::iterator i;
198 for(i = changedOptions->begin(); i != changedOptions->end(); i++)
200 // printf("I FIRST = %i SECOND = %i\n", i->first, i->second);
208 Log::getInstance()->log("Options", Log::DEBUG, "Setting New Remote");
209 Remote::getInstance()->setRemoteType(Remote::NEWREMOTE);
213 Log::getInstance()->log("Options", Log::DEBUG, "Setting Old Remote");
214 Remote::getInstance()->setRemoteType(Remote::OLDREMOTE);
221 VWelcome::getInstance()->redrawLang();
228 Log::getInstance()->log("Options", Log::DEBUG, "Setting S-Video");
229 video->setConnection(Video::SVIDEO);
233 Log::getInstance()->log("Options", Log::DEBUG, "Setting RGB/Composite");
234 video->setConnection(Video::COMPOSITERGB);
242 Log::getInstance()->log("Options", Log::DEBUG, "Setting 16:9 TV");
243 video->setTVsize(Video::ASPECT16X9);
247 Log::getInstance()->log("Options", Log::DEBUG, "Setting 4:3 TV");
248 video->setTVsize(Video::ASPECT4X3);
256 Log::getInstance()->log("Options", Log::DEBUG, "Setting letterbox");
257 video->setMode(Video::LETTERBOX);
261 Log::getInstance()->log("Options", Log::DEBUG, "Setting chop-sides");
262 video->setMode(Video::NORMAL);
268 size_t newTCPsize = 2048;
270 if (i->second == 0) newTCPsize = 1024;
271 else if (i->second == 1) newTCPsize = 2048;
272 else if (i->second == 2) newTCPsize = 4096;
273 else if (i->second == 3) newTCPsize = 8192;
274 else if (i->second == 4) newTCPsize = 16384;
275 else if (i->second == 5) newTCPsize = 32768;
276 else if (i->second == 6) newTCPsize = 65536;
278 Log::getInstance()->log("Options", Log::DEBUG, "Setting TCP window size %i", newTCPsize);
279 VDR::getInstance()->setReceiveWindow(newTCPsize);
285 delete changedOptions;
289 void VOptionsMenu::doGeneral()
291 static const int numOptions = 7;
293 static const char* options1[] = {"Old", "New"};
294 static const char* options3[] = {"RGB+composite", "S-Video"};
295 static const char* options4[] = {"4:3", "16:9"};
296 static const char* options5[] = {"Chop sides", "Letterbox"};
297 static const char* options6[] = {"On", "Off", "Last state"};
298 static const char* options7[] = {"All", "FTA only"};
300 const static OPTIONDATA optionData[numOptions] =
302 {1, "Remote control type", "General", "Remote type", OPTIONTYPE_TEXT, 2, 0, 0, options1 },
303 {2, "Language", "General", "Language", OPTIONTYPE_TEXT, I18n::NumLanguages, 0, 0, I18n::Languages },
304 {3, "TV connection type", "TV", "Connection", OPTIONTYPE_TEXT, 2, 0, 0, options3 },
305 {4, "TV aspect ratio", "TV", "Aspect", OPTIONTYPE_TEXT, 2, 0, 0, options4 },
306 {5, "16:9 on 4:3 display mode", "TV", "Widemode", OPTIONTYPE_TEXT, 2, 0, 0, options5 },
307 {6, "Power state after bootup", "General", "Power After Boot", OPTIONTYPE_TEXT, 3, 0, 0, options6 },
308 {7, "Display channels", "General", "Channels", OPTIONTYPE_TEXT, 2, 0, 0, options7 },
311 // As all the above data is const static, it can be sent to the new View, this stack frame can
312 // quit and the pointers will all still be valid. I think. (Hope).
314 VOptions* v = new VOptions(this, tr("General Options"), optionData, numOptions);
317 viewman->updateView(v);
321 void VOptionsMenu::doTimers()
323 static const int numOptions = 4;
325 const static OPTIONDATA optionData[numOptions] =
327 {9, "Default start margin (minutes)", "Timers", "Start margin", OPTIONTYPE_INT, 20, 5, 0, NULL },
328 {10, "Default end margin (minutes)", "Timers", "End margin", OPTIONTYPE_INT, 20, 5, 0, NULL },
329 {11, "Default priority", "Timers", "Priority", OPTIONTYPE_INT, 100, 99, 0, NULL },
330 {12, "Default lifetime", "Timers", "Lifetime", OPTIONTYPE_INT, 100, 99, 0, NULL },
333 // As all the above data is const static, it can be sent to the new View, this stack frame can
334 // quit and the pointers will all still be valid. I think. (Hope).
336 VOptions* v = new VOptions(this, tr("Timer Options"), optionData, numOptions);
339 viewman->updateView(v);
342 void VOptionsMenu::doAdvanced()
344 static const int numOptions = 3;
346 static const char* options13[] = {"1024", "2048", "4096", "8192", "16384", "32768", "65536"};
347 static const char* options14[] = {"No", "Yes"};
349 const static OPTIONDATA optionData[numOptions] =
351 {8, "VDR-Pri 0=OK !See forums!", "General", "Live priority", OPTIONTYPE_INT, 100, 0, 0, NULL },
352 {13, "TCP receive window size", "Advanced", "TCP receive window", OPTIONTYPE_TEXT, 7, 1, 0, options13 },
353 {14, "Use WSS (PAL only)", "General", "WSS", OPTIONTYPE_TEXT, 2, 0, 0, options14 }
356 // As all the above data is const static, it can be sent to the new View, this stack frame can
357 // quit and the pointers will all still be valid. I think. (Hope).
359 VOptions* v = new VOptions(this, tr("Advanced Options"), optionData, numOptions);
362 viewman->updateView(v);