--- /dev/null
+/*
+ Copyright 2004-2008 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.
+*/
+
+#include "vrecording.h"
+
+#include "remote.h"
+#include "recinfo.h"
+#include "vquestion.h"
+#include "vinfo.h"
+#include "vdr.h"
+#include "colour.h"
+#include "video.h"
+#include "i18n.h"
+#include "command.h"
+#include "vrecmove.h"
+#include "boxstack.h"
+#include "recman.h"
+#include "vrecordinglist.h"
+#include "recording.h"
+#include "message.h"
+#include "log.h"
+
+VRecording::VRecording(RecMan* trecman, Recording* trec)
+{
+ rec = trec;
+ recman = trecman;
+
+ Log::getInstance()->log("VRecording", Log::DEBUG, "%s", rec->getProgName());
+ rec->loadRecInfo();
+ Log::getInstance()->log("VRecording", Log::DEBUG, "%s", rec->getProgName());
+
+ setSize(570, 420);
+ createBuffer();
+ if (Video::getInstance()->getFormat() == Video::PAL)
+ {
+ setPosition(80, 70);
+ }
+ else
+ {
+ setPosition(70, 35);
+ }
+
+ setTitleBarOn(1);
+ setBorderOn(1);
+ setTitleText(rec->getProgName());
+ setTitleBarColour(Colour::TITLEBARBACKGROUND);
+
+ summary.setPosition(10, 30 + 5);
+ summary.setSize(area.w - 20, area.h - 30 - 15 - 50);
+ summary.setParaMode(true);
+
+ if (strlen(rec->recInfo->summary))
+ summary.setText(rec->recInfo->summary);
+ else
+ summary.setText(tr("Summary unavailable"));
+
+ add(&summary);
+
+
+ buttonPlay.setPosition(70, area.h - 40);
+ buttonResume.setPosition(180, area.h - 40);
+ buttonMove.setPosition(290, area.h - 40);
+ buttonDelete.setPosition(400, area.h - 40);
+
+ buttonRegion.x = 70;
+ buttonRegion.y = area.h - 40;
+ buttonRegion.w = 460;
+ buttonRegion.h = Surface::getFontHeight();
+
+ buttonPlay.setText(tr("Play"));
+ buttonResume.setText(tr("Resume"));
+ buttonMove.setText(tr("Move"));
+ buttonDelete.setText(tr("Delete"));
+
+ add(&buttonPlay);
+ add(&buttonResume);
+ add(&buttonMove);
+ add(&buttonDelete);
+
+ buttonPlay.setActive(1);
+ selected = 1;
+}
+
+VRecording::~VRecording()
+{
+}
+
+void VRecording::setParent(VRecordingList* tvRecList)
+{
+ vRecList = tvRecList;
+}
+
+void VRecording::draw()
+{
+ TBBoxx::draw();
+}
+
+int VRecording::handleCommand(int command)
+{
+ switch(command)
+ {
+ case Remote::LEFT:
+ case Remote::DF_UP:
+ case Remote::UP:
+ {
+ doLeft();
+ return 2;
+ }
+ case Remote::RIGHT:
+ case Remote::DF_DOWN:
+ case Remote::DOWN:
+ {
+ doRight();
+ return 2;
+ }
+ case Remote::OK:
+ {
+
+ if (selected == 1)
+ {
+ Message* m = new Message(); // Must be done after this view deleted
+ m->from = this;
+ m->to = vRecList;
+ m->message = Message::PLAY_SELECTED_RECORDING;
+ Command::getInstance()->postMessageNoLock(m);
+ return 4;
+ }
+
+ if (selected == 2)
+ {
+ Message* m = new Message(); // Must be done after this view deleted
+ m->from = this;
+ m->to = vRecList;
+ m->message = Message::RESUME_SELECTED_RECORDING;
+ Command::getInstance()->postMessageNoLock(m);
+ return 4;
+ }
+
+ if (selected == 3)
+ {
+ VRecMove* vrm = new VRecMove(recman);
+ vrm->setParent(this);
+ vrm->draw();
+ BoxStack::getInstance()->add(vrm);
+ BoxStack::getInstance()->update(vrm);
+ return 2;
+ }
+
+ if (selected == 4)
+ {
+ VQuestion* v = new VQuestion(this);
+ v->setSize(260, 180);
+ v->createBuffer();
+ v->setTitleBarColour(Colour::DANGER);
+ v->setTitleBarOn(1);
+ v->setBorderOn(1);
+ v->setTitleText(tr("Delete recording"));
+ v->setMainText(tr("Are you sure you want to delete this recording?"));
+ v->setDefault(VQuestion::NO);
+ if (Video::getInstance()->getFormat() == Video::PAL)
+ {
+ v->setPosition(230, 160);
+ }
+ else
+ {
+ v->setPosition(220, 140);
+ }
+
+ v->draw();
+ BoxStack::getInstance()->add(v);
+ BoxStack::getInstance()->update(v);
+ return 2;
+ }
+ }
+
+ case Remote::BACK:
+ {
+ return 4;
+ }
+ }
+ // stop command getting to any more views
+ return 1;
+}
+
+void VRecording::doRight()
+{
+ switch(selected)
+ {
+ case 1:
+ buttonPlay.setActive(0);
+ buttonResume.setActive(1);
+ buttonPlay.draw();
+ buttonResume.draw();
+ break;
+ case 2:
+ buttonResume.setActive(0);
+ buttonMove.setActive(1);
+ buttonResume.draw();
+ buttonMove.draw();
+ break;
+ case 3:
+ buttonMove.setActive(0);
+ buttonDelete.setActive(1);
+ buttonMove.draw();
+ buttonDelete.draw();
+ break;
+ case 4:
+ buttonDelete.setActive(0);
+ buttonPlay.setActive(1);
+ buttonDelete.draw();
+ buttonPlay.draw();
+ break;
+ }
+
+ if (++selected == 5) selected = 1;
+
+ BoxStack::getInstance()->update(this, &buttonRegion);
+}
+
+void VRecording::doLeft()
+{
+ switch(selected)
+ {
+ case 1:
+ buttonPlay.setActive(0);
+ buttonDelete.setActive(1);
+ buttonPlay.draw();
+ buttonDelete.draw();
+ break;
+ case 2:
+ buttonResume.setActive(0);
+ buttonPlay.setActive(1);
+ buttonResume.draw();
+ buttonPlay.draw();
+ break;
+ case 3:
+ buttonMove.setActive(0);
+ buttonResume.setActive(1);
+ buttonMove.draw();
+ buttonResume.draw();
+ break;
+ case 4:
+ buttonDelete.setActive(0);
+ buttonMove.setActive(1);
+ buttonDelete.draw();
+ buttonMove.draw();
+ break;
+ }
+
+ if (--selected == 0) selected = 4;
+
+ BoxStack::getInstance()->update(this, &buttonRegion);
+}
+
+void VRecording::processMessage(Message* m)
+{
+/*
+ if (m->message == Message::MOUSE_MOVE)
+ {
+ if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
+ {
+ sl.draw();
+ BoxStack::getInstance()->update(this);
+ }
+ }
+ else if (m->message == Message::MOUSE_LBDOWN)
+ {
+ if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
+ {
+ BoxStack::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>(int)getWidth() || y>(int)getHeight())
+ {
+ BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press
+ }
+ }
+ }
+ */
+ if (m->message == Message::QUESTION_YES)
+ {
+ if (selected == 4)
+ {
+ Message* m2 = new Message(); // Delete self
+ m2->from = this;
+ m2->to = BoxStack::getInstance();
+ m2->message = Message::CLOSE_ME;
+ Command::getInstance()->postMessageNoLock(m2);
+
+ m2 = new Message(); // OK. Want this to delete before this message does its job
+ m2->from = this;
+ m2->to = vRecList;
+ m2->message = Message::DELETE_SELECTED_RECORDING;
+ Command::getInstance()->postMessageNoLock(m2);
+ }
+ }
+ else if (m->message == Message::MOVE_RECORDING)
+ {
+ Message* m2 = new Message(); // Delete self
+ m2->from = this;
+ m2->to = BoxStack::getInstance();
+ m2->message = Message::CLOSE_ME;
+ Command::getInstance()->postMessageNoLock(m2);
+
+ m2 = new Message();
+ m2->from = this;
+ m2->to = vRecList;
+ m2->message = Message::MOVE_RECORDING;
+ m2->parameter = m->parameter;
+ Command::getInstance()->postMessageNoLock(m2);
+ }
+}
+
--- /dev/null
+/*
+ Copyright 2004-2008 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 VRECORDING_H
+#define VRECORDING_H
+
+#include <stdio.h>
+#include <string.h>
+
+#include "tbboxx.h"
+#include "wbutton.h"
+#include "wtextbox.h"
+
+class VRecordingList;
+class RecMan;
+class Recording;
+class Message;
+
+class VRecording : public TBBoxx
+{
+ public:
+ VRecording(RecMan* recman, Recording* rec);
+ ~VRecording();
+ void setParent(VRecordingList* tvRecList);
+
+ void draw();
+
+ int handleCommand(int command);
+ void processMessage(Message* m);
+
+ private:
+ RecMan* recman;
+ VRecordingList* vRecList;
+ Recording* rec;
+
+ WTextbox summary;
+
+ WButton buttonPlay; // 1
+ WButton buttonResume; // 2
+ WButton buttonMove; // 3
+ WButton buttonDelete; // 4
+
+ int selected;
+ Region buttonRegion;
+
+ void doLeft();
+ void doRight();
+};
+
+#endif