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("General");
49 wb->setSurface(surface);
50 wb->setSurfaceOffset(160, 70);
51 wb->setDimensions(140, fontHeight);
53 buttons.push_back(wb);
56 wb->setText("Timers");
57 wb->setSurface(surface);
58 wb->setSurfaceOffset(160, 110);
59 wb->setDimensions(140, fontHeight);
61 buttons.push_back(wb);
63 selectedButton = buttons.begin();
64 (*selectedButton)->setActive(1);
67 VOptionsMenu::~VOptionsMenu()
69 while (!buttons.empty())
71 delete buttons.back();
76 void VOptionsMenu::draw()
80 vector<WButton*>::iterator i;
81 for(i = buttons.begin(); i != buttons.end(); i++)
87 int VOptionsMenu::handleCommand(int command)
94 if (selectedButton == buttons.begin()) return 2;
95 (*selectedButton)->setActive(0);
97 (*selectedButton)->setActive(1);
98 draw(); // fixme - just draw buttons
99 viewman->updateView(this);
102 case Remote::DF_DOWN:
105 if (selectedButton == (buttons.end() - 1)) return 2;
106 (*selectedButton)->setActive(0);
108 (*selectedButton)->setActive(1);
109 draw(); // fixme - just draw buttons
110 viewman->updateView(this);
119 switch((*selectedButton)->getTag())
121 case 1: doGeneral(); break;
122 case 2: doTimers(); break;
131 void VOptionsMenu::processMessage(Message* m)
133 if (m->message == Message::CHANGED_OPTIONS)
135 doApplyChanges((map<int,int>*)m->parameter);
136 viewman->removeView(this);
140 void VOptionsMenu::doApplyChanges(map<int,int>* changedOptions)
142 Video* video = Video::getInstance();
143 map<int,int>::iterator i;
145 for(i = changedOptions->begin(); i != changedOptions->end(); i++)
147 printf("I FIRST = %i SECOND = %i\n", i->first, i->second);
155 Log::getInstance()->log("Options", Log::DEBUG, "Setting New Remote");
156 Remote::getInstance()->setRemoteType(Remote::NEWREMOTE);
160 Log::getInstance()->log("Options", Log::DEBUG, "Setting Old Remote");
161 Remote::getInstance()->setRemoteType(Remote::OLDREMOTE);
168 VWelcome::getInstance()->redrawLang();
175 Log::getInstance()->log("Options", Log::DEBUG, "Setting S-Video");
176 video->setConnection(Video::SVIDEO);
180 Log::getInstance()->log("Options", Log::DEBUG, "Setting RGB/Composite");
181 video->setConnection(Video::COMPOSITERGB);
189 Log::getInstance()->log("Options", Log::DEBUG, "Setting 16:9 TV");
190 video->setTVsize(Video::ASPECT16X9);
194 Log::getInstance()->log("Options", Log::DEBUG, "Setting 4:3 TV");
195 video->setTVsize(Video::ASPECT4X3);
203 Log::getInstance()->log("Options", Log::DEBUG, "Setting letterbox");
204 video->setMode(Video::LETTERBOX);
208 Log::getInstance()->log("Options", Log::DEBUG, "Setting chop-sides");
209 video->setMode(Video::NORMAL);
216 delete changedOptions;
220 void VOptionsMenu::doGeneral()
222 static const int numOptions = 8;
224 static const char* options1[] = {"Old", "New"};
225 static const char* options3[] = {"RGB+composite", "S-Video"};
226 static const char* options4[] = {"4:3", "16:9"};
227 static const char* options5[] = {"Chop sides", "Letterbox"};
228 static const char* options6[] = {"On", "Off", "Last state"};
229 static const char* options7[] = {"All", "FTA only"};
231 const static OPTIONDATA optionData[numOptions] =
233 {1, "Remote control type", "General", "Remote type", OPTIONTYPE_TEXT, 2, 0, 0, options1 },
234 {2, "Language", "General", "Language", OPTIONTYPE_TEXT, I18n::NumLanguages, 0, 0, I18n::Languages },
235 {3, "TV connection type", "TV", "Connection", OPTIONTYPE_TEXT, 2, 0, 0, options3 },
236 {4, "TV aspect ratio", "TV", "Aspect", OPTIONTYPE_TEXT, 2, 0, 0, options4 },
237 {5, "16:9 on 4:3 display mode", "TV", "Widemode", OPTIONTYPE_TEXT, 2, 0, 0, options5 },
238 {6, "Power state after bootup", "General", "Power After Boot", OPTIONTYPE_TEXT, 3, 0, 0, options6 },
239 {7, "Display channels", "General", "Channels", OPTIONTYPE_TEXT, 2, 0, 0, options7 },
240 {8, "VDR-Pri 0=OK !See forums!","General", "Live priority", OPTIONTYPE_INT, 100, 0, 0, NULL }
243 // As all the above data is const static, it can be sent to the new View, this stack frame can
244 // quit and the pointers will all still be valid. I think. (Hope).
246 VOptions* v = new VOptions(this, "General Options", optionData, numOptions);
249 viewman->updateView(v);
253 void VOptionsMenu::doTimers()
255 static const int numOptions = 4;
257 const static OPTIONDATA optionData[numOptions] =
259 {9, "Default start margin (minutes)", "Timers", "Start margin", OPTIONTYPE_INT, 20, 5, 0, NULL },
260 {10, "Default end margin (minutes)", "Timers", "End margin", OPTIONTYPE_INT, 20, 5, 0, NULL },
261 {11, "Default priority", "Timers", "Priority", OPTIONTYPE_INT, 100, 99, 0, NULL },
262 {12, "Default lifetime", "Timers", "Lifetime", OPTIONTYPE_INT, 100, 99, 0, NULL }
265 // As all the above data is const static, it can be sent to the new View, this stack frame can
266 // quit and the pointers will all still be valid. I think. (Hope).
268 VOptions* v = new VOptions(this, "Timer Options", optionData, numOptions);
271 viewman->updateView(v);