]> git.vomp.tv Git - vompclient-marten.git/commitdiff
New gui code
authorChris Tallon <chris@vomp.tv>
Tue, 13 Sep 2005 00:37:08 +0000 (00:37 +0000)
committerChris Tallon <chris@vomp.tv>
Tue, 13 Sep 2005 00:37:08 +0000 (00:37 +0000)
43 files changed:
Makefile
audio.cc
box.cc
box.h
command.cc
main.cc
osd.cc
playerradio.cc
playervideo.cc
surface.cc
surface.h
vchannellist.cc
vchannellist.h
vchannelselect.cc
vconnect.cc
view.cc
view.h
viewman.cc
viewman.h
vlivebanner.cc
vmute.cc
voptions.cc
vquestion.cc
vradiolive.cc
vrecordinglist.cc
vrecordingmenu.cc
vserverselect.cc
vvideolive.cc
vvideorec.cc
vvolume.cc
vwallpaper.cc
vwelcome.cc
wbutton.cc
wbutton.h
widget.cc [new file with mode: 0644]
widget.h [new file with mode: 0644]
wjpeg.cc
wjpeg.h
woptionbox.h
wselectlist.cc
wselectlist.h
wsymbol.cc
wsymbol.h

index 49e0e22bc1528cca503775f77d7e43eb27540af4..9c60e3fc611fdd988b4529d5fd6327e8c2a98861 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -3,8 +3,8 @@ STRIP = /opt/crosstool/powerpc-405-linux-gnu/gcc-2.95.3-glibc-2.2.5/bin/powerpc-
 
 CXX = $(CC)
 INCLUDES = -I../jpeg-6b
-CXXFLAGS_DEV = -g -O0 -Wall -Woverloaded-virtual -Werror -DDEV -D_GNU_SOURCE $(INCLUDES)
-CXXFLAGS_REL = -O3 -Wall -Woverloaded-virtual -Werror -D_GNU_SOURCE $(INCLUDES)
+CXXFLAGS_DEV = -g -O0 -Wall -Woverloaded-virtual -Wshadow -Werror -DDEV -D_GNU_SOURCE $(INCLUDES)
+CXXFLAGS_REL = -O3 -Wall -Woverloaded-virtual -Wshadow -Werror -D_GNU_SOURCE $(INCLUDES)
 LDFLAGS = -Wall -static
 
 LIBPATHS =
@@ -17,7 +17,7 @@ OBJECTS = main.o command.o log.o remote.o led.o mtd.o video.o audio.o tcp.o dire
           view.o vinfo.o vwallpaper.o vvolume.o vrecordinglist.o vlivebanner.o vmute.o \
           vrecordingmenu.o vquestion.o vchannellist.o vwelcome.o vvideolive.o vvideorec.o vradiolive.o \
           vchannelselect.o vserverselect.o colour.o vconnect.o voptions.o \
-          wselectlist.o wjpeg.o wsymbol.o wbutton.o woptionbox.o \
+          widget.o wselectlist.o wjpeg.o wsymbol.o wbutton.o woptionbox.o \
           fonts/helvB24.o fonts/helvB18.o
 
 .PHONY: clean fresh all install strip
index d47bf48aa9747462d5977bdc4873f194a35874b9..01e53e112b7bfb64eababdcb523408c48579b311 100644 (file)
--- a/audio.cc
+++ b/audio.cc
@@ -222,7 +222,7 @@ int Audio::test()
   int b = ioctl(fdAudio, AV_SET_AUD_DISABLE_SYNC, &a);
 
 
-  printf("Audio sync disable = %i\n", b);
+  printf("Audio sync disable = %i\n", b); // is in a DEV block
 
   return 1;
 
diff --git a/box.cc b/box.cc
index 30b24b6f33b81d71c8f160a213bd6cb430750419..dc28da5b6bd33a4b34d94e233563bfb01e757ff6 100644 (file)
--- a/box.cc
+++ b/box.cc
@@ -26,13 +26,16 @@ Box::Box()
 {
   height = 0;
   width = 0;
+
   screenX = 0;
   screenY = 0;
+  offsetX = 0;
+  offsetY = 0;
 
   numBoxes++;
   Log::getInstance()->log("Box", Log::DEBUG, "Construct, now %u", numBoxes);
 
-  surface = Surface::getObject(Surface::BUFFER);
+  surface = NULL;
 }
 
 Box::~Box()
@@ -45,27 +48,23 @@ void Box::draw()
 {
 }
 
-void Box::setDimensions(int w, int h)
-{
-  width = w;
-  height = h;
-}
-
 void Box::setScreenPos(int x, int y)
 {
   screenX = x;
   screenY = y;
 }
 
-void Box::show()
+void Box::setSurfaceOffset(UINT x, UINT y)
 {
-  Log::getInstance()->log("Box", Log::DEBUG, "Show data %u %u %u %u", screenX, screenY, width, height);
-  surface->updateToScreen(screenX, screenY, width, height);
+  offsetX = x;
+  offsetY = y;
 }
 
-void Box::showAll()
+void Box::show(int noBufferToScreen)
 {
-  Surface::bufferToScreen();
+  Log::getInstance()->log("Box", Log::DEBUG, "Show data %p %u %u %u %u %u", surface, screenX, screenY, width, height, noBufferToScreen);
+  surface->updateToBuffer(screenX, screenY, width, height);
+  if (!noBufferToScreen) Surface::bufferToScreen(screenX, screenY, width, height);
 }
 
 int Box::getScreenX()
@@ -128,7 +127,7 @@ void Box::drawPara(char* text, int x, int y, Colour& colour)
       }
 
       thisCharWidth = surface->getCharWidth(text[textPos]);
-      if ((lineWidth + thisCharWidth) > (width - (2 * paraMargin)))
+      if ((lineWidth + thisCharWidth) > (int)(width - (2 * paraMargin)))
       {
         // this character would break the right margin
         if (text[textPos] == ' ')
@@ -160,7 +159,7 @@ void Box::drawPara(char* text, int x, int y, Colour& colour)
     {
       drawText(line, x, ypos, colour);
       ypos += lineHeight;
-      if (ypos > (height - lineHeight)) break;
+      if (ypos > (int)(height - lineHeight)) break;
     }
     else
     {
@@ -171,29 +170,28 @@ void Box::drawPara(char* text, int x, int y, Colour& colour)
 
 // Level 0 drawing functions
 
-void Box::rectangle(int x1, int y1, int width, int height, Colour& colour)
+void Box::rectangle(int x1, int y1, int w, int h, Colour& colour)
 {
-  surface->fillblt(screenX + x1, screenY + y1, width, height, surface->rgba(colour.red, colour.green, colour.blue, colour.alpha));
+  surface->fillblt(offsetX + x1, offsetY + y1, w, h, surface->rgba(colour.red, colour.green, colour.blue, colour.alpha));
 }
 
 void Box::drawText(char* text, int x, int y, Colour& colour)
 {
-  surface->drawText(text, screenX + x, screenY + y, colour.red, colour.green, colour.blue);
+  surface->drawText(text, offsetX + x, offsetY + y, colour.red, colour.green, colour.blue);
 }
 
 void Box::drawTextRJ(char* text, int x, int y, Colour& colour)
 {
-  surface->drawTextRJ(text, screenX + x, screenY + y, colour.red, colour.green, colour.blue);
+  surface->drawTextRJ(text, offsetX + x, offsetY + y, colour.red, colour.green, colour.blue);
 }
 
-void Box::drawPixel(int x, int y, Colour& colour)
+void Box::drawPixel(UINT x, UINT y, Colour& colour)
 {
-  int c;
-        c = (  (0xFF000000        )
+  int c = (  (0xFF000000        )
              | (colour.red  << 16)
              | (colour.green  <<  8)
              | (colour.blue     ) );
 
 
-  surface->drawPixel(screenX + x, screenY + y, c);
+  surface->drawPixel(offsetX + x, offsetY + y, c);
 }
diff --git a/box.h b/box.h
index 93f8b318ef4cebc322c82ed80acbbc2e91bbb6fe..8f48056b6e693181969d7039b7df0bce4afb300c 100644 (file)
--- a/box.h
+++ b/box.h
@@ -35,8 +35,9 @@ class Box
     virtual ~Box();
 
     void setScreenPos(int x, int y);
-    void setDimensions(int w, int h);
-    void show();
+    void setSurfaceOffset(UINT x, UINT y);
+
+    void show(int noBufferToScreen = 0);
 
     virtual void draw();
 
@@ -48,25 +49,26 @@ class Box
     void rectangle(int x1, int y1, int x2, int y2, Colour& colour);
     void drawText(char* text, int x, int y, Colour& colour);
     void drawTextRJ(char* text, int x, int y, Colour& colour);
-    void drawPixel(int x, int y, Colour& colour);
+    void drawPixel(UINT x, UINT y, Colour& colour);
 
     int getScreenX();
     int getScreenY();
     int getWidth();
     int getHeight();
 
-    static void showAll();
-
   private:
 
   protected:
     Surface* surface;
-    int width;
-    int height;
+    UINT width;
+    UINT height;
 
     int screenX;
     int screenY;
 
+    UINT offsetX;
+    UINT offsetY;
+
     static char numBoxes;
 
     static const int paraMargin = 10;
index 26932f6530e15f9e46cf0109796b117643dc4bff..5455c9af8ba0d9191b20c9488fce21fec60a22c2 100644 (file)
@@ -91,7 +91,7 @@ void Command::run()
 
   // Blue background
   View* v = new View();
-  v->setDimensions(video->getScreenWidth(), video->getScreenHeight());
+  v->create(video->getScreenWidth(), video->getScreenHeight());
   v->setBackgroundColour(Colour::VIDEOBLUE);
   v->draw();
   v->show();
@@ -230,10 +230,7 @@ void Command::doStandby()
   }
   else
   {
-    ViewMan* viewman = ViewMan::getInstance();
-
     viewman->removeAll();
-    viewman->redrawAll();
 
     VDR::getInstance()->configSave("General", "Last Power State", "Off");
     VDR::getInstance()->disconnect();
@@ -254,11 +251,10 @@ void Command::doReboot()
 void Command::doJustConnected(VConnect* vconnect)
 {
   Video* video = Video::getInstance();
-  ViewMan* viewman = ViewMan::getInstance();
   viewman->removeView(vconnect, 0, 1);
 
   VInfo* vi = new VInfo();
-  vi->setDimensions(400, 200);
+  vi->create(400, 200);
   if (video->getFormat() == Video::PAL)
     vi->setScreenPos(170, 200);
   else
@@ -405,8 +401,10 @@ void Command::doJustConnected(VConnect* vconnect)
   viewman->removeView(vi);
 
   VWelcome* vw = new VWelcome();
+  vw->draw();
+  vw->show();
   viewman->add(vw);
-  viewman->redrawAll();
+//  viewman->redrawAll();
 
 /*
   handleCommand(Remote::DOWN);
diff --git a/main.cc b/main.cc
index 0d6e4a6d599de39a1430b6f5f72a38420613b216..490c8cadb47d9454e5921da3970d5ec5117da505 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -37,7 +37,7 @@
 #include "viewman.h"
 #include "command.h"
 
-void sighandler(int signal);
+void sighandler(int signalReceived);
 void shutdown(int code);
 
 // Global variables --------------------------------------------------------------------------------------------------
@@ -332,13 +332,11 @@ void shutdown(int code)
 
 // -------------------------------------------------------------------------------------------------------------------
 
-void sighandler(int signal)
+void sighandler(int signalReceived)
 {
-  Log* logger = Log::getInstance();
-
   logger->log("Core", Log::NOTICE, "Signal %i received", signal);
 
-  switch (signal)
+  switch (signalReceived)
   {
     case SIGINT:
     {
diff --git a/osd.cc b/osd.cc
index 9b7814c97b01711fee6498eab395bc15e5e0d1e4..71190f0b6d556c9b08e93209c3fdb76cdc9f191e 100644 (file)
--- a/osd.cc
+++ b/osd.cc
@@ -67,14 +67,14 @@ int Osd::init(char* device, int doubleBuffering)
 
   Video* video = Video::getInstance();
 
-  screen = new Surface(fdOsd, Surface::SCREEN);
-  screen->create(video->getScreenHeight(), video->getScreenWidth());
+  screen = new Surface(Surface::SCREEN);
+  screen->create(video->getScreenWidth(), video->getScreenHeight());
   screen->display();
 
   if (doubleBuffering)
   {
-    buffer = new Surface(fdOsd, Surface::BUFFER);
-    buffer->create(video->getScreenHeight(), video->getScreenWidth());
+    buffer = new Surface(Surface::BUFFER);
+    buffer->create(video->getScreenWidth(), video->getScreenHeight());
   }
   else
   {
index 03d291d9c2dfb2922ee6a650ebd310263d529ea2..ec41b2bdcd59f9961abfdf3dc34ac168204a6864 100644 (file)
@@ -332,8 +332,7 @@ void PlayerRadio::threadMethod()
     buf = vdr->getBlock(feedPosition, askFor, &thisRead);
     if (!buf) break;
 
-    // temp
-    printf("Written direct: %i\n", write(audio->getFD(), buf, thisRead));
+    printf("Written direct: %i\n", write(audio->getFD(), buf, thisRead)); // temp
 
 
 
index 999e8d0ef0292d1df4e0f29de25d83a460d8f601..bfb733179d71177db0cf1e8cd6fe48a654a6d544 100644 (file)
@@ -280,7 +280,7 @@ void PlayerVideo::test()
 
   flipflop = !flipflop;
 
-  printf("A = %i\n", a);
+  printf("A = %i\n", a); commented out
 */
 
   Log::getInstance()->log("Player", Log::DEBUG, "PLAYER TEST 1 4X3");
index 20a514301d51d15ff2817945fdd24013e1fc2f34..13af55e53bfe62a2f8f327a2f70994706183420e 100644 (file)
 */
 
 #include "surface.h"
+#include "osd.h"
 
 Surface* Surface::screen = NULL;
 Surface* Surface::buffer = NULL;
 int Surface::disableDoubleBuffering = 0;
+osd_font_t* Surface::font = &font_helvB18;
 
-Surface::Surface(int fd, int id)
+Surface::Surface(int id)
 {
   if (id == SCREEN) screen = this;
   if (id == BUFFER) buffer = this;
 
-  fdOsd = fd;
+  fdOsd = Osd::getInstance()->getFD();
   memset(&surface, 0, sizeof(osd_surface_t));
   memset(&surface.sfc, 0, sizeof(stbgfx_sfc_t));
   memset(&surface.map, 0, sizeof(stbgfx_map_t));
-
-  font = &font_helvB18;
 }
 
 Surface::~Surface()
@@ -68,7 +68,7 @@ Surface* Surface::getObject(int id)
   return NULL;
 }
 
-int Surface::create(int height, int width)
+int Surface::create(UINT width, UINT height)
 {
   int r = 0;
   int displayNumber = 0; // mvpmc iterates 0->15 till it gets one that works?
@@ -285,11 +285,13 @@ void Surface::drawVertLine(int x, int y1, int y2, unsigned int c)
 void Surface::bufferToScreen() // static, this is for Box::showAll
 {
   if (disableDoubleBuffering) return;
-  buffer->updateToScreen(0, 0, buffer->surface.sfc.width, buffer->surface.sfc.height);
+
+  Log::getInstance()->log("Surface", Log::DEBUG, "Full buffer to screen");
+  bufferToScreen(0, 0, buffer->surface.sfc.width, buffer->surface.sfc.height);
 }
 
-int Surface::updateToScreen(int x, int y, int width, int height) // main method for all normal windows
-{
+//int Surface::updateToScreen(int x, int y, int width, int height) // main method for all normal windows
+//{
   /*
   With double buffering:
     A view has buffer for its surface. this is buffer, copy area specified to screen
@@ -297,9 +299,19 @@ int Surface::updateToScreen(int x, int y, int width, int height) // main method
     A view has screen for its surface. this is screen, all painting work has already been done. ignore
   */
 
-  if (this == screen) return 0;
+//  if (this == screen) return 0;
+//
+//  return blt(fdOsd, surface.sfc.handle, x, y, width, height, screen->getSurfaceHandle(), x, y);
+//}
 
-  return blt(fdOsd, surface.sfc.handle, x, y, width, height, screen->getSurfaceHandle(), x, y);
+int Surface::bufferToScreen(int x, int y, int width, int height) // static
+{
+  return blt(Osd::getInstance()->getFD(), buffer->getSurfaceHandle(), x, y, width, height, screen->getSurfaceHandle(), x, y);
+}
+
+int Surface::updateToBuffer(int x, int y, int width, int height) // main method for all normal windows
+{
+  return blt(fdOsd, surface.sfc.handle, 0, 0, width, height, buffer->getSurfaceHandle(), x, y);
 }
 
 int Surface::blt(int fd, unsigned long shandle, int sx, int sy, int width, int height, unsigned long dhandle, int dx, int dy)
index 8cf8b7ab14cbcad684947333e020d07a83106e62..1b5dfa43ecccfd5881fb8f2e9843e2c76ec4c5b8 100644 (file)
--- a/surface.h
+++ b/surface.h
@@ -161,17 +161,20 @@ extern "C"
   #include <jpeglib.h>
 }
 
+#include "defines.h"
 #include "log.h"
 
 class Surface
 {
   public:
-    Surface(int fd, int id);
+    Surface(int id = 0);
     ~Surface();
 
     static Surface* getObject(int id);
+    static int bufferToScreen(int x, int y, int width, int height);
+    static int getFontHeight();
 
-    int create(int height, int width);
+    int create(UINT width, UINT height);
     void display();
     unsigned long getSurfaceHandle();
 
@@ -179,11 +182,10 @@ class Surface
     void drawPixel(int x, int y, unsigned int c);
     void drawHorzLine(int x1, int x2, int y, unsigned int c);
     void drawVertLine(int x, int y1, int y2, unsigned int c);
-    int updateToScreen(int x, int y, int width, int height);
+    int updateToBuffer(int x, int y, int width, int height);
     int drawText(char* text, int x, int y, int r, int g, int b);
     int drawTextRJ(char* text, int x, int y, int r, int g, int b);
     int getCharWidth(char c);
-    int getFontHeight();
     void readPixel(int x, int y, unsigned char* r, unsigned char* g, unsigned char* b);
     void yuv2rgb(int y, int u, int v, unsigned char* pr, unsigned char* pg, unsigned char* pb);
     void screenShot(char* fileName);
@@ -216,11 +218,11 @@ class Surface
     static Surface* screen;
     static Surface* buffer;
     static int disableDoubleBuffering;
+    static osd_font_t* font;
 
     int fdOsd;
 
     osd_surface_t surface;
-    osd_font_t* font;
 
     void rgb2yuv(unsigned char r, unsigned char g, unsigned char b, unsigned char *y, unsigned char *u, unsigned char *v);
 
index f8d196ba18c27a0667fcf135cb1ff8ca62bc6d69..4f66b0be8eedb825224db126cbb661f77eca944e 100644 (file)
@@ -22,6 +22,7 @@
 
 VChannelList::VChannelList(ULONG type)
 {
+  create(570, 420);
   if (Video::getInstance()->getFormat() == Video::PAL)
   {
     setScreenPos(80, 70);
@@ -31,7 +32,6 @@ VChannelList::VChannelList(ULONG type)
     setScreenPos(70, 35);
   }
 
-  setDimensions(570, 420);
 
   setBackgroundColour(Colour::VIEWBACKGROUND);
   setTitleBarOn(1);
@@ -46,7 +46,8 @@ VChannelList::VChannelList(ULONG type)
   }
   setTitleBarColour(Colour::TITLEBARBACKGROUND);
 
-  sl.setScreenPos(screenX + 10, screenY + 30 + 5);
+  sl.setSurface(surface);
+  sl.setSurfaceOffset(10, 30 + 5);
   sl.setDimensions(width - 20, height - 30 - 15 - 30);
 }
 
@@ -95,25 +96,26 @@ void VChannelList::draw()
   // Put the status stuff at the bottom
 
   WSymbol w;
+  w.setSurface(surface);
 
   w.nextSymbol = WSymbol::UP;
-  w.setScreenPos(screenX + 20, screenY + 385);
+  w.setSurfaceOffset(20, 385);
   w.draw();
 
   w.nextSymbol = WSymbol::DOWN;
-  w.setScreenPos(screenX + 50, screenY + 385);
+  w.setSurfaceOffset(50, 385);
   w.draw();
 
   w.nextSymbol = WSymbol::SKIPBACK;
-  w.setScreenPos(screenX + 85, screenY + 385);
+  w.setSurfaceOffset(85, 385);
   w.draw();
 
   w.nextSymbol = WSymbol::SKIPFORWARD;
-  w.setScreenPos(screenX + 115, screenY + 385);
+  w.setSurfaceOffset(115, 385);
   w.draw();
 
   w.nextSymbol = WSymbol::PLAY;
-  w.setScreenPos(screenX + 150, screenY + 385);
+  w.setSurfaceOffset(150, 385);
   w.draw();
 
   doShowingBar();
@@ -126,11 +128,15 @@ void VChannelList::doShowingBar()
 
   char showing[200];
   sprintf(showing, "%i to %i of %i", topOption, sl.getBottomOption(), sl.getNumOptions());
-  Box b;
-  b.setScreenPos(screenX + 220, screenY + 385);
-  b.setDimensions(160, 25);
-  b.fillColour(Colour::VIEWBACKGROUND);
-  b.drawText(showing, 0, 0, Colour::LIGHTTEXT);
+
+//  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);
 }
 
 int VChannelList::handleCommand(int command)
index 9fcb669fc34e22a98277e73629de5ed00f5ed415..ade2a2027092583e9c886d5759de439c1332a1ba 100644 (file)
@@ -50,7 +50,6 @@ class VChannelList : public View
 
   private:
     ChannelList* chanList;
-    ULONG type;
 
     WSelectList sl;
 
index fb93a2a3049e58d3726fadf89f26871f23a60c06..24ce79e7f06bda9594a4103f770c89f6905be914 100644 (file)
@@ -25,7 +25,7 @@
 
 VChannelSelect::VChannelSelect(VVideoLive* v, int command)
 {
-  setDimensions(53, 30);
+  create(53, 30);
   setScreenPos(80, 60);
 
   setBackgroundColour(Colour::VIEWBACKGROUND);
index 75a52927d2938b9b6f66397f771ccc8042920bea..9c3affca0835fd252e120d0b5e5225591a449986 100644 (file)
@@ -25,7 +25,7 @@ VConnect::VConnect()
   vdr = VDR::getInstance();
   logger = Log::getInstance();
 
-  setDimensions(400, 200);
+  create(400, 200);
   if (Video::getInstance()->getFormat() == Video::PAL)
   {
     setScreenPos(170, 200);
@@ -49,6 +49,7 @@ VConnect::~VConnect()
 void VConnect::draw()
 {
   VInfo::draw();
+  logger->log("VConnect", Log::DEBUG, "Draw done");
 }
 
 int VConnect::handleCommand(int command)
@@ -93,7 +94,7 @@ void VConnect::threadMethod()
       threadWaitForSignal();
     }
 
-    logger->log("Command", Log::NOTICE, "Connecting to server at %s", serverIPs[selectedServer]);
+    logger->log("VConnect", Log::NOTICE, "Connecting to server at %s", serverIPs[selectedServer]);
     vdr->setServerIP(serverIPs[selectedServer]);
 
     // Clear the serverIPs vector
diff --git a/view.cc b/view.cc
index 8c7831c8720098f07bc5a9b516b7ece7ef4d3e07..33c54206768429e66c55135d9d79dacc31ffc275 100644 (file)
--- a/view.cc
+++ b/view.cc
@@ -38,6 +38,8 @@ View::View()
 
   titleText = NULL;
 
+  surface = NULL;
+
   numViews++;
   Log::getInstance()->log("View", Log::DEBUG, "Construct %p, now %u", this, numViews);
 }
@@ -46,10 +48,21 @@ View::~View()
 {
   if (titleText) delete[] titleText;
 
+  delete surface;
+
   numViews--;
   Log::getInstance()->log("View", Log::DEBUG, "Destruct, now %u", numViews);
 }
 
+bool View::create(UINT w, UINT h)
+{
+  width = w;
+  height = h;
+
+  surface = new Surface();
+  return surface->create(width, height);
+}
+
 void View::setTitleText(char* takeText)
 {
   int length = strlen(takeText);
diff --git a/view.h b/view.h
index bfe38316b4a3650971afa401c6be0059e15a19e9..0cc12b2d6f5ed90aded2619251102e7964bcb565 100644 (file)
--- a/view.h
+++ b/view.h
@@ -34,6 +34,7 @@ class View : public Box
   public:
     View();
     virtual ~View();
+    bool create(UINT width, UINT height);
 
     virtual void draw();
     virtual int handleCommand(int command);
index 70a36548e0688fa2f64d9e80fec0ebe12a4b4a14..8840d86d0d29c98b2a407723453f042b130d8e65 100644 (file)
@@ -57,6 +57,7 @@ int ViewMan::shutdown()
 {
   if (!initted) return 0;
 
+  // FIXME don't think this can work properly, removeAll leaves the wallpaper there!
   removeAll();
 
   // get the lock here to ensure that the thread is waiting on the cond
@@ -172,7 +173,6 @@ int ViewMan::removeView(View* toDelete, int noLock, int noShow)
            && ((toDelete->getScreenY() + toDelete->getHeight()) <= (newTopBox->getScreenY() + newTopBox->getHeight()))
           )
   {
-    newTopBox->draw();
     newTopBox->show();
     Log::getInstance()->log("ViewMan", Log::DEBUG, "re-draw using optimisation 2");
   }
@@ -186,7 +186,12 @@ int ViewMan::removeView(View* toDelete, int noLock, int noShow)
   // no optimisations left, redo everything.
   else
   {
-    redrawAll(noShow);
+    for (int j = 1; j <= topView; j++)
+    {
+      views[j]->show(1);
+    }
+    if (!noShow) Surface::bufferToScreen();
+
     Log::getInstance()->log("ViewMan", Log::DEBUG, "re-draw using no optimisation");
   }
 
@@ -249,16 +254,6 @@ int ViewMan::isTotallyCovered(View* toDelete, int slotTakenFrom)
   }
 }
 
-void ViewMan::redrawAll(int noShow)
-{
-  for (int i = 1; i <= topView; i++)
-  {
-    views[i]->draw();
-  }
-
-  if (!noShow) Box::showAll();
-}
-
 // ---------------------------------------------------- END OF REMOVE CODE
 
 
@@ -273,6 +268,8 @@ void ViewMan::removeAll()
     delete views[topView];
   }
 
+  Surface::bufferToScreen();
+
   resetThread();
   pthread_mutex_unlock(&viewManLock);
 }
@@ -372,7 +369,7 @@ void ViewMan::processMessage(Message* m)
     }
     case Message::UPDATE_SCREEN:
     {
-      Box::showAll();
+      Surface::bufferToScreen();
       break;
     }
     case Message::SWAP_ME_FOR:
@@ -391,7 +388,8 @@ void ViewMan::processMessage(Message* m)
         toReplace->delNSec = currentTime.tv_nsec;
       }
       toReplace->draw();
-      Box::showAll();
+      toReplace->show();
+      Surface::bufferToScreen();
       resetThread();
       break;
     }
@@ -400,16 +398,16 @@ void ViewMan::processMessage(Message* m)
       View* toAdd = (View*)m->parameter;
       addNoLock(toAdd);
       toAdd->draw();
-      Box::showAll();
+      toAdd->show();
     }
   }
 }
 
-int ViewMan::timedDelete(View* v, int seconds, int lock)
+int ViewMan::timedDelete(View* v, int seconds, int lockMutex)
 {
   int success;
 
-  if (lock) pthread_mutex_lock(&viewManLock);
+  if (lockMutex) pthread_mutex_lock(&viewManLock);
 
   struct timespec currentTime;
   clock_gettime(CLOCK_REALTIME, &currentTime);
@@ -437,7 +435,7 @@ int ViewMan::timedDelete(View* v, int seconds, int lock)
   }
 
   resetThread();
-  if (lock) pthread_mutex_unlock(&viewManLock);
+  if (lockMutex) pthread_mutex_unlock(&viewManLock);
 
   return success;
 }
@@ -473,9 +471,9 @@ void ViewMan::startAutoDeleteThread3()
   View* nextToDelete = NULL;
 
   // I don't want signals
-  sigset_t sigset;
-  sigfillset(&sigset);
-  pthread_sigmask(SIG_BLOCK, &sigset, NULL);
+  sigset_t sigs;
+  sigfillset(&sigs);
+  pthread_sigmask(SIG_BLOCK, &sigs, NULL);
 
   // locked here
 
index bd0eb7e98f4cb59c8efd7a6cccd6631fa8b44761..40da7401b1a13d724074626c7755ad457f3b7d40 100644 (file)
--- a/viewman.h
+++ b/viewman.h
@@ -31,6 +31,7 @@
 #include "message.h"
 #include "messagequeue.h"
 #include "remote.h"
+#include "surface.h"
 
 class ViewMan : public MessageQueue
 {
@@ -47,11 +48,9 @@ class ViewMan : public MessageQueue
     int addNoLock(View* v);
     int removeView(View* toRemove = NULL, int noLock = 0, int noShow = 0);
     void removeAll();
-    void redrawAll(int noShow = 0);
 
     int handleCommand(UCHAR command);
     int timedDelete(View* v, int seconds, int lock);
-    //
 
     // not for external use
     void startAutoDeleteThread3();
index 39c4ef7f649ccb6dee731c35a8102839b3d9cc63..1c1dcf0817e20ab8e9b8d95715780c88d982149a 100644 (file)
@@ -25,6 +25,7 @@ VLiveBanner::VLiveBanner(View* tparent, Channel* channel)
   eventList = NULL;
   parent = tparent;
 
+  create(500, 120);
   if (Video::getInstance()->getFormat() == Video::PAL)
   {
     setScreenPos(125, 410);
@@ -34,13 +35,13 @@ VLiveBanner::VLiveBanner(View* tparent, Channel* channel)
     setScreenPos(115, 320);
   }
 
-  setDimensions(500, 120);
 
   setBackgroundColour(Colour::VIEWBACKGROUND);
   setTitleBarOn(1);
   setTitleBarColour(Colour::TITLEBARBACKGROUND);
 
-  sl.setScreenPos(screenX, screenY + 30);
+  sl.setSurface(surface);
+  sl.setSurfaceOffset(0, 30);
   sl.setDimensions(width, height - 60);
   sl.setNoLoop();
 
@@ -194,7 +195,7 @@ int VLiveBanner::handleCommand(int command)
           {
             vi->setScreenPos(110, 90);
           }
-          vi->setDimensions(510, 270);
+          vi->create(510, 270);
 
           ViewMan::getInstance()->addNoLock(vi);
           vi->draw();
index b4df9994a41ae5475e727dedf5b5359b9b368064..f7eb1a36452b8ba66b494d1057868f0bf5b3c5e8 100644 (file)
--- a/vmute.cc
+++ b/vmute.cc
@@ -24,6 +24,7 @@ VMute::VMute()
 {
   isMuted = Audio::getInstance()->toggleUserMute();
 
+  create(40, 40);
   if (Video::getInstance()->getFormat() == Video::PAL)
   {
     setScreenPos(600, 500);
@@ -33,8 +34,6 @@ VMute::VMute()
     setScreenPos(590, 400);
   }
 
-  setDimensions(40, 40);
-
   setBackgroundColour(Colour::VIEWBACKGROUND);
 }
 
@@ -42,13 +41,12 @@ void VMute::draw()
 {
   View::draw();
 
-  WSymbol* w = new WSymbol;
-  if (isMuted) w->nextSymbol = WSymbol::MUTE;
-  else w->nextSymbol = WSymbol::UNMUTE;
-  w->setScreenPos(screenX + 5, screenY + 5);
-  w->draw();
-
-  delete w;
+  WSymbol w;
+  w.setSurface(surface);
+  if (isMuted) w.nextSymbol = WSymbol::MUTE;
+  else w.nextSymbol = WSymbol::UNMUTE;
+  w.setSurfaceOffset(5, 5);
+  w.draw();
 }
 
 int VMute::handleCommand(int command)
index d8e15dd13d629d6fef1c896f2f08bce8d3ef373e..f451e121c47f64438d373ec339246bd3ed1818d0 100644 (file)
@@ -22,8 +22,7 @@
 
 VOptions::VOptions()
 {
-  setDimensions(500, 250);
-
+  create(500, 250);
   if (Video::getInstance()->getFormat() == Video::PAL)
   {
     setScreenPos(120, 140);
@@ -40,28 +39,33 @@ VOptions::VOptions()
 
   int fontHeight = surface->getFontHeight();
 
-  optionBox[0].setScreenPos(screenX + 330, screenY + 45);
+  optionBox[0].setSurface(surface);
+  optionBox[0].setSurfaceOffset(330, 45);
   optionBox[0].setDimensions(150, fontHeight);
   optionBox[0].addOption("Old");
   optionBox[0].addOption("New");
 
-  optionBox[1].setScreenPos(screenX + 330, screenY + 75);
+  optionBox[1].setSurface(surface);
+  optionBox[1].setSurfaceOffset(330, 75);
   optionBox[1].setDimensions(150, fontHeight);
   optionBox[1].addOption("RGB+composite");
   optionBox[1].addOption("S-Video");
 
-  optionBox[2].setScreenPos(screenX + 330, screenY + 105);
+  optionBox[2].setSurface(surface);
+  optionBox[2].setSurfaceOffset(330, 105);
   optionBox[2].setDimensions(150, fontHeight);
   optionBox[2].addOption("4:3");
   optionBox[2].addOption("16:9");
 
-  optionBox[3].setScreenPos(screenX + 330, screenY + 135);
+  optionBox[3].setSurface(surface);
+  optionBox[3].setSurfaceOffset(330, 135);
   optionBox[3].setDimensions(150, fontHeight);
   optionBox[3].addOption("On");
   optionBox[3].addOption("Off");
   optionBox[3].addOption("Last state");
 
-  optionBox[4].setScreenPos(screenX + 330, screenY + 165);
+  optionBox[4].setSurface(surface);
+  optionBox[4].setSurfaceOffset(330, 165);
   optionBox[4].setDimensions(150, fontHeight);
   optionBox[4].addOption("All");
   optionBox[4].addOption("FTA only");
@@ -172,6 +176,8 @@ void VOptions::draw()
 
   drawText("Press back to exit, <, > or [ok] to change", 10, 220, Colour::LIGHTTEXT);
 
+  wsy.setSurface(surface);
+
   for (UINT i = 0; i < numOptions; i++)
   {
     if (i == selectedOption) cl = Colour::SELECTHIGHLIGHT;
@@ -180,10 +186,10 @@ void VOptions::draw()
     wsy.nextSymbol = WSymbol::LEFTARROW;
     wsy.nextColour = cl;
 
-    wsy.setScreenPos(screenX + 312, screenY + 47 + (i * 30));
+    wsy.setSurfaceOffset(312, 47 + (i * 30));
     wsy.draw();
     wsy.nextSymbol = WSymbol::RIGHTARROW;
-    wsy.setScreenPos(screenX + 482, screenY + 47 + (i * 30));
+    wsy.setSurfaceOffset(482, 47 + (i * 30));
     wsy.draw();
     optionBox[i].draw();
     optionBox[i].show();
index f0c2dab303ab53c648c95d08255bc3ca8ee0d033..9ca83afe527dc0089048fccdfa5c1b108fab3bdc 100644 (file)
@@ -25,10 +25,12 @@ VQuestion::VQuestion()
   mainText = NULL;
   selectedOption = NO;
 
+  buttonYes.setSurfaceOffset(40, 120);
+  buttonNo.setSurfaceOffset(140, 120);
+
   buttonYes.setText("Yes");
   buttonNo.setText("No");
   buttonNo.setActive(1);
-
 }
 
 VQuestion::~VQuestion()
@@ -47,8 +49,8 @@ void VQuestion::draw()
 {
   View::draw();
 
-  buttonYes.setScreenPos(screenX + 40, screenY + 120);
-  buttonNo.setScreenPos(screenX + 140, screenY + 120);
+  buttonYes.setSurface(surface);
+  buttonNo.setSurface(surface);
 
   if (mainText) drawPara(mainText, 10, 45, Colour::LIGHTTEXT);
   buttonYes.draw();
index 57f17e3c79083439687a25a7cf90e54cfeed8177..08b76cc1b608b238a88757d42dda75f8e7c4f878 100644 (file)
@@ -28,7 +28,7 @@ VRadioLive::VRadioLive(ChannelList* tchanList)
   chanList = tchanList;
   currentChannel = 0;
 
-  setDimensions(100, 100);
+  create(100, 100);
   setBackgroundColour(Colour::VIEWBACKGROUND);
 }
 
index b483ed079e220b9ebe3bf748ca8182febfc9b672..f0f7a3850a976f481776d270c530ca209b8361fd 100644 (file)
 
 #include "vrecordinglist.h"
 
-VRecordingList::VRecordingList(VRecordingList* parent)
+VRecordingList::VRecordingList(VRecordingList* tparent)
 {
-  myParent = parent;
+  myParent = tparent;
   dataInvalid = 0;
 
+  create(570, 420);
   if (Video::getInstance()->getFormat() == Video::PAL)
   {
     setScreenPos(80, 70);
@@ -34,13 +35,12 @@ VRecordingList::VRecordingList(VRecordingList* parent)
     setScreenPos(70, 35);
   }
 
-  setDimensions(570, 420);
-
   setBackgroundColour(Colour::VIEWBACKGROUND);
   setTitleBarOn(1);
   setTitleBarColour(Colour::TITLEBARBACKGROUND);
 
-  sl.setScreenPos(screenX + 10, screenY + 30 + 5);
+  sl.setSurface(surface);
+  sl.setSurfaceOffset(10, 30 + 5);
   sl.setDimensions(width - 20, height - 30 - 15 - 30);
 }
 
@@ -100,9 +100,9 @@ void VRecordingList::drawData()
 
 
   Recording* rec;
-  for (UINT i = 0; i < recDir->recList.size(); i++)
+  for (UINT j = 0; j < recDir->recList.size(); j++)
   {
-    rec = recDir->recList[i];
+    rec = recDir->recList[j];
     btime = localtime((time_t*)&rec->start);
     strftime(tempA, 299, "%0d/%0m %0H:%0M ", btime);
     sprintf(tempB, "%s\t%s", tempA, rec->getProgName());
@@ -124,25 +124,26 @@ void VRecordingList::draw()
   // Put the status stuff at the bottom
 
   WSymbol w;
+  w.setSurface(surface);
 
   w.nextSymbol = WSymbol::UP;
-  w.setScreenPos(screenX + 20, screenY + 385);
+  w.setSurfaceOffset(20, 385);
   w.draw();
 
   w.nextSymbol = WSymbol::DOWN;
-  w.setScreenPos(screenX + 50, screenY + 385);
+  w.setSurfaceOffset(50, 385);
   w.draw();
 
   w.nextSymbol = WSymbol::SKIPBACK;
-  w.setScreenPos(screenX + 85, screenY + 385);
+  w.setSurfaceOffset(85, 385);
   w.draw();
 
   w.nextSymbol = WSymbol::SKIPFORWARD;
-  w.setScreenPos(screenX + 115, screenY + 385);
+  w.setSurfaceOffset(115, 385);
   w.draw();
 
   w.nextSymbol = WSymbol::PLAY;
-  w.setScreenPos(screenX + 150, screenY + 385);
+  w.setSurfaceOffset(150, 385);
   w.draw();
 
   // FIXME Right justify this!
@@ -163,11 +164,15 @@ void VRecordingList::doShowingBar()
 
   char showing[200];
   sprintf(showing, "%i to %i of %i", topOption, sl.getBottomOption(), sl.getNumOptions());
-  Box b;
-  b.setScreenPos(screenX + 220, screenY + 385);
-  b.setDimensions(160, 25);
-  b.fillColour(Colour::VIEWBACKGROUND);
-  b.drawText(showing, 0, 0, Colour::LIGHTTEXT);
+
+//  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);
 }
 
 
@@ -244,11 +249,15 @@ void VRecordingList::doDeleteSelected()
     ViewMan::getInstance()->postMessage(m1);
   }
 
+
+  show();
+/*
   Message* m2 = new Message();
   m2->from = this;
   m2->to = ViewMan::getInstance();
   m2->message = Message::UPDATE_SCREEN;
   ViewMan::getInstance()->postMessage(m2);
+*/
 }
 
 int VRecordingList::doPlay()
index 96caaf4f640689f53939edd7677de90ace90cc00..2aa6ade65fbed7b723329077454ed3c451958b59 100644 (file)
@@ -24,6 +24,7 @@ VRecordingMenu::VRecordingMenu()
 {
   rec = NULL;
 
+  create(200, 140);
   if (Video::getInstance()->getFormat() == Video::PAL)
   {
     setScreenPos(260, 190);
@@ -33,7 +34,6 @@ VRecordingMenu::VRecordingMenu()
     setScreenPos(250, 160);
   }
 
-  setDimensions(200, 140);
 
   setBackgroundColour(Colour::VIEWBACKGROUND);
   setTitleBarOn(1);
@@ -41,7 +41,8 @@ VRecordingMenu::VRecordingMenu()
   setTitleText("Programme menu");
   setTitleBarColour(Colour::TITLEBARBACKGROUND);
 
-  sl.setScreenPos(screenX + 10, screenY + 30 + 5);
+  sl.setSurface(surface);
+  sl.setSurfaceOffset(10, 30 + 5);
   sl.setDimensions(width - 20, height - 30 - 15);
   sl.addOption("Play", 1);
   sl.addOption("Resume", 0);
@@ -129,7 +130,7 @@ int VRecordingMenu::handleCommand(int command)
         {
           vi->setScreenPos(110, 90);
         }
-        vi->setDimensions(490, 300);
+        vi->create(490, 300);
 
         ViewMan::getInstance()->addNoLock(vi);
         vi->draw();
@@ -142,6 +143,7 @@ int VRecordingMenu::handleCommand(int command)
       else if (sl.getCurrentOption() == 3)
       {
         VQuestion* v = new VQuestion();
+        v->create(260, 180);
         v->setParent(this);
         v->setBackgroundColour(Colour::VIEWBACKGROUND);
         v->setTitleBarColour(Colour::DANGER);
@@ -158,7 +160,6 @@ int VRecordingMenu::handleCommand(int command)
         {
           v->setScreenPos(220, 140);
         }
-        v->setDimensions(260, 180);
 
         ViewMan::getInstance()->addNoLock(v);
         v->draw();
index 3f629122c09a95ffd1325aa9ff354160117dee54..a0055c55fa96c2ee7a14bebe43e77c910d11aebb 100644 (file)
@@ -27,6 +27,7 @@ VServerSelect::VServerSelect(std::vector<char*>* serverIPs)
   // a char array. so now we have the messy dereferencing...
   // anyway, now it doesn't use a object wide reference.
 
+  create(300, 200);
   if (Video::getInstance()->getFormat() == Video::PAL)
   {
     setScreenPos(220, 200);
@@ -35,13 +36,13 @@ VServerSelect::VServerSelect(std::vector<char*>* serverIPs)
   {
     setScreenPos(210, 150);
   }
-  setDimensions(300, 200);
+
   setBackgroundColour(Colour::VIEWBACKGROUND);
   setTitleBarOn(1);
   setTitleBarColour(Colour::TITLEBARBACKGROUND);
   setTitleText("Choose a VDR server");
 
-  sl.setScreenPos(screenY + 30 + 5, screenX + 10);
+  sl.setSurfaceOffset(30 + 5, 10);
   sl.setDimensions(width - 20, height - 30 - 15);
 
   sl.addOption((*serverIPs)[0], 1);
index 3e6dde2fd959eca7f182891657a15fe1f5e015f9..aab8f089baf83b5001c188cfb9467f45bc37e0a8 100644 (file)
@@ -43,7 +43,7 @@ VVideoLive::VVideoLive(ChannelList* tchanList, ULONG tstreamType)
   player->init();
 
   Video* video = Video::getInstance();
-  setDimensions(video->getScreenWidth(), video->getScreenHeight());
+  create(video->getScreenWidth(), video->getScreenHeight());
   Colour transparent(0, 0, 0, 0);
   setBackgroundColour(transparent);
 }
@@ -183,7 +183,7 @@ void VVideoLive::showUnavailable(int active)
     unavailable = 1;
 
     unavailableView = new VInfo();
-    unavailableView->setDimensions(400, 200);
+    unavailableView->create(400, 200);
     if (Video::getInstance()->getFormat() == Video::PAL)
     {
       unavailableView->setScreenPos(170, 200);
index a514b7644e70724b01bd0efea34798973ab46700..7f1339236eb3752f26e08ff9beed77da85127e09 100644 (file)
@@ -29,7 +29,7 @@ VVideoRec::VVideoRec(Recording* rec)
   myRec = rec;
 
   Video* video = Video::getInstance();
-  setDimensions(video->getScreenWidth(), video->getScreenHeight());
+  create(video->getScreenWidth(), video->getScreenHeight());
   Colour transparent(0, 0, 0, 0);
   setBackgroundColour(transparent);
 }
index 9ee1879760e548a6a916d85ab2365964c67478bc..4f8af9fbac5c99167fd81d39669f5b77c27a7071 100644 (file)
@@ -24,6 +24,7 @@ VVolume::VVolume()
 {
   displayVolume = Audio::getInstance()->getVolume();
 
+  create(227, 31);
   if (Video::getInstance()->getFormat() == Video::PAL)
   {
     setScreenPos(100, 499);
@@ -33,8 +34,6 @@ VVolume::VVolume()
     setScreenPos(90, 400);
   }
 
-  setDimensions(227, 31);
-
   setBackgroundColour(Colour::VIEWBACKGROUND);
 }
 
@@ -42,28 +41,27 @@ void VVolume::draw()
 {
   View::draw();
 
-  WSymbol* w = new WSymbol;
-  w->nextSymbol = WSymbol::VOLUME2;
-  w->setScreenPos(screenX + 3, screenY + 10);
-  w->draw();
+  WSymbol w;
+  w.setSurface(surface);
+  w.nextSymbol = WSymbol::VOLUME2;
+  w.setSurfaceOffset(3, 10);
+  w.draw();
 
   int i = 0;
 
   for(; i < displayVolume; i++)
   {
-    w->nextSymbol = WSymbol::VOLBAR;
-    w->setScreenPos(screenX + 40 + (i * 9), screenY + 3);
-    w->draw();
+    w.nextSymbol = WSymbol::VOLBAR;
+    w.setSurfaceOffset(40 + (i * 9), 3);
+    w.draw();
   }
 
   for(; i < 20; i++)
   {
-    w->nextSymbol = WSymbol::VOLDOT;
-    w->setScreenPos(screenX + 40 + (i * 9), screenY + 13);
-    w->draw();
+    w.nextSymbol = WSymbol::VOLDOT;
+    w.setSurfaceOffset(40 + (i * 9), 13);
+    w.draw();
   }
-
-  delete w;
 }
 
 int VVolume::handleCommand(int command)
index 69de4df17ef68fe2922e66684233ddc74fc17536..c432340d3eebd3fdb0df993571712cbd6a9f5401 100644 (file)
@@ -27,28 +27,19 @@ VWallpaper::VWallpaper()
 
 VWallpaper::~VWallpaper()
 {
-  delete surface;
 }
 
 void VWallpaper::init(char* name)
 {
-  jpeg.init(name);
-
   Video* video = Video::getInstance();
-  setDimensions(video->getScreenWidth(), video->getScreenHeight());
-
-  // Now override the surface pointer found in Box to a seperate wallpaper surface
-  // but only for the wjpeg, not for this object
-  wallpaperSurface = new Surface(Osd::getInstance()->getFD(), 0);
-  wallpaperSurface->create(height, width);
+  create(video->getScreenWidth(), video->getScreenHeight());
 
-  jpeg.overrideSurface(wallpaperSurface);
-  jpeg.draw();
+  jpeg.init(name);
+  jpeg.setSurface(surface);
 }
 
 void VWallpaper::draw()
 {
-  // we want to blit from wallpaperSurface to buffer (or screen if !doubleBuffer)
-  Surface::blt(Osd::getInstance()->getFD(), wallpaperSurface->getSurfaceHandle(), 0, 0, width, height, surface->getSurfaceHandle(), 0, 0);
-  // and the fd business here is terrible, but what can you do.
+  View::draw();
+  jpeg.draw();
 }
index f27b6a7bea4226ac68be599a256d5b04f1985ced..d5e8dc7627914bb338b1bb07d9169f6afedcb89d 100644 (file)
@@ -22,8 +22,7 @@
 
 VWelcome::VWelcome()
 {
-  setDimensions(460, 200);
-
+  create(460, 200);
   if (Video::getInstance()->getFormat() == Video::PAL)
   {
     setScreenPos(140, 170);
@@ -33,12 +32,15 @@ VWelcome::VWelcome()
     setScreenPos(130, 140);
   }
 
+  sl.setSurface(surface);
+  jpeg.setSurface(surface);
+
   setBackgroundColour(Colour::VIEWBACKGROUND);
   setTitleBarOn(1);
   setTitleBarColour(Colour::TITLEBARBACKGROUND);
   setTitleText("Welcome");
 
-  sl.setScreenPos(screenX + 20, screenY + 40);
+  sl.setSurfaceOffset(20, 40);
   sl.setDimensions(170, 140);
 
   sl.addOption("1. Live TV", 1);
@@ -48,7 +50,7 @@ VWelcome::VWelcome()
   sl.addOption("5. Stand by", 0);
   sl.addOption("6. Reboot", 0);
 
-  jpeg.setScreenPos(screenX + 240, screenY + 60);
+  jpeg.setSurfaceOffset(240, 60);
 }
 
 VWelcome::~VWelcome()
@@ -64,8 +66,8 @@ void VWelcome::draw()
   char timeString[20];
   time_t t;
   time(&t);
-  struct tm* tm = localtime(&t);
-  strftime(timeString, 19, "%H:%M", tm);
+  struct tm* tms = localtime(&t);
+  strftime(timeString, 19, "%H:%M", tms);
 
   drawTextRJ(timeString, 450, 5, Colour::LIGHTTEXT);
 
@@ -180,6 +182,7 @@ void VWelcome::doChannelsList()
     vchan->draw();
     vchan->show();
 
+
 //        Message* m = new Message();
 //        m->from = this;
 //        m->to = ViewMan::getInstance();
@@ -209,7 +212,7 @@ void VWelcome::doRecordingsList()
   ViewMan* viewman = ViewMan::getInstance();
 
   VInfo* viewWait = new VInfo();
-  viewWait->setDimensions(460, 190);
+  viewWait->create(460, 190);
   if (Video::getInstance()->getFormat() == Video::PAL)
   {
     viewWait->setScreenPos(140, 170);
index f66548c000b4c5d71c403856f49642bd5dd8ffbf..194d49e5397b4471e0102044ab2dbecbfc48386c 100644 (file)
@@ -22,7 +22,7 @@
 
 WButton::WButton()
 {
-  int fontHeight = surface->getFontHeight();
+  int fontHeight = Surface::getFontHeight();
   setDimensions(70, fontHeight);
 
   mytext = NULL;
index f93d9fee554bba5ffe82796c4cddb0d7b0452de1..cbe1cbd0d0cd025f78971265cfe0520c0be4f9e2 100644 (file)
--- a/wbutton.h
+++ b/wbutton.h
 #include <string.h>
 
 #include "defines.h"
-#include "box.h"
+#include "widget.h"
 #include "colour.h"
 
-class WButton : public Box
+class WButton : public Widget
 {
   public:
     WButton();
diff --git a/widget.cc b/widget.cc
new file mode 100644 (file)
index 0000000..8317fa6
--- /dev/null
+++ b/widget.cc
@@ -0,0 +1,42 @@
+/*
+    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()
+{
+  width = 0;
+  height = 0;
+}
+
+Widget::~Widget()
+{
+}
+
+void Widget::setSurface(Surface* tsurface)
+{
+  surface = tsurface;
+}
+
+void Widget::setDimensions(int twidth, int theight)
+{
+  width = twidth;
+  height = theight;
+}
diff --git a/widget.h b/widget.h
new file mode 100644 (file)
index 0000000..29f12e5
--- /dev/null
+++ b/widget.h
@@ -0,0 +1,43 @@
+/*
+    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 WIDGET_H
+#define WIDGET_H
+
+#include "log.h"
+#include "box.h"
+#include "defines.h"
+
+// Abstract
+class Widget : public Box
+{
+  public:
+    Widget();
+    virtual ~Widget();
+    virtual void draw()=0;
+    void setSurface(Surface* tsurface);
+    void setDimensions(int width, int height);
+
+  private:
+
+  protected:
+};
+
+#endif
index b99489ce1bb0df1c11e82e83b36bbc9515146e7e..b803564355c68132aeb7484b6d8065b6e064faaa 100644 (file)
--- a/wjpeg.cc
+++ b/wjpeg.cc
 
 #include "wjpeg.h"
 
-int WJpeg::init(char* fileName)
+int WJpeg::init(char* tfileName)
 {
-  this->fileName = fileName;
+  fileName = tfileName;
   return 1;
 }
 
-void WJpeg::overrideSurface(Surface* newSurface)
-{
-  surface = newSurface;
-}
-
 void WJpeg::draw()
 {
   Log* logger = Log::getInstance();
@@ -51,7 +46,7 @@ void WJpeg::draw()
   jpeg_read_header(&cinfo, TRUE);
   jpeg_start_decompress(&cinfo);
 
-  logger->log("BJpeg", Log::DEBUG, "JPEG startup done");
+  logger->log("BJpeg", Log::DEBUG, "JPEG startup done %i %i", cinfo.output_width, cinfo.output_height);
 
   // Init the surface
   setDimensions(cinfo.output_width, cinfo.output_height);
@@ -59,17 +54,18 @@ void WJpeg::draw()
 
   // MAKE THE 2D ARRAY
 
-  unsigned char* buffer = (unsigned char*)malloc(height * width * 3);
-  logger->log("BJpeg", Log::DEBUG, "Buffer allocated at %p", buffer);
+  unsigned char* buffer = (unsigned char*)malloc(width * height * 3);
+  logger->log("BJpeg", Log::DEBUG, "Buffer allocated at %p, width = %i height = %i", buffer, width, height);
 
   unsigned char* bufferPointers[height];
-  for(int ps = 0; ps < height; ps++) bufferPointers[ps] = buffer + (ps * width * 3);
+  for(UINT ps = 0; ps < height; ps++) bufferPointers[ps] = buffer + (ps * width * 3);
 
   logger->log("BJpeg", Log::DEBUG, "done array check");
 
   int rowsread = 0;
   while (cinfo.output_scanline < cinfo.output_height)
   {
+//  logger->log("BJpeg", Log::DEBUG, "%i", rowsread);
     rowsread += jpeg_read_scanlines(&cinfo, &bufferPointers[rowsread], height);
   }
 
@@ -82,8 +78,8 @@ void WJpeg::draw()
 
   logger->log("BJpeg", Log::DEBUG, "jpeg shutdown done, x, y %u %u", width, height);
 
-  unsigned int c;
-  int x, y, xoff;
+  Colour c;
+  UINT x, y, xoff;
   unsigned char* p;
 
   for (y = 0; y < height; y++)
@@ -94,12 +90,16 @@ void WJpeg::draw()
     {
       xoff = x * 3;
 
-      c = (  (0xFF000000        )
-           | (p[xoff    ]  << 16)
-           | (p[xoff + 1]  <<  8)
-           | (p[xoff + 2]       ) );
+//      c = (  (0xFF000000        )
+//           | (p[xoff    ]  << 16)
+//           | (p[xoff + 1]  <<  8)
+//           | (p[xoff + 2]       ) );
+
+      c.red = p[xoff];
+      c.green = p[xoff + 1];
+      c.blue = p[xoff + 2];
 
-      surface->drawPixel(screenX + x, screenY + y, c);
+      drawPixel(x, y, c);
     }
   }
 
diff --git a/wjpeg.h b/wjpeg.h
index 2b43df7435c24823f627ceb098332944954d1bf0..a647cd1ca8e5a1c823306dceeed6773b9fecbfff 100644 (file)
--- a/wjpeg.h
+++ b/wjpeg.h
@@ -29,18 +29,16 @@ extern "C"
 }
 
 #include "log.h"
-#include "box.h"
+#include "widget.h"
 #include "surface.h"
 
-class WJpeg : public Box
+class WJpeg : public Widget
 {
   public:
 
     int init(char* fileName);
     void draw();
 
-    void overrideSurface(Surface *newSurface);
-
   private:
     char* fileName;
 };
index 25253eb5e0a3588c06fb85d28c360dbcf451d915..c9e8def0997ac75859afb6ceacef435fa0a15e53 100644 (file)
 #include <stdlib.h>
 
 #include "defines.h"
-#include "box.h"
+#include "widget.h"
 #include "colour.h"
 
-class WOptionBox : public Box
+class WOptionBox : public Widget
 {
   public:
     WOptionBox();
index 2e3fc6cc3df580c8bf34eebf217f2debc8538630..85c50e7bac7da5c365e563e6b5863f6d0d1258e2 100644 (file)
@@ -54,15 +54,15 @@ void WSelectList::setNoLoop()
   noLoop = 1;
 }
 
-void WSelectList::hintSetCurrent(int index)
+void WSelectList::hintSetCurrent(int idx)
 {
-  selectedOption = index;
+  selectedOption = idx;
   if (selectedOption >= options.size()) selectedOption = options.size() - 1;
 }
 
-void WSelectList::hintSetTop(int index)
+void WSelectList::hintSetTop(int idx)
 {
-  topOption = index;
+  topOption = idx;
 }
 
 int WSelectList::addOption(char* text, int selected)
@@ -96,7 +96,7 @@ void WSelectList::draw()
 
   fillColour(Colour::VIEWBACKGROUND);
 
-  int ypos = 5;
+  UINT ypos = 5;
   for (UINT i = topOption; i < (topOption + numOptionsDisplayable); i++)
   {
     if (i == options.size()) return;
index 473e813eec3bf929908dde0622a40f54e1cef22c..c411cb7a66f0d76741e4837da7a9f5ccbdcccba5 100644 (file)
 #include <vector>
 
 #include "defines.h"
-#include "box.h"
+#include "widget.h"
 #include "colour.h"
 
 using namespace std;
 
-class WSelectList : public Box
+class WSelectList : public Widget
 {
   public:
     WSelectList();
index efc9ea16652b10cce7c7ad164e972ac766226874..15cbae44636653feb4ce2640e17edce47afbccac 100644 (file)
@@ -616,11 +616,11 @@ void WSymbol::draw()
   UCHAR* base = symbols + offset;
   int widthBytes = widths[nextSymbol];
   int widthBits = widthBytes * 8;
-  int height = heights[nextSymbol];
+  int sHeight = heights[nextSymbol];
 
   int x, y, bytesIn, bitsIn;
 
-  for (y = 0; y < height; y++)
+  for (y = 0; y < sHeight; y++)
   {
     for (x = 0; x < widthBits; x++)
     {
index 6eb672badb7e1bf2fe52ecbddfeeb09bfbae82e6..1ece7923b7c681c4b529b1498ac408359eadfc01 100644 (file)
--- a/wsymbol.h
+++ b/wsymbol.h
 #define WSYMBOL_H
 
 #include "defines.h"
-#include "box.h"
+#include "widget.h"
 #include "colour.h"
 
-class WSymbol : public Box
+class WSymbol : public Widget
 {
   public:
     WSymbol();