From d7c9931fa2565c9a7dd3efb5dc9d4ec0b3fb51dc Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Thu, 15 Mar 2007 17:13:55 +0000 Subject: [PATCH] Use vchannelselector on vchannellist --- vaudioselector.h | 2 +- vchannellist.cc | 59 +++++++++++++++++++++++++++++++++++++++-------- vchannellist.h | 3 ++- vchannelselect.cc | 8 +++---- vchannelselect.h | 4 ++-- 5 files changed, 58 insertions(+), 18 deletions(-) diff --git a/vaudioselector.h b/vaudioselector.h index e1efc04..1eff1b8 100644 --- a/vaudioselector.h +++ b/vaudioselector.h @@ -59,7 +59,7 @@ class VAudioSelector : public View ~VAudioSelector(); int handleCommand(int command); - void processMessage(Message* m); + void processMessage(Message* m); void draw(); private: diff --git a/vchannellist.cc b/vchannellist.cc index f9aa5d4..54a2882 100644 --- a/vchannellist.cc +++ b/vchannellist.cc @@ -22,6 +22,7 @@ VChannelList::VChannelList(ULONG type) { + viewman = ViewMan::getInstance(); create(570, 420); if (Video::getInstance()->getFormat() == Video::PAL) { @@ -93,7 +94,7 @@ void VChannelList::highlightChannel(Channel* chan) sl.hintSetCurrent(chan->index); sl.draw(); doShowingBar(); - ViewMan::getInstance()->updateView(this); + viewman->updateView(this); } void VChannelList::draw() @@ -158,7 +159,7 @@ int VChannelList::handleCommand(int command) sl.draw(); doShowingBar(); - ViewMan::getInstance()->updateView(this); + viewman->updateView(this); return 2; } case Remote::DF_DOWN: @@ -168,7 +169,7 @@ int VChannelList::handleCommand(int command) sl.draw(); doShowingBar(); - ViewMan::getInstance()->updateView(this); + viewman->updateView(this); return 2; } case Remote::SKIPBACK: @@ -177,7 +178,7 @@ int VChannelList::handleCommand(int command) sl.draw(); doShowingBar(); - ViewMan::getInstance()->updateView(this); + viewman->updateView(this); return 2; } case Remote::SKIPFORWARD: @@ -186,7 +187,24 @@ int VChannelList::handleCommand(int command) sl.draw(); doShowingBar(); - ViewMan::getInstance()->updateView(this); + viewman->updateView(this); + return 2; + } + case Remote::ZERO: + case Remote::ONE: + case Remote::TWO: + case Remote::THREE: + case Remote::FOUR: + case Remote::FIVE: + case Remote::SIX: + case Remote::SEVEN: + case Remote::EIGHT: + case Remote::NINE: + { + VChannelSelect* v = new VChannelSelect(this, command); + v->draw(); + viewman->add(v); + viewman->updateView(v); return 2; } case Remote::OK: @@ -199,8 +217,8 @@ int VChannelList::handleCommand(int command) VVideoLive* v = new VVideoLive(chanList, chan->type, this); v->draw(); - ViewMan::getInstance()->add(v); - ViewMan::getInstance()->updateView(v); + viewman->add(v); + viewman->updateView(v); v->channelChange(VVideoLive::NUMBER, chan->number); @@ -223,14 +241,14 @@ void VChannelList::processMessage(Message* m) { sl.draw(); doShowingBar(); - ViewMan::getInstance()->updateView(this); + 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 + viewman->handleCommand(Remote::OK); //simulate OK press } else { //check if press is outside this view! then simulate cancel @@ -238,8 +256,29 @@ void VChannelList::processMessage(Message* m) int y=(m->parameter&0xFFFF)-getScreenY(); if (x<0 || y <0 || x>getWidth() || y>getHeight()) { - ViewMan::getInstance()->handleCommand(Remote::BACK); //simulate cancel press + viewman->handleCommand(Remote::BACK); //simulate cancel press + } + } + } + else if (m->message == Message::CHANNEL_CHANGE) + { + bool isinlist = false; + + for (UINT i = 0; i < chanList->size(); i++) + { + if ((*chanList)[i]->number == m->parameter) + { + isinlist = true; + break; } } + if (!isinlist) return; + + VVideoLive* v = new VVideoLive(chanList, VDR::VIDEO, this); // FIXME - what's wrong with it? + + v->draw(); + viewman->add(v); + viewman->updateView(v); + v->channelChange(VVideoLive::NUMBER, m->parameter); } } diff --git a/vchannellist.h b/vchannellist.h index a0b2cbd..0421573 100644 --- a/vchannellist.h +++ b/vchannellist.h @@ -36,6 +36,7 @@ #include "colour.h" #include "video.h" #include "i18n.h" +#include "message.h" class VChannelList : public View { @@ -45,12 +46,12 @@ class VChannelList : public View void setList(ChannelList* chanList); void highlightChannel(Channel* channel); - void processMessage(Message* m); int handleCommand(int command); void draw(); private: + ViewMan* viewman; ChannelList* chanList; WSelectList sl; diff --git a/vchannelselect.cc b/vchannelselect.cc index 8df54f6..ad1351c 100644 --- a/vchannelselect.cc +++ b/vchannelselect.cc @@ -23,7 +23,7 @@ // this class only works as it does because the remote command // values for the numbers are the numbers themselves ! -VChannelSelect::VChannelSelect(VVideoLive* v, int command) +VChannelSelect::VChannelSelect(View* v, int command) { create(53, 30); setScreenPos(80, 60); @@ -35,7 +35,7 @@ VChannelSelect::VChannelSelect(VVideoLive* v, int command) third = command; numGot = 1; - videoLive = v; + parent = v; } VChannelSelect::~VChannelSelect() @@ -156,7 +156,7 @@ int VChannelSelect::handleCommand(int command) { Message* m = new Message(); m->from = this; - m->to = videoLive; + m->to = parent; m->message = Message::CHANNEL_CHANGE; m->parameter = (first * 100) + (second * 10) + third; Command::getInstance()->postMessageNoLock(m); @@ -202,7 +202,7 @@ void VChannelSelect::timercall(int clientReference) m = new Message(); // Must be done after this view deleted m->from = this; - m->to = videoLive; + m->to = parent; m->message = Message::CHANNEL_CHANGE; m->parameter = newChannel; Command::getInstance()->postMessageFromOuterSpace(m); diff --git a/vchannelselect.h b/vchannelselect.h index a1cc793..814da3f 100644 --- a/vchannelselect.h +++ b/vchannelselect.h @@ -38,7 +38,7 @@ class VVideoLive; class VChannelSelect : public View, public TimerReceiver { public: - VChannelSelect(VVideoLive* v, int command); + VChannelSelect(View* v, int command); ~VChannelSelect(); void draw(); @@ -52,7 +52,7 @@ class VChannelSelect : public View, public TimerReceiver int numGot; - VVideoLive* videoLive; + View* parent; }; #endif -- 2.39.5