libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
label.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <promeki/namespace.h>
11#include <promeki/string.h>
12#include <promeki/tui/widget.h>
13
14PROMEKI_NAMESPACE_BEGIN
15
22 AlignLeft,
23 AlignCenter,
24 AlignRight
25};
26
33class TuiLabel : public TuiWidget {
34 PROMEKI_OBJECT(TuiLabel, TuiWidget)
35 public:
36 TuiLabel(const String &text = String(), ObjectBase *parent = nullptr);
37 ~TuiLabel() override;
38
40 void setText(const String &text);
41
43 const String &text() const { return _text; }
44
47 _alignment = align;
48 update();
49 }
50
52 TuiAlignment alignment() const { return _alignment; }
53
55 void setWordWrap(bool wrap) {
56 _wordWrap = wrap;
57 update();
58 }
59
61 bool wordWrap() const { return _wordWrap; }
62
63 Size2Di32 sizeHint() const override;
64
65 protected:
66 void paintEvent(PaintEvent *e) override;
67
68 private:
69 String _text;
70 TuiAlignment _alignment = AlignLeft;
71 bool _wordWrap = false;
72};
73
74PROMEKI_NAMESPACE_END
Displays text (single or multi-line).
Definition label.h:33
TuiAlignment alignment() const
Returns the text alignment.
Definition label.h:52
void setText(const String &text)
Sets the display text.
const String & text() const
Returns the display text.
Definition label.h:43
void setAlignment(TuiAlignment align)
Sets the text alignment.
Definition label.h:46
bool wordWrap() const
Returns true if word wrapping is enabled.
Definition label.h:61
void setWordWrap(bool wrap)
Enables or disables word wrapping.
Definition label.h:55
TUI-specific widget base class.
Definition widget.h:33
TuiAlignment
Text alignment for TUI labels.
Definition label.h:21