From ed7fd031d15c9123b6c3574bb74b2cb1eebb2df8 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Tue, 13 Sep 2005 00:37:08 +0000 Subject: [PATCH] New gui code --- Makefile | 6 +++--- audio.cc | 2 +- box.cc | 42 ++++++++++++++++++++---------------------- box.h | 16 +++++++++------- command.cc | 12 +++++------- main.cc | 8 +++----- osd.cc | 8 ++++---- playerradio.cc | 3 +-- playervideo.cc | 2 +- surface.cc | 32 ++++++++++++++++++++++---------- surface.h | 12 +++++++----- vchannellist.cc | 30 ++++++++++++++++++------------ vchannellist.h | 1 - vchannelselect.cc | 2 +- vconnect.cc | 5 +++-- view.cc | 13 +++++++++++++ view.h | 1 + viewman.cc | 40 +++++++++++++++++++--------------------- viewman.h | 3 +-- vlivebanner.cc | 7 ++++--- vmute.cc | 16 +++++++--------- voptions.cc | 24 +++++++++++++++--------- vquestion.cc | 8 +++++--- vradiolive.cc | 2 +- vrecordinglist.cc | 43 ++++++++++++++++++++++++++----------------- vrecordingmenu.cc | 9 +++++---- vserverselect.cc | 5 +++-- vvideolive.cc | 4 ++-- vvideorec.cc | 2 +- vvolume.cc | 26 ++++++++++++-------------- vwallpaper.cc | 19 +++++-------------- vwelcome.cc | 17 ++++++++++------- wbutton.cc | 2 +- wbutton.h | 4 ++-- widget.cc | 42 ++++++++++++++++++++++++++++++++++++++++++ widget.h | 43 +++++++++++++++++++++++++++++++++++++++++++ wjpeg.cc | 36 ++++++++++++++++++------------------ wjpeg.h | 6 ++---- woptionbox.h | 4 ++-- wselectlist.cc | 10 +++++----- wselectlist.h | 4 ++-- wsymbol.cc | 4 ++-- wsymbol.h | 4 ++-- 43 files changed, 349 insertions(+), 230 deletions(-) create mode 100644 widget.cc create mode 100644 widget.h diff --git a/Makefile b/Makefile index 49e0e22..9c60e3f 100644 --- 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 diff --git a/audio.cc b/audio.cc index d47bf48..01e53e1 100644 --- 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 30b24b6..dc28da5 100644 --- 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 93f8b31..8f48056 100644 --- 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; diff --git a/command.cc b/command.cc index 26932f6..5455c9a 100644 --- a/command.cc +++ b/command.cc @@ -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 0d6e4a6..490c8ca 100644 --- 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 9b7814c..71190f0 100644 --- 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 { diff --git a/playerradio.cc b/playerradio.cc index 03d291d..ec41b2b 100644 --- a/playerradio.cc +++ b/playerradio.cc @@ -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 diff --git a/playervideo.cc b/playervideo.cc index 999e8d0..bfb7331 100644 --- a/playervideo.cc +++ b/playervideo.cc @@ -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"); diff --git a/surface.cc b/surface.cc index 20a5143..13af55e 100644 --- a/surface.cc +++ b/surface.cc @@ -20,22 +20,22 @@ */ #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) diff --git a/surface.h b/surface.h index 8cf8b7a..1b5dfa4 100644 --- a/surface.h +++ b/surface.h @@ -161,17 +161,20 @@ extern "C" #include } +#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); diff --git a/vchannellist.cc b/vchannellist.cc index f8d196b..4f66b0b 100644 --- a/vchannellist.cc +++ b/vchannellist.cc @@ -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) diff --git a/vchannellist.h b/vchannellist.h index 9fcb669..ade2a20 100644 --- a/vchannellist.h +++ b/vchannellist.h @@ -50,7 +50,6 @@ class VChannelList : public View private: ChannelList* chanList; - ULONG type; WSelectList sl; diff --git a/vchannelselect.cc b/vchannelselect.cc index fb93a2a..24ce79e 100644 --- a/vchannelselect.cc +++ b/vchannelselect.cc @@ -25,7 +25,7 @@ VChannelSelect::VChannelSelect(VVideoLive* v, int command) { - setDimensions(53, 30); + create(53, 30); setScreenPos(80, 60); setBackgroundColour(Colour::VIEWBACKGROUND); diff --git a/vconnect.cc b/vconnect.cc index 75a5292..9c3affc 100644 --- a/vconnect.cc +++ b/vconnect.cc @@ -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 8c7831c..33c5420 100644 --- 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 bfe3831..0cc12b2 100644 --- 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); diff --git a/viewman.cc b/viewman.cc index 70a3654..8840d86 100644 --- a/viewman.cc +++ b/viewman.cc @@ -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, ¤tTime); @@ -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 diff --git a/viewman.h b/viewman.h index bd0eb7e..40da740 100644 --- 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(); diff --git a/vlivebanner.cc b/vlivebanner.cc index 39c4ef7..1c1dcf0 100644 --- a/vlivebanner.cc +++ b/vlivebanner.cc @@ -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(); diff --git a/vmute.cc b/vmute.cc index b4df999..f7eb1a3 100644 --- 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) diff --git a/voptions.cc b/voptions.cc index d8e15dd..f451e12 100644 --- a/voptions.cc +++ b/voptions.cc @@ -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(); diff --git a/vquestion.cc b/vquestion.cc index f0c2dab..9ca83af 100644 --- a/vquestion.cc +++ b/vquestion.cc @@ -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(); diff --git a/vradiolive.cc b/vradiolive.cc index 57f17e3..08b76cc 100644 --- a/vradiolive.cc +++ b/vradiolive.cc @@ -28,7 +28,7 @@ VRadioLive::VRadioLive(ChannelList* tchanList) chanList = tchanList; currentChannel = 0; - setDimensions(100, 100); + create(100, 100); setBackgroundColour(Colour::VIEWBACKGROUND); } diff --git a/vrecordinglist.cc b/vrecordinglist.cc index b483ed0..f0f7a38 100644 --- a/vrecordinglist.cc +++ b/vrecordinglist.cc @@ -20,11 +20,12 @@ #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() diff --git a/vrecordingmenu.cc b/vrecordingmenu.cc index 96caaf4..2aa6ade 100644 --- a/vrecordingmenu.cc +++ b/vrecordingmenu.cc @@ -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(); diff --git a/vserverselect.cc b/vserverselect.cc index 3f62912..a0055c5 100644 --- a/vserverselect.cc +++ b/vserverselect.cc @@ -27,6 +27,7 @@ VServerSelect::VServerSelect(std::vector* 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* 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); diff --git a/vvideolive.cc b/vvideolive.cc index 3e6dde2..aab8f08 100644 --- a/vvideolive.cc +++ b/vvideolive.cc @@ -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); diff --git a/vvideorec.cc b/vvideorec.cc index a514b76..7f13392 100644 --- a/vvideorec.cc +++ b/vvideorec.cc @@ -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); } diff --git a/vvolume.cc b/vvolume.cc index 9ee1879..4f8af9f 100644 --- a/vvolume.cc +++ b/vvolume.cc @@ -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) diff --git a/vwallpaper.cc b/vwallpaper.cc index 69de4df..c432340 100644 --- a/vwallpaper.cc +++ b/vwallpaper.cc @@ -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(); } diff --git a/vwelcome.cc b/vwelcome.cc index f27b6a7..d5e8dc7 100644 --- a/vwelcome.cc +++ b/vwelcome.cc @@ -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); diff --git a/wbutton.cc b/wbutton.cc index f66548c..194d49e 100644 --- a/wbutton.cc +++ b/wbutton.cc @@ -22,7 +22,7 @@ WButton::WButton() { - int fontHeight = surface->getFontHeight(); + int fontHeight = Surface::getFontHeight(); setDimensions(70, fontHeight); mytext = NULL; diff --git a/wbutton.h b/wbutton.h index f93d9fe..cbe1cbd 100644 --- a/wbutton.h +++ b/wbutton.h @@ -25,10 +25,10 @@ #include #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 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 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 diff --git a/wjpeg.cc b/wjpeg.cc index b99489c..b803564 100644 --- a/wjpeg.cc +++ b/wjpeg.cc @@ -20,17 +20,12 @@ #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 2b43df7..a647cd1 100644 --- 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; }; diff --git a/woptionbox.h b/woptionbox.h index 25253eb..c9e8def 100644 --- a/woptionbox.h +++ b/woptionbox.h @@ -24,10 +24,10 @@ #include #include "defines.h" -#include "box.h" +#include "widget.h" #include "colour.h" -class WOptionBox : public Box +class WOptionBox : public Widget { public: WOptionBox(); diff --git a/wselectlist.cc b/wselectlist.cc index 2e3fc6c..85c50e7 100644 --- a/wselectlist.cc +++ b/wselectlist.cc @@ -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; diff --git a/wselectlist.h b/wselectlist.h index 473e813..c411cb7 100644 --- a/wselectlist.h +++ b/wselectlist.h @@ -27,12 +27,12 @@ #include #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(); diff --git a/wsymbol.cc b/wsymbol.cc index efc9ea1..15cbae4 100644 --- a/wsymbol.cc +++ b/wsymbol.cc @@ -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++) { diff --git a/wsymbol.h b/wsymbol.h index 6eb672b..1ece792 100644 --- a/wsymbol.h +++ b/wsymbol.h @@ -22,10 +22,10 @@ #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(); -- 2.39.5