]> git.vomp.tv Git - vompclient.git/commitdiff
Boxx: CWFs, some consts and formatting
authorChris Tallon <chris@vomp.tv>
Wed, 13 May 2020 14:18:34 +0000 (15:18 +0100)
committerChris Tallon <chris@vomp.tv>
Wed, 13 May 2020 14:18:34 +0000 (15:18 +0100)
boxstack.cc
boxstack.h
boxx.cc
boxx.h
vepg.cc

index eaa011018819df0475c225bc473546cf8ce51a8e..dcb1258254ebee5ce108455b7723b028bddbf76b 100644 (file)
@@ -221,7 +221,7 @@ void BoxStack::redrawAllBoxes()
   update(NULL,NULL); // should blt all
 }
 
-void BoxStack::update(Boxx* toUpdate, Region* regionToUpdate)
+void BoxStack::update(Boxx* toUpdate, const Region* regionToUpdate)
 {
 //  Log::getInstance()->log("BoxStack", Log::DEBUG, "Update called");
   if (!initted) return; // it is allowed to call this before init
index 188f7de759db6bfc4031476a875c112ef27bb75a..9f96de683fce3c134c24966a0f24344512756a6f 100644 (file)
@@ -51,7 +51,7 @@ class BoxStack
     int remove(Boxx*);
     void removeAllExceptWallpaper();
     void removeAll();
-    void update(Boxx*, Region* regionToUpdate = NULL);
+    void update(Boxx*, const Region* regionToUpdate = NULL);
     void redrawAllBoxes();
     // -- end
 
diff --git a/boxx.cc b/boxx.cc
index e0d092fb2dcbdacaef07bc6f49c719d5c73d9466..84e3860259bc76ec96e1e9efac9894ef696faa03 100644 (file)
--- a/boxx.cc
+++ b/boxx.cc
 #include <stdlib.h>
 
 #include "defines.h"
-#include "bitmap.h"
 #include "log.h"
+#include "message.h"
 #include "osd.h"
+#include "surface.h"
+#include "surfacevector.h"
 
 #include "boxx.h"
-#include "surfacevector.h"
 
 char Boxx::numBoxxes = 0;
 
@@ -132,7 +133,7 @@ void Boxx::setVisible(bool isVisible)
   visible = isVisible;
 }
 
-bool Boxx::getVisible()
+bool Boxx::getVisible() const
 {
   return visible;
 }
@@ -162,73 +163,73 @@ void Boxx::blt(Region& r)
   surface->updateToScreen(r.x, r.y, r.w, r.h, area.x + r.x, area.y + r.y);
 }
 
-int Boxx::getScreenX()
+int Boxx::getScreenX() const
 {
   if (parent) return area.x + parent->getScreenX();
   return area.x;
 }
 
-int Boxx::getScreenY()
+int Boxx::getScreenY() const
 {
   if (parent) return area.y + parent->getScreenY();
   return area.y;
 }
 
-int Boxx::getRootBoxOffsetX() // convert this to be getX and silently do the parent/not thing? same for Y below?
+int Boxx::getRootBoxOffsetX() const // convert this to be getX and silently do the parent/not thing? same for Y below?
 {
   if (parent) return area.x + parent->getRootBoxOffsetX();
   return 0;
 }
 
-int Boxx::getRootBoxOffsetY()
+int Boxx::getRootBoxOffsetY() const
 {
   if (parent) return area.y + parent->getRootBoxOffsetY();
   return 0;
 }
 
-int Boxx::getX()
+int Boxx::getX() const
 {
   return area.x;
 }
 
-int Boxx::getY()
+int Boxx::getY() const
 {
   return area.y;
 }
 
-int Boxx::getX2()
+int Boxx::getX2() const
 {
   return area.x + area.w;
 }
 
-int Boxx::getY2()
+int Boxx::getY2() const
 {
   return area.y + area.h;
 }
 
-UINT Boxx::getWidth()
+UINT Boxx::getWidth() const
 {
   return area.w;
 }
 
-UINT Boxx::getHeight()
+UINT Boxx::getHeight() const
 {
   return area.h;
 }
 
 // FIXME Clean up the code to use just one of the following
 
-Region* Boxx::getRegion()
+const Region* Boxx::getRegion() const
 {
   return &area;
 }
 
-Region Boxx::getRegionR()
+Region Boxx::getRegionR() const
 {
   return area;
 }
 
-void Boxx::getRootBoxRegion(Region* r)
+void Boxx::getRootBoxRegion(Region* r) const
 {
   // Returns a region that describes the position of this box on the box with the surface
   // To be used for boxstack->update calls
@@ -261,35 +262,31 @@ void Boxx::fillColour(const DrawStyle& colour)
 int Boxx::drawPara(const char* text, int x, int y, const DrawStyle& colour, unsigned int skiplines)
 {
   char line[256];
-  int lineHeight = getFontHeight() + paraVSpace;
+  UINT lineHeight = getFontHeight() + paraVSpace;
   float lineWidth;
   float thisCharWidth;
-  int textPos;
-  int textLength;
+  int textPos = 0;
+  int textLength = strlen(text);
   int linePos;
-  int ypos;
+  UINT ypos = y;
   int printLine;
-  int leftlines=0;
+  int leftlines = 0;
+  int drawLinePos = -skiplines;
 
 #if WIN32
   // FIXME win pragma
 #pragma warning(disable : 4146)
 #endif
 
-  int drawLinePos=-skiplines;
-
-  textPos = 0;
-  textLength = strlen(text);
-  ypos = y;
   Region tester;
 
   bool haschildren = true;
   if (children.size() == 0) haschildren = false;
   bool mchar = false;
-  Osd *osd = Osd::getInstance();
+  Osdosd = Osd::getInstance();
   if (osd->charSet() != 1) mchar = true;
   OsdVector *osdv = dynamic_cast<OsdVector*>(osd);
-  float *charwidtharray = NULL;
+  floatcharwidtharray = NULL;
   if (osdv) charwidtharray = osdv->getCharWidthArray();
 
   mbstate_t state;
@@ -301,7 +298,7 @@ int Boxx::drawPara(const char* text, int x, int y, const DrawStyle& colour, unsi
     lineWidth = 0;
     // tester reinit
     tester.h = lineHeight;
-    tester.y=ypos;
+    tester.y = ypos;
     tester.x = x;
     tester.w = area.w - (2 * paraMargin);
 
@@ -347,7 +344,7 @@ int Boxx::drawPara(const char* text, int x, int y, const DrawStyle& colour, unsi
       }
 
 
-      if ((lineWidth + thisCharWidth + x) > tester.w)
+      if ((lineWidth + thisCharWidth + static_cast<float>(x)) > static_cast<float>(tester.w))
       {
         // this character would break the right margin
         if (cur_char == ' ')
@@ -367,8 +364,8 @@ int Boxx::drawPara(const char* text, int x, int y, const DrawStyle& colour, unsi
               cur_length = mbrtowc(&cur_char, text + textPos, textLength-textPos, &state);
               if (cur_length <= 0)
               {
-                cur_char='?';
-                cur_length=1;
+                cur_char = '?';
+                cur_length = 1;
               }
             }
             else
@@ -392,7 +389,7 @@ int Boxx::drawPara(const char* text, int x, int y, const DrawStyle& colour, unsi
 
     if (printLine || (linePos > 1)) // if some text was put in line
     {
-      if (ypos <= (int)(area.h - lineHeight + paraVSpace))
+      if (ypos <= (area.h - lineHeight + paraVSpace))
       {
         if (drawLinePos >= 0)
         {
@@ -481,7 +478,7 @@ void Boxx::drawPixel(UINT x, UINT y, const Colour& colour, bool fastdraw)
 }
 */
 
-void Boxx::drawTTChar(int ox, int oy,int x, int y, cTeletextChar c)
+void Boxx::drawTTChar(int ox, int oy, int x, int y, cTeletextChar c)
 {
   if (parent) parent->drawTTChar(area.x + ox, area.y + oy, x,y,c);
   else  if (surface) surface->drawTTChar(ox, oy,x,y,c);
@@ -493,32 +490,32 @@ void Boxx::drawBitmap(UINT x, UINT y, const Bitmap& bm, const DisplayRegion & re
   else  if (surface) surface->drawBitmap(x, y, bm, region);
 }
 
-void Boxx::drawJpeg(const char *fileName, int x, int y, int *width, int *height)
+void Boxx::drawJpeg(const charfileName, int x, int y, int *width, int *height)
 {
   if (parent) parent->drawJpeg(fileName, area.x + x, area.y + y, width, height);
   else if (surface) surface->drawJpeg(fileName, x, y, width, height);
 }
 
-void Boxx::drawMonoBitmap(UCHAR*base, int dx, int dy, unsigned int height,unsigned int width, DrawStyle& nextColour)
+void Boxx::drawMonoBitmap(UCHAR* base, int dx, int dy, unsigned int height,unsigned int width, DrawStyle& nextColour)
 {
   if (parent) parent->drawMonoBitmap(base, area.x +dx, area.y + dy, height, width, nextColour);
   else if (surface) surface->drawMonoBitmap(base, dx,dy, height, width, nextColour);
 }
 
-void Boxx::drawTVMedia(TVMediaInfo & tvmedia,float x, float y, float  width, float height, Corner corner)
+void Boxx::drawTVMedia(TVMediaInfo& tvmedia, float x, float y, float width, float height, Corner corner)
 {
-  if (parent) parent->drawTVMedia(tvmedia,area.x + x,area.y + y,width, height, corner);
+  if (parent) parent->drawTVMedia(tvmedia, static_cast<float>(area.x) + x, static_cast<float>(area.y) + y, width, height, corner);
   else if (surface)
   {
     SurfaceVector* surfacevector = dynamic_cast<SurfaceVector*>(surface);
     if (surfacevector) surfacevector->drawTVMedia(tvmedia, x, y, width, height, corner);
-    else surface->fillblt((int)x, (int)y, (int)width, (int)height, DrawStyle::RED); // Signal that something went wrong
+    else surface->fillblt(static_cast<int>(x), static_cast<int>(y), static_cast<int>(width), static_cast<int>(height), DrawStyle::RED); // Signal that something went wrong
   }
 }
 
 void Boxx::drawClippingRectangle(float x, float y, float w, float h)
 {
-  if (parent) parent->drawClippingRectangle(area.x + x, area.y + y, w, h);
+  if (parent) parent->drawClippingRectangle(static_cast<float>(area.x) + x, static_cast<float>(area.y) + y, w, h);
   else if (surface)
   {
     SurfaceVector* surfacevector = dynamic_cast<SurfaceVector*>(surface);
@@ -572,8 +569,8 @@ Surface* Boxx::getSurface()
 
 bool Boxx::mouseMove(int x, int y)
 {
-  if ((x >=  (int)area.x) && (x<(int)area.x2())
-      && (y >= (int)area.y) && (y < (int)area.y2()))
+  if (   (x >= static_cast<int>(area.x)) && (x < static_cast<int>(area.x2()))
+      && (y >= static_cast<int>(area.y)) && (y < static_cast<int>(area.y2())) )
   {
     return true;
   }
@@ -585,8 +582,8 @@ bool Boxx::mouseMove(int x, int y)
 
 bool Boxx::mouseLBDOWN(int x, int y)
 {
-  if ((x >= (int)area.x) && (x<(int)area.x2())
-      && (y >= (int)area.y) && (y < (int)area.y2()))
+  if (   (x >= static_cast<int>(area.x)) && (x < static_cast<int>(area.x2()))
+      && (y >= static_cast<int>(area.y)) && (y < static_cast<int>(area.y2())) )
   {
     return true;
   }
diff --git a/boxx.h b/boxx.h
index e027da79887117d32aad5c9a1fe945846438d1f1..c29a9756faa7436d9e19b641ccf69c8bfd2937fe 100644 (file)
--- a/boxx.h
+++ b/boxx.h
 #ifndef BOXX_H
 #define BOXX_H
 
-#include <stdio.h>
 #include <vector>
 
+#include "osdvector.h"
+#include "bitmap.h"
 #include "colour.h"
 #include "region.h"
-#include "message.h"
-
-
-#include "surface.h"
 #include "video.h"
 #include "tvmedia.h"
-#include "osdvector.h"
 
 class Bitmap;
+class Message;
+class Surface;
 
 class Boxx
 {
@@ -46,13 +44,11 @@ class Boxx
     void createBuffer(); // Make this a root view that goes in the BoxStack
     virtual void draw();
     
-    
     void setGap(UINT gap);
     void setBackgroundColour(const DrawStyle& colour);
     void setVisible(bool isVisible);
     void setVideoBackground();
 
-
     // The following are supposed to be abstract functions
     // However, it is useful to be able to make instances of Boxx
     // Therefore the following stubs are provided.
@@ -74,20 +70,20 @@ class Boxx
     */
 
     // Get functions
-    int getScreenX();        // where is it on screen
-    int getScreenY();
-    int getRootBoxOffsetX(); // where is it relative to the top-parent in the boxstack
-    int getRootBoxOffsetY();
-    int getX();              // where is it relative to its parent
-    int getX2();             // .. and the right edge
-    int getY();
-    int getY2();
-    UINT getWidth();
-    UINT getHeight();
-    bool getVisible();
-    Region* getRegion();     // Not to be used for changing the region
-    Region getRegionR();     // Same but as an object
-    void getRootBoxRegion(Region*);
+    int getScreenX() const;        // where is it on screen
+    int getScreenY() const;
+    int getRootBoxOffsetX() const; // where is it relative to the top-parent in the boxstack
+    int getRootBoxOffsetY() const;
+    int getX() const;              // where is it relative to its parent
+    int getX2() const;             // .. and the right edge
+    int getY() const;
+    int getY2() const;
+    UINT getWidth() const;
+    UINT getHeight() const;
+    bool getVisible() const;
+    const Region* getRegion() const;
+    Region getRegionR() const;     // Same but as an object
+    void getRootBoxRegion(Region*) const;
     
     bool getVideoDisplay(VideoDisplay &vd);
 
@@ -107,10 +103,10 @@ class Boxx
     void drawTextCentre(const char* text, int x, int y, const DrawStyle& colour);
     //Now deprecated
     //void drawPixel(UINT x, UINT y, const Colour& colour, bool fastdraw=false);
-    void drawBitmap(UINT x, UINT y, const Bitmap& bm, const DisplayRegion & region);
+    void drawBitmap(UINT x, UINT y, const Bitmap& bm, const DisplayRegion& region);
     //Now deprecated
     // void drawPixelAlpha(UINT x, UINT y, const Colour& colour,bool fastdraw=false);
-    void drawTVMedia(TVMediaInfo & tvmedia,float x, float y, float width, float height, Corner corner=TopLeft);
+    void drawTVMedia(TVMediaInfo& tvmedia, float x, float y, float width, float height, Corner corner=TopLeft);
     void drawClippingRectangle(float x, float y, float w, float h);
     int getFontHeight();
 
@@ -141,7 +137,7 @@ class Boxx
   friend class BoxStack;
   protected:
     //get the surface this box is drawing to
-    Surface *getSurface();
+    SurfacegetSurface();
 
     // I want a parent box or a surface.
     Boxx* parent{};
diff --git a/vepg.cc b/vepg.cc
index 6607ee1f370fe0e99198456c338bc292669d6a7c..091a0b78037da9d95ab3dfab9b8de40b27c334f2 100644 (file)
--- a/vepg.cc
+++ b/vepg.cc
@@ -34,6 +34,7 @@
 #include "vchannellist.h"
 #include "messagequeue.h"
 #include "video.h"
+#include "surface.h"
 #include "vepgsettimer.h"
 #include "wsymbol.h"
 #include "message.h"