ScummVM API documentation
text_widget.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 ULTIMA8_GUMPS_WIDGETS_TEXTWIDGET_H
23 #define ULTIMA8_GUMPS_WIDGETS_TEXTWIDGET_H
24 
25 //
26 // TextWidget. Displays text in either a fixed-size or a fit-to-text rectangle.
27 //
28 
29 #include "ultima/ultima8/gumps/gump.h"
30 #include "ultima/ultima8/gfx/fonts/font.h"
31 #include "ultima/ultima8/misc/classtype.h"
32 
33 namespace Ultima {
34 namespace Ultima8 {
35 
36 class RenderedText;
37 
38 class TextWidget : public Gump {
39 protected:
40  Std::string _text;
41  bool _gameFont;
42  int _fontNum;
43  uint32 _blendColour;
44  int32 _tx, _ty;
45  bool _doPaging;
46 
47  unsigned int _currentStart;
48  unsigned int _currentEnd;
49 
50  int32 _targetWidth, _targetHeight;
51 
52  RenderedText *_cachedText;
53  Font::TextAlign _textAlign;
54 public:
55  ENABLE_RUNTIME_CLASSTYPE()
56 
57  TextWidget();
58  TextWidget(int x, int y, const Std::string &txt, bool gamefont, int fontnum,
59  int width = 0, int height = 0,
60  Font::TextAlign align = Font::TEXT_LEFT,
61  bool dopaging = false);
62  ~TextWidget() override;
63 
64  // Init the gump, call after construction
65  void InitGump(Gump *newparent, bool take_focus = true) override;
66 
67  // Overloadable method to Paint just this Gump (RenderSurface is relative to this)
68  void PaintThis(RenderSurface *, int32 lerp_factor, bool scaled) override;
69 
70  void PaintComposited(RenderSurface *surf, int32 lerp_factor, int32 scalex, int32 scaley) override;
71 
72  Gump *onMouseMotion(int32 mx, int32 my) override;
73 
76  bool setupNextText();
77 
79  void rewind();
80 
84  void getCurrentText(unsigned int &start, unsigned int &end) const {
85  start = _currentStart;
86  end = _currentEnd;
87  }
88 
90  void setBlendColour(uint32 col) {
91  _blendColour = col;
92  }
93 
95  int getVlead();
96 
97  const Std::string &getText() const {
98  return _text;
99  }
100 
101 protected:
102  void renderText();
103 
104  Font *getFont() const;
105 
106 public:
107  bool loadData(Common::ReadStream *rs, uint32 version);
108  void saveData(Common::WriteStream *ws) override;
109 };
110 
111 } // End of namespace Ultima8
112 } // End of namespace Ultima
113 
114 #endif
Definition: font.h:41
int getVlead()
get the RenderedText&#39;s vlead
TextAlign
Definition: font.h:48
void PaintThis(RenderSurface *, int32 lerp_factor, bool scaled) override
Overloadable method to Paint just this Gump (RenderSurface is relative to this)
Definition: stream.h:77
void InitGump(Gump *newparent, bool take_focus=true) override
Definition: render_surface.h:40
Definition: gump.h:47
Definition: rendered_text.h:30
Definition: detection.h:27
unsigned int _currentEnd
start of remaining text
Definition: text_widget.h:48
Definition: string.h:30
void getCurrentText(unsigned int &start, unsigned int &end) const
Definition: text_widget.h:84
unsigned int _currentStart
start of currently displaying text
Definition: text_widget.h:47
void PaintComposited(RenderSurface *surf, int32 lerp_factor, int32 scalex, int32 scaley) override
Overloadable method to Paint just this gumps unscaled components that require compositing (RenderSurf...
Definition: stream.h:385
Definition: text_widget.h:38
void setBlendColour(uint32 col)
set the colour to blend the rendered text with. (0 to disable)
Definition: text_widget.h:90
void rewind()
reset the widget to the start of the text
Definition: algorithm.h:37