5#ifndef INCLUDE_FIFECHAN_WIDGETS_TEXTFIELD_HPP_
6#define INCLUDE_FIFECHAN_WIDGETS_TEXTFIELD_HPP_
10#include "fifechan/keylistener.hpp"
11#include "fifechan/mouselistener.hpp"
12#include "fifechan/platform.hpp"
13#include "fifechan/widget.hpp"
25 class FIFEGUI_API TextField :
public Widget,
public MouseListener,
public KeyListener
36 explicit TextField(std::string
const & text);
38 TextField(TextField
const &) =
delete;
39 TextField& operator=(TextField
const &) =
delete;
40 TextField(TextField&&) =
delete;
41 TextField& operator=(TextField&&) =
delete;
43 ~TextField()
override;
51 virtual void setText(std::string
const & text);
59 virtual std::string
getText()
const;
Abstract interface providing primitive drawing functions (lines, rectangles, etc.).
Represents a mouse event.
void adjustSizeImpl()
Adjusts the size of the button to fit the caption.
void resizeToContent(bool recursion) override
Resize this widget to fit its content.
void setCaretPosition(unsigned int position)
Sets the caret position.
bool mEditable
True if the text field is editable, false otherwise.
void mousePressed(MouseEvent &mouseEvent) override
Called when a mouse button has been pressed on the widget area.
virtual void drawCaret(Graphics *graphics, int x)
Draws the caret.
UTF8StringEditor * mStringEditor
String editor for UTF8 support.
unsigned int getCaretPosition() const
Gets the caret position.
void fixScroll()
Scrolls the text horizontally so that the caret shows if needed.
int mXScroll
Holds the amount scrolled in x.
void keyPressed(KeyEvent &keyEvent) override
Called if a key is pressed when the widget has keyboard focus.
void mouseDragged(MouseEvent &mouseEvent) override
Called when the mouse has moved and the mouse has previously been pressed on the widget.
virtual void setText(std::string const &text)
Sets the text of the text field.
virtual std::string getText() const
Gets the text of the text field.
void setEditable(bool editable)
Sets the text field to be editable or not.
void adjustSize() override
Adjusts the size of the text field to fit the text.
bool isEditable() const
Checks if the text field is editable.
void adjustHeight()
Adjusts the height of the text field to fit caption.
void draw(Graphics *graphics) override
Draws the widget.
Text * mText
Holds the text of the text field.
Helper class for text manipulation within widgets.
Utility for editing and handling UTF-8 encoded strings.