From 8b8e0ad08b57f2f0dbcac184bfb2989221e81fea Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Wed, 26 Mar 2008 15:04:27 +0000 Subject: [PATCH] Code cleaning: const fix --- CREDITS | 9 ++++++--- boxx.cc | 21 ++++++++++----------- boxx.h | 22 +++++++++++----------- colour.h | 2 +- tbboxx.cc | 2 +- tbboxx.h | 2 +- vepg.cc | 2 +- vepg.h | 2 +- wjpeg.cc | 2 +- wjpeg.h | 2 +- wselectlist.cc | 4 ++-- wselectlist.h | 4 ++-- wtextbox.cc | 2 +- wtextbox.h | 2 +- 14 files changed, 40 insertions(+), 38 deletions(-) diff --git a/CREDITS b/CREDITS index 285ccd3..8585f16 100644 --- a/CREDITS +++ b/CREDITS @@ -44,13 +44,16 @@ Marten Richter Andreas Vogel Media player +Alexander Pipelka + Code cleaning patches + Various bug fixes + Thanks to the following people for their work with the MVP: Jon Gettler, BtB and the other MVPMC developers Dominic Morris for the vdr-mediamvp VDR plugin -Apologies to anyone I have forgotten, I only just started -trying to keep track of all this... (And now I don't remember -to keep it up to date!) +This list is most likely incomplete. Apologies to anyone +I have forgotten, and for forgetting to update this list. diff --git a/boxx.cc b/boxx.cc index 7c88047..f1ba98a 100644 --- a/boxx.cc +++ b/boxx.cc @@ -107,7 +107,7 @@ void Boxx::setParent(Boxx* newParent) parent = newParent; } -void Boxx::setBackgroundColour(Colour& Tcolour) +void Boxx::setBackgroundColour(const Colour& Tcolour) { backgroundColour = Tcolour; backgroundColourSet = true; @@ -221,12 +221,12 @@ void Boxx::getRootBoxRegion(Region* r) // Level 1 drawing functions -void Boxx::fillColour(Colour& colour) +void Boxx::fillColour(const Colour& colour) { rectangle(0, 0, area.w, area.h, colour); } -void Boxx::drawPara(char* text, int x, int y, Colour& colour) +void Boxx::drawPara(char* text, int x, int y, const Colour& colour) { char line[256]; int lineHeight = surface->getFontHeight() + paraVSpace; @@ -302,44 +302,44 @@ void Boxx::drawPara(char* text, int x, int y, Colour& colour) } } -void Boxx::rectangle(Region& region, Colour& colour) +void Boxx::rectangle(Region& region, const Colour& colour) { rectangle(region.x, region.y, region.w, region.h, colour); } // Level 0 drawing functions -void Boxx::rectangle(UINT x, UINT y, UINT w, UINT h, Colour& colour) +void Boxx::rectangle(UINT x, UINT y, UINT w, UINT h, const Colour& colour) { if (parent) parent->rectangle(area.x + x, area.y + y, w, h, colour); else surface->fillblt(x, y, w, h, colour.rgba()); } -void Boxx::drawText(const char* text, int x, int y, Colour& colour) +void Boxx::drawText(const char* text, int x, int y, const Colour& colour) { if (parent) parent->drawText(text, area.x + x, area.y + y, colour); else surface->drawText(text, x, y, colour.rgba()); } -void Boxx::drawText(const char* text, int x, int y, int width, Colour& colour) +void Boxx::drawText(const char* text, int x, int y, int width, const Colour& colour) { if (parent) parent->drawText(text, area.x + x, area.y + y, width, colour); else surface->drawText(text, x, y, width, colour.rgba()); } -void Boxx::drawTextRJ(const char* text, int x, int y, Colour& colour) +void Boxx::drawTextRJ(const char* text, int x, int y, const Colour& colour) { if (parent) parent->drawTextRJ(text, area.x + x, area.y + y, colour); else surface->drawTextRJ(text, x, y, colour.rgba()); } -void Boxx::drawTextCentre(const char* text, int x, int y, Colour& colour) +void Boxx::drawTextCentre(const char* text, int x, int y, const Colour& colour) { if (parent) parent->drawTextCentre(text, area.x + x, area.y + y, colour); else surface->drawTextCentre(text, x, y, colour.rgba()); } -void Boxx::drawPixel(UINT x, UINT y, Colour& colour) +void Boxx::drawPixel(UINT x, UINT y, const Colour& colour) { if (parent) parent->drawPixel(area.x + x, area.y + y, colour); else @@ -377,4 +377,3 @@ int Boxx::charWidth(char c) if (parent) return parent->charWidth(c); else return surface->getCharWidth(c); } - diff --git a/boxx.h b/boxx.h index d8fc18e..46c6924 100644 --- a/boxx.h +++ b/boxx.h @@ -49,7 +49,7 @@ class Boxx void setGap(UINT gap); - void setBackgroundColour(Colour& colour); + void setBackgroundColour(const Colour& colour); void setVisible(bool isVisible); @@ -79,18 +79,18 @@ class Boxx void getRootBoxRegion(Region*); // Drawing functions level 1 - void fillColour(Colour& colour); - void drawPara(char* text, int x, int y, Colour& colour); + void fillColour(const Colour& colour); + void drawPara(char* text, int x, int y, const Colour& colour); // Drawing functions level 0 - void rectangle(UINT x, UINT y, UINT w, UINT h, Colour& colour); - void rectangle(Region& region, Colour& colour); - - void drawText(const char* text, int x, int y, Colour& colour); - void drawText(const char* text, int x, int y, int width, Colour& colour); - void drawTextRJ(const char* text, int x, int y, Colour& colour); - void drawTextCentre(const char* text, int x, int y, Colour& colour); - void drawPixel(UINT x, UINT y, Colour& colour); + void rectangle(UINT x, UINT y, UINT w, UINT h, const Colour& colour); + void rectangle(Region& region, const Colour& colour); + + void drawText(const char* text, int x, int y, const Colour& colour); + void drawText(const char* text, int x, int y, int width, const Colour& colour); + void drawTextRJ(const char* text, int x, int y, const Colour& colour); + void drawTextCentre(const char* text, int x, int y, const Colour& colour); + void drawPixel(UINT x, UINT y, const Colour& colour); /* This is for system which need a locking of the drawing surface to speed up drawing */ void startFastDraw(); diff --git a/colour.h b/colour.h index 757ad9e..3b0eecd 100644 --- a/colour.h +++ b/colour.h @@ -39,7 +39,7 @@ class Colour void set(int Tred, int Tgreen, int Tblue, int Talpha) { red = Tred; green = Tgreen; blue = Tblue; alpha = Talpha; } - unsigned long rgba() + unsigned long rgba() const { return (alpha << 24) | (red << 16) | (green << 8) | blue; } diff --git a/tbboxx.cc b/tbboxx.cc index 84f6af0..76ac705 100644 --- a/tbboxx.cc +++ b/tbboxx.cc @@ -68,7 +68,7 @@ void TBBoxx::draw() Boxx::draw(); } -void TBBoxx::setTitleBarColour(Colour& Tcolour) +void TBBoxx::setTitleBarColour(const Colour& Tcolour) { titleBarColour = Tcolour; } diff --git a/tbboxx.h b/tbboxx.h index 39565ae..63e8b8c 100644 --- a/tbboxx.h +++ b/tbboxx.h @@ -41,7 +41,7 @@ class TBBoxx : public Boxx void setTitleBarOn(UCHAR on); void setTitleText(const char* title, int width=0); - void setTitleBarColour(Colour& colour); + void setTitleBarColour(const Colour& colour); char* getTitleText() { return titleText; }; private: diff --git a/vepg.cc b/vepg.cc index b1aaa50..fde0b52 100644 --- a/vepg.cc +++ b/vepg.cc @@ -682,7 +682,7 @@ void VEpg::setCurrentChannel() boxstack->update(this, &r); } -void VEpg::paintCell(Event* event, int yOffset, Colour bg, Colour fg) +void VEpg::paintCell(Event* event, int yOffset, const Colour& bg, const Colour& fg) { int w, x, y, h; w = x = 0; // keep compiler happy diff --git a/vepg.h b/vepg.h index a03eed1..e9de9c8 100644 --- a/vepg.h +++ b/vepg.h @@ -79,7 +79,7 @@ class VEpg : public Boxx, public TimerReceiver int listWindowSize; void updateChanList(); void updateEventList(); - void paintCell(Event* event, int yOffset, Colour bg, Colour fg); + void paintCell(Event* event, int yOffset, const Colour& bg, const Colour& fg); time_t prevHour(time_t* t); void* parent; BoxStack* boxstack; diff --git a/wjpeg.cc b/wjpeg.cc index 2b0bda9..33e422c 100644 --- a/wjpeg.cc +++ b/wjpeg.cc @@ -194,7 +194,7 @@ void WJpeg::draw() 270:xr=y yr=w-x */ -void WJpeg::drawPixel(int x, int y,int w,int h,int xpos, int ypos,Colour c){ +void WJpeg::drawPixel(int x, int y,int w,int h,int xpos, int ypos, const Colour& c){ int xb=0; int yb=0; switch(rotate) { diff --git a/wjpeg.h b/wjpeg.h index 0f2b079..f8c626f 100644 --- a/wjpeg.h +++ b/wjpeg.h @@ -115,7 +115,7 @@ class WJpeg : public Boxx private: int drawJpeg(); //our drawPixel with considers rotation - void drawPixel(int x, int y,int w,int h,int xpos, int ypos,Colour c); + void drawPixel(int x, int y,int w,int h,int xpos, int ypos, const Colour& c); char* fileName; JpegReader *reader; #ifdef WIN32 diff --git a/wselectlist.cc b/wselectlist.cc index b961523..b309e85 100644 --- a/wselectlist.cc +++ b/wselectlist.cc @@ -59,7 +59,7 @@ void WSelectList::setNoLoop() noLoop = 1; } -void WSelectList::setBackgroundColour(Colour& colour) +void WSelectList::setBackgroundColour(const Colour& colour) { backgroundColour = colour; } @@ -133,7 +133,7 @@ void WSelectList::addColumn(int x) columns[numColumns++] = x; } -void WSelectList::drawOptionLine(char* text, int xpos, int ypos, int width, Colour& colour) +void WSelectList::drawOptionLine(char* text, int xpos, int ypos, int width, const Colour& colour) { if (!numColumns) { diff --git a/wselectlist.h b/wselectlist.h index 008d894..ce2e853 100644 --- a/wselectlist.h +++ b/wselectlist.h @@ -49,7 +49,7 @@ class WSelectList : public Boxx void setShowSelOption(bool set) { showseloption = set; }; int addOption(const char* text, ULONG data, int selected); void draw(); - void setBackgroundColour(Colour& colour); + void setBackgroundColour(const Colour& colour); void down(); void up(); @@ -69,7 +69,7 @@ class WSelectList : public Boxx virtual bool mouseLBDOWN(int x, int y); private: - void drawOptionLine(char* text, int xpos, int ypos, int width, Colour& colour); + void drawOptionLine(char* text, int xpos, int ypos, int width, const Colour& colour); int getMouseLine(int x, int y); vector options; diff --git a/wtextbox.cc b/wtextbox.cc index 42c574b..f6ec878 100644 --- a/wtextbox.cc +++ b/wtextbox.cc @@ -56,7 +56,7 @@ void WTextbox::setText(const char* takeText) strcpy(text, takeText); } -void WTextbox::setForegroundColour(Colour fcolour) +void WTextbox::setForegroundColour(const Colour& fcolour) { foreColour = fcolour; } diff --git a/wtextbox.h b/wtextbox.h index 9ac7072..d8b257b 100644 --- a/wtextbox.h +++ b/wtextbox.h @@ -36,7 +36,7 @@ class WTextbox : public Boxx ~WTextbox(); void setText(const char* text); void draw(); - void setForegroundColour(Colour fcolour); + void setForegroundColour(const Colour& fcolour); void setTextPos(int x, int y); // optional void setParaMode(bool mode); -- 2.39.2