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