ScummVM API documentation
scroll_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 MM1_VIEWS_ENH_SCROLL_TEXT_H
23 #define MM1_VIEWS_ENH_SCROLL_TEXT_H
24 
25 #include "common/rect.h"
26 #include "common/str.h"
27 #include "graphics/font.h"
28 #include "mm/mm1/views_enh/scroll_view.h"
29 
30 namespace MM {
31 namespace MM1 {
32 namespace ViewsEnh {
33 
37 class ScrollText : public ScrollView {
38  struct Line {
39  Common::String _str;
40  Common::Point _pos;
41  byte _color = 0;
42  TextAlign _align = ALIGN_LEFT;
43 
44  Line(const Common::String &str, const Common::Point &pos,
45  byte color = 0, TextAlign align = ALIGN_LEFT) :
46  _str(str), _pos(pos), _color(color), _align(align) {
47  }
48  };
49 public:
50  typedef Common::Array<Line> Lines;
51 private:
52  size_t _rowCount = 0;
53  Lines _lines;
54 public:
55  ScrollText(const Common::String &name);
56  ScrollText(const Common::String &name, UIElement *owner);
57 
61  void setBounds(const Common::Rect &r) override;
62 
63  Lines::iterator begin() { return _lines.begin(); }
64  Lines::iterator end() { return _lines.end(); }
65  Lines::const_iterator begin() const { return _lines.begin(); }
66  Lines::const_iterator end() const { return _lines.end(); }
67 
71  void clear() {
72  _lines.clear();
73  }
74 
78  void addLine(const Common::String &str,
79  TextAlign align = ALIGN_LEFT, byte color = 0);
80 
84  void addText(const Common::String &str,
85  int lineNum, byte color = 0,
86  TextAlign align = ALIGN_LEFT, int xp = 0);
87  void addText(const Common::String &str,
88  int lineNum, TextAlign align = ALIGN_LEFT,
89  int xp = 0) {
90  addText(str, lineNum, 0, align, xp);
91  }
92 
96  void draw() override;
97 };
98 
99 } // namespace ViewsEnh
100 } // namespace MM1
101 } // namespace MM
102 
103 #endif
Definition: scroll_text.h:37
Definition: str.h:59
void clear()
Definition: array.h:320
iterator end()
Definition: array.h:379
iterator begin()
Definition: array.h:374
Line * iterator
Definition: array.h:54
Definition: rect.h:144
void setBounds(const Common::Rect &r) override
Definition: scroll_view.h:35
const Line * const_iterator
Definition: array.h:55
Definition: detection.h:27
Definition: rect.h:45
void clear()
Definition: scroll_text.h:71
void addText(const Common::String &str, int lineNum, byte color=0, TextAlign align=ALIGN_LEFT, int xp=0)
Definition: events.h:68
void addLine(const Common::String &str, TextAlign align=ALIGN_LEFT, byte color=0)