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;
33 Log::getInstance()->log("Box", Log::DEBUG, "Construct, now %u", numBoxes);
35 surface = Surface::getObject(Surface::BUFFER);
41 Log::getInstance()->log("Box", Log::DEBUG, "Destruct, now %u", numBoxes);
48 void Box::setDimensions(int w, int h)
54 void Box::setScreenPos(int x, int y)
62 Log::getInstance()->log("Box", Log::DEBUG, "Show data %u %u %u %u", screenX, screenY, width, height);
63 surface->updateToScreen(screenX, screenY, width, height);
68 Surface::bufferToScreen();
91 // Level 1 drawing functions
93 void Box::fillColour(Colour& colour)
95 rectangle(0, 0, width, height, colour);
98 void Box::drawPara(char* text, int x, int y, Colour& colour)
101 int lineHeight = surface->getFontHeight() + 6;
121 if (text[textPos] == '\0') break;
123 if (text[textPos] == '\n')
125 textPos++; // ignore the \n
130 thisCharWidth = surface->getCharWidth(text[textPos]);
131 if ((lineWidth + thisCharWidth) > (width - (2 * paraMargin)))
133 // this character would break the right margin
134 if (text[textPos] == ' ')
136 // this char is a space, ignore and break
142 // Need to go back to the last space in the line
143 while ((text[textPos] != ' ') && (linePos >= 0))
148 // Now take the space we just found
153 line[linePos++] = text[textPos];
154 lineWidth += thisCharWidth;
158 line[linePos++] = '\0';
159 if (printLine || (linePos > 1)) // if some text was put in line
161 drawText(line, x, ypos, colour);
163 if (ypos > (height - lineHeight)) break;
172 // Level 0 drawing functions
174 void Box::rectangle(int x1, int y1, int width, int height, Colour& colour)
176 surface->fillblt(screenX + x1, screenY + y1, width, height, surface->rgba(colour.red, colour.green, colour.blue, colour.alpha));
179 void Box::drawText(char* text, int x, int y, Colour& colour)
181 surface->drawText(text, screenX + x, screenY + y, colour.red, colour.green, colour.blue);
184 void Box::drawTextRJ(char* text, int x, int y, Colour& colour)
186 surface->drawTextRJ(text, screenX + x, screenY + y, colour.red, colour.green, colour.blue);
189 void Box::drawPixel(int x, int y, Colour& colour)
194 | (colour.green << 8)
198 surface->drawPixel(screenX + x, screenY + y, c);