terminalgui  0.1.0
Widgets for your terminal, powered by Qt! Create textual GUI (TUI) in your console easily.
Public Slots | Signals | Public Member Functions | Protected Member Functions | Properties | List of all members
Tg::Label Class Reference
Inheritance diagram for Tg::Label:
Inheritance graph
[legend]
Collaboration diagram for Tg::Label:
Collaboration graph
[legend]

Public Slots

void setText (const QString &text, const bool expand=false)
 
void setHighlighted (const bool highlighted)
 
- Public Slots inherited from Tg::Widget
void setPosition (const QPoint &position)
 Moves Widget to a new position. More...
 
void setSize (const QSize &size)
 Resizes Widget to a new size.
 
void setBackgroundColor (const Tg::Color &color)
 Changes background color.
 
void setBackgroundCharacter (const QChar &character)
 Changes character drawn in the empty space of this Widget.
 
void setTextColor (const Tg::Color &color)
 Changes text color.
 
void setBorderTextColor (const Tg::Color &color)
 Changes border text color.
 
void setBorderBackgroundColor (const Tg::Color &color)
 Changes border background color.
 
void setVisible (const bool visible)
 Makes Widget visible (or not). More...
 
void show ()
 Makes Widget visible. More...
 
void hide ()
 Makes Widget hidden. More...
 
void setBorderVisible (const bool visible)
 Makes Widget's border visible (or not).
 
void setZ (const int z)
 
WidgetList childrenWidgets () const
 Returns all children of this Widget which can be cast to Widget.
 

Signals

void textChanged (const QString &text) const
 
void highlightedChanged (const bool highlighted) const
 
- Signals inherited from Tg::Widget
void needsRedraw (const RedrawType type, const Widget *widget) const
 Indicates that widget (usually this) needs to be redrawn using redraw type.
 
void positionChanged (const QPoint &position) const
 Emitted when Widget's position changes.
 
void sizeChanged (const QSize &size) const
 Emitted when Widget's size is changed.
 
void backgroundColorChanged (const Tg::Color &color) const
 Indicates that Widget's background color has changed.
 
void backgroundCharacterChanged (const QChar &character) const
 Indicates that Widget's background character has changed.
 
void textColorChanged (const Tg::Color &color) const
 Indicates that Widget's text color has changed.
 
void borderTextColorChanged (const Tg::Color &color) const
 Indicates that Widget's border text color has changed.
 
void borderBackgroundColorChanged (const Tg::Color &color) const
 Indicates that Widget's border background color has changed.
 
void visibleChanged (const bool visible) const
 Indicates that Widget is shown or hidden (depening on visible).
 
void borderVisibleChanged (const bool visible) const
 Indicates that Widget's border is now visible (or not).
 
void acceptsFocusChanged (const bool accepts) const
 Indicates that Widget now accepts focus (or not).
 
void hasFocusChanged (const bool hasFocus) const
 Indicates that Widget now hasFocus (or not).
 
void moveFocusToPreviousWidget () const
 Indicates that active focus should be moved to the previous Widget ready to receive it.
 
void moveFocusToNextWidget () const
 Indicates that active focus should be moved to the next Widget ready to receive it.
 
void propagatesStyleChanged (const bool propagates) const
 Indicates that Widget either stopped or resumed (propagates) propagating its Style object to its children.
 
void styleChanged () const
 Emitted when Widget's Style object is changed.
 
void layoutOvershootChanged (const SizeOvershoot overshoot) const
 Emitted when layout overshoot has changed.
 
void widgetOvershootChanged (const SizeOvershoot overshoot) const
 Emitted when Widget overshoot has changed.
 
void childAdded (Widget *child) const
 Emitted when a child Widget has been added.
 
void childRemoved () const
 Emitted when a child Widget has been removed.
 
void zChanged (const int z) const
 Emitted when z value changes.
 

Public Member Functions

 Label (Widget *parent)
 
 Label (Screen *screen)
 
 Label (const QString &text=QString(), Widget *parent=nullptr)
 
 Label (const QString &text=QString(), Screen *screen=nullptr)
 
QString text () const
 
bool highlighted () const
 
- Public Member Functions inherited from Tg::Widget
 Widget (Widget *parent)
 Constructs Widget as a child of parent. More...
 
 Widget (Screen *screen)
 Constructs a top-level Widget on a given screen. More...
 
 ~Widget ()
 Deregisters the Widget from parent Screen, then destroys the Widget object.
 
QPoint position () const
 Returns current position of the Widget (relative). More...
 
QSize size () const
 Returns current size of the Widget. More...
 
QRect boundingRectangle () const
 Returns the rectangle constructed from position() and size(). More...
 
QRect globalBoundingRectangle () const
 Returns the rectangle contructed from position() (mapped to global coordinates using mapToGlobal()) and size(). More...
 
QRect contentsRectangle () const
 Returns the rectangle which holds Widget interior. More...
 
Tg::Color backgroundColor () const
 Returns current background color - either taken from Style or value set using setBackgroundColor(). More...
 
QChar backgroundCharacter () const
 Returns character drawn on empty space in this Widget.
 
Tg::Color textColor () const
 Returns current text color - either taken from Style or value set using setTextColor(). More...
 
Tg::Color borderTextColor () const
 Returns current border text color - either taken from Style or value set using setBorderTextColor(). More...
 
Tg::Color borderBackgroundColor () const
 Returns current border background color - either taken from Style or value set using setBorderBackgroundColor(). More...
 
bool visible () const
 Returns true when Widget is visible.
 
bool borderVisible () const
 Returns true when Widget's border is visible. More...
 
bool acceptsFocus () const
 Returns true when Widget is set to accept focus (keyboard or mouse). More...
 
bool hasFocus () const
 Returns true when Widget actively holds focus (is receiving keyboard events). More...
 
void setAcceptsFocus (const bool accept)
 When accept is true, this Widget will receive keyboard events from Screen instance - but only when it actively holds focus (see hasFocus()). More...
 
Screenscreen () const
 Returns the Screen on which this Widget is being drawn.
 
WidgetparentWidget () const
 Returns the parent Widget. More...
 
WidgettopLevelParentWidget () const
 Returns top-level parent of current Widget. More...
 
bool isTopLevel () const
 Returns true if this Widget is top-level. More...
 
bool isBorder (const QPoint &pixel) const
 Returns true when pixel lies within the border of the Widget. More...
 
bool verticalArrowsMoveFocus () const
 Returns true if this Widget ignores up and down arrows on keyboard. More...
 
QPoint mapFromGlobal (const QPoint &position) const
 Returns position mapped from global coordinates into local one (coordinates within the Widget, where (0,0) is top-left corner).
 
QPoint mapToGlobal (const QPoint &position) const
 Returns position mapped from local coordinates into global ones (coordinates within parent Screen).
 
QPoint mapToChild (const WidgetPointer &child, const QPoint &position) const
 Returns position mapped into child coordinate system.
 
bool propagatesStyle () const
 Returns true if this Widget automatically applies its Style to all children Widgets. More...
 
void setStyle (const StylePointer &style, const bool propagate=true)
 Sets a new Style on this Widget. More...
 
Layout::Type layoutType () const
 Returns Layout type. More...
 
void setLayoutType (const Layout::Type type)
 Sets the way this Widget places, paints and treats children widgets to type.
 
SizeOvershoot layoutOvershoot () const
 Returns current overshoot of layout inside this Widget. More...
 
SizeOvershoot widgetOvershoot () const
 Returns current overshoot of contents of this Widget. More...
 
int z () const
 Returns the z value - position of this Widget on z order stack.
 

Protected Member Functions

void init () override
 Initializes Widget and it's connections. More...
 
QString drawPixel (const QPoint &pixel) const override
 Returns ANSI-encoded string, used by Screen to draw the pixel. More...
 
int reservedCharactersCount () const
 
QString reservedText () const
 
void setReservedText (const QString &reserved)
 
- Protected Member Functions inherited from Tg::Widget
void setHasFocus (const bool active)
 Sets this Widget to hold active focus (or not). More...
 
virtual void consumeKeyboardBuffer (const QString &keyboardBuffer)
 Called when Widget accepts focus and keyboardBuffer is not empty. More...
 
virtual QString drawBorderPixel (const QPoint &pixel) const
 Returns ANSI-encoded string, used by Screen to draw the pixel. More...
 
QPoint previousGlobalPosition () const
 Returns Widget's last position (before it was moved), in global coordinates. More...
 
QSize previousSize () const
 Returns Widget's previous size (before it was resized). More...
 
QRect globalPreviousBoundingRectangle () const
 Returns globalBoundingRectangle() recorded last time when widget was moved or its size has been changed.
 
int effectiveBorderWidth () const
 If borders are visible, it returns border width. More...
 
void setVerticalArrowsMoveFocus (const bool enable)
 If enable is true, clicking up arrow or down arrow on keyboard will be intercepted by parent Screen and used to switch focus to previous or next Widget. More...
 
void setPropagatesStyle (const bool propagate)
 When propagate is true, this Widget will set its style() object on its children whenever it changes. More...
 
void propagateStyleToChild (Widget *child) const
 Propagates style() to child. More...
 
StylePointer style () const
 Returns the pointer to Style object used to draw this Widget. More...
 
void setWidgetOvershoot (const SizeOvershoot overshoot)
 Sets current overshoot of the contents of this Widget.
 
void setupPressTimer (QTimer *timer) const
 Sets timer object which controls how long pressed elements (buttons, scroll bar arrows, etc.) look different (pressed). More...
 
void doLayout ()
 Forces Widget to lay out its children according to layoutType(). More...
 

Properties

QString text
 
bool highlighted
 
- Properties inherited from Tg::Widget
QPoint position
 Position of Widget. More...
 
QSize size
 Size of the Widget. More...
 
int z
 Widget position on the z axis - this is used to control which Widgets should be displayed above and which below if they overlap.
 
Tg::Color backgroundColor
 Color of the background of Widget's interior (contentsRectangle()). More...
 
QChar backgroundCharacter
 This is the character which fills the empty background. More...
 
Tg::Color textColor
 Color of the characters ("foreground color") printed inside of the Widget (see contentsRectangle()). More...
 
Tg::Color borderTextColor
 Color of the characters ("foreground color") printed on the borders of the Widget (see boundingRectangle()). More...
 
Tg::Color borderBackgroundColor
 Color of the background of Widget's border (see boundingRectangle()). More...
 
bool visible
 A visible Widget is visible. More...
 
bool borderVisible
 Controls whether border is drawn. More...
 
bool acceptsFocus
 When true, Widget will receive keyboard signals (Screen will call consumeKeyboardBuffer()) when its turn comes.
 
bool hasFocus
 Returns true when Widget is currently actively listening to keyboard signals. More...
 
bool propagatesStyle
 If true, Widget will set its Style object on its children widgets. More...
 

Additional Inherited Members

- Protected Slots inherited from Tg::Widget
void scheduleFullRedraw () const
 Instructs Screen that full redraw of entire Screen area should be performed. More...
 
void schedulePartialRedraw () const
 Instructs Screen to redraw this Widget only, at its current position. More...
 
void schedulePreviousPositionRedraw () const
 Instructs Screen to redraw the area previously occupied by this Widget. More...
 

Member Function Documentation

◆ drawPixel()

QString Tg::Label::drawPixel ( const QPoint &  pixel) const
overrideprotectedvirtual

Returns ANSI-encoded string, used by Screen to draw the pixel.

"Draws" the internal contents of the Widget. Default implementation draws the border (see drawBorderPixel()), any child Widgets (if present), in accordance with layoutType(). If there is any empty space left, it is filled with backgroundCharacter().

See also
drawBorderPixel, layoutType, setLayoutType, backgroundCharacter, children

Reimplemented from Tg::Widget.

◆ init()

void Tg::Label::init ( )
overrideprotectedvirtual

Initializes Widget and it's connections.

All subclasses should call init() of its parent class. If a subclass has any properties or signals which affect the visual look of the Widget, it should reimplement init() and connect such signal to schedulePartialRedraw() slot.

See also
schedulePartialRedraw

Reimplemented from Tg::Widget.

Reimplemented in Tg::RadioButton, and Tg::LineEdit.


The documentation for this class was generated from the following files: