MyGUI  3.2.0
MyGUI_TextIterator.h
Go to the documentation of this file.
1 
6 /*
7  This file is part of MyGUI.
8 
9  MyGUI is free software: you can redistribute it and/or modify
10  it under the terms of the GNU Lesser General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  MyGUI is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public License
20  along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
21 */
22 #ifndef __MYGUI_TEXT_ITERATOR_H__
23 #define __MYGUI_TEXT_ITERATOR_H__
24 
25 #include "MyGUI_Prerequest.h"
26 #include "MyGUI_Colour.h"
28 #include "MyGUI_IFont.h"
29 
30 namespace MyGUI
31 {
32 
34  {
35  private:
36  TextIterator();
37 
38  public:
39  TextIterator(const UString& _text, VectorChangeInfo* _history = nullptr);
40 
41  bool moveNext();
42 
43  // возвращает цвет
44  bool getTagColour(UString& _colour) const;
45 
46  // удаляет цвет
47  void clearTagColour();
48 
49  bool setTagColour(const Colour& _colour);
50 
51  bool setTagColour(UString _colour);
52 
53  // сохраняет текущий итератор
54  bool saveStartPoint();
55 
56  // возвращает строку от сохраненного итератора до текущего
57  UString getFromStart();
58 
59  // удаляет от запомненной точки до текущей
60  bool eraseFromStart();
61 
62  // возвращает текущую псевдо позицию
63  size_t getPosition() const;
64 
65  const UString& getText() const;
66 
67  void insertText(const UString& _insert, bool _multiLine);
68 
69  void clearNewLine(UString& _text);
70 
71  //очищает весь текст
72  void clearText();
73 
74  // возвращает размер строки
75  size_t getSize() const;
76 
77  void setText(const UString& _text, bool _multiLine);
78 
79  void cutMaxLength(size_t _max);
80 
81  void cutMaxLengthFromBeginning(size_t _max);
82 
83  // возвращает текст без тегов
84  static UString getOnlyText(const UString& _text);
85 
86  static UString getTextNewLine();
87 
88  static UString getTextCharInfo(Char _char);
89 
90  // просто конвертируем цвет в строку
91  static UString convertTagColour(const Colour& _colour);
92 
93  static UString toTagsString(const UString& _text);
94 
95  private:
96  // возвращает цвет
97  bool getTagColour(UString& _colour, UString::iterator& _iter) const;
98 
99  void insert(UString::iterator& _start, UString& _insert);
100 
102 
103  void clear();
104 
105  private:
106  UString mText;
107  UString::iterator mCurrent, mEnd, mSave;
108 
109  // позиция и размер
110  size_t mPosition;
111  mutable size_t mSize;
112  bool mFirst;
113 
114  VectorChangeInfo* mHistory;
115  };
116 
117 } // namespace MyGUI
118 
119 #endif // __MYGUI_TEXT_ITERATOR_H__
std::vector< TextCommandInfo > VectorChangeInfo
#define MYGUI_EXPORT
unsigned int Char
Definition: MyGUI_Types.h:66
forward iterator for UString
A UTF-16 string with implicit conversion to/from std::string and std::wstring.