libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
textarea.h
Go to the documentation of this file.
1
8#pragma once
9
11#include <promeki/core/string.h>
13#include <promeki/tui/widget.h>
14
16
22class TuiTextArea : public TuiWidget {
23 PROMEKI_OBJECT(TuiTextArea, TuiWidget)
24 public:
25 TuiTextArea(ObjectBase *parent = nullptr);
26 ~TuiTextArea() override;
27
28 void setText(const String &text);
29 String text() const;
30
31 void setReadOnly(bool readOnly) { _readOnly = readOnly; }
32 bool isReadOnly() const { return _readOnly; }
33
34 void appendLine(const String &line);
35
36 Size2Di32 sizeHint() const override;
37
38 PROMEKI_SIGNAL(textChanged)
39
40 protected:
41 void paintEvent(TuiPaintEvent *e) override;
42 void keyEvent(KeyEvent *e) override;
43
44 private:
45 StringList _lines;
46 int _cursorRow = 0;
47 int _cursorCol = 0;
48 int _scrollRow = 0;
49 int _scrollCol = 0;
50 bool _readOnly = false;
51};
52
Event delivered when a key is pressed or released.
Definition keyevent.h:22
Dynamic array container wrapping std::vector.
Definition list.h:40
Base object for promeki.
Definition objectbase.h:129
ObjectBase * parent() const
Returns the parent object, if one. nullptr if none.
Definition objectbase.h:258
Manages a list of strings.
Definition stringlist.h:21
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
Event delivered when a TUI widget needs to repaint.
Definition widget.h:28
Multi-line text editing/display widget.
Definition textarea.h:22
void keyEvent(KeyEvent *e) override
Called on keyboard input. Override in subclasses.
Size2Di32 sizeHint() const override
Returns the preferred size. Override in subclasses.
void paintEvent(TuiPaintEvent *e) override
Called to paint the widget. Override in subclasses.
Base class for all TUI widgets.
Definition widget.h:88
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19