TextView
TextView
Section titled “TextView”#include <TextView.hpp>Inherits:
Widget
A read-only multiline text widget.
TextView displays text over multiple lines and supports optional vertical scrolling for long content.
Public Methods
Section titled “Public Methods”| Return | Name | Description |
|---|---|---|
TextView | Defaulted constructor. | |
TextView inline explicit | Create a text view with text inside it. | |
void | setText inline | Set the text content of the TextView. |
const std::string & | getText const inline | Get the current text content of the TextView. |
void | setFlowMode inline | Set the text flow mode, which determines how the TextArea handles overflow. |
TextFlowMode | getFlowMode const inline | Get the current text flow mode. |
bool | isFocusable virtual const | Returns whether this widget can receive keyboard focus. |
bool | onEvent virtual | Handles an input event. |
void | setScrollX | |
int | scrollX const inline | |
void | setScrollY | |
int | scrollY const inline | |
core::Size | measure virtual | Measures how much space this widget needs. |
TextView
Section titled “TextView”TextView() = defaultDefaulted constructor.
TextView
Section titled “TextView”inline explicit
inline explicit TextView(const std::string & text)Create a text view with text inside it.
Parameters
Section titled “Parameters”textThe text to display in the TextView
setText
Section titled “setText”inline
inline void setText(const std::string & t)Set the text content of the TextView.
Parameters
Section titled “Parameters”tThe new text content
getText
Section titled “getText”const inline
inline const std::string & getText() constGet the current text content of the TextView.
Returns
Section titled “Returns”The current text content
setFlowMode
Section titled “setFlowMode”inline
inline void setFlowMode(TextFlowMode mode)Set the text flow mode, which determines how the TextArea handles overflow.
Parameters
Section titled “Parameters”modeThe new TextFlowMode (default: Scroll)
getFlowMode
Section titled “getFlowMode”const inline
inline TextFlowMode getFlowMode() constGet the current text flow mode.
Returns
Section titled “Returns”The current flow mode
isFocusable
Section titled “isFocusable”virtual const
virtual bool isFocusable() constReturns whether this widget can receive keyboard focus.
Widgets like Button and Input return true; containers return false.
Returns
Section titled “Returns”True if this widget can be focused, false otherwise
onEvent
Section titled “onEvent”virtual
virtual bool onEvent(const core::events::Event & event)Handles an input event.
Called by the framework to deliver an event to this widget. The default implementation runs any listeners registered via addEventListener(), then returns false. Subclasses (Button, Input, etc.) override this to add built-in behavior, and should call Widget::onEvent(event) first to give user listeners a chance to handle the event before the widget’s own logic.
Return true if the event was handled, false to let it bubble to the parent widget.
Parameters
Section titled “Parameters”eventThe input event
Returns
Section titled “Returns”True if this widget (or one of its listeners) handled the event
setScrollX
Section titled “setScrollX”void setScrollX(int x)scrollX
Section titled “scrollX”const inline
inline int scrollX() constsetScrollY
Section titled “setScrollY”void setScrollY(int y)scrollY
Section titled “scrollY”const inline
inline int scrollY() constmeasure
Section titled “measure”virtual
virtual core::Size measure(int availW, int availH)Measures how much space this widget needs.
Called during the measurement pass to determine widget size requirements. Should return the preferred size based on available space.
Parameters
Section titled “Parameters”-
availWMaximum available width (may be ignored by widget) -
availHMaximum available height (may be ignored by widget)
Returns
Section titled “Returns”The Size this widget wants, or needs at minimum
Protected Methods
Section titled “Protected Methods”| Return | Name | Description |
|---|---|---|
void | drawContent virtual | Draws this widget’s content. |
drawContent
Section titled “drawContent”virtual
virtual void drawContent(backend::Buffer & buf, core::Rect inner)Draws this widget’s content.
Called by render() after background and borders are drawn. This is where you should draw your widget’s actual content. The inner rectangle accounts for borders and padding.
Parameters
Section titled “Parameters”-
bufThe buffer to draw to -
innerThe inner rectangle (excluding border/padding)
Private Attributes
Section titled “Private Attributes”| Return | Name | Description |
|---|---|---|
std::string | text | |
int | scrollOffsetX | |
int | scrollOffsetY | |
TextFlowMode | flowMode |
std::string textscrollOffsetX
Section titled “scrollOffsetX”int scrollOffsetX = 0scrollOffsetY
Section titled “scrollOffsetY”int scrollOffsetY = 0flowMode
Section titled “flowMode”TextFlowMode flowMode = TextFlowMode::Scroll