ScummVM API documentation
te_text_base2.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 TETRAEDGE_TE_TE_TEXT_BASE2_H
23 #define TETRAEDGE_TE_TE_TEXT_BASE2_H
24 
25 #include "common/str.h"
26 #include "common/hashmap.h"
27 
28 #include "tetraedge/te/te_color.h"
29 #include "tetraedge/te/te_intrusive_ptr.h"
30 #include "tetraedge/te/te_i_font.h"
31 #include "tetraedge/te/te_mesh.h"
32 #include "tetraedge/te/te_vector2s32.h"
33 
34 namespace Tetraedge {
35 
36 class TeTextBase2 {
37 public:
38  TeTextBase2();
39  virtual ~TeTextBase2();
40 
41  struct Line {
42  uint _startOffset;
43  uint _endOffset;
44  float _height;
45  float _width;
46  };
47 
48  enum WrapMode {
49  WrapModeFixed,
50  WrapModeProportional
51  };
52 
53  void build();
54  void clear();
55  void clearStyles();
56  void clearText();
57 
58  TeColor currentColor(uint offset) const;
59  TeIntrusivePtr<TeIFont> currentFont(uint offset);
60  void draw();
61  uint endOfWord(uint i) const;
62  void insertNewLine(uint offset);
63  bool isASpace(uint offset) const;
64  int newLines(uint offset) const;
65  int nextNonSpaceChar(uint start);
66  void setAlignStyle(TeIFont::AlignStyle style);
67  void setColor(uint offset, const TeColor &color);
68  void setFont(uint offset, const TeIntrusivePtr<TeIFont> &newfont);
69  void setFontSize(int fontSz);
70  void setGlobalColor(const TeColor &color);
71  void setInterLine(float val);
72  void setRect(const TeVector2s32 &rect);
73  void setText(const Common::String &newText);
74  void setWrapMode(WrapMode &mode);
75  TeVector2s32 size();
76  void strikethrough(bool val);
77  bool strikethrough() const { return _strikethrough; }
78  const Common::String &text() const { return _text; }
79  WrapMode wrapMode() const { return _wrapMode; }
80  const TeVector2s32 &size() const { return _size; }
81 
82 private:
83  void computeNbSpaces(Line &line, uint startOffset, uint endOffset);
84  void drawEmptyChar(uint offset);
85  void drawLine(TeImage &img, const Common::String &str, int yoffset);
86 
87  TeIFont::AlignStyle _alignStyle;
88  WrapMode _wrapMode;
89  int _fontSize;
90  bool _valueWasSet;
91  TeColor _globalColor;
92  float _interLine;
93  TeVector2s32 _drawRect;
94  TeVector2s32 _size;
95  Common::String _text;
96  bool _strikethrough;
97 
98  TeMesh *_mesh;
99 
100  Common::Array<Common::String> _wrappedLines;
101 
102  Common::Array<uint32> _lineBreaks;
105 };
106 
107 } // end namespace Tetraedge
108 
109 #endif // TETRAEDGE_TE_TE_TEXT_BASE2_H
Definition: te_image.h:40
Definition: str.h:59
Definition: detection.h:27
Definition: te_mesh.h:43
Definition: te_text_base2.h:41
Definition: te_color.h:30
Definition: te_text_base2.h:36
Definition: hashmap.h:85
Definition: te_intrusive_ptr.h:31
Definition: te_vector2s32.h:31