44 mMouseLeftPressed(false),
47 mModeMultiline(false),
52 mOverflowToTheLeft(false),
221 UString::utf32string::reverse_iterator iterBack = text.rend() - cursorPosition;
222 UString::utf32string::iterator iterForw = text.begin() + cursorPosition;
224 while (iterBack != text.rend())
226 if (((*iterBack) < 256) && (ispunct(*iterBack) || isspace(*iterBack)))
231 while (iterForw != text.end())
233 if (((*iterForw) < 256) && (ispunct(*iterForw) || isspace(*iterForw)))
293 return c ==
' ' || c ==
'\t';
425 const UString& text = getRealString();
462 const UString& text = getRealString();
749 void EditBox::frameEntered(
float _frame)
779 mouse.
left -= view.left;
780 mouse.top -= view.top;
919 void EditBox::resetSelect()
929 void EditBox::commandPosition(
size_t _undo,
size_t _redo,
size_t _length,
VectorChangeInfo* _info)
931 if (_info !=
nullptr)
932 _info->push_back(TextCommandInfo(_undo, _redo, _length));
935 void EditBox::commandMerge()
944 for (VectorChangeInfo::iterator iter = info.begin(); iter != info.end(); ++iter)
950 bool EditBox::commandUndo()
966 for (VectorChangeInfo::const_reverse_iterator iter = info.rbegin(); iter != info.rend(); ++iter)
968 const auto& change = *iter;
972 text.erase(change.start, change.text.size());
975 text.insert(change.start, change.text);
984 setRealString(UString(text));
996 bool EditBox::commandRedo()
1013 for (
const auto& change : info)
1015 switch (change.type)
1018 text.insert(change.start, change.text);
1021 text.erase(change.start, change.text.size());
1031 setRealString(UString(text));
1045 if (_info ==
nullptr)
1048 if ( _info->empty())
1065 size_t end = _start + _count;
1074 bool need_colour =
true;
1092 else if (pos == _start)
1101 else if (pos == end)
1113 void EditBox::_setTextColour(
size_t _start,
size_t _count,
const Colour& _colour,
bool _history)
1121 size_t end = _start + _count;
1130 while (iterator.moveNext())
1133 size_t pos = iterator.getPosition();
1136 iterator.getTagColour(colour);
1143 else if (pos == _start)
1144 iterator.setTagColour(_colour);
1148 iterator.clearTagColour();
1151 else if (pos == end)
1153 iterator.setTagColour(colour);
1161 commandPosition(_start, _start + _count,
mTextLength, history);
1166 saveInHistory(history);
1171 commandResetHistory();
1174 setRealString(iterator.getText());
1177 void EditBox::setTextSelectColour(
const Colour& _colour,
bool _history)
1185 _setTextColour(start, end - start, _colour, _history);
1222 commandResetHistory();
1225 void EditBox::setText(
const UString& _caption,
bool _history)
1262 saveInHistory(history);
1267 commandResetHistory();
1270 setRealString(iterator.getText());
1296 TextIterator iterator(getRealString(), history);
1302 bool need_colour = ( (_text.size() > 6) && (_text[0] == L
'#') && (_text[1] != L
'#') );
1305 while (iterator.moveNext())
1308 size_t pos = iterator.getPosition();
1312 iterator.getTagColour(colour);
1321 iterator.setTagColour(colour);
1343 commandPosition(_start, _start +
mTextLength - old, old, history);
1348 saveInHistory(history);
1353 commandResetHistory();
1356 setRealString(iterator.getText());
1379 TextIterator iterator(getRealString(), history);
1384 size_t end = _start + _count;
1385 bool need_colour =
false;
1388 while (iterator.moveNext())
1391 size_t pos = iterator.getPosition();
1397 iterator.getTagColour(colour);
1402 else if (pos == _start)
1405 if (!colour.empty())
1411 iterator.getTagColour(colour);
1412 iterator.saveStartPoint();
1419 iterator.getTagColour(colour);
1423 else if (pos == end)
1426 if (!colour.empty())
1428 if (iterator.getTagColour(colour))
1429 need_colour =
false;
1437 iterator.eraseFromStart();
1440 iterator.setTagColour(colour);
1443 commandPosition(_start + _count, _start,
mTextLength, history);
1452 saveInHistory(history);
1457 commandResetHistory();
1460 setRealString(iterator.getText());
1468 void EditBox::commandCut()
1485 void EditBox::commandCopy()
1494 void EditBox::commandPast()
1513 const UString& EditBox::getRealString()
const
1523 void EditBox::setRealString(
const UString& _caption)
1548 void EditBox::updateEditState()
1604 setText(_value,
false);
1609 return getRealString();
1612 void EditBox::updateSelectText()
1684 point.
top = _position;
1690 point.
left = _position;
1703 int offset = point.
top;
1711 else if (offset > (
int)
mVRange)
1714 if (offset != point.
top)
1725 int offset = point.
left;
1733 else if (offset > (
int)
mHRange)
1736 if (offset != point.
left)
1738 point.
left = offset;
1789 updateCursorPosition();
1793 void EditBox::updateCursorPosition()
1814 if (!view.
inside(cursor))
1844 else if (cursor.
top < view.
top)
1846 delta = - (view.
top - cursor.
top);
1852 offset.
top = point.
top + delta;
1857 if (offset != point)
1868 void EditBox::setContentPosition(
const IntPoint& _point)
1874 IntSize EditBox::getViewSize()
const
1881 IntSize EditBox::getContentSize()
const
1888 size_t EditBox::getVScrollPage()
const
1895 size_t EditBox::getHScrollPage()
const
1902 IntPoint EditBox::getContentPosition()
const
1909 Align EditBox::getContentAlign()
const
1918 _setTextColour(_start, _count, _colour,
false);
1943 setTextSelectColour(_colour,
false);
1980 commandResetHistory();
1989 setText(getRealString(),
false);
1997 commandResetHistory();
2016 if (!_value.
empty())
2078 point.
left = _index;
2100 if (_key ==
"CursorPosition")
2104 else if (_key ==
"TextSelect")
2108 else if (_key ==
"ReadOnly")
2112 else if (_key ==
"Password")
2116 else if (_key ==
"MultiLine")
2120 else if (_key ==
"PasswordChar")
2124 else if (_key ==
"MaxTextLength")
2128 else if (_key ==
"OverflowToTheLeft")
2132 else if (_key ==
"Static")
2136 else if (_key ==
"VisibleVScroll")
2140 else if (_key ==
"VisibleHScroll")
2144 else if (_key ==
"WordWrap")
2148 else if (_key ==
"TabPrinting")
2152 else if (_key ==
"InvertSelected")
2244 void EditBox::commandResetRedo()
2249 void EditBox::commandResetHistory()
static ClipboardManager & getInstance()
void clearClipboardData(const std::string &_type)
void setClipboardData(const std::string &_type, const std::string &_data)
std::string getClipboardData(const std::string &_type) const
DequeUndoRedoInfo mVectorUndoChangeInfo
void setFontHeight(int _value) override
void insertText(const UString &_text, size_t _index=ITEM_NONE)
void setCoord(const IntCoord &_value) override
void deleteTextSelection()
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)
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 updateViewWithCursor()
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()
EventHandle_FrameEventDelegate eventFrameStart
const IntCoord & getCoord() const
IntRect getAbsoluteRect() const
virtual void setTextAlign(Align _value)
virtual bool getInvertSelected() const
virtual void setViewOffset(const IntPoint &_point)
virtual IntPoint getViewOffset() const
virtual const Colour & getTextColour() const
virtual const UString & getCaption() const
virtual void setCursorPosition(size_t _index)
virtual void setShadowColour(const Colour &_value)
IntRect getCursorRect(size_t _position) const
IntPoint getCursorPoint(size_t _position) const
virtual void setInvertSelected(bool _value)
virtual IntSize getTextSize() const
virtual void setShadow(bool _value)
virtual size_t getCursorPosition() const
virtual int getFontHeight() const
virtual void setFontHeight(int _value)
virtual void setSelectBackground(bool _normal)
virtual void setTextColour(const Colour &_value)
virtual void setVisibleCursor(bool _value)
virtual Align getTextAlign() const
virtual void setFontName(const std::string &_value)
virtual void setWordWrap(bool _value)
virtual void setTextSelection(size_t _start, size_t _end)
virtual void setCaption(const UString &_value)
virtual bool isVisibleCursor() const
ISubWidgetText * getSubWidgetText() const
static UString getOnlyText(const UString &_text)
static UString getTextNewLine()
static UString getTextCharInfo(Char _char)
UString getFromStart() const
static UString convertTagColour(const Colour &_colour)
static UString toTagsString(const UString &_text)
size_t getPosition() const
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
bool empty() const
returns true if the string has no elements, false otherwise
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
const float EDIT_OFFSET_HORZ_CURSOR
types::TSize< int > IntSize
delegates::DelegateFunction< Args... > * newDelegate(void(*_func)(Args... args))
const float EDIT_ACTION_MOUSE_TIMER
types::TPoint< int > IntPoint
const int EDIT_ACTION_MOUSE_ZONE
const size_t EDIT_DEFAULT_MAX_TEXT_LENGTH
bool isWhitespace(const UString::code_point &c)
types::TRect< int > IntRect
std::vector< TextCommandInfo > VectorChangeInfo
bool inside(const TRect< T > &_value) const