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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "vremoteconfig.h"
33 VRemoteConfig::VRemoteConfig(void* tparent)
36 viewman = ViewMan::getInstance();
37 remote = Remote::getInstance();
42 if (Video::getInstance()->getFormat() == Video::PAL)
51 setBackgroundColour(Colour::VIEWBACKGROUND);
53 setTitleBarColour(Colour::TITLEBARBACKGROUND);
54 setTitleText(tr("Remote control"));
59 sl.setShowSelOption(false);
65 VRemoteConfig::~VRemoteConfig()
70 void VRemoteConfig::initSelectList(bool startup)
76 selection=sl.getCurrentOption();
77 top=sl.getTopOption();
80 // sl.setSurface(surface);
81 // sl.setSurfaceOffset(10, 40);
82 // sl.setDimensions(area.w - 20, area.h - 30 - 15 -30 );
88 for (i = 0; i < 256;i++)
90 const char * name = remote->CommandDesc((UCHAR)i);
93 char *line = remote->CommandTranslateStr((UCHAR)i);
94 // char * desc=new char [strlen(line)+1]; // CJT memory leak and unneccessary?
96 sl.addOption(line,i,0);
101 sl.hintSetCurrent(selection);
107 void VRemoteConfig::draw()
111 drawText(tr("Command"), 15, 15, Colour::LIGHTTEXT);
112 drawText(tr("Hard wired"), 165, 15, Colour::LIGHTTEXT);
113 drawText(tr("User assignable"), 315, 15, Colour::LIGHTTEXT);
117 drawText(tr("Learning! Press any hardwired key to exit."), 15, area.h - 30, Colour::SELECTHIGHLIGHT);
121 drawText(tr("Press [ok] for learning or MENU to reset to defaults."), 15, area.h - 30, Colour::LIGHTTEXT);
130 void VRemoteConfig::processMessage(Message* m)
132 Log::getInstance()->log("VRecordingList", Log::DEBUG, "Got message value %lu", m->message);
134 if (m->message == Message::MOUSE_MOVE)
136 if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
138 sl.setShowSelOption(true);
140 viewman->updateView(this);
143 else if (m->message == Message::MOUSE_LBDOWN)
145 if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
147 ViewMan::getInstance()->handleCommand(Remote::OK); //simulate OK press
151 //check if press is outside this view! then simulate cancel
152 int x=(m->parameter>>16)-getScreenX();
153 int y=(m->parameter&0xFFFF)-getScreenY();
154 if (x<0 || y <0 || x>getWidth() || y>getHeight())
156 ViewMan::getInstance()->handleCommand(Remote::BACK); //simulate cancel press
164 void VRemoteConfig::doSave()
166 Message* m = new Message();
167 m->message = Message::CHANGED_REMOTECONTROL;
170 Command::getInstance()->postMessageNoLock(m);
175 int VRemoteConfig::handleCommand(int command)
180 if (command == Remote::NA_LEARN)
182 initSelectList(false);
185 viewman->updateView(this);
193 if (sl.getCurrentOption() != 0)
196 sl.setShowSelOption(true);
198 viewman->updateView(this);
203 sl.setShowSelOption(false);
204 return 0; //Control to tab control
207 case Remote::DF_DOWN:
210 Log::getInstance()->log("P", Log::DEBUG, "1");
212 sl.setShowSelOption(true);
213 Log::getInstance()->log("P", Log::DEBUG, "1.5");
215 Log::getInstance()->log("P", Log::DEBUG, "2");
218 Log::getInstance()->log("P", Log::DEBUG, "3");
219 viewman->updateView(this);
220 Log::getInstance()->log("P", Log::DEBUG, "4");
223 case Remote::SKIPBACK:
229 viewman->updateView(this);
232 case Remote::SKIPFORWARD:
238 viewman->updateView(this);
245 remote->EnterLearningMode(sl.getCurrentOptionData());
246 viewman->updateView(this);
253 // Instead of returning 4 here which would delete this view
254 // before the doSave message is processed, let the message queue
255 // do the doSave then this close message. That will make the options menu
256 // disappear before this view
258 Message* m = new Message();
259 m->message = Message::CLOSE_ME;
262 Command::getInstance()->postMessageNoLock(m);
268 remote->ResetToDefault();
269 initSelectList(false);
271 viewman->updateView(this);
277 // stop command getting to any more views