MyGUI
3.2.0
|
00001 00006 /* 00007 This file is part of MyGUI. 00008 00009 MyGUI is free software: you can redistribute it and/or modify 00010 it under the terms of the GNU Lesser General Public License as published by 00011 the Free Software Foundation, either version 3 of the License, or 00012 (at your option) any later version. 00013 00014 MyGUI is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License 00020 along with MyGUI. If not, see <http://www.gnu.org/licenses/>. 00021 */ 00022 #ifndef __MYGUI_TEXT_ITERATOR_H__ 00023 #define __MYGUI_TEXT_ITERATOR_H__ 00024 00025 #include "MyGUI_Prerequest.h" 00026 #include "MyGUI_Colour.h" 00027 #include "MyGUI_TextChangeHistory.h" 00028 #include "MyGUI_IFont.h" 00029 00030 namespace MyGUI 00031 { 00032 00033 class MYGUI_EXPORT TextIterator 00034 { 00035 private: 00036 TextIterator(); 00037 00038 public: 00039 TextIterator(const UString& _text, VectorChangeInfo* _history = nullptr); 00040 00041 bool moveNext(); 00042 00043 // возвращает цвет 00044 bool getTagColour(UString& _colour) const; 00045 00046 // удаляет цвет 00047 void clearTagColour(); 00048 00049 bool setTagColour(const Colour& _colour); 00050 00051 bool setTagColour(UString _colour); 00052 00053 // сохраняет текущий итератор 00054 bool saveStartPoint(); 00055 00056 // возвращает строку от сохраненного итератора до текущего 00057 UString getFromStart(); 00058 00059 // удаляет от запомненной точки до текущей 00060 bool eraseFromStart(); 00061 00062 // возвращает текущую псевдо позицию 00063 size_t getPosition() const; 00064 00065 const UString& getText() const; 00066 00067 void insertText(const UString& _insert, bool _multiLine); 00068 00069 void clearNewLine(UString& _text); 00070 00071 //очищает весь текст 00072 void clearText(); 00073 00074 // возвращает размер строки 00075 size_t getSize() const; 00076 00077 void setText(const UString& _text, bool _multiLine); 00078 00079 void cutMaxLength(size_t _max); 00080 00081 void cutMaxLengthFromBeginning(size_t _max); 00082 00083 // возвращает текст без тегов 00084 static UString getOnlyText(const UString& _text); 00085 00086 static UString getTextNewLine(); 00087 00088 static UString getTextCharInfo(Char _char); 00089 00090 // просто конвертируем цвет в строку 00091 static UString convertTagColour(const Colour& _colour); 00092 00093 static UString toTagsString(const UString& _text); 00094 00095 private: 00096 // возвращает цвет 00097 bool getTagColour(UString& _colour, UString::iterator& _iter) const; 00098 00099 void insert(UString::iterator& _start, UString& _insert); 00100 00101 UString::iterator erase(UString::iterator _start, UString::iterator _end); 00102 00103 void clear(); 00104 00105 private: 00106 UString mText; 00107 UString::iterator mCurrent, mEnd, mSave; 00108 00109 // позиция и размер 00110 size_t mPosition; 00111 mutable size_t mSize; 00112 bool mFirst; 00113 00114 VectorChangeInfo* mHistory; 00115 }; 00116 00117 } // namespace MyGUI 00118 00119 #endif // __MYGUI_TEXT_ITERATOR_H__