mirror of
https://github.com/edubart/otclient.git
synced 2025-04-30 17:49:21 +02:00
56 lines
1.3 KiB
C++
56 lines
1.3 KiB
C++
#ifndef UILINEEDIT_H
|
|
#define UILINEEDIT_H
|
|
|
|
#include "uiwidget.h"
|
|
|
|
class UILineEdit : public UIWidget
|
|
{
|
|
public:
|
|
UILineEdit();
|
|
|
|
static UILineEditPtr create();
|
|
|
|
virtual void loadStyleFromOTML(const OTMLNodePtr& styleNode);
|
|
virtual void render();
|
|
|
|
void update();
|
|
|
|
void setText(const std::string& text);
|
|
void setAlign(AlignmentFlag align);
|
|
void setCursorPos(int pos);
|
|
void setCursorEnabled(bool enable = true);
|
|
|
|
void clearText() { setText(""); }
|
|
void moveCursor(bool right);
|
|
void appendCharacter(char c);
|
|
void removeCharacter(bool right);
|
|
|
|
void setFont(const FontPtr& font);
|
|
std::string getText() const { return m_text; }
|
|
int getTextPos(Point pos);
|
|
|
|
protected:
|
|
virtual void onRectUpdate(UIRectUpdateEvent& event);
|
|
virtual void onFocusChange(UIFocusEvent& event);
|
|
virtual void onKeyPress(UIKeyEvent& event);
|
|
virtual void onMousePress(UIMouseEvent& event);
|
|
|
|
private:
|
|
void blinkCursor();
|
|
|
|
std::string m_text;
|
|
Rect m_drawArea;
|
|
AlignmentFlag m_align;
|
|
int m_cursorPos;
|
|
Point m_startInternalPos;
|
|
int m_startRenderPos;
|
|
int m_cursorTicks;
|
|
int m_textHorizontalMargin;
|
|
SimpleCallback m_onAction;
|
|
|
|
std::vector<Rect> m_glyphsCoords;
|
|
std::vector<Rect> m_glyphsTexCoords;
|
|
};
|
|
|
|
#endif
|