2 Copyright 2004-2007 Chris Tallon, Marten Richter
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 "vremoteconfig.h"
23 VRemoteConfig::VRemoteConfig(void* tparent)
26 viewman = ViewMan::getInstance();
27 remote = Remote::getInstance();
32 if (Video::getInstance()->getFormat() == Video::PAL)
41 setBackgroundColour(Colour::VIEWBACKGROUND);
43 setTitleBarColour(Colour::TITLEBARBACKGROUND);
44 setTitleText(tr("Remote control"));
49 sl.setShowSelOption(false);
55 VRemoteConfig::~VRemoteConfig()
60 void VRemoteConfig::initSelectList(bool startup)
66 selection=sl.getCurrentOption();
67 top=sl.getTopOption();
70 sl.setSurface(surface);
71 sl.setSurfaceOffset(10, 40);
72 sl.setDimensions(area.w - 20, area.h - 30 - 15 -30 );
78 for (i = 0; i < 256;i++)
80 const char * name = remote->CommandDesc((UCHAR)i);
83 char *line = remote->CommandTranslateStr((UCHAR)i);
84 char * desc=new char [strlen(line)+1];
86 sl.addOption(desc,i,0);
91 sl.hintSetCurrent(selection);
97 void VRemoteConfig::draw()
101 drawText(tr("Command"), 15, 15, Colour::LIGHTTEXT);
102 drawText(tr("Hardwired"), 165, 15, Colour::LIGHTTEXT);
103 drawText(tr("Userassignable"), 315, 15, Colour::LIGHTTEXT);
107 drawText(tr("Learning! Press any hardwired key to exit!"), 15, area.h - 30, Colour::SELECTHIGHLIGHT);
111 drawText(tr("Press [ok] for learning or MENU to reset to defaults! "), 15, area.h - 30, Colour::LIGHTTEXT);
120 void VRemoteConfig::processMessage(Message* m)
122 Log::getInstance()->log("VRecordingList", Log::DEBUG, "Got message value %lu", m->message);
124 if (m->message == Message::MOUSE_MOVE)
126 if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
128 sl.setShowSelOption(true);
130 viewman->updateView(this);
133 else if (m->message == Message::MOUSE_LBDOWN)
135 if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
137 ViewMan::getInstance()->handleCommand(Remote::OK); //simulate OK press
141 //check if press is outside this view! then simulate cancel
142 int x=(m->parameter>>16)-getScreenX();
143 int y=(m->parameter&0xFFFF)-getScreenY();
144 if (x<0 || y <0 || x>getWidth() || y>getHeight())
146 ViewMan::getInstance()->handleCommand(Remote::BACK); //simulate cancel press
154 void VRemoteConfig::doSave()
156 Message* m = new Message();
157 m->message = Message::CHANGED_REMOTECONTROL;
160 Command::getInstance()->postMessageNoLock(m);
165 int VRemoteConfig::handleCommand(int command)
170 if (command == Remote::NA_LEARN)
172 initSelectList(false);
175 viewman->updateView(this);
183 if (sl.getCurrentOption() != 0)
186 sl.setShowSelOption(true);
188 viewman->updateView(this);
193 sl.setShowSelOption(false);
194 return 0; //Control to tab control
197 case Remote::DF_DOWN:
200 Log::getInstance()->log("P", Log::DEBUG, "1");
202 sl.setShowSelOption(true);
203 Log::getInstance()->log("P", Log::DEBUG, "1.5");
205 Log::getInstance()->log("P", Log::DEBUG, "2");
208 Log::getInstance()->log("P", Log::DEBUG, "3");
209 viewman->updateView(this);
210 Log::getInstance()->log("P", Log::DEBUG, "4");
213 case Remote::SKIPBACK:
219 viewman->updateView(this);
222 case Remote::SKIPFORWARD:
228 viewman->updateView(this);
235 remote->EnterLearningMode(sl.getCurrentOptionData());
236 viewman->updateView(this);
243 // Instead of returning 4 here which would delete this view
244 // before the doSave message is processed, let the message queue
245 // do the doSave then this close message. That will make the options menu
246 // disappear before this view
248 Message* m = new Message();
249 m->message = Message::CLOSE_ME;
252 Command::getInstance()->postMessageNoLock(m);
258 remote->ResetToDefault();
259 initSelectList(false);
261 viewman->updateView(this);
267 // stop command getting to any more views