MyGUI 3.4.2
MyGUI_EditBox.cpp
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#include "MyGUI_Precompiled.h"
8#include "MyGUI_EditBox.h"
9#include "MyGUI_Gui.h"
10#include "MyGUI_ResourceSkin.h"
11#include "MyGUI_SkinManager.h"
12#include "MyGUI_InputManager.h"
16#include "MyGUI_ScrollBar.h"
17
18#include <cctype>
19
20namespace MyGUI
21{
22
23 enum class EditCommand {
32 Undo, Redo
33 };
34
35 const float EDIT_CURSOR_TIMER = 0.7f;
36 const float EDIT_ACTION_MOUSE_TIMER = 0.05f;
37 const int EDIT_CURSOR_MAX_POSITION = 100000;
38 const int EDIT_CURSOR_MIN_POSITION = -100000;
39 const size_t EDIT_MAX_UNDO = 128;
40 const size_t EDIT_DEFAULT_MAX_TEXT_LENGTH = 2048;
41 const float EDIT_OFFSET_HORZ_CURSOR = 10.0f; // дополнительное смещение для курсора
42 const int EDIT_ACTION_MOUSE_ZONE = 1500; // область для восприятия мыши за пределом эдита
43 const std::string EDIT_CLIPBOARD_TYPE_TEXT = "Text";
44 const int EDIT_MOUSE_WHEEL = 50; // область для восприятия мыши за пределом эдита
45
47 mIsPressed(false),
48 mIsFocus(false),
49 mCursorActive(false),
50 mCursorTimer(0),
51 mActionMouseTimer(0),
52 mCursorPosition(0),
53 mTextLength(0),
54 mStartSelect(ITEM_NONE),
55 mEndSelect(0),
56 mMouseLeftPressed(false),
57 mModeReadOnly(false),
58 mModePassword(false),
59 mModeMultiline(false),
60 mModeStatic(false),
61 mModeWordWrap(false),
62 mTabPrinting(false),
63 mCharPassword('*'),
64 mOverflowToTheLeft(false),
65 mMaxTextLength(EDIT_DEFAULT_MAX_TEXT_LENGTH),
66 mClientText(nullptr)
67 {
69 }
70
72 {
74
76
77 // FIXME нам нужен фокус клавы
78 setNeedKeyFocus(true);
79
81 if (getClientWidget() != nullptr)
82 {
90 }
91
93 assignWidget(mVScroll, "VScroll");
94 if (mVScroll != nullptr)
95 {
97 }
98
100 assignWidget(mHScroll, "HScroll");
101 if (mHScroll != nullptr)
102 {
104 }
105
107 if (getClientWidget() != nullptr)
108 {
110 if (text)
111 mClientText = text;
112 }
113
115
116 // первоначальная инициализация курсора
117 if (mClientText != nullptr)
119
120 updateSelectText();
121 }
122
124 {
125 mScrollViewClient = nullptr;
126 mClientText = nullptr;
127 mVScroll = nullptr;
128 mHScroll = nullptr;
129
131 }
132
134 {
135 if ((_old == getClientWidget()) || (mIsFocus))
136 return;
137
138 mIsFocus = true;
139 updateEditState();
140 }
141
143 {
144 if ((_new == getClientWidget()) || (!mIsFocus))
145 return;
146
147 mIsFocus = false;
148 updateEditState();
149 }
150
152 {
153 if (mClientText == nullptr)
154 return;
155
156 // в статике все недоступно
157 if (mModeStatic)
158 return;
159
160 IntPoint point = InputManager::getInstance().getLastPressedPosition(MouseButton::Left);
164 mCursorTimer = 0;
165 updateSelectText();
166
167 if (_id == MouseButton::Left)
168 mMouseLeftPressed = true;
169 }
170
172 {
173 // сбрасываем всегда
174 mMouseLeftPressed = false;
175 }
176
178 {
179 if (_id != MouseButton::Left)
180 return;
181
182 if (mClientText == nullptr)
183 return;
184
185 // в статике все недоступно
186 if (mModeStatic)
187 return;
188
189 // останавливаем курсор
191
192 // сбрасываем все таймеры
193 mCursorTimer = 0;
195
196 size_t old = mCursorPosition;
197 IntPoint point(_left, _top);
199
200 if (old != mCursorPosition)
201 {
203
204 if (mStartSelect == ITEM_NONE)
206
210 else
212
214 }
215 }
216
218 {
219 if (mClientText == nullptr)
220 return;
221
222 // в статике все недоступно
223 if (mModeStatic)
224 return;
225
226 const IntPoint& lastPressed = InputManager::getInstance().getLastPressedPosition(MouseButton::Left);
227
231
233 UString::utf32string::reverse_iterator iterBack = text.rend() - cursorPosition;
234 UString::utf32string::iterator iterForw = text.begin() + cursorPosition;
235
236 while (iterBack != text.rend())
237 {
238 if (((*iterBack) < 256) && (ispunct(*iterBack) || isspace(*iterBack)))
239 break;
240 ++iterBack;
241 mStartSelect--;
242 }
243 while (iterForw != text.end())
244 {
245 if (((*iterForw) < 256) && (ispunct(*iterForw) || isspace(*iterForw)))
246 break;
247 ++iterForw;
248 mEndSelect++;
249 }
250
253 }
254
256 {
257 notifyMouseDrag(nullptr, _left, _top, _id);
258
260 }
261
263 {
264 if (!mIsPressed)
265 {
266 mIsPressed = true;
267 updateEditState();
268
269 if (!mModeStatic)
270 {
271 if (mClientText != nullptr)
272 {
273 mCursorActive = true;
274 Gui::getInstance().eventFrameStart += newDelegate(this, &EditBox::frameEntered);
277 mCursorTimer = 0;
278 }
279 }
280 }
281
283 }
284
286 {
287 if (mIsPressed)
288 {
289 mIsPressed = false;
290 updateEditState();
291
292 if (mClientText != nullptr)
293 {
294 mCursorActive = false;
295 Gui::getInstance().eventFrameStart -= newDelegate(this, &EditBox::frameEntered);
298 }
299 }
300
302 }
303
304 static bool isWhitespace(const UString::code_point& c) {
305 return c == ' ' || c == '\t';
306 }
307
309#if MYGUI_PLATFORM == MYGUI_PLATFORM_LINUX || MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
310 switch (key.getValue()) {
313 case KeyCode::Delete: return input.isShiftPressed() ? EditCommand::Cut : EditCommand::EraseNext;
314 case KeyCode::Insert: return input.isShiftPressed() ? EditCommand::Paste : (input.isControlPressed() ? EditCommand::Copy : EditCommand::Unknown);
315 case KeyCode::Return:
322 case KeyCode::End: return input.isControlPressed() ? EditCommand::MoveTextEnd : EditCommand::MoveLineEnd;
325 }
326 if (input.isControlPressed()) {
327 switch (key.getValue()) {
328 case KeyCode::C: return EditCommand::Copy;
329 case KeyCode::V: return EditCommand::Paste;
330 case KeyCode::X: return EditCommand::Cut;
331 case KeyCode::Z: return EditCommand::Undo;
332 case KeyCode::Y: return EditCommand::Redo;
334 }
335 }
336#elif MYGUI_PLATFORM == MYGUI_PLATFORM_APPLE
337 switch (key.getValue()) {
341 case KeyCode::Return:
343 case KeyCode::ArrowLeft: {
344 if (input.isAltPressed()) return EditCommand::MoveLeftWord;
345 if (input.isMetaPressed() || input.isControlPressed()) return EditCommand::MoveLineBeginning;
347 }
348 case KeyCode::ArrowRight: {
349 if (input.isAltPressed()) return EditCommand::MoveRightWord;
350 if (input.isMetaPressed() || input.isControlPressed()) return EditCommand::MoveLineEnd;
352 }
359 }
360 if (input.isMetaPressed()) {
361 switch (key.getValue()) {
362 case KeyCode::C: return EditCommand::Copy;
363 case KeyCode::V: return EditCommand::Paste;
364 case KeyCode::X: return EditCommand::Cut;
365 case KeyCode::Z: return input.isShiftPressed() ? EditCommand::Redo : EditCommand::Undo;
367 }
368 }
369#endif
371 }
372
374 {
375 if (mClientText == nullptr || getClientWidget() == nullptr)
376 {
378 return;
379 }
380
381 // в статическом режиме ничего не доступно
382 if (mModeStatic)
383 {
385 return;
386 }
387
389
391 mCursorTimer = 0.0f;
392
394
396 {
397 InputManager::getInstance().setKeyFocusWidget(nullptr);
398 }
400 {
401 // если нуно то удаляем выделенный текст
402 if (!mModeReadOnly)
403 {
404 // сбрасываем повтор
405 commandResetRedo();
406
407 if (!deleteTextSelect(true))
408 {
409 // прыгаем на одну назад и удаляем
410 if (mCursorPosition != 0)
411 {
413 eraseText(mCursorPosition, 1, true);
414 }
415 }
416 // отсылаем событие о изменении
418 }
419
420 }
421 else if (editCmd == EditCommand::Cut)
422 {
423 // сбрасываем повтор
424 commandResetRedo();
425
426 commandCut();
427 }
429 {
430 if (!mModeReadOnly)
431 {
432 // сбрасываем повтор
433 commandResetRedo();
434
435 // если нуно то удаляем выделенный текст
436 if (!deleteTextSelect(true))
437 {
439 {
440 eraseText(mCursorPosition, 1, true);
441 }
442 }
443 // отсылаем событие о изменении
445 }
446
447 }
448 else if (editCmd == EditCommand::Paste)
449 {
450 // сбрасываем повтор
451 commandResetRedo();
452
453 commandPast();
454 }
455 else if (editCmd == EditCommand::Copy)
456 {
457 commandCopy();
458 }
459 else if (editCmd == EditCommand::Cut)
460 {
461 commandResetRedo();
462
463 commandCut();
464 }
465 else if (editCmd == EditCommand::Undo)
466 {
467 commandUndo();
468 }
469 else if (editCmd == EditCommand::Redo)
470 {
471 commandRedo();
472 }
474 {
476 }
477 else if (editCmd == EditCommand::NewLine)
478 {
479 // работаем только в режиме редактирования
480 if (!mModeReadOnly)
481 {
482 if (mModeMultiline)
483 {
484 // сбрасываем повтор
485 commandResetRedo();
486
487 // попытка объединения двух комманд
488 size_t size = mVectorUndoChangeInfo.size();
489 // непосредственно операции
490 deleteTextSelect(true);
492 // проверяем на возможность объединения
493 if ((size + 2) == mVectorUndoChangeInfo.size())
494 commandMerge();
495 // отсылаем событие о изменении
497 }
498 // при сингл лайн и и мульти+сонтрол шлем эвент
499 else
500 {
502 }
503 }
504
505 }
507 {
509 }
511 {
513 {
515 {
516 if (mModePassword)
517 {
519 }
520 else
521 {
522 const UString& text = getRealString();
524 {
526 }
528 {
530 }
531 }
532 }
533 else
534 {
536 }
538 updateSelectText();
539 }
540 // сбрасываем выделение
541 else if (isTextSelection() && !input.isShiftPressed())
542 {
543 resetSelect();
544 }
545
546 }
548 {
549 if (mCursorPosition != 0)
550 {
552 {
553 if (mModePassword)
554 {
555 mCursorPosition = 0;
556 }
557 else
558 {
559 const UString& text = getRealString();
560 while (mCursorPosition > 0 && isWhitespace(text[mCursorPosition - 1]))
561 {
563 }
564 while (mCursorPosition > 0 && !isWhitespace(text[mCursorPosition - 1]))
565 {
567 }
568 }
569 }
570 else
571 {
573 }
575 updateSelectText();
576 }
577 // сбрасываем выделение
578 else if (isTextSelection() && !input.isShiftPressed())
579 {
580 resetSelect();
581 }
582
583 }
584 else if (editCmd == EditCommand::MoveUp)
585 {
587 point.top -= mClientText->getFontHeight();
588 size_t old = mCursorPosition;
590 // самая верхняя строчка
591 if (old == mCursorPosition)
592 {
593 if (mCursorPosition != 0)
594 {
595 mCursorPosition = 0;
597 updateSelectText();
598 }
599 // сбрасываем выделение
600 else if (isTextSelection() && !input.isShiftPressed())
601 {
602 resetSelect();
603 }
604 }
605 else
606 {
608 updateSelectText();
609 }
610
611 }
612 else if (editCmd == EditCommand::MoveDown)
613 {
615 point.top += mClientText->getFontHeight();
616 size_t old = mCursorPosition;
618 // самая нижняя строчка
619 if (old == mCursorPosition)
620 {
622 {
625 updateSelectText();
626 }
627 // сбрасываем выделение
628 else if (isTextSelection() && !input.isShiftPressed())
629 {
630 resetSelect();
631 }
632 }
633 else
634 {
636 updateSelectText();
637 }
638
639 }
641 {
644 size_t old = mCursorPosition;
646 if (old != mCursorPosition)
647 {
649 updateSelectText();
650 }
651 else if (isTextSelection() && !input.isShiftPressed())
652 {
653 resetSelect();
654 }
655 }
657 {
658 if (0 != mCursorPosition)
659 {
660 mCursorPosition = 0;
662 updateSelectText();
663 }
664 else if (isTextSelection() && !input.isShiftPressed())
665 {
666 resetSelect();
667 }
668 }
670 {
673 size_t old = mCursorPosition;
675 if (old != mCursorPosition)
676 {
678 updateSelectText();
679 }
680 else if (isTextSelection() && !input.isShiftPressed())
681 {
682 resetSelect();
683 }
684 }
686 {
688 {
691 updateSelectText();
692 }
693 else if (isTextSelection() && !input.isShiftPressed())
694 {
695 resetSelect();
696 }
697 }
699 {
700 // на размер окна, но не меньше одной строки
703 size_t old = mCursorPosition;
705 // самая верхняя строчка
706 if (old == mCursorPosition)
707 {
708 if (mCursorPosition != 0)
709 {
710 mCursorPosition = 0;
712 updateSelectText();
713 }
714 // сбрасываем выделение
715 else if (isTextSelection() && !input.isShiftPressed())
716 {
717 resetSelect();
718 }
719 }
720 else
721 {
723 updateSelectText();
724 }
725 }
727 {
728 // на размер окна, но не меньше одной строки
731 size_t old = mCursorPosition;
733 // самая нижняя строчка
734 if (old == mCursorPosition)
735 {
737 {
740 updateSelectText();
741 }
742 // сбрасываем выделение
743 else if (isTextSelection() && !input.isShiftPressed())
744 {
745 resetSelect();
746 }
747 }
748 else
749 {
751 updateSelectText();
752 }
753 }
754 else if ((_key == KeyCode::LeftShift) || (_key == KeyCode::RightShift))
755 {
756 // для правильно выделения
757 if (mStartSelect == ITEM_NONE)
758 {
760 }
761 }
762 else {
763 // если не нажат контрл, то обрабатываем как текст
764 if (!mModeReadOnly && _char != 0)
765 {
766 // сбрасываем повтор
767 commandResetRedo();
768
769 // таб только если нужно
770 if (_char != '\t' || mTabPrinting)
771 {
772 // попытка объединения двух комманд
773 size_t size = mVectorUndoChangeInfo.size();
774 // непосредственно операции
775 deleteTextSelect(true);
777 // проверяем на возможность объединения
778 if ((size + 2) == mVectorUndoChangeInfo.size())
779 commandMerge();
780 // отсылаем событие о изменении
782 }
783 }
784 }
785
787 }
788
789 void EditBox::frameEntered(float _frame)
790 {
791 if (mClientText == nullptr)
792 return;
793
794 // в статике все недоступно
795 if (mModeStatic)
796 return;
797
798 if (mCursorActive)
799 {
801
803 {
807 }
808 }
809
810 // сдвигаем курсор по положению мыши
812 {
813 mActionMouseTimer += _frame;
814
816 {
817 IntPoint mouse = InputManager::getInstance().getMousePositionByLayer();
818 const IntRect& view = getClientWidget()->getAbsoluteRect();
819 mouse.left -= view.left;
820 mouse.top -= view.top;
821 IntPoint point;
822
823 bool action = false;
824
825 // вверх на одну строчку
826 if ((mouse.top < 0) && (mouse.top > -EDIT_ACTION_MOUSE_ZONE))
827 {
828 if ((mouse.left > 0) && (mouse.left <= getClientWidget()->getWidth()))
829 {
831 point.top -= mClientText->getFontHeight();
832 action = true;
833 }
834 }
835 // вниз на одну строчку
836 else if ((mouse.top > getClientWidget()->getHeight()) && (mouse.top < (getClientWidget()->getHeight() + EDIT_ACTION_MOUSE_ZONE)))
837 {
838 if ((mouse.left > 0) && (mouse.left <= getClientWidget()->getWidth()))
839 {
841 point.top += mClientText->getFontHeight();
842 action = true;
843 }
844 }
845
846 // влево на небольшое расстояние
847 if ((mouse.left < 0) && (mouse.left > -EDIT_ACTION_MOUSE_ZONE))
848 {
850 point.left -= (int)EDIT_OFFSET_HORZ_CURSOR;
851 action = true;
852 }
853 // вправо на небольшое расстояние
854 else if ((mouse.left > getClientWidget()->getWidth()) && (mouse.left < (getClientWidget()->getWidth() + EDIT_ACTION_MOUSE_ZONE)))
855 {
857 point.left += (int)EDIT_OFFSET_HORZ_CURSOR;
858 action = true;
859 }
860
861 if (action)
862 {
863 size_t old = mCursorPosition;
865
866 if (old != mCursorPosition)
867 {
869
870 if (mStartSelect == ITEM_NONE)
871 mStartSelect = old;
872
873 mEndSelect = (size_t)mCursorPosition;
876 else
878
879 // пытаемся показать курсор
881 }
882 }
883 // если в зону не попадает то сбрасываем
884 else
885 {
887 }
888
891 }
892
893 } // if (mMouseLeftPressed)
894 }
895
897 {
898 // сбрасываем выделение
899 resetSelect();
900
901 // новая позиция
902 if (_index > mTextLength)
904
905 if (mCursorPosition == _index)
906 return;
907
909
910 // обновляем по позиции
911 if (mClientText != nullptr)
913
914 updateSelectText();
915 }
916
918 {
919 if (_start > mTextLength)
921 if (_end > mTextLength)
923
926
927 if (mClientText != nullptr)
928 {
931 else
933 }
934
936 return;
937 // курсор на конец выделения
939
940 // обновляем по позиции
941 if (mClientText != nullptr)
943 }
944
946 {
947 if (!isTextSelection())
948 return false;
949
950 // начало и конец выделения
951 size_t start = getTextSelectionStart();
952 size_t end = getTextSelectionEnd();
953
954 eraseText(start, end - start, _history);
955
956 return true;
957 }
958
959 void EditBox::resetSelect()
960 {
961 if (mStartSelect != ITEM_NONE)
962 {
964 if (mClientText != nullptr)
966 }
967 }
968
969 void EditBox::commandPosition(size_t _undo, size_t _redo, size_t _length, VectorChangeInfo* _info)
970 {
971 if (_info != nullptr)
972 _info->push_back(TextCommandInfo(_undo, _redo, _length));
973 }
974
975 void EditBox::commandMerge()
976 {
977 if (mVectorUndoChangeInfo.size() < 2)
978 return; // на всякий
979 // сохраняем последние набор отмен
981 mVectorUndoChangeInfo.pop_back();
982
983 // объединяем последовательности
984 for (VectorChangeInfo::iterator iter = info.begin(); iter != info.end(); ++iter)
985 {
986 mVectorUndoChangeInfo.back().push_back((*iter));
987 }
988 }
989
990 bool EditBox::commandUndo()
991 {
992 if (mVectorUndoChangeInfo.empty())
993 return false;
994
995 resetSelect();
996
997 // save last undo info
999 // move undo info to redo
1000 mVectorUndoChangeInfo.pop_back();
1001 mVectorRedoChangeInfo.push_back(info);
1002
1003 UString::utf32string text = getRealString().asUTF32();
1004
1005 // apply undo
1006 for (VectorChangeInfo::const_reverse_iterator iter = info.rbegin(); iter != info.rend(); ++iter)
1007 {
1008 const auto& change = *iter;
1009 switch (change.type)
1010 {
1012 text.erase(change.start, change.text.size());
1013 break;
1015 text.insert(change.start, change.text);
1016 break;
1018 mCursorPosition = change.undo;
1019 mTextLength = change.length;
1020 break;
1021 }
1022 }
1023
1024 setRealString(UString(text));
1025
1026 // restore cursor position
1027 if (mClientText != nullptr)
1029 updateSelectText();
1030
1031 eventEditTextChange(this);
1032
1033 return true;
1034 }
1035
1036 bool EditBox::commandRedo()
1037 {
1038 if (mVectorRedoChangeInfo.empty())
1039 return false;
1040
1041 // сбрасываем выделение
1042 resetSelect();
1043
1044 // save last undo info
1046 // move redo info to undo
1047 mVectorRedoChangeInfo.pop_back();
1048 mVectorUndoChangeInfo.push_back(info);
1049
1050 UString::utf32string text = getRealString().asUTF32();
1051
1052 // apply redo
1053 for (const auto& change : info)
1054 {
1055 switch (change.type)
1056 {
1058 text.insert(change.start, change.text);
1059 break;
1061 text.erase(change.start, change.text.size());
1062 break;
1064 mCursorPosition = change.redo;
1065 mTextLength = change.length;
1066 break;
1067 }
1068
1069 }
1070
1071 setRealString(UString(text));
1072
1073 // restore cursor position
1074 if (mClientText != nullptr)
1076 updateSelectText();
1077
1078 eventEditTextChange(this);
1079
1080 return true;
1081 }
1082
1083 void EditBox::saveInHistory(VectorChangeInfo* _info)
1084 {
1085 if (_info == nullptr)
1086 return;
1087 // если нет информации об изменении
1088 if ( _info->empty())
1089 return;
1090 if ((_info->size() == 1) && (_info->back().type == TextCommandInfo::COMMAND_POSITION))
1091 return;
1092
1093 mVectorUndoChangeInfo.push_back(*_info);
1094 // проверяем на максимальный размер
1096 mVectorUndoChangeInfo.pop_front();
1097 }
1098
1099 // возвращает текст
1101 {
1102 // подстраховка
1104 // конец диапазона
1105 size_t end = _start + _count;
1106
1107 // итератор нашей строки
1108 TextIterator iterator(getRealString());
1109
1110 // дефолтный цвет
1112
1113 // нужно ли вставлять цвет
1114 bool need_colour = true;
1115
1116 // цикл прохода по строке
1117 while (iterator.moveNext())
1118 {
1119 // текущаяя позиция
1120 size_t pos = iterator.getPosition();
1121
1122 // еще рано
1123 if (pos < _start)
1124 {
1125 // берем цвет из позиции и запоминаем
1126 iterator.getTagColour(colour);
1127
1128 continue;
1129 }
1130
1131 // проверяем на надобность начального тега
1132 else if (pos == _start)
1133 {
1134 need_colour = ! iterator.getTagColour(colour);
1135 // сохраняем место откуда начинается
1136 iterator.saveStartPoint();
1137
1138 }
1139
1140 // а теперь просто до конца диапазона
1141 else if (pos == end)
1142 break;
1143
1144 }
1145
1146 // возвращаем строку
1147 if (need_colour)
1148 return colour + iterator.getFromStart();
1149 return iterator.getFromStart();
1150 }
1151
1152 // выделяет цветом диапазон
1153 void EditBox::_setTextColour(size_t _start, size_t _count, const Colour& _colour, bool _history)
1154 {
1155 // история изменений
1156 VectorChangeInfo* history = nullptr;
1157 if (_history)
1158 history = new VectorChangeInfo();
1159
1160 // конец диапазона
1161 size_t end = _start + _count;
1162
1163 // итератор нашей строки
1164 TextIterator iterator(getRealString(), history);
1165
1166 // дефолтный цвет
1168
1169 // цикл прохода по строке
1170 while (iterator.moveNext())
1171 {
1172 // текущаяя позиция
1173 size_t pos = iterator.getPosition();
1174
1175 // берем цвет из позиции и запоминаем
1176 iterator.getTagColour(colour);
1177
1178 // еще рано
1179 if (pos < _start)
1180 continue;
1181
1182 // ставим начальный тег
1183 else if (pos == _start)
1184 iterator.setTagColour(_colour);
1185
1186 // внутри диапазона очищаем все
1187 else if (pos < end)
1188 iterator.clearTagColour();
1189
1190 // на конец ставим последний найденный или дефолтный
1191 else if (pos == end)
1192 {
1193 iterator.setTagColour(colour);
1194 // и выходим из цикла
1195 break;
1196 }
1197
1198 }
1199
1200 // сохраняем позицию для восстановления курсора
1201 commandPosition(_start, _start + _count, mTextLength, history);
1202
1203 // запоминаем в историю
1204 if (_history)
1205 {
1206 saveInHistory(history);
1207 delete history;
1208 }
1209 // сбрасываем историю
1210 else
1211 commandResetHistory();
1212
1213 // и возвращаем строку на место
1214 setRealString(iterator.getText());
1215 }
1216
1217 void EditBox::setTextSelectColour(const Colour& _colour, bool _history)
1218 {
1219 // нужно выделение
1220 if ( !isTextSelection())
1221 return;
1222 // начало и конец выделения
1223 size_t start = getTextSelectionStart();
1224 size_t end = getTextSelectionEnd();
1225 _setTextColour(start, end - start, _colour, _history);
1226 }
1227
1229 {
1230 if ( !isTextSelection())
1231 return "";
1232 size_t start = getTextSelectionStart();
1233 size_t end = getTextSelectionEnd();
1234 return getTextInterval(start, end - start);
1235 }
1236
1238 {
1239 if (mModePassword == _password)
1240 return;
1242
1243 if (mModePassword)
1244 {
1245 if (mClientText != nullptr)
1246 {
1249 }
1250 }
1251 else
1252 {
1253 if (mClientText != nullptr)
1254 {
1257 }
1258 }
1259 // обновляем по размерам
1260 updateView();
1261 // сбрасываем историю
1262 commandResetHistory();
1263 }
1264
1265 void EditBox::setText(const UString& _caption, bool _history)
1266 {
1267 // сбрасываем выделение
1268 resetSelect();
1269
1270 // история изменений
1271 VectorChangeInfo* history = nullptr;
1272 if (_history)
1273 history = new VectorChangeInfo();
1274
1275 // итератор нашей строки
1276 TextIterator iterator(getRealString(), history);
1277
1278 // вставляем текст
1279 iterator.setText(_caption, mModeMultiline || mModeWordWrap);
1280
1282 {
1283 iterator.cutMaxLengthFromBeginning(mMaxTextLength);
1284 }
1285 else
1286 {
1287 // обрезаем по максимальной длинне
1288 iterator.cutMaxLength(mMaxTextLength);
1289 }
1290
1291 // запоминаем размер строки
1292 size_t old = mTextLength;
1293 // новая позиция и положение на конец вставки
1294 mCursorPosition = mTextLength = iterator.getSize();
1295
1296 // сохраняем позицию для восстановления курсора
1297 commandPosition(0, mTextLength, old, history);
1298
1299 // запоминаем в историю
1300 if (_history)
1301 {
1302 saveInHistory(history);
1303 delete history;
1304 }
1305 // сбрасываем историю
1306 else
1307 commandResetHistory();
1308
1309 // и возвращаем строку на место
1310 setRealString(iterator.getText());
1311
1312 // обновляем по позиции
1313 if (mClientText != nullptr)
1315 updateSelectText();
1316 }
1317
1318 void EditBox::insertText(const UString& _text, size_t _start, bool _history)
1319 {
1320 // сбрасываем выделение
1321 resetSelect();
1322
1323 // если строка пустая, или размер максимален
1324 if (_text.empty())
1325 return;
1326
1327 if ((mOverflowToTheLeft == false) && (mTextLength == mMaxTextLength))
1328 return;
1329
1330 // история изменений
1331 VectorChangeInfo* history = nullptr;
1332 if (_history)
1333 history = new VectorChangeInfo();
1334
1335 // итератор нашей строки
1336 TextIterator iterator(getRealString(), history);
1337
1338 // дефолтный цвет
1339 UString colour = mClientText == nullptr ? "" : TextIterator::convertTagColour(mClientText->getTextColour());
1340 // нужен ли тег текста
1341 // потом переделать через TextIterator чтобы отвязать понятие тег от эдита
1342 bool need_colour = ( (_text.size() > 6) && (_text[0] == L'#') && (_text[1] != L'#') );
1343
1344 // цикл прохода по строке
1345 while (iterator.moveNext())
1346 {
1347 // текущаяя позиция
1348 size_t pos = iterator.getPosition();
1349
1350 // текущий цвет
1351 if (need_colour)
1352 iterator.getTagColour(colour);
1353
1354 // если дошли то выходим
1355 if (pos == _start)
1356 break;
1357 }
1358
1359 // если нужен цвет то вставляем
1360 if (need_colour)
1361 iterator.setTagColour(colour);
1362
1363 // а теперь вставляем строку
1364 iterator.insertText(_text, mModeMultiline || mModeWordWrap);
1365
1367 {
1368 iterator.cutMaxLengthFromBeginning(mMaxTextLength);
1369 }
1370 else
1371 {
1372 // обрезаем по максимальной длинне
1373 iterator.cutMaxLength(mMaxTextLength);
1374 }
1375
1376 // запоминаем размер строки
1377 size_t old = mTextLength;
1378 // новая позиция и положение на конец вставки
1379 mTextLength = iterator.getSize();
1381
1382 // сохраняем позицию для восстановления курсора
1383 commandPosition(_start, _start + mTextLength - old, old, history);
1384
1385 // запоминаем в историю
1386 if (_history)
1387 {
1388 saveInHistory(history);
1389 delete history;
1390 }
1391 // сбрасываем историю
1392 else
1393 commandResetHistory();
1394
1395 // и возвращаем строку на место
1396 setRealString(iterator.getText());
1397
1398 // обновляем по позиции
1399 if (mClientText != nullptr)
1401 updateSelectText();
1402 }
1403
1404 void EditBox::eraseText(size_t _start, size_t _count, bool _history)
1405 {
1406 // чета маловато
1407 if (_count == 0)
1408 return;
1409
1410 // сбрасываем выделение
1411 resetSelect();
1412
1413 // история изменений
1414 VectorChangeInfo* history = nullptr;
1415 if (_history)
1416 history = new VectorChangeInfo();
1417
1418 // итератор нашей строки
1419 TextIterator iterator(getRealString(), history);
1420
1421 // дефолтный цвет
1422 UString colour;
1423 // конец диапазона
1424 size_t end = _start + _count;
1425 bool need_colour = false;
1426
1427 // цикл прохода по строке
1428 while (iterator.moveNext())
1429 {
1430 // текущаяя позиция
1431 size_t pos = iterator.getPosition();
1432
1433 // еще рано
1434 if (pos < _start)
1435 {
1436 // берем цвет из позиции и запоминаем
1437 iterator.getTagColour(colour);
1438 continue;
1439 }
1440
1441 // сохраняем место откуда начинается
1442 else if (pos == _start)
1443 {
1444 // если до диапазона был цвет, то нужно закрыть тег
1445 if (!colour.empty())
1446 {
1447 need_colour = true;
1448 colour.clear();
1449 }
1450 // берем цвет из позиции и запоминаем
1451 iterator.getTagColour(colour);
1452 iterator.saveStartPoint();
1453 }
1454
1455 // внутри диапазона
1456 else if (pos < end)
1457 {
1458 // берем цвет из позиции и запоминаем
1459 iterator.getTagColour(colour);
1460 }
1461
1462 // окончание диапазона
1463 else if (pos == end)
1464 {
1465 // нужно ставить тег или нет
1466 if (!colour.empty())
1467 need_colour = true;
1468 if (iterator.getTagColour(colour))
1469 need_colour = false;
1470
1471 break;
1472 }
1473
1474 }
1475
1476 // удаляем диапазон
1477 iterator.eraseFromStart();
1478 // и вставляем последний цвет
1479 if (need_colour)
1480 iterator.setTagColour(colour);
1481
1482 // сохраняем позицию для восстановления курсора
1483 commandPosition(_start + _count, _start, mTextLength, history);
1484
1485 // на месте удаленного
1486 mCursorPosition = _start;
1487 mTextLength -= _count;
1488
1489 // запоминаем в историю
1490 if (_history)
1491 {
1492 saveInHistory(history);
1493 delete history;
1494 }
1495 // сбрасываем историю
1496 else
1497 commandResetHistory();
1498
1499 // и возвращаем строку на место
1500 setRealString(iterator.getText());
1501
1502 // обновляем по позиции
1503 if (mClientText != nullptr)
1505 updateSelectText();
1506 }
1507
1508 void EditBox::commandCut()
1509 {
1510 // вырезаем в буфер обмена
1511 if (isTextSelection() && (!mModePassword))
1512 {
1514 if (!mModeReadOnly)
1515 {
1516 deleteTextSelect(true);
1517 // отсылаем событие о изменении
1518 eventEditTextChange(this);
1519 }
1520 }
1521 else
1523 }
1524
1525 void EditBox::commandCopy()
1526 {
1527 // копируем в буфер обмена
1528 if (isTextSelection() && (!mModePassword))
1530 else
1532 }
1533
1534 void EditBox::commandPast()
1535 {
1536 // копируем из буфера обмена
1537 std::string clipboard = ClipboardManager::getInstance().getClipboardData(EDIT_CLIPBOARD_TYPE_TEXT);
1538 if ((!mModeReadOnly) && (!clipboard.empty()))
1539 {
1540 // попытка объединения двух комманд
1541 size_t size = mVectorUndoChangeInfo.size();
1542 // непосредственно операции
1543 deleteTextSelect(true);
1544 insertText(clipboard, mCursorPosition, true);
1545 // проверяем на возможность объединения
1546 if ((size + 2) == mVectorUndoChangeInfo.size())
1547 commandMerge();
1548 // отсылаем событие о изменении
1549 eventEditTextChange(this);
1550 }
1551 }
1552
1553 const UString& EditBox::getRealString() const
1554 {
1555 if (mModePassword)
1556 return mPasswordText;
1557 else if (mClientText == nullptr)
1558 return mPasswordText;
1559
1560 return mClientText->getCaption();
1561 }
1562
1563 void EditBox::setRealString(const UString& _caption)
1564 {
1565 if (mModePassword)
1566 {
1567 mPasswordText = _caption;
1568 if (mClientText != nullptr)
1570 }
1571 else
1572 {
1573 if (mClientText != nullptr)
1574 mClientText->setCaption(_caption);
1575 }
1576 }
1577
1579 {
1581 if (mModePassword)
1582 {
1583 if (mClientText != nullptr)
1585 }
1586 }
1587
1588 void EditBox::updateEditState()
1589 {
1590 if (!getInheritedEnabled())
1591 {
1592 _setWidgetState("disabled");
1593 }
1594 else if (mIsPressed)
1595 {
1596 if (mIsFocus)
1597 _setWidgetState("pushed");
1598 else
1599 _setWidgetState("normal_checked");
1600 }
1601 else if (mIsFocus)
1602 {
1603 _setWidgetState("highlighted");
1604 }
1605 else
1606 {
1607 _setWidgetState("normal");
1608 }
1609 }
1610
1612 {
1614 }
1615
1617 {
1618 // если перенос, то сбрасываем размер текста
1619 if (mModeWordWrap)
1620 {
1621 if (mClientText != nullptr)
1622 mClientText->setWordWrap(true);
1623 }
1624
1625 updateView();
1626 }
1627
1629 {
1631
1632 eraseView();
1633 }
1634
1636 {
1638
1639 eraseView();
1640 }
1641
1643 {
1644 setText(_value, false);
1645 }
1646
1648 {
1649 return getRealString();
1650 }
1651
1652 void EditBox::updateSelectText()
1653 {
1654 if (!mModeStatic)
1655 {
1657 if ((input.isShiftPressed()) && (mStartSelect != ITEM_NONE))
1658 {
1659 // меняем выделение
1661 if (mClientText != nullptr)
1662 {
1665 else
1667 }
1668
1669 }
1670 else if (mStartSelect != ITEM_NONE)
1671 {
1672 // сбрасываем шифт
1674 if (mClientText != nullptr)
1676 }
1677 }
1678
1679 // пытаемся показать курсор
1681 }
1682
1684 {
1686
1687 if (mClientText != nullptr)
1689
1690 // так как мы сами рулим смещениями
1691 updateView();
1692 }
1693
1695 {
1697
1698 if (mClientText != nullptr)
1700 }
1701
1703 {
1704 if (mClientText != nullptr)
1705 return mClientText->getCoord();
1706 return Base::getTextRegion();
1707 }
1708
1710 {
1711 if (mClientText != nullptr)
1712 return mClientText->getTextSize();
1713 return Base::getTextSize();
1714 }
1715
1717 {
1718 if (mClientText == nullptr)
1719 return;
1720
1721 if (_sender == mVScroll)
1722 {
1724 point.top = _position;
1725 mClientText->setViewOffset(point);
1726 }
1727 else if (_sender == mHScroll)
1728 {
1730 point.left = _position;
1731 mClientText->setViewOffset(point);
1732 }
1733 }
1734
1736 {
1737 if (mClientText == nullptr)
1738 return;
1739
1740 if (mVRange != 0)
1741 {
1743 int offset = point.top;
1744 if (_rel < 0)
1745 offset += EDIT_MOUSE_WHEEL;
1746 else
1747 offset -= EDIT_MOUSE_WHEEL;
1748
1749 if (offset < 0)
1750 offset = 0;
1751 else if (offset > (int)mVRange)
1752 offset = mVRange;
1753
1754 if (offset != point.top)
1755 {
1756 point.top = offset;
1757 if (mVScroll != nullptr)
1758 mVScroll->setScrollPosition(offset);
1759 mClientText->setViewOffset(point);
1760 }
1761 }
1762 else if (mHRange != 0)
1763 {
1765 int offset = point.left;
1766 if (_rel < 0)
1767 offset += EDIT_MOUSE_WHEEL;
1768 else
1769 offset -= EDIT_MOUSE_WHEEL;
1770
1771 if (offset < 0)
1772 offset = 0;
1773 else if (offset > (int)mHRange)
1774 offset = mHRange;
1775
1776 if (offset != point.left)
1777 {
1778 point.left = offset;
1779 if (mHScroll != nullptr)
1780 mHScroll->setScrollPosition(offset);
1781 mClientText->setViewOffset(point);
1782 }
1783 }
1784 }
1785
1787 {
1789 if (mClientText != nullptr)
1791
1792 eraseView();
1793 }
1794
1795 void EditBox::setFontName(const std::string& _value)
1796 {
1798
1799 if (mClientText != nullptr)
1801
1802 eraseView();
1803 }
1804
1806 {
1808
1809 if (mClientText != nullptr)
1811
1812 eraseView();
1813 }
1814
1816 {
1817 return (nullptr == mClientText) ? 0 : mClientText->getFontHeight();
1818 }
1819
1821 {
1824 }
1825
1827 {
1829 updateCursorPosition();
1831 }
1832
1833 void EditBox::updateCursorPosition()
1834 {
1835 if (mClientText == nullptr || getClientWidget() == nullptr)
1836 return;
1837
1838 // размер контекста текста
1840
1841 // текущее смещение контекста текста
1843 // расчетное смещение
1844 IntPoint offset = point;
1845
1846 // абсолютные координаты курсора
1848 cursor.right ++;
1849
1850 // абсолютные координаты вью
1852
1853 // проверяем и показываем курсор
1854 if (!view.inside(cursor))
1855 {
1856 // горизонтальное смещение
1857 if (textSize.width > view.width())
1858 {
1859 if (cursor.left < view.left)
1860 {
1861 offset.left = point.left - (view.left - cursor.left);
1862 // добавляем смещение, только если курсор не перепрыгнет
1863 if ((float(view.width()) - EDIT_OFFSET_HORZ_CURSOR) > EDIT_OFFSET_HORZ_CURSOR)
1864 offset.left -= int(EDIT_OFFSET_HORZ_CURSOR);
1865 }
1866 else if (cursor.right > view.right)
1867 {
1868 offset.left = point.left + (cursor.right - view.right);
1869 // добавляем смещение, только если курсор не перепрыгнет
1871 offset.left += int(EDIT_OFFSET_HORZ_CURSOR);
1872 }
1873 }
1874
1875 // вертикальное смещение
1876 if (textSize.height > view.height())
1877 {
1878 int delta = 0;
1879 if (cursor.height() > view.height())
1880 {
1881 // if text is bigger than edit height then place it in center
1882 delta = ((cursor.bottom - view.bottom) - (view.top - cursor.top)) / 2;
1883 }
1884 else if (cursor.top < view.top)
1885 {
1886 delta = - (view.top - cursor.top);
1887 }
1888 else if (cursor.bottom > view.bottom)
1889 {
1890 delta = (cursor.bottom - view.bottom);
1891 }
1892 offset.top = point.top + delta;
1893 }
1894
1895 }
1896
1897 if (offset != point)
1898 {
1899 mClientText->setViewOffset(offset);
1900 // обновить скролы
1901 if (mVScroll != nullptr)
1903 if (mHScroll != nullptr)
1905 }
1906 }
1907
1908 void EditBox::setContentPosition(const IntPoint& _point)
1909 {
1910 if (mClientText != nullptr)
1911 mClientText->setViewOffset(_point);
1912 }
1913
1914 IntSize EditBox::getViewSize() const
1915 {
1916 if (mClientText != nullptr)
1917 return mClientText->getSize();
1919 }
1920
1921 IntSize EditBox::getContentSize() const
1922 {
1923 if (mClientText != nullptr)
1924 return mClientText->getTextSize();
1926 }
1927
1928 size_t EditBox::getVScrollPage() const
1929 {
1930 if (mClientText != nullptr)
1931 return (size_t)mClientText->getFontHeight();
1933 }
1934
1935 size_t EditBox::getHScrollPage() const
1936 {
1937 if (mClientText != nullptr)
1938 return (size_t)mClientText->getFontHeight();
1940 }
1941
1942 IntPoint EditBox::getContentPosition() const
1943 {
1944 if (mClientText != nullptr)
1945 return mClientText->getViewOffset();
1947 }
1948
1949 Align EditBox::getContentAlign() const
1950 {
1951 if (mClientText != nullptr)
1952 return mClientText->getTextAlign();
1954 }
1955
1957 {
1958 _setTextColour(_start, _count, _colour, false);
1959 }
1960
1962 {
1964 }
1965
1967 {
1969 }
1970
1972 {
1973 return (mStartSelect != ITEM_NONE) && (mStartSelect != mEndSelect);
1974 }
1975
1977 {
1978 deleteTextSelect(false);
1979 }
1980
1982 {
1983 setTextSelectColour(_colour, false);
1984 }
1985
1987 {
1988 return mEndSelect - mStartSelect;
1989 }
1990
1992 {
1993 setText(TextIterator::toTagsString(_text), false);
1994 }
1995
1997 {
1998 return TextIterator::getOnlyText(getRealString());
1999 }
2000
2002 {
2003 insertText(_text, _index, false);
2004 }
2005
2007 {
2008 insertText(_text, ITEM_NONE, false);
2009 }
2010
2011 void EditBox::eraseText(size_t _start, size_t _count)
2012 {
2013 eraseText(_start, _count, false);
2014 }
2015
2017 {
2019 // сбрасываем историю
2020 commandResetHistory();
2021 }
2022
2024 {
2026 // на всякий, для убирания переносов
2027 if (!mModeMultiline)
2028 {
2029 setText(getRealString(), false);
2030 }
2031 // обновляем по размерам
2032 else
2033 {
2034 updateView();
2035 }
2036 // сбрасываем историю
2037 commandResetHistory();
2038 }
2039
2041 {
2043 resetSelect();
2044
2045 if (getClientWidget() != nullptr)
2046 {
2047 if (mModeStatic)
2049 else
2051 }
2052 }
2053
2055 {
2056 if (!_value.empty())
2058 }
2059
2061 {
2063 updateView();
2064 }
2065
2067 {
2069 updateView();
2070 }
2071
2073 {
2074 return mVRange + 1;
2075 }
2076
2078 {
2079 return mClientText == nullptr ? 0 : mClientText->getViewOffset().top;
2080 }
2081
2083 {
2084 if (mClientText == nullptr)
2085 return;
2086
2087 if (_index > mVRange)
2088 _index = mVRange;
2089
2091 point.top = _index;
2092
2093 mClientText->setViewOffset(point);
2094 // обновить скролы
2095 if (mVScroll != nullptr)
2097 }
2098
2100 {
2101 return mHRange + 1;
2102 }
2103
2105 {
2106 return mClientText == nullptr ? 0 : mClientText->getViewOffset().left;
2107 }
2108
2110 {
2111 if (mClientText == nullptr)
2112 return;
2113
2114 if (_index > mHRange)
2115 _index = mHRange;
2116
2118 point.left = _index;
2119
2120 mClientText->setViewOffset(point);
2121 // обновить скролы
2122 if (mHScroll != nullptr)
2124 }
2125
2127 {
2128 return mClientText == nullptr ? false : mClientText->getInvertSelected();
2129 }
2130
2132 {
2133 if (mClientText != nullptr)
2135 }
2136
2137 void EditBox::setPropertyOverride(const std::string& _key, const std::string& _value)
2138 {
2140 if (_key == "CursorPosition")
2141 setTextCursor(utility::parseValue<size_t>(_value));
2142
2144 else if (_key == "TextSelect")
2146
2148 else if (_key == "ReadOnly")
2149 setEditReadOnly(utility::parseValue<bool>(_value));
2150
2152 else if (_key == "Password")
2153 setEditPassword(utility::parseValue<bool>(_value));
2154
2156 else if (_key == "MultiLine")
2157 setEditMultiLine(utility::parseValue<bool>(_value));
2158
2160 else if (_key == "PasswordChar")
2162
2164 else if (_key == "MaxTextLength")
2165 setMaxTextLength(utility::parseValue<size_t>(_value));
2166
2168 else if (_key == "OverflowToTheLeft")
2169 setOverflowToTheLeft(utility::parseValue<bool>(_value));
2170
2172 else if (_key == "Static")
2173 setEditStatic(utility::parseValue<bool>(_value));
2174
2176 else if (_key == "VisibleVScroll")
2177 setVisibleVScroll(utility::parseValue<bool>(_value));
2178
2180 else if (_key == "VisibleHScroll")
2181 setVisibleHScroll(utility::parseValue<bool>(_value));
2182
2184 else if (_key == "WordWrap")
2185 setEditWordWrap(utility::parseValue<bool>(_value));
2186
2188 else if (_key == "TabPrinting")
2189 setTabPrinting(utility::parseValue<bool>(_value));
2190
2192 else if (_key == "InvertSelected")
2193 setInvertSelected(utility::parseValue<bool>(_value));
2194
2195 else
2196 {
2198 return;
2199 }
2200
2202 }
2203
2205 {
2206 return mCursorPosition;
2207 }
2208
2210 {
2211 return mTextLength;
2212 }
2213
2215 {
2217 }
2218
2220 {
2221 return mOverflowToTheLeft;
2222 }
2223
2225 {
2227 }
2228
2230 {
2231 return mMaxTextLength;
2232 }
2233
2235 {
2236 return mModeReadOnly;
2237 }
2238
2240 {
2241 return mModePassword;
2242 }
2243
2245 {
2246 return mModeMultiline;
2247 }
2248
2250 {
2251 return mModeStatic;
2252 }
2253
2255 {
2256 return mCharPassword;
2257 }
2258
2260 {
2261 return mModeWordWrap;
2262 }
2263
2265 {
2267 }
2268
2270 {
2271 return mTabPrinting;
2272 }
2273
2275 {
2276 return mVisibleVScroll;
2277 }
2278
2280 {
2281 return mVisibleHScroll;
2282 }
2283
2284 void EditBox::commandResetRedo()
2285 {
2286 mVectorRedoChangeInfo.clear();
2287 }
2288
2289 void EditBox::commandResetHistory()
2290 {
2291 mVectorRedoChangeInfo.clear();
2292 mVectorUndoChangeInfo.clear();
2293 }
2294
2296 {
2298
2299 if (mClientText != nullptr)
2301 }
2302
2304 {
2306
2307 if (mClientText != nullptr)
2309 }
2310
2311} // namespace MyGUI
static ClipboardManager & getInstance()
DequeUndoRedoInfo mVectorUndoChangeInfo
void setFontHeight(int _value) override
void insertText(const UString &_text, size_t _index=ITEM_NONE)
void setCoord(const IntCoord &_value) override
size_t getTextLength() const
void setMaxTextLength(size_t _value)
Sets the max amount of text allowed in the edit field.
size_t getVScrollRange() const
size_t getVScrollPosition() const
IntCoord getTextRegion() const override
void setTextShadow(bool _value) override
void setPasswordChar(Char _value)
ISubWidgetText * mClientText
void notifyMouseSetFocus(Widget *_sender, Widget *_old)
const UString & getCaption() const override
bool isVisibleVScroll() const
void setOnlyText(const UString &_value)
int getFontHeight() const override
void setTextSelection(size_t _start, size_t _end)
bool getEditStatic() const
void eraseText(size_t _start, size_t _count=1)
void notifyMouseDrag(Widget *_sender, int _left, int _top, MouseButton _id)
void setEditStatic(bool _value)
UString mPasswordText
size_t getTextSelectionStart() const
void setEditMultiLine(bool _value)
void shutdownOverride() override
EventPair< EventHandle_WidgetVoid, EventHandle_EditPtr > eventEditTextChange
void notifyMouseReleased(Widget *_sender, int _left, int _top, MouseButton _id)
void setPosition(const IntPoint &_value) override
size_t getTextCursor() const
bool getEditPassword() const
void setTabPrinting(bool _value)
Char getPasswordChar() const
bool getEditMultiLine() const
void onMouseDrag(int _left, int _top, MouseButton _id) override
IntSize getTextSize() const override
void setFontName(const std::string &_value) override
bool isVisibleHScroll() const
void setEditWordWrap(bool _value)
DequeUndoRedoInfo mVectorRedoChangeInfo
size_t getHScrollRange() const
void setPropertyOverride(const std::string &_key, const std::string &_value) override
void onKeyButtonPressed(KeyCode _key, Char _char) override
void setTextColour(const Colour &_value) override
void setVisibleVScroll(bool _value)
void setHScrollPosition(size_t _index)
void setTextShadowColour(const Colour &_value) override
std::string mOriginalPointer
void notifyMouseLostFocus(Widget *_sender, Widget *_new)
void onKeyLostFocus(Widget *_new) override
void setCaption(const UString &_value) override
void notifyMouseButtonDoubleClick(Widget *_sender)
void setVisibleHScroll(bool _value)
void setTextSelectionColour(const Colour &_value)
bool getEditReadOnly() const
void notifyScrollChangePosition(ScrollBar *_sender, size_t _position)
void setEditPassword(bool _value)
size_t getTextSelectionLength() const
UString getTextInterval(size_t _start, size_t _count) const
UString getTextSelection() const
bool isTextSelection() const
void setOverflowToTheLeft(bool _value)
Sets if surplus characters should push characters off the left side rather than ignored.
void setSize(const IntSize &_value) override
bool getEditWordWrap() const
size_t getHScrollPosition() const
void addText(const UString &_text)
size_t getTextSelectionEnd() const
void setInvertSelected(bool _value)
void setVScrollPosition(size_t _index)
bool getTabPrinting() const
UString getOnlyText() const
void notifyMouseWheel(Widget *_sender, int _rel)
bool getInvertSelected() const
EventPair< EventHandle_WidgetVoid, EventHandle_EditPtr > eventEditSelectAccept
void setTextAlign(Align _value) override
bool getOverflowToTheLeft() const
Returns true if surplus characters will be pushed off the left rather than ignored.
void setTextIntervalColour(size_t _start, size_t _count, const Colour &_colour)
size_t getMaxTextLength() const
Gets the max amount of text allowed in the edit field.
void setEditReadOnly(bool _value)
void onKeySetFocus(Widget *_old) override
void notifyMousePressed(Widget *_sender, int _left, int _top, MouseButton _id)
void initialiseOverride() override
void setTextCursor(size_t _index)
static Gui & getInstance()
const IntCoord & getCoord() const
virtual bool getInvertSelected() const
virtual void setTextColour(const Colour &)
virtual IntPoint getViewOffset() const
virtual const Colour & getTextColour() const
virtual const UString & getCaption() const
virtual void setTextAlign(Align)
IntRect getCursorRect(size_t _position) const
virtual void setFontName(const std::string &)
IntPoint getCursorPoint(size_t _position) const
virtual void setCaption(const UString &)
virtual IntSize getTextSize() const
virtual void setShadowColour(const Colour &)
virtual void setWordWrap(bool)
virtual void setCursorPosition(size_t)
virtual void setFontHeight(int)
virtual size_t getCursorPosition() const
virtual int getFontHeight() const
virtual void setInvertSelected(bool)
virtual void setVisibleCursor(bool)
virtual void setTextSelection(size_t, size_t)
virtual Align getTextAlign() const
virtual void setSelectBackground(bool)
virtual void setViewOffset(const IntPoint &)
virtual void setShadow(bool)
virtual bool isVisibleCursor() const
static InputManager & getInstance()
widget description should be here.
EventHandle_ScrollBarPtrSizeT eventScrollChangePosition
void setScrollPosition(size_t _value)
virtual IntSize getViewSize() const
virtual size_t getHScrollPage() const
virtual IntPoint getContentPosition() const
virtual Align getContentAlign() const
virtual IntSize getContentSize() const
virtual size_t getVScrollPage() const
ISubWidgetText * getSubWidgetText() const
static UString getOnlyText(const UString &_text)
static UString getTextNewLine()
static UString getTextCharInfo(Char _char)
static UString convertTagColour(const Colour &_colour)
static UString toTagsString(const UString &_text)
bool getTagColour(UString &_colour) const
A UTF-16 string with implicit conversion to/from std::string and std::wstring.
const utf32string & asUTF32() const
returns the current string in UTF-32 form within a utf32string
void clear()
deletes all of the elements in the string
std::basic_string< unicode_char > utf32string
string type used for returning UTF-32 formatted data
uint16 code_point
a single UTF-16 code point
widget description should be here.
bool getInheritedEnabled() const
EventHandle_WidgetStringString eventChangeProperty
bool _setWidgetState(const std::string &_value)
void assignWidget(T *&_widget, const std::string &_name)
Widget * getClientWidget()
EventHandle_WidgetVoid eventMouseButtonDoubleClick
void setPointer(const std::string &_value)
EventHandle_WidgetIntIntButton eventMouseButtonReleased
const std::string & getPointer() const
void setNeedKeyFocus(bool _value)
EventHandle_WidgetIntIntButton eventMouseButtonPressed
EventHandle_WidgetWidget eventMouseSetFocus
EventHandle_WidgetWidget eventMouseLostFocus
EventPairAddParameter< EventHandle_WidgetIntInt, EventHandle_WidgetIntIntButton > eventMouseDrag
EventHandle_WidgetInt eventMouseWheel
T parseValue(const std::string &_value)
const int EDIT_MOUSE_WHEEL
const int EDIT_CURSOR_MIN_POSITION
const std::string EDIT_CLIPBOARD_TYPE_TEXT
const size_t EDIT_MAX_UNDO
const int EDIT_CURSOR_MAX_POSITION
const float EDIT_CURSOR_TIMER
static EditCommand ToEditCommand(KeyCode key, const InputManager &input)
const float EDIT_OFFSET_HORZ_CURSOR
static bool isWhitespace(const UString::code_point &c)
types::TSize< int > IntSize
Definition MyGUI_Types.h:30
const size_t ITEM_NONE
delegates::DelegateFunction< Args... > * newDelegate(void(*_func)(Args... args))
const float EDIT_ACTION_MOUSE_TIMER
types::TPoint< int > IntPoint
Definition MyGUI_Types.h:27
const int EDIT_ACTION_MOUSE_ZONE
const size_t EDIT_DEFAULT_MAX_TEXT_LENGTH
types::TRect< int > IntRect
Definition MyGUI_Types.h:33
unsigned int Char
Definition MyGUI_Types.h:50
std::vector< TextCommandInfo > VectorChangeInfo
int getValue() const