terminalgui  0.1.0
Widgets for your terminal, powered by Qt! Create textual GUI (TUI) in your console easily.
tglabel.h
1 #pragma once
2 
3 #include <widgets/tgwidget.h>
4 
5 namespace Tg {
6 class Label : public Widget
7 {
8  Q_OBJECT
9 
10  Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
11  Q_PROPERTY(bool highlighted READ highlighted WRITE setHighlighted NOTIFY highlightedChanged)
12 
13 public:
14  Label(Widget *parent);
16  Label(const QString &text = QString(), Widget *parent = nullptr);
17  Label(const QString &text = QString(), Screen *screen = nullptr);
18 
19  QString text() const;
20 
21  bool highlighted() const;
22 
23 signals:
24  void textChanged(const QString &text) const;
25  void highlightedChanged(const bool highlighted) const;
26 
27 public slots:
28  void setText(const QString &text, const bool expand = false);
29  void setHighlighted(const bool highlighted);
30 
31 protected:
32  void init() override;
33  QString drawPixel(const QPoint &pixel) const override;
34 
35  int reservedCharactersCount() const;
36  QString reservedText() const;
37  void setReservedText(const QString &reserved);
38 
39 private slots:
40  void layoutText();
41 
42 private:
43  bool _highlighted = false;
44 
45  QString _text;
46  QString _reservedText;
47  QStringList _laidOutTextCache;
48 };
49 }
Tg::Screen
Screen is the "canvas" on which widgets (subclasses of Widget) are drawn.
Definition: tgscreen.h:31
Tg::Label::drawPixel
QString drawPixel(const QPoint &pixel) const override
Returns ANSI-encoded string, used by Screen to draw the pixel.
Definition: tglabel.cpp:38
Tg::Label::init
void init() override
Initializes Widget and it's connections.
Definition: tglabel.cpp:102
Tg
All Terminal GUI classes (both core and widgets) are defined within the Tg namespace.
Definition: tgcolor.h:6
Tg::Widget
Base class for all widgets in a Terminal Gui application.
Definition: tgwidget.h:64
Tg::Widget::screen
Screen * screen() const
Returns the Screen on which this Widget is being drawn.
Definition: tgwidget.cpp:174
Tg::Label
Definition: tglabel.h:7