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, see <https://www.gnu.org/licenses/>.
20 #include "wremoteconfig.h"
28 WRemoteConfig::WRemoteConfig()
30 remote = Remote::getInstance();
34 sl.setShowSelOption(false);
35 sl.setPosition(10, 30);
40 WRemoteConfig::~WRemoteConfig()
44 void WRemoteConfig::initSelectList(bool startup)
51 selection = sl.getCurrentOption();
52 top = sl.getTopOption();
61 for (i = 0; i < 256; i++)
63 const char * name = remote->CommandDesc((UCHAR)i);
66 char *line = remote->CommandTranslateStr((UCHAR)i);
67 sl.addOption(line,i,0);
72 sl.hintSetCurrent(selection);
77 void WRemoteConfig::setSize(UINT w, UINT h)
80 sl.setSize(area.w - 20, area.h - 70);
83 void WRemoteConfig::draw()
87 drawText(tr("Command"), 15, 4, DrawStyle::LIGHTTEXT);
88 drawText(tr("Hard wired"), 165, 4, DrawStyle::LIGHTTEXT);
89 drawText(tr("User assignable"), 315, 4, DrawStyle::LIGHTTEXT);
93 drawText(tr("Learning! Press any hardwired key to exit."), 15, area.h - 30, DrawStyle::SELECTHIGHLIGHT);
97 drawText(tr("Press [ok] for learning or MENU to reset to defaults."), 15, area.h - 30, DrawStyle::LIGHTTEXT);
101 bool WRemoteConfig::mouseLBDOWN(int x, int y)
103 if (sl.mouseLBDOWN(x,y))
105 BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press
111 bool WRemoteConfig::mouseMove(int x, int y)
113 if (sl.mouseMove(x,y))
115 sl.setShowSelOption(true);
122 void WRemoteConfig::processMessage(Message* m)
124 Log::getInstance()->log("VRecordingList", Log::DEBUG, "Got message value %lu", m->message);
126 if (m->message == Message::MOUSE_MOVE)
128 if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
130 sl.setShowSelOption(true);
132 viewman->updateView(this);
135 else if (m->message == Message::MOUSE_LBDOWN)
137 if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
139 ViewMan::getInstance()->handleCommand(Remote::OK); //simulate OK press
143 //check if press is outside this view! then simulate cancel
144 int x=(m->parameter>>16)-getScreenX();
145 int y=(m->parameter&0xFFFF)-getScreenY();
146 if (x<0 || y <0 || x>getWidth() || y>getHeight())
148 ViewMan::getInstance()->handleCommand(Remote::BACK); //simulate cancel press
156 void WRemoteConfig::doSave()
158 Message* m = new Message();
159 m->message = Message::CHANGED_REMOTECONTROL;
162 //Command::getInstance()->postMessage(m);
167 int WRemoteConfig::handleCommand(int command)
172 if (command == Remote::NA_LEARN)
174 initSelectList(false);
183 if (sl.getCurrentOption() != 0)
190 sl.setShowSelOption(false);
192 return 4; // return control to vopts
195 case Remote::DF_DOWN:
201 sl.setShowSelOption(true);
209 case Remote::SKIPBACK:
214 case Remote::SKIPFORWARD:
222 remote->EnterLearningMode(sl.getCurrentOptionData());
231 // Instead of returning 4 here which would delete this view
232 // before the doSave message is processed, let the message queue
233 // do the doSave then this close message. That will make the options menu
234 // disappear before this view
236 Message* m = new Message();
237 m->message = Message::CLOSE_ME;
240 //Command::getInstance()->postMessage(m);
246 remote->ResetToDefault();
247 initSelectList(false);