MyGUI  3.4.1
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"
15 #include "MyGUI_ScrollViewBase.h"
16 
17 namespace MyGUI
18 {
19 
21 
26  public TextBox,
27  public ScrollViewBase,
28  public MemberObsolete<EditBox>
29  {
31 
32  public:
33  EditBox();
34 
36  void setTextIntervalColour(size_t _start, size_t _count, const Colour& _colour);
37 
39  size_t getTextSelectionStart() const;
40 
42  size_t getTextSelectionEnd() const;
43 
45  size_t getTextSelectionLength() const;
46 
47  // возвращает текст с тегами
49  UString getTextInterval(size_t _start, size_t _count) const;
50 
55  void setTextSelection(size_t _start, size_t _end);
56 
58  void deleteTextSelection();
59 
61  UString getTextSelection() const;
62 
64  bool isTextSelection() const;
65 
67  void setTextSelectionColour(const Colour& _value);
68 
70  void setTextCursor(size_t _index);
72  size_t getTextCursor() const;
73 
74 
76  void setCaption(const UString& _value) override;
78  const UString& getCaption() const override;
79 
81  void setOnlyText(const UString& _value);
83  UString getOnlyText() const;
84 
89  size_t getTextLength() const;
90 
92  void setOverflowToTheLeft(bool _value);
94  bool getOverflowToTheLeft() const;
95 
97  void setMaxTextLength(size_t _value);
99  size_t getMaxTextLength() const;
100 
102  void insertText(const UString& _text, size_t _index = ITEM_NONE);
104  void addText(const UString& _text);
106  void eraseText(size_t _start, size_t _count = 1);
107 
112  void setEditReadOnly(bool _value);
114  bool getEditReadOnly() const;
115 
120  void setEditPassword(bool _value);
122  bool getEditPassword() const;
123 
129  void setEditMultiLine(bool _value);
131  bool getEditMultiLine() const;
132 
137  void setEditStatic(bool _value);
139  bool getEditStatic() const;
140 
142  void setPasswordChar(Char _value);
144  void setPasswordChar(const UString& _char);
146  Char getPasswordChar() const;
147 
153  void setEditWordWrap(bool _value);
155  bool getEditWordWrap() const;
156 
162  void setTabPrinting(bool _value);
164  bool getTabPrinting() const;
165 
167  bool getInvertSelected() const;
171  void setInvertSelected(bool _value);
172 
174  void setPosition(const IntPoint& _value) override;
176  void setSize(const IntSize& _value) override;
178  void setCoord(const IntCoord& _value) override;
179 
180  using Widget::setPosition;
181  using Widget::setSize;
182  using Widget::setCoord;
183 
185  void setVisibleVScroll(bool _value);
187  bool isVisibleVScroll() const;
194  size_t getVScrollRange() const;
196  size_t getVScrollPosition() const;
198  void setVScrollPosition(size_t _index);
199 
201  void setVisibleHScroll(bool _value);
203  bool isVisibleHScroll() const;
209  size_t getHScrollRange() const;
211  size_t getHScrollPosition() const;
213  void setHScrollPosition(size_t _index);
214 
215 
217  void setFontName(const std::string& _value) override;
219  void setFontHeight(int _value) override;
221  int getFontHeight() const override;
222 
224  void setTextAlign(Align _value) override;
226  void setTextColour(const Colour& _value) override;
227 
229  IntCoord getTextRegion() const override;
230 
232  IntSize getTextSize() const override;
233 
235  void setTextShadowColour(const Colour& _value) override;
236 
238  void setTextShadow(bool _value) override;
239 
240  /*events:*/
246 
252 
253  protected:
254  void initialiseOverride() override;
255  void shutdownOverride() override;
256 
257  void onMouseDrag(int _left, int _top, MouseButton _id) override;
258  void onKeyLostFocus(Widget* _new) override;
259  void onKeySetFocus(Widget* _old) override;
260  void onKeyButtonPressed(KeyCode _key, Char _char) override;
261 
262  // потом убрать все нотифи в сраку
263  void notifyMouseSetFocus(Widget* _sender, Widget* _old);
264  void notifyMouseLostFocus(Widget* _sender, Widget* _new);
265  void notifyMousePressed(Widget* _sender, int _left, int _top, MouseButton _id);
266  void notifyMouseReleased(Widget* _sender, int _left, int _top, MouseButton _id);
267  void notifyMouseDrag(Widget* _sender, int _left, int _top, MouseButton _id);
268  void notifyMouseButtonDoubleClick(Widget* _sender);
269 
270  void notifyScrollChangePosition(ScrollBar* _sender, size_t _position);
271  void notifyMouseWheel(Widget* _sender, int _rel);
272 
273  // обновление представления
274  void updateView();
275  void updateViewWithCursor();
276 
277  void eraseView();
278 
279  void setPropertyOverride(const std::string& _key, const std::string& _value) override;
280 
281  private:
282  // устанавливает текст
283  void setText(const UString& _text, bool _history);
284  // удаляет все что выделенно
285  bool deleteTextSelect(bool _history);
286  // вставляет текст в указанную позицию
287  void insertText(const UString& _text, size_t _index, bool _history);
288  // удаляет текст
289  void eraseText(size_t _start, size_t _count, bool _history);
290  // выделяет цветом выделение
291  void setTextSelectColour(const Colour& _colour, bool _history);
292  // выделяет цветом диапазон
293  void _setTextColour(size_t _start, size_t _count, const Colour& _colour, bool _history);
294 
295  void frameEntered(float _frame);
296 
297  void updateEditState();
298 
299  // обновляет курсор по координате
300  void updateSelectText();
301 
302  void resetSelect();
303 
304  // запись в историю данных о позиции
305  void commandPosition(size_t _undo, size_t _redo, size_t _length, VectorChangeInfo* _info = nullptr);
306 
307  // команнды отмена и повтор
308  bool commandRedo();
309  bool commandUndo();
310  // объединяет последние две комманды
311  void commandMerge();
312  // очистка
313  void commandResetRedo();
314  void commandResetHistory();
315  void saveInHistory(VectorChangeInfo* _info = nullptr);
316 
317  // работа с буфером обмена
318  void commandCut();
319  void commandCopy();
320  void commandPast();
321 
322  const UString& getRealString() const;
323 
324  void setRealString(const UString& _caption);
325 
326  void updateCursorPosition();
327 
328  // размер данных
329  IntSize getContentSize() const override;
330  // смещение данных
331  IntPoint getContentPosition() const override;
332  void setContentPosition(const IntPoint& _point) override;
333  // размер окна, через которые видно данные
334  IntSize getViewSize() const override;
335  // размер на который прокручиваются данные при щелчке по скролу
336  size_t getVScrollPage() const override;
337  size_t getHScrollPage() const override;
338 
339  Align getContentAlign() const override;
340 
341  protected:
342  // нажата ли кнопка
344  // в фокусе ли кнопка
345  bool mIsFocus;
346 
350 
351  // позиция курсора
353  // максимальное колличество
354  size_t mTextLength;
355 
356  // выделение
357  size_t mStartSelect;
358  size_t mEndSelect;
359 
360  // списоки изменений для отмены и повтора
363 
365 
371 
373 
374  // настоящий текст, закрытый за звездочками
376 
377  // для поддержки режима статик, где курсор не нужен
378  std::string mOriginalPointer;
379 
381 
384 
386  };
387 
388 } // namespace MyGUI
389 
390 #endif // MYGUI_EDIT_BOX_H_
#define MYGUI_EXPORT
#define MYGUI_RTTI_DERIVED(DerivedType)
Definition: MyGUI_RTTI.h:48
widget description should be here.
Definition: MyGUI_EditBox.h:29
DequeUndoRedoInfo mVectorUndoChangeInfo
ISubWidgetText * mClientText
size_t mMaxTextLength
UString mPasswordText
EventPair< EventHandle_WidgetVoid, EventHandle_EditPtr > eventEditTextChange
DequeUndoRedoInfo mVectorRedoChangeInfo
std::string mOriginalPointer
float mActionMouseTimer
EventPair< EventHandle_WidgetVoid, EventHandle_EditPtr > eventEditSelectAccept
size_t mCursorPosition
widget description should be here.
widget description should be here.
Definition: MyGUI_TextBox.h:21
A UTF-16 string with implicit conversion to/from std::string and std::wstring.
widget description should be here.
Definition: MyGUI_Widget.h:37
void setCoord(const IntCoord &_value) override
void setPosition(const IntPoint &_value) override
void setSize(const IntSize &_value) override
delegates::CMultiDelegate1< EditBox * > EventHandle_EditPtr
Definition: MyGUI_EditBox.h:20
const size_t ITEM_NONE
Definition: MyGUI_Macros.h:17
unsigned int Char
Definition: MyGUI_Types.h:49
std::deque< VectorChangeInfo > DequeUndoRedoInfo
std::vector< TextCommandInfo > VectorChangeInfo