44 mMouseLeftPressed(false),
47 mModeMultiline(false),
52 mOverflowToTheLeft(false),
53 mMaxTextLength(EDIT_DEFAULT_MAX_TEXT_LENGTH),
226 while (iterBack != text.
rend())
228 if (((*iterBack) < 265) && (ispunct(*iterBack) || isspace(*iterBack)))
233 while (iterForw != text.
end())
235 if (((*iterForw) < 265) && (ispunct(*iterForw) || isspace(*iterForw)))
703 void EditBox::frameEntered(
float _frame)
740 if ((mouse.
top < 0) && (mouse.
top > -EDIT_ACTION_MOUSE_ZONE))
761 if ((mouse.
left < 0) && (mouse.
left > -EDIT_ACTION_MOUSE_ZONE))
764 point.
left -= (int)EDIT_OFFSET_HORZ_CURSOR;
771 point.
left += (int)EDIT_OFFSET_HORZ_CURSOR;
870 void EditBox::resetSelect()
880 void EditBox::commandPosition(
size_t _undo,
size_t _redo,
size_t _length,
VectorChangeInfo* _info)
882 if (_info !=
nullptr)
886 void EditBox::commandMerge()
895 for (VectorChangeInfo::iterator iter = info.begin(); iter != info.end(); ++iter)
901 bool EditBox::commandUndo()
916 UString text = getRealString();
919 for (VectorChangeInfo::reverse_iterator iter = info.rbegin(); iter != info.rend(); ++iter)
922 text.
erase((*iter).start, (*iter).text.size());
924 text.
insert((*iter).start, (*iter).text);
946 bool EditBox::commandRedo()
961 UString text = getRealString();
964 for (VectorChangeInfo::iterator iter = info.begin(); iter != info.end(); ++iter)
967 text.
insert((*iter).start, (*iter).text);
969 text.
erase((*iter).start, (*iter).text.size());
994 if (_info ==
nullptr)
1014 size_t end = _start + _count;
1023 bool need_colour =
true;
1041 else if (pos == _start)
1050 else if (pos == end)
1062 void EditBox::_setTextColour(
size_t _start,
size_t _count,
const Colour& _colour,
bool _history)
1070 size_t end = _start + _count;
1092 else if (pos == _start)
1100 else if (pos == end)
1110 commandPosition(_start, _start + _count,
mTextLength, history);
1115 saveInHistory(history);
1120 commandResetHistory();
1123 setRealString(iterator.
getText());
1126 void EditBox::setTextSelectColour(
const Colour& _colour,
bool _history)
1134 _setTextColour(start, end - start, _colour, _history);
1171 commandResetHistory();
1174 void EditBox::setText(
const UString& _caption,
bool _history)
1211 saveInHistory(history);
1216 commandResetHistory();
1219 setRealString(iterator.
getText());
1251 bool need_colour = ( (_text.
size() > 6) && (_text[0] == L
'#') && (_text[1] != L
'#') );
1292 commandPosition(_start, _start +
mTextLength - old, old, history);
1297 saveInHistory(history);
1302 commandResetHistory();
1305 setRealString(iterator.
getText());
1333 size_t end = _start + _count;
1334 bool need_colour =
false;
1351 else if (pos == _start)
1354 if (!colour.
empty())
1372 else if (pos == end)
1375 if (!colour.
empty())
1378 need_colour =
false;
1392 commandPosition(_start + _count, _start,
mTextLength, history);
1401 saveInHistory(history);
1406 commandResetHistory();
1409 setRealString(iterator.
getText());
1417 void EditBox::commandCut()
1434 void EditBox::commandCopy()
1443 void EditBox::commandPast()
1462 const UString& EditBox::getRealString()
1472 void EditBox::setRealString(
const UString& _caption)
1497 void EditBox::updateEditState()
1553 setText(_value,
false);
1558 return getRealString();
1561 void EditBox::updateSelectText()
1633 point.
top = _position;
1639 point.
left = _position;
1652 int offset = point.
top;
1660 else if (offset > (
int)
mVRange)
1663 if (offset != point.
top)
1674 int offset = point.
left;
1682 else if (offset > (
int)
mHRange)
1685 if (offset != point.
left)
1687 point.
left = offset;
1733 updateCursorPosition();
1737 void EditBox::updateCursorPosition()
1758 if (!view.
inside(cursor))
1768 offset.
left -=
int(EDIT_OFFSET_HORZ_CURSOR);
1775 offset.
left +=
int(EDIT_OFFSET_HORZ_CURSOR);
1788 else if (cursor.
top < view.
top)
1790 delta = - (view.
top - cursor.
top);
1796 offset.
top = point.
top + delta;
1801 if (offset != point)
1812 void EditBox::setContentPosition(
const IntPoint& _point)
1818 IntSize EditBox::getViewSize()
1825 IntSize EditBox::getContentSize()
1832 size_t EditBox::getVScrollPage()
1839 size_t EditBox::getHScrollPage()
1846 IntPoint EditBox::getContentPosition()
1853 Align EditBox::getContentAlign()
1862 _setTextColour(_start, _count, _colour,
false);
1887 setTextSelectColour(_colour,
false);
1924 commandResetHistory();
1933 setText(getRealString(),
false);
1941 commandResetHistory();
1960 if (!_value.
empty())
2022 point.
left = _index;
2044 if (_key ==
"CursorPosition")
2048 else if (_key ==
"TextSelect")
2052 else if (_key ==
"ReadOnly")
2056 else if (_key ==
"Password")
2060 else if (_key ==
"MultiLine")
2064 else if (_key ==
"PasswordChar")
2068 else if (_key ==
"MaxTextLength")
2072 else if (_key ==
"OverflowToTheLeft")
2076 else if (_key ==
"Static")
2080 else if (_key ==
"VisibleVScroll")
2084 else if (_key ==
"VisibleHScroll")
2088 else if (_key ==
"WordWrap")
2092 else if (_key ==
"TabPrinting")
2096 else if (_key ==
"InvertSelected")
2203 void EditBox::commandResetRedo()
2208 void EditBox::commandResetHistory()
bool getEditStatic() const
size_t getPosition() const
static UString getTextCharInfo(Char _char)
virtual void setTextColour(const Colour &_value)
size_t getTextSelectionStart() const
const UString & getText() const
reverse_iterator rend()
returns a reverse iterator just past the beginning of the string
size_t getTextSelectionLength() const
DequeUndoRedoInfo mVectorUndoChangeInfo
void notifyMouseButtonDoubleClick(Widget *_sender)
bool inside(const TRect< T > &_value) const
virtual void setInvertSelected(bool _value)
void cutMaxLength(size_t _max)
void setVisibleVScroll(bool _value)
EventHandle_FrameEventDelegate eventFrameStart
std::vector< TextCommandInfo > VectorChangeInfo
virtual void onKeyButtonPressed(KeyCode _key, Char _char)
const IntCoord & getCoord() const
types::TSize< int > IntSize
void setEditReadOnly(bool _value)
void setTextSelection(size_t _start, size_t _end)
bool getEditWordWrap() const
static UString getOnlyText(const UString &_text)
iterator erase(iterator loc)
removes the code point pointed to by loc, returning an iterator to the next character ...
bool isVisibleHScroll() const
delegates::IDelegate0 * newDelegate(void(*_func)())
virtual void setWordWrap(bool _value)
static InputManager & getInstance()
virtual void setTextAlign(Align _value)
virtual void setSelectBackground(bool _normal)
virtual void setShadowColour(const Colour &_value)
UString getTextInterval(size_t _start, size_t _count)
bool getTagColour(UString &_colour) const
const int EDIT_MOUSE_WHEEL
const float EDIT_CURSOR_TIMER
size_t getMaxTextLength() const
Gets the max amount of text allowed in the edit field.
virtual void setTextShadow(bool _value)
void notifyScrollChangePosition(ScrollBar *_sender, size_t _position)
EventPair< EventHandle_WidgetVoid, EventHandle_EditPtr > eventEditSelectAccept
std::string mOriginalPointer
bool getEditPassword() const
void clearClipboardData(const std::string &_type)
virtual void onKeySetFocus(Widget *_old)
size_t getTextLength() const
const size_t EDIT_MAX_UNDO
size_t getHScrollRange() const
std::string getClipboardData(const std::string &_type)
virtual void shutdownOverride()
virtual IntPoint getViewOffset() const
UString getTextSelection()
void clear()
deletes all of the elements in the string
void deleteTextSelection()
void notifyMousePressed(Widget *_sender, int _left, int _top, MouseButton _id)
iterator begin()
returns an iterator to the first element of the string
virtual void setCaption(const UString &_value)
Char getPasswordChar() const
virtual IntSize getTextSize()
void updateViewWithCursor()
ISubWidgetText * getSubWidgetText()
types::TCoord< int > IntCoord
void insertText(const UString &_insert, bool _multiLine)
IntRect getAbsoluteRect() const
virtual IntCoord getTextRegion()
virtual const Colour & getTextColour() const
const float EDIT_ACTION_MOUSE_TIMER
virtual void setTextSelection(size_t _start, size_t _end)
virtual void setFontHeight(int _value)
uint16 code_point
a single UTF-16 code point
virtual void setFontName(const std::string &_value)
bool isTextSelection() const
void setEditMultiLine(bool _value)
void setTextIntervalColour(size_t _start, size_t _count, const Colour &_colour)
virtual void setCursorPosition(size_t _index)
T parseValue(const std::string &_value)
bool getTabPrinting() const
const int EDIT_CURSOR_MIN_POSITION
void setHScrollPosition(size_t _index)
void setClipboardData(const std::string &_type, const std::string &_data)
virtual void setVisibleCursor(bool _value)
bool getEditMultiLine() const
virtual bool getInvertSelected() const
static UString toTagsString(const UString &_text)
virtual void setShadow(bool _value)
void addText(const UString &_text)
virtual bool isVisibleCursor() const
size_t getVScrollRange() const
virtual void initialiseOverride()
virtual void setViewOffset(const IntPoint &_point)
virtual void setFontName(const std::string &_value)
virtual void setFontHeight(int _value)
void eraseText(size_t _start, size_t _count=1)
void setMaxTextLength(size_t _value)
Sets the max amount of text allowed in the edit field.
virtual void setCaption(const UString &_value)
forward iterator for UString
size_t getVScrollPosition()
IntPoint getCursorPoint(size_t _position)
void setText(const UString &_text, bool _multiLine)
const int EDIT_CURSOR_MAX_POSITION
virtual void setCoord(const IntCoord &_value)
bool isVisibleVScroll() const
ISubWidgetText * mClientText
bool setTagColour(const Colour &_colour)
void setTextCursor(size_t _index)
void insertText(const UString &_text, size_t _index=ITEM_NONE)
size_t getTextSelectionEnd() const
virtual void setSize(const IntSize &_value)
virtual void setPosition(const IntPoint &_value)
bool getEditReadOnly() const
forward iterator for UString
virtual Align getTextAlign() const
void notifyMouseSetFocus(Widget *_sender, Widget *_old)
void notifyMouseDrag(Widget *_sender, int _left, int _top, MouseButton _id)
virtual int getFontHeight() const
static UString getTextNewLine()
virtual void setTextColour(const Colour &_value)
void setInvertSelected(bool _value)
virtual void setTextShadowColour(const Colour &_value)
A UTF-16 string with implicit conversion to/from std::string and std::wstring.
virtual const UString & getCaption() const
EventPair< EventHandle_WidgetVoid, EventHandle_EditPtr > eventEditTextChange
void cutMaxLengthFromBeginning(size_t _max)
void setOverflowToTheLeft(bool _value)
Sets if surplus characters should push characters off the left side rather than ignored.
iterator insert(iterator i, const code_point &ch)
inserts ch before the code point denoted by i
const int EDIT_ACTION_MOUSE_ZONE
iterator end()
returns an iterator just past the end of the string
void setVScrollPosition(size_t _index)
DequeUndoRedoInfo mVectorRedoChangeInfo
void setPasswordChar(Char _value)
virtual void onMouseDrag(int _left, int _top, MouseButton _id)
size_type size() const
Returns the number of code points in the current string.
void setTextSelectionColour(const Colour &_value)
void setEditStatic(bool _value)
void setEditPassword(bool _value)
void setTabPrinting(bool _value)
const std::string EDIT_CLIPBOARD_TYPE_TEXT
bool getOverflowToTheLeft() const
Returns true if surplus characters will be pushed off the left rather than ignored.
size_t getTextCursor() const
virtual void setTextAlign(Align _value)
virtual void setPropertyOverride(const std::string &_key, const std::string &_value)
virtual IntSize getTextSize()
IntRect getCursorRect(size_t _position)
virtual void onKeyLostFocus(Widget *_new)
void notifyMouseWheel(Widget *_sender, int _rel)
void setOnlyText(const UString &_value)
virtual size_t getCursorPosition() const
static UString convertTagColour(const Colour &_colour)
size_t getHScrollPosition()
virtual const UString & getCaption()
bool empty() const
returns true if the string has no elements, false otherwise
const float EDIT_OFFSET_HORZ_CURSOR
void notifyMouseLostFocus(Widget *_sender, Widget *_new)
void setVisibleHScroll(bool _value)
void setEditWordWrap(bool _value)
const size_t EDIT_DEFAULT_MAX_TEXT_LENGTH
void notifyMouseReleased(Widget *_sender, int _left, int _top, MouseButton _id)
types::TPoint< int > IntPoint