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