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"
29 WRemoteConfig::WRemoteConfig()
31 remote = InputMan::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 = InputMan::CommandDesc((UCHAR)i);
67 //char *line = remote->CommandTranslateStr((UCHAR)i);
69 const char* line = "UNK,FIXME";
71 sl.addOption(line,i,0);
76 sl.hintSetCurrent(selection);
81 void WRemoteConfig::setSize(UINT w, UINT h)
84 sl.setSize(area.w - 20, area.h - 70);
87 void WRemoteConfig::draw()
91 drawText(tr("Command"), 15, 4, DrawStyle::LIGHTTEXT);
92 drawText(tr("Hard wired"), 165, 4, DrawStyle::LIGHTTEXT);
93 drawText(tr("User assignable"), 315, 4, DrawStyle::LIGHTTEXT);
97 drawText(tr("Learning! Press any hardwired key to exit."), 15, area.h - 30, DrawStyle::SELECTHIGHLIGHT);
101 drawText(tr("Press [ok] for learning or MENU to reset to defaults."), 15, area.h - 30, DrawStyle::LIGHTTEXT);
105 bool WRemoteConfig::mouseLBDOWN(int x, int y)
107 if (sl.mouseLBDOWN(x,y))
109 BoxStack::getInstance()->handleCommand(Input::OK); //simulate OK press
115 bool WRemoteConfig::mouseMove(int x, int y)
117 if (sl.mouseMove(x,y))
119 sl.setShowSelOption(true);
126 void WRemoteConfig::processMessage(Message* m)
128 Log::getInstance()->log("VRecordingList", Log::DEBUG, "Got message value %lu", m->message);
130 if (m->message == Message::MOUSE_MOVE)
132 if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
134 sl.setShowSelOption(true);
136 viewman->updateView(this);
139 else if (m->message == Message::MOUSE_LBDOWN)
141 if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
143 ViewMan::getInstance()->handleCommand(Input::OK); //simulate OK press
147 //check if press is outside this view! then simulate cancel
148 int x=(m->parameter>>16)-getScreenX();
149 int y=(m->parameter&0xFFFF)-getScreenY();
150 if (x<0 || y <0 || x>getWidth() || y>getHeight())
152 ViewMan::getInstance()->handleCommand(Input::BACK); //simulate cancel press
160 void WRemoteConfig::doSave()
162 Message* m = new Message();
163 m->message = Message::CHANGED_REMOTECONTROL;
166 //Command::getInstance()->postMessage(m);
171 int WRemoteConfig::handleCommand(int command)
176 if (command == Input::NA_LEARN)
178 initSelectList(false);
186 if (sl.getCurrentOption() != 0)
193 sl.setShowSelOption(false);
195 return 4; // return control to vopts
203 sl.setShowSelOption(true);
211 case Input::SKIPBACK:
216 case Input::SKIPFORWARD:
224 // remote->EnterLearningMode(sl.getCurrentOptionData()); FIXME
233 // Instead of returning 4 here which would delete this view
234 // before the doSave message is processed, let the message queue
235 // do the doSave then this close message. That will make the options menu
236 // disappear before this view
238 Message* m = new Message();
239 m->message = Message::CLOSE_ME;
242 //Command::getInstance()->postMessage(m);
248 // remote->ResetToDefault(); FIXME
249 initSelectList(false);