2 Copyright 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 "wremoteconfig.h"
29 WRemoteConfig::WRemoteConfig()
31 remote = Remote::getInstance();
35 sl.setShowSelOption(false);
36 sl.setPosition(10, 30);
41 WRemoteConfig::~WRemoteConfig()
45 void WRemoteConfig::initSelectList(bool startup)
52 selection = sl.getCurrentOption();
53 top = sl.getTopOption();
62 for (i = 0; i < 256; i++)
64 const char * name = remote->CommandDesc((UCHAR)i);
67 char *line = remote->CommandTranslateStr((UCHAR)i);
68 sl.addOption(line,i,0);
73 sl.hintSetCurrent(selection);
78 void WRemoteConfig::setSize(UINT w, UINT h)
81 sl.setSize(area.w - 20, area.h - 70);
84 void WRemoteConfig::draw()
88 drawText(tr("Command"), 15, 4, Colour::LIGHTTEXT);
89 drawText(tr("Hard wired"), 165, 4, Colour::LIGHTTEXT);
90 drawText(tr("User assignable"), 315, 4, Colour::LIGHTTEXT);
94 drawText(tr("Learning! Press any hardwired key to exit!"), 15, area.h - 30, Colour::SELECTHIGHLIGHT);
98 drawText(tr("Press [ok] for learning or MENU to reset to defaults! "), 15, area.h - 30, Colour::LIGHTTEXT);
102 bool WRemoteConfig::mouseLBDOWN(int x, int y)
104 if (sl.mouseLBDOWN(x,y))
106 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press
112 bool WRemoteConfig::mouseMove(int x, int y)
114 if (sl.mouseMove(x,y))
116 sl.setShowSelOption(true);
123 void WRemoteConfig::processMessage(Message* m)
125 Log::getInstance()->log("VRecordingList", Log::DEBUG, "Got message value %lu", m->message);
127 if (m->message == Message::MOUSE_MOVE)
129 if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
131 sl.setShowSelOption(true);
133 viewman->updateView(this);
136 else if (m->message == Message::MOUSE_LBDOWN)
138 if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
140 ViewMan::getInstance()->handleCommand(Remote::OK); //simulate OK press
144 //check if press is outside this view! then simulate cancel
145 int x=(m->parameter>>16)-getScreenX();
146 int y=(m->parameter&0xFFFF)-getScreenY();
147 if (x<0 || y <0 || x>getWidth() || y>getHeight())
149 ViewMan::getInstance()->handleCommand(Remote::BACK); //simulate cancel press
157 void WRemoteConfig::doSave()
159 Message* m = new Message();
160 m->message = Message::CHANGED_REMOTECONTROL;
163 Command::getInstance()->postMessageNoLock(m);
168 int WRemoteConfig::handleCommand(int command)
173 if (command == Remote::NA_LEARN)
175 initSelectList(false);
184 if (sl.getCurrentOption() != 0)
191 sl.setShowSelOption(false);
193 return 4; // return control to vopts
196 case Remote::DF_DOWN:
202 sl.setShowSelOption(true);
210 case Remote::SKIPBACK:
215 case Remote::SKIPFORWARD:
223 remote->EnterLearningMode(sl.getCurrentOptionData());
232 // Instead of returning 4 here which would delete this view
233 // before the doSave message is processed, let the message queue
234 // do the doSave then this close message. That will make the options menu
235 // disappear before this view
237 Message* m = new Message();
238 m->message = Message::CLOSE_ME;
241 Command::getInstance()->postMessageNoLock(m);
247 remote->ResetToDefault();
248 initSelectList(false);