MyGUI 3.4.3
MyGUI_EditBox.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_EDIT_BOX_H_
8#define MYGUI_EDIT_BOX_H_
9
10#include "MyGUI_Prerequest.h"
11#include "MyGUI_TextBox.h"
13#include "MyGUI_TextIterator.h"
14#include "MyGUI_EventPair.h"
16
17namespace MyGUI
18{
19
21
25 class MYGUI_EXPORT EditBox : public TextBox, public ScrollViewBase, public MemberObsolete<EditBox>
26 {
28
29 public:
30 EditBox();
31
33 void setTextIntervalColour(size_t _start, size_t _count, const Colour& _colour);
34
36 size_t getTextSelectionStart() const;
37
39 size_t getTextSelectionEnd() const;
40
42 size_t getTextSelectionLength() const;
43
44 // возвращает текст с тегами
46 UString getTextInterval(size_t _start, size_t _count) const;
47
52 void setTextSelection(size_t _start, size_t _end);
53
55 void deleteTextSelection();
56
58 UString getTextSelection() const;
59
61 bool isTextSelection() const;
62
64 void setTextSelectionColour(const Colour& _colour);
65
67 void setTextCursor(size_t _index);
69 size_t getTextCursor() const;
70
71
73 void setCaption(const UString& _value) override;
75 const UString& getCaption() const override;
76
78 void setOnlyText(const UString& _text);
80 UString getOnlyText() const;
81
86 size_t getTextLength() const;
87
89 void setOverflowToTheLeft(bool _value);
91 bool getOverflowToTheLeft() const;
92
94 void setMaxTextLength(size_t _value);
96 size_t getMaxTextLength() const;
97
99 void insertText(const UString& _text, size_t _index = ITEM_NONE);
101 void addText(const UString& _text);
103 void eraseText(size_t _start, size_t _count = 1);
104
109 void setEditReadOnly(bool _value);
111 bool getEditReadOnly() const;
112
117 void setEditPassword(bool _password);
119 bool getEditPassword() const;
120
126 void setEditMultiLine(bool _value);
128 bool getEditMultiLine() const;
129
134 void setEditStatic(bool _value);
136 bool getEditStatic() const;
137
139 void setPasswordChar(Char _char);
141 void setPasswordChar(const UString& _value);
143 Char getPasswordChar() const;
144
150 void setEditWordWrap(bool _value);
152 bool getEditWordWrap() const;
153
159 void setTabPrinting(bool _value);
161 bool getTabPrinting() const;
162
164 bool getInvertSelected() const;
168 void setInvertSelected(bool _value);
169
171 void setPosition(const IntPoint& _point) override;
173 void setSize(const IntSize& _size) override;
175 void setCoord(const IntCoord& _coord) override;
176
177 using Widget::setPosition;
178 using Widget::setSize;
179 using Widget::setCoord;
180
182 void setVisibleVScroll(bool _value);
184 bool isVisibleVScroll() const;
191 size_t getVScrollRange() const;
193 size_t getVScrollPosition() const;
195 void setVScrollPosition(size_t _index);
196
198 void setVisibleHScroll(bool _value);
200 bool isVisibleHScroll() const;
206 size_t getHScrollRange() const;
208 size_t getHScrollPosition() const;
210 void setHScrollPosition(size_t _index);
211
212
214 void setFontName(std::string_view _value) override;
216 void setFontHeight(int _value) override;
218 int getFontHeight() const override;
219
221 void setTextAlign(Align _value) override;
223 void setTextColour(const Colour& _value) override;
224
226 IntCoord getTextRegion() const override;
227
229 IntSize getTextSize() const override;
230
232 void setTextShadowColour(const Colour& _value) override;
233
235 void setTextShadow(bool _value) override;
236
237 /*events:*/
243
249
250 protected:
251 void initialiseOverride() override;
252 void shutdownOverride() override;
253
254 void onMouseDrag(int _left, int _top, MouseButton _id) override;
255 void onKeyLostFocus(Widget* _new) override;
256 void onKeySetFocus(Widget* _old) override;
257 void onKeyButtonPressed(KeyCode _key, Char _char) override;
258
259 // потом убрать все нотифи в сраку
260 void notifyMouseSetFocus(Widget* _sender, Widget* _old);
261 void notifyMouseLostFocus(Widget* _sender, Widget* _new);
262 void notifyMousePressed(Widget* _sender, int _left, int _top, MouseButton _id);
263 void notifyMouseReleased(Widget* _sender, int _left, int _top, MouseButton _id);
264 void notifyMouseDrag(Widget* _sender, int _left, int _top, MouseButton _id);
265 void notifyMouseButtonDoubleClick(Widget* _sender);
266
267 void notifyScrollChangePosition(ScrollBar* _sender, size_t _position);
268 void notifyMouseWheel(Widget* _sender, int _rel);
269
270 // обновление представления
271 void updateView();
272 void updateViewWithCursor();
273
274 void eraseView();
275
276 void setPropertyOverride(std::string_view _key, std::string_view _value) override;
277
278 private:
279 // устанавливает текст
280 void setText(const UString& _caption, bool _history);
281 // удаляет все что выделенно
282 bool deleteTextSelect(bool _history);
283 // вставляет текст в указанную позицию
284 void insertText(const UString& _text, size_t _start, bool _history);
285 // удаляет текст
286 void eraseText(size_t _start, size_t _count, bool _history);
287 // выделяет цветом выделение
288 void setTextSelectColour(const Colour& _colour, bool _history);
289 // выделяет цветом диапазон
290 void _setTextColour(size_t _start, size_t _count, const Colour& _colour, bool _history);
291
292 void frameEntered(float _frame);
293
294 void updateEditState();
295
296 // обновляет курсор по координате
297 void updateSelectText();
298
299 void resetSelect();
300
301 // запись в историю данных о позиции
302 void commandPosition(size_t _undo, size_t _redo, size_t _length, VectorChangeInfo* _info = nullptr);
303
304 // команнды отмена и повтор
305 bool commandRedo();
306 bool commandUndo();
307 // объединяет последние две комманды
308 void commandMerge();
309 // очистка
310 void commandResetRedo();
311 void commandResetHistory();
312 void saveInHistory(VectorChangeInfo* _info = nullptr);
313
314 // clipboard commands
315 void commandCut();
316 void commandCopy() const;
317 void commandPaste();
318
319 const UString& getRealString() const;
320
321 void setRealString(const UString& _caption);
322
323 void updateCursorPosition();
324
325 // размер данных
326 IntSize getContentSize() const override;
327 // смещение данных
328 IntPoint getContentPosition() const override;
329 void setContentPosition(const IntPoint& _point) override;
330 // размер окна, через которые видно данные
331 IntSize getViewSize() const override;
332 // размер на который прокручиваются данные при щелчке по скролу
333 size_t getVScrollPage() const override;
334 size_t getHScrollPage() const override;
335
336 Align getContentAlign() const override;
337
338 protected:
339 // нажата ли кнопка
340 bool mIsPressed{false};
341 // в фокусе ли кнопка
342 bool mIsFocus{false};
343
344 bool mCursorActive{false};
345 float mCursorTimer{0};
346 float mActionMouseTimer{0};
347
348 // позиция курсора
349 size_t mCursorPosition{0};
350 // максимальное колличество
351 size_t mTextLength{0};
352
353 // выделение
354 size_t mStartSelect{ITEM_NONE};
355 size_t mEndSelect{0};
356
357 // списоки изменений для отмены и повтора
360
361 bool mMouseLeftPressed{false};
362
363 bool mModeReadOnly{false};
364 bool mModePassword{false};
365 bool mModeMultiline{false};
366 bool mModeStatic{false};
367 bool mModeWordWrap{false};
368
369 bool mTabPrinting{false};
370
371 // настоящий текст, закрытый за звездочками
373
374 // для поддержки режима статик, где курсор не нужен
375 std::string mOriginalPointer;
376
377 Char mCharPassword{'*'};
378
379 bool mOverflowToTheLeft{false};
381
382 ISubWidgetText* mClientText{nullptr};
383 };
384
385} // namespace MyGUI
386
387#endif // MYGUI_EDIT_BOX_H_
#define MYGUI_EXPORT
#define MYGUI_RTTI_DERIVED(DerivedType)
Definition MyGUI_RTTI.h:69
widget description should be here.
DequeUndoRedoInfo mVectorUndoChangeInfo
UString mPasswordText
EventPair< EventHandle_WidgetVoid, EventHandle_EditPtr > eventEditTextChange
DequeUndoRedoInfo mVectorRedoChangeInfo
std::string mOriginalPointer
EventPair< EventHandle_WidgetVoid, EventHandle_EditPtr > eventEditSelectAccept
widget description should be here.
widget description should be here.
A UTF-16 string with implicit conversion to/from std::string and std::wstring.
widget description should be here.
std::vector< TextCommandInfo > VectorChangeInfo
unsigned int Char
Definition MyGUI_Types.h:50
constexpr size_t ITEM_NONE
std::deque< VectorChangeInfo > DequeUndoRedoInfo