libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
label.h
Go to the documentation of this file.
1
8#pragma once
9
11#include <promeki/core/string.h>
12#include <promeki/tui/widget.h>
13
15
22 AlignLeft,
23 AlignCenter,
24 AlignRight
25};
26
30class TuiLabel : public TuiWidget {
31 PROMEKI_OBJECT(TuiLabel, TuiWidget)
32 public:
33 TuiLabel(const String &text = String(), ObjectBase *parent = nullptr);
34 ~TuiLabel() override;
35
37 void setText(const String &text);
38
40 const String &text() const { return _text; }
41
43 void setAlignment(TuiAlignment align) { _alignment = align; update(); }
44
46 TuiAlignment alignment() const { return _alignment; }
47
49 void setWordWrap(bool wrap) { _wordWrap = wrap; update(); }
50
52 bool wordWrap() const { return _wordWrap; }
53
54 Size2Di32 sizeHint() const override;
55
56 protected:
57 void paintEvent(TuiPaintEvent *e) override;
58
59 private:
60 String _text;
61 TuiAlignment _alignment = AlignLeft;
62 bool _wordWrap = false;
63};
64
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
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
Displays text (single or multi-line).
Definition label.h:30
void setText(const String &text)
Sets the display text.
const String & text() const
Returns the display text.
Definition label.h:40
TuiAlignment alignment() const
Returns the text alignment.
Definition label.h:46
bool wordWrap() const
Returns true if word wrapping is enabled.
Definition label.h:52
void setWordWrap(bool wrap)
Enables or disables word wrapping.
Definition label.h:49
void setAlignment(TuiAlignment align)
Sets the text alignment.
Definition label.h:43
Size2Di32 sizeHint() const override
Returns the preferred size. Override in subclasses.
void paintEvent(TuiPaintEvent *e) override
Called to paint the widget. Override in subclasses.
Event delivered when a TUI widget needs to repaint.
Definition widget.h:28
Base class for all TUI widgets.
Definition widget.h:88
void update()
Marks the widget as needing a repaint.
TuiAlignment
Text alignment for TUI labels.
Definition label.h:21
#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