mirror of
https://github.com/edubart/otclient.git
synced 2025-11-07 13:56:22 +01:00
UITextEdit selection, closes #55
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#define UITEXTEDIT_H
|
||||
|
||||
#include "uiwidget.h"
|
||||
#include <boost/concept_check.hpp>
|
||||
|
||||
// @bindclass
|
||||
class UITextEdit : public UIWidget
|
||||
@@ -38,6 +39,7 @@ private:
|
||||
|
||||
public:
|
||||
void setCursorPos(int pos);
|
||||
void setSelection(int start, int end);
|
||||
void setCursorVisible(bool enable) { m_cursorVisible = enable; }
|
||||
void setTextHidden(bool hidden);
|
||||
void setValidCharacters(const std::string validCharacters) { m_validCharacters = validCharacters; }
|
||||
@@ -46,25 +48,44 @@ public:
|
||||
void setMaxLength(uint maxLength) { m_maxLength = maxLength; }
|
||||
void setTextVirtualOffset(const Point& offset);
|
||||
void setEditable(bool editable) { m_editable = editable; }
|
||||
void setSelectable(bool selectable) { m_selectable = selectable; }
|
||||
void setSelectionColor(const Color& color) { m_selectionColor = color; }
|
||||
void setSelectionBackgroundColor(const Color& color) { m_selectionBackgroundColor = color; }
|
||||
|
||||
void moveCursor(bool right);
|
||||
void moveCursorHorizontally(bool right);
|
||||
void moveCursorVertically(bool up);
|
||||
void appendText(std::string text);
|
||||
void appendCharacter(char c);
|
||||
void removeCharacter(bool right);
|
||||
void blinkCursor();
|
||||
|
||||
void del(bool right = false);
|
||||
void paste(const std::string& text);
|
||||
std::string copy();
|
||||
std::string cut();
|
||||
void selectAll() { setSelection(0, m_text.length()); }
|
||||
void clearSelection() { setSelection(0, 0); }
|
||||
|
||||
void wrapText();
|
||||
std::string getDisplayedText();
|
||||
std::string getSelection();
|
||||
int getTextPos(Point pos);
|
||||
int getCursorPos() { return m_cursorPos; }
|
||||
Point getTextVirtualOffset() { return m_textVirtualOffset; }
|
||||
Size getTextVirtualSize() { return m_textVirtualSize; }
|
||||
Size getTextTotalSize() { return m_textTotalSize; }
|
||||
uint getMaxLength() { return m_maxLength; }
|
||||
int getSelectionStart() { return m_selectionStart; }
|
||||
int getSelectionEnd() { return m_selectionEnd; }
|
||||
Color getSelectionColor() { return m_selectionColor; }
|
||||
Color getSelectionBackgroundColor() { return m_selectionBackgroundColor; }
|
||||
bool hasSelection() { return m_selectionEnd - m_selectionStart > 0; }
|
||||
bool isCursorVisible() { return m_cursorVisible; }
|
||||
bool isTextHidden() { return m_textHidden; }
|
||||
bool isShiftNavigation() { return m_shiftNavigation; }
|
||||
bool isMultiline() { return m_multiline; }
|
||||
bool isEditable() { return m_editable; }
|
||||
bool isSelectable() { return m_selectable; }
|
||||
|
||||
protected:
|
||||
virtual void onHoverChange(bool hovered);
|
||||
@@ -76,10 +97,14 @@ protected:
|
||||
virtual bool onKeyText(const std::string& keyText);
|
||||
virtual bool onKeyPress(uchar keyCode, int keyboardModifiers, int autoRepeatTicks);
|
||||
virtual bool onMousePress(const Point& mousePos, Fw::MouseButton button);
|
||||
virtual bool onMouseRelease(const Point& mousePos, Fw::MouseButton button);
|
||||
virtual bool onMouseMove(const Point& mousePos, const Point& mouseMoved);
|
||||
virtual void onTextAreaUpdate(const Point& vitualOffset, const Size& virtualSize, const Size& totalSize);
|
||||
virtual void onSelectionChange(const std::string& text, int start, int end);
|
||||
|
||||
private:
|
||||
void blinkCursor();
|
||||
void disableUpdates() { m_updatesEnabled = false; }
|
||||
void enableUpdates() { m_updatesEnabled = true; }
|
||||
|
||||
Rect m_drawArea;
|
||||
int m_cursorPos;
|
||||
@@ -95,6 +120,15 @@ private:
|
||||
bool m_editable;
|
||||
std::string m_validCharacters;
|
||||
uint m_maxLength;
|
||||
bool m_updatesEnabled;
|
||||
|
||||
bool m_selectable;
|
||||
int m_selectionReference;
|
||||
int m_selectionStart;
|
||||
int m_selectionEnd;
|
||||
|
||||
Color m_selectionColor;
|
||||
Color m_selectionBackgroundColor;
|
||||
|
||||
std::vector<Rect> m_glyphsCoords;
|
||||
std::vector<Rect> m_glyphsTexCoords;
|
||||
|
||||
Reference in New Issue
Block a user