2 Copyright 2004-2005 Chris Tallon
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 char Box::numBoxes = 0;
36 Log::getInstance()->log("Box", Log::DEBUG, "Construct, now %u", numBoxes);
44 Log::getInstance()->log("Box", Log::DEBUG, "Destruct, now %u", numBoxes);
51 void Box::setScreenPos(int x, int y)
57 void Box::setSurfaceOffset(UINT x, UINT y)
63 void Box::show(int noBufferToScreen)
65 Log::getInstance()->log("Box", Log::DEBUG, "Show data %p %u %u %u %u %u", surface, screenX, screenY, width, height, noBufferToScreen);
66 surface->updateToBuffer(screenX, screenY, width, height);
67 if (!noBufferToScreen) Surface::bufferToScreen(screenX, screenY, width, height);
90 // Level 1 drawing functions
92 void Box::fillColour(Colour& colour)
94 rectangle(0, 0, width, height, colour);
97 void Box::drawPara(char* text, int x, int y, Colour& colour)
100 int lineHeight = surface->getFontHeight() + 6;
120 if (text[textPos] == '\0') break;
122 if (text[textPos] == '\n')
124 textPos++; // ignore the \n
129 thisCharWidth = surface->getCharWidth(text[textPos]);
130 if ((lineWidth + thisCharWidth) > (int)(width - (2 * paraMargin)))
132 // this character would break the right margin
133 if (text[textPos] == ' ')
135 // this char is a space, ignore and break
141 // Need to go back to the last space in the line
142 while ((text[textPos] != ' ') && (linePos >= 0))
147 // Now take the space we just found
152 line[linePos++] = text[textPos];
153 lineWidth += thisCharWidth;
157 line[linePos++] = '\0';
158 if (printLine || (linePos > 1)) // if some text was put in line
160 drawText(line, x, ypos, colour);
162 if (ypos > (int)(height - lineHeight)) break;
171 // Level 0 drawing functions
173 void Box::rectangle(int x1, int y1, int w, int h, Colour& colour)
175 surface->fillblt(offsetX + x1, offsetY + y1, w, h, surface->rgba(colour.red, colour.green, colour.blue, colour.alpha));
178 void Box::drawText(char* text, int x, int y, Colour& colour)
180 surface->drawText(text, offsetX + x, offsetY + y, colour.red, colour.green, colour.blue);
183 void Box::drawTextRJ(char* text, int x, int y, Colour& colour)
185 surface->drawTextRJ(text, offsetX + x, offsetY + y, colour.red, colour.green, colour.blue);
188 void Box::drawPixel(UINT x, UINT y, Colour& colour)
190 int c = ( (0xFF000000 )
192 | (colour.green << 8)
196 surface->drawPixel(offsetX + x, offsetY + y, c);