tibia-client/src/framework/ui/uilineedit.h

56 lines
1.3 KiB
C
Raw Normal View History

2011-08-14 04:09:11 +02:00
#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);
2011-08-20 22:30:41 +02:00
void setCursorEnabled(bool enable = true);
2011-08-20 22:30:41 +02:00
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);
2011-08-14 04:09:11 +02:00
protected:
2011-08-21 21:43:05 +02:00
virtual void onRectUpdate(UIRectUpdateEvent& event);
virtual void onFocusChange(UIFocusEvent& event);
virtual void onKeyPress(UIKeyEvent& event);
virtual void onMousePress(UIMouseEvent& event);
2011-08-14 04:09:11 +02:00
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;
2011-08-20 22:30:41 +02:00
SimpleCallback m_onAction;
std::vector<Rect> m_glyphsCoords;
std::vector<Rect> m_glyphsTexCoords;
2011-08-14 04:09:11 +02:00
};
#endif