ScummVM API documentation
text.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 STARK_VISUAL_TEXT_H
23 #define STARK_VISUAL_TEXT_H
24 
25 #include "engines/stark/visual/visual.h"
26 
27 #include "engines/stark/services/fontprovider.h"
28 #include "engines/stark/gfx/color.h"
29 
30 #include "common/rect.h"
31 #include "graphics/font.h"
32 
33 namespace Stark {
34 
35 namespace Gfx {
36 class Driver;
37 class SurfaceRenderer;
38 class Bitmap;
39 }
40 
44 class VisualText : public Visual {
45 public:
46  static const VisualType TYPE = Visual::kImageText;
47 
48  explicit VisualText(Gfx::Driver *gfx);
49  ~VisualText() override;
50 
51  Common::Rect getRect();
52 
53  void setText(const Common::String &text);
54  void setColor(const Gfx::Color &color);
55  void setBackgroundColor(const Gfx::Color &color);
56  void setAlign(Graphics::TextAlign align);
57  void setTargetWidth(uint32 width);
58  void setTargetHeight(uint32 height);
59  void setFont(FontProvider::FontType type, int32 customFontIndex = -1);
60 
61  uint getTargetWidth() { return _targetWidth; }
62  uint getTargetHeight() { return _targetHeight; }
63 
64  void render(const Common::Point &position);
65  void reset();
66 
67 private:
68  void createBitmap();
69  void freeBitmap();
70 
72  bool isBlank();
73 
74  Gfx::Driver *_gfx;
75  Gfx::SurfaceRenderer *_surfaceRenderer;
76  Gfx::Bitmap *_bitmap;
77 
78  Common::String _text;
79  Gfx::Color _color;
80  Gfx::Color _backgroundColor;
81  Graphics::TextAlign _align;
82  uint32 _targetWidth;
83  uint32 _targetHeight;
84  Common::Rect _originalRect;
85 
86  FontProvider::FontType _fontType;
87  int32 _fontCustomIndex;
88 };
89 
90 } // End of namespace Stark
91 
92 #endif // STARK_VISUAL_TEXT_H
Definition: str.h:59
TextAlign
Definition: font.h:48
Definition: visual.h:29
Definition: rect.h:144
Definition: surfacerenderer.h:36
Definition: driver.h:44
Definition: text.h:44
Definition: console.h:27
Definition: bitmap.h:38
Definition: rect.h:45
Definition: color.h:30
bool isBlank(int c)