+++ /dev/null
-/*
- Copyright 2004-2007 Chris Tallon, Marten Richter
-
- This file is part of VOMP.
-
- VOMP is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- VOMP is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with VOMP; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*/
-
-#include "vremoteconfig.h"
-
-#include "remote.h"
-#include "wsymbol.h"
-#include "viewman.h"
-#include "vdr.h"
-#include "colour.h"
-#include "video.h"
-#include "i18n.h"
-#include "command.h"
-#include "message.h"
-
-VRemoteConfig::VRemoteConfig(void* tparent)
-{
- parent = tparent;
- viewman = ViewMan::getInstance();
- remote = Remote::getInstance();
- learnmode = false;
-
-
- create(530, 320);
- if (Video::getInstance()->getFormat() == Video::PAL)
- {
- setScreenPos(80, 70);
- }
- else
- {
- setScreenPos(70, 35);
- }
-
- setBackgroundColour(Colour::VIEWBACKGROUND);
- setTitleBarOn(1);
- setTitleBarColour(Colour::TITLEBARBACKGROUND);
- setTitleText(tr("Remote control"));
-
-
-
- initSelectList(true);
- sl.setShowSelOption(false);
-
-
-
-}
-
-VRemoteConfig::~VRemoteConfig()
-{
-
-}
-
-void VRemoteConfig::initSelectList(bool startup)
-{
- ULONG selection=0;
- ULONG top=0;
- if (!startup)
- {
- selection=sl.getCurrentOption();
- top=sl.getTopOption();
-
- }
-// sl.setSurface(surface);
-// sl.setSurfaceOffset(10, 40);
-// sl.setDimensions(area.w - 20, area.h - 30 - 15 -30 );
- sl.clear();
- sl.addColumn(0);
- sl.addColumn(150);
- sl.addColumn(300);
- ULONG i;
- for (i = 0; i < 256;i++)
- {
- const char * name = remote->CommandDesc((UCHAR)i);
- if (name != NULL)
- {
- char *line = remote->CommandTranslateStr((UCHAR)i);
- // char * desc=new char [strlen(line)+1]; // CJT memory leak and unneccessary?
- // strcpy(desc,line);
- sl.addOption(line,i,0);
- }
- }
- if (!startup)
- {
- sl.hintSetCurrent(selection);
- sl.hintSetTop(top);
- }
-}
-
-
-void VRemoteConfig::draw()
-{
- View::draw();
-
- drawText(tr("Command"), 15, 15, Colour::LIGHTTEXT);
- drawText(tr("Hard wired"), 165, 15, Colour::LIGHTTEXT);
- drawText(tr("User assignable"), 315, 15, Colour::LIGHTTEXT);
- sl.draw();
- if (learnmode)
- {
- drawText(tr("Learning! Press any hardwired key to exit."), 15, area.h - 30, Colour::SELECTHIGHLIGHT);
- }
- else
- {
- drawText(tr("Press [ok] for learning or MENU to reset to defaults."), 15, area.h - 30, Colour::LIGHTTEXT);
- }
-
-
-
-
-}
-
-
-void VRemoteConfig::processMessage(Message* m)
-{
- Log::getInstance()->log("VRecordingList", Log::DEBUG, "Got message value %lu", m->message);
-
- if (m->message == Message::MOUSE_MOVE)
- {
- if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
- {
- sl.setShowSelOption(true);
- sl.draw();
- viewman->updateView(this);
- }
- }
- else if (m->message == Message::MOUSE_LBDOWN)
- {
- if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
- {
- ViewMan::getInstance()->handleCommand(Remote::OK); //simulate OK press
- }
- else
- {
- //check if press is outside this view! then simulate cancel
- int x=(m->parameter>>16)-getScreenX();
- int y=(m->parameter&0xFFFF)-getScreenY();
- if (x<0 || y <0 || x>getWidth() || y>getHeight())
- {
- ViewMan::getInstance()->handleCommand(Remote::BACK); //simulate cancel press
- }
- }
- }
-}
-
-void VRemoteConfig::doSave()
-{
- Message* m = new Message();
- m->message = Message::CHANGED_REMOTECONTROL;
- m->to = parent;
- m->parameter = 0;
- Command::getInstance()->postMessageNoLock(m);
-}
-
-int VRemoteConfig::handleCommand(int command)
-{
- if (learnmode)
- {
- learnmode = false;
- if (command == Remote::NA_LEARN)
- {
- initSelectList(false);
- }
- draw();
- viewman->updateView(this);
- return 2;
- }
- switch(command)
- {
- case Remote::DF_UP:
- case Remote::UP:
- {
- if (sl.getCurrentOption() != 0)
- {
- sl.up();
- sl.setShowSelOption(true);
- draw();
- viewman->updateView(this);
- return 2;
- }
- else
- {
- sl.setShowSelOption(false);
- return 0; //Control to tab control
- }
- }
- case Remote::DF_DOWN:
- case Remote::DOWN:
- {
- sl.down();
- sl.setShowSelOption(true);
- draw();
- viewman->updateView(this);
- return 2;
- }
- case Remote::SKIPBACK:
- {
- sl.pageUp();
- sl.draw();
-
-
- viewman->updateView(this);
- return 2;
- }
- case Remote::SKIPFORWARD:
- {
- sl.pageDown();
- sl.draw();
-
-
- viewman->updateView(this);
- return 2;
- }
- case Remote::OK:
- {
- learnmode = true;
- draw();
- remote->EnterLearningMode(sl.getCurrentOptionData());
- viewman->updateView(this);
- return 2;
- }
- case Remote::BACK:
- {
- doSave();
-
- // Instead of returning 4 here which would delete this view
- // before the doSave message is processed, let the message queue
- // do the doSave then this close message. That will make the options menu
- // disappear before this view
-
- Message* m = new Message();
- m->message = Message::CLOSE_ME;
- m->from = this;
- m->to = viewman;
- Command::getInstance()->postMessageNoLock(m);
- return 2;
-
- }
- case Remote::MENU:
- {
- remote->ResetToDefault();
- initSelectList(false);
- draw();
- viewman->updateView(this);
- return 2;
- }
-
-
- }
- // stop command getting to any more views
- return 1;
-}
-
-
+++ /dev/null
-/*
- Copyright 2004-2005 Chris Tallon
-
- This file is part of VOMP.
-
- VOMP is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- VOMP is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with VOMP; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*/
-
-#ifndef VREMOTECONFIG_H
-#define VREMOTECONFIG_H
-
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
-#include <vector>
-#include <stack>
-
-#include "view.h"
-#include "wselectlist.h"
-
-class Remote;
-class Message;
-
-class VRemoteConfig : public View
-{
- public:
- VRemoteConfig (void* tparent);
- ~VRemoteConfig ();
-
- int handleCommand(int command);
- void processMessage(Message* m);
- void draw();
-
-
- private:
- WSelectList sl;
- Remote *remote;
- bool learnmode;
- void initSelectList(bool startup);
- void doSave();
- void* parent;
-
-};
-
-#endif
-