#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;
visible = isVisible;
}
-bool Boxx::getVisible()
+bool Boxx::getVisible() const
{
return visible;
}
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
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();
+ Osd* osd = Osd::getInstance();
if (osd->charSet() != 1) mchar = true;
OsdVector *osdv = dynamic_cast<OsdVector*>(osd);
- float *charwidtharray = NULL;
+ float* charwidtharray = NULL;
if (osdv) charwidtharray = osdv->getCharWidthArray();
mbstate_t state;
lineWidth = 0;
// tester reinit
tester.h = lineHeight;
- tester.y=ypos;
+ tester.y = ypos;
tester.x = x;
tester.w = area.w - (2 * paraMargin);
}
- 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 == ' ')
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
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)
{
}
*/
-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);
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 char* fileName, 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);
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;
}
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;
}
#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
{
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.
*/
// 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);
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();
friend class BoxStack;
protected:
//get the surface this box is drawing to
- Surface *getSurface();
+ Surface* getSurface();
// I want a parent box or a surface.
Boxx* parent{};