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)
68 void Box::show(Region& r)
70 Log::getInstance()->log("Box", Log::DEBUG, "Show region %p %u %u %u %u", surface, r.x, r.y, r.w, r.h);
71 // surface->updateToScreen(area.x, area.y, area.w, area.h);
73 /* surface update to screen needs:
74 source x distance into this surface
75 source y distance into this surface
78 destination x on screen
79 destination y on screen
82 surface->updateToScreen(r.x - area.x, r.y - area.y, r.w, r.h, r.x, r.y);
105 // Level 1 drawing functions
107 void Box::fillColour(Colour& colour)
109 rectangle(0, 0, area.w, area.h, colour);
112 void Box::drawPara(char* text, int x, int y, Colour& colour)
115 int lineHeight = surface->getFontHeight() + 6;
135 if (text[textPos] == '\0') break;
137 if (text[textPos] == '\n')
139 textPos++; // ignore the \n
144 thisCharWidth = surface->getCharWidth(text[textPos]);
145 if ((lineWidth + thisCharWidth) > (int)(area.w - (2 * paraMargin)))
147 // this character would break the right margin
148 if (text[textPos] == ' ')
150 // this char is a space, ignore and break
156 // Need to go back to the last space in the line
157 while ((text[textPos] != ' ') && (linePos >= 0))
162 // Now take the space we just found
167 line[linePos++] = text[textPos];
168 lineWidth += thisCharWidth;
172 line[linePos++] = '\0';
173 if (printLine || (linePos > 1)) // if some text was put in line
175 drawText(line, x, ypos, colour);
177 if (ypos > (int)(area.h - lineHeight)) break;
186 // Level 0 drawing functions
188 void Box::rectangle(int x1, int y1, int w, int h, Colour& colour)
190 surface->fillblt(offsetX + x1, offsetY + y1, w, h, surface->rgba(colour.red, colour.green, colour.blue, colour.alpha));
193 void Box::drawText(char* text, int x, int y, Colour& colour)
195 surface->drawText(text, offsetX + x, offsetY + y, colour.red, colour.green, colour.blue);
198 void Box::drawTextRJ(char* text, int x, int y, Colour& colour)
200 surface->drawTextRJ(text, offsetX + x, offsetY + y, colour.red, colour.green, colour.blue);
203 void Box::drawTextCentre(char* text, int x, int y, Colour& colour)
205 surface->drawTextCentre(text, offsetX + x, offsetY + y, colour.red, colour.green, colour.blue);
208 void Box::drawPixel(UINT x, UINT y, Colour& colour)
210 int c = ( (0xFF000000 )
212 | (colour.green << 8)
216 surface->drawPixel(offsetX + x, offsetY + y, c);