From e2b561db38f57cd2b20b91797252fadf65dd8161 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sat, 12 Jan 2008 16:58:31 +0000 Subject: [PATCH] Patch from Philipp Mueller for long drawText lines --- boxx.cc | 6 ++++++ boxx.h | 1 + surface.cc | 7 ++++++- surface.h | 1 + vvideorec.cc | 3 ++- wselectlist.cc | 10 +++++----- wselectlist.h | 2 +- 7 files changed, 22 insertions(+), 8 deletions(-) diff --git a/boxx.cc b/boxx.cc index 17e6dd1..7c88047 100644 --- a/boxx.cc +++ b/boxx.cc @@ -321,6 +321,12 @@ void Boxx::drawText(const char* text, int x, int y, Colour& colour) else surface->drawText(text, x, y, colour.rgba()); } +void Boxx::drawText(const char* text, int x, int y, int width, 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) { if (parent) parent->drawTextRJ(text, area.x + x, area.y + y, colour); diff --git a/boxx.h b/boxx.h index 929e654..d8fc18e 100644 --- a/boxx.h +++ b/boxx.h @@ -87,6 +87,7 @@ class Boxx 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); diff --git a/surface.cc b/surface.cc index fc69577..eabbae1 100644 --- a/surface.cc +++ b/surface.cc @@ -41,6 +41,11 @@ Surface* Surface::getScreen() } int Surface::drawText(const char* text, int x, int y, ULONG rgba) +{ + return drawText(text, x, y, 2000, rgba); +} + +int Surface::drawText(const char* text, int x, int y, int width, ULONG rgba) { int h, n, i; int Y, X, cx; @@ -57,7 +62,7 @@ int Surface::drawText(const char* text, int x, int y, ULONG rgba) int w = font->width[c]; int pixels = 0; - for (X=0; XgetFontHeight(); - barBlue.set(0, 0, 150, 150); +// barBlue.set(0, 0, 150, 150); + barBlue.set(0, 0, 0, 128); barShowing = false; barGenHold = false; diff --git a/wselectlist.cc b/wselectlist.cc index 9295324..b961523 100644 --- a/wselectlist.cc +++ b/wselectlist.cc @@ -117,11 +117,11 @@ void WSelectList::draw() if (i == selectedOption && showseloption) { rectangle(0, ypos, area.w, fontHeight, Colour::SELECTHIGHLIGHT); - drawOptionLine(options[i].text, 5, ypos, Colour::DARKTEXT); + drawOptionLine(options[i].text, 5, ypos, area.w - 5, Colour::DARKTEXT); } else { - drawOptionLine(options[i].text, 5, ypos, Colour::LIGHTTEXT); + drawOptionLine(options[i].text, 5, ypos, area.w - 5, Colour::LIGHTTEXT); } ypos += ySeperation; } @@ -133,11 +133,11 @@ void WSelectList::addColumn(int x) columns[numColumns++] = x; } -void WSelectList::drawOptionLine(char* text, int xpos, int ypos, Colour& colour) +void WSelectList::drawOptionLine(char* text, int xpos, int ypos, int width, Colour& colour) { if (!numColumns) { - drawText(text, xpos, ypos, colour); + drawText(text, xpos, ypos, width, colour); } else { @@ -149,7 +149,7 @@ void WSelectList::drawOptionLine(char* text, int xpos, int ypos, Colour& colour) pointer = strtok(buffer, "\t"); while(pointer) { - drawText(pointer, xpos + columns[currentColumn], ypos, colour); + drawText(pointer, xpos + columns[currentColumn], ypos, width - columns[currentColumn], colour); currentColumn++; if (currentColumn == 10) return; pointer = strtok(NULL, "\t"); diff --git a/wselectlist.h b/wselectlist.h index dbd1b9e..008d894 100644 --- a/wselectlist.h +++ b/wselectlist.h @@ -69,7 +69,7 @@ class WSelectList : public Boxx virtual bool mouseLBDOWN(int x, int y); private: - void drawOptionLine(char* text, int xpos, int ypos, Colour& colour); + void drawOptionLine(char* text, int xpos, int ypos, int width, Colour& colour); int getMouseLine(int x, int y); vector options; -- 2.39.5