ScummVM API documentation
textdrawer.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef ILLUSIONS_TEXTDRAWER_H
23 #define ILLUSIONS_TEXTDRAWER_H
24 
25 #include "illusions/graphics.h"
26 #include "illusions/resources/fontresource.h"
27 #include "common/array.h"
28 #include "common/rect.h"
29 #include "graphics/surface.h"
30 
31 namespace Illusions {
32 
33 class IllusionsEngine;
34 
35 struct TextLine {
36  uint16 *_text;
37  int16 _length;
38  int16 _x, _y;
39  TextLine() : _text(0) {}
40  TextLine(uint16 *text, int16 length, int16 x, int16 y)
41  : _text(text), _length(length), _x(x), _y(y) {}
42 };
43 
44 class TextDrawer {
45 public:
46  bool wrapText(FontResource *font, uint16 *text, WidthHeight *dimensions, Common::Point offsPt,
47  uint textFlags, uint16 *&outTextPtr);
48  void drawText(Screen *screen, Graphics::Surface *surface, uint16 backgroundColor, uint16 borderColor);
49 protected:
50  FontResource *_font;
51  uint16 *_text;
52  WidthHeight *_dimensions;
53  Common::Point _offsPt;
54  uint _textFlags;
55  Graphics::Surface *_surface;
56 
57  Common::Array<TextLine> _textLines;
58 
59  bool textHasChar(uint16 c);
60  int16 getSpaceWidth();
61  int16 getCharWidth(uint16 c);
62  bool wrapTextIntern(int16 x, int16 y, int16 maxWidth, int16 maxHeight, uint16 *&outTextPtr);
63 };
64 
65 } // End of namespace Illusions
66 
67 #endif // ILLUSIONS_TALKRESOURCE_H
Definition: fontresource.h:60
Definition: surface.h:67
Definition: textdrawer.h:44
Definition: array.h:52
Definition: actor.h:34
Definition: screen.h:154
Definition: graphics.h:31
Definition: rect.h:45
Definition: textdrawer.h:35