MyGUI  3.2.2
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 
20  typedef delegates::CMultiDelegate1<EditBox*> EventHandle_EditPtr;
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  virtual const UString& getCaption();
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  virtual void setPosition(const IntPoint& _value);
176  virtual void setSize(const IntSize& _value);
178  virtual void setCoord(const IntCoord& _value);
179 
181  void setPosition(int _left, int _top);
183  void setSize(int _width, int _height);
185  void setCoord(int _left, int _top, int _width, int _height);
186 
188  void setVisibleVScroll(bool _value);
190  bool isVisibleVScroll() const;
197  size_t getVScrollRange() const;
199  size_t getVScrollPosition();
201  void setVScrollPosition(size_t _index);
202 
204  void setVisibleHScroll(bool _value);
206  bool isVisibleHScroll() const;
212  size_t getHScrollRange() const;
214  size_t getHScrollPosition();
216  void setHScrollPosition(size_t _index);
217 
218 
220  virtual void setFontName(const std::string& _value);
222  virtual void setFontHeight(int _value);
223 
225  virtual void setTextAlign(Align _value);
227  virtual void setTextColour(const Colour& _value);
228 
230  virtual IntCoord getTextRegion();
231 
233  virtual IntSize getTextSize();
234 
236  virtual void setTextShadowColour(const Colour& _value);
237 
239  virtual void setTextShadow(bool _value);
240 
241  /*events:*/
247 
253 
254  protected:
255  virtual void initialiseOverride();
256  virtual void shutdownOverride();
257 
258  virtual void onMouseDrag(int _left, int _top, MouseButton _id);
259  virtual void onKeyLostFocus(Widget* _new);
260  virtual void onKeySetFocus(Widget* _old);
261  virtual void onKeyButtonPressed(KeyCode _key, Char _char);
262 
263  // потом убрать все нотифи в сраку
264  void notifyMouseSetFocus(Widget* _sender, Widget* _old);
265  void notifyMouseLostFocus(Widget* _sender, Widget* _new);
266  void notifyMousePressed(Widget* _sender, int _left, int _top, MouseButton _id);
267  void notifyMouseReleased(Widget* _sender, int _left, int _top, MouseButton _id);
268  void notifyMouseDrag(Widget* _sender, int _left, int _top, MouseButton _id);
269  void notifyMouseButtonDoubleClick(Widget* _sender);
270 
271  void notifyScrollChangePosition(ScrollBar* _sender, size_t _position);
272  void notifyMouseWheel(Widget* _sender, int _rel);
273 
274  // обновление представления
275  void updateView();
276  void updateViewWithCursor();
277 
278  void eraseView();
279 
280  virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
281 
282  private:
283  // устанавливает текст
284  void setText(const UString& _text, bool _history);
285  // удаляет все что выделенно
286  bool deleteTextSelect(bool _history);
287  // вставляет текст в указанную позицию
288  void insertText(const UString& _text, size_t _index, bool _history);
289  // удаляет текст
290  void eraseText(size_t _start, size_t _count, bool _history);
291  // выделяет цветом выделение
292  void setTextSelectColour(const Colour& _colour, bool _history);
293  // выделяет цветом диапазон
294  void _setTextColour(size_t _start, size_t _count, const Colour& _colour, bool _history);
295 
296  void frameEntered(float _frame);
297 
298  void updateEditState();
299 
300  // обновляет курсор по координате
301  void updateSelectText();
302 
303  void resetSelect();
304 
305  // запись в историю данных о позиции
306  void commandPosition(size_t _undo, size_t _redo, size_t _length, VectorChangeInfo* _info = nullptr);
307 
308  // команнды отмена и повтор
309  bool commandRedo();
310  bool commandUndo();
311  // объединяет последние две комманды
312  void commandMerge();
313  // очистка
314  void commandResetRedo();
315  void commandResetHistory();
316  void saveInHistory(VectorChangeInfo* _info = nullptr);
317 
318  // работа с буфером обмена
319  void commandCut();
320  void commandCopy();
321  void commandPast();
322 
323  const UString& getRealString();
324 
325  void setRealString(const UString& _caption);
326 
327  void updateCursorPosition();
328 
329  // размер данных
330  virtual IntSize getContentSize();
331  // смещение данных
332  virtual IntPoint getContentPosition();
333  virtual void setContentPosition(const IntPoint& _point);
334  // размер окна, через которые видно данные
335  virtual IntSize getViewSize();
336  // размер на который прокручиваются данные при щелчке по скролу
337  virtual size_t getVScrollPage();
338  virtual size_t getHScrollPage();
339 
340  virtual Align getContentAlign();
341 
342  protected:
343  // нажата ли кнопка
345  // в фокусе ли кнопка
346  bool mIsFocus;
347 
351 
352  // позиция курсора
354  // максимальное колличество
355  size_t mTextLength;
356 
357  // выделение
358  size_t mStartSelect;
359  size_t mEndSelect;
360 
361  // списоки изменений для отмены и повтора
364 
366 
372 
374 
375  // настоящий текст, закрытый за звездочками
377 
378  // для поддержки режима статик, где курсор не нужен
379  std::string mOriginalPointer;
380 
382 
385 
387  };
388 
389 } // namespace MyGUI
390 
391 #endif // MYGUI_EDIT_BOX_H_
MyGUI::EditBox::eventEditTextChange
EventPair< EventHandle_WidgetVoid, EventHandle_EditPtr > eventEditTextChange
Definition: MyGUI_EditBox.h:252
MyGUI::ISubWidgetText
Definition: MyGUI_ISubWidgetText.h:18
MyGUI::EditBox::mMouseLeftPressed
bool mMouseLeftPressed
Definition: MyGUI_EditBox.h:365
MyGUI::VectorChangeInfo
std::vector< TextCommandInfo > VectorChangeInfo
Definition: MyGUI_TextChangeHistory.h:60
MyGUI::EditBox::mModePassword
bool mModePassword
Definition: MyGUI_EditBox.h:368
MyGUI::ScrollBar
ScrollBar properties. Skin childs. ScrollBar widget description should be here.
Definition: MyGUI_ScrollBar.h:23
MyGUI::EditBox::mTextLength
size_t mTextLength
Definition: MyGUI_EditBox.h:355
MyGUI::EditBox
EditBox properties. Skin childs. EditBox widget description should be here.
Definition: MyGUI_EditBox.h:25
MyGUI_EventPair.h
MyGUI::EditBox::mVectorRedoChangeInfo
DequeUndoRedoInfo mVectorRedoChangeInfo
Definition: MyGUI_EditBox.h:363
MyGUI::EditBox::mMaxTextLength
size_t mMaxTextLength
Definition: MyGUI_EditBox.h:384
MyGUI::Widget
Widget properties. Skin childs. Widget widget description should be here.
Definition: MyGUI_Widget.h:29
MyGUI::EditBox::mModeMultiline
bool mModeMultiline
Definition: MyGUI_EditBox.h:369
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:381
MyGUI::EditBox::mClientText
ISubWidgetText * mClientText
Definition: MyGUI_EditBox.h:386
MyGUI::EventPair< EventHandle_WidgetVoid, EventHandle_EditPtr >
MyGUI::EditBox::mIsPressed
bool mIsPressed
Definition: MyGUI_EditBox.h:344
MyGUI::EditBox::mCursorPosition
size_t mCursorPosition
Definition: MyGUI_EditBox.h:353
MyGUI::Align
Definition: MyGUI_Align.h:19
MyGUI::EditBox::mModeStatic
bool mModeStatic
Definition: MyGUI_EditBox.h:370
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:367
MyGUI::EditBox::mModeWordWrap
bool mModeWordWrap
Definition: MyGUI_EditBox.h:371
MyGUI::MouseButton
Definition: MyGUI_MouseButton.h:15
MyGUI::EditBox::mActionMouseTimer
float mActionMouseTimer
Definition: MyGUI_EditBox.h:350
MyGUI::ScrollViewBase
Definition: MyGUI_ScrollViewBase.h:16
MyGUI::EditBox::eventEditSelectAccept
EventPair< EventHandle_WidgetVoid, EventHandle_EditPtr > eventEditSelectAccept
Definition: MyGUI_EditBox.h:246
MyGUI_ScrollViewBase.h
MyGUI_Prerequest.h
MyGUI::TextBox
TextBox properties. Skin childs. TextBox widget description should be here.
Definition: MyGUI_TextBox.h:19
MyGUI::EditBox::mEndSelect
size_t mEndSelect
Definition: MyGUI_EditBox.h:359
MyGUI::DequeUndoRedoInfo
std::deque< VectorChangeInfo > DequeUndoRedoInfo
Definition: MyGUI_TextChangeHistory.h:61
MyGUI::EditBox::mOverflowToTheLeft
bool mOverflowToTheLeft
Definition: MyGUI_EditBox.h:383
MyGUI_TextChangeHistory.h
MyGUI::EditBox::mPasswordText
UString mPasswordText
Definition: MyGUI_EditBox.h:376
MyGUI::EditBox::mCursorActive
bool mCursorActive
Definition: MyGUI_EditBox.h:348
MYGUI_RTTI_DERIVED
#define MYGUI_RTTI_DERIVED(DerivedType)
Definition: MyGUI_RTTI.h:65
MyGUI::EditBox::mTabPrinting
bool mTabPrinting
Definition: MyGUI_EditBox.h:373
MyGUI::MemberObsolete
Definition: MyGUI_DeprecatedTypes.h:13
MyGUI::EditBox::mCursorTimer
float mCursorTimer
Definition: MyGUI_EditBox.h:349
MyGUI::types::TSize< int >
MyGUI::EditBox::mVectorUndoChangeInfo
DequeUndoRedoInfo mVectorUndoChangeInfo
Definition: MyGUI_EditBox.h:362
MyGUI::Colour
Definition: MyGUI_Colour.h:16
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition: MyGUI_Platform.h:103
MyGUI::Char
unsigned int Char
Definition: MyGUI_Types.h:51
MyGUI::EditBox::mStartSelect
size_t mStartSelect
Definition: MyGUI_EditBox.h:358
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:346
MyGUI
Definition: MyGUI_ActionController.h:14
MyGUI::EditBox::mOriginalPointer
std::string mOriginalPointer
Definition: MyGUI_EditBox.h:379
MyGUI_TextBox.h
MyGUI_TextIterator.h
MyGUI::KeyCode
Definition: MyGUI_KeyCode.h:15