5#ifndef INCLUDE_FIFECHAN_WIDGETS_TEXTBOX_HPP_
6#define INCLUDE_FIFECHAN_WIDGETS_TEXTBOX_HPP_
14#include "fifechan/platform.hpp"
17#include "fifechan/listeners/keylistener.hpp"
18#include "fifechan/listeners/mouselistener.hpp"
19#include "fifechan/widget.hpp"
39 explicit TextBox(std::string
const & text =
"");
54 void setText(std::string
const & text);
80 void setTextRow(
int row, std::string
const & text);
174 virtual void addRow(std::string
const & row);
Abstract interface providing primitive drawing functions (lines, rectangles, etc.).
KeyListener(KeyListener const &)=default
Copy constructor.
Represents a mouse event.
MouseListener(MouseListener const &)=default
Copy constructor.
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 textInput(TextInputEvent &event) override
Called when text input (IME, dead-key, paste) is received.
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.
void resizeToContent(bool recursion=true) override
Resizes the widget's size to fit the content exactly, calls recursively all childs.
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 down 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 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).
Text input event for IME (input method editor) composition, dead keys, and pasted text.
Helper class for text manipulation within widgets.
Utility for editing and handling UTF-8 encoded strings.
Used replacement tokens by configure_file():