5#ifndef INCLUDE_FIFECHAN_WIDGETS_TEXTBOX_HPP_
6#define INCLUDE_FIFECHAN_WIDGETS_TEXTBOX_HPP_
12#include "fifechan/keylistener.hpp"
13#include "fifechan/mouselistener.hpp"
14#include "fifechan/platform.hpp"
15#include "fifechan/widget.hpp"
27 class FIFEGUI_API
TextBox :
public Widget,
public MouseListener,
public KeyListener
35 explicit TextBox(std::string
const & text =
"");
50 void setText(std::string
const & text);
76 void setTextRow(
int row, std::string
const & text);
170 virtual void addRow(std::string
const & row);
Abstract interface providing primitive drawing functions (lines, rectangles, etc.).
Represents a mouse event.
void fontChanged() override
Called when the font has changed.
virtual void scrollToCaret()
Scrolls the text to the caret if the text box is in a scroll area.
void setCaretColumnUTF8(int column)
Sets caret column (UTF-8 aware).
virtual void addRow(std::string const &row)
Adds a row of text to the end of the text.
void keyPressed(KeyEvent &keyEvent) override
Called if a key is pressed when the widget has keyboard focus.
std::string getTextRow(int row) const
Gets a certain row from the text.
Text * mText
Holds the text of the text box.
void setCaretRowColumn(int row, int column)
Sets the row and the column where the caret should be currently located.
void draw(Graphics *graphics) override
Draws the widget.
void setTextRow(int row, std::string const &text)
Sets the text of a certain row of the text.
bool mEditable
True if the text box is editable, false otherwise.
void adjustSizeImpl()
Adjusts the size of the button to fit the caption.
unsigned int getCaretPosition() const
Gets the caret position in the text.
virtual void drawCaret(Graphics *graphics, int x, int y)
Draws the caret.
bool mOpaque
True if the text box is opaque, false otherwise.
std::string getText() const
Gets the text of the text box.
void setCaretColumn(int column)
Sets the column where the caret should be currently located.
TextBox(std::string const &text="")
Constructor.
unsigned int getCaretColumn() const
Gets the column where the caret is currently located.
void setCaretRow(int row)
Sets the row where the caret should be currently located.
void mousePressed(MouseEvent &mouseEvent) override
Called when a mouse button has been pressed on the widget area.
void setEditable(bool editable)
Sets the text box to be editable or not.
void adjustSize() override
Adjusts the text box's size to fit the text.
void setCaretRowUTF8(int row)
Sets caret row (UTF-8 aware).
void mouseDragged(MouseEvent &mouseEvent) override
Called when the mouse has moved and the mouse has previously been pressed on the widget.
unsigned int getCaretRow() const
Gets the row number where the caret is currently located.
void resizeToContent(bool recursion) override
Resize this widget to fit its content.
void setText(std::string const &text)
Sets the text of the text box.
bool isOpaque() const
Checks if the text box is opaque.
void setOpaque(bool opaque)
Sets the text box to be opaque or not.
UTF8StringEditor * mStringEditor
UTF8StringEditor for UTF8 support.
unsigned int getNumberOfRows() const
Gets the number of rows in the text.
bool isEditable() const
Checks if the text box is editable.
void setCaretPosition(unsigned int position)
Sets the position of the caret in the text.
void setCaretRowColumnUTF8(int row, int column)
Sets the caret row and column (UTF-8 aware).
Helper class for text manipulation within widgets.
Utility for editing and handling UTF-8 encoded strings.