23 #include "ginteractor.h" 25 class _Internal_QTextEdit;
40 GTextArea(
int rows,
int columns, QWidget* parent =
nullptr);
45 GTextArea(
const string& text =
"", QWidget* parent =
nullptr);
56 virtual void appendFormattedText(
const string& text,
const string& color =
"",
const string& font =
"");
142 virtual string
getText()
const;
145 string
getType()
const override;
206 virtual void select(
int startIndex,
int length);
245 virtual void setHtml(
const string& html);
280 virtual void setRows(
int rows);
293 virtual void setText(
const string& text);
330 _Internal_QTextEdit* _iqtextedit;
331 bool _contextMenuEnabled;
336 friend class _Internal_QTextEdit;
343 class _Internal_QTextEdit :
public QTextEdit,
public _Internal_QWidget {
347 _Internal_QTextEdit(
GTextArea* gtextArea, QWidget* parent =
nullptr);
348 void contextMenuEvent(QContextMenuEvent* event)
override;
349 void detach()
override;
350 void keyPressEvent(QKeyEvent* event)
override;
351 void keyReleaseEvent(QKeyEvent* event)
override;
352 void mousePressEvent(QMouseEvent* event)
override;
353 void mouseReleaseEvent(QMouseEvent* event)
override;
354 QSize sizeHint()
const override;
357 void handleScroll(
int value);
358 void handleTextChange();
366 #endif // _gtextarea_h virtual void setColumns(int columns)
Sets the width of the text area to be wide enough to fit the given number of characters (columns) of ...
Definition: gtextarea.cpp:255
This struct contains real-valued width and height fields.
Definition: gtypes.h:39
virtual void setTextChangeListener(GEventListener func)
Sets a text change listener on this text area so that it will be called when the user modifies the cu...
Definition: gtextarea.cpp:331
virtual int getRows() const
Returns the number of visible rows (lines tall) in the text area.
Definition: gtextarea.cpp:131
virtual void scrollToBottom()
Moves the visible scroll region of the text area so that the bottom part of the text is visible...
Definition: gtextarea.cpp:222
virtual void appendText(string text)
Adds the given plain text to the end of the text area.
Definition: gtextarea.cpp:81
string getType() const override
Returns a string representing the class name of this interactor, such as "GButton" or "GCheckBox"...
Definition: gtextarea.cpp:180
virtual int getSelectionLength() const
Returns the number of characters that are currently selected.
Definition: gtextarea.cpp:158
virtual string getSelectedText() const
Returns the text that is currently selected in the text area.
Definition: gtextarea.cpp:135
virtual void setHtml(string html)
Sets the text area's current text to the given HTML string.
Definition: gtextarea.cpp:282
virtual int getColumns() const
Returns the number of visible columns (characters wide) in the text area.
Definition: gtextarea.cpp:102
virtual void clearText()
Sets the text in the text area to be empty.
Definition: gtextarea.cpp:96
virtual void setText(string text)
Sets the text area's current text to the given string, replacing any existing text.
Definition: gtextarea.cpp:325
virtual int getSelectionStart() const
Returns the index of the start of the current selection of text as a 0-based character index within t...
Definition: gtextarea.cpp:165
virtual void select(int startIndex, int length)
Sets the given range of text to be selected, beginning with the given start index as a 0-based charac...
Definition: gtextarea.cpp:238
GTextArea(int rows, int columns, QWidget* parent=nullptr)
Creates a new text area large enough to display the given number of rows and columns of text...
Definition: gtextarea.cpp:25
This abstract class is the superclass for all graphical interactors.
Definition: ginteractor.h:48
virtual void setCursorPosition(int index, bool keepAnchor=false)
Moves the keyboard cursor to the given 0-based character index within the text.
Definition: gtextarea.cpp:266
virtual int getSelectionEnd() const
Returns the index just past the end of the current selection of text as a 0-based character index wit...
Definition: gtextarea.cpp:146
virtual bool isContextMenuEnabled() const
Returns true if a context menu will pop up when the user right-clicks the text area.
Definition: gtextarea.cpp:188
virtual int getCursorPosition() const
Returns the keyboard cursor's current position in the text area as a 0-based character index within t...
Definition: gtextarea.cpp:106
A GTextArea is a multi-line editable text box.
Definition: gtextarea.h:33
virtual void removeTextChangeListener()
Removes the text change listener from this text area so that it will no longer call it when the user ...
Definition: gtextarea.cpp:218
void setMouseListener(GEventListener func) override
Sets a mouse listener on this text area so that it will be called when the user moves or clicks the m...
Definition: gtextarea.cpp:294
virtual void moveCursorToStart()
Sets the text area's keyboard cursor position to the start of the current text.
Definition: gtextarea.cpp:209
QWidget* getWidget() const override
Returns a direct pointer to the internal Qt widget being wrapped by this interactor.
Definition: gtextarea.cpp:184
virtual void clearSelection()
Deselects any text that is currently selected in the text area.
Definition: gtextarea.cpp:88
virtual string getText() const
Returns the text area's current text.
Definition: gtextarea.cpp:176
virtual void setPlaceholder(string text)
Sets the text area's placeholder text, which is usually displayed as a light gray text in the text ar...
Definition: gtextarea.cpp:304
virtual bool isLineWrap() const
Returns whether the text area wraps its text when a line becomes too long.
Definition: gtextarea.cpp:196
virtual bool isEditable() const
Returns whether the text area allows the user to modify its text.
Definition: gtextarea.cpp:192
virtual void setRows(int rows)
Sets the height of the text area to be wide enough to fit the given number of lines (rows) of text...
Definition: gtextarea.cpp:310
virtual void scrollToTop()
Moves the visible scroll region of the text area so that the top part of the text is visible...
Definition: gtextarea.cpp:230
virtual void selectAll()
Selects the entire text of the text area.
Definition: gtextarea.cpp:249
~GTextArea() override
Frees memory allocated internally by the text area.
Definition: gtextarea.cpp:43
virtual string getHtml() const
Returns the text area's current text as HTML.
Definition: gtextarea.cpp:110
virtual void setLineWrap(bool wrap)
Sets whether the text area wraps its text when a line becomes too long.
Definition: gtextarea.cpp:288
virtual void setEditable(bool value)
Sets whether the text area allows the user to modify its text.
Definition: gtextarea.cpp:276
virtual void appendHtml(string html)
Adds HTML-formatted text to the end of the text area.
Definition: gtextarea.cpp:76
virtual void moveCursorToEnd()
Sets the text area's keyboard cursor position to the end of the current text.
Definition: gtextarea.cpp:200
_Internal_QWidget* getInternalWidget() const override
Returns a direct pointer to the internal Qt widget being wrapped by this interactor.
Definition: gtextarea.cpp:114
virtual void appendFormattedText(string text, string color="", string font="")
Adds formatted text to the end of the text area.
Definition: gtextarea.cpp:49
virtual void setRowsColumns(int rows, int columns)
Sets the size of the text area to be wide enough to fit the given number of lines (rows) and characte...
Definition: gtextarea.cpp:317
virtual string getPlaceholder() const
Returns the text area's placeholder text, which is usually displayed as a light gray text in the text...
Definition: gtextarea.cpp:118
virtual void setContextMenuEnabled(bool enabled)
Sets whether a context menu will pop up when the user right-clicks the text area. ...
Definition: gtextarea.cpp:262