From 564c45fa0ca8e647bb616007772c55716986a7d6 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Fri, 26 Oct 2007 22:49:42 +0000 Subject: [PATCH] Switch trunk code to new boxes --- CREDITS | 2 + GNUmakefile | 4 +- afeed.cc | 4 + afeed.h | 5 +- audio.cc | 3 +- audio.h | 1 - audiomvp.cc | 2 + audiomvp.h | 2 - audioplayer.cc | 8 +- audioplayer.h | 8 +- box.cc | 226 ---------------- box.h | 85 ------ viewman.cc => boxstack.cc | 191 +++++++------- viewman.h => boxstack.h | 51 ++-- boxx.cc | 345 ++++++++++++++++++++++++ boxx.h | 151 +++++++++++ channel.cc | 2 + channel.h | 1 - colour.cc | 2 +- command.cc | 162 +++++++----- command.h | 33 +-- defines.h | 15 ++ demuxeraudio.cc | 8 +- event.cc | 6 +- event.h | 6 +- i18n.cc | 5 +- i18n.h | 5 +- main.cc | 24 +- message.h | 1 + messagequeue.cc | 3 + messagequeue.h | 3 +- mtdmvp.cc | 2 + mtdmvp.h | 1 - objects.mk | 16 +- option.cc | 53 ++++ option.h | 50 ++++ osd.cc | 2 + osd.h | 2 +- osdwin.cc | 3 +- player.cc | 15 +- player.h | 24 +- playerradio.cc | 10 + playerradio.h | 21 +- recinfo.cc | 1 + recinfo.h | 1 - recman.cc | 1 + recording.cc | 5 + recording.h | 6 +- rectimer.h | 2 + remote.cc | 2 + remote.h | 1 - remotemvp.cc | 2 + remotemvp.h | 3 +- stream.h | 1 + surface.cc | 8 +- surface.h | 7 +- surfacemvp.cc | 2 + surfacemvp.h | 1 - surfacewin.cc | 1 + surfacewin.h | 1 - view.cc => tbboxx.cc | 63 ++--- view.h => tbboxx.h | 33 +-- tcp.cc | 2 + tcp.h | 1 - timers.cc | 4 + timers.h | 18 +- udp.cc | 5 + udp.h | 7 +- vaudioplayer.cc | 81 +++--- vaudioplayer.h | 23 +- vaudioselector.cc | 89 +++++-- vaudioselector.h | 25 +- vchannellist.cc | 78 +++--- vchannellist.h | 24 +- vchannelselect.cc | 22 +- vchannelselect.h | 18 +- vconnect.cc | 31 ++- vconnect.h | 13 +- vdr.cc | 57 +++- vdr.h | 19 +- vepg.cc | 198 ++++++++------ vepg.h | 33 ++- vepgsettimer.cc | 59 +++-- vepgsettimer.h | 24 +- vfeed.cc | 4 + vfeed.h | 6 +- vinfo.cc | 23 +- vinfo.h | 15 +- vlivebanner.cc | 58 ++-- vlivebanner.h | 19 +- vmedialist.cc | 140 +++++----- vmedialist.h | 16 +- vmute.cc | 29 +- vmute.h | 11 +- voptions.cc | 348 ------------------------ voptions.h | 72 ----- voptionsmenu.cc | 258 ------------------ voptionsmenu.h | 59 ----- vopts.cc | 293 +++++++++++++++++++++ vwallpaper.h => vopts.h | 46 ++-- vpicture.cc | 70 +++-- vpicture.h | 24 +- vpicturebanner.cc | 31 ++- vpicturebanner.h | 10 +- vquestion.cc | 38 +-- vquestion.h | 11 +- vradiorec.cc | 49 ++-- vradiorec.h | 22 +- vrecmove.cc | 49 ++-- vrecmove.h | 21 +- vrecordinglist.cc | 111 ++++---- vrecordinglist.h | 26 +- vrecordingmenu.cc | 86 +++--- vrecordingmenu.h | 20 +- vremoteconfig.cc | 16 +- vremoteconfig.h | 12 +- vscreensaver.cc | 13 +- vscreensaver.h | 10 +- vserverselect.cc | 34 ++- vserverselect.h | 15 +- vtabsviewman.cc | 438 ------------------------------- vtimeredit.cc | 117 ++++++++- vtimeredit.h | 29 +- vtimerlist.cc | 174 ++++++++---- vtimerlist.h | 19 +- vvideolive.cc | 87 ++++-- vvideolive.h | 27 +- vvideorec.cc | 168 ++++++++---- vvideorec.h | 34 +-- vvolume.cc | 36 ++- vvolume.h | 11 +- vwelcome.cc | 93 ++++--- vwelcome.h | 30 +-- wbutton.cc | 28 +- wbutton.h | 9 +- widget.cc | 66 ----- winmain.cc | 29 +- wjpeg.cc | 11 +- wjpeg.h | 15 +- wol.cc | 2 + wol.h | 3 +- woptionbox.cc | 74 ++++-- woptionbox.h | 17 +- woptionpane.cc | 169 ++++++++++++ vtabsviewman.h => woptionpane.h | 53 ++-- wremoteconfig.cc | 235 +++++++++++++++++ vwallpaper.cc => wremoteconfig.h | 46 ++-- wselectlist.cc | 14 +- wselectlist.h | 11 +- wsymbol.cc | 2 + wsymbol.h | 5 +- wtabbar.cc | 248 +++++++++++++++++ widget.h => wtabbar.h | 49 ++-- wtextbox.cc | 38 ++- wtextbox.h | 15 +- wwss.cc | 3 + wwss.h | 6 +- 157 files changed, 3836 insertions(+), 3175 deletions(-) delete mode 100644 box.cc delete mode 100644 box.h rename viewman.cc => boxstack.cc (63%) rename viewman.h => boxstack.h (61%) create mode 100644 boxx.cc create mode 100644 boxx.h create mode 100644 option.cc create mode 100644 option.h rename view.cc => tbboxx.cc (56%) rename view.h => tbboxx.h (66%) delete mode 100644 voptions.cc delete mode 100644 voptions.h delete mode 100644 voptionsmenu.cc delete mode 100644 voptionsmenu.h create mode 100644 vopts.cc rename vwallpaper.h => vopts.h (66%) delete mode 100644 vtabsviewman.cc delete mode 100644 widget.cc create mode 100644 woptionpane.cc rename vtabsviewman.h => woptionpane.h (57%) create mode 100644 wremoteconfig.cc rename vwallpaper.cc => wremoteconfig.h (60%) create mode 100644 wtabbar.cc rename widget.h => wtabbar.h (60%) diff --git a/CREDITS b/CREDITS index fd0fc9a..285ccd3 100644 --- a/CREDITS +++ b/CREDITS @@ -41,6 +41,8 @@ Marten Richter Reporting of many bugs Audio channel selection +Andreas Vogel + Media player Thanks to the following people for their work with the MVP: diff --git a/GNUmakefile b/GNUmakefile index 347c5f0..faa83f3 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -47,10 +47,10 @@ install-wmp: debug: - ../../gdb/gdb-6.3-target-ppc/gdb/gdb /diskless/nfs/mvp/vompclient /diskless/nfs/mvp/core.* + ../../gdb/gdb-6.7/gdb/gdb /diskless/nfs/mvp/vompclient /diskless/nfs/mvp/core.* debug2: - ../../gdb/gdb-6.3-target-ppc/gdb/gdb /diskless/nfs/wmvp/vompclient /diskless/nfs/wmvp/core.* + ../../gdb/gdb-6.7/gdb/gdb /diskless/nfs/wmvp/vompclient /diskless/nfs/wmvp/core.* dev: CXXFLAGS := $(CXXFLAGS_DEV) dev: vompclient diff --git a/afeed.cc b/afeed.cc index 5f86445..e942d24 100644 --- a/afeed.cc +++ b/afeed.cc @@ -20,6 +20,10 @@ #include "afeed.h" +#include "log.h" +#include "demuxer.h" +#include "callback.h" + AFeed::AFeed(Callback* tcb) : cb(*tcb) { diff --git a/afeed.h b/afeed.h index 76ec466..aef429d 100644 --- a/afeed.h +++ b/afeed.h @@ -24,16 +24,13 @@ #include #include -#include "log.h" -#include "demuxer.h" -#include "callback.h" - #ifdef WIN32 #include "threadwin.h" #else #include "threadp.h" #endif +class Callback; class AFeed : public Thread_TYPE { diff --git a/audio.cc b/audio.cc index a601421..87a05f7 100644 --- a/audio.cc +++ b/audio.cc @@ -20,6 +20,8 @@ #include "audio.h" +#include "log.h" + Audio* Audio::instance = NULL; Audio::Audio() @@ -101,7 +103,6 @@ int Audio::doMuting() { Log::getInstance()->log("Audio", Log::DEBUG, "doMuting: user=%i sys=%i", userMute, systemMute); - if (userMute || systemMute) { return mute(); diff --git a/audio.h b/audio.h index 340110c..3830bf8 100644 --- a/audio.h +++ b/audio.h @@ -23,7 +23,6 @@ #include #include "defines.h" -#include "log.h" #include "draintarget.h" typedef struct diff --git a/audiomvp.cc b/audiomvp.cc index d826534..75e2007 100644 --- a/audiomvp.cc +++ b/audiomvp.cc @@ -20,6 +20,8 @@ #include "audiomvp.h" +#include "log.h" + AudioMVP::AudioMVP() { if (instance) return; diff --git a/audiomvp.h b/audiomvp.h index fdd6f17..6e68091 100644 --- a/audiomvp.h +++ b/audiomvp.h @@ -29,10 +29,8 @@ #include #include "defines.h" -#include "log.h" #include "audio.h" - typedef struct { int parm1; diff --git a/audioplayer.cc b/audioplayer.cc index 0524362..5dd2c65 100644 --- a/audioplayer.cc +++ b/audioplayer.cc @@ -22,10 +22,14 @@ #include "vaudioplayer.h" #include "demuxeraudio.h" #include "timers.h" +#include "video.h" +#include "command.h" +#include "i18n.h" +#include "boxx.h" AudioPlayer * AudioPlayer::instance=NULL; -AudioPlayer * AudioPlayer::getInstance(View * parent,bool create) { +AudioPlayer * AudioPlayer::getInstance(Boxx * parent,bool create) { // Log::getInstance()->log("AudioPlayer",Log::DEBUG,"getInstance for view %p, instance=%p",parent,instance); AudioPlayer *np=instance; if (! np && ! create) return NULL; @@ -40,7 +44,7 @@ AudioPlayer * AudioPlayer::getInstance(View * parent,bool create) { return instance; } -AudioPlayer::AudioPlayer(View *parent) : afeed(this) +AudioPlayer::AudioPlayer(Boxx *parent) : afeed(this) { frontend=parent; audio = Audio::getInstance(); diff --git a/audioplayer.h b/audioplayer.h index 727e035..dc21bf6 100644 --- a/audioplayer.h +++ b/audioplayer.h @@ -46,7 +46,7 @@ -class View; +class Boxx; class DemuxerAudio; @@ -59,7 +59,7 @@ class AudioPlayer : public Thread_TYPE, public Callback, public TimerReceiver //later you can change the view the player is connect with //a view that "goes" should call getInstance(NULL,false) to detach //the last media view should shutdown the player - static AudioPlayer * getInstance(View * frontend, bool create=true); + static AudioPlayer * getInstance(Boxx * frontend, bool create=true); //start the player thread void run(); @@ -136,7 +136,7 @@ class AudioPlayer : public Thread_TYPE, public Callback, public TimerReceiver private: //to guess lengthes if the demux does not know const static ULONG DEFAULT_BITRATE=128000; - AudioPlayer(View *frontend); + AudioPlayer(Boxx *frontend); virtual ~AudioPlayer(); static AudioPlayer * instance; bool playerRunnig; @@ -178,7 +178,7 @@ class AudioPlayer : public Thread_TYPE, public Callback, public TimerReceiver int skipfactor; //the buffer len in bytes const static int BUFLEN=50*1024; - View *frontend; + Boxx *frontend; //requested sequence int requestedSequence; //handled sequence diff --git a/box.cc b/box.cc deleted file mode 100644 index 0203155..0000000 --- a/box.cc +++ /dev/null @@ -1,226 +0,0 @@ -/* - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "box.h" - -char Box::numBoxes = 0; - -Box::Box() -{ - area.x = 0; - area.y = 0; - area.w = 0; - area.h = 0; - - offsetX = 0; - offsetY = 0; - - gap = 6; // default gap for drawPara - - numBoxes++; - Log::getInstance()->log("Box", Log::DEBUG, "Construct, now %u", numBoxes); - - surface = NULL; -} - -Box::~Box() -{ - numBoxes--; - Log::getInstance()->log("Box", Log::DEBUG, "Destruct, now %u", numBoxes); -} - -void Box::draw() -{ -} - -void Box::setScreenPos(int x, int y) -{ - area.x = x; - area.y = y; -} - -void Box::setSurfaceOffset(UINT x, UINT y) -{ - offsetX = x; - offsetY = y; -} - -void Box::setGap(UINT tgap) -{ - gap = tgap; -} - -void Box::blt(Region& r) -{ -// Log::getInstance()->log("Box", Log::DEBUG, "Show region %p %u %u %u %u", surface, r.x, r.y, r.w, r.h); -// surface->updateToScreen(area.x, area.y, area.w, area.h); - - /* surface update to screen needs: - source x distance into this surface - source y distance into this surface - width of update - height of update - destination x on screen - destination y on screen - */ - - surface->updateToScreen(r.x - area.x, r.y - area.y, r.w, r.h, r.x, r.y); -} - -int Box::getScreenX() -{ - return area.x; -} - -int Box::getScreenY() -{ - return area.y; -} - -int Box::getWidth() -{ - return area.w; -} - -int Box::getHeight() -{ - return area.h; -} - -// Level 1 drawing functions - -void Box::fillColour(Colour& colour) -{ - rectangle(0, 0, area.w, area.h, colour); -} - -void Box::drawPara(char* text, int x, int y, Colour& colour) -{ - char line[256]; - int lineHeight = surface->getFontHeight() + gap; - - int lineWidth; - int thisCharWidth; - int textPos; - int linePos; - int ypos; - int printLine; - - textPos = 0; - ypos = y; - - while(1) - { - linePos = 0; - lineWidth = 0; - while(1) - { - printLine = 0; - - if (text[textPos] == '\0') break; - - if (text[textPos] == '\n') - { - textPos++; // ignore the \n - printLine = 1; - break; - } - - thisCharWidth = surface->getCharWidth(text[textPos]); - if ((lineWidth + thisCharWidth) > (int)(area.w - (2 * paraMargin))) - { - // this character would break the right margin - if (text[textPos] == ' ') - { - // this char is a space, ignore and break - textPos++; - break; - } - else - { - // Need to go back to the last space in the line - while ((text[textPos] != ' ') && (linePos >= 0)) - { - textPos--; - linePos--; - } - // Now take the space we just found - textPos++; - break; - } - } - line[linePos++] = text[textPos]; - lineWidth += thisCharWidth; - textPos++; - } - -// line[linePos++] = '\0'; - if (linePos>=0) line[linePos++] = '\0'; //Here is the change - - if (printLine || (linePos > 1)) // if some text was put in line - { - drawText(line, x, ypos, colour); - ypos += lineHeight; - if (ypos > (int)(area.h - lineHeight)) break; - } - else - { - break; - } - } -} - -// Level 0 drawing functions - -void Box::rectangle(int x1, int y1, int w, int h, Colour colour) -{ - surface->fillblt(offsetX + x1, offsetY + y1, w, h, colour.rgba()); -} - -void Box::rectangle(Region& region, Colour& colour) -{ - surface->fillblt(offsetX + region.x, offsetY + region.y, region.w, region.h, colour.rgba()); -} - -void Box::drawText(char* text, int x, int y, Colour& colour) -{ - surface->drawText(text, offsetX + x, offsetY + y, colour.rgba()); -} - -void Box::drawTextRJ(char* text, int x, int y, Colour& colour) -{ - surface->drawTextRJ(text, offsetX + x, offsetY + y, colour.rgba()); -} - -void Box::drawTextCentre(char* text, int x, int y, Colour& colour) -{ - surface->drawTextCentre(text, offsetX + x, offsetY + y, colour.rgba()); -} - -void Box::drawPixel(UINT x, UINT y, Colour& colour) -{ - int c = ( (0xFF000000 ) - | (colour.red << 16) - | (colour.green << 8) - | (colour.blue ) ); - - - surface->drawPixel(offsetX + x, offsetY + y, c); -} diff --git a/box.h b/box.h deleted file mode 100644 index 1908b58..0000000 --- a/box.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef BOX_H -#define BOX_H - -#include - -#include "log.h" -#include "colour.h" -#include "region.h" - -#ifdef WIN32 -#include "surfacewin.h" -#else -#include "surfacemvp.h" -#endif - -// Abstract ??????? -class Box -{ - public: - Box(); - virtual ~Box(); - - void setScreenPos(int x, int y); // Even numbers only!!! - void setSurfaceOffset(UINT x, UINT y); - void setGap(UINT gap); - - virtual void blt(Region& r); // For use only by ViewMan - - virtual void draw(); - - // Drawing functions level 1 - void fillColour(Colour& colour); - void drawPara(char* text, int x, int y, Colour& colour); - - // Drawing functions level 0 - void rectangle(int x, int y, int w, int h, Colour colour); // FIXME make this ref again - void rectangle(Region& region, Colour& colour); - - void drawText(char* text, int x, int y, Colour& colour); - void drawTextRJ(char* text, int x, int y, Colour& colour); - void drawTextCentre(char* text, int x, int y, Colour& colour); - void drawPixel(UINT x, UINT y, Colour& colour); - - int getScreenX(); - int getScreenY(); - int getWidth(); - int getHeight(); - - // so viewman can read it: - Region area; - Surface* surface; // temp - is there a get function for this? FIXME - - protected: - UINT offsetX; - UINT offsetY; - - UINT gap; - - static char numBoxes; - - static const int paraMargin = 10; - -}; - -#endif diff --git a/viewman.cc b/boxstack.cc similarity index 63% rename from viewman.cc rename to boxstack.cc index a4ebd12..6917afc 100644 --- a/viewman.cc +++ b/boxstack.cc @@ -18,37 +18,40 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "viewman.h" +#include "boxstack.h" + #include "command.h" +#include "remote.h" +#include "log.h" -ViewMan* ViewMan::instance = NULL; +BoxStack* BoxStack::instance = NULL; -ViewMan::ViewMan() +BoxStack::BoxStack() { if (instance) return; instance = this; initted = 0; - numViews = 0; + numBoxes = 0; } -ViewMan::~ViewMan() +BoxStack::~BoxStack() { instance = NULL; } -ViewMan* ViewMan::getInstance() +BoxStack* BoxStack::getInstance() { return instance; } -int ViewMan::init() +int BoxStack::init() { if (initted) return 0; initted = 1; return 1; } -int ViewMan::shutdown() +int BoxStack::shutdown() { if (!initted) return 0; @@ -59,61 +62,61 @@ int ViewMan::shutdown() return 1; } -int ViewMan::add(View* v) +int BoxStack::add(Boxx* v) { if (!initted) return 0; - if (numViews == 16) return 0; + if (numBoxes == 16) return 0; - views[numViews++] = v; + boxes[numBoxes++] = v; return 1; } // ---------------------------------------------------- REMOVE CODE -int ViewMan::removeView(View* toDelete) +int BoxStack::remove(Boxx* toDelete) { if (!initted) return 0; - if (numViews == 0) return 0; + if (numBoxes == 0) return 0; -// Log::getInstance()->log("ViewMan", Log::DEBUG, "entering remove, numViews=%i", numViews); +// Log::getInstance()->log("BoxStack", Log::DEBUG, "entering remove, numBoxes=%i", numBoxes); int i; if (toDelete == NULL) { - toDelete = views[numViews-1]; - i = numViews - 1; + toDelete = boxes[numBoxes-1]; + i = numBoxes - 1; } else { - // to be deleted view is more likely to be at the top - for (i = numViews-1; i >= 0; i--) + // to be deleted box is more likely to be at the top + for (i = numBoxes-1; i >= 0; i--) { -// Log::getInstance()->log("ViewMan", Log::DEBUG, "todel: %p, i=%i, views[i]=%p", toDelete, i, views[i]); - if (views[i] == toDelete) break; +// Log::getInstance()->log("BoxStack", Log::DEBUG, "todel: %p, i=%i, boxes[i]=%p", toDelete, i, boxes[i]); + if (boxes[i] == toDelete) break; } if (i == -1) { - // not a View we have! + // not a Box we have! return 0; } } -// Log::getInstance()->log("ViewMan", Log::DEBUG, "Starting deleteView"); - deleteView(i); -// Log::getInstance()->log("ViewMan", Log::DEBUG, "Done deleteView"); +// Log::getInstance()->log("BoxStack", Log::DEBUG, "Starting deleteBox"); + deleteBox(i); +// Log::getInstance()->log("BoxStack", Log::DEBUG, "Done deleteBox"); - // Shift the views on top down one - --numViews; - for(int j = i; j < numViews; j++) views[j] = views[j+1]; + // Shift the boxes on top down one + --numBoxes; + for(int j = i; j < numBoxes; j++) boxes[j] = boxes[j+1]; - // Delete the view + // Delete the box delete toDelete; // If there is only the wallpaper left signal command - if (numViews == 1) + if (numBoxes == 1) { Message* m = new Message(); m->to = Command::getInstance(); @@ -128,11 +131,11 @@ int ViewMan::removeView(View* toDelete) // NEW STUFF ///////////////////////////////////////////////////////////////////////////// -void ViewMan::deleteView(int z) +void BoxStack::deleteBox(int z) { -// Log::getInstance()->log("ViewMan", Log::DEBUG, "Delete view %i of %i", z, numViews); +// Log::getInstance()->log("BoxStack", Log::DEBUG, "Delete box %i of %i", z, numBoxes); RegionList rl; - boxSplit(views[z]->area, z + 1, numViews, 1, rl); + boxSplit(boxes[z]->area, z + 1, numBoxes, 1, rl); while(!rl.empty()) { repaintRevealed(z, rl.front()); @@ -140,32 +143,32 @@ void ViewMan::deleteView(int z) } } -void ViewMan::updateView(View* toUpdate, Region* regionToUpdate) +void BoxStack::update(Boxx* toUpdate, Region* regionToUpdate) { -// Log::getInstance()->log("ViewMan", Log::DEBUG, "UpdateView called"); - // Get the z index of the view +// Log::getInstance()->log("BoxStack", Log::DEBUG, "Update called"); + // Get the z index of the box int z; - for (z = 0; z < numViews; z++) + for (z = 0; z < numBoxes; z++) { - if (views[z] == toUpdate) break; + if (boxes[z] == toUpdate) break; } - if (z == numViews) + if (z == numBoxes) { - // not a View we have! + // not a Box we have! return; } - // get the region for the whole view, could be less than that + // get the region for the whole box, could be less than that // for smaller updates - Region r = views[z]->area; + Region r = toUpdate->area; if (regionToUpdate) { - // Can be null if the whole view should be updated - // If this is given the numbers are relative to the size of the view, not the screen + // Can be null if the whole box should be updated + // If this is given the numbers are relative to the size of the box, not the screen r.x += regionToUpdate->x; r.y += regionToUpdate->y; @@ -176,17 +179,17 @@ void ViewMan::updateView(View* toUpdate, Region* regionToUpdate) RegionList rl; Region r2; - boxSplit(r, z+1, numViews, 1, rl); + boxSplit(r, z+1, numBoxes, 1, rl); while(!rl.empty()) { r2 = rl.front(); r2.z = z; - views[z]->blt(r2); + boxes[z]->blt(r2); rl.pop_front(); } } -void ViewMan::repaintRevealed(int x, Region r) +void BoxStack::repaintRevealed(int x, Region r) { RegionList rl; boxSplit(r, x - 1, -1, -1, rl); @@ -195,40 +198,40 @@ void ViewMan::repaintRevealed(int x, Region r) while(!rl.empty()) { r2 = rl.front(); - views[r2.z]->blt(r2); + boxes[r2.z]->blt(r2); rl.pop_front(); } } -void ViewMan::boxSplit(Region r, int start, int end, int direction, RegionList& rl) +void BoxStack::boxSplit(Region r, int start, int end, int direction, RegionList& rl) { // printf("Y= S=%i E=%i D=%i: Boxsplit: %i %i %i %i\n", start, end, direction, r.x, r.y, r.w, r.h); for(int z = start; z != end; z += direction) { - if (r.overlappedBy(views[z]->area)) + if (r.overlappedBy(boxes[z]->area)) { // printf("Z=%i S=%i E=%i D=%i: %i overlaps\n", z, start, end, direction, z); int top = r.y; int btm = r.y2(); - if (views[z]->area.y > r.y) + if (boxes[z]->area.y > r.y) { -// printf("Z=%i S=%i E=%i D=%i: Case 1 for %i %i %i %i split by %i: %i %i %i %i\n", z, start, end, direction, r.x, r.y, r.w, r.h, z, views[z]->area.x, views[z]->area.y, views[z]->area.w, views[z]->area.h); - top = views[z]->area.y; +// printf("Z=%i S=%i E=%i D=%i: Case 1 for %i %i %i %i split by %i: %i %i %i %i\n", z, start, end, direction, r.x, r.y, r.w, r.h, z, boxes[z]->area.x, boxes[z]->area.y, boxes[z]->area.w, boxes[z]->area.h); + top = boxes[z]->area.y; Region newR; newR.x = r.x; newR.y = r.y; newR.w = r.w; - newR.h = views[z]->area.y - r.y; + newR.h = boxes[z]->area.y - r.y; boxSplit(newR, z + direction, end, direction, rl); if (direction == -1) { Region newR2; newR2.x = r.x; - newR2.y = views[z]->area.y; + newR2.y = boxes[z]->area.y; newR2.w = r.w; newR2.h = r.h - newR.h; boxSplit(newR2, z, end, -1, rl); @@ -236,13 +239,13 @@ void ViewMan::boxSplit(Region r, int start, int end, int direction, RegionList& } } - if (views[z]->area.y2() < r.y2()) + if (boxes[z]->area.y2() < r.y2()) { -// printf("Z=%i S=%i E=%i D=%i: Case 2 for %i %i %i %i split by %i: %i %i %i %i\n", z, start, end, direction, r.x, r.y, r.w, r.h, z, views[z]->area.x, views[z]->area.y, views[z]->area.w, views[z]->area.h); - btm = views[z]->area.y2(); +// printf("Z=%i S=%i E=%i D=%i: Case 2 for %i %i %i %i split by %i: %i %i %i %i\n", z, start, end, direction, r.x, r.y, r.w, r.h, z, boxes[z]->area.x, boxes[z]->area.y, boxes[z]->area.w, boxes[z]->area.h); + btm = boxes[z]->area.y2(); Region newR; newR.x = r.x; - newR.y = views[z]->area.y2() + 1; + newR.y = boxes[z]->area.y2() + 1; newR.w = r.w; newR.h = r.y2() - newR.y + 1; boxSplit(newR, z + direction, end, direction, rl); @@ -259,13 +262,13 @@ void ViewMan::boxSplit(Region r, int start, int end, int direction, RegionList& } } - if (views[z]->area.x > r.x) + if (boxes[z]->area.x > r.x) { -// printf("Z=%i S=%i E=%i D=%i: Case 3 for %i %i %i %i split by %i: %i %i %i %i\n", z, start, end, direction, r.x, r.y, r.w, r.h, z, views[z]->area.x, views[z]->area.y, views[z]->area.w, views[z]->area.h); +// printf("Z=%i S=%i E=%i D=%i: Case 3 for %i %i %i %i split by %i: %i %i %i %i\n", z, start, end, direction, r.x, r.y, r.w, r.h, z, boxes[z]->area.x, boxes[z]->area.y, boxes[z]->area.w, boxes[z]->area.h); Region newR; newR.x = r.x; newR.y = top; - newR.w = views[z]->area.x - r.x; + newR.w = boxes[z]->area.x - r.x; newR.h = btm - top + 1; boxSplit(newR, z + direction, end, direction, rl); @@ -281,11 +284,11 @@ void ViewMan::boxSplit(Region r, int start, int end, int direction, RegionList& } } - if (views[z]->area.x2() < r.x2()) + if (boxes[z]->area.x2() < r.x2()) { -// printf("Z=%i S=%i E=%i D=%i: Case 4 for %i %i %i %i split by %i: %i %i %i %i\n", z, start, end, direction, r.x, r.y, r.w, r.h, z, views[z]->area.x, views[z]->area.y, views[z]->area.w, views[z]->area.h); +// printf("Z=%i S=%i E=%i D=%i: Case 4 for %i %i %i %i split by %i: %i %i %i %i\n", z, start, end, direction, r.x, r.y, r.w, r.h, z, boxes[z]->area.x, boxes[z]->area.y, boxes[z]->area.w, boxes[z]->area.h); Region newR; - newR.x = views[z]->area.x2() + 1; + newR.x = boxes[z]->area.x2() + 1; newR.y = top; newR.w = r.x2() - newR.x + 1; newR.h = btm - top + 1; @@ -306,10 +309,10 @@ void ViewMan::boxSplit(Region r, int start, int end, int direction, RegionList& if (direction == -1) { // we are going down the stack - // r is underlapped by views[z] + // r is underlapped by boxes[z] // but we have not split // Therefore this region under test is - // completely covering views[z] + // completely covering boxes[z] // don't go any further down, generate a region and quit @@ -328,7 +331,7 @@ void ViewMan::boxSplit(Region r, int start, int end, int direction, RegionList& } // if direction = 1 then we have come to a region that is - // entirely clear of higher views and needs to be redrawn + // entirely clear of higher boxes and needs to be redrawn // if direction = -1 then we have come to a region that is on // the very bottom with nothing below it to repaint. @@ -347,16 +350,16 @@ void ViewMan::boxSplit(Region r, int start, int end, int direction, RegionList& // ---------------------------------------------------- END OF REMOVE CODE -void ViewMan::removeAll() +void BoxStack::removeAll() { // 1.. Don't delete wallpaper. No point. - for (; numViews > 1; --numViews) + for (; numBoxes > 1; --numBoxes) { - delete views[numViews-1]; + delete boxes[numBoxes-1]; } } -int ViewMan::handleCommand(int command) +int BoxStack::handleCommand(int command) { int retVal; int retVal2 = 0; @@ -365,18 +368,18 @@ int ViewMan::handleCommand(int command) if (command != Remote::NA_NONE) { // handle command return values - // 0 - drop through to next view - // 1 - dont drop to next view, but not handled + // 0 - drop through to next box + // 1 - dont drop to next box, but not handled // 2 - handled - stop command here - // 4 - handled - delete this view + // 4 - handled - delete this box - for (i=numViews-1; i>=0; i--) + for (i=numBoxes-1; i>=0; i--) { -// Log::getInstance()->log("ViewMan", Log::DEBUG, "Giving command to i=%i", i); - retVal = views[i]->handleCommand(command); +// Log::getInstance()->log("BoxStack", Log::DEBUG, "Giving command to i=%i", i); + retVal = boxes[i]->handleCommand(command); if (retVal == 1) { - // not handled but don't give to any more views + // not handled but don't give to any more boxes return 0; } @@ -388,8 +391,8 @@ int ViewMan::handleCommand(int command) } else if (retVal == 4) { -// Log::getInstance()->log("ViewMan", Log::DEBUG, "Return 4: i=%i, views[i]=%p", i, views[i]); - removeView(views[i]); +// Log::getInstance()->log("BoxStack", Log::DEBUG, "Return 4: i=%i, boxes[i]=%p", i, boxes[i]); + remove(boxes[i]); retVal2 = 1; break; } @@ -404,16 +407,16 @@ int ViewMan::handleCommand(int command) return retVal2; } -void ViewMan::processMessage(Message* m) +void BoxStack::processMessage(Message* m) { if (m->to != this) { - for (int i = numViews-1; i >= 0; i--) + for (int i = numBoxes-1; i >= 0; i--) { - if (views[i] == m->to) + if (boxes[i] == m->to) { - Log::getInstance()->log("ViewMan", Log::DEBUG, "sending message from view %p to view %p %lu", m->from, m->to, m->message); - views[i]->processMessage(m); + Log::getInstance()->log("BoxStack", Log::DEBUG, "sending message from box %p to box %p %lu", m->from, m->to, m->message); + boxes[i]->processMessage(m); return; } } @@ -421,35 +424,35 @@ void ViewMan::processMessage(Message* m) } /* Handle mouse events*/ - // They come in with m->to = NULL? and just need to be delivered to top view? - if ((numViews > 1) && ((m->message == Message::MOUSE_MOVE) || (m->message == Message::MOUSE_LBDOWN))) + // They come in with m->to = NULL? and just need to be delivered to top box? + if ((numBoxes > 1) && ((m->message == Message::MOUSE_MOVE) || (m->message == Message::MOUSE_LBDOWN))) { - views[numViews-1]->processMessage(m); + boxes[numBoxes-1]->processMessage(m); return; } - Log::getInstance()->log("ViewMan", Log::DEBUG, "it's for meeee!"); + Log::getInstance()->log("BoxStack", Log::DEBUG, "it's for meeee!"); switch(m->message) { case Message::CLOSE_ME: { - removeView((View*)m->from); + remove((Boxx*)m->from); break; } case Message::ADD_VIEW: // currently not used by anything but it might come in useful again { - View* toAdd = (View*)m->parameter; + Boxx* toAdd = (Boxx*)m->parameter; add(toAdd); toAdd->draw(); - updateView(toAdd); + update(toAdd); break; } case Message::REDRAW: { - View* toRedraw = (View*)m->from; + Boxx* toRedraw = (Boxx*)m->from; Region* toRedrawRegion = (Region*)m->parameter; - updateView(toRedraw, toRedrawRegion); + update(toRedraw, toRedrawRegion); break; } } diff --git a/viewman.h b/boxstack.h similarity index 61% rename from viewman.h rename to boxstack.h index 7a71054..e930d87 100644 --- a/viewman.h +++ b/boxstack.h @@ -18,21 +18,18 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef VIEWMAN_H -#define VIEWMAN_H +#ifndef BOXSTACK_H +#define BOXSTACK_H #include #include #include #include -#include "defines.h" -#include "view.h" -#include "message.h" -#include "messagequeue.h" -#include "remote.h" -#include "surface.h" +#include "boxx.h" #include "region.h" +#include "message.h" + //using namespace std; @@ -40,48 +37,32 @@ typedef list RegionList; -class AbstractViewMan -{ - public: - AbstractViewMan() {}; - virtual ~AbstractViewMan() {}; - - virtual int handleCommand(int command)=0; - - virtual int add(View* v)=0; - virtual int removeView(View* toRemove)=0; - virtual void removeAll()=0; - virtual void updateView(View* toUpdate, Region* regionToUpdate = NULL)=0; -}; - - -class ViewMan: public AbstractViewMan +class BoxStack { public: - ViewMan(); - virtual ~ViewMan(); - static ViewMan* getInstance(); + BoxStack(); + virtual ~BoxStack(); + static BoxStack* getInstance(); int init(); int shutdown(); - int add(View* v); - int removeView(View* toRemove); + int add(Boxx*); + int remove(Boxx*); void removeAll(); - void updateView(View* toUpdate, Region* regionToUpdate = NULL); + void update(Boxx*, Region* regionToUpdate = NULL); int handleCommand(int command); void processMessage(Message* m); private: - static ViewMan* instance; + static BoxStack* instance; int initted; - View* views[20]; - int numViews; + Boxx* boxes[20]; + int numBoxes; - // New windowing stuff - void deleteView(int z); + void deleteBox(int z); void repaintRevealed(int x, Region r); void boxSplit(Region r, int start, int end, int direction, RegionList& rl); }; diff --git a/boxx.cc b/boxx.cc new file mode 100644 index 0000000..d546633 --- /dev/null +++ b/boxx.cc @@ -0,0 +1,345 @@ +/* + Copyright 2007 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "boxx.h" + +#include "log.h" + +char Boxx::numBoxxes = 0; + +Boxx::Boxx() +{ + // I want a parent box or a surface. + parent = NULL; + surface = NULL; + + area.x = 0; + area.y = 0; + area.w = 0; + area.h = 0; + + paraVSpace = 6; // default gap for drawPara + + backgroundColourSet = false; + visible = true; + + numBoxxes++; + Log::getInstance()->log("Boxx", Log::DEBUG, "Construct, now %u", numBoxxes); +} + +Boxx::~Boxx() +{ + if (surface) delete surface; + numBoxxes--; + Log::getInstance()->log("Boxx", Log::DEBUG, "Destruct, now %u", numBoxxes); +} + +void Boxx::draw() +{ + //Log::getInstance()->log("Boxx", Log::DEBUG, "Draw this %p surface %p", this, surface); + if (backgroundColourSet) fillColour(backgroundColour); + + Boxx* currentBoxx; + vector::iterator j; + for (j = children.begin(); j != children.end(); j++) + { + currentBoxx = *j; + if (currentBoxx->getVisible()) currentBoxx->draw(); + } +} + +int Boxx::handleCommand(int x) +{ + // A similar comment for this? FIXME make a commandreceiver thingy + return 0; +} + +void Boxx::processMessage(Message* m) +{ + // And this? +} + +void Boxx::setSize(UINT w, UINT h) +{ + area.w = w; + area.h = h; +} + +void Boxx::setPosition(UINT x, UINT y) +{ + area.x = x; + area.y = y; +} + +void Boxx::createBuffer() +{ + surface = new Surface_TYPE(); + surface->create(area.w, area.h); +} + +void Boxx::add(Boxx* newChild) +{ + newChild->setParent(this); + children.push_back(newChild); +} + +void Boxx::remove(Boxx* oldChild) +{ + for(vector::iterator i = children.begin(); i != children.end(); i++) + { + if (*i == oldChild) + { + children.erase(i); + return; + } + } + Log::getInstance()->log("Boxx", Log::ERR, "Remove child box called, child %p not found", oldChild); +} + +void Boxx::setParent(Boxx* newParent) +{ + parent = newParent; +} + +void Boxx::setBackgroundColour(Colour& Tcolour) +{ + backgroundColour = Tcolour; + backgroundColourSet = true; +} + +void Boxx::setVisible(bool isVisible) +{ + visible = isVisible; +} + +bool Boxx::getVisible() +{ + return visible; +} + +void Boxx::setGap(UINT gap) +{ + paraVSpace = gap; +} + +void Boxx::blt(Region& r) +{ + /* surface update to screen needs: + source x distance into this surface + source y distance into this surface + width of update + height of update + destination x on screen + destination y on screen + */ + + if (parent) + { + printf("parent blt???\n"); + abort(); + return; + } + + // this shouldn't be here + r.x -= area.x; + r.y -= area.y; + + surface->updateToScreen(r.x, r.y, r.w, r.h, area.x + r.x, area.y + r.y); + +} + +int Boxx::getScreenX() +{ + if (parent) return area.x + parent->getScreenX(); + return area.x; +} + +int Boxx::getScreenY() +{ + if (parent) return area.y + parent->getScreenY(); + return area.y; +} + +int Boxx::getRootBoxOffsetX() // convert this to be getX and silently do the parent/not thing? same for Y below? +{ + if (parent) return area.x + parent->getRootBoxOffsetX(); + return 0; +} + +int Boxx::getRootBoxOffsetY() +{ + if (parent) return area.y + parent->getRootBoxOffsetY(); + return 0; +} + +int Boxx::getX() +{ + return area.x; +} + +int Boxx::getY() +{ + return area.y; +} + +UINT Boxx::getWidth() +{ + return area.w; +} + +UINT Boxx::getHeight() +{ + return area.h; +} + +// Level 1 drawing functions + +void Boxx::fillColour(Colour& colour) +{ + rectangle(0, 0, area.w, area.h, colour); +} + +void Boxx::drawPara(char* text, int x, int y, Colour& colour) +{ + char line[256]; + int lineHeight = surface->getFontHeight() + paraVSpace; + + int lineWidth; + int thisCharWidth; + int textPos; + int linePos; + int ypos; + int printLine; + + textPos = 0; + ypos = y; + + while(1) + { + linePos = 0; + lineWidth = 0; + while(1) + { + printLine = 0; + + if (text[textPos] == '\0') break; + + if (text[textPos] == '\n') + { + textPos++; // ignore the \n + printLine = 1; + break; + } + + thisCharWidth = surface->getCharWidth(text[textPos]); + if ((lineWidth + thisCharWidth) > (int)(area.w - (2 * paraMargin))) + { + // this character would break the right margin + if (text[textPos] == ' ') + { + // this char is a space, ignore and break + textPos++; + break; + } + else + { + // Need to go back to the last space in the line + while ((text[textPos] != ' ') && (linePos >= 0)) + { + textPos--; + linePos--; + } + // Now take the space we just found + textPos++; + break; + } + } + line[linePos++] = text[textPos]; + lineWidth += thisCharWidth; + textPos++; + } + +// line[linePos++] = '\0'; + if (linePos>=0) line[linePos++] = '\0'; //Here is the change + + if (printLine || (linePos > 1)) // if some text was put in line + { + drawText(line, x, ypos, colour); + ypos += lineHeight; + if (ypos > (int)(area.h - lineHeight)) break; + } + else + { + break; + } + } +} + +void Boxx::rectangle(Region& region, Colour& colour) +{ + rectangle(region.x, region.y, region.w, region.h, colour); +} + +// Level 0 drawing functions + +void Boxx::rectangle(UINT x, UINT y, UINT w, UINT h, Colour& colour) +{ + if (parent) parent->rectangle(area.x + x, area.y + y, w, h, colour); + else surface->fillblt(x, y, w, h, colour.rgba()); +} + +void Boxx::drawText(const char* text, int x, int y, Colour& colour) +{ + if (parent) parent->drawText(text, area.x + x, area.y + y, colour); + else surface->drawText(text, x, y, colour.rgba()); +} + +void Boxx::drawTextRJ(const char* text, int x, int y, Colour& colour) +{ + if (parent) parent->drawTextRJ(text, area.x + x, area.y + y, colour); + else surface->drawTextRJ(text, x, y, colour.rgba()); +} + +void Boxx::drawTextCentre(const char* text, int x, int y, Colour& colour) +{ + if (parent) parent->drawTextCentre(text, area.x + x, area.y + y, colour); + else surface->drawTextCentre(text, x, y, colour.rgba()); +} + +void Boxx::drawPixel(UINT x, UINT y, Colour& colour) +{ + if (parent) parent->drawPixel(area.x + x, area.y + y, colour); + else + { + int c = ( (0xFF000000 ) + | (colour.red << 16) + | (colour.green << 8) + | (colour.blue ) ); + + surface->drawPixel(x, y, c); + } +} + +int Boxx::charWidth(char c) +{ + if (parent) return parent->charWidth(c); + else return surface->getCharWidth(c); +} + diff --git a/boxx.h b/boxx.h new file mode 100644 index 0000000..560904c --- /dev/null +++ b/boxx.h @@ -0,0 +1,151 @@ +/* + 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef BOXX_H +#define BOXX_H + +#include +#include + +using namespace std; + +#include "colour.h" +#include "region.h" +#include "message.h" + +#ifdef WIN32 +#include "surfacewin.h" +#else +#include "surfacemvp.h" +#endif + +class Boxx +{ + public: + Boxx(); + virtual ~Boxx(); + + virtual void setSize(UINT w, UINT h); + void setPosition(UINT x, UINT y); // Set position on parent. Even numbers only!!! + void createBuffer(); // Make this a root view that goes in the BoxStack + + void setGap(UINT gap); + + // Not really for box.. see .cc + virtual void draw(); + virtual int handleCommand(int); + virtual void processMessage(Message*); + + void setBackgroundColour(Colour& colour); + void setVisible(bool isVisible); + + // Drawing functions level 1 + void fillColour(Colour& colour); + void drawPara(char* text, int x, int y, Colour& colour); + + // Drawing functions level 0 + void rectangle(UINT x, UINT y, UINT w, UINT h, Colour& colour); + void rectangle(Region& region, Colour& colour); + + void drawText(const char* text, int x, int y, Colour& colour); + void drawTextRJ(const char* text, int x, int y, Colour& colour); + void drawTextCentre(const char* text, int x, int y, Colour& colour); + void drawPixel(UINT x, UINT y, Colour& colour); + + int charWidth(char c); + + // Following 4 used by mouse stuff only, except 1 getWidth/getHeight? in orig. vtabsman + int getScreenX(); + int getScreenY(); + int getRootBoxOffsetX(); + int getRootBoxOffsetY(); + int getX(); + int getY(); + UINT getWidth(); + UINT getHeight(); + bool getVisible(); + + void add(Boxx*); // a boxx has a set of child boxxs + void remove(Boxx*); + + /* + The following function sets the child's parent pointer without adding the child to the children vector. + It's a hack (that should be deprecated?) to allow things like WSymbol to be created, do some drawing on + the surface and then be deleted again, leaving the drawing present. + A better design would be to create many WSymbols - one per symbol and leave them created - then the + automatic draw code (not written yet) will be able to redraw the symbols without all that code needing + to be in the derived boxx's draw method. + */ + void TEMPADD(Boxx* child) { child->setParent(this); } + + friend class BoxStack; + protected: + Boxx* parent; + Region area; + vector children; + + void setParent(Boxx*); + void blt(Region& r); + + static const int paraMargin = 10; + UINT paraVSpace; + + Colour backgroundColour; + bool backgroundColourSet; + bool visible; + + static char numBoxxes; + Surface* surface; +}; + +#endif + + +/* + +New Boxx design + +It's "Boxx" because "Box" was already taken. + +BoxStack replaces Viewman and handles displaying a stack of root boxxs (boxxs with surfaces) on the screen. + +Boxx relaces Box, Widget and parts of View and represents a box with or without a surface. +Let's call a Boxx with a surface a root box, and a boxx without a surface a child box. + +A boxx with a surface (root) is like an old View and is handled by BoxStack. +A boxx without a surface (child) is like and old Widget and needs to be a child box of another boxx (root or not). + +Don't add a boxx with a surface to another boxx. That isn't the design. + +So, when you create a boxx, either that boxx calls createBuffer() on itself, +or some other box add()s the new box to itself. + +Root boxxs can overlap each other - this is managed by boxstack. +Child boxxs within a parent boxx do not overlap each other. +However, a grandchild box can overlap a child box (but must be entirely contained within the child box). + +TBBoxx replaces View but is now only a convenience class for the window dressing stuff. It isn't required anymore since +all the real work that view used to do is done in Boxx now. + +Obseleted classes: Box, View, Viewman, Widget, others? +No code outside boxx should talk about surfaces anymore. Hopefully. + +*/ + diff --git a/channel.cc b/channel.cc index 4de723d..4edef14 100644 --- a/channel.cc +++ b/channel.cc @@ -19,7 +19,9 @@ */ #include "channel.h" + #include "vdr.h" +#include "log.h" Channel::Channel() { diff --git a/channel.h b/channel.h index c872c79..6efb9fd 100644 --- a/channel.h +++ b/channel.h @@ -24,7 +24,6 @@ #include #include -#include "log.h" #include "defines.h" using namespace std; diff --git a/colour.cc b/colour.cc index 711b8e8..3db474e 100644 --- a/colour.cc +++ b/colour.cc @@ -34,7 +34,7 @@ Colour Colour::SELECTHIGHLIGHT(240, 250, 80); Colour Colour::LIGHTTEXT(255, 255, 255); Colour Colour::DARKTEXT(0, 0, 100); Colour Colour::DANGER(200, 0, 0); -Colour Colour::BUTTONBACKGROUND(0, 0, 150); +Colour Colour::BUTTONBACKGROUND(0, 0, 200); Colour Colour::PROGRAMMEB(80, 80, 240); // two colours used as alterating backgrounds for individual programmes in EPG Colour Colour::PROGRAMMEA(40, 40, 120); // TODO fit epg style (colours) in with rest of application Colour Colour::NOPROGRAMME(180, 180, 180); // no programme details colour diff --git a/command.cc b/command.cc index e1e83e0..0d0bf9d 100644 --- a/command.cc +++ b/command.cc @@ -18,11 +18,37 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include + #include "command.h" + #ifdef WIN32 #include "remotewin.h" #endif +#include "led.h" +#include "video.h" +#include "vdr.h" +#include "vvolume.h" +#include "vserverselect.h" +#include "vwelcome.h" +#include "vmute.h" +#include "colour.h" +#include "osd.h" +#include "i18n.h" +#include "timerreceiver.h" +#include "timers.h" +#include "wol.h" +#include "vvideolive.h" +#include "vconnect.h" +#include "message.h" +#include "remote.h" +#include "vinfo.h" +#include "boxx.h" +#include "boxstack.h" +#include "log.h" + + Command* Command::instance = NULL; Command::Command() @@ -51,10 +77,10 @@ int Command::init() initted = 1; logger = Log::getInstance(); - viewman = ViewMan::getInstance(); + boxstack = BoxStack::getInstance(); remote = Remote::getInstance(); - - if (!logger || !viewman || !remote) + + if (!logger || !boxstack || !remote) { initted = 0; return 0; @@ -87,29 +113,35 @@ void Command::doWallpaper() Video* video = Video::getInstance(); // Blue background - View* v = new View(); - v->create(video->getScreenWidth(), video->getScreenHeight()); - v->setBackgroundColour(Colour::VIDEOBLUE); - v->draw(); - viewman->add(v); - viewman->updateView(v); - viewman->removeView(v); + Boxx* bbg = new Boxx(); + bbg->setSize(video->getScreenWidth(), video->getScreenHeight()); + bbg->createBuffer(); + bbg->fillColour(Colour::VIDEOBLUE); + boxstack->add(bbg); + boxstack->update(bbg); + boxstack->remove(bbg); // Wallpaper - wallpaper = new VWallpaper(); + WJpeg* wallpaperj = new WJpeg(); + wallpaperj->setSize(video->getScreenWidth(), video->getScreenHeight()); + wallpaperj->createBuffer(); + if (video->getFormat() == Video::PAL) { logger->log("Command", Log::DEBUG, "PAL wallpaper selected"); - wallpaper->init("/wallpaperPAL.jpg"); + wallpaperj->init("/wallpaperPAL.jpg"); } else { logger->log("Command", Log::DEBUG, "NTSC wallpaper selected"); - wallpaper->init("/wallpaperNTSC.jpg"); + wallpaperj->init("/wallpaperNTSC.jpg"); } - wallpaper->draw(); - viewman->add(wallpaper); - viewman->updateView(wallpaper); + wallpaperj->draw(); + + boxstack->add(wallpaperj); + boxstack->update(wallpaperj); + + wallpaper = wallpaperj; } void Command::run() @@ -136,7 +168,7 @@ void Command::run() //logger->log("Command", Log::DEBUG, "LOCKED"); VConnect* vconnect = new VConnect(); - viewman->add(vconnect); + boxstack->add(vconnect); vconnect->run(); // Start method 2 of getting commands in... @@ -155,13 +187,13 @@ void Command::run() button = remote->getButtonPress(2); // FIXME why is this set to 2 and not 0? so it can quit // something happened, lock and process - //logger->log("Command", Log::DEBUG, "WANT LOCK"); + // logger->log("Command", Log::DEBUG, "WANT LOCK"); #ifndef WIN32 pthread_mutex_lock(&masterLock); #else WaitForSingleObject(masterLock, INFINITE ); #endif - //logger->log("Command", Log::DEBUG, "LOCK"); + // logger->log("Command", Log::DEBUG, "LOCK"); if ((button == Remote::NA_NONE) /*|| (button == Remote::NA_UNKNOWN)*/) continue; @@ -267,13 +299,13 @@ void Command::postMessageFromOuterSpace(Message* m) The whole message system was at first supposed to prevent the problem of calling a function on an object that had just been deleted, by ordering messages such that all calls are done before object deletion. However, - because of the new centralised messaging system and the fact that ViewMan + because of the new centralised messaging system and the fact that BoxStack locates the destination object before calling it, the messaging system now allows the kind of sloppy calls it was supposed to stop. Weird huh. This is mentioned here because the video stream might generate an event just as the user hits stop. The mutex is locked, and by the time the message is examined the vvideorec/live has been deleted. This doesn't matter because - viewman will drop the message if it can't find the matching object to + boxstack will drop the message if it can't find the matching object to deliver it to. Finally, all this is fine and dandy, except that I'm not 100% sure that this sloppy postMessage and hope a queued signal will force it to be processed @@ -350,21 +382,22 @@ void Command::processMessage(Message* m) } case Message::CHANGE_LANGUAGE: { - viewman->removeAll(); - viewman->updateView(wallpaper); + boxstack->removeAll(); + boxstack->update(wallpaper); I18n::initialize(); VWelcome* vw = new VWelcome(); vw->draw(); - viewman->add(vw); - viewman->updateView(vw); + boxstack->add(vw); + boxstack->update(vw); break; } case Message::LAST_VIEW_CLOSE: { +// not currently used // VWelcome* vw = new VWelcome(); // vw->draw(); -// viewman->add(vw); -// viewman->updateView(vw); +// boxstack->add(vw); +// boxstack->update(vw); break; } @@ -372,16 +405,15 @@ void Command::processMessage(Message* m) } else { - logger->log("Command", Log::DEBUG, "Sending message to viewman"); - viewman->processMessage(m); + logger->log("Command", Log::DEBUG, "Sending message to boxstack"); + boxstack->processMessage(m); } } void Command::handleCommand(int button) { if (isStandby && (button != Remote::POWER)) return; - - if (!connLost && viewman->handleCommand(button)) return; // don't send to viewman if connLost + if (!connLost && boxstack->handleCommand(button)) return; // don't send to boxstack if connLost // command was not handled @@ -393,7 +425,7 @@ void Command::handleCommand(int button) case Remote::VOLUMEDOWN: { VVolume* v = new VVolume(); - viewman->add(v); + boxstack->add(v); v->handleCommand(button); // this will draw+show return; } @@ -401,8 +433,8 @@ void Command::handleCommand(int button) { VMute* v = new VMute(); v->draw(); - viewman->add(v); - viewman->updateView(v); + boxstack->add(v); + boxstack->update(v); return; } case Remote::POWER: @@ -439,14 +471,14 @@ void Command::doStandby() VConnect* vconnect = new VConnect(); - viewman->add(vconnect); + boxstack->add(vconnect); vconnect->run(); } else { - viewman->removeAll(); + boxstack->removeAll(); Video::getInstance()->signalOff(); - viewman->updateView(wallpaper); + boxstack->update(wallpaper); VDR::getInstance()->configSave("General", "Last Power State", "Off"); VDR::getInstance()->disconnect(); @@ -463,29 +495,30 @@ void Command::doFromTheTop(bool which) if (which) { connLost = new VInfo(); - connLost->create(360, 200); + connLost->setSize(360, 200); + connLost->createBuffer(); if (Video::getInstance()->getFormat() == Video::PAL) - connLost->setScreenPos(190, 170); + connLost->setPosition(190, 170); else - connLost->setScreenPos(180, 120); + connLost->setPosition(180, 120); connLost->setOneLiner(tr("Connection lost")); connLost->setDropThrough(); connLost->setBorderOn(1); connLost->setTitleBarColour(Colour::DANGER); connLost->okButton(); connLost->draw(); - viewman->add(connLost); - viewman->updateView(connLost); + boxstack->add(connLost); + boxstack->update(connLost); remote->clearBuffer(); } else { VDR::getInstance()->disconnect(); - viewman->removeAll(); - viewman->updateView(wallpaper); + boxstack->removeAll(); + boxstack->update(wallpaper); connLost = NULL; VConnect* vconnect = new VConnect(); - viewman->add(vconnect); + boxstack->add(vconnect); vconnect->run(); } } @@ -512,19 +545,19 @@ void Command::doJustConnected(VConnect* vconnect) { I18n::initialize(); Video* video = Video::getInstance(); - viewman->removeView(vconnect); + boxstack->remove(vconnect); VInfo* vi = new VInfo(); - vi->create(400, 200); + vi->setSize(400, 200); + vi->createBuffer(); if (video->getFormat() == Video::PAL) - vi->setScreenPos(170, 200); + vi->setPosition(170, 200); else - vi->setScreenPos(160, 150); - + vi->setPosition(160, 150); vi->setOneLiner(tr("Connected, loading config")); vi->draw(); - viewman->add(vi); - viewman->updateView(vi); + boxstack->add(vi); + boxstack->update(vi); VDR* vdr = VDR::getInstance(); char* config; @@ -541,8 +574,8 @@ void Command::doJustConnected(VConnect* vconnect) // Oh sheesh, need to switch format. Bye bye TV... // Take everything down - viewman->removeAll(); - viewman->removeView(wallpaper); + boxstack->removeAll(); + boxstack->remove(wallpaper); Osd* osd = Osd::getInstance(); osd->shutdown(); video->shutdown(); @@ -565,16 +598,17 @@ void Command::doJustConnected(VConnect* vconnect) // Re add the vinfo vi = new VInfo(); - vi->create(400, 200); + vi->setSize(400, 200); + vi->createBuffer(); if (video->getFormat() == Video::PAL) - vi->setScreenPos(170, 200); + vi->setPosition(170, 200); else - vi->setScreenPos(160, 150); + vi->setPosition(160, 150); vi->setOneLiner(tr("Connected, loading config")); vi->draw(); - viewman->add(vi); - viewman->updateView(vi); + boxstack->add(vi); + boxstack->update(vi); } else { @@ -804,15 +838,15 @@ void Command::doJustConnected(VConnect* vconnect) } else { - viewman->removeView(vi); + boxstack->remove(vi); VWelcome* vw = new VWelcome(); vw->draw(); - viewman->add(vw); - viewman->updateView(vw); + boxstack->add(vw); + boxstack->update(vw); // Enter pre-keys here -// handleCommand(Remote::THREE); +// handleCommand(Remote::SIX); // handleCommand(Remote::UP); // handleCommand(Remote::PLAY); // handleCommand(Remote::DOWN); @@ -820,6 +854,6 @@ void Command::doJustConnected(VConnect* vconnect) // handleCommand(Remote::DOWN); // handleCommand(Remote::OK); // handleCommand(Remote::OK); -// handleCommand(Remote::OK); +// handleCommand(Remote::RED); } } diff --git a/command.h b/command.h index a5a6d03..e07dda2 100644 --- a/command.h +++ b/command.h @@ -36,31 +36,16 @@ #include #include "defines.h" -#include "log.h" -#include "viewman.h" -#include "led.h" -#include "video.h" -#include "remote.h" -#include "vdr.h" -#include "message.h" #include "messagequeue.h" -#include "box.h" -#include "view.h" -#include "vinfo.h" -#include "vwallpaper.h" -#include "vvolume.h" -#include "vconnect.h" -#include "vserverselect.h" -#include "vwelcome.h" -#include "vmute.h" -#include "colour.h" -#include "osd.h" -#include "i18n.h" -#include "timerreceiver.h" -#include "timers.h" #include "udp.h" class VConnect; +class Message; +class Remote; +class Boxx; +class BoxStack; +class Log; +class VInfo; class Command : public MessageQueue { @@ -102,11 +87,11 @@ class Command : public MessageQueue UCHAR firstBoot; Log* logger; - ViewMan* viewman; + BoxStack* boxstack; Remote* remote; - VWallpaper* wallpaper; + Boxx* wallpaper; VInfo* connLost; - + UDP udp; void processMessage(Message* m); diff --git a/defines.h b/defines.h index 6f1c78a..d2eb4f4 100644 --- a/defines.h +++ b/defines.h @@ -66,4 +66,19 @@ void MILLISLEEP(ULONG a); #endif +/* +typedef struct +{ + UINT id; // Used for working out what has changed at the end + char *title; // Name of the option + char *configSection; // Which section of the config file + char *configParam; // Parameter name in the config file + UINT optionType; // 1 for text, 2 for int + UINT optionCount; // How many choices? + UINT defaultOption; // Serial of the default choice (base 0), or actual option in int mode + int startInt; // Starting int for int mode + const char * const * options; // Text for the options (null for int mode) +} OPTIONDATA; +*/ + #endif diff --git a/demuxeraudio.cc b/demuxeraudio.cc index e2f5244..f539474 100644 --- a/demuxeraudio.cc +++ b/demuxeraudio.cc @@ -1184,13 +1184,13 @@ int id3_tag::stringlen(bool withTitle) const { //create a string out of the id3 tag info //delete this string afterwards if you did not provide the buffer char * id3_tag::toString(char *b, int len, bool withTitle) const { - char *ta=tr("Artist"); + const char *ta=tr("Artist"); //char *tg=tr("Genre"); //char *ty=tr("Year"); - char *tx=tr("Album"); + const char *tx=tr("Album"); //char *to=tr("Composer"); //char *tc=tr("Comment"); - char *tn=tr("Track"); + const char *tn=tr("Track"); /* in the moment: Title: Artist: @@ -1204,7 +1204,7 @@ char * id3_tag::toString(char *b, int len, bool withTitle) const { const char * del=" - "; if (strlen(year) == 0) del=""; if (withTitle){ - char *tt=tr("Title"); + const char *tt=tr("Title"); snprintf(b,len-1,"%s: %s\n%s: %s\n%s: %s%s%s\n%s: %s", tt,title,ta,artist,tx,year,del,album,tn,track); } diff --git a/event.cc b/event.cc index b08a784..c4d9b6a 100644 --- a/event.cc +++ b/event.cc @@ -38,21 +38,21 @@ Event::~Event() if (description) delete[] description; } -void Event::settitle(char* s) +void Event::settitle(const char* s) { delete title; title = new char[strlen(s) + 1]; strcpy(title, s); } -void Event::setdescription(char* s) +void Event::setdescription(const char* s) { delete description; description = new char[strlen(s) + 1]; strcpy(description, s); } -void Event::setsubtitle(char* s) +void Event::setsubtitle(const char* s) { delete subtitle; subtitle = new char[strlen(s) + 1]; diff --git a/event.h b/event.h index 05b6d47..71fc45d 100644 --- a/event.h +++ b/event.h @@ -32,9 +32,9 @@ class Event Event(); ~Event(); - void settitle(char* title); - void setsubtitle(char* subtitle); - void setdescription(char* description); + void settitle(const char* title); + void setsubtitle(const char* subtitle); + void setdescription(const char* description); ULONG id; ULONG time; diff --git a/i18n.cc b/i18n.cc index 4097bf7..f36d052 100644 --- a/i18n.cc +++ b/i18n.cc @@ -25,6 +25,9 @@ #include "i18n.h" #include "language-data.h" +#include "log.h" +#include "vdr.h" + int I18n::LanguageID = DEFAULT_LANGUAGE_INDEX; int I18n::initialize(void) @@ -47,7 +50,7 @@ int I18n::initialize(void) return LanguageID; } -char* I18n::translate(char* s) +const char* I18n::translate(const char* s) { if (LanguageID >= 0) { diff --git a/i18n.h b/i18n.h index 86a930e..77ff57a 100644 --- a/i18n.h +++ b/i18n.h @@ -33,8 +33,7 @@ #endif #include "defines.h" -#include "log.h" -#include "vdr.h" + #define I18N_HEADER #include "language-data.h" @@ -46,7 +45,7 @@ class I18n { public: static int initialize(void); - static char* translate(char* s); + static const char* translate(const char* s); static const char* LanguageName(int index); static int LanguageIndex(const char* name); diff --git a/main.cc b/main.cc index f51b75d..bf1910b 100644 --- a/main.cc +++ b/main.cc @@ -31,7 +31,7 @@ #include "log.h" #include "timers.h" #include "vdr.h" -#include "viewman.h" +#include "boxstack.h" #include "command.h" #include "mtdmvp.h" @@ -40,6 +40,7 @@ #include "osdmvp.h" #include "audiomvp.h" #include "videomvp.h" +#include "wol.h" #ifndef WIN32 void sighandler(int signalReceived); @@ -60,7 +61,7 @@ Mtd* mtd; Led* led; Osd* osd; Timers* timers; -ViewMan* viewman; +BoxStack* boxstack; Command* command; VDR* vdr; Video* video; @@ -87,11 +88,11 @@ int main(int argc, char** argv) osd = new OsdMVP(); audio = new AudioMVP(); video = new VideoMVP(); - viewman = new ViewMan(); + boxstack = new BoxStack(); command = new Command(); wol = new Wol(); - if (!logger || !remote || !mtd || !led || !osd || !video || !audio || !viewman || !command || !wol) + if (!logger || !remote || !mtd || !led || !osd || !video || !audio || !boxstack || !command || !wol) { printf("Could not create objects. Memory problems?\n"); shutdown(1); @@ -270,14 +271,14 @@ int main(int argc, char** argv) shutdown(1); } - success = viewman->init(); + success = boxstack->init(); if (success) { - logger->log("Core", Log::INFO, "ViewMan module initialised"); + logger->log("Core", Log::INFO, "BoxStack module initialised"); } else { - logger->log("Core", Log::EMERG, "ViewMan module failed to initialise"); + logger->log("Core", Log::EMERG, "BoxStack module failed to initialise"); shutdown(1); } @@ -359,13 +360,14 @@ void sighandler(int signalReceived) void shutdown(int code) { - if (viewman) + if (boxstack) { - viewman->shutdown(); - delete viewman; - logger->log("Core", Log::NOTICE, "ViewMan module shut down"); + boxstack->shutdown(); + delete boxstack; + logger->log("Core", Log::NOTICE, "BoxStack module shut down"); } + // FIXME, send a del all to boxstack first, then get rid of it after command? if (command) // shut down command here in case views have posted messages { command->shutdown(); diff --git a/message.h b/message.h index 9f1a4b0..d08fa8c 100644 --- a/message.h +++ b/message.h @@ -72,6 +72,7 @@ class Message const static ULONG CHANGE_LANGUAGE = 27; const static ULONG LAST_VIEW_CLOSE = 28; const static ULONG CHANGED_REMOTECONTROL = 29; + const static ULONG DELETE_SELECTED_TIMER = 30; }; #endif diff --git a/messagequeue.cc b/messagequeue.cc index e5b0ab8..a9b5a66 100644 --- a/messagequeue.cc +++ b/messagequeue.cc @@ -20,6 +20,9 @@ #include "messagequeue.h" +#include "message.h" +#include "log.h" + void MessageQueue::postMessage(Message* m) { messages.push(m); diff --git a/messagequeue.h b/messagequeue.h index 9949424..b167c67 100644 --- a/messagequeue.h +++ b/messagequeue.h @@ -24,8 +24,7 @@ #include using namespace std; -#include "message.h" -#include "log.h" +class Message; typedef queue MQueue; diff --git a/mtdmvp.cc b/mtdmvp.cc index 24654ed..87b74c1 100644 --- a/mtdmvp.cc +++ b/mtdmvp.cc @@ -20,6 +20,8 @@ #include "mtdmvp.h" +#include "log.h" + MtdMVP::MtdMVP() { if (instance) return; diff --git a/mtdmvp.h b/mtdmvp.h index 21d6404..fe85804 100644 --- a/mtdmvp.h +++ b/mtdmvp.h @@ -43,7 +43,6 @@ So, am assuming: #include #include -#include "log.h" #include "mtd.h" class MtdMVP : public Mtd diff --git a/objects.mk b/objects.mk index d9eb4c2..8f89d10 100644 --- a/objects.mk +++ b/objects.mk @@ -1,19 +1,17 @@ OBJECTS1 = command.o log.o tcp.o dsock.o thread.o timers.o i18n.o mutex.o \ message.o messagequeue.o udp.o wol.o \ vdr.o recman.o recording.o recinfo.o channel.o rectimer.o event.o \ - directory.o mark.o \ + directory.o mark.o option.o \ player.o playerradio.o vfeed.o afeed.o \ demuxer.o demuxervdr.o demuxerts.o stream.o draintarget.o \ - viewman.o box.o region.o colour.o view.o \ - vinfo.o vquestion.o vwallpaper.o vrecordinglist.o vlivebanner.o \ - vmute.o vvolume.o voptions.o \ - vtimerlist.o vtimeredit.o voptionsmenu.o vrecordingmenu.o \ + region.o colour.o boxstack.o boxx.o tbboxx.o \ + vinfo.o vquestion.o vrecordinglist.o vlivebanner.o \ + vmute.o vvolume.o vtimerlist.o vtimeredit.o vrecordingmenu.o \ vchannellist.o vwelcome.o vvideolive.o vvideorec.o vepgsettimer.o \ vchannelselect.o vserverselect.o vconnect.o vepg.o vrecmove.o \ - vradiorec.o vaudioselector.o vscreensaver.o \ - vtabsviewman.o vremoteconfig.o \ - widget.o wselectlist.o wjpeg.o wsymbol.o wbutton.o \ - woptionbox.o wtextbox.o wwss.o \ + vradiorec.o vaudioselector.o vscreensaver.o vopts.o \ + wselectlist.o wjpeg.o wsymbol.o wbutton.o wtextbox.o wwss.o \ + woptionpane.o woptionbox.o wremoteconfig.o wtabbar.o \ fonts/helvB24.o fonts/helvB18.o \ remote.o led.o mtd.o video.o audio.o osd.o surface.o \ vmedialist.o media.o vpicture.o vpicturebanner.o \ diff --git a/option.cc b/option.cc new file mode 100644 index 0000000..310d3ba --- /dev/null +++ b/option.cc @@ -0,0 +1,53 @@ +/* + Copyright 2007 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "option.h" +#include "vdr.h" + +Option::Option(UINT ID, const char* DISPLAYTEXT, const char* CONFIGSECTION, const char* CONFIGKEY, UINT OPTIONTYPE, + UINT NUMCHOICES, UINT DEFAULTCHOICE, UINT STARTINT, const char * const * OPTIONS) +: id(ID), displayText(DISPLAYTEXT), configSection(CONFIGSECTION), configKey(CONFIGKEY), optionType(OPTIONTYPE), + numChoices(NUMCHOICES), defaultChoice(DEFAULTCHOICE), startInt(STARTINT), options(OPTIONS) +{ + configChoice = defaultChoice; + userSetChoice = defaultChoice; + + // Now see if there is a config saved at vdr for this option + char* config = VDR::getInstance()->configLoad(configSection, configKey); + if (config) + { + if (optionType == TYPE_TEXT) + { + for (UINT i = 0; i < numChoices; i++) + { + if (!STRCASECMP(config, options[i])) + { + configChoice = i; + } + } + } + else + { + configChoice = atoi(config); + } + delete[] config; + } +} + diff --git a/option.h b/option.h new file mode 100644 index 0000000..00056a9 --- /dev/null +++ b/option.h @@ -0,0 +1,50 @@ +/* + Copyright 2007 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef OPTION_H +#define OPTION_H + +#include "defines.h" + +class Option +{ + public: + Option(UINT id, const char* displayText, const char* configSection, const char* configKey, UINT optionType, + UINT numChoices, UINT defaultChoice, UINT startInt, const char * const * options); + + UINT id; + const char* displayText; + const char* configSection; + const char* configKey; + UCHAR optionType; + UINT numChoices; + UINT defaultChoice; + int startInt; + const char * const * options; + + UINT configChoice; + UINT userSetChoice; + + const static UCHAR TYPE_TEXT = 1; + const static UCHAR TYPE_INT = 2; +}; + +#endif + diff --git a/osd.cc b/osd.cc index 96db8e3..b2453f8 100644 --- a/osd.cc +++ b/osd.cc @@ -20,6 +20,8 @@ #include "osd.h" +#include "surface.h" + Osd* Osd::instance = NULL; Osd::Osd() diff --git a/osd.h b/osd.h index c22dfe0..eec4224 100644 --- a/osd.h +++ b/osd.h @@ -23,7 +23,7 @@ #include -#include "surface.h" +class Surface; class Osd { diff --git a/osdwin.cc b/osdwin.cc index 23e0b91..e0858c7 100644 --- a/osdwin.cc +++ b/osdwin.cc @@ -309,9 +309,10 @@ bool OsdWin::DoLost(){ } d3ddevice->GetRenderTarget(0,&d3drtsurf); InitVertexBuffer(); - //Redraw Views, Chris could you add a member function to viewman, so that + //Redraw Views, Chris could you add a member function to BoxStack, so that // I can cause it to completely redraw the Views? // Otherwise the OSD would be distorted after Device Lost + // FIXME SetEvent(event); diff --git a/player.cc b/player.cc index 8f2c076..9d77ab6 100644 --- a/player.cc +++ b/player.cc @@ -20,6 +20,16 @@ #include "player.h" +#include "log.h" +#include "audio.h" +#include "video.h" +#include "demuxervdr.h" +#include "demuxerts.h" +#include "vdr.h" +#include "messagequeue.h" +#include "remote.h" +#include "message.h" + #define USER_RESPONSE_TIME 500 // Milliseconds // ----------------------------------- Called from outside, one offs or info funcs @@ -162,7 +172,10 @@ int Player::getCurrentAudioChannel() void Player::setAudioChannel(int newChannel) { - demuxer->setAudioChannel(newChannel); + if (isRecording) + demuxer->setAudioChannel(newChannel); + else + ((DemuxerTS*)demuxer)->setAID(newChannel); } // ----------------------------------- Externally called events diff --git a/player.h b/player.h index 4306cbc..b7033b5 100644 --- a/player.h +++ b/player.h @@ -28,24 +28,24 @@ #endif #include -#include "audio.h" -#include "video.h" -#include "demuxervdr.h" -#include "demuxerts.h" -#include "vfeed.h" -#include "afeed.h" -#include "remote.h" -#include "vdr.h" -#include "callback.h" -#include "message.h" -#include "messagequeue.h" - #ifdef WIN32 #include "threadwin.h" #else #include "threadp.h" #endif +#include "callback.h" +#include "defines.h" +#include "vfeed.h" +#include "afeed.h" + +class MessageQueue; +class Audio; +class Video; +class VDR; +class Log; +class Demuxer; + class Player : public Thread_TYPE, public Callback { public: diff --git a/playerradio.cc b/playerradio.cc index ee1a788..55a6377 100644 --- a/playerradio.cc +++ b/playerradio.cc @@ -20,6 +20,16 @@ #include "playerradio.h" +#include "log.h" +#include "audio.h" +#include "video.h" +#include "demuxervdr.h" +#include "demuxerts.h" +#include "remote.h" +#include "vdr.h" +#include "message.h" +#include "messagequeue.h" + // ----------------------------------- Called from outside, one offs or info funcs PlayerRadio::PlayerRadio(MessageQueue* tmessageQueue, void* tmessageReceiver, bool tIsRecording) diff --git a/playerradio.h b/playerradio.h index 863ea91..ea51dd0 100644 --- a/playerradio.h +++ b/playerradio.h @@ -28,22 +28,21 @@ #endif #include -#include "audio.h" -#include "video.h" -#include "demuxervdr.h" -#include "demuxerts.h" -#include "afeed.h" -#include "remote.h" -#include "vdr.h" -#include "callback.h" -#include "message.h" -#include "messagequeue.h" - #ifdef WIN32 #include "threadwin.h" #else #include "threadp.h" #endif +#include "callback.h" +#include "defines.h" +#include "afeed.h" + +class Log; +class Audio; +class Video; +class Demuxer; +class VDR; +class MessageQueue; class PlayerRadio : public Thread_TYPE, public Callback { diff --git a/recinfo.cc b/recinfo.cc index faa370a..22e4753 100644 --- a/recinfo.cc +++ b/recinfo.cc @@ -19,6 +19,7 @@ */ #include "recinfo.h" +#include "log.h" RecInfo::RecInfo() { diff --git a/recinfo.h b/recinfo.h index 031fcc5..1c535da 100644 --- a/recinfo.h +++ b/recinfo.h @@ -24,7 +24,6 @@ #include #include "defines.h" -#include "log.h" class RecInfo { diff --git a/recman.cc b/recman.cc index e46da95..524d916 100644 --- a/recman.cc +++ b/recman.cc @@ -19,6 +19,7 @@ */ #include "recman.h" + #include "vdr.h" RecMan::RecMan() diff --git a/recording.cc b/recording.cc index 5f7b381..b9c123f 100644 --- a/recording.cc +++ b/recording.cc @@ -20,6 +20,11 @@ #include "recording.h" +#include "recinfo.h" +#include "mark.h" +#include "log.h" +#include "demuxer.h" + Recording* Recording::recInfoFor = NULL; RecInfo* Recording::recInfo = NULL; diff --git a/recording.h b/recording.h index 14b6c0f..2b3490c 100644 --- a/recording.h +++ b/recording.h @@ -25,10 +25,8 @@ #include #include "defines.h" #include "vdr.h" -#include "recinfo.h" -#include "mark.h" -#include "log.h" -#include "demuxer.h" + +class Log; class Recording { diff --git a/rectimer.h b/rectimer.h index cb5cfcd..d351a8a 100644 --- a/rectimer.h +++ b/rectimer.h @@ -45,6 +45,8 @@ class RecTimer ULONG channelNumber; ULONG startTime; ULONG stopTime; + ULONG day; + ULONG weekDays; // int index; diff --git a/remote.cc b/remote.cc index 8da388b..7e6ea75 100644 --- a/remote.cc +++ b/remote.cc @@ -19,7 +19,9 @@ */ #include "remote.h" + #include "i18n.h" +#include "log.h" Remote* Remote::instance = NULL; diff --git a/remote.h b/remote.h index 7d0be6e..729713d 100644 --- a/remote.h +++ b/remote.h @@ -25,7 +25,6 @@ #include #include "defines.h" -#include "log.h" using namespace std; typedef map RemoteTranslationList; diff --git a/remotemvp.cc b/remotemvp.cc index bb07859..ff20983 100644 --- a/remotemvp.cc +++ b/remotemvp.cc @@ -20,6 +20,8 @@ #include "remotemvp.h" +#include "log.h" + RemoteMVP::RemoteMVP() { if (instance) return; diff --git a/remotemvp.h b/remotemvp.h index 25c3844..09425a8 100644 --- a/remotemvp.h +++ b/remotemvp.h @@ -25,9 +25,8 @@ #include #include -#include "defines.h" -#include "log.h" #include "remote.h" +#include "defines.h" class RemoteMVP : public Remote { diff --git a/stream.h b/stream.h index 59c5575..1f13c1f 100644 --- a/stream.h +++ b/stream.h @@ -34,6 +34,7 @@ #endif #include #include "defines.h" + #include "draintarget.h" class Stream diff --git a/surface.cc b/surface.cc index 8a4c42b..fc69577 100644 --- a/surface.cc +++ b/surface.cc @@ -19,7 +19,9 @@ */ #include "surface.h" + #include "osd.h" +#include "log.h" Surface* Surface::screen = NULL; osd_font_t* Surface::font = &font_helvB18; @@ -38,7 +40,7 @@ Surface* Surface::getScreen() return screen; } -int Surface::drawText(char* text, int x, int y, ULONG rgba) +int Surface::drawText(const char* text, int x, int y, ULONG rgba) { int h, n, i; int Y, X, cx; @@ -71,7 +73,7 @@ int Surface::drawText(char* text, int x, int y, ULONG rgba) return 1; } -int Surface::drawTextRJ(char* text, int x, int y, ULONG rgba) +int Surface::drawTextRJ(const char* text, int x, int y, ULONG rgba) { int i, n, w; w = 0; @@ -89,7 +91,7 @@ int Surface::drawTextRJ(char* text, int x, int y, ULONG rgba) else return drawText(text, x, y, rgba); } -int Surface::drawTextCentre(char* text, int x, int y, ULONG rgba) +int Surface::drawTextCentre(const char* text, int x, int y, ULONG rgba) { int i, n, w; w = 0; diff --git a/surface.h b/surface.h index 557f630..56611ce 100644 --- a/surface.h +++ b/surface.h @@ -23,7 +23,6 @@ #include #include "defines.h" -#include "log.h" // Font stuff @@ -50,9 +49,9 @@ class Surface static int getFontHeight(); int getCharWidth(char c); - int drawText(char* text, int x, int y, ULONG rgba); - int drawTextRJ(char* text, int x, int y, ULONG rgba); - int drawTextCentre(char* text, int x, int y, ULONG rgba); + int drawText(const char* text, int x, int y, ULONG rgba); + int drawTextRJ(const char* text, int x, int y, ULONG rgba); + int drawTextCentre(const char* text, int x, int y, ULONG rgba); virtual int create(UINT width, UINT height)=0; virtual void display()=0; diff --git a/surfacemvp.cc b/surfacemvp.cc index 4fe3bcc..b088178 100644 --- a/surfacemvp.cc +++ b/surfacemvp.cc @@ -20,7 +20,9 @@ */ #include "surfacemvp.h" + #include "osd.h" +#include "log.h" SurfaceMVP::SurfaceMVP(int id) : Surface(id) diff --git a/surfacemvp.h b/surfacemvp.h index 79c4083..5746514 100644 --- a/surfacemvp.h +++ b/surfacemvp.h @@ -34,7 +34,6 @@ extern "C" } #include "defines.h" -#include "log.h" #include "surface.h" // Structures for surface management diff --git a/surfacewin.cc b/surfacewin.cc index b5f3226..dfaea4e 100644 --- a/surfacewin.cc +++ b/surfacewin.cc @@ -21,6 +21,7 @@ #include "surfacewin.h" #include "osdwin.h" #include +#include "log.h" SurfaceWin::SurfaceWin(int id) : Surface(id) diff --git a/surfacewin.h b/surfacewin.h index 6409103..45423d7 100644 --- a/surfacewin.h +++ b/surfacewin.h @@ -22,7 +22,6 @@ #define SURFACEWIN_H #include "defines.h" -#include "log.h" #include "surface.h" #include #include diff --git a/view.cc b/tbboxx.cc similarity index 56% rename from view.cc rename to tbboxx.cc index 0354881..4019b77 100644 --- a/view.cc +++ b/tbboxx.cc @@ -1,5 +1,5 @@ /* - Copyright 2004-2005 Chris Tallon + Copyright 2007 Chris Tallon This file is part of VOMP. @@ -18,60 +18,39 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "view.h" +#include "tbboxx.h" -char View::numViews = 0; +#include "log.h" -View::View() +TBBoxx::TBBoxx() { titleBarOn = 0; borderOn = 0; - titleText = NULL; - - surface = NULL; - - numViews++; - Log::getInstance()->log("View", Log::DEBUG, "Construct %p, now %u", this, numViews); } -View::~View() +TBBoxx::~TBBoxx() { if (titleText) delete[] titleText; - - if (surface != NULL) delete surface; - - numViews--; - Log::getInstance()->log("View", Log::DEBUG, "Destruct, now %u", numViews); } -bool View::create(UINT w, UINT h) -{ - area.w = w; - area.h = h; - - surface = new Surface_TYPE(); - return surface->create(area.w, area.h); -} - -void View::setTitleText(const char* takeText) +void TBBoxx::setTitleText(const char* takeText) { int length = strlen(takeText); titleText = new char[length + 1]; strcpy(titleText, takeText); } -void View::draw() +void TBBoxx::draw() { + Log::getInstance()->log("TBBoxx", Log::DEBUG, "Draw"); + + fillColour(Colour::VIEWBACKGROUND); if (borderOn) { rectangle(0, 0, area.w, area.h, titleBarColour); - rectangle(5, 5, area.w-10, area.h-10, backgroundColour); - } - else - { - fillColour(backgroundColour); + rectangle(5, 5, area.w-10, area.h-10, Colour::VIEWBACKGROUND); } if (titleBarOn) @@ -79,33 +58,21 @@ void View::draw() rectangle(0, 0, area.w, 30, titleBarColour); if (titleText) drawText(titleText, 5, 5, Colour::LIGHTTEXT); } -} - -int View::handleCommand(int command) -{ - return 0; -} -void View::processMessage(Message* m) -{ -} - -void View::setBackgroundColour(Colour& Tcolour) -{ - backgroundColour = Tcolour; + Boxx::draw(); } -void View::setTitleBarColour(Colour& Tcolour) +void TBBoxx::setTitleBarColour(Colour& Tcolour) { titleBarColour = Tcolour; } -void View::setTitleBarOn(UCHAR on) +void TBBoxx::setTitleBarOn(UCHAR on) { titleBarOn = on; } -void View::setBorderOn(UCHAR on) +void TBBoxx::setBorderOn(UCHAR on) { borderOn = on; } diff --git a/view.h b/tbboxx.h similarity index 66% rename from view.h rename to tbboxx.h index 53f0755..b1290c3 100644 --- a/view.h +++ b/tbboxx.h @@ -1,5 +1,5 @@ /* - Copyright 2004-2005 Chris Tallon + Copyright 2007 Chris Tallon This file is part of VOMP. @@ -18,52 +18,39 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef VIEW_H -#define VIEW_H +#ifndef TBBOXX_H +#define TBBOXX_H #include -#include "log.h" -#include "box.h" +#include "boxx.h" #include "defines.h" -#include "message.h" #include "colour.h" -class AbstractViewMan; +// Note! Do not use setBackgroundColour on a TBBoxx or anything derived from it - +// it will screw up the display -class View : public Box +class TBBoxx : public Boxx { public: - View(); - virtual ~View(); - bool create(UINT width, UINT height); // Even numbers only ? - + TBBoxx(); + virtual ~TBBoxx(); virtual void draw(); - virtual int handleCommand(int command); - virtual void processMessage(Message* m); // The master lock will be locked void setBorderOn(UCHAR on); void setTitleBarOn(UCHAR on); void setTitleText(const char* title); - void setBackgroundColour(Colour& colour); - void setTitleBarColour(Colour& colour); + void setTitleBarColour(Colour& colour); char* getTitleText() { return titleText; }; - void setViewMan(AbstractViewMan* tviewman) { viewman=tviewman; }; - private: - static char numViews; - char* titleText; UCHAR borderOn; protected: - Colour backgroundColour; Colour titleBarColour; UCHAR titleBarOn; - - AbstractViewMan* viewman; }; #endif diff --git a/tcp.cc b/tcp.cc index 2600635..70f53ee 100644 --- a/tcp.cc +++ b/tcp.cc @@ -24,6 +24,8 @@ #include #endif +#include "log.h" + TCP::TCP() { sock = 0; diff --git a/tcp.h b/tcp.h index 0ecba21..9b2e6be 100644 --- a/tcp.h +++ b/tcp.h @@ -43,7 +43,6 @@ #endif #include "defines.h" -#include "log.h" class TCP { diff --git a/timers.cc b/timers.cc index 0c1b460..a95e964 100755 --- a/timers.cc +++ b/timers.cc @@ -20,6 +20,10 @@ #include "timers.h" +#include "log.h" +#include "command.h" +#include "timerreceiver.h" + Timers* Timers::instance = NULL; Timers::Timers() diff --git a/timers.h b/timers.h index 3c95e60..55ddc9a 100755 --- a/timers.h +++ b/timers.h @@ -22,21 +22,19 @@ #define TIMERS_H #include +#include + #ifndef WIN32 -#include +#include "threadp.h" +#else +#include "threadwin.h" #endif -#include #include "defines.h" -#include "log.h" -#include "command.h" -#include "timerreceiver.h" -#ifdef WIN32 -#include "threadwin.h" -#else -#include "threadp.h" -#endif + +class Log; +class TimerReceiver; /* diff --git a/udp.cc b/udp.cc index e8e5a75..ec70e09 100755 --- a/udp.cc +++ b/udp.cc @@ -20,6 +20,11 @@ #include "udp.h" +#include "dsock.h" +#include "messagequeue.h" +#include "message.h" +#include "log.h" + //void dump(unsigned char* data, USHORT size); //unsigned char dcc(UCHAR c); diff --git a/udp.h b/udp.h index 9133391..cfdacc6 100755 --- a/udp.h +++ b/udp.h @@ -26,9 +26,6 @@ #include #include "defines.h" -#include "log.h" -#include "dsock.h" -#include "messagequeue.h" #ifdef WIN32 #include "threadwin.h" @@ -36,6 +33,10 @@ #include "threadp.h" #endif +class DatagramSocket; +class MessageQueue; +class Log; + class UDP : public Thread_TYPE { public: diff --git a/vaudioplayer.cc b/vaudioplayer.cc index fbb9829..fb0c1df 100644 --- a/vaudioplayer.cc +++ b/vaudioplayer.cc @@ -18,15 +18,29 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include + #include "vaudioplayer.h" + #include "audioplayer.h" -#include +#include "message.h" +#include "remote.h" +#include "wsymbol.h" +#include "boxstack.h" +#include "vdr.h" +#include "media.h" +#include "i18n.h" +#include "wjpeg.h" +#include "timers.h" +#include "video.h" +#include "command.h" VAudioplayer::VAudioplayer(VMediaList *p) { parent=p; Video* video = Video::getInstance(); - create(video->getScreenWidth(),video->getScreenHeight()); + setSize(video->getScreenWidth(),video->getScreenHeight()); + createBuffer(); banner=NULL; fullname=NULL; filename=NULL; @@ -54,7 +68,7 @@ AudioPlayer * VAudioplayer::getPlayer(bool createIfNeeded) VAudioplayer::~VAudioplayer() { - if (banner) ViewMan::getInstance()->removeView(banner); + if (banner) BoxStack::getInstance()->remove(banner); if (fullname) delete fullname; if (filename) delete filename; Timers::getInstance()->cancelTimer(this,1); @@ -84,7 +98,7 @@ int VAudioplayer::handleCommand(int command) case Remote::DF_UP: case Remote::UP: play(VMediaList::MV_PREV); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); rt= 2; break; case Remote::FORWARD: @@ -94,7 +108,7 @@ int VAudioplayer::handleCommand(int command) case Remote::DF_DOWN: case Remote::DOWN: play(VMediaList::MV_NEXT); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); rt= 2; break; case Remote::SKIPFORWARD: @@ -205,9 +219,9 @@ void VAudioplayer::processMessage(Message* m) //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()) + if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight()) { - ViewMan::getInstance()->handleCommand(Remote::BACK); //simulate cancel press + BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press } } else if (m->message == Message::PLAYER_EVENT) { @@ -223,8 +237,8 @@ void VAudioplayer::processMessage(Message* m) case AudioPlayer::SHORT_UPDATE: if (banner) { drawClocks(); - ViewMan::getInstance()->updateView(banner,&clocksRegion); - ViewMan::getInstance()->updateView(banner,&barRegion); + BoxStack::getInstance()->update(banner,&clocksRegion); + BoxStack::getInstance()->update(banner,&barRegion); Timers::getInstance()->setTimerD(this, 3, 1); } break; @@ -247,11 +261,11 @@ VAudioplayer * VAudioplayer::createPlayer(VMediaList * mparent, bool bplayall) { Log::getInstance()->log("VAudioplayer::createPlayer", Log::DEBUG, "p=%p", mparent); VAudioplayer *vmn=new VAudioplayer(mparent); - ViewMan::getInstance()->add(vmn); - ViewMan::getInstance()->updateView(vmn); + BoxStack::getInstance()->add(vmn); + BoxStack::getInstance()->update(vmn); vmn->play(); if (bplayall) vmn->startPlayall(); - ViewMan::getInstance()->updateView(vmn); + BoxStack::getInstance()->update(vmn); return vmn; } @@ -325,12 +339,12 @@ void VAudioplayer::showBanner(bool forceNewTime) { Timers::getInstance()->setTimerD(this,1,remainingTime); if (playerError) Timers::getInstance()->setTimerD(this,2,BANNER_ERROR_TIME); Timers::getInstance()->setTimerD(this,3, 1); - ViewMan::getInstance()->updateView(banner); + BoxStack::getInstance()->update(banner); } void VAudioplayer::destroyBanner() { if (banner) { - ViewMan::getInstance()->removeView(banner); + BoxStack::getInstance()->remove(banner); banner=NULL; } Timers::getInstance()->cancelTimer(this,1); @@ -385,39 +399,39 @@ void VAudioplayer::timercall(int clientref) { } -void VAudioplayer::sendViewMsg(View *v,bool vdestroy) { +void VAudioplayer::sendViewMsg(Boxx *v,bool vdestroy) { Message* m = new Message(); m->message = vdestroy?Message::CLOSE_ME:Message::ADD_VIEW; - m->to = ViewMan::getInstance(); + m->to = BoxStack::getInstance(); m->from = v; m->parameter=(ULONG)v; Command::getInstance()->postMessageFromOuterSpace(m); } -View * VAudioplayer::createBannerView(int numlines) { - View *rt=new View(); +TBBoxx * VAudioplayer::createBannerView(int numlines) { + TBBoxx *rt=new TBBoxx(); UINT height=numlines*30+60; UINT vheight=Video::getInstance()->getScreenHeight(); UINT vwidth=Video::getInstance()->getScreenWidth(); if (height > vheight-2*BANNER_BOTTOM_MARGIN) height=vheight-2*BANNER_BOTTOM_MARGIN; - rt->create(vwidth -2*BANNER_X_MARGIN, height); + rt->setSize(vwidth -2*BANNER_X_MARGIN, height); + rt->createBuffer(); if (Video::getInstance()->getFormat() == Video::PAL) { - rt->setScreenPos(BANNER_X_MARGIN, vheight-height-BANNER_BOTTOM_MARGIN); + rt->setPosition(BANNER_X_MARGIN, vheight-height-BANNER_BOTTOM_MARGIN); } else { - rt->setScreenPos(BANNER_X_MARGIN, vheight-height-BANNER_BOTTOM_MARGIN); + rt->setPosition(BANNER_X_MARGIN, vheight-height-BANNER_BOTTOM_MARGIN); } - rt->setBackgroundColour(Colour::VIEWBACKGROUND); rt->setTitleBarOn(0); //from vvideorec //set the regions for the closcks and bars on banner - barRegion.x = rt->area.w-BARLEN-20; - barRegion.y = rt->area.h - 30; // FIXME, need to be - 1? and below? - barRegion.w = rt->area.w-BARLEN+10; + barRegion.x = rt->getWidth()-BARLEN-20; + barRegion.y = rt->getHeight() - 30; // FIXME, need to be - 1? and below? + barRegion.w = rt->getWidth()-BARLEN+10; barRegion.h = 30; clocksRegion.x = 130; @@ -425,7 +439,7 @@ View * VAudioplayer::createBannerView(int numlines) { clocksRegion.w = 190; clocksRegion.h = surface->getFontHeight(); Log::getInstance()->log("VAudioPlayer",Log::DEBUG,"created banner %p",rt); - ViewMan::getInstance()->add(rt); + BoxStack::getInstance()->add(rt); return rt; } @@ -436,13 +450,13 @@ void VAudioplayer::drawBanner(){ char *playerTitle=getPlayer()->getTitle(); if (playerTitle) title=playerTitle; else title=filename; - char *pl=tr("Playlist"); + const char *pl=tr("Playlist"); int num=parent->getNumEntries(MEDIA_TYPE_AUDIO,currentMedia->index); bool playerError=getPlayer()->getState() == AudioPlayer::S_ERROR; //1more line for long dirs int numlines=playall?5:4; int len=0; - char *first=NULL; + const char *first=NULL; char *playerInfo=NULL; if (playerError) { numlines=3; @@ -503,14 +517,15 @@ void VAudioplayer::drawBanner(){ //now the real drawing functions banner->draw(); WSymbol w; - w.setSurface(banner->surface); + banner->TEMPADD(&w); +// w.setSurface(banner->surface); //title - banner->rectangle(0, 0, banner->area.w, 30, Colour::TITLEBARBACKGROUND); + banner->rectangle(0, 0, banner->getWidth(), 30, Colour::TITLEBARBACKGROUND); banner->drawText(title, 5, 5, Colour::LIGHTTEXT); banner->drawPara(buf,5,32,Colour::LIGHTTEXT); int x=10; - int ybottom=banner->area.h; - banner->rectangle(0, ybottom - barRegion.h, banner->area.w, barRegion.h, Colour::TITLEBARBACKGROUND); + int ybottom=banner->getHeight(); + banner->rectangle(0, ybottom - barRegion.h, banner->getWidth(), barRegion.h, Colour::TITLEBARBACKGROUND); bool drawSymbol=true; switch(getPlayer()->getState()) { case AudioPlayer::S_PAUSE: @@ -536,7 +551,7 @@ void VAudioplayer::drawBanner(){ break; } if (drawSymbol) { - w.setSurfaceOffset(x, ybottom-24); + w.setPosition(x, ybottom-24); w.draw(); } else { diff --git a/vaudioplayer.h b/vaudioplayer.h index 9514573..33f839d 100644 --- a/vaudioplayer.h +++ b/vaudioplayer.h @@ -25,16 +25,13 @@ #include #include -#include "view.h" -#include "remote.h" -#include "wsymbol.h" -#include "viewman.h" -#include "vdr.h" -#include "media.h" +#include "tbboxx.h" +#include "timerreceiver.h" #include "colour.h" -#include "i18n.h" +#include "region.h" #include "vmedialist.h" -#include "wjpeg.h" + +class Message; /** * the audio player frontend @@ -43,7 +40,7 @@ */ class AudioPlayer; -class VAudioplayer : public View,public TimerReceiver +class VAudioplayer : public TBBoxx, public TimerReceiver { public: ~VAudioplayer(); @@ -83,19 +80,19 @@ class VAudioplayer : public View,public TimerReceiver void updateBanner(bool restart=false); void drawBanner(); void drawClocks(); - View *createBannerView(int numlines); + TBBoxx *createBannerView(int numlines); int bannerlines; //add or destroy a view (banner, info) - void sendViewMsg(View *v,bool destroy=false); + void sendViewMsg(Boxx *v,bool destroy=false); //get the player - create it if necessary AudioPlayer* getPlayer(bool create=true); VMediaList *parent; - View *banner; + TBBoxx *banner; char * fullname; char * filename; ULONG ftime; bool playall; - char * mediaError; + const char * mediaError; Media * currentMedia; bool justPlaying; int numentries; diff --git a/vaudioselector.cc b/vaudioselector.cc index 61782f3..1ecc426 100644 --- a/vaudioselector.cc +++ b/vaudioselector.cc @@ -20,23 +20,32 @@ #include "vaudioselector.h" -VAudioSelector::VAudioSelector(void* tparent,bool* availableMpegAudioChannels, - bool* availableAc3AudioChannels, - int currentAudioChannel, RecInfo* recInfo) +#include "remote.h" +#include "colour.h" +#include "video.h" +#include "boxstack.h" +#include "i18n.h" +#include "message.h" +#include "command.h" +#include "recinfo.h" +#include "log.h" +#include "channel.h" + +VAudioSelector::VAudioSelector(void* tparent, bool* availableMpegAudioChannels, + bool* availableAc3AudioChannels, int currentAudioChannel, RecInfo* recInfo) { Log::getInstance()->log("VAS", Log::DEBUG, "%i", currentAudioChannel); parent = tparent; - create(200, 120); + liveMode = false; -// setTitleText(tr("Audio")); -// setTitleBarOn(1); -// setTitleBarColour(Colour::TITLEBARBACKGROUND); + setSize(200, 120); + createBuffer(); - sl.setSurface(surface); - sl.setSurfaceOffset(40, 30); - sl.setDimensions(area.w - 45, area.h - 30); + sl.setPosition(40, 30); + sl.setSize(area.w - 45, area.h - 30); + add(&sl); // Load data from availableAudioChannels, currentAudioChannel and recInfo @@ -180,12 +189,53 @@ VAudioSelector::VAudioSelector(void* tparent,bool* availableMpegAudioChannels, } } +VAudioSelector::VAudioSelector(void* tparent, Channel* channel, int currentAudioChannel) +{ + parent = tparent; + + liveMode = true; + + setSize(200, 120); + createBuffer(); + + sl.setPosition(40, 30); + sl.setSize(area.w - 45, area.h - 30); + add(&sl); + + // Load data from availableAudioChannels, currentAudioChannel and recInfo + + for (UINT i = 0; i < channel->numAPids; i++) + { + AudioChannel* ac = new AudioChannel(); + ac->type = 0; + ac->name = new char[strlen(channel->apids[i].name) + 1]; + strcpy(ac->name, channel->apids[i].name); + ac->pestype = channel->apids[i].pid; + acl.push_back(ac); + } + + int audioChannelListSize = acl.size(); + + if (audioChannelListSize) + { + for(int i = 0; i < audioChannelListSize; i++) + { + AudioChannel* ac = acl[i]; + sl.addOption(ac->name, (ULONG)ac, (ac->pestype == currentAudioChannel)); + } + } + else + { + sl.addOption(tr("No audio channel data available"), 0, 1); + } +} + VAudioSelector::~VAudioSelector() { int audioChannelListSize = acl.size(); for(int i = 0; i < audioChannelListSize; i++) { - delete acl[i]; + delete acl[i]; // FIXME memory leak - nobody is deleting audio channel name? } acl.clear(); @@ -200,7 +250,10 @@ VAudioSelector::~VAudioSelector() void VAudioSelector::draw() { - View::draw(); + TBBoxx::draw(); + + // FIXME bad drawing + rectangle(0, 0, area.w, 30, Colour::TITLEBARBACKGROUND); drawText(tr("Audio"), 45, 5, Colour::LIGHTTEXT); @@ -224,7 +277,7 @@ int VAudioSelector::handleCommand(int command) sl.up(); sl.draw(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); Message* m = new Message(); m->from = this; @@ -241,7 +294,7 @@ int VAudioSelector::handleCommand(int command) sl.down(); sl.draw(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); Message* m = new Message(); m->from = this; @@ -264,22 +317,22 @@ void VAudioSelector::processMessage(Message* m) if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) { sl.draw(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(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 + 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>getWidth() || y>getHeight()) + if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight()) { - ViewMan::getInstance()->handleCommand(Remote::BACK); //simulate cancel press + BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press } } } diff --git a/vaudioselector.h b/vaudioselector.h index 1eff1b8..34a3ca5 100644 --- a/vaudioselector.h +++ b/vaudioselector.h @@ -26,15 +26,11 @@ #include #include -#include "view.h" -#include "remote.h" +#include "tbboxx.h" #include "wselectlist.h" -#include "colour.h" -#include "video.h" -#include "viewman.h" -#include "i18n.h" -#include "message.h" -#include "command.h" + +class RecInfo; +class Channel; #define PES_AUDIO_START 0xc0 #define PES_AUDIO_MAXCHANNELS 0x20 @@ -51,11 +47,16 @@ class AudioChannel typedef vector AudioChannelList; -class VAudioSelector : public View +class VAudioSelector : public TBBoxx { public: - VAudioSelector(void* parent, bool* availableMpegAudioChannels, - bool* availableAc3AudioChannels, int currentAudioChannel, RecInfo* recInfo); + VAudioSelector(void* parent, bool* availableMpegAudioChannels, // Recording mode + bool* availableAc3AudioChannels, int currentAudioChannel, RecInfo* recInfo); + + VAudioSelector(void* tparent, Channel* channel, int currentAudioChannel); // Live mode + + VAudioSelector(void* parent, Channel* channel); + ~VAudioSelector(); int handleCommand(int command); @@ -65,6 +66,8 @@ class VAudioSelector : public View private: void* parent; WSelectList sl; + + bool liveMode; AudioChannelList acl; }; diff --git a/vchannellist.cc b/vchannellist.cc index c6e4769..ae2dd10 100644 --- a/vchannellist.cc +++ b/vchannellist.cc @@ -20,21 +20,31 @@ #include "vchannellist.h" +#include "remote.h" +#include "wsymbol.h" +#include "vvideolive.h" +#include "colour.h" +#include "video.h" +#include "i18n.h" +#include "channel.h" +#include "message.h" +#include "boxstack.h" +#include "vchannelselect.h" + VChannelList::VChannelList(ULONG type) { - viewman = ViewMan::getInstance(); - create(570, 420); + boxstack = BoxStack::getInstance(); + setSize(570, 420); + createBuffer(); if (Video::getInstance()->getFormat() == Video::PAL) { - setScreenPos(80, 70); + setPosition(80, 70); } else { - setScreenPos(70, 35); + setPosition(70, 35); } - - setBackgroundColour(Colour::VIEWBACKGROUND); setTitleBarOn(1); if (type == VDR::VIDEO) @@ -47,9 +57,9 @@ VChannelList::VChannelList(ULONG type) } setTitleBarColour(Colour::TITLEBARBACKGROUND); - sl.setSurface(surface); - sl.setSurfaceOffset(10, 30 + 5); - sl.setDimensions(area.w - 20, area.h - 30 - 15 - 30); + sl.setPosition(10, 30 + 5); + sl.setSize(area.w - 20, area.h - 30 - 15 - 30); + add(&sl); } VChannelList::~VChannelList() @@ -94,37 +104,37 @@ void VChannelList::highlightChannel(Channel* chan) sl.hintSetCurrent(chan->index); sl.draw(); doShowingBar(); - viewman->updateView(this); + boxstack->update(this); } void VChannelList::draw() { - View::draw(); + TBBoxx::draw(); sl.draw(); // Put the status stuff at the bottom WSymbol w; - w.setSurface(surface); + TEMPADD(&w); w.nextSymbol = WSymbol::UP; - w.setSurfaceOffset(20, 385); + w.setPosition(20, 385); w.draw(); w.nextSymbol = WSymbol::DOWN; - w.setSurfaceOffset(50, 385); + w.setPosition(50, 385); w.draw(); w.nextSymbol = WSymbol::SKIPBACK; - w.setSurfaceOffset(85, 385); + w.setPosition(85, 385); w.draw(); w.nextSymbol = WSymbol::SKIPFORWARD; - w.setSurfaceOffset(115, 385); + w.setPosition(115, 385); w.draw(); w.nextSymbol = WSymbol::PLAY; - w.setSurfaceOffset(150, 385); + w.setPosition(150, 385); w.draw(); doShowingBar(); @@ -138,12 +148,6 @@ void VChannelList::doShowingBar() char showing[200]; sprintf(showing, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions()); -// Box b; -// b.setSurfaceOffset(220, 385); -// b.setDimensions(160, 25); -// b.fillColour(Colour::VIEWBACKGROUND); -// b.drawText(showing, 0, 0, Colour::LIGHTTEXT); - rectangle(220, 385, 220+160, 385+25, Colour::VIEWBACKGROUND); drawText(showing, 220, 385, Colour::LIGHTTEXT); } @@ -159,7 +163,7 @@ int VChannelList::handleCommand(int command) sl.draw(); doShowingBar(); - viewman->updateView(this); + boxstack->update(this); return 2; } case Remote::DF_DOWN: @@ -169,7 +173,7 @@ int VChannelList::handleCommand(int command) sl.draw(); doShowingBar(); - viewman->updateView(this); + boxstack->update(this); return 2; } case Remote::SKIPBACK: @@ -178,7 +182,7 @@ int VChannelList::handleCommand(int command) sl.draw(); doShowingBar(); - viewman->updateView(this); + boxstack->update(this); return 2; } case Remote::SKIPFORWARD: @@ -187,7 +191,7 @@ int VChannelList::handleCommand(int command) sl.draw(); doShowingBar(); - viewman->updateView(this); + boxstack->update(this); return 2; } case Remote::ZERO: @@ -203,8 +207,8 @@ int VChannelList::handleCommand(int command) { VChannelSelect* v = new VChannelSelect(this); v->draw(); - viewman->add(v); - viewman->updateView(v); + boxstack->add(v); + boxstack->update(v); v->handleCommand(command); return 2; } @@ -218,8 +222,8 @@ int VChannelList::handleCommand(int command) VVideoLive* v = new VVideoLive(chanList, chan->type, this); v->draw(); - viewman->add(v); - viewman->updateView(v); + boxstack->add(v); + boxstack->update(v); v->channelChange(VVideoLive::NUMBER, chan->number); @@ -242,22 +246,22 @@ void VChannelList::processMessage(Message* m) { sl.draw(); doShowingBar(); - viewman->updateView(this); + boxstack->update(this); } } else if (m->message == Message::MOUSE_LBDOWN) { if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) { - viewman->handleCommand(Remote::OK); //simulate OK press + boxstack->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()) + if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight()) { - viewman->handleCommand(Remote::BACK); //simulate cancel press + boxstack->handleCommand(Remote::BACK); //simulate cancel press } } } @@ -278,8 +282,8 @@ void VChannelList::processMessage(Message* m) VVideoLive* v = new VVideoLive(chanList, VDR::VIDEO, this); // FIXME - what's wrong with it? v->draw(); - viewman->add(v); - viewman->updateView(v); + boxstack->add(v); + boxstack->update(v); v->channelChange(VVideoLive::NUMBER, m->parameter); } } diff --git a/vchannellist.h b/vchannellist.h index 0421573..ad13c51 100644 --- a/vchannellist.h +++ b/vchannellist.h @@ -25,20 +25,16 @@ #include #include -#include "view.h" -#include "wselectlist.h" -#include "remote.h" -#include "wsymbol.h" -#include "viewman.h" +#include "tbboxx.h" +#include "defines.h" #include "vdr.h" -#include "channel.h" -#include "vvideolive.h" -#include "colour.h" -#include "video.h" -#include "i18n.h" -#include "message.h" - -class VChannelList : public View +#include "wselectlist.h" + +class Channel; +class BoxStack; +class Message; + +class VChannelList : public TBBoxx { public: VChannelList(ULONG type); @@ -51,7 +47,7 @@ class VChannelList : public View void draw(); private: - ViewMan* viewman; + BoxStack* boxstack; ChannelList* chanList; WSelectList sl; diff --git a/vchannelselect.cc b/vchannelselect.cc index b538de2..8264ccb 100644 --- a/vchannelselect.cc +++ b/vchannelselect.cc @@ -20,10 +20,19 @@ #include "vchannelselect.h" +#include "remote.h" +#include "vvideolive.h" +#include "message.h" +#include "boxstack.h" +#include "colour.h" +#include "log.h" +#include "timers.h" +#include "command.h" + // this class only works as it does because the remote command // values for the numbers are the numbers themselves ! -VChannelSelect::VChannelSelect(View* v) +VChannelSelect::VChannelSelect(Boxx* v) { parent = v; numGot = 0; @@ -33,8 +42,9 @@ VChannelSelect::VChannelSelect(View* v) if (numWidth > 10) numWidth = 10; for (int i = 0; i < numWidth; i++) input[i] = -1; - create((numWidth*10) + 22, 30); // 10 px = width of number chars in font - setScreenPos(80, 60); + setSize((numWidth*10) + 22, 30); // 10 px = width of number chars in font + createBuffer(); + setPosition(80, 60); setBackgroundColour(Colour::VIEWBACKGROUND); } @@ -63,7 +73,7 @@ void VChannelSelect::doInput(int number) void VChannelSelect::draw() { - View::draw(); + Boxx::draw(); // draw numbers char text[2]; @@ -115,7 +125,7 @@ void VChannelSelect::changeChannel(bool which) // Close me m = new Message(); // Delete self m->from = this; - m->to = ViewMan::getInstance(); + m->to = BoxStack::getInstance(); m->message = Message::CLOSE_ME; if (which) Command::getInstance()->postMessageNoLock(m); @@ -140,7 +150,7 @@ int VChannelSelect::handleCommand(int command) { doInput(command); draw(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); if (numGot == numWidth) changeChannel(true); else Timers::getInstance()->setTimerD(this, 1, 3); return 2; diff --git a/vchannelselect.h b/vchannelselect.h index 9449e5f..0df9783 100644 --- a/vchannelselect.h +++ b/vchannelselect.h @@ -22,23 +22,15 @@ #define VCHANNELSELECT_H #include +#include -#include "view.h" -#include "remote.h" -#include "vvideolive.h" -#include "message.h" -#include "viewman.h" -#include "colour.h" -#include "log.h" +#include "boxx.h" #include "timerreceiver.h" -#include "timers.h" -class VVideoLive; - -class VChannelSelect : public View, public TimerReceiver +class VChannelSelect : public Boxx, public TimerReceiver { public: - VChannelSelect(View* v); + VChannelSelect(Boxx* v); ~VChannelSelect(); void draw(); @@ -46,7 +38,7 @@ class VChannelSelect : public View, public TimerReceiver void timercall(int clientReference); private: - View* parent; + Boxx* parent; int input[10]; int numGot; diff --git a/vconnect.cc b/vconnect.cc index 52ed995..b7323d8 100644 --- a/vconnect.cc +++ b/vconnect.cc @@ -20,20 +20,31 @@ #include "vconnect.h" +#include "video.h" +#include "colour.h" +#include "command.h" +#include "i18n.h" +#include "boxstack.h" +#include "message.h" +#include "log.h" +#include "wol.h" +#include "vserverselect.h" + VConnect::VConnect() { - viewman = ViewMan::getInstance(); + boxstack = BoxStack::getInstance(); vdr = VDR::getInstance(); logger = Log::getInstance(); - create(400, 200); + setSize(400, 200); + createBuffer(); if (Video::getInstance()->getFormat() == Video::PAL) { - setScreenPos(170, 200); + setPosition(170, 200); } else { - setScreenPos(160, 150); + setPosition(160, 150); } exitable = 0; @@ -73,7 +84,7 @@ void VConnect::threadMethod() { setOneLiner(tr("Locating server")); draw(); - viewman->updateView(this); + boxstack->update(this); vdr->findServers(servers); if (!irun) @@ -96,9 +107,9 @@ void VConnect::threadMethod() selectedServer = -1; VServerSelect* vs = new VServerSelect(servers, this); vs->draw(); - viewman->add(vs); // FIXME - do this better - perhaps post message to Command - // Otherwise it will be using ViewMan without the Command mutex locked - viewman->updateView(vs); + boxstack->add(vs); // FIXME - do this better - perhaps post message to Command + // Otherwise it will be using BoxStack without the Command mutex locked + boxstack->update(vs); threadLock(); threadWaitForSignal(); @@ -130,7 +141,7 @@ void VConnect::threadMethod() setOneLiner(tr("Connecting to VDR")); draw(); - viewman->updateView(this); + boxstack->update(this); success = vdr->connect(); if (success) @@ -152,7 +163,7 @@ void VConnect::threadMethod() } draw(); - viewman->updateView(this); + boxstack->update(this); MILLISLEEP(delay); } while(!success); diff --git a/vconnect.h b/vconnect.h index bc4cdf4..3f4704e 100644 --- a/vconnect.h +++ b/vconnect.h @@ -25,14 +25,8 @@ #include #include -#include "view.h" -#include "viewman.h" +#include "vinfo.h" #include "vdr.h" -#include "command.h" -#include "message.h" -#include "colour.h" -#include "video.h" -#include "i18n.h" #ifdef WIN32 #include "threadwin.h" @@ -40,6 +34,10 @@ #include "threadp.h" #endif +class Log; +class BoxStack; +class Message; + class VConnect : public VInfo, public Thread_TYPE { public: @@ -57,6 +55,7 @@ class VConnect : public VInfo, public Thread_TYPE void threadPostStopCleanup() {}; void clearServerIPs(); + BoxStack* boxstack; UCHAR irun; VDR* vdr; Log* logger; diff --git a/vdr.cc b/vdr.cc index c89b746..af0be46 100644 --- a/vdr.cc +++ b/vdr.cc @@ -19,7 +19,15 @@ */ #include "vdr.h" + #include "recman.h" +#include "tcp.h" +#include "log.h" +#include "recinfo.h" +#include "dsock.h" +#include "channel.h" +#include "event.h" +#include "wol.h" VDR* VDR::instance = NULL; @@ -887,7 +895,7 @@ EventList* VDR::getChannelSchedule(ULONG number, time_t start, ULONG duration) return eventList; } -int VDR::configSave(char* section, char* key, const char* value) +int VDR::configSave(const char* section, const char* key, const char* value) { ULONG totalLength = 8 + strlen(section) + strlen(key) + strlen(value) + 3; // 8 for headers, 3 for nulls UCHAR* buffer = new UCHAR[totalLength]; @@ -928,7 +936,7 @@ int VDR::configSave(char* section, char* key, const char* value) return toReturn; } -char* VDR::configLoad(char* section, char* key) +char* VDR::configLoad(const char* section, const char* key) { ULONG totalLength = 8 + strlen(section) + strlen(key) + 2; // 8 for headers, 2 for nulls UCHAR* buffer = new UCHAR[totalLength]; @@ -1011,6 +1019,8 @@ RecTimerList* VDR::getRecTimersList() newRecTimer->channelNumber = extractULONG(); newRecTimer->startTime = extractULONG(); newRecTimer->stopTime = extractULONG(); + newRecTimer->day = extractULONG(); + newRecTimer->weekDays = extractULONG(); tempString = extractString(); newRecTimer->setFile(tempString); @@ -1432,3 +1442,46 @@ ULONG VDR::loadImage(const char* fileName, ULONG x, ULONG y) return lengthBytes; } + +int VDR::deleteTimer(RecTimer* delTimer) +{ + Log::getInstance()->log("VDR", Log::DEBUG, "Delete timer called"); + + unsigned long totalLength = 28; + UCHAR* buffer = new UCHAR[totalLength]; + + *(unsigned long*)&buffer[0] = htonl(totalLength - 4); + *(unsigned long*)&buffer[4] = htonl(VDR_DELETETIMER); + *(unsigned long*)&buffer[8] = htonl(delTimer->channelNumber); + *(unsigned long*)&buffer[12] = htonl(delTimer->weekDays); + *(unsigned long*)&buffer[16] = htonl(delTimer->day); + *(unsigned long*)&buffer[20] = htonl(delTimer->startTime); + *(unsigned long*)&buffer[24] = htonl(delTimer->stopTime); + + + MUTEX_LOCK(&mutex); + if (!connected) { MUTEX_UNLOCK(&mutex); return 0; } + + unsigned int a = tcp->sendPacket(buffer, totalLength); + delete []buffer; + + if (a != totalLength) + { + disconnect(); + MUTEX_UNLOCK(&mutex); + return 0; + } + + if (!getPacket()) + { + MUTEX_UNLOCK(&mutex); + return 0; + } + + int toReturn = (int)extractULONG(); + freePacket(); + MUTEX_UNLOCK(&mutex); + + return toReturn; +} + diff --git a/vdr.h b/vdr.h index ce74fea..97513a1 100644 --- a/vdr.h +++ b/vdr.h @@ -32,17 +32,16 @@ #include #include "defines.h" -#include "log.h" -#include "dsock.h" -#include "tcp.h" -#include "channel.h" -#include "event.h" #include "rectimer.h" -#include "recinfo.h" #include "mark.h" -#include "wol.h" #include "media.h" +class TCP; +class Log; +class RecInfo; +class Event; +class Channel; + using namespace std; typedef vector EventList; @@ -125,6 +124,7 @@ class VDR bool getNextIFrame(ULONG frameNumber, ULONG direction, ULLONG* rfilePosition, ULONG* rframeNumber, ULONG* rframeLength); // Direction: 0=backwards, 1=forwards MarkList* getMarks(char* fileName); + int deleteTimer(RecTimer* delTimer); ChannelList* getChannelsList(ULONG type); int streamChannel(ULONG number); @@ -136,8 +136,8 @@ class VDR int stopStreaming(); EventList* getChannelSchedule(ULONG number); EventList* getChannelSchedule(ULONG number, time_t start, ULONG duration); - int configSave(char* section, char* key, const char* value); - char* configLoad(char* section, char* key); + int configSave(const char* section, const char* key, const char* value); + char* configLoad(const char* section, const char* key); ULONG setEventTimer(char* timerString); RecTimerList* getRecTimersList(); @@ -210,6 +210,7 @@ class VDR const static ULONG VDR_GETRECINFO = 20; const static ULONG VDR_GETMARKS = 21; const static ULONG VDR_GETCHANNELPIDS = 22; + const static ULONG VDR_DELETETIMER = 23; const static ULONG VDR_GETMEDIALIST = 30; const static ULONG VDR_GETIMAGE = 31; const static ULONG VDR_GETIMAGEBLOCK = 32; diff --git a/vepg.cc b/vepg.cc index 06859ee..d18787e 100644 --- a/vepg.cc +++ b/vepg.cc @@ -33,6 +33,20 @@ #include "vepg.h" +#include "remote.h" +#include "vchannellist.h" +#include "command.h" +#include "video.h" +#include "vepgsettimer.h" +#include "timers.h" +#include "wsymbol.h" +#include "message.h" +#include "colour.h" +#include "vvideolive.h" +#include "boxstack.h" +#include "channel.h" +#include "i18n.h" + VEpg* VEpg::instance = NULL; VEpg::VEpg(VVideoLive* v, UINT currentChannel, ULONG streamType) @@ -71,7 +85,7 @@ VEpg::VEpg(VVideoLive* v, UINT currentChannel, ULONG streamType) } // initialise variables and pointers - viewman = ViewMan::getInstance(); + boxstack = BoxStack::getInstance(); videoLive = v; eventList = NULL; chanList = VDR::getInstance()->getChannelsList(streamType); //TODO want to be able to display video and radio together @@ -86,36 +100,42 @@ VEpg::VEpg(VVideoLive* v, UINT currentChannel, ULONG streamType) // Create pallet on which to paint our epg view and position it in centre of screen. // Need to reduce size to deal with overscanning TVs. - create(xsize, ysize); - setScreenPos(xpos, ypos); + setSize(xsize, ysize); + createBuffer(); + setPosition(xpos, ypos); // beautify - Colour transparent = Colour(0, 0, 0, 0); - setBackgroundColour(transparent); +// Colour transparent = Colour(0, 0, 0, 0); +// setBackgroundColour(transparent); - progTitle.setSurface(surface); - progTitle.setSurfaceOffset(0,0); - progTitle.setDimensions(300,(Surface::getFontHeight() + 4) * 2 + 16); //paragraph line seperation is 4 pixels +// progTitle.setSurface(surface); + progTitle.setPosition(0,0); + progTitle.setSize(300,(Surface::getFontHeight() + 4) * 2 + 16); //paragraph line seperation is 4 pixels progTitle.setBackgroundColour(Colour::TITLEBARBACKGROUND); progTitle.setTextPos(5, 16); progTitle.setGap(4); + add(&progTitle); - progInfo.setSurface(surface); - progInfo.setSurfaceOffset(0, progTitle.getOffsetY() + progTitle.getHeight()); - progInfo.setDimensions(300,((Surface::getFontHeight() + 4) * summaryLines) + summaryLowerPadding); +// progInfo.setSurface(surface); + progInfo.setBackgroundColour(Colour::VIEWBACKGROUND); + progInfo.setPosition(0, progTitle.getY() + progTitle.getHeight()); + progInfo.setSize(300,((Surface::getFontHeight() + 4) * summaryLines) + summaryLowerPadding); progInfo.setGap(4); + add(&progInfo); - chanName.setSurface(surface); - chanName.setDimensions(510, (Surface::getFontHeight() + 4)); - chanName.setSurfaceOffset(305, chanNameYpos); - chanName.setBackgroundColour(Colour(0, 0, 0, 90)); +// chanName.setSurface(surface); + chanName.setSize(510, (Surface::getFontHeight() + 4)); + chanName.setPosition(305, chanNameYpos); + Colour t1(0, 0, 0, 90); + chanName.setBackgroundColour(t1); + add(&chanName); // create area to display list of channels - chanListbox.setSurface(surface); // add channel list - chanListbox.setSurfaceOffset(0, progInfo.getOffsetY() + progInfo.getHeight() + Surface::getFontHeight() + 8); // position channel list - chanListbox.setDimensions(150, ((Surface::getFontHeight() + 2) * gridRows) + 5); //listbox line seperation is 2 pixels +// chanListbox.setSurface(surface); // add channel list + chanListbox.setPosition(0, progInfo.getY() + progInfo.getHeight() + Surface::getFontHeight() + 8); // position channel list + chanListbox.setSize(150, ((Surface::getFontHeight() + 2) * gridRows) + 5); //listbox line seperation is 2 pixels chanListbox.setGap(2); - + add(&chanListbox); // populate channel list if (chanList) @@ -155,7 +175,7 @@ VEpg::~VEpg() delete eventLista[listIndex]; } } - // delete [] eventLista; + // delete [] eventLista; // FIXME // destroy dynamically allocated memory } @@ -200,64 +220,79 @@ void VEpg::setInfo(Event* event) void VEpg::draw() { - View::draw(); // draw pallet - +// View::draw(); // draw pallet + // beautify + Colour transparent = Colour(0, 0, 0, 0); + fillColour(transparent); + + // Moved all the dynamic data drawing to a seperate function // Display the status and key stuff at the bottom - int keyx = chanListbox.getOffsetX(); - int keyy = chanListbox.getOffsetY() + chanListbox.getHeight() + 2; - rectangle(keyx, keyy, 605, Surface::getFontHeight() * 2 + 14, Colour(100, 100, 100, 255)); - WSymbol w; - w.setSurface(surface); + UINT keyx = chanListbox.getRootBoxOffsetX(); + UINT keyy = chanListbox.getRootBoxOffsetY() + chanListbox.getHeight() + 2; + Colour ref1 = Colour(100, 100, 100, 255); + rectangle(keyx, keyy, 605, Surface::getFontHeight() * 2 + 14, ref1); + WSymbol w; + TEMPADD(&w); + w.nextSymbol = WSymbol::LEFTARROW; - w.setSurfaceOffset(keyx + 1, keyy + 20); + w.setPosition(keyx + 1, keyy + 20); w.draw(); w.nextSymbol = WSymbol::UP; - w.setSurfaceOffset(keyx + 26, keyy + 3); + w.setPosition(keyx + 26, keyy + 3); w.draw(); w.nextSymbol = WSymbol::DOWN; - w.setSurfaceOffset(keyx + 26, keyy + 36); + w.setPosition(keyx + 26, keyy + 36); w.draw(); w.nextSymbol = WSymbol::RIGHTARROW; - w.setSurfaceOffset(keyx + 50, keyy + 20); + w.setPosition(keyx + 50, keyy + 20); w.draw(); drawText(tr("OK"), keyx + 18, keyy + 20, Colour::LIGHTTEXT); - rectangle(keyx + 72, keyy + 4, 104, Surface::getFontHeight() + 2, Colour(200, 0, 0, 255)); + Colour ref2 = Colour(200, 0, 0, 255); + rectangle(keyx + 72, keyy + 4, 104, Surface::getFontHeight() + 2, ref2); drawText(tr("Page up"), keyx + 74, keyy + 5, Colour::LIGHTTEXT); - rectangle(keyx + 72, keyy + Surface::getFontHeight() + 8, 104, Surface::getFontHeight() + 2, Colour(0, 200, 0, 255)); + Colour ref3 = Colour(0, 200, 0, 255); + rectangle(keyx + 72, keyy + Surface::getFontHeight() + 8, 104, Surface::getFontHeight() + 2, ref3); drawText(tr("Page down"), keyx + 74, keyy + Surface::getFontHeight() + 9, Colour::LIGHTTEXT); - rectangle(keyx + 180, keyy + 4, 104, Surface::getFontHeight() + 2, Colour(200, 200, 0, 255)); + Colour ref4 = Colour(200, 200, 0, 255); + rectangle(keyx + 180, keyy + 4, 104, Surface::getFontHeight() + 2, ref4); drawText(tr("-24 hours"), keyx + 182, keyy + 5, Colour::LIGHTTEXT); - rectangle(keyx + 180, keyy + Surface::getFontHeight() + 8, 104, Surface::getFontHeight() + 2, Colour(0, 0, 200, 255)); + Colour ref5 = Colour(0, 0, 200, 255); + rectangle(keyx + 180, keyy + Surface::getFontHeight() + 8, 104, Surface::getFontHeight() + 2, ref5); drawText(tr("+24 hours"), keyx + 182, keyy + Surface::getFontHeight() + 9, Colour::LIGHTTEXT); - rectangle(keyx + 290, keyy + 4, 180, Surface::getFontHeight() + 2, Colour(180, 180, 180, 255)); + Colour ref6 = Colour(180, 180, 180, 255); + rectangle(keyx + 290, keyy + 4, 180, Surface::getFontHeight() + 2, ref6); drawText(tr("Guide / Back: Close"), keyx + 292 , keyy + 5, Colour::LIGHTTEXT); - rectangle(keyx + 290, keyy + Surface::getFontHeight() + 8, 180, Surface::getFontHeight() + 2, Colour(180, 180, 180, 255)); + Colour ref7 = Colour(180, 180, 180, 255); + rectangle(keyx + 290, keyy + Surface::getFontHeight() + 8, 180, Surface::getFontHeight() + 2, ref7); Colour red = Colour(130, 0, 0); drawText(tr("Rec: Set timer"), keyx + 292, keyy + Surface::getFontHeight() + 9, red); - rectangle(keyx + 474, keyy + 4, 128, Surface::getFontHeight() + 2, Colour(180, 180, 180, 255)); + Colour ref8 = Colour(180, 180, 180, 255); + rectangle(keyx + 474, keyy + 4, 128, Surface::getFontHeight() + 2, ref8); w.nextSymbol = WSymbol::PLAY; - w.setSurfaceOffset(keyx + 476, keyy + 5); + w.setPosition(keyx + 476, keyy + 5); w.draw(); drawText(tr("Sel channel"), keyx + 496, keyy + 5, Colour::LIGHTTEXT); - rectangle(keyx + 474, keyy + Surface::getFontHeight() + 8, 128, Surface::getFontHeight() + 2, Colour(180, 180, 180, 255)); + Colour ref9 = Colour(180, 180, 180, 255); + rectangle(keyx + 474, keyy + Surface::getFontHeight() + 8, 128, Surface::getFontHeight() + 2, ref9); drawText(tr("Go: Preview"), keyx + 476, keyy + Surface::getFontHeight() + 9, Colour::LIGHTTEXT); + // Draw all the dynamic data drawData(); } @@ -269,8 +304,8 @@ void VEpg::drawData() // So, blank out the data area first rectangle( - chanListbox.getOffsetX(), - chanListbox.getOffsetY() - Surface::getFontHeight() - 3, + chanListbox.getRootBoxOffsetX(), + chanListbox.getRootBoxOffsetY() - Surface::getFontHeight() - 3, 155 + WINDOW_WIDTH * MINUTE_SCALE, chanListbox.getHeight() + Surface::getFontHeight() + 4, Colour::BLACK); @@ -278,6 +313,7 @@ void VEpg::drawData() chanListbox.draw(); drawgrid(); chanName.draw(); // TODO this should be dealt with by vvideolive + progTitle.draw(); progInfo.draw(); @@ -293,10 +329,10 @@ void VEpg::drawData() void VEpg::timercall(int clientReference) { drawData(); - // Put updateView through master mutex since viewman is not mutex protected + // Put updateView through master mutex since boxstack is not mutex protected Message* m = new Message(); m->message = Message::REDRAW; - m->to = ViewMan::getInstance(); + m->to = boxstack; m->from = this; m->parameter = 0; Command::getInstance()->postMessageFromOuterSpace(m); @@ -311,7 +347,7 @@ int VEpg::handleCommand(int command) { // cursor up the channel list chanListbox.up(); drawData(); - viewman->updateView(this); + boxstack->update(this); return 2; } case Remote::DF_DOWN: @@ -319,7 +355,7 @@ int VEpg::handleCommand(int command) { // cursor down the channel list chanListbox.down(); drawData(); - viewman->updateView(this); + boxstack->update(this); return 2; } case Remote::DF_LEFT: @@ -327,7 +363,7 @@ int VEpg::handleCommand(int command) { // cursor left through time selTime = thisEvent.time - 1; drawData(); - viewman->updateView(this); + boxstack->update(this); return 2; } case Remote::DF_RIGHT: @@ -336,7 +372,7 @@ int VEpg::handleCommand(int command) // cursor right through time selTime = thisEvent.time + thisEvent.duration; drawData(); - viewman->updateView(this); + boxstack->update(this); return 2; } case Remote::RED: @@ -344,7 +380,7 @@ int VEpg::handleCommand(int command) // cursor up one page chanListbox.pageUp(); drawData(); - viewman->updateView(this); + boxstack->update(this); return 2; } case Remote::GREEN: @@ -352,7 +388,7 @@ int VEpg::handleCommand(int command) // cursor down one page chanListbox.pageDown(); drawData(); - viewman->updateView(this); + boxstack->update(this); return 2; } case Remote::BLUE: @@ -360,7 +396,7 @@ int VEpg::handleCommand(int command) // step forward 24 hours selTime += 24 * 60 * 60; drawData(); - viewman->updateView(this); + boxstack->update(this); return 2; } case Remote::YELLOW: @@ -368,7 +404,7 @@ int VEpg::handleCommand(int command) // step forward 24 hours selTime -= 24 * 60 * 60; drawData(); - viewman->updateView(this); + boxstack->update(this); return 2; } case Remote::RECORD: @@ -377,8 +413,8 @@ int VEpg::handleCommand(int command) Log::getInstance()->log("VEPG", Log::DEBUG, "ID %lu TIME %lu DURATION %lu TITLE %s", thisEvent.id, thisEvent.time, thisEvent.duration, thisEvent.title); VEpgSetTimer* vs = new VEpgSetTimer(&thisEvent, (*chanList)[chanListbox.getCurrentOption()]); vs->draw(); - viewman->add(vs); - viewman->updateView(vs); + boxstack->add(vs); + boxstack->update(vs); return 2; } case Remote::PLAY: @@ -445,26 +481,28 @@ void VEpg::drawgrid() // redraws grid and select programme updateEventList(); } // draw time scale + Colour white = Colour(255, 255, 255, 255); + t = ltime; struct tm* tms; tms = localtime(&t); strftime(timeString, 19, "%a %e %b", tms); - int timey = chanListbox.getOffsetY() - Surface::getFontHeight() - 3; + int timey = chanListbox.getRootBoxOffsetY() - Surface::getFontHeight() - 3; int timex = 135; drawTextRJ(timeString, timex - 10, timey, Colour::LIGHTTEXT); // print date strftime(timeString, 19, "%H:%M", tms); drawText(timeString, timex, timey, Colour::LIGHTTEXT); // print left time - rectangle(155, timey + Surface::getFontHeight(), 2, 7, Colour(255, 255, 255, 255)); + rectangle(155, timey + Surface::getFontHeight(), 2, 7, white); t = t + 3600; tms = localtime(&t); strftime(timeString, 19, "%H:%M", tms); drawText(timeString, timex + 180, timey, Colour::LIGHTTEXT); // print middle time - rectangle(335, timey + Surface::getFontHeight(), 2, 7, Colour(255, 255, 255, 255)); + rectangle(335, timey + Surface::getFontHeight(), 2, 7, white); t = t + 3600; tms = localtime(&t); strftime(timeString, 19, "%H:%M", tms); drawText(timeString, timex + 360, timey, Colour::LIGHTTEXT); // print right time - rectangle(515, timey + Surface::getFontHeight(), 2, 7, Colour(255, 255, 255, 255)); + rectangle(515, timey + Surface::getFontHeight(), 2, 7, white); // pointer to selTime //rectangle(155 + (selTime - ltime) / 20, timey + Surface::getFontHeight(), 2, 7, Colour(255, 50, 50, 255)); @@ -485,7 +523,7 @@ void VEpg::drawgrid() // redraws grid and select programme thisEvent.id = 0; bool swapColour = FALSE; // alternate cell colour bool currentRow = FALSE; - int y = chanListbox.getOffsetY() + 5; // vertical position of cell + int y = chanListbox.getRootBoxOffsetY() + 5; // vertical position of cell Colour bg, fg; // background colour of cells in grid // for each displayed channel, find programmes that fall in 2.5 hour time window for(UINT listIndex = 0; listIndex < gridRows; listIndex++) @@ -589,7 +627,7 @@ void VEpg::setCurrentChannel(char* chname) { chanName.setText(chname); chanName.draw(); - viewman->updateView(this); + boxstack->update(this); } void VEpg::paintCell(Event* event, int yOffset, Colour bg, Colour fg) @@ -658,67 +696,67 @@ void VEpg::processMessage(Message* m) if (chanListbox.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) { drawData(); - ViewMan::getInstance()->updateView(this); + boxstack->update(this); } } else if (m->message == Message::MOUSE_LBDOWN) { if (chanListbox.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) { - ViewMan::getInstance()->handleCommand(Remote::OK); //simulate OK press + boxstack->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(); - int keyx = chanListbox.getOffsetX(); - int keyy = chanListbox.getOffsetY() + chanListbox.getHeight() + 2; + int keyx = chanListbox.getRootBoxOffsetX(); + int keyy = chanListbox.getRootBoxOffsetY() + chanListbox.getHeight() + 2; - if (x<0 || y <0 || x>getWidth() || y>getHeight()) + if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight()) { - ViewMan::getInstance()->handleCommand(Remote::BACK); //simulate cancel press + boxstack->handleCommand(Remote::BACK); //simulate cancel press } else if (x>=(keyx+72) && y>=(keyy+4) &&x<=(keyx+72+104) &&y<=(keyy+4+Surface::getFontHeight() + 2)) { - ViewMan::getInstance()->handleCommand(Remote::RED); + boxstack->handleCommand(Remote::RED); } else if (x>=(keyx+72) && y>=(keyy+ Surface::getFontHeight() + 8) &&x<=(keyx+72+104) &&y<=(keyy+8+2*Surface::getFontHeight() + 2)) { - ViewMan::getInstance()->handleCommand(Remote::GREEN); + boxstack->handleCommand(Remote::GREEN); } else if (x>=(keyx+180) && y>=(keyy+4) &&x<=(keyx+180+104) &&y<=(keyy+4+Surface::getFontHeight() + 2)) { - ViewMan::getInstance()->handleCommand(Remote::YELLOW); + boxstack->handleCommand(Remote::YELLOW); } else if (x>=(keyx+180) && y>=(keyy+ Surface::getFontHeight() + 8) &&x<=(keyx+180+104) &&y<=(keyy+8+2*Surface::getFontHeight() + 2)) { - ViewMan::getInstance()->handleCommand(Remote::BLUE); + boxstack->handleCommand(Remote::BLUE); } else if (x>=(keyx+290) && y>=(keyy+4) &&x<=(keyx+180+290) &&y<=(keyy+4+Surface::getFontHeight() + 2)) { - ViewMan::getInstance()->handleCommand(Remote::BACK); + boxstack->handleCommand(Remote::BACK); } else if (x>=(keyx+290) && y>=(keyy+ Surface::getFontHeight() + 8) &&x<=(keyx+290+180) &&y<=(keyy+8+2*Surface::getFontHeight() + 2)) { - ViewMan::getInstance()->handleCommand(Remote::RECORD); + boxstack->handleCommand(Remote::RECORD); } else if (x>=(keyx+474) && y>=(keyy+4) &&x<=(keyx+128+474) &&y<=(keyy+4+Surface::getFontHeight() + 2)) { - ViewMan::getInstance()->handleCommand(Remote::PLAY); + boxstack->handleCommand(Remote::PLAY); } else if (x>=(keyx+474) && y>=(keyy+ Surface::getFontHeight() + 8) &&x<=(keyx+238+474) &&y<=(keyy+8+2*Surface::getFontHeight() + 2)) { - ViewMan::getInstance()->handleCommand(Remote::GO); + boxstack->handleCommand(Remote::GO); } - else if ( x>=(chanListbox.getOffsetX()) - && y>=(chanListbox.getOffsetY() + 5) + else if ( x>=(chanListbox.getRootBoxOffsetX()) + && y>=(chanListbox.getRootBoxOffsetY() + 5) // &&x<=(chanListbox.getOffsetX()+155 + WINDOW_WIDTH * MINUTE_SCALE) - &&y<=(chanListbox.getOffsetY() - Surface::getFontHeight() - - 3+chanListbox.getHeight() + Surface::getFontHeight() + 3) + &&y<=(chanListbox.getRootBoxOffsetY() - Surface::getFontHeight() + - 3+(int)chanListbox.getHeight() + Surface::getFontHeight() + 3) ) { - int cy=y-(chanListbox.getOffsetY() + 5); + int cy=y-(chanListbox.getRootBoxOffsetY() + 5); int row=cy/(Surface::getFontHeight()+2); int clistTop = chanListbox.getTopOption(); chanListbox.hintSetCurrent(clistTop+row); @@ -728,7 +766,7 @@ void VEpg::processMessage(Message* m) selTime = ttime; drawData(); - viewman->updateView(this); + boxstack->update(this); } } } diff --git a/vepg.h b/vepg.h index 04aa1d6..c633b49 100644 --- a/vepg.h +++ b/vepg.h @@ -20,31 +20,28 @@ #ifndef VEPG_H #define VEPG_H -#define WINDOW_WIDTH (150) -#define MINUTE_SCALE (3) + #include #include -#include "view.h" -#include "remote.h" -#include "wselectlist.h" -#include "viewman.h" -#include "vdr.h" -#include "vchannellist.h" -#include "command.h" -#include "message.h" -#include "colour.h" -#include "video.h" +#include "boxx.h" +#include "defines.h" +#include "timerreceiver.h" #include "wtextbox.h" +#include "vdr.h" +#include "wselectlist.h" #include "event.h" -#include "message.h" -#include "vvideolive.h" -#include "vepgsettimer.h" -#include "timers.h" + +class Message; +class VVideoLive; +class BoxStack; + +#define WINDOW_WIDTH (150) +#define MINUTE_SCALE (3) class VVideoLive; -class VEpg : public View, public TimerReceiver +class VEpg : public Boxx, public TimerReceiver { public: VEpg(VVideoLive* v, UINT currentChannel, ULONG streamType); @@ -85,7 +82,7 @@ class VEpg : public View, public TimerReceiver void paintCell(Event* event, int yOffset, Colour bg, Colour fg); time_t prevHour(time_t* t); VVideoLive* videoLive; - ViewMan* viewman; + BoxStack* boxstack; UINT gridRows; }; diff --git a/vepgsettimer.cc b/vepgsettimer.cc index 4e0bcef..4059b11 100644 --- a/vepgsettimer.cc +++ b/vepgsettimer.cc @@ -20,35 +20,48 @@ #include "vepgsettimer.h" +#include "event.h" +#include "channel.h" +#include "boxstack.h" +#include "vdr.h" +#include "log.h" +#include "vinfo.h" +#include "message.h" +#include "command.h" +#include "video.h" +#include "remote.h" +#include "i18n.h" + VEpgSetTimer::VEpgSetTimer(Event* tevent, Channel* tchannel) { - viewman = ViewMan::getInstance(); + boxstack = BoxStack::getInstance(); vdr = VDR::getInstance(); logger = Log::getInstance(); event = tevent; channel = tchannel; - create(400, 240); + setSize(400, 240); + createBuffer(); if (Video::getInstance()->getFormat() == Video::PAL) { - setScreenPos(150, 170); + setPosition(150, 170); } else { - setScreenPos(140, 140); + setPosition(140, 140); } - setBackgroundColour(Colour::VIEWBACKGROUND); setTitleBarOn(1); setTitleBarColour(Colour::TITLEBARBACKGROUND); setBorderOn(true); setTitleText(tr("Set Timer")); - buttonYes.setSurface(surface); - buttonNo.setSurface(surface); - buttonYes.setSurfaceOffset(80, 40 + (7 * surface->getFontHeight())); - buttonNo.setSurfaceOffset(220, 40 + (7 * surface->getFontHeight())); + add(&buttonYes); + add(&buttonNo); + + buttonYes.setPosition(80, 40 + (7 * surface->getFontHeight())); + buttonNo.setPosition(220, 40 + (7 * surface->getFontHeight())); buttonYes.setText(tr("Yes")); buttonNo.setText(tr("No")); @@ -161,7 +174,7 @@ void VEpgSetTimer::swap() void VEpgSetTimer::draw() { - View::draw(); + TBBoxx::draw(); drawPara(event->title, 10, 40, Colour::LIGHTTEXT); drawText(channel->name, 10, 40 + (2 * surface->getFontHeight()), Colour::LIGHTTEXT); @@ -202,7 +215,7 @@ int VEpgSetTimer::handleCommand(int command) { swap(); draw(); - ViewMan::getInstance()->updateView(this); + boxstack->update(this); return 2; } case Remote::DF_RIGHT: @@ -210,7 +223,7 @@ int VEpgSetTimer::handleCommand(int command) { swap(); draw(); - ViewMan::getInstance()->updateView(this); + boxstack->update(this); return 2; } case Remote::BACK: @@ -247,15 +260,16 @@ void VEpgSetTimer::doit() else if (ret == 2) logger->log("VEPGST", Log::DEBUG, "Fail: General failure setting timer"); VInfo* vi = new VInfo(); - vi->create(400, 150); + vi->setSize(400, 150); + vi->createBuffer(); vi->setExitable(); vi->setBorderOn(1); vi->setTitleBarOn(0); if (Video::getInstance()->getFormat() == Video::PAL) - vi->setScreenPos(170, 200); + vi->setPosition(170, 200); else - vi->setScreenPos(160, 150); + vi->setPosition(160, 150); if (ret == 0) vi->setOneLiner(tr("Timer set successfully")); else if (ret == 1) vi->setOneLiner(tr("There is already a timer for this event")); @@ -264,12 +278,11 @@ void VEpgSetTimer::doit() Message* m = new Message(); m->message = Message::ADD_VIEW; - m->to = viewman; + m->to = boxstack; m->parameter = (ULONG)vi; Command::getInstance()->postMessageNoLock(m); } - void VEpgSetTimer::processMessage(Message* m) { if (m->message == Message::MOUSE_MOVE) @@ -279,34 +292,34 @@ void VEpgSetTimer::processMessage(Message* m) buttonNo.setActive(0); selectedOption = YES; draw(); - ViewMan::getInstance()->updateView(this); + boxstack->update(this); } else if (buttonNo.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) { buttonYes.setActive(0); selectedOption = NO; draw(); - ViewMan::getInstance()->updateView(this); + boxstack->update(this); } } else if (m->message == Message::MOUSE_LBDOWN) { if (buttonYes.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) { - ViewMan::getInstance()->handleCommand(Remote::OK); //simulate OK press + boxstack->handleCommand(Remote::OK); //simulate OK press } else if (buttonNo.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) { - ViewMan::getInstance()->handleCommand(Remote::OK); //simulate OK press + boxstack->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()) + if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight()) { - ViewMan::getInstance()->handleCommand(Remote::BACK); //simulate cancel press + boxstack->handleCommand(Remote::BACK); //simulate cancel press } } } diff --git a/vepgsettimer.h b/vepgsettimer.h index b2ee0f9..e09da8a 100644 --- a/vepgsettimer.h +++ b/vepgsettimer.h @@ -22,20 +22,18 @@ #define VEPGSETTIMER_H #include -#include "video.h" -#include "view.h" -#include "remote.h" -#include "viewman.h" -#include "vdr.h" -#include "event.h" -#include "channel.h" -#include "i18n.h" + +#include "tbboxx.h" #include "wbutton.h" -#include "vinfo.h" -#include "message.h" -#include "command.h" -class VEpgSetTimer : public View +class Event; +class Channel; +class Log; +class VDR; +class Message; +class BoxStack; + +class VEpgSetTimer : public TBBoxx { public: VEpgSetTimer(Event* event, Channel* channel); @@ -46,8 +44,8 @@ class VEpgSetTimer : public View void draw(); private: + BoxStack* boxstack; Log* logger; - ViewMan* viewman; VDR* vdr; Event* event; diff --git a/vfeed.cc b/vfeed.cc index c73bd64..c4409be 100644 --- a/vfeed.cc +++ b/vfeed.cc @@ -20,6 +20,10 @@ #include "vfeed.h" +#include "log.h" +#include "demuxer.h" +#include "callback.h" + VFeed::VFeed(Callback* tcb) : cb(*tcb) { diff --git a/vfeed.h b/vfeed.h index 54975ef..514c908 100644 --- a/vfeed.h +++ b/vfeed.h @@ -24,16 +24,14 @@ #include #include -#include "log.h" -#include "demuxer.h" -#include "callback.h" - #ifdef WIN32 #include "threadwin.h" #else #include "threadp.h" #endif +class Callback; + class VFeed : public Thread_TYPE { public: diff --git a/vinfo.cc b/vinfo.cc index 790c451..eff47a0 100644 --- a/vinfo.cc +++ b/vinfo.cc @@ -20,6 +20,12 @@ #include "vinfo.h" +#include "remote.h" +#include "colour.h" +#include "wbutton.h" +#include "i18n.h" +#include "boxstack.h" + VInfo::VInfo() { mainText = NULL; @@ -27,7 +33,6 @@ VInfo::VInfo() dropThrough = 0; okbutton = false; - setBackgroundColour(Colour::VIEWBACKGROUND); setTitleBarOn(1); setTitleBarColour(Colour::TITLEBARBACKGROUND); } @@ -47,7 +52,7 @@ void VInfo::setDropThrough() dropThrough = 1; } -void VInfo::setMainText(char* takeText) +void VInfo::setMainText(const char* takeText) { int length = strlen(takeText); mainText = new char[length + 1]; @@ -55,7 +60,7 @@ void VInfo::setMainText(char* takeText) mainTextType = NORMAL; } -void VInfo::setOneLiner(char* takeText) +void VInfo::setOneLiner(const char* takeText) { int length = strlen(takeText); mainText = new char[length + 1]; @@ -65,7 +70,7 @@ void VInfo::setOneLiner(char* takeText) void VInfo::draw() { - View::draw(); + TBBoxx::draw(); if (mainText) { @@ -83,13 +88,15 @@ void VInfo::draw() if (okbutton) { +/* WButton button; - button.setSurface(surface); - button.setSurfaceOffset((area.w / 2) - 30, area.h - 50); + button.setPosition((area.w / 2) - 30, area.h - 50); button.setText(tr("OK")); button.setActive(1); + add(&button); button.draw(); - } +*/ + } // FIXME check } int VInfo::handleCommand(int command) @@ -117,6 +124,6 @@ void VInfo::processMessage(Message* m) { if (m->message == Message::MOUSE_LBDOWN) { - ViewMan::getInstance()->handleCommand(Remote::OK); //simulate OK press + BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press } } diff --git a/vinfo.h b/vinfo.h index 4f806bd..92deb06 100644 --- a/vinfo.h +++ b/vinfo.h @@ -24,22 +24,17 @@ #include #include +#include "tbboxx.h" #include "defines.h" -#include "view.h" -#include "remote.h" -#include "colour.h" -#include "wbutton.h" -#include "i18n.h" -#include "viewman.h" - -class VInfo : public View + +class VInfo : public TBBoxx { public: VInfo(); virtual ~VInfo(); - void setMainText(char* title); - void setOneLiner(char* text); + void setMainText(const char* title); + void setOneLiner(const char* text); void setExitable(); void setDropThrough(); void okButton(); diff --git a/vlivebanner.cc b/vlivebanner.cc index 6f1f835..b1e5cca 100644 --- a/vlivebanner.cc +++ b/vlivebanner.cc @@ -20,6 +20,18 @@ #include "vlivebanner.h" +#include "vvideolive.h" +#include "remote.h" +#include "colour.h" +#include "video.h" +#include "event.h" +#include "vinfo.h" +#include "boxstack.h" +#include "i18n.h" +#include "timers.h" +#include "channel.h" +#include "command.h" + VLiveBanner* VLiveBanner::instance = NULL; VLiveBanner::VLiveBanner(VVideoLive* tvvideoLive, Channel* channel, bool bannerTakesCommands) @@ -34,25 +46,25 @@ VLiveBanner::VLiveBanner(VVideoLive* tvvideoLive, Channel* channel, bool bannerT clockRegion.w = 60; clockRegion.h = 30; - create(500, 120); + setSize(500, 120); + createBuffer(); if (Video::getInstance()->getFormat() == Video::PAL) { - setScreenPos(124, 410); + setPosition(124, 410); } else { - setScreenPos(114, 320); + setPosition(114, 320); } - setBackgroundColour(Colour::VIEWBACKGROUND); setTitleBarOn(1); setTitleBarColour(Colour::TITLEBARBACKGROUND); - sl.setSurface(surface); - sl.setSurfaceOffset(0, 30); - sl.setDimensions(area.w, area.h - 60); + sl.setPosition(0, 30); + sl.setSize(area.w, area.h - 60); sl.setNoLoop(); + add(&sl); setChannel(channel); } @@ -138,8 +150,7 @@ void VLiveBanner::setChannel(Channel* tChannel) void VLiveBanner::draw() { - View::draw(); - sl.draw(); + TBBoxx::draw(); rectangle(0, area.h - 30, area.w, 30, titleBarColour); rectangle(7, area.h - 24, 18, 16, Colour::RED); @@ -170,7 +181,7 @@ int VLiveBanner::handleCommand(int command) sl.up(); sl.draw(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); // Arrows pressed, go to an 8s timer Timers::getInstance()->setTimerD(this, 1, 8); @@ -186,7 +197,7 @@ int VLiveBanner::handleCommand(int command) sl.down(); sl.draw(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); // Arrows pressed, go to an 8s timer Timers::getInstance()->setTimerD(this, 1, 8); @@ -224,17 +235,18 @@ int VLiveBanner::handleCommand(int command) else vi->setMainText(tr("Summary unavailable")); if (Video::getInstance()->getFormat() == Video::PAL) { - vi->setScreenPos(120, 130); + vi->setPosition(120, 130); } else { - vi->setScreenPos(110, 90); + vi->setPosition(110, 90); } - vi->create(510, 270); + vi->setSize(510, 270); + vi->createBuffer(); vi->draw(); - ViewMan::getInstance()->add(vi); - ViewMan::getInstance()->updateView(vi); + BoxStack::getInstance()->add(vi); + BoxStack::getInstance()->update(vi); return 2; } @@ -262,7 +274,7 @@ void VLiveBanner::timercall(int clientReference) // delete me! Message* m = new Message(); // Delete self m->message = Message::CLOSE_ME; - m->to = ViewMan::getInstance(); + m->to = BoxStack::getInstance(); m->from = this; Command::getInstance()->postMessageFromOuterSpace(m); } @@ -272,7 +284,7 @@ void VLiveBanner::timercall(int clientReference) drawClock(); Message* m = new Message(); m->message = Message::REDRAW; - m->to = ViewMan::getInstance(); + m->to = BoxStack::getInstance(); m->from = this; m->parameter = (ULONG)&clockRegion; Command::getInstance()->postMessageFromOuterSpace(m); @@ -306,7 +318,7 @@ void VLiveBanner::processMessage(Message* m) if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) { sl.draw(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); } } else if (m->message == Message::MOUSE_LBDOWN) @@ -314,20 +326,20 @@ void VLiveBanner::processMessage(Message* m) //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()) + if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight()) { - ViewMan::getInstance()->handleCommand(Remote::BACK); //simulate cancel press + BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press } else if (y>=(int)area.h-24 && y<=(int)area.h-6) { //y coordinate is right! if (x>=7 &&x<=25) { - ViewMan::getInstance()->handleCommand(Remote::RED); //simulate red press + BoxStack::getInstance()->handleCommand(Remote::RED); //simulate red press } else if (x>=110 &&x<=128) { - ViewMan::getInstance()->handleCommand(Remote::GREEN); //simulate red press + BoxStack::getInstance()->handleCommand(Remote::GREEN); //simulate red press } } } diff --git a/vlivebanner.h b/vlivebanner.h index 85ee138..79cc51e 100644 --- a/vlivebanner.h +++ b/vlivebanner.h @@ -26,23 +26,16 @@ #include #include -#include "view.h" -#include "remote.h" -#include "vdr.h" -#include "wselectlist.h" -#include "colour.h" -#include "video.h" -#include "event.h" -#include "vinfo.h" -#include "viewman.h" -#include "i18n.h" +#include "tbboxx.h" #include "timerreceiver.h" -#include "timers.h" -//#include "vvideolive.h" +#include "wselectlist.h" +#include "region.h" +#include "vdr.h" class VVideoLive; +class Channel; -class VLiveBanner : public View, public TimerReceiver +class VLiveBanner : public TBBoxx, public TimerReceiver { public: VLiveBanner(VVideoLive* tvvideoLive, Channel* channel, bool bannerTakesCommands); diff --git a/vmedialist.cc b/vmedialist.cc index baaa129..e29a745 100644 --- a/vmedialist.cc +++ b/vmedialist.cc @@ -19,13 +19,24 @@ */ #include -#include "unistd.h" -#include "vmedialist.h" #include #include +#include "unistd.h" + +#include "vmedialist.h" + #include "vpicture.h" #include "vaudioplayer.h" - +#include "remote.h" +#include "wsymbol.h" +#include "boxstack.h" +#include "vvideolive.h" +#include "colour.h" +#include "video.h" +#include "i18n.h" +#include "vdr.h" +#include "command.h" +#include "vinfo.h" using namespace std; class MediaDirectory { @@ -225,33 +236,30 @@ struct MediaSorterTime VMediaList::VMediaList() { + boxstack = BoxStack::getInstance(); + dirlist=new DirList(); Log::getInstance()->log("VMediaList::VMediaList", Log::DEBUG, "dirlist=%p,curren=%p",dirlist,dirlist->getCurrent()); dirlist->getCurrent()->setSortorder(SORT_NAME); - create(570, 420); + setSize(570, 420); + createBuffer(); if (Video::getInstance()->getFormat() == Video::PAL) - { - setScreenPos(80, 70); - } + setPosition(80, 70); else - { - setScreenPos(70, 35); - } + setPosition(70, 35); - setBackgroundColour(Colour::VIEWBACKGROUND); setTitleBarOn(1); setTitleBarColour(Colour::TITLEBARBACKGROUND); - sl.setSurface(surface); - sl.setSurfaceOffset(10, 30 + 5); - sl.setDimensions(area.w - 20, area.h - 30 - 15 - 30); + sl.setPosition(10, 30 + 5); + sl.setSize(area.w - 20, area.h - 30 - 15 - 30); sl.addColumn(0); sl.addColumn(60); + add(&sl); + mediaList=NULL; loading=true; sortOrder=SORT_NONE; - - } VMediaList::~VMediaList() @@ -356,7 +364,7 @@ void VMediaList::highlightMedia(Media* media) sl.hintSetCurrent(media->index); sl.draw(); doShowingBar(); - ViewMan::getInstance()->updateView(this); + boxstack->update(this); } void VMediaList::draw() @@ -366,40 +374,45 @@ void VMediaList::draw() SNPRINTF(title, 398, tr("Media - %s"), dirlist->getCurrent()->getDisplayname()); title[399]=0; setTitleText(title); - View::draw(); + if (loading) { + sl.setVisible(false); + TBBoxx::draw(); drawText(tr("Loading..."), 240, 180, Colour::LIGHTTEXT); } - else { - if (sl.getNumOptions() > 0) sl.draw(); + else + { + //if (sl.getNumOptions() > 0) sl.draw(); + sl.setVisible(true); + TBBoxx::draw(); - // Put the status stuff at the bottom + // Put the status stuff at the bottom - WSymbol w; - w.setSurface(surface); + WSymbol w; + TEMPADD(&w); - w.nextSymbol = WSymbol::UP; - w.setSurfaceOffset(20, 385); - w.draw(); + w.nextSymbol = WSymbol::UP; + w.setPosition(20, 385); + w.draw(); - w.nextSymbol = WSymbol::DOWN; - w.setSurfaceOffset(50, 385); - w.draw(); + w.nextSymbol = WSymbol::DOWN; + w.setPosition(50, 385); + w.draw(); - w.nextSymbol = WSymbol::SKIPBACK; - w.setSurfaceOffset(85, 385); - w.draw(); + w.nextSymbol = WSymbol::SKIPBACK; + w.setPosition(85, 385); + w.draw(); - w.nextSymbol = WSymbol::SKIPFORWARD; - w.setSurfaceOffset(115, 385); - w.draw(); + w.nextSymbol = WSymbol::SKIPFORWARD; + w.setPosition(115, 385); + w.draw(); - w.nextSymbol = WSymbol::PLAY; - w.setSurfaceOffset(150, 385); - w.draw(); + w.nextSymbol = WSymbol::PLAY; + w.setPosition(150, 385); + w.draw(); - doShowingBar(); + doShowingBar(); } } @@ -409,7 +422,7 @@ void VMediaList::doShowingBar() if (sl.getNumOptions() == 0) topOption = 0; char showing[250]; - char * strmode=tr("Name"); + const char* strmode=tr("Name"); switch (sortOrder) { case SORT_TIME: strmode=tr("Rand"); @@ -473,7 +486,7 @@ int VMediaList::handleCommand(int command) sl.hintSetCurrent(0); sl.draw(); doShowingBar(); - ViewMan::getInstance()->updateView(this); + boxstack->update(this); return 2; } case Remote::DF_UP: @@ -483,7 +496,7 @@ int VMediaList::handleCommand(int command) sl.draw(); doShowingBar(); - ViewMan::getInstance()->updateView(this); + boxstack->update(this); return 2; } case Remote::DF_DOWN: @@ -493,7 +506,7 @@ int VMediaList::handleCommand(int command) sl.draw(); doShowingBar(); - ViewMan::getInstance()->updateView(this); + boxstack->update(this); return 2; } case Remote::SKIPBACK: @@ -502,7 +515,7 @@ int VMediaList::handleCommand(int command) sl.draw(); doShowingBar(); - ViewMan::getInstance()->updateView(this); + boxstack->update(this); return 2; } case Remote::SKIPFORWARD: @@ -511,7 +524,7 @@ int VMediaList::handleCommand(int command) sl.draw(); doShowingBar(); - ViewMan::getInstance()->updateView(this); + boxstack->update(this); return 2; } case Remote::BLUE: @@ -519,15 +532,15 @@ int VMediaList::handleCommand(int command) switch(sortOrder) { case SORT_NAME: sortList(SORT_TIME); - ViewMan::getInstance()->updateView(this); + boxstack->update(this); return 2; case SORT_TIME: sortList(SORT_RANDOM); - ViewMan::getInstance()->updateView(this); + boxstack->update(this); return 2; default: sortList(SORT_NAME); - ViewMan::getInstance()->updateView(this); + boxstack->update(this); return 2; } } @@ -580,8 +593,8 @@ int VMediaList::handleCommand(int command) VVideoLive* v = new VVideoLive(mediaList, media->type, this); v->draw(); - ViewMan::getInstance()->add(v); - ViewMan::getInstance()->updateView(v); + boxstack->add(v); + boxstack->updatev); v->medianelChange(VVideoLive::NUMBER, media->number); */ @@ -607,22 +620,22 @@ void VMediaList::processMessage(Message* m) { sl.draw(); doShowingBar(); - ViewMan::getInstance()->updateView(this); + boxstack->update(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 + boxstack->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()) + if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight()) { - ViewMan::getInstance()->handleCommand(Remote::BACK); //simulate cancel press + boxstack->handleCommand(Remote::BACK); //simulate cancel press } } } @@ -632,10 +645,10 @@ int VMediaList::createList() { Log::getInstance()->log("VMediaList::createList", Log::DEBUG, ""); VMediaList *vmn=new VMediaList(); //show the "loading" indicator - ViewMan::getInstance()->add(vmn); + BoxStack::getInstance()->add(vmn); int rt=vmn->load(); if ( rt != 0) { - ViewMan::getInstance()->removeView(vmn); + BoxStack::getInstance()->remove(vmn); } return rt; } @@ -665,7 +678,7 @@ int VMediaList::load() { loading=true; draw(); - ViewMan::getInstance()->updateView(this); + boxstack->update(this); VDR* vdr=VDR::getInstance(); Log::getInstance()->log("VMediaList::load", Log::DEBUG, "load list for %s",dirlist->getPath()); if (vdr->isConnected()) { @@ -674,7 +687,7 @@ int VMediaList::load() { if (mn != NULL) { setList(mn); draw(); - ViewMan::getInstance()->updateView(this); + boxstack->update(this); return 0; } } @@ -683,22 +696,24 @@ int VMediaList::load() { } else { Log::getInstance()->log("VMediaList", Log::ERR, "unable to get MediaList for %s",dirlist->getPath()); + VInfo* vi = new VInfo(); - vi->create(400, 150); + vi->setSize(400, 150); + vi->createBuffer(); vi->setExitable(); vi->setBorderOn(1); vi->setTitleBarOn(0); if (Video::getInstance()->getFormat() == Video::PAL) - vi->setScreenPos(170, 200); + vi->setPosition(170, 200); else - vi->setScreenPos(160, 150); + vi->setPosition(160, 150); vi->setOneLiner(tr("unable to get media list")); vi->draw(); Message* m = new Message(); m->message = Message::ADD_VIEW; - m->to = ViewMan::getInstance(); + m->to = boxstack; m->parameter = (ULONG)vi; Command::getInstance()->postMessageNoLock(m); } @@ -708,3 +723,4 @@ int VMediaList::load() { const char * VMediaList::getDirname() const { return dirlist->getCurrent()->getFullPath(); } + diff --git a/vmedialist.h b/vmedialist.h index ff2b541..6ebbebf 100644 --- a/vmedialist.h +++ b/vmedialist.h @@ -25,20 +25,15 @@ #include #include -#include "view.h" +#include "tbboxx.h" #include "wselectlist.h" -#include "remote.h" -#include "wsymbol.h" -#include "viewman.h" -#include "vdr.h" #include "media.h" -#include "vvideolive.h" -#include "colour.h" -#include "video.h" -#include "i18n.h" class DirList; -class VMediaList : public View +class Message; +class BoxStack; + +class VMediaList : public TBBoxx { public: VMediaList(); @@ -75,6 +70,7 @@ class VMediaList : public View * fill the medialist basing on the current dirname */ int load(); + BoxStack* boxstack; MediaList *mediaList; WSelectList sl; bool loading; diff --git a/vmute.cc b/vmute.cc index 1f13950..ebf8bae 100644 --- a/vmute.cc +++ b/vmute.cc @@ -20,21 +20,29 @@ #include "vmute.h" +#include "remote.h" +#include "audio.h" +#include "video.h" +#include "wsymbol.h" +#include "colour.h" +#include "timers.h" +#include "boxstack.h" +#include "command.h" + VMute::VMute() { isMuted = Audio::getInstance()->toggleUserMute(); - create(40, 40); + setSize(40, 40); + createBuffer(); if (Video::getInstance()->getFormat() == Video::PAL) { - setScreenPos(600, 500); + setPosition(600, 500); } else { - setScreenPos(590, 400); + setPosition(590, 400); } - - setBackgroundColour(Colour::VIEWBACKGROUND); } VMute::~VMute() @@ -45,13 +53,14 @@ VMute::~VMute() void VMute::draw() { - View::draw(); + // draw background? + fillColour(Colour::VIEWBACKGROUND); WSymbol w; - w.setSurface(surface); + TEMPADD(&w); if (isMuted) w.nextSymbol = WSymbol::MUTE; else w.nextSymbol = WSymbol::UNMUTE; - w.setSurfaceOffset(5, 5); + w.setPosition(5, 5); w.draw(); Timers::getInstance()->setTimerD(this, 1, 2); @@ -62,7 +71,7 @@ void VMute::timercall(int clientReference) // delete me! Message* m = new Message(); // Delete self m->message = Message::CLOSE_ME; - m->to = ViewMan::getInstance(); + m->to = BoxStack::getInstance(); m->from = this; Command::getInstance()->postMessageFromOuterSpace(m); } @@ -75,7 +84,7 @@ int VMute::handleCommand(int command) { isMuted = Audio::getInstance()->toggleUserMute(); draw(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); // handled return 2; } diff --git a/vmute.h b/vmute.h index 3709115..ce223a8 100644 --- a/vmute.h +++ b/vmute.h @@ -23,17 +23,10 @@ #include -#include "view.h" -#include "remote.h" -#include "audio.h" -#include "wsymbol.h" -#include "colour.h" -#include "video.h" +#include "boxx.h" #include "timerreceiver.h" -#include "timers.h" -#include "viewman.h" -class VMute : public View, public TimerReceiver +class VMute : public Boxx, public TimerReceiver { public: VMute(); diff --git a/voptions.cc b/voptions.cc deleted file mode 100644 index c264846..0000000 --- a/voptions.cc +++ /dev/null @@ -1,348 +0,0 @@ -/* - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "voptions.h" - -VOptions::VOptions(void* tparent, const char* title, const OPTIONDATA* toptionData, const int tnumOptions) -{ - viewman = ViewMan::getInstance(); - - parent = tparent; - optionData = toptionData; - numOptions = tnumOptions; - - UINT newHeight = 85; - if (numOptions < 4) newHeight += (4 * 30); - else newHeight += (numOptions * 30); - - create(530, newHeight); - - setBackgroundColour(Colour::VIEWBACKGROUND); - setTitleBarOn(1); - setTitleBarColour(Colour::TITLEBARBACKGROUND); - setTitleText(title); - - int fontHeight = surface->getFontHeight(); - - optionBoxes = new WOptionBox[numOptions]; - - UINT i, j; - char* config; - vdr = VDR::getInstance(); - // After setup, save all current indexes - optionsAtStart = new int[numOptions]; - - for (i = 0; i < numOptions; i++) - { - optionBoxes[i].setSurface(surface); - optionBoxes[i].setSurfaceOffset(346, 45 + (i * 30)); - optionBoxes[i].setDimensions(150, fontHeight); - - if (optionData[i].optionType == OPTIONTYPE_TEXT) - { - for (j = 0; j < optionData[i].optionCount; j++) - { - Log::getInstance()->log("Options", Log::DEBUG, "Add option: %s", optionData[i].options[j]); - optionBoxes[i].addOption(tr((char*)optionData[i].options[j])); - } - - // Set the built in default - optionBoxes[i].setSelected(tr((char*)optionData[i].options[optionData[i].defaultOption])); - } - else - { - // int mode - optionBoxes[i].setIntMode(optionData[i].startInt, optionData[i].optionCount); - optionBoxes[i].setSelected(optionData[i].defaultOption); - } - - // Now see if there is a config option for it - config = vdr->configLoad(optionData[i].configSection, optionData[i].configParam); - if (config) - { - if (optionData[i].optionType == OPTIONTYPE_TEXT) - { - for (j = 0; j < optionData[i].optionCount; j++) - { - if (!STRCASECMP(config, optionData[i].options[j])) - { - optionBoxes[i].setSelected(tr((char*)optionData[i].options[j])); - } - } - } - else - { - optionBoxes[i].setSelected(atoi(config)); - } - delete[] config; - } - - // After setup, save initial option - optionsAtStart[i] = optionBoxes[i].getSelectedIndex(); - } - - selectedOption = numOptions; - //optionBoxes[0].setActive(1); - - int voff = 0; - if ((numOptions < 8) && (numOptions >= 4)) - { - voff = (8 - numOptions) * 10; - } - else if (numOptions < 4) - { - voff = 40; //(4 * 10) - } - - if (Video::getInstance()->getFormat() == Video::PAL) - { - setScreenPos(104, 130 + voff); - } - else - { - setScreenPos(94, 70 + voff); - } - - if (!vdr->isConnected()) Command::getInstance()->connectionLost(); -} - -VOptions::~VOptions() -{ - delete[] optionsAtStart; - delete[] optionBoxes; -} - -void VOptions::draw() -{ - View::draw(); - - WSymbol wsy; - Colour cl; - - drawText(tr("Press back to exit, <, > or [ok] to change"), 10, area.h - 30, Colour::LIGHTTEXT); - - wsy.setSurface(surface); - UINT ystart=titleBarOn ? 45 : 15; - - for (UINT i = 0; i < numOptions; i++) - { - drawText(tr(optionData[i].title), 10, ystart + i*30, Colour::LIGHTTEXT); - - if (i == selectedOption) cl = Colour::SELECTHIGHLIGHT; - else cl = Colour::BUTTONBACKGROUND; - - wsy.nextSymbol = WSymbol::LEFTARROW; - wsy.nextColour = cl; - - wsy.setSurfaceOffset(328, ystart + 2 + (i * 30)); - wsy.draw(); - wsy.nextSymbol = WSymbol::RIGHTARROW; - wsy.setSurfaceOffset(498, ystart + 2 + (i * 30)); - wsy.draw(); - optionBoxes[i].setSurfaceOffset(346, ystart + (i * 30)); - optionBoxes[i].draw(); - } -} - -int VOptions::handleCommand(int command) -{ - switch(command) - { - case Remote::DF_UP: - case Remote::UP: - { - if (selectedOption > 0) - { - if (selectedOption < numOptions) optionBoxes[selectedOption].setActive(0); - --selectedOption; - optionBoxes[selectedOption].setActive(1); - draw(); - viewman->updateView(this); - } - else - { - if (selectedOption < numOptions) optionBoxes[selectedOption].setActive(0); - selectedOption = numOptions; - return 0; //Control to tab view - } - return 2; - } - case Remote::DF_DOWN: - case Remote::DOWN: - { - if (selectedOption < (numOptions - 1)) - { - if (selectedOption < numOptions) optionBoxes[selectedOption].setActive(0); - ++selectedOption; - optionBoxes[selectedOption].setActive(1); - draw(); - viewman->updateView(this); - } - else if (selectedOption == numOptions) - { - selectedOption = 0; - optionBoxes[selectedOption].setActive(1); - draw(); - viewman->updateView(this); - } - return 2; - } - case Remote::DF_LEFT: - case Remote::LEFT: - { - if (selectedOption == numOptions) return 2; - optionBoxes[selectedOption].left(); - draw(); - viewman->updateView(this); - return 2; - } - case Remote::DF_RIGHT: - case Remote::RIGHT: - { - if (selectedOption == numOptions) return 2; - optionBoxes[selectedOption].right(); - draw(); - 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::OK: - { - if (selectedOption == numOptions) return 2; - optionBoxes[selectedOption].cycle(); - draw(); - viewman->updateView(this); - } - } - - return 1; -} - -void VOptions::doSave() -{ - UINT i; - int* result = new int[numOptions]; - - for (i = 0; i < numOptions; i++) - { - result[i] = optionBoxes[i].getSelectedIndex(); - - if (result[i] != optionsAtStart[i]) - { - Log::getInstance()->log("Options", Log::DEBUG, "Option %i has changed", i); - - if (optionData[i].optionType == OPTIONTYPE_TEXT) - { - vdr->configSave(optionData[i].configSection, optionData[i].configParam, - optionData[i].options[result[i]]); - } - else - { - char buffer[20]; - sprintf(buffer, "%i", result[i]); - vdr->configSave(optionData[i].configSection, optionData[i].configParam, - buffer); - } - } - } - - // Save a vector of option IDs that have changed - - map* optionChanges = new map; - - for (i = 0; i < numOptions; i++) - { - if (result[i] != optionsAtStart[i]) - { - (*optionChanges)[optionData[i].id] = result[i]; - } - } - - delete[] result; - - // Send it to parent for changes to be applied - Message* m = new Message(); - m->message = Message::CHANGED_OPTIONS; - m->to = parent; - m->parameter = (ULONG)optionChanges; - Command::getInstance()->postMessageNoLock(m); -} - -void VOptions::processMessage(Message* m) -{ - if (m->message == Message::MOUSE_MOVE) - { - int x=(m->parameter>>16)-getScreenX(); - int y=(m->parameter&0xFFFF)-getScreenY(); - UINT i; - for (i = 0; i < numOptions; i++) - { - if (optionBoxes[i].mouseMove(x,y)) - { - if (selectedOption != numOptions) optionBoxes[selectedOption].setActive(0); - optionBoxes[i].setActive(1); - selectedOption=i; - draw(); - viewman->updateView(this); - break; - } - } - } - else if (m->message == Message::MOUSE_LBDOWN) - { - int x=(m->parameter>>16)-getScreenX(); - int y=(m->parameter&0xFFFF)-getScreenY(); - UINT i; - bool butpress=false; - for (i = 0; i < numOptions; i++) - { - if (optionBoxes[i].mouseLBDOWN(x,y)) - { - ViewMan::getInstance()->handleCommand(Remote::OK); //simulate OK press - butpress=true; - break; - } - } - if (!butpress) - { - //check if press is outside this view! then simulate cancel - if (x<0 || y <0 || x>getWidth() || y>getHeight()) - { - ViewMan::getInstance()->handleCommand(Remote::BACK); //simulate cancel press - } - } - } -} diff --git a/voptions.h b/voptions.h deleted file mode 100644 index ea6684e..0000000 --- a/voptions.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef VOPTIONS_H -#define VOPTIONS_H - -#include -#include "defines.h" -#include "view.h" -#include "viewman.h" -#include "vdr.h" -#include "colour.h" -#include "video.h" -#include "woptionbox.h" -#include "wsymbol.h" -#include "i18n.h" -#include "command.h" - -typedef struct -{ - UINT id; // Used for working out what has changed at the end - char *title; // Name of the option - char *configSection; // Which section of the config file - char *configParam; // Parameter name in the config file - UINT optionType; // 1 for text, 2 for int - UINT optionCount; // How many choices? - UINT defaultOption; // Serial of the default choice (base 0), or actual option in int mode - int startInt; // Starting int for int mode - const char * const * options; // Text for the options (null for int mode) -} OPTIONDATA; - -class VOptions : public View -{ - public: - VOptions(void* tparent, const char* title, const OPTIONDATA* toptionData, const int tnumOptions); - ~VOptions(); - - int handleCommand(int command); - void processMessage(Message* m); - void draw(); - - private: - void doSave(); - - const OPTIONDATA* optionData; - UINT numOptions; - UINT selectedOption; - WOptionBox* optionBoxes; - VDR* vdr; - int* optionsAtStart; - void* parent; -}; - -#endif - diff --git a/voptionsmenu.cc b/voptionsmenu.cc deleted file mode 100644 index ee7ef78..0000000 --- a/voptionsmenu.cc +++ /dev/null @@ -1,258 +0,0 @@ -/* - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "voptionsmenu.h" - -VOptionsMenu::VOptionsMenu() -{ - viewman = ViewMan::getInstance(); - - setBackgroundColour(Colour::VIEWBACKGROUND); - setTitleBarOn(1); - setTitleBarColour(Colour::TITLEBARBACKGROUND); - setTitleText(tr("Options")); - -// int fontHeight = surface->getFontHeight(); - - doGeneral(); - doRemoteConfig(); - doTimers(); - doAdvanced(); - - create(); - draw(); -} - -VOptionsMenu::~VOptionsMenu() -{ -} - -void VOptionsMenu::draw() -{ - VTabsViewMan::draw(); -} - -int VOptionsMenu::handleCommand(int command) -{ - return VTabsViewMan::handleCommand(command); -} - -void VOptionsMenu::processMessage(Message* m) -{ - if (m->message == Message::CHANGED_OPTIONS) - { - doApplyChanges((map*)m->parameter); - //viewman->removeView(this); - - if (!VDR::getInstance()->isConnected()) Command::getInstance()->connectionLost(); - } - else if (m->message == Message::CHANGED_REMOTECONTROL) - { - char* remote = Remote::getInstance()->SaveKeysConfig(); //FIXME - VDR::getInstance()->configSave("General","Remote keys",remote); - delete[] remote; - } - else - { - VTabsViewMan::processMessage(m); - } -} - -void VOptionsMenu::doApplyChanges(map* changedOptions) -{ - Video* video = Video::getInstance(); - map::iterator i; - - for(i = changedOptions->begin(); i != changedOptions->end(); i++) - { -// printf("I FIRST = %i SECOND = %i\n", i->first, i->second); - - switch(i->first) - { - case 1: - { - if (i->second == 1) - { - Log::getInstance()->log("Options", Log::DEBUG, "Setting New Remote"); - Remote::getInstance()->setRemoteType(Remote::NEWREMOTE); - } - else - { - Log::getInstance()->log("Options", Log::DEBUG, "Setting Old Remote"); - Remote::getInstance()->setRemoteType(Remote::OLDREMOTE); - } - break; - } - case 2: - { - Message* m = new Message(); - m->message = Message::CHANGE_LANGUAGE; - m->to = Command::getInstance(); - Command::getInstance()->postMessageNoLock(m); - break; - } - case 3: - { - if (i->second == 1) - { - Log::getInstance()->log("Options", Log::DEBUG, "Setting S-Video"); - video->setConnection(Video::SVIDEO); - } - else - { - Log::getInstance()->log("Options", Log::DEBUG, "Setting RGB/Composite"); - video->setConnection(Video::COMPOSITERGB); - } - break; - } - case 4: - { - if (i->second == 1) - { - Log::getInstance()->log("Options", Log::DEBUG, "Setting 16:9 TV"); - video->setTVsize(Video::ASPECT16X9); - } - else - { - Log::getInstance()->log("Options", Log::DEBUG, "Setting 4:3 TV"); - video->setTVsize(Video::ASPECT4X3); - } - break; - } - case 5: - { - if (i->second == 1) - { - Log::getInstance()->log("Options", Log::DEBUG, "Setting letterbox"); - video->setMode(Video::LETTERBOX); - } - else - { - Log::getInstance()->log("Options", Log::DEBUG, "Setting chop-sides"); - video->setMode(Video::NORMAL); - } - break; - } - case 13: - { - size_t newTCPsize = 2048; - - if (i->second == 0) newTCPsize = 1024; - else if (i->second == 1) newTCPsize = 2048; - else if (i->second == 2) newTCPsize = 4096; - else if (i->second == 3) newTCPsize = 8192; - else if (i->second == 4) newTCPsize = 16384; - else if (i->second == 5) newTCPsize = 32768; - else if (i->second == 6) newTCPsize = 65536; - - Log::getInstance()->log("Options", Log::DEBUG, "Setting TCP window size %i", newTCPsize); - VDR::getInstance()->setReceiveWindow(newTCPsize); - break; - } - } - } - - delete changedOptions; - -} - -void VOptionsMenu::doGeneral() -{ - static const int numOptions = 8; - - static const char* options1[] = {"Old", "New"}; - static const char* options3[] = {"RGB+composite", "S-Video"}; - static const char* options4[] = {"4:3", "16:9"}; - static const char* options5[] = {"Chop sides", "Letterbox"}; - static const char* options6[] = {"On", "Off", "Last state"}; - static const char* options7[] = {"All", "FTA only"}; - static const char* options15[] = {"Alphabetical", "Chronological"}; - - const static OPTIONDATA optionData[numOptions] = - { - {1, "Remote control type", "General", "Remote type", OPTIONTYPE_TEXT, 2, 0, 0, options1 }, - {2, "Language", "General", "Language", OPTIONTYPE_TEXT, I18n::NumLanguages, 0, 0, I18n::Languages }, - {3, "TV connection type", "TV", "Connection", OPTIONTYPE_TEXT, 2, 0, 0, options3 }, - {4, "TV aspect ratio", "TV", "Aspect", OPTIONTYPE_TEXT, 2, 0, 0, options4 }, - {5, "16:9 on 4:3 display mode", "TV", "Widemode", OPTIONTYPE_TEXT, 2, 0, 0, options5 }, - {6, "Power state after bootup", "General", "Power After Boot", OPTIONTYPE_TEXT, 3, 0, 0, options6 }, - {7, "Display channels", "General", "Channels", OPTIONTYPE_TEXT, 2, 0, 0, options7 }, - {15, "Recordings sort order", "General", "Recordings Sort Order", OPTIONTYPE_TEXT, 2, 0, 0, options15 }, - }; - - // As all the above data is const static, it can be sent to the new View, this stack frame can - // quit and the pointers will all still be valid. I think. (Hope). - - VOptions* v = new VOptions(this, tr("General"), optionData, numOptions); - v->draw(); - add(v); - //viewman->updateView(v); -} - -void VOptionsMenu::doRemoteConfig() -{ - VRemoteConfig* v = new VRemoteConfig(this); - v->draw(); - add(v); -} - -void VOptionsMenu::doTimers() -{ - static const int numOptions = 4; - - const static OPTIONDATA optionData[numOptions] = - { - {9, "Default start margin (minutes)", "Timers", "Start margin", OPTIONTYPE_INT, 20, 5, 0, NULL }, - {10, "Default end margin (minutes)", "Timers", "End margin", OPTIONTYPE_INT, 20, 5, 0, NULL }, - {11, "Default priority", "Timers", "Priority", OPTIONTYPE_INT, 100, 99, 0, NULL }, - {12, "Default lifetime", "Timers", "Lifetime", OPTIONTYPE_INT, 100, 99, 0, NULL }, - }; - - // As all the above data is const static, it can be sent to the new View, this stack frame can - // quit and the pointers will all still be valid. I think. (Hope). - - VOptions* v = new VOptions(this, tr("Timers"), optionData, numOptions); - v->draw(); - add(v); - //viewman->updateView(v); -} - -void VOptionsMenu::doAdvanced() -{ - static const int numOptions = 3; - - static const char* options13[] = {"1024", "2048", "4096", "8192", "16384", "32768", "65536"}; - static const char* options14[] = {"No", "Yes"}; - - const static OPTIONDATA optionData[numOptions] = - { - {8, "VDR-Pri 0=OK !See forums!", "General", "Live priority", OPTIONTYPE_INT, 100, 0, 0, NULL }, - {13, "TCP receive window size", "Advanced", "TCP receive window", OPTIONTYPE_TEXT, 7, 1, 0, options13 }, - {14, "Use WSS (PAL only)", "General", "WSS", OPTIONTYPE_TEXT, 2, 0, 0, options14 } - }; - - // As all the above data is const static, it can be sent to the new View, this stack frame can - // quit and the pointers will all still be valid. I think. (Hope). - - VOptions* v = new VOptions(this, tr("Advanced"), optionData, numOptions); - v->draw(); - add(v); - //viewman->updateView(v); -} diff --git a/voptionsmenu.h b/voptionsmenu.h deleted file mode 100644 index 9f07582..0000000 --- a/voptionsmenu.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef VOPTIONSMENU_H -#define VOPTIONSMENU_H - -#include -#include -#include "view.h" -#include "remote.h" -#include "viewman.h" -#include "vdr.h" -#include "colour.h" -#include "video.h" -#include "wbutton.h" -#include "i18n.h" -#include "voptions.h" -#include "vremoteconfig.h" -#include "vtabsviewman.h" - -class VOptionsMenu : public VTabsViewMan -{ - public: - VOptionsMenu(); - ~VOptionsMenu(); - - int handleCommand(int command); - void processMessage(Message* m); - void draw(); - - private: - void doGeneral(); - void doTimers(); - void doAdvanced(); - void doRemoteConfig(); - void doApplyChanges(map* changedOptions); - - vector buttons; - vector::iterator selectedButton; -}; - -#endif diff --git a/vopts.cc b/vopts.cc new file mode 100644 index 0000000..76a237c --- /dev/null +++ b/vopts.cc @@ -0,0 +1,293 @@ +/* + Copyright 2007 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "vopts.h" + +#include "colour.h" +#include "video.h" +#include "i18n.h" +#include "remote.h" +#include "boxstack.h" +#include "woptionpane.h" +#include "wremoteconfig.h" +#include "log.h" +#include "option.h" +#include "vdr.h" +#include "command.h" + +//#include "vdr.h" +//#include "command.h" + +VOpts::VOpts() +{ + setTitleBarOn(1); + setTitleBarColour(Colour::TITLEBARBACKGROUND); + setTitleText(tr("Options")); + + setSize(520, 360); + createBuffer(); + if (Video::getInstance()->getFormat() == Video::PAL) + setPosition(100, 110); + else + setPosition(90, 90); + + tabbar.setPosition(6, 32); + tabbar.setSize(getWidth() - 12, getHeight() - 34); + add(&tabbar); + + Option* option; + WOptionPane* wop; + + // --- edit options start here + + static const char* options1[] = {"Old", "New"}; + static const char* options3[] = {"RGB+composite", "S-Video"}; + static const char* options4[] = {"4:3", "16:9"}; + static const char* options5[] = {"Chop sides", "Letterbox"}; + static const char* options6[] = {"On", "Off", "Last state"}; + static const char* options7[] = {"All", "FTA only"}; + static const char* options15[] = {"Alphabetical", "Chronological"}; + + static const char* options13[] = {"1024", "2048", "4096", "8192", "16384", "32768", "65536"}; + static const char* options14[] = {"No", "Yes"}; + + numPanes = 4; + panes = new Boxx*[numPanes]; + + wop = new WOptionPane(); + tabbar.addTab(tr("General"), wop); + panes[0] = wop; + + option = new Option(1, "Remote control type", "General", "Remote type", Option::TYPE_TEXT, 2, 0, 0, options1); + options.push_back(option); + wop->addOptionLine(option); + option = new Option(2, "Language", "General", "Language", Option::TYPE_TEXT, I18n::NumLanguages, 0, 0, I18n::Languages); + options.push_back(option); + wop->addOptionLine(option); + option = new Option(3, "TV connection type", "TV", "Connection", Option::TYPE_TEXT, 2, 0, 0, options3); + options.push_back(option); + wop->addOptionLine(option); + option = new Option(4, "TV aspect ratio", "TV", "Aspect", Option::TYPE_TEXT, 2, 0, 0, options4); + options.push_back(option); + wop->addOptionLine(option); + option = new Option(5, "16:9 on 4:3 display mode", "TV", "Widemode", Option::TYPE_TEXT, 2, 0, 0, options5); + options.push_back(option); + wop->addOptionLine(option); + option = new Option(6, "Power state after bootup", "General", "Power After Boot", Option::TYPE_TEXT, 3, 0, 0, options6); + options.push_back(option); + wop->addOptionLine(option); + option = new Option(7, "Display channels", "General", "Channels", Option::TYPE_TEXT, 2, 0, 0, options7); + options.push_back(option); + wop->addOptionLine(option); + option = new Option(15, "Recordings sort order", "General", "Recordings Sort Order", Option::TYPE_TEXT, 2, 0, 0, options15); + options.push_back(option); + wop->addOptionLine(option); + + + WRemoteConfig* wrc = new WRemoteConfig(); + tabbar.addTab(tr("Remote Control"), wrc); + panes[1] = wrc; + + + wop = new WOptionPane(); + tabbar.addTab(tr("Timers"), wop); + panes[2] = wop; + + option = new Option(9, "Default start margin (minutes)", "Timers", "Start margin", Option::TYPE_INT, 20, 5, 0, NULL); + options.push_back(option); + wop->addOptionLine(option); + option = new Option(10, "Default end margin (minutes)", "Timers", "End margin", Option::TYPE_INT, 20, 5, 0, NULL); + options.push_back(option); + wop->addOptionLine(option); + option = new Option(11, "Default priority", "Timers", "Priority", Option::TYPE_INT, 100, 99, 0, NULL); + options.push_back(option); + wop->addOptionLine(option); + option = new Option(12, "Default lifetime", "Timers", "Lifetime", Option::TYPE_INT, 100, 99, 0, NULL); + options.push_back(option); + wop->addOptionLine(option); + + + wop = new WOptionPane(); + tabbar.addTab(tr("Advanced"), wop); + panes[3] = wop; + + option = new Option(8, "VDR-Pri 0=OK !See forums!", "General", "Live priority", Option::TYPE_INT, 100, 0, 0, NULL); + options.push_back(option); + wop->addOptionLine(option); + option = new Option(13, "TCP receive window size", "Advanced", "TCP receive window", Option::TYPE_TEXT, 7, 1, 0, options13); + options.push_back(option); + wop->addOptionLine(option); + option = new Option(14, "Use WSS (PAL only)", "General", "WSS", Option::TYPE_TEXT, 2, 0, 0, options14); + options.push_back(option); + wop->addOptionLine(option); +} + +VOpts::~VOpts() +{ + for (int i = 0; i < numPanes; i++) delete panes[i]; + delete[] panes; + + for(vector::iterator j = options.begin(); j != options.end(); j++) delete *j; +} + +int VOpts::handleCommand(int command) +{ + // either is active, handle back + if (command == Remote::BACK) + { + doSave(); + return 4; + } + else + { + int retval = tabbar.handleCommand(command); + if (retval == 1) + { + BoxStack::getInstance()->update(this); + return 2; + } + else + { + return 1; // ??? + } + } +} + +void VOpts::doSave() +{ + VDR* vdr = VDR::getInstance(); + + // Damn, and the dynamic idea was going *so* well... + WOptionPane* wop; + wop = (WOptionPane*)panes[0]; + wop->saveOpts(); + wop = (WOptionPane*)panes[2]; + wop->saveOpts(); + wop = (WOptionPane*)panes[3]; + wop->saveOpts(); + + + for (UINT i = 0; i < options.size(); i++) + { + if (options[i]->configChoice == options[i]->userSetChoice) continue; // no change + + Log::getInstance()->log("Options", Log::DEBUG, "Option %i has changed", i); + + // Save to vdr + + if (options[i]->optionType == Option::TYPE_TEXT) + { + vdr->configSave(options[i]->configSection, options[i]->configKey, options[i]->options[options[i]->userSetChoice]); + } + else + { + char buffer[20]; + sprintf(buffer, "%i", options[i]->userSetChoice); + vdr->configSave(options[i]->configSection, options[i]->configKey, buffer); + } + + // Set new setting + + switch(options[i]->id) + { + case 1: + { + if (options[i]->userSetChoice == 1) + { + Log::getInstance()->log("Options", Log::DEBUG, "Setting New Remote"); + Remote::getInstance()->setRemoteType(Remote::NEWREMOTE); + } + else + { + Log::getInstance()->log("Options", Log::DEBUG, "Setting Old Remote"); + Remote::getInstance()->setRemoteType(Remote::OLDREMOTE); + } + break; + } + case 2: + { + Message* m = new Message(); + m->message = Message::CHANGE_LANGUAGE; + m->to = Command::getInstance(); + Command::getInstance()->postMessageNoLock(m); + break; + } + case 3: + { + if (options[i]->userSetChoice == 1) + { + Log::getInstance()->log("Options", Log::DEBUG, "Setting S-Video"); + Video::getInstance()->setConnection(Video::SVIDEO); + } + else + { + Log::getInstance()->log("Options", Log::DEBUG, "Setting RGB/Composite"); + Video::getInstance()->setConnection(Video::COMPOSITERGB); + } + break; + } + case 4: + { + if (options[i]->userSetChoice == 1) + { + Log::getInstance()->log("Options", Log::DEBUG, "Setting 16:9 TV"); + Video::getInstance()->setTVsize(Video::ASPECT16X9); + } + else + { + Log::getInstance()->log("Options", Log::DEBUG, "Setting 4:3 TV"); + Video::getInstance()->setTVsize(Video::ASPECT4X3); + } + break; + } + case 5: + { + if (options[i]->userSetChoice == 1) + { + Log::getInstance()->log("Options", Log::DEBUG, "Setting letterbox"); + Video::getInstance()->setMode(Video::LETTERBOX); + } + else + { + Log::getInstance()->log("Options", Log::DEBUG, "Setting chop-sides"); + Video::getInstance()->setMode(Video::NORMAL); + } + break; + } + case 13: + { + size_t newTCPsize = 2048; + + if (options[i]->userSetChoice == 0) newTCPsize = 1024; + else if (options[i]->userSetChoice == 1) newTCPsize = 2048; + else if (options[i]->userSetChoice == 2) newTCPsize = 4096; + else if (options[i]->userSetChoice == 3) newTCPsize = 8192; + else if (options[i]->userSetChoice == 4) newTCPsize = 16384; + else if (options[i]->userSetChoice == 5) newTCPsize = 32768; + else if (options[i]->userSetChoice == 6) newTCPsize = 65536; + + Log::getInstance()->log("Options", Log::DEBUG, "Setting TCP window size %i", newTCPsize); + VDR::getInstance()->setReceiveWindow(newTCPsize); + break; + } + } + } +} + diff --git a/vwallpaper.h b/vopts.h similarity index 66% rename from vwallpaper.h rename to vopts.h index 721c73a..e9cfaef 100644 --- a/vwallpaper.h +++ b/vopts.h @@ -1,5 +1,5 @@ /* - Copyright 2004-2005 Chris Tallon + Copyright 2007 Chris Tallon This file is part of VOMP. @@ -18,32 +18,36 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef VWALLPAPER_H -#define VWALLPAPER_H +#ifndef VOPTS_H +#define VOPTS_H -#include -#include +#include +#include "tbboxx.h" +#include "defines.h" +#include "wtabbar.h" -#include "view.h" -#include "wjpeg.h" +class Boxx; +class Option; -#include "osd.h" -#include "surface.h" -#include "video.h" - -class VWallpaper : public View +class VOpts : public TBBoxx { public: - VWallpaper(); - ~VWallpaper(); - - void init(char* file); - - void draw(); - + VOpts(); + ~VOpts(); + + int handleCommand(int command); + private: - Surface* wallpaperSurface; - WJpeg jpeg; + void doSave(); + + WTabBar tabbar; + + int numPanes; + Boxx** panes; + + vector options; + }; #endif + diff --git a/vpicture.cc b/vpicture.cc index 139d587..25badaa 100644 --- a/vpicture.cc +++ b/vpicture.cc @@ -18,9 +18,25 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include + #include "vpicture.h" + #include "vpicturebanner.h" -#include +#include "timers.h" +#include "boxx.h" +#include "wselectlist.h" +#include "remote.h" +#include "wsymbol.h" +#include "boxstack.h" +#include "vdr.h" +#include "media.h" +#include "vvideolive.h" +#include "video.h" +#include "vinfo.h" +#include "i18n.h" +#include "message.h" +#include "command.h" Colour VPicture::pictureBack=Colour(140,140,140); Colour VPicture::infoBack=Colour(110,110,110); @@ -56,7 +72,8 @@ VPicture::VPicture(VMediaList *p) reader=new VPreader(this); needDraw=false; Video* video = Video::getInstance(); - create(video->getScreenWidth(), video->getScreenHeight()); + setSize(video->getScreenWidth(), video->getScreenHeight()); + createBuffer(); jpeg.setSurface(surface); jpeg.setDimensions(area.w,area.h); banner=NULL; @@ -71,12 +88,13 @@ VPicture::VPicture(VMediaList *p) rotate=0; info=NULL; jpeg.setBackgroundColour(pictureBack); + add(&jpeg); } VPicture::~VPicture() { delete reader; - if (banner) ViewMan::getInstance()->removeView(banner); + if (banner) BoxStack::getInstance()->remove(banner); if (fullname) delete fullname; if (filename) delete filename; Timers::getInstance()->cancelTimer(this,1); @@ -90,7 +108,7 @@ void VPicture::draw() { Log::getInstance()->log("VPicture::draw", Log::DEBUG, "needDraw=%d,p=%p", needDraw,this); - View::draw(); +// View::draw(); if (mediaError) { drawText(mediaError,20,area.h-10,Colour::LIGHTTEXT); return; @@ -111,7 +129,7 @@ int VPicture::handleCommand(int command) case Remote::UP: case Remote::SKIPBACK: showPicture(VMediaList::MV_PREV); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); rt= 2; break; case Remote::FORWARD: @@ -122,7 +140,7 @@ int VPicture::handleCommand(int command) case Remote::DOWN: case Remote::SKIPFORWARD: showPicture(VMediaList::MV_NEXT); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); rt= 2; break; case Remote::REVERSE: @@ -143,7 +161,7 @@ int VPicture::handleCommand(int command) { slideshow=true; showPicture(VMediaList::MV_NEXT); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); rt= 2; } break; @@ -174,7 +192,7 @@ int VPicture::handleCommand(int command) break; } showPicture(VMediaList::MV_NONE,rotate); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); rt=2; break; case Remote::GREEN: @@ -205,9 +223,9 @@ void VPicture::processMessage(Message* m) //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()) + if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight()) { - ViewMan::getInstance()->handleCommand(Remote::BACK); //simulate cancel press + BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press } } } @@ -216,12 +234,12 @@ VPicture * VPicture::createViewer(VMediaList * mparent, bool bslideshow) { Log::getInstance()->log("VPicture::createViewer", Log::DEBUG, "p=%p", mparent); VPicture *vmn=new VPicture(mparent); - ViewMan::getInstance()->add(vmn); - ViewMan::getInstance()->updateView(vmn); + BoxStack::getInstance()->add(vmn); + BoxStack::getInstance()->update(vmn); vmn->showPicture(); if (bslideshow) vmn->startSlideshow(); vmn->showBanner(); - ViewMan::getInstance()->updateView(vmn); + BoxStack::getInstance()->update(vmn); return vmn; } @@ -236,7 +254,7 @@ void VPicture::showPicture(ULONG move, int rt) { load(currentMedia); if (mediaError || jpeg.hasError()) destroyInfo(); else updateInfo(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); } @@ -296,7 +314,7 @@ void VPicture::showBanner(bool loading,int shortDisplay) { } if (banner) destroyBanner(!loading); banner= new VPictureBanner(this, loading, slideshow); - banner->setBackgroundColour(infoBack); + banner->fillColour(infoBack); if (! loading) { int len=strlen(filename)+Media::TIMEBUFLEN+20; char buf[len]; @@ -317,10 +335,10 @@ void VPicture::showBanner(bool loading,int shortDisplay) { if (! slideshow && shortDisplay == 0) shortDisplay=8; //OK we start timer if we don't load and either shortDisplay or no slideshow if (! loading && shortDisplay != 0) Timers::getInstance()->setTimerD(this,2,shortDisplay); - if (! loading) sendViewMsg(banner,false); + if (! loading) ; /*sendViewMsg(banner,false); upgrade to boxx */ else { - ViewMan::getInstance()->add(banner); - ViewMan::getInstance()->updateView(banner); + BoxStack::getInstance()->add(banner); + BoxStack::getInstance()->update(banner); } } @@ -328,8 +346,8 @@ void VPicture::showBanner(bool loading,int shortDisplay) { void VPicture::destroyBanner(bool fromTimer) { shortBanner=false; if (banner) { - if (fromTimer) sendViewMsg(banner,true); - else ViewMan::getInstance()->removeView(banner); + if (fromTimer) ;/* sendViewMsg(banner,true); upgrade to boxx*/ + else BoxStack::getInstance()->remove(banner); banner=NULL; if (! fromTimer) Timers::getInstance()->cancelTimer(this,2); } @@ -364,17 +382,19 @@ void VPicture::timercall(int clientref) { void VPicture::showInfo(){ if (info) destroyInfo(); if (! currentMedia) return; + info=new VInfo(); info->setTitleText(currentMedia->getFileName()); info->setDropThrough(); - info->create(500, 300); + info->setSize(500, 300); + info->createBuffer(); info->setBorderOn(1); info->setTitleBarOn(1); if (Video::getInstance()->getFormat() == Video::PAL) - info->setScreenPos(100, 180); + info->setPosition(100, 180); else - info->setScreenPos(100, 150); + info->setPosition(100, 150); char buf[INFOBUF]; char tbuf[Media::TIMEBUFLEN]; snprintf(buf,INFOBUF,"%s= %s\n%s= %ld x %ld\n%s= %ld kBytes\n%s= %s\n%s= %ld\n%s= 1/%ld", @@ -402,10 +422,10 @@ void VPicture::destroyInfo(bool fromTimer){ if (! fromTimer) Timers::getInstance()->cancelTimer(this,3); } -void VPicture::sendViewMsg(View *v,bool vdestroy) { +void VPicture::sendViewMsg(Boxx *v,bool vdestroy) { Message* m = new Message(); m->message = vdestroy?Message::CLOSE_ME:Message::ADD_VIEW; - m->to = ViewMan::getInstance(); + m->to = BoxStack::getInstance(); m->from = v; m->parameter=(ULONG)v; Command::getInstance()->postMessageFromOuterSpace(m); diff --git a/vpicture.h b/vpicture.h index 3c8eaa0..df997d2 100644 --- a/vpicture.h +++ b/vpicture.h @@ -25,21 +25,15 @@ #include #include -#include "view.h" -#include "wselectlist.h" -#include "remote.h" -#include "wsymbol.h" -#include "viewman.h" -#include "vdr.h" -#include "media.h" -#include "vvideolive.h" -#include "colour.h" -#include "video.h" -#include "vinfo.h" -#include "i18n.h" +#include "boxx.h" +#include "timerreceiver.h" #include "vmedialist.h" +#include "colour.h" #include "wjpeg.h" +class Message; +class VInfo; + /** * the picture viewer * will ineract with the parent List for ff,back, slide show... @@ -47,7 +41,7 @@ */ class VPictureBanner; -class VPicture : public View,public TimerReceiver +class VPicture : public Boxx, public TimerReceiver { public: ~VPicture(); @@ -76,7 +70,7 @@ class VPicture : public View,public TimerReceiver void updateInfo(); void destroyInfo(bool fromTimer=false); //add or destroy a view (banner, info) - void sendViewMsg(View *v,bool destroy=false); + void sendViewMsg(Boxx *v,bool destroy=false); //send command in main thread void sendCommandMsg(int command); VMediaList *parent; @@ -90,7 +84,7 @@ class VPicture : public View,public TimerReceiver ULONG ftime; bool slideshow; int showtime; - char * mediaError; + const char * mediaError; Media * currentMedia; const static int INITIAL_SHOWTIME=5; bool shortBanner; diff --git a/vpicturebanner.cc b/vpicturebanner.cc index 13abc08..85c4015 100644 --- a/vpicturebanner.cc +++ b/vpicturebanner.cc @@ -19,8 +19,15 @@ */ #include "vpicturebanner.h" -#include "vpicture.h" +#include "vpicture.h" +#include "wsymbol.h" +#include "remote.h" +#include "colour.h" +#include "video.h" +#include "vinfo.h" +#include "boxstack.h" +#include "i18n.h" VPictureBanner::VPictureBanner(VPicture *p, bool ld, bool sl) { @@ -28,9 +35,9 @@ VPictureBanner::VPictureBanner(VPicture *p, bool ld, bool sl) slideshow=sl; parent=p; Video *v=Video::getInstance(); - create(v->getScreenWidth()-100, 36); - setScreenPos(50, v->getScreenHeight()-50); - setBackgroundColour(Colour::VIEWBACKGROUND); + setSize(v->getScreenWidth()-100, 36); + createBuffer(); + setPosition(50, v->getScreenHeight()-50); setTitleBarOn(0); info=NULL; Log::getInstance()->log("VPictureBanner",Log::DEBUG,"created %p",this); @@ -48,7 +55,7 @@ VPictureBanner::~VPictureBanner() void VPictureBanner::draw() { - View::draw(); +// View::draw(); if (loading) { if (info) { char buf[strlen(info)+100]; @@ -68,14 +75,14 @@ void VPictureBanner::draw() drawText(tr("info"), 5+18+3+rotsize+3+18+3, area.h - 25, Colour::LIGHTTEXT); x+=infsize+3; WSymbol w; - w.setSurface(surface); + TEMPADD(&w); if (slideshow) { w.nextSymbol = WSymbol::PAUSE; } else { w.nextSymbol = WSymbol::PLAY; } - w.setSurfaceOffset(x, area.h-24); + w.setPosition(x, area.h-24); w.draw(); x+=20+3; if (info) { @@ -96,27 +103,27 @@ void VPictureBanner::processMessage(Message* m) { if (m->message == Message::MOUSE_MOVE) { - ; + } else if (m->message == Message::MOUSE_LBDOWN) { //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()) + if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight()) { - ViewMan::getInstance()->handleCommand(Remote::BACK); //simulate cancel press + BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press } else if (y>=(int)area.h-24 && y<=(int)area.h-6) { //y coordinate is right! if (x>=7 &&x<=25) { - ViewMan::getInstance()->handleCommand(Remote::RED); //simulate red press + BoxStack::getInstance()->handleCommand(Remote::RED); //simulate red press } else if (x>=110 &&x<=128) { - ViewMan::getInstance()->handleCommand(Remote::GREEN); //simulate red press + BoxStack::getInstance()->handleCommand(Remote::GREEN); //simulate red press } } } diff --git a/vpicturebanner.h b/vpicturebanner.h index 49f5d1c..f99b015 100644 --- a/vpicturebanner.h +++ b/vpicturebanner.h @@ -26,17 +26,11 @@ #include #include -#include "view.h" -#include "remote.h" -#include "colour.h" -#include "video.h" -#include "vinfo.h" -#include "viewman.h" -#include "i18n.h" +#include "tbboxx.h" class VPicture; -class VPictureBanner : public View +class VPictureBanner : public TBBoxx { public: VPictureBanner(VPicture *p,bool loading, bool slideshow); diff --git a/vquestion.cc b/vquestion.cc index 1cf63d6..eafd74e 100644 --- a/vquestion.cc +++ b/vquestion.cc @@ -20,18 +20,27 @@ #include "vquestion.h" +#include "remote.h" +#include "boxstack.h" +#include "colour.h" +#include "i18n.h" +#include "command.h" + VQuestion::VQuestion(void* treplyTo) { replyTo = treplyTo; mainText = NULL; selectedOption = NO; - buttonYes.setSurfaceOffset(40, 130); - buttonNo.setSurfaceOffset(140, 130); + buttonYes.setPosition(40, 130); + buttonNo.setPosition(140, 130); buttonYes.setText(tr("Yes")); buttonNo.setText(tr("No")); buttonNo.setActive(1); + + add(&buttonYes); + add(&buttonNo); } VQuestion::~VQuestion() @@ -39,7 +48,7 @@ VQuestion::~VQuestion() if (mainText) delete[] mainText; } -void VQuestion::setMainText(char* takeText) +void VQuestion::setMainText(const char* takeText) { int length = strlen(takeText); mainText = new char[length + 1]; @@ -48,14 +57,9 @@ void VQuestion::setMainText(char* takeText) void VQuestion::draw() { - View::draw(); - - buttonYes.setSurface(surface); - buttonNo.setSurface(surface); + TBBoxx::draw(); if (mainText) drawPara(mainText, 10, 45, Colour::LIGHTTEXT); - buttonYes.draw(); - buttonNo.draw(); } void VQuestion::swap() @@ -83,7 +87,7 @@ int VQuestion::handleCommand(int command) { swap(); draw(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); return 2; } case Remote::DF_RIGHT: @@ -91,7 +95,7 @@ int VQuestion::handleCommand(int command) { swap(); draw(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); return 2; } case Remote::BACK: @@ -128,34 +132,34 @@ void VQuestion::processMessage(Message* m) buttonNo.setActive(0); selectedOption = YES; draw(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); } else if (buttonNo.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) { buttonYes.setActive(0); selectedOption = NO; draw(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); } } else if (m->message == Message::MOUSE_LBDOWN) { if (buttonYes.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) { - ViewMan::getInstance()->handleCommand(Remote::OK); //simulate OK press + BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press } else if (buttonNo.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) { - ViewMan::getInstance()->handleCommand(Remote::OK); //simulate OK press + 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>getWidth() || y>getHeight()) + if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight()) { - ViewMan::getInstance()->handleCommand(Remote::BACK); //simulate cancel press + BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press } } } diff --git a/vquestion.h b/vquestion.h index f50c990..4dd01fa 100644 --- a/vquestion.h +++ b/vquestion.h @@ -24,21 +24,16 @@ #include #include -#include "view.h" +#include "tbboxx.h" #include "wbutton.h" -#include "remote.h" -#include "viewman.h" -#include "colour.h" -#include "i18n.h" -#include "command.h" -class VQuestion : public View +class VQuestion : public TBBoxx { public: VQuestion(void* replyTo); ~VQuestion(); void setDefault(UCHAR option); - void setMainText(char* title); + void setMainText(const char* title); int handleCommand(int command); void processMessage(Message* m); diff --git a/vradiorec.cc b/vradiorec.cc index 55d73e2..0e18753 100644 --- a/vradiorec.cc +++ b/vradiorec.cc @@ -20,9 +20,24 @@ #include "vradiorec.h" +#include "command.h" +#include "osd.h" +#include "player.h" +#include "wsymbol.h" +#include "recording.h" +#include "message.h" +#include "vdr.h" +#include "video.h" +#include "timers.h" +#include "playerradio.h" +#include "boxstack.h" +#include "remote.h" +#include "vinfo.h" +#include "i18n.h" + VRadioRec::VRadioRec(Recording* rec) { - viewman = ViewMan::getInstance(); + boxstack = BoxStack::getInstance(); vdr = VDR::getInstance(); video = Video::getInstance(); timers = Timers::getInstance(); @@ -57,8 +72,9 @@ VRadioRec::VRadioRec(Recording* rec) Log::getInstance()->log("VRadioRec", Log::DEBUG, "SM: %u EM: %u", startMargin, endMargin); - create(video->getScreenWidth(), video->getScreenHeight()); - setBackgroundColour(Colour::BLACK); + setSize(video->getScreenWidth(), video->getScreenHeight()); + createBuffer(); + setPosition(0, 0); barRegion.x = 0; barRegion.y = video->getScreenHeight() - 58; // FIXME, need to be - 1? and below? @@ -91,7 +107,7 @@ VRadioRec::~VRadioRec() void VRadioRec::draw() { - View::draw(); + fillColour(Colour::BLACK); } void VRadioRec::go() @@ -125,15 +141,16 @@ void VRadioRec::go() Message* m = new Message(); m->message = Message::CLOSE_ME; m->from = this; - m->to = viewman; + m->to = boxstack; Command::getInstance()->postMessageNoLock(m); VInfo* vi = new VInfo(); - vi->create(400, 150); + vi->setSize(400, 150); + vi->createBuffer(); if (video->getFormat() == Video::PAL) - vi->setScreenPos(170, 200); + vi->setPosition(170, 200); else - vi->setScreenPos(160, 150); + vi->setPosition(160, 150); vi->setExitable(); vi->setBorderOn(1); vi->setTitleBarOn(0); @@ -142,7 +159,7 @@ void VRadioRec::go() m = new Message(); m->message = Message::ADD_VIEW; - m->to = viewman; + m->to = boxstack; m->parameter = (ULONG)vi; Command::getInstance()->postMessageNoLock(m); } @@ -241,7 +258,7 @@ void VRadioRec::processMessage(Message* m) int y=(m->parameter&0xFFFF)-(int)getScreenY(); if (!barShowing) { - ViewMan::getInstance()->handleCommand(Remote::OK); //simulate rok press + boxstack->handleCommand(Remote::OK); //simulate rok press } else if ((int)barRegion.x<=x && (int)barRegion.y<=y && ((int)barRegion.x+(int)barRegion.w)>=x && ((int)barRegion.y+(int)barRegion.h)>=y) @@ -263,7 +280,7 @@ void VRadioRec::processMessage(Message* m) } else { - ViewMan::getInstance()->handleCommand(Remote::OK); //simulate rok press + boxstack->handleCommand(Remote::OK); //simulate rok press } } else if (m->message == Message::PLAYER_EVENT) @@ -340,9 +357,9 @@ void VRadioRec::doBar(int action) */ WSymbol w; - w.setSurface(surface); + TEMPADD(&w); w.nextSymbol = 0; - w.setSurfaceOffset(barRegion.x + 66, barRegion.y + 16); + w.setPosition(barRegion.x + 66, barRegion.y + 16); UCHAR playerState = 0; @@ -365,7 +382,7 @@ void VRadioRec::doBar(int action) drawBarClocks(); - ViewMan::getInstance()->updateView(this, &barRegion); + BoxStack::getInstance()->update(this, &barRegion); timers->setTimerD(this, 1, 4); // only set the getridofbar timer if not ffwd/fbwd timers->setTimerD(this, 2, 0, 200000000); @@ -388,7 +405,7 @@ void VRadioRec::timercall(int clientReference) drawBarClocks(); Message* m = new Message(); m->message = Message::REDRAW; - m->to = ViewMan::getInstance(); + m->to = boxstack; m->from = this; m->parameter = (ULONG)&barRegion; Command::getInstance()->postMessageFromOuterSpace(m); @@ -530,7 +547,7 @@ void VRadioRec::removeBar() Message* m = new Message(); m->message = Message::REDRAW; - m->to = ViewMan::getInstance(); + m->to = boxstack; m->from = this; m->parameter = (ULONG)&barRegion; Command::getInstance()->postMessageFromOuterSpace(m); diff --git a/vradiorec.h b/vradiorec.h index d7f9aa6..3bed0e3 100644 --- a/vradiorec.h +++ b/vradiorec.h @@ -23,21 +23,20 @@ #include -#include "video.h" -#include "view.h" -#include "playerradio.h" -#include "vdr.h" -#include "recording.h" -#include "command.h" -#include "colour.h" -#include "osd.h" -#include "timers.h" +#include "boxx.h" #include "timerreceiver.h" -#include "message.h" +#include "defines.h" +#include "colour.h" +#include "region.h" +class Recording; +class Message; +class VDR; +class Video; +class PlayerRadio; class Timers; -class VRadioRec : public View, public TimerReceiver +class VRadioRec : public Boxx, public TimerReceiver { public: VRadioRec(Recording* rec); @@ -55,6 +54,7 @@ class VRadioRec : public View, public TimerReceiver Timers* timers; PlayerRadio* player; Recording* myRec; + BoxStack* boxstack; Colour barBlue; diff --git a/vrecmove.cc b/vrecmove.cc index 8f41080..336d619 100644 --- a/vrecmove.cc +++ b/vrecmove.cc @@ -20,29 +20,43 @@ #include "vrecmove.h" +#include "defines.h" +#include "recording.h" +#include "remote.h" +#include "vinfo.h" +#include "colour.h" +#include "video.h" +#include "i18n.h" +#include "command.h" +#include "wsymbol.h" +#include "recman.h" +#include "directory.h" +#include "message.h" +#include "boxstack.h" + VRecMove::VRecMove(RecMan* trecman) { recman = trecman; - create(260, 210); + setSize(260, 210); + createBuffer(); if (Video::getInstance()->getFormat() == Video::PAL) { - setScreenPos(220, 160); + setPosition(220, 160); } else { - setScreenPos(210, 130); + setPosition(210, 130); } - setBackgroundColour(Colour::VIEWBACKGROUND); setTitleBarOn(1); setBorderOn(1); setTitleText(tr("Move recording")); setTitleBarColour(Colour::TITLEBARBACKGROUND); - sl.setSurface(surface); - sl.setSurfaceOffset(10, 30 + 5); - sl.setDimensions(area.w - 40, area.h - 30 - 15); + sl.setPosition(10, 30 + 5); + sl.setSize(area.w - 40, area.h - 30 - 15); + add(&sl); Directory* dir = recman->getRootDir(); sl.addOption("/", (ULONG)dir, 1); @@ -76,19 +90,18 @@ void VRecMove::addDirs(Directory* dir, char* prefix) void VRecMove::draw() { - View::draw(); - sl.draw(); + TBBoxx::draw(); rectangle(area.w - 30, 30 + 5, 20, area.h - 30 - 15, Colour::VIEWBACKGROUND); WSymbol w; - w.setSurface(surface); + TEMPADD(&w); w.nextSymbol = WSymbol::SMALLUP; - w.setSurfaceOffset(area.w - 28, 30 + 7); + w.setPosition(area.w - 28, 30 + 7); w.draw(); w.nextSymbol = WSymbol::SMALLDOWN; - w.setSurfaceOffset(area.w - 28, area.h - 26); + w.setPosition(area.w - 28, area.h - 26); w.draw(); } @@ -101,7 +114,7 @@ int VRecMove::handleCommand(int command) { sl.up(); sl.draw(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); return 2; } case Remote::DF_DOWN: @@ -109,7 +122,7 @@ int VRecMove::handleCommand(int command) { sl.down(); sl.draw(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); return 2; } case Remote::OK: @@ -138,23 +151,23 @@ void VRecMove::processMessage(Message* m) if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) { sl.draw(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(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 + 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>getWidth() || y>getHeight()) + if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight()) { - ViewMan::getInstance()->handleCommand(Remote::BACK); //simulate cancel press + BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press } } } diff --git a/vrecmove.h b/vrecmove.h index 58d4a82..49c73e5 100644 --- a/vrecmove.h +++ b/vrecmove.h @@ -24,21 +24,14 @@ #include #include -#include "defines.h" -#include "view.h" -#include "recording.h" +#include "tbboxx.h" #include "wselectlist.h" -#include "remote.h" -#include "vinfo.h" -#include "colour.h" -#include "video.h" -#include "i18n.h" -#include "command.h" -#include "directory.h" -#include "message.h" -#include "viewman.h" - -class VRecMove : public View + +class RecMan; +class Directory; +class Message; + +class VRecMove : public TBBoxx { public: VRecMove(RecMan* recman); diff --git a/vrecordinglist.cc b/vrecordinglist.cc index 4f264cd..4a2667a 100644 --- a/vrecordinglist.cc +++ b/vrecordinglist.cc @@ -1,5 +1,5 @@ /* - Copyright 2004-2005 Chris Tallon + Copyright 2004-2007 Chris Tallon This file is part of VOMP. @@ -20,29 +20,45 @@ #include "vrecordinglist.h" +#include "recman.h" +#include "directory.h" +#include "recording.h" +#include "remote.h" +#include "wsymbol.h" +#include "boxstack.h" +#include "vrecordingmenu.h" +#include "vdr.h" +#include "vvideorec.h" +#include "vradiorec.h" +#include "colour.h" +#include "video.h" +#include "i18n.h" +#include "command.h" +#include "vinfo.h" + VRecordingList::VRecordingList() { - viewman = ViewMan::getInstance(); + boxstack = BoxStack::getInstance(); recman = NULL; loading = true; - create(570, 420); + setSize(570, 420); + createBuffer(); if (Video::getInstance()->getFormat() == Video::PAL) { - setScreenPos(80, 70); + setPosition(80, 70); } else { - setScreenPos(70, 35); + setPosition(70, 35); } - setBackgroundColour(Colour::VIEWBACKGROUND); setTitleBarOn(1); setTitleBarColour(Colour::TITLEBARBACKGROUND); - sl.setSurface(surface); - sl.setSurfaceOffset(10, 30 + 5); - sl.setDimensions(area.w - 20, area.h - 30 - 15 - 30); + sl.setPosition(10, 30 + 5); + sl.setSize(area.w - 20, area.h - 30 - 15 - 30); + add(&sl); } VRecordingList::~VRecordingList() @@ -126,7 +142,7 @@ void VRecordingList::draw(bool doIndexPop) } } - View::draw(); + TBBoxx::draw(); if (loading) { @@ -142,26 +158,26 @@ void VRecordingList::draw(bool doIndexPop) // Symbols WSymbol w; - w.setSurface(surface); + TEMPADD(&w); w.nextSymbol = WSymbol::UP; - w.setSurfaceOffset(20, 385); + w.setPosition(20, 385); w.draw(); w.nextSymbol = WSymbol::DOWN; - w.setSurfaceOffset(50, 385); + w.setPosition(50, 385); w.draw(); w.nextSymbol = WSymbol::SKIPBACK; - w.setSurfaceOffset(85, 385); + w.setPosition(85, 385); w.draw(); w.nextSymbol = WSymbol::SKIPFORWARD; - w.setSurfaceOffset(115, 385); + w.setPosition(115, 385); w.draw(); w.nextSymbol = WSymbol::PLAY; - w.setSurfaceOffset(150, 385); + w.setPosition(150, 385); w.draw(); drawTextRJ(tr("[ok] = menu"), 560, 385, Colour::LIGHTTEXT); @@ -193,23 +209,23 @@ void VRecordingList::processMessage(Message* m) { sl.draw(); doShowingBar(); - viewman->updateView(this); + boxstack->update(this); } } else if (m->message == Message::MOUSE_LBDOWN) { if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) { - viewman->handleCommand(Remote::OK); //simulate OK press + boxstack->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()) + if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight()) { - viewman->handleCommand(Remote::BACK); //simulate cancel press + boxstack->handleCommand(Remote::BACK); //simulate cancel press } } } @@ -251,24 +267,25 @@ void VRecordingList::doDeleteSelected() if (success != 1) { VInfo* vi = new VInfo(); - vi->create(360, 200); + vi->setSize(360, 200); + vi->createBuffer(); if (Video::getInstance()->getFormat() == Video::PAL) - vi->setScreenPos(190, 170); + vi->setPosition(190, 170); else - vi->setScreenPos(180, 120); + vi->setPosition(180, 120); vi->setOneLiner(tr("Failed to delete recording")); vi->setExitable(); vi->setBorderOn(1); vi->setTitleBarColour(Colour::DANGER); vi->okButton(); vi->draw(); - viewman->add(vi); - viewman->updateView(vi); + boxstack->add(vi); + boxstack->update(vi); } else { draw(); - viewman->updateView(this); + boxstack->update(this); } } @@ -290,24 +307,25 @@ void VRecordingList::doMoveRecording(Directory* toDir) if (success != 1) { VInfo* vi = new VInfo(); - vi->create(360, 200); + vi->setSize(360, 200); + vi->createBuffer(); if (Video::getInstance()->getFormat() == Video::PAL) - vi->setScreenPos(190, 170); + vi->setPosition(190, 170); else - vi->setScreenPos(180, 120); + vi->setPosition(180, 120); vi->setOneLiner(tr("Failed to move recording")); vi->setExitable(); vi->setBorderOn(1); vi->setTitleBarColour(Colour::DANGER); vi->okButton(); vi->draw(); - viewman->add(vi); - viewman->updateView(vi); + boxstack->add(vi); + boxstack->update(vi); } else { draw(); - viewman->updateView(this); + boxstack->update(this); } } @@ -325,16 +343,16 @@ int VRecordingList::doPlay(bool resume) { VRadioRec* radrec = new VRadioRec(toPlay); radrec->draw(); - viewman->add(radrec); - viewman->updateView(radrec); + boxstack->add(radrec); + boxstack->update(radrec); radrec->go(); } else { VVideoRec* vidrec = new VVideoRec(toPlay); vidrec->draw(); - viewman->add(vidrec); - viewman->updateView(vidrec); + boxstack->add(vidrec); + boxstack->update(vidrec); vidrec->go(resume); } return 1; @@ -368,7 +386,7 @@ int VRecordingList::handleCommand(int command) sl.draw(); doShowingBar(); - viewman->updateView(this); + boxstack->update(this); return 2; } case Remote::DF_DOWN: @@ -382,7 +400,7 @@ int VRecordingList::handleCommand(int command) doShowingBar(); Log::getInstance()->log("P", Log::DEBUG, "3"); - viewman->updateView(this); + boxstack->update(this); Log::getInstance()->log("P", Log::DEBUG, "4"); return 2; } @@ -392,7 +410,7 @@ int VRecordingList::handleCommand(int command) sl.draw(); doShowingBar(); - viewman->updateView(this); + boxstack->update(this); return 2; } case Remote::SKIPFORWARD: @@ -401,7 +419,7 @@ int VRecordingList::handleCommand(int command) sl.draw(); doShowingBar(); - viewman->updateView(this); + boxstack->update(this); return 2; } case Remote::OK: @@ -422,7 +440,7 @@ int VRecordingList::handleCommand(int command) slIndexStack.push(sl.getCurrentOption()); sl.clear(); draw(); - viewman->updateView(this); + boxstack->update(this); } return 2; } @@ -438,8 +456,8 @@ int VRecordingList::handleCommand(int command) v->setParent(this); v->setRecording(current); v->draw(); - viewman->add(v); - viewman->updateView(v); + boxstack->add(v); + boxstack->update(v); return 2; } // should not get to here @@ -452,7 +470,7 @@ int VRecordingList::handleCommand(int command) recman->up(); sl.clear(); draw(true); - viewman->updateView(this); + boxstack->update(this); return 2; } else @@ -497,7 +515,7 @@ bool VRecordingList::load() recman->sort(); draw(); - viewman->updateView(this); + boxstack->update(this); } return success; @@ -509,5 +527,6 @@ void VRecordingList::reSort() recman->sort(); sl.clear(); draw(); - viewman->updateView(this); + boxstack->update(this); } + diff --git a/vrecordinglist.h b/vrecordinglist.h index ae0c480..1a398ac 100644 --- a/vrecordinglist.h +++ b/vrecordinglist.h @@ -27,24 +27,16 @@ #include #include -#include "view.h" -#include "recman.h" -#include "directory.h" -#include "recording.h" +#include "tbboxx.h" #include "wselectlist.h" -#include "remote.h" -#include "wsymbol.h" -#include "viewman.h" -#include "vrecordingmenu.h" -#include "vdr.h" -#include "vvideorec.h" -#include "vradiorec.h" -#include "colour.h" -#include "video.h" -#include "i18n.h" -#include "command.h" -class VRecordingList : public View +class Message; +class BoxStack; +class RecMan; +class Directory; +class Recording; + +class VRecordingList : public TBBoxx { public: VRecordingList(); @@ -57,7 +49,7 @@ class VRecordingList : public View void drawData(bool doIndexPop = false); private: - + BoxStack* boxstack; bool loading; RecMan* recman; Directory* dir; diff --git a/vrecordingmenu.cc b/vrecordingmenu.cc index fb764c1..d50e713 100644 --- a/vrecordingmenu.cc +++ b/vrecordingmenu.cc @@ -20,35 +20,50 @@ #include "vrecordingmenu.h" +#include "remote.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" + VRecordingMenu::VRecordingMenu(RecMan* trecman) { rec = NULL; recman = trecman; - create(200, 164); + setSize(200, 164); + createBuffer(); if (Video::getInstance()->getFormat() == Video::PAL) { - setScreenPos(260, 190); + setPosition(260, 190); } else { - setScreenPos(250, 160); + setPosition(250, 160); } - setBackgroundColour(Colour::VIEWBACKGROUND); setTitleBarOn(1); setBorderOn(1); setTitleText(tr("Programme menu")); setTitleBarColour(Colour::TITLEBARBACKGROUND); - sl.setSurface(surface); - sl.setSurfaceOffset(10, 30 + 5); - sl.setDimensions(area.w - 20, area.h - 30 - 15); + sl.setPosition(10, 30 + 5); + sl.setSize(area.w - 20, area.h - 30 - 15); sl.addOption(tr("Play"), 1, 1); sl.addOption(tr("Resume"), 2, 0); sl.addOption(tr("Summary"), 3, 0); sl.addOption(tr("Move"), 4, 0); sl.addOption(tr("Delete"), 5, 0); + add(&sl); } VRecordingMenu::~VRecordingMenu() @@ -65,12 +80,6 @@ void VRecordingMenu::setRecording(Recording* trec) rec = trec; } -void VRecordingMenu::draw() -{ - View::draw(); - sl.draw(); -} - int VRecordingMenu::handleCommand(int command) { switch(command) @@ -80,7 +89,7 @@ int VRecordingMenu::handleCommand(int command) { sl.up(); sl.draw(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); return 2; } case Remote::DF_DOWN: @@ -88,7 +97,7 @@ int VRecordingMenu::handleCommand(int command) { sl.down(); sl.draw(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); return 2; } case Remote::OK: @@ -118,6 +127,12 @@ int VRecordingMenu::handleCommand(int command) rec->loadRecInfo(); VInfo* vi = new VInfo(); + vi->setSize(490, 300); + vi->createBuffer(); + if (Video::getInstance()->getFormat() == Video::PAL) + vi->setPosition(120, 130); + else + vi->setPosition(110, 90); vi->setTitleText(tr("Programme summary")); vi->setBorderOn(1); vi->setExitable(); @@ -125,18 +140,9 @@ int VRecordingMenu::handleCommand(int command) vi->setMainText(rec->recInfo->summary); else vi->setMainText(tr("Summary unavailable")); - if (Video::getInstance()->getFormat() == Video::PAL) - { - vi->setScreenPos(120, 130); - } - else - { - vi->setScreenPos(110, 90); - } - vi->create(490, 300); vi->draw(); - ViewMan::getInstance()->add(vi); - ViewMan::getInstance()->updateView(vi); + BoxStack::getInstance()->add(vi); + BoxStack::getInstance()->update(vi); return 2; } @@ -146,16 +152,16 @@ int VRecordingMenu::handleCommand(int command) VRecMove* vrm = new VRecMove(recman); vrm->setParent(this); vrm->draw(); - ViewMan::getInstance()->add(vrm); - ViewMan::getInstance()->updateView(vrm); + BoxStack::getInstance()->add(vrm); + BoxStack::getInstance()->update(vrm); return 2; } if (sl.getCurrentOptionData() == 5) { VQuestion* v = new VQuestion(this); - v->create(260, 180); - v->setBackgroundColour(Colour::VIEWBACKGROUND); + v->setSize(260, 180); + v->createBuffer(); v->setTitleBarColour(Colour::DANGER); v->setTitleBarOn(1); v->setBorderOn(1); @@ -164,16 +170,16 @@ int VRecordingMenu::handleCommand(int command) v->setDefault(VQuestion::NO); if (Video::getInstance()->getFormat() == Video::PAL) { - v->setScreenPos(230, 160); + v->setPosition(230, 160); } else { - v->setScreenPos(220, 140); + v->setPosition(220, 140); } v->draw(); - ViewMan::getInstance()->add(v); - ViewMan::getInstance()->updateView(v); + BoxStack::getInstance()->add(v); + BoxStack::getInstance()->update(v); return 2; } } @@ -193,23 +199,23 @@ void VRecordingMenu::processMessage(Message* m) if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) { sl.draw(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(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 + 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>getWidth() || y>getHeight()) + if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight()) { - ViewMan::getInstance()->handleCommand(Remote::BACK); //simulate cancel press + BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press } } } @@ -219,7 +225,7 @@ void VRecordingMenu::processMessage(Message* m) { Message* m2 = new Message(); // Delete self m2->from = this; - m2->to = ViewMan::getInstance(); + m2->to = BoxStack::getInstance(); m2->message = Message::CLOSE_ME; Command::getInstance()->postMessageNoLock(m2); @@ -234,7 +240,7 @@ void VRecordingMenu::processMessage(Message* m) { Message* m2 = new Message(); // Delete self m2->from = this; - m2->to = ViewMan::getInstance(); + m2->to = BoxStack::getInstance(); m2->message = Message::CLOSE_ME; Command::getInstance()->postMessageNoLock(m2); diff --git a/vrecordingmenu.h b/vrecordingmenu.h index 54c5fa1..fb932c6 100644 --- a/vrecordingmenu.h +++ b/vrecordingmenu.h @@ -24,24 +24,15 @@ #include #include -#include "view.h" -#include "recording.h" +#include "tbboxx.h" #include "wselectlist.h" -#include "remote.h" -#include "vrecordinglist.h" -#include "vquestion.h" -#include "message.h" -#include "vinfo.h" -#include "vdr.h" -#include "colour.h" -#include "video.h" -#include "i18n.h" -#include "command.h" -#include "vrecmove.h" class VRecordingList; +class RecMan; +class Recording; +class Message; -class VRecordingMenu : public View +class VRecordingMenu : public TBBoxx { public: VRecordingMenu(RecMan* recman); @@ -51,7 +42,6 @@ class VRecordingMenu : public View int handleCommand(int command); void processMessage(Message* m); - void draw(); private: RecMan* recman; diff --git a/vremoteconfig.cc b/vremoteconfig.cc index b8cb865..910d051 100644 --- a/vremoteconfig.cc +++ b/vremoteconfig.cc @@ -20,6 +20,16 @@ #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; @@ -67,9 +77,9 @@ void VRemoteConfig::initSelectList(bool startup) top=sl.getTopOption(); } - sl.setSurface(surface); - sl.setSurfaceOffset(10, 40); - sl.setDimensions(area.w - 20, area.h - 30 - 15 -30 ); +// 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); diff --git a/vremoteconfig.h b/vremoteconfig.h index 193b767..8a69c3f 100644 --- a/vremoteconfig.h +++ b/vremoteconfig.h @@ -29,14 +29,9 @@ #include "view.h" #include "wselectlist.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" + +class Remote; +class Message; class VRemoteConfig : public View { @@ -56,7 +51,6 @@ class VRemoteConfig : public View void initSelectList(bool startup); void doSave(); void* parent; - }; diff --git a/vscreensaver.cc b/vscreensaver.cc index d633d9f..9182632 100644 --- a/vscreensaver.cc +++ b/vscreensaver.cc @@ -20,9 +20,16 @@ #include "vscreensaver.h" +#include "defines.h" +#include "log.h" +#include "remote.h" +#include "colour.h" +#include "video.h" +#include "surface.h" + VScreensaver::VScreensaver() { - setScreenPos(0, 0); + setPosition(0, 0); Video* video = Video::getInstance(); screenWidth = video->getScreenWidth(); screenHeight = video->getScreenHeight(); @@ -39,15 +46,13 @@ VScreensaver::~VScreensaver() void VScreensaver::draw() { - setBackgroundColour(Colour::BLACK); - View::draw(); + fillColour(Colour::BLACK); threadStart(); } int VScreensaver::handleCommand(int command) { threadCancel(); - return 4; } diff --git a/vscreensaver.h b/vscreensaver.h index 4d3330e..e7e594a 100644 --- a/vscreensaver.h +++ b/vscreensaver.h @@ -25,13 +25,7 @@ #include #include -#include "defines.h" -#include "log.h" -#include "view.h" -#include "remote.h" -#include "colour.h" -#include "video.h" -#include "video.h" +#include "boxx.h" #ifdef WIN32 #include "threadwin.h" @@ -40,7 +34,7 @@ #endif -class VScreensaver : public View, public Thread_TYPE +class VScreensaver : public Boxx, public Thread_TYPE { public: VScreensaver(); diff --git a/vserverselect.cc b/vserverselect.cc index 11dc19a..e9acdf7 100644 --- a/vserverselect.cc +++ b/vserverselect.cc @@ -20,6 +20,15 @@ #include "vserverselect.h" +#include "defines.h" +#include "remote.h" +#include "colour.h" +#include "video.h" +#include "boxstack.h" +#include "i18n.h" +#include "command.h" + + VServerSelect::VServerSelect(vector& servers, void* treplyTo) { // I tried the whole passing using a reference here, but @@ -27,24 +36,24 @@ VServerSelect::VServerSelect(vector& servers, void* treplyTo) // a char array. so now we have the messy dereferencing... // anyway, now it doesn't use a object wide reference. - create(300, 200); + setSize(300, 200); + createBuffer(); if (Video::getInstance()->getFormat() == Video::PAL) { - setScreenPos(220, 200); + setPosition(220, 200); } else { - setScreenPos(210, 150); + setPosition(210, 150); } - setBackgroundColour(Colour::VIEWBACKGROUND); setTitleBarOn(1); setTitleBarColour(Colour::TITLEBARBACKGROUND); setTitleText(tr("Choose a VDR server")); - sl.setSurface(surface); - sl.setSurfaceOffset(10, 30 + 5); - sl.setDimensions(area.w - 20, area.h - 30 - 15); + sl.setPosition(10, 30 + 5); + sl.setSize(area.w - 20, area.h - 30 - 15); + add(&sl); sl.addOption(servers[0].name, 0, 1); for(UINT k = 1; k < servers.size(); k++) @@ -61,8 +70,7 @@ VServerSelect::~VServerSelect() void VServerSelect::draw() { - View::draw(); - sl.draw(); + TBBoxx::draw(); } int VServerSelect::handleCommand(int command) @@ -74,7 +82,7 @@ int VServerSelect::handleCommand(int command) { sl.up(); sl.draw(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); return 2; } case Remote::DF_DOWN: @@ -82,7 +90,7 @@ int VServerSelect::handleCommand(int command) { sl.down(); sl.draw(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); return 2; } case Remote::OK: @@ -106,14 +114,14 @@ void VServerSelect::processMessage(Message* m) if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) { sl.draw(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(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 + BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press } } } diff --git a/vserverselect.h b/vserverselect.h index af6a68c..708528a 100644 --- a/vserverselect.h +++ b/vserverselect.h @@ -25,20 +25,15 @@ #include #include -#include "defines.h" -#include "view.h" -#include "remote.h" -#include "wselectlist.h" -#include "colour.h" -#include "video.h" -#include "viewman.h" -#include "i18n.h" +#include "tbboxx.h" #include "vdr.h" -#include "command.h" +#include "wselectlist.h" + +class Message; using namespace std; -class VServerSelect : public View +class VServerSelect : public TBBoxx { public: VServerSelect(vector& servers, void* replyTo); diff --git a/vtabsviewman.cc b/vtabsviewman.cc deleted file mode 100644 index 1ecbef1..0000000 --- a/vtabsviewman.cc +++ /dev/null @@ -1,438 +0,0 @@ -/* - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -#include "vtabsviewman.h" -#include "video.h" -#include "wsymbol.h" -#include "remote.h" -#include "command.h" -#include "viewman.h" - -VTabsViewMan::VTabsViewMan() -{ - numViews = 0; - selectedView = 0; - backgroundColour = Colour::VIEWBACKGROUND; - tabHasControl = true; -} - -VTabsViewMan::~VTabsViewMan() -{ - removeAll(); -} - -int VTabsViewMan::add(View* v) -{ - if (numViews == 16) return 0; - - v->setTitleBarOn(0); //No Title Bar - v->setViewMan(this); //For this view, we are the viewman - v->setBackgroundColour(Colour::TABVIEWBACKGROUND); - - views[numViews++] = v; - - if (surface!=NULL) create(); //Recreating surface - - return 1; -} - -int VTabsViewMan::removeView(View* toDelete) -{ - if (numViews == 0) return 0; - - int i; - - if (toDelete == NULL) - { - toDelete = views[numViews-1]; - i = numViews - 1; - } - else - { - // to be deleted view is more likely to be at the top - for (i = numViews-1; i >= 0; i--) - { - if (views[i] == toDelete) break; - } - if (i == -1) - { - // not a View we have! - return 0; - } - } -// deleteView(i); - - // Shift the views on top down one - --numViews; - for(int j = i; j < numViews; j++) views[j] = views[j+1]; - - // Delete the view - delete toDelete; - - if (surface!=NULL) create(); //Recreating surface, if we are initted - if (selectedView >= numViews) selectedView = numViews-1; - - return 1; -} - -void VTabsViewMan::removeAll() -{ - for (; numViews > 0; --numViews) - { - delete views[numViews-1]; - } -} - -void VTabsViewMan::updateView(View* toUpdate, Region* regionToUpdate) -{ - draw(); - ViewMan::getInstance()->updateView(this,regionToUpdate); -} - -void VTabsViewMan::create() -{ - if (surface!=NULL) - { - delete surface;//destroy old surface - surface=NULL; - } - Region newarea; - int i; - if (numViews == 0) - { - newarea.h=200; - newarea.w=200; - } - else - { - for (i = 0; i < numViews; i++) - { - newarea.h=max(views[i]->getHeight(),newarea.h); - newarea.w=max(views[i]->getWidth(),newarea.w); - } - } - newarea.h += 30; //Title Bar - newarea.h += 30; //Tab bar - newarea.h += 2; //Border - newarea.w += 2; - - //centering - - newarea.y = Video::getInstance()->getScreenHeight()/2-newarea.h/2; - newarea.x = Video::getInstance()->getScreenWidth()/2-newarea.w/2; - setScreenPos(newarea.x,newarea.y); - - //Now iterate through the views and set the position - - for (i = 0; i < numViews; i++) - { - views[i]->setScreenPos(newarea.x+1,newarea.y+1+30+30); - } - View::create(newarea.w,newarea.h); - -} - - -void VTabsViewMan::draw() -{ - if (surface==NULL) return; - View::draw(); - //Now Drawing the tabs bar - int xpos=1; - WSymbol wsy; - wsy.setSurface(surface); - - if (selectedView>=2) - { - wsy.nextSymbol = WSymbol::LEFTARROW; - wsy.nextColour = Colour::BUTTONBACKGROUND; - wsy.setSurfaceOffset(xpos, 40); - wsy.draw(); - xpos+=20; - } - int i; - UINT textypos=30+30-2-surface->getFontHeight(); - for (i = max(selectedView-1,0); i < numViews && xpos+150+20 < (int)area.w; i++) - { - if (i == selectedView) - { - rectangle(xpos+1,30+1,150,30,Colour::TABVIEWBACKGROUND); - } - else - { - rectangle(xpos+1,30+1,150,28,Colour::TABVIEWBACKGROUND); - } - if (i == selectedView && tabHasControl) - drawText(views[i]->getTitleText(),xpos+5,textypos,Colour::SELECTHIGHLIGHT); - else - drawText(views[i]->getTitleText(),xpos+5,textypos,Colour::LIGHTTEXT); - - xpos+=151; - } - if (i < numViews) - { - wsy.nextSymbol = WSymbol::RIGHTARROW; - wsy.nextColour = Colour::BUTTONBACKGROUND; - wsy.setSurfaceOffset(xpos+5, 40); - wsy.draw(); - xpos+=20; - } - - - if (selectedView < numViews) views[selectedView]->draw(); -} - -void VTabsViewMan::blt(Region& r) -{ - Box::blt(r); - - if (selectedView < numViews) { - Region helper=r; - helper.x = max(helper.x,views[selectedView]->area.x); - helper.w -= helper.x-r.x; - helper.y = max(helper.y,views[selectedView]->area.y); - helper.h -= helper.y-r.y; - helper.w = min(helper.w,views[selectedView]->area.w); - helper.h = min(helper.h,views[selectedView]->area.h); - views[selectedView]->blt(helper); - } -} - - -int VTabsViewMan::handleCommand(int command) -{ - int retVal; - int i; - if (command == Remote::BACK) - { - for (i=0;ihandleCommand(Remote::BACK); - } - // Instead of returning 4 here which would delete this view - // before the doSave messages are 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::getInstance(); - Command::getInstance()->postMessageNoLock(m); - return 2; - } - else if (tabHasControl) //our control bar is selected, we are the master of the universe - { - switch (command) - { - case Remote::DF_DOWN: - case Remote::DOWN: - { - tabHasControl = false; //loose control - if (selectedView < numViews) - { - views[selectedView]->handleCommand(command); - draw(); - - - // viewman->updateView(this); // CJT // this line makes it flash twice, unneccessary? - return 2; - } - else - return 2; - }break; - case Remote::DF_LEFT: - case Remote::LEFT: - { - selectedView=max(0,selectedView-1); - draw(); - viewman->updateView(this); - return 2; - }break; - case Remote::DF_RIGHT: - case Remote::RIGHT: - { - selectedView=min(numViews-1,selectedView+1); - draw(); - viewman->updateView(this); - return 2; - }break; - } - return 1; - } - else if (command != Remote::NA_NONE) - { - // handle command return values - // 0 - drop through to next view //this means me - // 1 - dont drop to next view, but not handled - // 2 - handled - stop command here - // 4 - handled - delete this view //delete me too - - - if (selectedView < numViews) - { - retVal = views[selectedView]->handleCommand(command); - if (retVal == 1) - { - // not handled but don't give to any more views - return 1; - } - if (retVal == 2) - { - // command handled - return 2; - } - else if (retVal == 4) - { - // Log::getInstance()->log("ViewMan", Log::DEBUG, "Return 4: i=%i, views[i]=%p", i, views[i]); - - return 1; - } else if (retVal == 0) { - tabHasControl = true; - draw(); // I have control - viewman->updateView(this); - return 2; - } - - } - } - else - { - // fake the return code - return 2; - } - - return 0; - -} - -void VTabsViewMan::processMessage(Message* m) -{ - /* Handle mouse events*/ - // They come in with m->to = ViewMan and just need to be delivered to selectedView? - if ((numViews > 0) && ((m->message == Message::MOUSE_MOVE) || (m->message == Message::MOUSE_LBDOWN))) - { - //TODO, add Tab bar interaction - int x=(m->parameter>>16)-getScreenX(); - int y=(m->parameter&0xFFFF)-getScreenY(); - if (x<0 || y <0 || x>getWidth() || y>getHeight()) - { - if (m->message == Message::MOUSE_LBDOWN) - { - Message *newm=new Message(); - newm->from=NULL; - newm->to=Command::getInstance(); - newm->message=Message::UDP_BUTTON; - newm->parameter=Remote::BACK; - Command::getInstance()->postMessage(newm); - } - } else { - if ( y <= 60) - { //my area - if (y >= 30 && m->message == Message::MOUSE_LBDOWN) - { - int xpos=1; - if (selectedView>=2) - { - if (xpos < x && x <=xpos+20) - { - tabHasControl=true; - Message *newm=new Message(); - newm->from=NULL; - newm->to=Command::getInstance(); - newm->message=Message::UDP_BUTTON; - newm->parameter=Remote::LEFT; - Command::getInstance()->postMessage(newm); - return; - } - xpos+=20; - } - int i; - for (i = max(selectedView-1,0);i < numViews && xpos+150+20 < (int)area.w; i++) - { - if (xpos < x && x <=xpos+150) - { - tabHasControl=true; - selectedView = i; - draw(); - ViewMan::getInstance()->updateView(this); - return; - } - xpos+=151; - } - if (i < numViews) - { - if (xpos < x && x <=xpos+20) - { - tabHasControl=true; - Message *newm=new Message(); - newm->from=NULL; - newm->to=Command::getInstance(); - newm->message=Message::UDP_BUTTON; - newm->parameter=Remote::RIGHT; - Command::getInstance()->postMessage(newm); - return; - } - } - } - } - else //tabs area - { - tabHasControl=false; - views[selectedView]->processMessage(m); - } - } - return; - } - - if (m->to != this) - { - for (int i = numViews-1; i >= 0; i--) - { - if (views[i] == m->to) - { - Log::getInstance()->log("VTabsViewMan", Log::DEBUG, "sending message from view %p to view %p %lu", m->from, m->to, m->message); - views[i]->processMessage(m); - return; - } - } - return; - } - - - - Log::getInstance()->log("VTabsViewMan", Log::DEBUG, "it's for meeee!"); - - switch(m->message) - { - case Message::CLOSE_ME: - { - removeView((View*)m->from); - break; - } - case Message::ADD_VIEW: // currently not used by anything but it might come in useful again - { - View* toAdd = (View*)m->parameter; - add(toAdd); - toAdd->draw(); - ViewMan::getInstance()->updateView(this); - break; - } - } -} diff --git a/vtimeredit.cc b/vtimeredit.cc index c0fec61..4ca1149 100644 --- a/vtimeredit.cc +++ b/vtimeredit.cc @@ -20,30 +20,57 @@ #include "vtimeredit.h" +#include "remote.h" +#include "wsymbol.h" +#include "boxstack.h" +#include "vdr.h" +#include "colour.h" +#include "video.h" +#include "i18n.h" +#include "timers.h" +#include "vquestion.h" +#include "command.h" + VTimerEdit::VTimerEdit(RecTimer* trt) { recTimer = trt; - create(570, 420); + setSize(570, 420); + createBuffer(); if (Video::getInstance()->getFormat() == Video::PAL) { - setScreenPos(80, 70); + setPosition(80, 70); } else { - setScreenPos(70, 35); + setPosition(70, 35); } + selectedButton = 0; + buttonBack.setPosition(30,350); + buttonDelete.setPosition(400,350); + buttonBack.setText("Back"); + buttonBack.setActive(1); + buttonDelete.setText("Delete"); + add(&buttonBack); + add(&buttonDelete); - - setBackgroundColour(Colour::VIEWBACKGROUND); setTitleBarOn(1); setTitleText(tr("Edit Timer")); setTitleBarColour(Colour::TITLEBARBACKGROUND); +} +VTimerEdit::~VTimerEdit() +{ +} - // Draw statics +void VTimerEdit::setParent(VTimerList* tvTimerList) +{ + vTimerList = tvTimerList; +} - draw(); // View::draw +void VTimerEdit::draw() +{ + TBBoxx::draw(); int xpos = 20; int ypos = 50; @@ -114,18 +141,29 @@ VTimerEdit::VTimerEdit(RecTimer* trt) if (recTimer->recording) strcpy(buffer, "Yes"); else strcpy(buffer, "No"); drawText(buffer, xpos, ypos, Colour::LIGHTTEXT); ypos += surface->getFontHeight(); - - } -VTimerEdit::~VTimerEdit() +void VTimerEdit::swap() { + if (selectedButton == 0) + { + buttonBack.setActive(0); + buttonDelete.setActive(1); + selectedButton = 1; + } + else + { + buttonDelete.setActive(0); + buttonBack.setActive(1); + selectedButton = 0; + } } int VTimerEdit::handleCommand(int command) { switch(command) { + /* case Remote::DF_UP: case Remote::UP: { @@ -140,9 +178,46 @@ int VTimerEdit::handleCommand(int command) ViewMan::getInstance()->updateView(this); return 2; } + */ + case Remote::LEFT: + case Remote::DF_RIGHT: + { + swap(); + buttonBack.draw(); + buttonDelete.draw(); + BoxStack::getInstance()->update(this); + return 2; + } + case Remote::RIGHT: + case Remote::DF_LEFT: + { + swap(); + buttonBack.draw(); + buttonDelete.draw(); + BoxStack::getInstance()->update(this); + return 2; + } case Remote::OK: { - + // Back + if (selectedButton == 0) return 4; + // Delete + VQuestion* v = new VQuestion(this); + v->setSize(260, 180); + v->createBuffer(); + v->setTitleBarColour(Colour::DANGER); + v->setTitleBarOn(1); + v->setBorderOn(1); + v->setTitleText("Delete timer"); + v->setMainText("Are you sure you want to delete this timer?"); + 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: @@ -158,6 +233,24 @@ void VTimerEdit::processMessage(Message* m) { if (m->message == Message::MOUSE_LBDOWN) { - ViewMan::getInstance()->handleCommand(Remote::OK); //simulate OK press + BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press + } + else if (m->message == Message::QUESTION_YES) + { + if (selectedButton == 1) + { + 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 = vTimerList; + m2->message = Message::DELETE_SELECTED_TIMER; + Command::getInstance()->postMessageNoLock(m2); + } } } + diff --git a/vtimeredit.h b/vtimeredit.h index 259a5b3..1ae14d6 100644 --- a/vtimeredit.h +++ b/vtimeredit.h @@ -24,29 +24,32 @@ #include #include -#include "view.h" -#include "wselectlist.h" -#include "remote.h" -#include "wsymbol.h" -#include "viewman.h" -#include "vdr.h" -#include "colour.h" -#include "video.h" -#include "i18n.h" -#include "timers.h" - -class VTimerEdit : public View +#include "tbboxx.h" +#include "wbutton.h" + +class VTimerList; +class RecTimer; +class Message; + +class VTimerEdit : public TBBoxx { public: VTimerEdit(RecTimer* rt); ~VTimerEdit(); + void draw(); int handleCommand(int command); void processMessage(Message* m); + void setParent(VTimerList* tvTimerList); private: + void swap(); RecTimer* recTimer; - + VTimerList* vTimerList; + WButton buttonBack; + WButton buttonDelete; + UINT selectedButton; }; #endif + diff --git a/vtimerlist.cc b/vtimerlist.cc index 3d28051..e00a8c5 100644 --- a/vtimerlist.cc +++ b/vtimerlist.cc @@ -20,6 +20,19 @@ #include "vtimerlist.h" +#include "message.h" +#include "remote.h" +#include "wsymbol.h" +#include "colour.h" +#include "video.h" +#include "i18n.h" +#include "timers.h" +#include "vtimeredit.h" +#include "command.h" +#include "boxstack.h" +#include "vdr.h" +#include "vinfo.h" + VTimerList::VTimerList() { recTimerList = NULL; @@ -36,67 +49,71 @@ VTimerList::VTimerList() flipflop = true; - create(570, 420); + setSize(570, 420); + createBuffer(); if (Video::getInstance()->getFormat() == Video::PAL) { - setScreenPos(80, 70); + setPosition(80, 70); } else { - setScreenPos(70, 35); + setPosition(70, 35); } - - setBackgroundColour(Colour::VIEWBACKGROUND); setTitleBarOn(1); setTitleText(tr("Timers")); setTitleBarColour(Colour::TITLEBARBACKGROUND); - sl.setSurface(surface); - sl.setSurfaceOffset(30, 30 + 5); - sl.setDimensions(area.w - 40, area.h - 30 - 15 - 30); + sl.setPosition(30, 30 + 5); + sl.setSize(area.w - 40, area.h - 30 - 15 - 30); + add(&sl); +} + +VTimerList::~VTimerList() +{ + Timers::getInstance()->cancelTimer(this, 1); + if (recTimerList) + { + for (UINT i = 0; i < recTimerList->size(); i++) + { + delete (*recTimerList)[i]; + } + + recTimerList->clear(); + delete recTimerList; + } +} +void VTimerList::draw() +{ // Draw statics - draw(); // View::draw + TBBoxx::draw(); WSymbol w; - w.setSurface(surface); + TEMPADD(&w); w.nextSymbol = WSymbol::UP; - w.setSurfaceOffset(20, 385); + w.setPosition(20, 385); w.draw(); w.nextSymbol = WSymbol::DOWN; - w.setSurfaceOffset(50, 385); + w.setPosition(50, 385); w.draw(); w.nextSymbol = WSymbol::SKIPBACK; - w.setSurfaceOffset(85, 385); + w.setPosition(85, 385); w.draw(); w.nextSymbol = WSymbol::SKIPFORWARD; - w.setSurfaceOffset(115, 385); + w.setPosition(115, 385); w.draw(); drawTextRJ("[ok] = edit", 560, 385, Colour::LIGHTTEXT); drawClock(); -} - -VTimerList::~VTimerList() -{ - Timers::getInstance()->cancelTimer(this, 1); - if (recTimerList) - { - for (UINT i = 0; i < recTimerList->size(); i++) - { - delete (*recTimerList)[i]; - } - - recTimerList->clear(); - delete recTimerList; - } + drawShowing(); + drawIndicators(); } bool VTimerList::load() @@ -129,10 +146,6 @@ bool VTimerList::load() first = 0; } - sl.draw(); - drawShowing(); - drawIndicators(); - ViewMan::getInstance()->updateView(this); return true; } @@ -184,7 +197,6 @@ void VTimerList::drawIndicators() { if (flipflop) { - //rectangle(6, ypos, 18, 16, Colour::RED); rectangle(6, ypos, 18, 16, Colour::RED); drawText("R", 8, ypos-3, Colour::LIGHTTEXT); } @@ -214,7 +226,7 @@ void VTimerList::timercall(int clientReference) Message* m = new Message(); m->message = Message::REDRAW; - m->to = ViewMan::getInstance(); + m->to = BoxStack::getInstance(); m->from = this; m->parameter = (ULONG)&clockRegion; Command::getInstance()->postMessageFromOuterSpace(m); @@ -224,7 +236,7 @@ void VTimerList::timercall(int clientReference) m = new Message(); m->message = Message::REDRAW; - m->to = ViewMan::getInstance(); + m->to = BoxStack::getInstance(); m->from = this; m->parameter = (ULONG)&indicatorsRegion; Command::getInstance()->postMessageFromOuterSpace(m); @@ -241,7 +253,7 @@ int VTimerList::handleCommand(int command) sl.draw(); drawShowing(); drawIndicators(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); return 2; } case Remote::DF_DOWN: @@ -251,7 +263,7 @@ int VTimerList::handleCommand(int command) sl.draw(); drawShowing(); drawIndicators(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); return 2; } case Remote::SKIPBACK: @@ -260,7 +272,7 @@ int VTimerList::handleCommand(int command) sl.draw(); drawShowing(); drawIndicators(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); return 2; } case Remote::SKIPFORWARD: @@ -269,28 +281,20 @@ int VTimerList::handleCommand(int command) sl.draw(); drawShowing(); drawIndicators(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); return 2; } case Remote::OK: { RecTimer* recTimer = NULL; if (recTimerList) recTimer = (RecTimer*)sl.getCurrentOptionData(); -// { -// int currentOption = sl.getCurrentOption(); -// -// for (UINT i = 0; i < recTimerList->size(); i++) -// { -// recTimer = (*recTimerList)[i]; -// if (currentOption == recTimer->index) break; -// } -// } - if (recTimer == NULL) return 2; VTimerEdit* v = new VTimerEdit(recTimer); - ViewMan::getInstance()->add(v); - ViewMan::getInstance()->updateView(v); + v->setParent(this); + v->draw(); + BoxStack::getInstance()->add(v); + BoxStack::getInstance()->update(v); return 2; } @@ -310,24 +314,82 @@ void VTimerList::processMessage(Message* m) if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) { sl.draw(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(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 + 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>getWidth() || y>getHeight()) + if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight()) { - ViewMan::getInstance()->handleCommand(Remote::BACK); //simulate cancel press + BoxStack::getInstance()->handleCommand(Remote::BACK); //simulate cancel press } } } + else if (m->message == Message::DELETE_SELECTED_TIMER) + { + RecTimer* recTimer = (RecTimer*)sl.getCurrentOptionData(); + if (recTimer == NULL) return; + Log::getInstance()->log("VTimerList", Log::DEBUG, "Got timer to delete"); + + + ULONG retval = VDR::getInstance()->deleteTimer(recTimer); + Log::getInstance()->log("VTimerList", Log::DEBUG, "Got return fron delete timer: %lu", retval); + + if (retval != 10) + { + VInfo* errorBox = new VInfo(); + errorBox->setSize(360, 200); + errorBox->createBuffer(); + if (Video::getInstance()->getFormat() == Video::PAL) + errorBox->setPosition(190, 170); + else + errorBox->setPosition(180, 120); + + + if (retval == 1) errorBox->setOneLiner(tr("Timers being edited at VDR, please try later")); + else if (retval == 3) errorBox->setOneLiner(tr("Unable to delete timer - timer is running")); + else if (retval == 4) errorBox->setOneLiner(tr("Error - timer not found at VDR")); + else errorBox->setOneLiner(tr("Unknown error")); + + errorBox->setExitable(); + errorBox->setBorderOn(1); + errorBox->setTitleBarColour(Colour::DANGER); + errorBox->okButton(); + errorBox->draw(); + BoxStack::getInstance()->add(errorBox); + BoxStack::getInstance()->update(errorBox); + } + + int saveIndex = sl.getCurrentOption(); + int saveTop = sl.getTopOption(); + + if (recTimerList) + { + for (UINT i = 0; i < recTimerList->size(); i++) + { + delete (*recTimerList)[i]; + } + + recTimerList->clear(); + delete recTimerList; + } + + sl.clear(); + load(); + + sl.hintSetCurrent(saveIndex); + sl.hintSetTop(saveTop); + draw(); + BoxStack::getInstance()->update(this); + } } + diff --git a/vtimerlist.h b/vtimerlist.h index 2a25168..53e0fa9 100644 --- a/vtimerlist.h +++ b/vtimerlist.h @@ -25,19 +25,15 @@ #include #include -#include "view.h" -#include "wselectlist.h" -#include "remote.h" -#include "wsymbol.h" -#include "viewman.h" +#include "tbboxx.h" +#include "timerreceiver.h" #include "vdr.h" -#include "colour.h" -#include "video.h" -#include "i18n.h" -#include "timers.h" -#include "vtimeredit.h" +#include "wselectlist.h" +#include "region.h" + +class Message; -class VTimerList : public View, public TimerReceiver +class VTimerList : public TBBoxx, public TimerReceiver { public: VTimerList(); @@ -47,6 +43,7 @@ class VTimerList : public View, public TimerReceiver void timercall(int clientReference); void processMessage(Message* m); bool load(); + void draw(); private: RecTimerList* recTimerList; diff --git a/vvideolive.cc b/vvideolive.cc index aff2612..5d6ccee 100644 --- a/vvideolive.cc +++ b/vvideolive.cc @@ -20,13 +20,31 @@ #include "vvideolive.h" +#include "vchannellist.h" +#include "video.h" +#include "player.h" +#include "playerradio.h" +#include "channel.h" +#include "vlivebanner.h" +#include "boxstack.h" +#include "vchannelselect.h" +#include "colour.h" +#include "osd.h" +#include "vinfo.h" +#include "command.h" +#include "i18n.h" +#include "vepg.h" +#include "wtextbox.h" +#include "remote.h" +#include "vaudioselector.h" + VVideoLive* VVideoLive::instance = NULL; VVideoLive::VVideoLive(ChannelList* tchanList, ULONG tstreamType, VChannelList* tvchannelList) { instance = this; vdr = VDR::getInstance(); - viewman = ViewMan::getInstance(); + boxstack = BoxStack::getInstance(); video = Video::getInstance(); chanList = tchanList; @@ -50,9 +68,10 @@ VVideoLive::VVideoLive(ChannelList* tchanList, ULONG tstreamType, VChannelList* ((Player*)player)->init(); } - create(video->getScreenWidth(), video->getScreenHeight()); + setSize(video->getScreenWidth(), video->getScreenHeight()); + createBuffer(); Colour transparent(0, 0, 0, 0); - setBackgroundColour(transparent); + fillColour(transparent); dowss = false; char* optionWSS = vdr->configLoad("General", "WSS"); @@ -64,8 +83,8 @@ VVideoLive::VVideoLive(ChannelList* tchanList, ULONG tstreamType, VChannelList* Log::getInstance()->log("VVideoLive", Log::DEBUG, "Do WSS: %u", dowss); wss.setFormat(video->getFormat()); - wss.setSurface(surface); wss.setWide(true); + add(&wss); wssRegion.x = 0; wssRegion.y = 6; @@ -93,11 +112,6 @@ VVideoLive* VVideoLive::getInstance() return instance; } -void VVideoLive::draw() -{ - View::draw(); -} - int VVideoLive::handleCommand(int command) { switch(command) @@ -173,21 +187,31 @@ int VVideoLive::handleCommand(int command) { VChannelSelect* v = new VChannelSelect(this); v->draw(); - viewman->add(v); - viewman->updateView(v); + boxstack->add(v); + boxstack->update(v); v->handleCommand(command); return 2; } + case Remote::GREEN: + { + if (streamType == VDR::VIDEO) + { + VAudioSelector* vas = new VAudioSelector(this, (*chanList)[currentChannel], ((Player*)player)->getCurrentAudioChannel()); + vas->setBackgroundColour(Colour::VIEWBACKGROUND); + vas->setPosition(0, getHeight()-200); + vas->draw(); + BoxStack::getInstance()->add(vas); + BoxStack::getInstance()->update(vas); + } + } #ifdef DEV case Remote::YELLOW: { - break; } case Remote::BLUE: { - break; } #endif } @@ -249,7 +273,7 @@ void VVideoLive::channelChange(UCHAR changeType, UINT newData) { vlb->setChannel((*chanList)[currentChannel]); vlb->draw(); - viewman->updateView(vlb); + boxstack->update(vlb); } play(); @@ -266,7 +290,7 @@ void VVideoLive::processMessage(Message* m) { if (m->message == Message::MOUSE_LBDOWN) { - ViewMan::getInstance()->handleCommand(Remote::OK); //simulate rok press + BoxStack::getInstance()->handleCommand(Remote::OK); //simulate rok press } else if (m->message == Message::CHANNEL_CHANGE) { @@ -282,6 +306,11 @@ void VVideoLive::processMessage(Message* m) video->setMode(videoMode); if (saveUnavailable) showUnavailable(1); } + else if (m->message == Message::AUDIO_CHANGE_CHANNEL) + { + Log::getInstance()->log("VVideoLive", Log::DEBUG, "Received change audio channel to %i", m->parameter); + ((Player*)player)->setAudioChannel(m->parameter); + } else if (m->message == Message::PLAYER_EVENT) { switch(m->parameter) @@ -312,7 +341,7 @@ void VVideoLive::processMessage(Message* m) Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 43"); wss.setWide(false); wss.draw(); - ViewMan::getInstance()->updateView(this, &wssRegion); + BoxStack::getInstance()->update(this, &wssRegion); } break; } @@ -323,7 +352,7 @@ void VVideoLive::processMessage(Message* m) Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 169"); wss.setWide(true); wss.draw(); - ViewMan::getInstance()->updateView(this, &wssRegion); + BoxStack::getInstance()->update(this, &wssRegion); } break; } @@ -340,8 +369,8 @@ void VVideoLive::doBanner(bool bannerTakesCommands) VLiveBanner* vlb = new VLiveBanner(this, (*chanList)[currentChannel], bannerTakesCommands); vlb->draw(); - viewman->add(vlb); - viewman->updateView(vlb); + boxstack->add(vlb); + boxstack->update(vlb); } void VVideoLive::doNoSuchChannel() @@ -359,26 +388,27 @@ void VVideoLive::showUnavailable(int active) unavailable = 1; unavailableView = new VInfo(); - unavailableView->create(400, 200); + unavailableView->setSize(400, 200); + unavailableView->createBuffer(); if (video->getFormat() == Video::PAL) { - unavailableView->setScreenPos(170, 200); + unavailableView->setPosition(170, 200); } else { - unavailableView->setScreenPos(160, 150); + unavailableView->setPosition(160, 150); } unavailableView->setTitleText((*chanList)[currentChannel]->name); unavailableView->setOneLiner(tr("Channel unavailable")); unavailableView->setDropThrough(); unavailableView->draw(); - viewman->add(unavailableView); - viewman->updateView(unavailableView); + boxstack->add(unavailableView); + boxstack->update(unavailableView); } else { unavailable = 0; - viewman->removeView(unavailableView); + boxstack->remove(unavailableView); unavailableView = NULL; } } @@ -419,7 +449,7 @@ void VVideoLive::play(int noShowVLB) void VVideoLive::stop(int noRemoveVLB) { if (unavailable) return; - if (!noRemoveVLB && VLiveBanner::getInstance()) viewman->removeView(VLiveBanner::getInstance()); // if live banner is present, remove it. won't cause damage if its not present + if (!noRemoveVLB && VLiveBanner::getInstance()) boxstack->remove(VLiveBanner::getInstance()); // if live banner is present, remove it. won't cause damage if its not present if (streamType == VDR::RADIO) { @@ -465,8 +495,8 @@ void VVideoLive::showEPG() VEpg* vepg = new VEpg(this, currentChannel, streamType); vepg->draw(); - viewman->add(vepg); - viewman->updateView(vepg); + boxstack->add(vepg); + boxstack->update(vepg); } void VVideoLive::toggleChopSides() @@ -484,3 +514,4 @@ void VVideoLive::toggleChopSides() video->setMode(Video::NORMAL); } } + diff --git a/vvideolive.h b/vvideolive.h index 6a8354f..be76ab5 100644 --- a/vvideolive.h +++ b/vvideolive.h @@ -24,34 +24,25 @@ #include #include -#include "view.h" -#include "player.h" -#include "playerradio.h" -#include "vdr.h" -#include "channel.h" -#include "vlivebanner.h" -#include "viewman.h" -#include "vchannelselect.h" -#include "colour.h" -#include "osd.h" -#include "vinfo.h" -#include "command.h" -#include "i18n.h" -#include "vepg.h" -#include "wtextbox.h" +#include "boxx.h" +#include "region.h" #include "wwss.h" +#include "vdr.h" class VEpg; class VChannelList; class VLiveBanner; +class VInfo; +class Video; +class VChannelList; +class BoxStack; -class VVideoLive : public View +class VVideoLive : public Boxx { public: VVideoLive(ChannelList* chanList, ULONG streamType, VChannelList* vchannelList); ~VVideoLive(); static VVideoLive* getInstance(); - void draw(); int handleCommand(int command); void processMessage(Message* m); void streamEnd(); // from command @@ -73,7 +64,7 @@ class VVideoLive : public View private: static VVideoLive* instance; - // ViewMan* viewman; + BoxStack* boxstack; VDR* vdr; Video* video; void* player; // HA HA FIXME diff --git a/vvideorec.cc b/vvideorec.cc index 6e7c4a8..e85ad5e 100644 --- a/vvideorec.cc +++ b/vvideorec.cc @@ -20,13 +20,30 @@ #include "vvideorec.h" +#include "command.h" +#include "osd.h" +#include "wsymbol.h" +#include "audio.h" +#include "vdr.h" +#include "video.h" +#include "timers.h" +#include "player.h" +#include "recording.h" +#include "vaudioselector.h" +#include "message.h" +#include "remote.h" +#include "boxstack.h" +#include "vinfo.h" +#include "i18n.h" + VVideoRec::VVideoRec(Recording* rec) { - viewman = ViewMan::getInstance(); + boxstack = BoxStack::getInstance(); vdr = VDR::getInstance(); video = Video::getInstance(); timers = Timers::getInstance(); vas = NULL; + vsummary = NULL; player = new Player(Command::getInstance(), this, true); player->init(); @@ -62,7 +79,8 @@ VVideoRec::VVideoRec(Recording* rec) Log::getInstance()->log("VVideoRec", Log::DEBUG, "SM: %u EM: %u", startMargin, endMargin); - create(video->getScreenWidth(), video->getScreenHeight()); + setSize(video->getScreenWidth(), video->getScreenHeight()); + createBuffer(); transparent.set(0, 0, 0, 0); setBackgroundColour(transparent); @@ -94,15 +112,9 @@ VVideoRec::VVideoRec(Recording* rec) Log::getInstance()->log("VVideoRec", Log::DEBUG, "Do WSS: %u", dowss); wss.setFormat(video->getFormat()); - wss.setSurface(surface); wss.setWide(true); + add(&wss); -/* - wssRegion.x = 0; - wssRegion.y = 6; - wssRegion.w = video->getScreenWidth(); - wssRegion.h = 2; -*/ wssRegion.x = 0; wssRegion.y = 0; wssRegion.w = video->getScreenWidth(); @@ -111,12 +123,16 @@ VVideoRec::VVideoRec(Recording* rec) VVideoRec::~VVideoRec() { + Log::getInstance()->log("VVideoRec", Log::DEBUG, "Entering vvideorec destructor"); + if (vas) { - viewman->removeView(vas); + boxstack->remove(vas); vas = NULL; } + if (vsummary) delete vsummary; + if (playing) stopPlay(); video->setDefaultAspect(); @@ -129,11 +145,6 @@ VVideoRec::~VVideoRec() // rec->recInfo->resumePoint - this will fix the ~10s offset problem as well } -void VVideoRec::draw() -{ - View::draw(); -} - void VVideoRec::go(bool resume) { ULONG startFrameNum; @@ -167,15 +178,16 @@ void VVideoRec::go(bool resume) Message* m = new Message(); m->message = Message::CLOSE_ME; m->from = this; - m->to = viewman; + m->to = boxstack; Command::getInstance()->postMessageNoLock(m); VInfo* vi = new VInfo(); - vi->create(400, 150); + vi->setSize(400, 150); + vi->createBuffer(); if (video->getFormat() == Video::PAL) - vi->setScreenPos(170, 200); + vi->setPosition(170, 200); else - vi->setScreenPos(160, 150); + vi->setPosition(160, 150); vi->setExitable(); vi->setBorderOn(1); vi->setTitleBarOn(0); @@ -184,7 +196,7 @@ void VVideoRec::go(bool resume) m = new Message(); m->message = Message::ADD_VIEW; - m->to = viewman; + m->to = boxstack; m->parameter = (ULONG)vi; Command::getInstance()->postMessageNoLock(m); } @@ -201,8 +213,15 @@ int VVideoRec::handleCommand(int command) return 2; } - case Remote::STOP: case Remote::BACK: + { + if (vsummary) + { + removeSummary(); + return 2; + } + } // DROP THROUGH + case Remote::STOP: case Remote::MENU: { if (playing) stopPlay(); @@ -239,6 +258,17 @@ int VVideoRec::handleCommand(int command) doBar(0); return 2; } + case Remote::RED: + { + if (vsummary) removeSummary(); + else doSummary(); + return 2; + } + case Remote::GREEN: + { + doAudioSelector(); + return 2; + } case Remote::YELLOW: { if (myRec->hasMarks()) @@ -299,11 +329,6 @@ int VVideoRec::handleCommand(int command) player->skipForward(10); return 2; } - case Remote::GREEN: - { - doAudioSelector(); - return 2; - } case Remote::FULL: case Remote::TV: { @@ -313,6 +338,12 @@ int VVideoRec::handleCommand(int command) case Remote::OK: { + if (vsummary) + { + removeSummary(); + return 2; + } + if (barShowing) removeBar(); else doBar(0); return 2; @@ -330,8 +361,8 @@ int VVideoRec::handleCommand(int command) case Remote::NINE: player->jumpToPercent(90); doBar(0); return 2; #ifdef DEV - case Remote::RED: - { +// case Remote::RED: +// { //Don't use RED for anything. It will eventually be recording summary //player->test1(); @@ -343,12 +374,12 @@ int VVideoRec::handleCommand(int command) Video::getInstance()->setPosition(170, 5); VEpg* vepg = new VEpg(NULL, 0); vepg->draw(); - ViewMan::getInstance()->add(vepg); - ViewMan::getInstance()->updateView(vepg); + BoxStack::getInstance()->add(vepg); + BoxStack::getInstance()->update(vepg); */ - return 2; - } +// return 2; +// } #endif @@ -368,7 +399,7 @@ void VVideoRec::processMessage(Message* m) if (!barShowing) { - ViewMan::getInstance()->handleCommand(Remote::OK); //simulate rok press + BoxStack::getInstance()->handleCommand(Remote::OK); //simulate rok press } else if (barRegion.x<=x && barRegion.y<=y && (barRegion.x+barRegion.w)>=x && (barRegion.y+barRegion.h)>=y) { @@ -426,7 +457,7 @@ void VVideoRec::processMessage(Message* m) } else { - ViewMan::getInstance()->handleCommand(Remote::OK); //simulate rok press + BoxStack::getInstance()->handleCommand(Remote::OK); //simulate rok press } } else if (m->from == player) @@ -459,7 +490,7 @@ void VVideoRec::processMessage(Message* m) Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 43"); wss.setWide(false); wss.draw(); - viewman->updateView(this, &wssRegion); + boxstack->update(this, &wssRegion); } break; } @@ -470,7 +501,7 @@ void VVideoRec::processMessage(Message* m) Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 169"); wss.setWide(true); wss.draw(); - viewman->updateView(this, &wssRegion); + boxstack->update(this, &wssRegion); } break; } @@ -541,25 +572,18 @@ void VVideoRec::doAudioSelector() availableAc3AudioChannels = player->getDemuxerAc3AudioChannels(); } - vas = new VAudioSelector(this, availableMpegAudioChannels,availableAc3AudioChannels, currentAudioChannel, myRec->recInfo); + vas = new VAudioSelector(this, availableMpegAudioChannels, availableAc3AudioChannels, currentAudioChannel, myRec->recInfo); vas->setBackgroundColour(barBlue); - if (video->getFormat() == Video::PAL) - { -// vas->setScreenPos(62, barRegion.y - 120); - vas->setScreenPos(0, barRegion.y - 120); - } - else - { -// vas->setScreenPos(57, barRegion.y - 120); - vas->setScreenPos(0, barRegion.y - 120); - } + vas->setPosition(0, barRegion.y - 120); + +// pal 62, ntsc 57 barVasHold = true; doBar(0); vas->draw(); - viewman->add(vas); - viewman->updateView(vas); + boxstack->add(vas); + boxstack->update(vas); } void VVideoRec::doBar(int action) @@ -585,9 +609,9 @@ void VVideoRec::doBar(int action) */ WSymbol w; - w.setSurface(surface); + TEMPADD(&w); w.nextSymbol = 0; - w.setSurfaceOffset(barRegion.x + 66, barRegion.y + 16); + w.setPosition(barRegion.x + 66, barRegion.y + 16); UCHAR playerState = 0; @@ -624,7 +648,7 @@ void VVideoRec::doBar(int action) drawBarClocks(); - viewman->updateView(this, &barRegion); + boxstack->update(this, &barRegion); timers->cancelTimer(this, 1); @@ -654,7 +678,7 @@ void VVideoRec::timercall(int clientReference) drawBarClocks(); Message* m = new Message(); m->message = Message::REDRAW; - m->to = ViewMan::getInstance(); + m->to = BoxStack::getInstance(); m->from = this; m->parameter = (ULONG)&barRegion; Command::getInstance()->postMessageFromOuterSpace(m); @@ -806,8 +830,44 @@ void VVideoRec::removeBar() Message* m = new Message(); m->message = Message::REDRAW; - m->to = ViewMan::getInstance(); + m->to = BoxStack::getInstance(); m->from = this; m->parameter = (ULONG)&barRegion; Command::getInstance()->postMessageFromOuterSpace(m); } + +void VVideoRec::doSummary() +{ + vsummary = new VInfo(); + vsummary->setTitleText(myRec->getProgName()); + vsummary->setBorderOn(1); + vsummary->setExitable(); + if (myRec->recInfo->summary) vsummary->setMainText(myRec->recInfo->summary); + else vsummary->setMainText(tr("Summary unavailable")); + if (Video::getInstance()->getFormat() == Video::PAL) + { + vsummary->setPosition(120, 130); + } + else + { + vsummary->setPosition(110, 90); + } + vsummary->setSize(510, 270); + add(vsummary); + vsummary->draw(); + + BoxStack::getInstance()->update(this); +} + +void VVideoRec::removeSummary() +{ + if (vsummary) + { + remove(vsummary); + delete vsummary; + vsummary = NULL; + draw(); + BoxStack::getInstance()->update(this); + } +} + diff --git a/vvideorec.h b/vvideorec.h index 0901436..e51f071 100644 --- a/vvideorec.h +++ b/vvideorec.h @@ -23,31 +23,29 @@ #include -#include "video.h" -#include "view.h" -#include "player.h" -#include "vdr.h" -#include "recording.h" -#include "command.h" -#include "colour.h" -#include "osd.h" -#include "timers.h" +#include "boxx.h" #include "timerreceiver.h" -#include "message.h" #include "wwss.h" -#include "vaudioselector.h" - -//#include "vepg.h" // for testing EPG in NTSC with a NTSC test video +#include "region.h" +#include "colour.h" +class VDR; +class Video; class Timers; +class Player; +class Recording; class VAudioSelector; +class Message; +class BoxStack; +class VInfo; + +//#include "vepg.h" // for testing EPG in NTSC with a NTSC test video -class VVideoRec : public View, public TimerReceiver +class VVideoRec : public Boxx, public TimerReceiver { public: VVideoRec(Recording* rec); ~VVideoRec(); - void draw(); int handleCommand(int command); void go(bool resume); @@ -55,7 +53,7 @@ class VVideoRec : public View, public TimerReceiver void processMessage(Message* m); private: - // ViewMan* viewman; + BoxStack* boxstack; VDR* vdr; Video* video; Timers* timers; @@ -82,6 +80,8 @@ class VVideoRec : public View, public TimerReceiver void drawBarClocks(); void stopPlay(); void removeBar(); + void doSummary(); + void removeSummary(); Region barRegion; Region clocksRegion; @@ -91,6 +91,8 @@ class VVideoRec : public View, public TimerReceiver Wwss wss; Region wssRegion; bool dowss; + + VInfo* vsummary; }; #endif diff --git a/vvolume.cc b/vvolume.cc index d7e684d..df3316b 100644 --- a/vvolume.cc +++ b/vvolume.cc @@ -20,21 +20,29 @@ #include "vvolume.h" +#include "remote.h" +#include "audio.h" +#include "wsymbol.h" +#include "colour.h" +#include "video.h" +#include "timers.h" +#include "boxstack.h" +#include "command.h" + VVolume::VVolume() { displayVolume = Audio::getInstance()->getVolume(); - create(227, 31); + setSize(227, 31); + createBuffer(); if (Video::getInstance()->getFormat() == Video::PAL) { - setScreenPos(100, 499); + setPosition(100, 499); } else { - setScreenPos(90, 400); + setPosition(90, 400); } - - setBackgroundColour(Colour::VIEWBACKGROUND); } VVolume::~VVolume() @@ -45,12 +53,14 @@ VVolume::~VVolume() void VVolume::draw() { - View::draw(); + Boxx::draw(); + + fillColour(Colour::VIEWBACKGROUND); WSymbol w; - w.setSurface(surface); + TEMPADD(&w); w.nextSymbol = WSymbol::VOLUME2; - w.setSurfaceOffset(3, 10); + w.setPosition(3, 10); w.draw(); int i = 0; @@ -58,14 +68,14 @@ void VVolume::draw() for(; i < displayVolume; i++) { w.nextSymbol = WSymbol::VOLBAR; - w.setSurfaceOffset(40 + (i * 9), 3); + w.setPosition(40 + (i * 9), 3); w.draw(); } for(; i < 20; i++) { w.nextSymbol = WSymbol::VOLDOT; - w.setSurfaceOffset(40 + (i * 9), 13); + w.setPosition(40 + (i * 9), 13); w.draw(); } @@ -77,7 +87,7 @@ void VVolume::timercall(int clientReference) // delete me! Message* m = new Message(); // Delete self m->message = Message::CLOSE_ME; - m->to = ViewMan::getInstance(); + m->to = BoxStack::getInstance(); m->from = this; Command::getInstance()->postMessageFromOuterSpace(m); } @@ -91,7 +101,7 @@ int VVolume::handleCommand(int command) { displayVolume = Audio::getInstance()->volumeDown(); draw(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); // handled return 2; } @@ -100,7 +110,7 @@ int VVolume::handleCommand(int command) { displayVolume = Audio::getInstance()->volumeUp(); draw(); - ViewMan::getInstance()->updateView(this); + BoxStack::getInstance()->update(this); // handled return 2; } diff --git a/vvolume.h b/vvolume.h index ce24717..80dd518 100644 --- a/vvolume.h +++ b/vvolume.h @@ -23,17 +23,10 @@ #include -#include "view.h" -#include "remote.h" -#include "audio.h" -#include "wsymbol.h" -#include "colour.h" -#include "video.h" +#include "boxx.h" #include "timerreceiver.h" -#include "timers.h" -#include "viewman.h" -class VVolume : public View, public TimerReceiver +class VVolume : public Boxx, public TimerReceiver { public: VVolume(); diff --git a/vwelcome.cc b/vwelcome.cc index b2bc219..2f5b31f 100644 --- a/vwelcome.cc +++ b/vwelcome.cc @@ -20,32 +20,48 @@ #include "vwelcome.h" +#include "remote.h" +#include "vdr.h" +#include "vchannellist.h" +#include "vrecordinglist.h" +#include "vtimerlist.h" +#include "command.h" +#include "message.h" +#include "colour.h" +#include "video.h" +#include "i18n.h" +#include "timers.h" +#include "vscreensaver.h" +#include "vmedialist.h" +#include "boxstack.h" +#include "vopts.h" + VWelcome::VWelcome() { - viewman = ViewMan::getInstance(); + boxstack = BoxStack::getInstance(); clockRegion.x = 400; clockRegion.y = 0; clockRegion.w = 60; clockRegion.h = 30; - create(460, 220); + setSize(460, 220); + createBuffer(); if (Video::getInstance()->getFormat() == Video::PAL) { - setScreenPos(140, 170); + setPosition(140, 170); } else { - setScreenPos(130, 140); + setPosition(130, 140); } - setBackgroundColour(Colour::VIEWBACKGROUND); setTitleBarOn(1); setTitleBarColour(Colour::TITLEBARBACKGROUND); - sl.setSurface(surface); - sl.setSurfaceOffset(20, 40); - sl.setDimensions(200, 160); + sl.setPosition(20, 40); + sl.setSize(200, 160); + add(&sl); setTitleText(tr("Welcome")); sl.addOption(tr("1. Live TV"), 1, 1); @@ -56,8 +72,9 @@ VWelcome::VWelcome() sl.addOption(tr("6. Options"), 6, 0); sl.addOption(tr("7. Reboot"), 7, 0); - jpeg.setSurface(surface); - jpeg.setSurfaceOffset(240, 60); + jpeg.setPosition(240, 60); + jpeg.init("/vdr.jpg"); + add(&jpeg); } VWelcome::~VWelcome() @@ -67,10 +84,7 @@ VWelcome::~VWelcome() void VWelcome::draw() { - View::draw(); - sl.draw(); - jpeg.init("/vdr.jpg"); - jpeg.draw(); + TBBoxx::draw(); drawClock(); } @@ -97,10 +111,10 @@ void VWelcome::drawClock() void VWelcome::timercall(int clientReference) { drawClock(); - // Put updateView through master mutex since viewman is not mutex protected + // Put updateView through master mutex since boxstack is not mutex protected Message* m = new Message(); m->message = Message::REDRAW; - m->to = ViewMan::getInstance(); + m->to = boxstack; m->from = this; m->parameter = (ULONG)&clockRegion; Command::getInstance()->postMessageFromOuterSpace(m); @@ -115,7 +129,7 @@ int VWelcome::handleCommand(int command) { sl.up(); sl.draw(); - viewman->updateView(this); + boxstack->update(this); return 2; } case Remote::DF_DOWN: @@ -123,7 +137,7 @@ int VWelcome::handleCommand(int command) { sl.down(); sl.draw(); - viewman->updateView(this); + boxstack->update(this); return 2; } case Remote::ONE: @@ -204,9 +218,9 @@ int VWelcome::handleCommand(int command) case Remote::NINE: { VScreensaver* vscreensaver = new VScreensaver(); - viewman->add(vscreensaver); + boxstack->add(vscreensaver); vscreensaver->draw(); -// viewman->updateView(vscreensaver); +// boxstack->update(vscreensaver); return 2; } @@ -232,8 +246,8 @@ void VWelcome::doChannelsList() vchan->setList(chanList); vchan->draw(); - viewman->add(vchan); - viewman->updateView(vchan); + boxstack->add(vchan); + boxstack->update(vchan); } else { @@ -251,8 +265,8 @@ void VWelcome::doRadioList() vchan->setList(chanList); vchan->draw(); - viewman->add(vchan); - viewman->updateView(vchan); + boxstack->add(vchan); + boxstack->update(vchan); } else { @@ -264,8 +278,8 @@ void VWelcome::doRecordingsList() { VRecordingList* vrec = new VRecordingList(); vrec->draw(); - viewman->add(vrec); - viewman->updateView(vrec); + boxstack->add(vrec); + boxstack->update(vrec); if (!vrec->load()) { @@ -277,24 +291,33 @@ void VWelcome::doMediaList() { VMediaList::createList(); } + void VWelcome::doTimersList() { VTimerList* vtl = new VTimerList(); - viewman->add(vtl); - viewman->updateView(vtl); - if (!vtl->load()) { + delete vtl; Command::getInstance()->connectionLost(); + return; } + + vtl->draw(); + boxstack->add(vtl); + boxstack->update(vtl); } void VWelcome::doOptions() { - VOptionsMenu* voptionsmenu = new VOptionsMenu(); - voptionsmenu->draw(); - viewman->add(voptionsmenu); - viewman->updateView(voptionsmenu); +// VOptionsMenu* voptionsmenu = new VOptionsMenu(); +// voptionsmenu->draw(); +// boxstack->add(voptionsmenu); +// boxstack->updateView(voptionsmenu); + + VOpts* vopts = new VOpts(); + vopts->draw(); + boxstack->add(vopts); + boxstack->update(vopts); } void VWelcome::processMessage(Message* m) @@ -304,14 +327,14 @@ void VWelcome::processMessage(Message* m) if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) { sl.draw(); - viewman->updateView(this); + boxstack->update(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 + boxstack->handleCommand(Remote::OK); //simulate OK press } } } diff --git a/vwelcome.h b/vwelcome.h index 56f7b14..d078cb4 100644 --- a/vwelcome.h +++ b/vwelcome.h @@ -24,31 +24,23 @@ #include #include -#include "view.h" -#include "remote.h" +#include "tbboxx.h" +#include "timerreceiver.h" #include "wselectlist.h" #include "wjpeg.h" -#include "viewman.h" -#include "vdr.h" -#include "vchannellist.h" -#include "vrecordinglist.h" -#include "vtimerlist.h" -#include "command.h" -#include "message.h" -#include "colour.h" -#include "video.h" -#include "voptionsmenu.h" -#include "i18n.h" -#include "timers.h" -#include "vscreensaver.h" -#include "vmedialist.h" - -class VWelcome : public View, public TimerReceiver +#include "region.h" + +class Message; +class BoxStack; + +class VWelcome : public TBBoxx, public TimerReceiver { public: VWelcome(); ~VWelcome(); + void create(); + int handleCommand(int command); void processMessage(Message* m); void draw(); @@ -58,7 +50,7 @@ class VWelcome : public View, public TimerReceiver WSelectList sl; WJpeg jpeg; - // ViewMan* viewman; + BoxStack* boxstack; void doChannelsList(); void doRadioList(); diff --git a/wbutton.cc b/wbutton.cc index e638c9a..03faf47 100644 --- a/wbutton.cc +++ b/wbutton.cc @@ -20,14 +20,17 @@ #include "wbutton.h" +#include "colour.h" + WButton::WButton() { int fontHeight = Surface::getFontHeight(); - setDimensions(70, fontHeight); + setSize(70, fontHeight); mytext = NULL; active = 0; tag = 0; + dimmed = false; } WButton::~WButton() @@ -35,7 +38,7 @@ WButton::~WButton() if (mytext) delete[] mytext; } -void WButton::setText(char* takeText) +void WButton::setText(const char* takeText) { int length = strlen(takeText); mytext = new char[length + 1]; @@ -44,12 +47,25 @@ void WButton::setText(char* takeText) void WButton::setActive(UCHAR tactive) { + dimmed = false; active = tactive; } +void WButton::dim() +{ + // a bolt on for now - an active but dimmed state + dimmed = true; + active = false; +} + void WButton::draw() { - if (active) + if (dimmed) + { + fillColour(Colour::BLACK); + drawText(mytext, 0, 0, Colour::SELECTHIGHLIGHT); + } + else if (active) { fillColour(Colour::SELECTHIGHLIGHT); drawText(mytext, 0, 0, Colour::DARKTEXT); @@ -71,23 +87,29 @@ int WButton::getTag() return tag; } +// Sorry, I've broken these in the boxx upgrade - chris + bool WButton::mouseMove(int x, int y) { +/* if ((x-offsetX)>=area.x && (y-offsetY)>=area.y && (x-offsetX)<=area.w && (y-offsetY)<=area.h && !active) { setActive(1); return true; } +*/ return false; } bool WButton::mouseLBDOWN(int x, int y) { +/* if ((x-offsetX)>=area.x && (y-offsetY)>=area.y && (x-offsetX)<=area.w && (y-offsetY)<=area.h && active) { return true; } +*/ return false; } diff --git a/wbutton.h b/wbutton.h index 14461aa..b84f3e1 100644 --- a/wbutton.h +++ b/wbutton.h @@ -25,16 +25,16 @@ #include #include "defines.h" -#include "widget.h" -#include "colour.h" +#include "boxx.h" -class WButton : public Widget +class WButton : public Boxx { public: WButton(); ~WButton(); - void setText(char* text); + void setText(const char* text); void setActive(UCHAR tactive); + void dim(); void draw(); void setTag(int tag); int getTag(); @@ -44,6 +44,7 @@ class WButton : public Widget private: UCHAR active; + bool dimmed; char* mytext; int tag; diff --git a/widget.cc b/widget.cc deleted file mode 100644 index 757ce56..0000000 --- a/widget.cc +++ /dev/null @@ -1,66 +0,0 @@ -/* - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "widget.h" - -Widget::Widget() -{ - backgroundColour = Colour::VIEWBACKGROUND; -} - -Widget::~Widget() -{ -} - -void Widget::setSurface(Surface* tsurface) -{ - surface = tsurface; -} - -void Widget::setDimensions(int twidth, int theight) -{ - area.w = twidth; - area.h = theight; -} - -void Widget::setBackgroundColour(Colour& Tcolour) -{ - backgroundColour = Tcolour; -} - -int Widget::getOffsetY() -{ - return offsetY; -} - -int Widget::getOffsetX() -{ - return offsetX; -} - -bool Widget::mouseMove(int x, int y) -{ - return false; -} - -bool Widget::mouseLBDOWN(int x, int y) -{ - return false; -} diff --git a/winmain.cc b/winmain.cc index 31ce101..882259e 100644 --- a/winmain.cc +++ b/winmain.cc @@ -39,7 +39,7 @@ #include "audiowin.h" #include "vdr.h" #include "osdwin.h" -#include "viewman.h" +#include "boxstack.h" #include "command.h" void sighandler(int signalReceived); @@ -53,7 +53,7 @@ Mtd* mtd; Led* led; Osd* osd; Timers* timers; -ViewMan* viewman; +BoxStack* boxstack; Command* command; VDR* vdr; Video* video; @@ -144,10 +144,10 @@ INT WINAPI WinMain( HINSTANCE hinst , HINSTANCE previnst, LPSTR cmdline, int cmd vdr = new VDR(); video = new VideoWin(); audio = new AudioWin(); - viewman = new ViewMan(); + boxstack = new BoxStack(); command = new Command(); - if (!logger || !remote || !mtd || !led || !osd || !video || !audio || !viewman || !command) + if (!logger || !remote || !mtd || !led || !osd || !video || !audio || !boxstack || !command) { ERROR_MSG("Could not create objects. Memory problems?\n"); shutdown(1); @@ -281,14 +281,14 @@ INT WINAPI WinMain( HINSTANCE hinst , HINSTANCE previnst, LPSTR cmdline, int cmd return 0; } - success = viewman->init(); + success = boxstack->init(); if (success) { - logger->log("Core", Log::INFO, "ViewMan module initialised"); + logger->log("Core", Log::INFO, "BoxStack module initialised"); } else { - logger->log("Core", Log::EMERG, "ViewMan module failed to initialise"); + logger->log("Core", Log::EMERG, "BoxStack module failed to initialise"); shutdown(1); WSACleanup(); return 0; @@ -659,7 +659,7 @@ LONG FAR PASCAL WindowProc(HWND wind, UINT msg, WPARAM wparam, LPARAM lparam) Message *mousemes=new Message(); mousemes->message=Message::MOUSE_MOVE; mousemes->from=NULL; - mousemes->to=ViewMan::getInstance(); + mousemes->to=BoxStack::getInstance(); mousemes->parameter=(mpos.x & 0xFFFF)<< 16| (mpos.y & 0xFFFF); mousemes->tag=0; //command->postMessageFromOuterSpace(mousemes); @@ -692,7 +692,7 @@ LONG FAR PASCAL WindowProc(HWND wind, UINT msg, WPARAM wparam, LPARAM lparam) Message *mousemes=new Message(); mousemes->message=Message::MOUSE_LBDOWN; mousemes->from=NULL; - mousemes->to=ViewMan::getInstance(); + mousemes->to=BoxStack::getInstance(); mousemes->parameter=(mpos.x & 0xFFFF)<< 16| (mpos.y & 0xFFFF); mousemes->tag=0; command->postMessageFromOuterSpace(mousemes); @@ -786,11 +786,11 @@ bool InitApp(HINSTANCE hinst,int cmdshow) { void shutdown(int code) { - if (viewman) + if (boxstack) { - viewman->shutdown(); - delete viewman; - logger->log("Core", Log::NOTICE, "ViewMan module shut down"); + boxstack->shutdown(); + delete boxstack; + logger->log("Core", Log::NOTICE, "BoxStack module shut down"); } if (command) // shut down command here in case views have posted messages @@ -878,4 +878,5 @@ ULLONG htonll(ULLONG a) return (((ULLONG)htonl((ULONG)((a<<32)>> 32))<<32) |(ULONG)htonl(((ULONG) (a >> 32)))); } -#endif \ No newline at end of file +#endif + diff --git a/wjpeg.cc b/wjpeg.cc index 4e750a0..4b1f55d 100644 --- a/wjpeg.cc +++ b/wjpeg.cc @@ -20,8 +20,10 @@ #include "wjpeg.h" #include -#include "i18n.h" +#include "i18n.h" +#include "log.h" +#include "surface.h" extern "C" void jpeg_memio_src (j_decompress_ptr cinfo, void * userdata); @@ -174,7 +176,7 @@ void WJpeg::drawPixel(int x, int y,int w,int h,int xpos, int ypos,Colour c){ Log::getInstance()->log("WJpeg:drawPixel",Log::ERR,"pixpos < 0 x=%d, y=%d",xb,yb); return; } - Box::drawPixel((UINT)xb,(UINT)yb,c); + Boxx::drawPixel((UINT)xb,(UINT)yb,c); } int WJpeg::drawJpeg() { @@ -284,8 +286,13 @@ int WJpeg::drawJpeg() { logger->log("BJpeg", Log::DEBUG, "JPEG startup done pw=%i ph=%i, xo=%i,yo=%i, iw=%i, ih=%i", picturew, pictureh,xpos,ypos,w,h); // Init the surface + +// Temp disabled for boxx. what does this do anyway .. - cjt +/* if (useImageDimensions) setDimensions(picturew, pictureh); fillColour(backgroundColour); +*/ + //line len in bytes (3 bytes per Pixel) - for buffer (can be bigger then surface) int linelen=cinfo.output_width*3; diff --git a/wjpeg.h b/wjpeg.h index 2e2a9c9..cebde65 100644 --- a/wjpeg.h +++ b/wjpeg.h @@ -32,9 +32,9 @@ extern "C" //TODO find a replacement on WIN32 #endif -#include "log.h" -#include "widget.h" -#include "surface.h" +#include "boxx.h" + +class Surface; //a reader to be implemented by the caller class JpegReader { @@ -51,9 +51,16 @@ class JpegReader { virtual ~JpegReader(){}; }; -class WJpeg : public Widget +class WJpeg : public Boxx { public: + + // temp for boxx + void setSurface(Surface* tsurface) {}; + void setDimensions(int width, int height) {}; + void setBackgroundColour(Colour& colour) {}; + + WJpeg(); virtual ~WJpeg(); int init(char* fileName, bool useImage=true, JpegReader *rdr=NULL); diff --git a/wol.cc b/wol.cc index f9081db..0af301b 100644 --- a/wol.cc +++ b/wol.cc @@ -30,6 +30,8 @@ #include #include "wol.h" +#include "log.h" + #define _PATH_PROCNET_ARP "/proc/net/arp" Wol* Wol::instance = NULL; diff --git a/wol.h b/wol.h index 02312a5..a8aee22 100644 --- a/wol.h +++ b/wol.h @@ -28,7 +28,8 @@ #include #include -#include "log.h" + +class Log; class Wol { diff --git a/woptionbox.cc b/woptionbox.cc index be1b5d2..76a0101 100644 --- a/woptionbox.cc +++ b/woptionbox.cc @@ -20,6 +20,9 @@ #include "woptionbox.h" +#include "colour.h" +#include "unistd.h" + WOptionBox::WOptionBox() { numOptions = 0; @@ -28,6 +31,20 @@ WOptionBox::WOptionBox() currentOption = 0; mode = MODE_TEXT; + + textbox.setPosition(20, 0); + textbox.setSize(10, surface->getFontHeight()); + textbox.setParaMode(false); + textbox.setTextPos(0, 0); + add(&textbox); + + leftArrow.setPosition(0, 2); + leftArrow.nextSymbol = WSymbol::LEFTARROW; + add(&leftArrow); + + rightArrow.setPosition(0, 2); + rightArrow.nextSymbol = WSymbol::RIGHTARROW; + add(&rightArrow); } WOptionBox::~WOptionBox() @@ -38,45 +55,64 @@ WOptionBox::~WOptionBox() free(options); } -void WOptionBox::addOption(const char* takeText) +void WOptionBox::setSize(UINT w, UINT h) { - int length = strlen(takeText); - char* newOption = new char[length + 1]; - strcpy(newOption, takeText); - options = (char**)realloc(options, (numOptions+1) * sizeof(char*)); - options[numOptions] = newOption; - numOptions++; + Boxx::setSize(w, h); + textbox.setSize(w - 40, surface->getFontHeight()); + rightArrow.setPosition(w - 18, 2); } void WOptionBox::setActive(UCHAR tactive) { active = tactive; + setData(); } -void WOptionBox::draw() +void WOptionBox::setData() { + // set colours, set text + if (active) { - fillColour(Colour::SELECTHIGHLIGHT); - drawText(options[currentOption], 0, 0, Colour::DARKTEXT); + textbox.setForegroundColour(Colour::DARKTEXT); + textbox.setBackgroundColour(Colour::SELECTHIGHLIGHT); + leftArrow.nextColour = Colour::SELECTHIGHLIGHT; + rightArrow.nextColour = Colour::SELECTHIGHLIGHT; } else { - fillColour(Colour::BUTTONBACKGROUND); - drawText(options[currentOption], 0, 0, Colour::LIGHTTEXT); + textbox.setForegroundColour(Colour::LIGHTTEXT); + textbox.setBackgroundColour(Colour::BUTTONBACKGROUND); + leftArrow.nextColour = Colour::BUTTONBACKGROUND; + rightArrow.nextColour = Colour::BUTTONBACKGROUND; } + textbox.setText(options[currentOption]); + +} + +void WOptionBox::addOption(const char* takeText) +{ + int length = strlen(takeText); + char* newOption = new char[length + 1]; + strcpy(newOption, takeText); + options = (char**)realloc(options, (numOptions+1) * sizeof(char*)); + options[numOptions] = newOption; + numOptions++; + setData(); } void WOptionBox::left() { if (currentOption == 0) return; --currentOption; + setData(); } void WOptionBox::right() { if (currentOption == (numOptions - 1)) return; ++currentOption; + setData(); } void WOptionBox::cycle() @@ -89,6 +125,7 @@ void WOptionBox::cycle() { ++currentOption; } + setData(); } void WOptionBox::setSelected(const char* toSelect) @@ -98,17 +135,14 @@ void WOptionBox::setSelected(const char* toSelect) if (!strcmp(toSelect, options[i])) { currentOption = i; + setData(); return; } } currentOption = 0; + setData(); } -//char* WOptionBox::getSelected() -//{ -// return options[currentOption]; -//} - int WOptionBox::getSelectedIndex() { if (mode == MODE_TEXT) @@ -142,29 +176,35 @@ void WOptionBox::setSelected(int toSelect) if (atoi(options[i]) == toSelect) { currentOption = i; + setData(); return; } } currentOption = 0; + setData(); } bool WOptionBox::mouseMove(int x, int y) { +/* if ((x-offsetX)>=area.x && (y-offsetY)>=area.y && (x-offsetX)<=area.w && (y-offsetY)<=area.h && !active) { setActive(1); return true; } + */ return false; } bool WOptionBox::mouseLBDOWN(int x, int y) { +/* if ((x-offsetX)>=area.x && (y-offsetY)>=area.y && (x-offsetX)<=area.w && (y-offsetY)<=area.h && active) { return true; } + */ return false; } diff --git a/woptionbox.h b/woptionbox.h index 3e4261b..de365bb 100644 --- a/woptionbox.h +++ b/woptionbox.h @@ -24,10 +24,11 @@ #include #include "defines.h" -#include "widget.h" -#include "colour.h" +#include "boxx.h" +#include "wsymbol.h" +#include "wtextbox.h" -class WOptionBox : public Widget +class WOptionBox : public Boxx { public: WOptionBox(); @@ -39,14 +40,14 @@ class WOptionBox : public Widget void addOption(const char* newOption); void setSelected(const char* selectedOption); -// char* getSelected(); void setActive(UCHAR tactive); void left(); void right(); void cycle(); - void draw(); int getSelectedIndex(); + virtual void setSize(UINT w, UINT h); + virtual bool mouseMove(int x, int y); virtual bool mouseLBDOWN(int x, int y); @@ -60,6 +61,12 @@ class WOptionBox : public Widget UINT currentOption; int mode; + + void setData(); + + WSymbol leftArrow; + WSymbol rightArrow; + WTextbox textbox; }; #endif diff --git a/woptionpane.cc b/woptionpane.cc new file mode 100644 index 0000000..3b3e109 --- /dev/null +++ b/woptionpane.cc @@ -0,0 +1,169 @@ +/* + Copyright 2007 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "woptionpane.h" +#include "wtextbox.h" +#include "i18n.h" +#include "woptionbox.h" +#include "log.h" +#include "vdr.h" +#include "remote.h" +#include "option.h" + +WOptionPane::WOptionPane() +{ + numOptions = 0; + selectedOption = -1; +} + +WOptionPane::~WOptionPane() +{ + for(int i = 0; i < numOptions; i++) + { + delete textBoxes[i]; + delete optionBoxes[i]; + } +} + +void WOptionPane::draw() +{ + Boxx::draw(); + drawText(tr("Press back to exit, <, > or [ok] to change"), 10, area.h - 30, Colour::LIGHTTEXT); +} + +void WOptionPane::saveOpts() +{ + // Due to the way the pane is constructed, options[0] corresponds to textBoxes[0] and optionBoxes[0] etc + + for(int i = 0; i < numOptions; i++) + { + options[i]->userSetChoice = optionBoxes[i]->getSelectedIndex(); + } +} + +void WOptionPane::addOptionLine(Option* option) +{ + int fontHeight = surface->getFontHeight(); + + options.resize(numOptions+1); + options[numOptions] = option; + + WTextbox* tb = new WTextbox(); + tb->setPosition(4, 4 + (numOptions * 30)); + tb->setSize(300, fontHeight); + tb->setText(tr(option->displayText)); + tb->setTextPos(0, 0); + add(tb); + + textBoxes.resize(numOptions+1); + textBoxes[numOptions] = tb; + + WOptionBox* ob = new WOptionBox(); + ob->setPosition(310, 4 + (numOptions * 30)); + ob->setSize(190, fontHeight); + add(ob); + + optionBoxes.resize(numOptions+1); + optionBoxes[numOptions] = ob; + + if (option->optionType == Option::TYPE_TEXT) + { + for (UINT j = 0; j < option->numChoices; j++) + { + Log::getInstance()->log("Options", Log::DEBUG, "Add option: %s", option->options[j]); + ob->addOption(tr(option->options[j])); + } + + // Set the selected choice + ob->setSelected(tr(option->options[option->configChoice])); + } + else + { + // int mode + ob->setIntMode(option->startInt, option->numChoices); + ob->setSelected(option->configChoice); + } + + numOptions++; + +} + +int WOptionPane::handleCommand(int command) +{ + switch(command) + { + case Remote::DF_UP: + case Remote::UP: + { + if (selectedOption > 0) + { + optionBoxes[selectedOption]->setActive(0); + --selectedOption; + optionBoxes[selectedOption]->setActive(1); + return 1; + } + else + { + optionBoxes[selectedOption--]->setActive(0); + return 4; // Signal return control to parent + } + } + case Remote::DF_DOWN: + case Remote::DOWN: + { + if (selectedOption < (numOptions - 1)) + { + if (selectedOption != -1) optionBoxes[selectedOption]->setActive(0); + ++selectedOption; + optionBoxes[selectedOption]->setActive(1); + return 1; + } + else if (selectedOption == (numOptions - 1)) + { + optionBoxes[selectedOption]->setActive(0); + selectedOption = -1; + return 4; // Signal return control to parent + } + } + case Remote::DF_LEFT: + case Remote::LEFT: + { + optionBoxes[selectedOption]->left(); + return 1; + } + case Remote::DF_RIGHT: + case Remote::RIGHT: + { + optionBoxes[selectedOption]->right(); + return 1; + } + case Remote::OK: + { + optionBoxes[selectedOption]->cycle(); + return 1; + } + } + + return 0; +} + + + + diff --git a/vtabsviewman.h b/woptionpane.h similarity index 57% rename from vtabsviewman.h rename to woptionpane.h index 198e31a..1120c8c 100644 --- a/vtabsviewman.h +++ b/woptionpane.h @@ -1,5 +1,5 @@ /* - Copyright 2004-2007 Chris Tallon,Marten Richter + Copyright 2007 Chris Tallon This file is part of VOMP. @@ -18,37 +18,36 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef VTABSVIEWMAN_H -#define VTABSVIEWMAN_H +#ifndef WOPTIONPANE_H +#define WOPTIONPANE_H -#include "view.h" -#include "viewman.h" +#include +#include "boxx.h" +#include "defines.h" +class WTextbox; +class WOptionBox; +class Option; -class VTabsViewMan: public View,AbstractViewMan +class WOptionPane : public Boxx { -public: - VTabsViewMan(); - ~VTabsViewMan(); - - int add(View* v); - int removeView(View* toRemove); - void removeAll(); - void create(); - - void draw(); + public: + WOptionPane(); + ~WOptionPane(); + void addOptionLine(Option*); int handleCommand(int command); - void processMessage(Message* m); // The master lock will be locked - void updateView(View* toUpdate, Region* regionToUpdate = NULL); - - void blt(Region& r); - -protected: - View* views[20]; - int numViews; - int selectedView; - bool tabHasControl; - + void saveOpts(); + void draw(); + + private: + int numOptions; + int selectedOption; + + vector options; + + vector textBoxes; + vector optionBoxes; }; + #endif diff --git a/wremoteconfig.cc b/wremoteconfig.cc new file mode 100644 index 0000000..cbda1d9 --- /dev/null +++ b/wremoteconfig.cc @@ -0,0 +1,235 @@ +/* + Copyright 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "wremoteconfig.h" + +#include "remote.h" +#include "wsymbol.h" +#include "colour.h" +#include "i18n.h" + +WRemoteConfig::WRemoteConfig() +{ + remote = Remote::getInstance(); + learnmode = false; + active = false; + + sl.setShowSelOption(false); + sl.setPosition(10, 30); + add(&sl); + initSelectList(true); +} + +WRemoteConfig::~WRemoteConfig() +{ +} + +void WRemoteConfig::initSelectList(bool startup) +{ + ULONG selection = 0; + ULONG top = 0; + + if (!startup) + { + selection = sl.getCurrentOption(); + top = sl.getTopOption(); + } + + 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); + sl.addOption(line,i,0); + } + } + if (!startup) + { + sl.hintSetCurrent(selection); + sl.hintSetTop(top); + } +} + +void WRemoteConfig::setSize(UINT w, UINT h) +{ + Boxx::setSize(w, h); + sl.setSize(area.w - 20, area.h - 70); +} + +void WRemoteConfig::draw() +{ + Boxx::draw(); + + drawText(tr("Command"), 15, 4, Colour::LIGHTTEXT); + drawText(tr("Hard wired"), 165, 4, Colour::LIGHTTEXT); + drawText(tr("User assignable"), 315, 4, Colour::LIGHTTEXT); + + 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 WRemoteConfig::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 WRemoteConfig::doSave() +{ + Message* m = new Message(); + m->message = Message::CHANGED_REMOTECONTROL; + m->to = parent; + m->parameter = 0; + Command::getInstance()->postMessageNoLock(m); + +} +*/ + +int WRemoteConfig::handleCommand(int command) +{ + if (learnmode) + { + learnmode = false; + if (command == Remote::NA_LEARN) + { + initSelectList(false); + } + return 1; + } + switch(command) + { + case Remote::DF_UP: + case Remote::UP: + { + if (sl.getCurrentOption() != 0) + { + sl.up(); + return 1; + } + else + { + sl.setShowSelOption(false); + active = false; + return 4; // return control to vopts + } + } + case Remote::DF_DOWN: + case Remote::DOWN: + { + if (!active) + { + active = true; + sl.setShowSelOption(true); + } + else + { + sl.down(); + } + return 1; + } + case Remote::SKIPBACK: + { + sl.pageUp(); + return 1; + } + case Remote::SKIPFORWARD: + { + sl.pageDown(); + return 1; + } + case Remote::OK: + { + learnmode = true; + remote->EnterLearningMode(sl.getCurrentOptionData()); + return 1; + } + case Remote::BACK: + { + return 0; +/* + 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); + return 1; + } + } + + return 0; +} + + diff --git a/vwallpaper.cc b/wremoteconfig.h similarity index 60% rename from vwallpaper.cc rename to wremoteconfig.h index c432340..37c1823 100644 --- a/vwallpaper.cc +++ b/wremoteconfig.h @@ -1,5 +1,5 @@ /* - Copyright 2004-2005 Chris Tallon + Copyright 2007 Chris Tallon, Marten Richter This file is part of VOMP. @@ -18,28 +18,32 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "vwallpaper.h" +#ifndef WREMOTECONFIG_H +#define WREMOTECONFIG_H -VWallpaper::VWallpaper() -{ - -} +#include "boxx.h" +#include "wselectlist.h" -VWallpaper::~VWallpaper() -{ -} +class Remote; +class Message; -void VWallpaper::init(char* name) +class WRemoteConfig : public Boxx { - Video* video = Video::getInstance(); - create(video->getScreenWidth(), video->getScreenHeight()); + public: + WRemoteConfig(); + ~WRemoteConfig(); + + void setSize(UINT w, UINT h); + int handleCommand(int command); + void draw(); + + private: + WSelectList sl; + Remote *remote; + bool learnmode; + void initSelectList(bool startup); + bool active; +}; + +#endif - jpeg.init(name); - jpeg.setSurface(surface); -} - -void VWallpaper::draw() -{ - View::draw(); - jpeg.draw(); -} diff --git a/wselectlist.cc b/wselectlist.cc index 6fdf0f7..9295324 100644 --- a/wselectlist.cc +++ b/wselectlist.cc @@ -20,6 +20,8 @@ #include "wselectlist.h" +#include "colour.h" + WSelectList::WSelectList() { selectedOption = 0; @@ -29,6 +31,7 @@ WSelectList::WSelectList() noLoop = 0; gap = 1; showseloption = true; + backgroundColour = Colour::VIEWBACKGROUND; } WSelectList::~WSelectList() @@ -56,6 +59,11 @@ void WSelectList::setNoLoop() noLoop = 1; } +void WSelectList::setBackgroundColour(Colour& colour) +{ + backgroundColour = colour; +} + void WSelectList::hintSetCurrent(int idx) { selectedOption = idx; @@ -67,7 +75,7 @@ void WSelectList::hintSetTop(int idx) topOption = idx; } -int WSelectList::addOption(char* text, ULONG data, int selected) +int WSelectList::addOption(const char* text, ULONG data, int selected) { int thisNewOption = options.size(); @@ -224,7 +232,7 @@ ULONG WSelectList::getCurrentOptionData() bool WSelectList::mouseMove(int x, int y) { - int ml = getMouseLine(x-offsetX,y-offsetY); + int ml = getMouseLine(x-getRootBoxOffsetX(), y-getRootBoxOffsetY()); if (ml>=0 && ml!=(int)selectedOption) { selectedOption = ml; @@ -235,7 +243,7 @@ bool WSelectList::mouseMove(int x, int y) bool WSelectList::mouseLBDOWN(int x, int y) { - int ml = getMouseLine(x-offsetX, y-offsetY); + int ml = getMouseLine(x-getRootBoxOffsetX(), y-getRootBoxOffsetY()); if (ml == (int)selectedOption) { /* caller should generate a OK message*/ diff --git a/wselectlist.h b/wselectlist.h index 2a486c5..dbd1b9e 100644 --- a/wselectlist.h +++ b/wselectlist.h @@ -27,8 +27,7 @@ #include #include "defines.h" -#include "widget.h" -#include "colour.h" +#include "boxx.h" using namespace std; @@ -38,7 +37,7 @@ typedef struct ULONG data; } wsloption; -class WSelectList : public Widget +class WSelectList : public Boxx { public: WSelectList(); @@ -48,8 +47,9 @@ class WSelectList : public Widget void setNoLoop(); void setShowSelOption(bool set) { showseloption = set; }; - int addOption(char* text, ULONG data, int selected); + int addOption(const char* text, ULONG data, int selected); void draw(); + void setBackgroundColour(Colour& colour); void down(); void up(); @@ -80,6 +80,9 @@ class WSelectList : public Widget int numColumns; int noLoop; bool showseloption; + + UINT gap; + Colour backgroundColour; }; #endif diff --git a/wsymbol.cc b/wsymbol.cc index 81171d6..863b01e 100644 --- a/wsymbol.cc +++ b/wsymbol.cc @@ -20,6 +20,8 @@ #include "wsymbol.h" +#include "colour.h" + UCHAR WSymbol::widths[] = { 2, 2, 4, 4, 1, 1, 3, 3, 3, 3, 3, 4, 4, 2, 2, 3, 5, 5, 4, 4, 2, 2}; UCHAR WSymbol::heights[] = { 8, 8, 12, 12, 24, 4, 18, 18, 18, 18, 18, 30, 30, 16, 16, 18, 18, 18, 16, 16, 8, 8}; diff --git a/wsymbol.h b/wsymbol.h index c0be549..364ef68 100644 --- a/wsymbol.h +++ b/wsymbol.h @@ -22,10 +22,9 @@ #define WSYMBOL_H #include "defines.h" -#include "widget.h" -#include "colour.h" +#include "boxx.h" -class WSymbol : public Widget +class WSymbol : public Boxx { public: WSymbol(); diff --git a/wtabbar.cc b/wtabbar.cc new file mode 100644 index 0000000..ef54b9b --- /dev/null +++ b/wtabbar.cc @@ -0,0 +1,248 @@ +/* + 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "wtabbar.h" +#include "surface.h" +#include "remote.h" +#include "wbutton.h" +#include "colour.h" + +WTabBar::WTabBar() +{ + buttonBarActive = true; + visiblePane = 0; + setBackgroundColour(Colour::VIEWBACKGROUND); + + symbolLeft.setPosition(0, 4); + symbolLeft.nextColour = Colour::BUTTONBACKGROUND; + symbolLeft.nextSymbol = WSymbol::LEFTARROW; + add(&symbolLeft); + + symbolRight.setPosition(getWidth() - 28, 4); + symbolRight.nextColour = Colour::BUTTONBACKGROUND; + symbolRight.nextSymbol = WSymbol::RIGHTARROW; + add(&symbolRight); +} + +WTabBar::~WTabBar() +{ + for (UINT i = 0; i < tabs.size(); i++) + { + delete tabs[i].button; + } +} + +void WTabBar::addTab(const char* name, Boxx* boxx) +{ + TabDetails td; + td.name = name; + td.nameWidth = 0; + + for(UINT i = 0; i < strlen(name); i++) + { + td.nameWidth += charWidth(name[i]); + } + + UINT newButtonX = 22; + for(UINT i = 0; i < tabs.size(); i++) newButtonX += tabs[i].button->getWidth() + 10; + + WButton* newButton = new WButton(); + newButton->setText(name); + newButton->setPosition(newButtonX, 2); + newButton->setSize(td.nameWidth + 6, Surface::getFontHeight()); + if ((newButtonX + newButton->getWidth()) > (getWidth() - 22)) newButton->setVisible(false); + add(newButton); + + boxx->setPosition(0, 34); + boxx->setSize(getWidth(), getHeight()-34); + add(boxx); + + td.button = newButton; + td.pane = boxx; + tabs.push_back(td); + + if (tabs.size() == 1) + { + newButton->setActive(true); + boxx->setVisible(true); + } + else + { + newButton->setActive(false); + boxx->setVisible(false); + symbolRight.nextColour = Colour::SELECTHIGHLIGHT; // if this is the 2nd+ tab, ensure right arrow goes active + } +} + +int WTabBar::handleCommand(int command) +{ + // This returns 0 for not handled, and 1 for handled and please-update-me, 2 for handled-no-update + + // if the focus is in a pane, send the command there + if (!buttonBarActive) + { + // Send the command to the pane + // Return code should be: + // 0 - not handled + // 1 - handled - stop command here + // 4 - handled - pane is returning control to here + // FIXME standardise these + + int paneRetCode = tabs[visiblePane].pane->handleCommand(command); + if (paneRetCode == 0) + { + return 0; + } + else if (paneRetCode == 1) + { + draw(); + return 1; + } + else if (paneRetCode == 4) + { + buttonBarActive = true; + tabs[visiblePane].button->setActive(true); + if (visiblePane != 0) symbolLeft.nextColour = Colour::SELECTHIGHLIGHT; + if (visiblePane != tabs.size() - 1) symbolRight.nextColour = Colour::SELECTHIGHLIGHT; + draw(); + return 1; + } + } + + if (buttonBarActive) + { + switch(command) + { + case Remote::DF_LEFT: + case Remote::LEFT: + { + if (!left()) return 2; + draw(); + return 1; + } + case Remote::DF_RIGHT: + case Remote::RIGHT: + { + if (!right()) return 2; + draw(); + return 1; + } + case Remote::DOWN: + case Remote::DF_DOWN: + { + buttonBarActive = false; + tabs[visiblePane].button->dim(); + symbolLeft.nextColour = Colour::BUTTONBACKGROUND; + symbolRight.nextColour = Colour::BUTTONBACKGROUND; + if (tabs[visiblePane].pane->handleCommand(command) == 1) // shouldn't return anything else at this point?! + { + draw(); + return 1; + } + } + } + } + return 0; +} + +// When there are too many tabs to display simultaneously, extend this to shift the tabs left and right + +bool WTabBar::left() +{ + if (visiblePane == 0) return false; + tabs[visiblePane].button->setActive(false); + tabs[visiblePane].pane->setVisible(false); + --visiblePane; + tabs[visiblePane].button->setActive(true); + tabs[visiblePane].pane->setVisible(true); + + if (visiblePane == 0) symbolLeft.nextColour = Colour::BUTTONBACKGROUND; + symbolRight.nextColour = Colour::SELECTHIGHLIGHT; + + // Move the buttons.. + if (tabs[visiblePane].button->getVisible() == false) + { + tabs[visiblePane].button->setVisible(true); + // We have gone << past the last visible button + UINT newButtonX = 22; + UINT j; + for(j = visiblePane; j < tabs.size(); j++) // start with the button just uncovered + { + if ((newButtonX + tabs[j].button->getWidth()) > (getWidth() - 22)) break; // this one too big. + tabs[j].button->setPosition(newButtonX, 2); + newButtonX += tabs[j].button->getWidth() + 10; + } + for(; j < tabs.size(); j++) // hide the rest + { + tabs[j].button->setVisible(false); + } + } + + return true; +} + +bool WTabBar::right() +{ + if (visiblePane == tabs.size() - 1) return false; + tabs[visiblePane].button->setActive(false); + tabs[visiblePane].pane->setVisible(false); + ++visiblePane; + tabs[visiblePane].button->setActive(true); + tabs[visiblePane].pane->setVisible(true); + + if (visiblePane == tabs.size() - 1) symbolRight.nextColour = Colour::BUTTONBACKGROUND; + symbolLeft.nextColour = Colour::SELECTHIGHLIGHT; + + // Move the buttons.. + if (tabs[visiblePane].button->getVisible() == false) + { + tabs[visiblePane].button->setVisible(true); + // We have gone >> past the last visible button + // Move all buttons left, but need to work out which one to finally display as first on the left + UINT displayWidth = getWidth() - 44; + UINT widthSum = tabs[visiblePane].button->getWidth(); // start with width of newly shown button (on the right) + int startWith = 0; + int i; + for(i = visiblePane - 1; i >= 0; i--) + { + widthSum += tabs[i].button->getWidth() + 10; // add on width needed to display also the previous button + if (widthSum > displayWidth) // then it's too much + { + startWith = i + 1; + break; + } + } + + for(i = 0; i < startWith; i++) // For each button to the left of startWith... + { + tabs[i].button->setVisible(false); + } + + UINT newButtonX = 22; + for(UINT j = startWith; j <= visiblePane; j++) // startWith -> the one we just uncovered + { + tabs[j].button->setPosition(newButtonX, 2); + newButtonX += tabs[j].button->getWidth() + 10; + } + } + + return true; +} + diff --git a/widget.h b/wtabbar.h similarity index 60% rename from widget.h rename to wtabbar.h index a2d01bb..3868309 100644 --- a/widget.h +++ b/wtabbar.h @@ -18,33 +18,42 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef WIDGET_H -#define WIDGET_H +#ifndef WTABBAR_H +#define WTABBAR_H -#include "log.h" -#include "box.h" +#include #include "defines.h" +#include "boxx.h" +#include "wsymbol.h" -// Abstract -class Widget : public Box +class WButton; + +typedef struct sTabDetails +{ + const char* name; + UINT nameWidth; + WButton* button; + Boxx* pane; +} TabDetails; + +class WTabBar : public Boxx { public: - Widget(); - virtual ~Widget(); - virtual void draw()=0; - void setSurface(Surface* tsurface); - void setDimensions(int width, int height); - void setBackgroundColour(Colour& colour); - int getOffsetY(); - int getOffsetX(); - - virtual bool mouseMove(int x, int y); - virtual bool mouseLBDOWN(int x, int y); + WTabBar(); + ~WTabBar(); + void addTab(const char* name, Boxx* boxx); + int handleCommand(int command); private: - - protected: - Colour backgroundColour; + bool left(); + bool right(); + + UINT visiblePane; + bool buttonBarActive; + vector tabs; + + WSymbol symbolLeft; + WSymbol symbolRight; }; #endif diff --git a/wtextbox.cc b/wtextbox.cc index 66696ff..42c574b 100644 --- a/wtextbox.cc +++ b/wtextbox.cc @@ -20,33 +20,40 @@ #include "wtextbox.h" -WTextbox::WTextbox() +#include "colour.h" + +WTextbox::WTextbox(const char* ttext) { - int fontHeight = Surface::getFontHeight(); - setDimensions(70, fontHeight); - setDimensions(100,100); +// int fontHeight = Surface::getFontHeight(); + //setDimensions(70, fontHeight); + //setDimensions(100,100); + setSize(100, 100); text = NULL; foreColour = Colour::LIGHTTEXT; - backColour = Colour::VIEWBACKGROUND; textX = 5; textY = 2; + + paraMode = true; + + if (ttext) setText(ttext); } WTextbox::~WTextbox() { - if (text) delete[] text; //TODO is this needed? + if (text) delete[] text; } -void WTextbox::setText(char* takeText) +void WTextbox::setParaMode(bool mode) { - int length = strlen(takeText); - text = new char[length + 1]; - strcpy(text, takeText); + paraMode = mode; } -void WTextbox::setBackgroundColour(Colour bcolour) +void WTextbox::setText(const char* takeText) { - backColour = bcolour; + if (text) delete[] text; + int length = strlen(takeText); + text = new char[length + 1]; + strcpy(text, takeText); } void WTextbox::setForegroundColour(Colour fcolour) @@ -56,9 +63,12 @@ void WTextbox::setForegroundColour(Colour fcolour) void WTextbox::draw() { - fillColour(backColour); + Boxx::draw(); if (text) - drawPara(text, textX, textY, foreColour); + { + if (paraMode) drawPara(text, textX, textY, foreColour); + else drawText(text, textX, textY, foreColour); + } } void WTextbox::setTextPos(int x, int y) diff --git a/wtextbox.h b/wtextbox.h index 87bdaae..9ac7072 100644 --- a/wtextbox.h +++ b/wtextbox.h @@ -25,27 +25,28 @@ #include #include "defines.h" -#include "widget.h" -#include "colour.h" +#include "boxx.h" -class WTextbox : public Widget +class Colour; + +class WTextbox : public Boxx { public: - WTextbox(); + WTextbox(const char* ttext = NULL); ~WTextbox(); - void setText(char* text); + void setText(const char* text); void draw(); - void setBackgroundColour(Colour bcolour); void setForegroundColour(Colour fcolour); void setTextPos(int x, int y); // optional + void setParaMode(bool mode); private: char* text; Colour foreColour; - Colour backColour; int textX; int textY; + bool paraMode; }; #endif diff --git a/wwss.cc b/wwss.cc index 25bfa73..34a5c48 100644 --- a/wwss.cc +++ b/wwss.cc @@ -20,6 +20,9 @@ #include "wwss.h" +#include "colour.h" +#include "video.h" + Wwss::Wwss() { format = Video::NTSC; diff --git a/wwss.h b/wwss.h index feff7a8..99f137a 100644 --- a/wwss.h +++ b/wwss.h @@ -24,12 +24,10 @@ #include #include +#include "boxx.h" #include "defines.h" -#include "widget.h" -#include "colour.h" -#include "video.h" -class Wwss : public Widget +class Wwss : public Boxx { public: Wwss(); -- 2.39.5