MyGUI: MyGUI_TextIterator.h Source File

MyGUI 3.4.3

MyGUI_TextIterator.h
Go to the documentation of this file.
1/*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7#ifndef MYGUI_TEXT_ITERATOR_H_
8#define MYGUI_TEXT_ITERATOR_H_
9
10#include "MyGUI_Prerequest.h"
11#include "MyGUI_Colour.h"
12#include "MyGUI_TextChangeHistory.h"
13#include "MyGUI_IFont.h"
14
15namespace MyGUI
16{
17
18 class MYGUI_EXPORT TextIterator
19 {
20 private:
21 TextIterator();
22
23 public:
24 TextIterator(const UString& _text, VectorChangeInfo* _history = nullptr);
25
26 bool moveNext();
27
28 // возвращает цвет
29 bool getTagColour(UString& _colour) const;
30
31 // удаляет цвет
32 void clearTagColour();
33
34 bool setTagColour(const Colour& _colour);
35
36 bool setTagColour(const UString& _colour);
37
38 // сохраняет текущий итератор
39 bool saveStartPoint();
40
41 // возвращает строку от сохраненного итератора до текущего
42 UString getFromStart() const;
43
44 // удаляет от запомненной точки до текущей
45 bool eraseFromStart();
46
47 // возвращает текущую псевдо позицию
48 size_t getPosition() const;
49
50 UString getText() const;
51
52 void insertText(const UString& _insert, bool _multiLine);
53
54 void clearNewLine(UString& _text);
55
56 //очищает весь текст
57 void clearText();
58
59 // возвращает размер строки
60 size_t getSize() const;
61
62 void setText(const UString& _text, bool _multiLine);
63
64 void cutMaxLength(size_t _max);
65
66 void cutMaxLengthFromBeginning(size_t _max);
67
68 // возвращает текст без тегов
69 static UString getOnlyText(const UString& _text);
70
71 static UString getTextNewLine();
72
73 static UString getTextCharInfo(Char _char);
74
75 // просто конвертируем цвет в строку
76 static UString convertTagColour(const Colour& _colour);
77
78 static UString toTagsString(const UString& _text);
79
80 private:
81 bool getTagColour(UString& _colour, UString::utf32string::iterator& _iter) const;
82
83 bool setTagColour(const UString::utf32string& _colour);
84
85 void insert(UString::utf32string::iterator& _start, const UString::utf32string& _insert);
86
87 UString::utf32string::iterator erase(
88 UString::utf32string::iterator _start,
89 UString::utf32string::iterator _end);
90
91 void clear();
92
93 void normaliseNewLine(UString& _text);
94
95 private:
96 UString::utf32string mText;
97 UString::utf32string::iterator mCurrent, mEnd, mSave;
98
99 // позиция и размер
100 size_t mPosition;
101 mutable size_t mSize;
102 bool mFirst;
103
104 VectorChangeInfo* mHistory;
105 };
106
107} // namespace MyGUI
108
109#endif // MYGUI_TEXT_ITERATOR_H_
MyGUI_Colour.h
MyGUI_IFont.h
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition MyGUI_Platform.h:77
MyGUI_Prerequest.h
MyGUI_TextChangeHistory.h
MyGUI::TextIterator::eraseFromStart
bool eraseFromStart()
Definition MyGUI_TextIterator.cpp:317
MyGUI::TextIterator::getOnlyText
static UString getOnlyText(const UString &_text)
Definition MyGUI_TextIterator.cpp:219
MyGUI::TextIterator::clearTagColour
void clearTagColour()
Definition MyGUI_TextIterator.cpp:572
MyGUI::TextIterator::clearNewLine
void clearNewLine(UString &_text)
Definition MyGUI_TextIterator.cpp:289
MyGUI::TextIterator::getText
UString getText() const
Definition MyGUI_TextIterator.cpp:593
MyGUI::TextIterator::getTextNewLine
static UString getTextNewLine()
Definition MyGUI_TextIterator.cpp:603
MyGUI::TextIterator::getTextCharInfo
static UString getTextCharInfo(Char _char)
Definition MyGUI_TextIterator.cpp:355
MyGUI::TextIterator::cutMaxLength
void cutMaxLength(size_t _max)
Definition MyGUI_TextIterator.cpp:450
MyGUI::TextIterator::setTagColour
bool setTagColour(const Colour &_colour)
Definition MyGUI_TextIterator.cpp:123
MyGUI::TextIterator::moveNext
bool moveNext()
Definition MyGUI_TextIterator.cpp:33
MyGUI::TextIterator::getFromStart
UString getFromStart() const
Definition MyGUI_TextIterator.cpp:309
MyGUI::TextIterator::convertTagColour
static UString convertTagColour(const Colour &_colour)
Definition MyGUI_TextIterator.cpp:364
MyGUI::TextIterator::clearText
void clearText()
Definition MyGUI_TextIterator.cpp:598
MyGUI::TextIterator::saveStartPoint
bool saveStartPoint()
Definition MyGUI_TextIterator.cpp:301
MyGUI::TextIterator::toTagsString
static UString toTagsString(const UString &_text)
Definition MyGUI_TextIterator.cpp:388
MyGUI::TextIterator::cutMaxLengthFromBeginning
void cutMaxLengthFromBeginning(size_t _max)
Definition MyGUI_TextIterator.cpp:505
MyGUI::TextIterator::setText
void setText(const UString &_text, bool _multiLine)
Definition MyGUI_TextIterator.cpp:338
MyGUI::TextIterator::getPosition
size_t getPosition() const
Definition MyGUI_TextIterator.cpp:588
MyGUI::TextIterator::getSize
size_t getSize() const
Definition MyGUI_TextIterator.cpp:179
MyGUI::TextIterator::insertText
void insertText(const UString &_insert, bool _multiLine)
Definition MyGUI_TextIterator.cpp:326
MyGUI::TextIterator::getTagColour
bool getTagColour(UString &_colour) const
Definition MyGUI_TextIterator.cpp:106
MyGUI::UString
A UTF-16 string with implicit conversion to/from std::string and std::wstring.
Definition MyGUI_UString.h:144
MyGUI::UString::utf32string
std::basic_string< unicode_char > utf32string
string type used for returning UTF-32 formatted data
Definition MyGUI_UString.h:177
MyGUI
Definition MyGUI_ActionController.h:15
MyGUI::VectorChangeInfo
std::vector< TextCommandInfo > VectorChangeInfo
Definition MyGUI_TextChangeHistory.h:58
MyGUI::Char
unsigned int Char
Definition MyGUI_Types.h:50
MyGUI::Colour
Definition MyGUI_Colour.h:17