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 /*
23  * This code is based on Broken Sword 2.5 engine
24  *
25  * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
26  *
27  * Licensed under GNU GPL v2
28  *
29  */
30 
31 #ifndef SWORD25_TEXT_H
32 #define SWORD25_TEXT_H
33 
34 #include "sword25/kernel/common.h"
35 #include "common/rect.h"
36 #include "sword25/gfx/renderobject.h"
37 
38 namespace Sword25 {
39 
40 class Kernel;
41 class FontResource;
42 class ResourceManager;
43 
44 class Text : public RenderObject {
45  friend class RenderObject;
46 
47 public:
53  bool setFont(const Common::String &font);
54 
59  void setText(const Common::String &text);
60 
65  void setAlpha(int alpha);
66 
75  void setAutoWrap(bool autoWrap);
76 
82  void setAutoWrapThreshold(uint32 autoWrapThreshold);
83 
88  return _text;
89  }
90 
95  return _font;
96  }
97 
102  void setColor(uint32 modulationColor);
103 
108  int getAlpha() const {
109  return _modulationColor >> BS_ASHIFT;
110  }
111 
116  int getColor() const {
117  return _modulationColor & BS_RGBMASK;
118  }
119 
123  bool isAutoWrapActive() const {
124  return _autoWrap;
125  }
126 
130  uint32 getAutoWrapThreshold() const {
131  return _autoWrapThreshold;
132  }
133 
134  bool persist(OutputPersistenceBlock &writer) override;
135  bool unpersist(InputPersistenceBlock &reader) override;
136 
137 protected:
138  bool doRender(RectangleList *updateRects) override;
139 
140 private:
142  Text(InputPersistenceBlock &reader, RenderObjectPtr<RenderObject> parentPtr, uint handle);
143 
144  uint32 _modulationColor;
145  Common::String _font;
146  Common::String _text;
147  bool _autoWrap;
148  uint32 _autoWrapThreshold;
149 
150  struct Line {
151  Common::Rect bbox;
152  Common::String text;
153  };
154 
155  Common::Array<Line> _lines;
156 
157  void updateFormat();
158  void updateMetrics(FontResource &fontResource);
159  ResourceManager *getResourceManager();
160  FontResource *lockFontResource();
161 };
162 
163 } // End of namespace Sword25
164 
165 #endif
Definition: fontresource.h:44
Definition: str.h:59
bool isAutoWrapActive() const
Gibt zurück, ob die automatische Formatierung aktiviert ist.
Definition: text.h:123
const Common::String & getText()
Gibt den dargestellten Text zurück.
Definition: text.h:87
int getColor() const
Gibt die Farbe des Textes zurück.
Definition: text.h:116
Definition: renderobjectptr.h:46
void setText(const Common::String &text)
Setzt den darzustellenden Text.
const Common::String & getFont()
Gibt den Namen das momentan benutzten Fonts zurück.
Definition: text.h:94
Definition: rect.h:144
uint32 getAutoWrapThreshold() const
Gibt die Längengrenze des Textes in Pixeln zurück, ab der eine automatische Formatierung vorgenommen ...
Definition: text.h:130
Definition: microtiles.h:38
bool doRender(RectangleList *updateRects) override
Einschubmethode, die den tatsächlichen Redervorgang durchführt.
Definition: console.h:27
int getAlpha() const
Gibt den Alphawert des Textes zurück.
Definition: text.h:108
void setAutoWrap(bool autoWrap)
Legt fest, ob der Text automatisch umgebrochen werden soll.
void setAlpha(int alpha)
Setzt den Alphawert des Textes.
bool setFont(const Common::String &font)
Setzt den Font mit dem der Text dargestellt werden soll.
Definition: resmanager.h:48
void setAutoWrapThreshold(uint32 autoWrapThreshold)
Legt die Längengrenze des Textes in Pixeln fest, ab der ein automatischer Zeilenumbruch vorgenommen w...
void setColor(uint32 modulationColor)
Setzt die Farbe des Textes.
Definition: inputpersistenceblock.h:40
Dieses ist die Klasse die sämtliche sichtbaren Objekte beschreibt.
Definition: renderobject.h:72
Definition: outputpersistenceblock.h:39
Definition: text.h:44