MyGUI  3.4.0
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);
50 
55  void setTextSelection(size_t _start, size_t _end);
56 
58  void deleteTextSelection();
59 
61  UString getTextSelection();
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  virtual void setCaption(const UString& _value);
78  const UString& getCaption() override;
79 
81  void setOnlyText(const UString& _value);
83  UString getOnlyText();
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();
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();
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();
213  void setHScrollPosition(size_t _index);
214 
215 
217  void setFontName(const std::string& _value) override;
219  void setFontHeight(int _value) override;
220 
222  void setTextAlign(Align _value) override;
224  void setTextColour(const Colour& _value) override;
225 
227  IntCoord getTextRegion() override;
228 
230  IntSize getTextSize() override;
231 
233  void setTextShadowColour(const Colour& _value) override;
234 
236  void setTextShadow(bool _value) override;
237 
238  /*events:*/
244 
250 
251  protected:
252  void initialiseOverride() override;
253  void shutdownOverride() override;
254 
255  void onMouseDrag(int _left, int _top, MouseButton _id) override;
256  void onKeyLostFocus(Widget* _new) override;
257  void onKeySetFocus(Widget* _old) override;
258  void onKeyButtonPressed(KeyCode _key, Char _char) override;
259 
260  // потом убрать все нотифи в сраку
261  void notifyMouseSetFocus(Widget* _sender, Widget* _old);
262  void notifyMouseLostFocus(Widget* _sender, Widget* _new);
263  void notifyMousePressed(Widget* _sender, int _left, int _top, MouseButton _id);
264  void notifyMouseReleased(Widget* _sender, int _left, int _top, MouseButton _id);
265  void notifyMouseDrag(Widget* _sender, int _left, int _top, MouseButton _id);
266  void notifyMouseButtonDoubleClick(Widget* _sender);
267 
268  void notifyScrollChangePosition(ScrollBar* _sender, size_t _position);
269  void notifyMouseWheel(Widget* _sender, int _rel);
270 
271  // обновление представления
272  void updateView();
273  void updateViewWithCursor();
274 
275  void eraseView();
276 
277  void setPropertyOverride(const std::string& _key, const std::string& _value) override;
278 
279  private:
280  // устанавливает текст
281  void setText(const UString& _text, bool _history);
282  // удаляет все что выделенно
283  bool deleteTextSelect(bool _history);
284  // вставляет текст в указанную позицию
285  void insertText(const UString& _text, size_t _index, bool _history);
286  // удаляет текст
287  void eraseText(size_t _start, size_t _count, bool _history);
288  // выделяет цветом выделение
289  void setTextSelectColour(const Colour& _colour, bool _history);
290  // выделяет цветом диапазон
291  void _setTextColour(size_t _start, size_t _count, const Colour& _colour, bool _history);
292 
293  void frameEntered(float _frame);
294 
295  void updateEditState();
296 
297  // обновляет курсор по координате
298  void updateSelectText();
299 
300  void resetSelect();
301 
302  // запись в историю данных о позиции
303  void commandPosition(size_t _undo, size_t _redo, size_t _length, VectorChangeInfo* _info = nullptr);
304 
305  // команнды отмена и повтор
306  bool commandRedo();
307  bool commandUndo();
308  // объединяет последние две комманды
309  void commandMerge();
310  // очистка
311  void commandResetRedo();
312  void commandResetHistory();
313  void saveInHistory(VectorChangeInfo* _info = nullptr);
314 
315  // работа с буфером обмена
316  void commandCut();
317  void commandCopy();
318  void commandPast();
319 
320  const UString& getRealString();
321 
322  void setRealString(const UString& _caption);
323 
324  void updateCursorPosition();
325 
326  // размер данных
327  IntSize getContentSize() override;
328  // смещение данных
329  IntPoint getContentPosition() override;
330  void setContentPosition(const IntPoint& _point) override;
331  // размер окна, через которые видно данные
332  IntSize getViewSize() override;
333  // размер на который прокручиваются данные при щелчке по скролу
334  size_t getVScrollPage() override;
335  size_t getHScrollPage() override;
336 
337  Align getContentAlign() override;
338 
339  protected:
340  // нажата ли кнопка
342  // в фокусе ли кнопка
343  bool mIsFocus;
344 
348 
349  // позиция курсора
351  // максимальное колличество
352  size_t mTextLength;
353 
354  // выделение
355  size_t mStartSelect;
356  size_t mEndSelect;
357 
358  // списоки изменений для отмены и повтора
361 
363 
369 
371 
372  // настоящий текст, закрытый за звездочками
374 
375  // для поддержки режима статик, где курсор не нужен
376  std::string mOriginalPointer;
377 
379 
382 
384  };
385 
386 } // namespace MyGUI
387 
388 #endif // MYGUI_EDIT_BOX_H_
MyGUI::Char
unsigned int Char
Definition: MyGUI_Types.h:48
MyGUI::EditBox::eventEditTextChange
EventPair< EventHandle_WidgetVoid, EventHandle_EditPtr > eventEditTextChange
Definition: MyGUI_EditBox.h:249
MyGUI::ISubWidgetText
Definition: MyGUI_ISubWidgetText.h:20
MyGUI::EditBox::mMouseLeftPressed
bool mMouseLeftPressed
Definition: MyGUI_EditBox.h:362
MyGUI::EditBox::mModePassword
bool mModePassword
Definition: MyGUI_EditBox.h:365
MyGUI::Widget::setPosition
void setPosition(const IntPoint &_value) override
Definition: MyGUI_Widget.cpp:630
MyGUI::ScrollBar
ScrollBar properties. Skin childs. ScrollBar widget description should be here.
Definition: MyGUI_ScrollBar.h:26
MyGUI::EditBox::mTextLength
size_t mTextLength
Definition: MyGUI_EditBox.h:352
MyGUI::EditBox
EditBox properties. Skin childs. EditBox widget description should be here.
Definition: MyGUI_EditBox.h:29
MyGUI_EventPair.h
MyGUI::EditBox::mVectorRedoChangeInfo
DequeUndoRedoInfo mVectorRedoChangeInfo
Definition: MyGUI_EditBox.h:360
MyGUI::delegates::MultiDelegate
Definition: MyGUI_Delegate.h:183
MyGUI::VectorChangeInfo
std::vector< TextCommandInfo > VectorChangeInfo
Definition: MyGUI_TextChangeHistory.h:60
MyGUI::EditBox::mMaxTextLength
size_t mMaxTextLength
Definition: MyGUI_EditBox.h:381
MyGUI::Widget
Widget properties. Skin childs. Widget widget description should be here.
Definition: MyGUI_Widget.h:37
MyGUI::EditBox::mModeMultiline
bool mModeMultiline
Definition: MyGUI_EditBox.h:366
MyGUI::ITEM_NONE
const size_t ITEM_NONE
Definition: MyGUI_Macros.h:17
MyGUI::types::TPoint< int >
MyGUI::EditBox::mCharPassword
Char mCharPassword
Definition: MyGUI_EditBox.h:378
MyGUI::EditBox::mClientText
ISubWidgetText * mClientText
Definition: MyGUI_EditBox.h:383
MyGUI::EventPair
Definition: MyGUI_EventPair.h:17
MyGUI::EditBox::mIsPressed
bool mIsPressed
Definition: MyGUI_EditBox.h:341
MyGUI::EditBox::mCursorPosition
size_t mCursorPosition
Definition: MyGUI_EditBox.h:350
MyGUI::Align
Definition: MyGUI_Align.h:20
MyGUI::EditBox::mModeStatic
bool mModeStatic
Definition: MyGUI_EditBox.h:367
MyGUI::UString
A UTF-16 string with implicit conversion to/from std::string and std::wstring.
Definition: MyGUI_UString.h:168
MyGUI::EditBox::mModeReadOnly
bool mModeReadOnly
Definition: MyGUI_EditBox.h:364
MyGUI::EditBox::mModeWordWrap
bool mModeWordWrap
Definition: MyGUI_EditBox.h:368
MyGUI::MouseButton
Definition: MyGUI_MouseButton.h:16
MyGUI::EditBox::mActionMouseTimer
float mActionMouseTimer
Definition: MyGUI_EditBox.h:347
MyGUI::ScrollViewBase
Definition: MyGUI_ScrollViewBase.h:17
MyGUI::EditBox::eventEditSelectAccept
EventPair< EventHandle_WidgetVoid, EventHandle_EditPtr > eventEditSelectAccept
Definition: MyGUI_EditBox.h:243
MyGUI_ScrollViewBase.h
MyGUI_Prerequest.h
MyGUI::TextBox
TextBox properties. Skin childs. TextBox widget description should be here.
Definition: MyGUI_TextBox.h:21
MyGUI::EditBox::mEndSelect
size_t mEndSelect
Definition: MyGUI_EditBox.h:356
MyGUI::Widget::setSize
void setSize(const IntSize &_value) override
Definition: MyGUI_Widget.cpp:647
MyGUI::EditBox::mOverflowToTheLeft
bool mOverflowToTheLeft
Definition: MyGUI_EditBox.h:380
MyGUI_TextChangeHistory.h
MyGUI::EditBox::mPasswordText
UString mPasswordText
Definition: MyGUI_EditBox.h:373
MyGUI::EditBox::mCursorActive
bool mCursorActive
Definition: MyGUI_EditBox.h:345
MYGUI_RTTI_DERIVED
#define MYGUI_RTTI_DERIVED(DerivedType)
Definition: MyGUI_RTTI.h:48
MyGUI::EditBox::mTabPrinting
bool mTabPrinting
Definition: MyGUI_EditBox.h:370
MyGUI::MemberObsolete
Definition: MyGUI_DeprecatedTypes.h:14
MyGUI::EditBox::mCursorTimer
float mCursorTimer
Definition: MyGUI_EditBox.h:346
MyGUI::types::TSize< int >
MyGUI::Widget::setCoord
void setCoord(const IntCoord &_value) override
Definition: MyGUI_Widget.cpp:684
MyGUI::EditBox::mVectorUndoChangeInfo
DequeUndoRedoInfo mVectorUndoChangeInfo
Definition: MyGUI_EditBox.h:359
MyGUI::Colour
Definition: MyGUI_Colour.h:17
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition: MyGUI_Platform.h:89
MyGUI::EditBox::mStartSelect
size_t mStartSelect
Definition: MyGUI_EditBox.h:355
MyGUI::types::TCoord< int >
MyGUI::EventHandle_EditPtr
delegates::CMultiDelegate1< EditBox * > EventHandle_EditPtr
Definition: MyGUI_EditBox.h:20
MyGUI::EditBox::mIsFocus
bool mIsFocus
Definition: MyGUI_EditBox.h:343
MyGUI
Definition: MyGUI_ActionController.h:15
MyGUI::DequeUndoRedoInfo
std::deque< VectorChangeInfo > DequeUndoRedoInfo
Definition: MyGUI_TextChangeHistory.h:61
MyGUI::EditBox::mOriginalPointer
std::string mOriginalPointer
Definition: MyGUI_EditBox.h:376
MyGUI_TextBox.h
MyGUI_TextIterator.h
MyGUI::KeyCode
Definition: MyGUI_KeyCode.h:16