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 | Properties | Friends | List of all members
Tg::Screen Class Reference

Screen is the "canvas" on which widgets (subclasses of Widget) are drawn. More...

#include <tgscreen.h>

Inheritance diagram for Tg::Screen:
Inheritance graph
[legend]
Collaboration diagram for Tg::Screen:
Collaboration graph
[legend]

Public Slots

void scheduleRedraw (const RedrawType type, const Widget *widget)
 Schedules a redraw of widget using type. More...
 
void moveFocusToPreviousWidget ()
 Finds next Widget ready to accept keyboard focus and moves the focus to it. More...
 
void moveFocusToNextWidget ()
 Finds previous Widget ready to accept keyboard focus and moves the focus to it. More...
 
void setCanDragWidgets (const bool canDragWidgets)
 

Signals

void sizeChanged (const QSize &size) const
 Emitted when Screen's size is modified.
 
void canDragWidgetsChanged (const bool canDragWidgets) const
 

Public Member Functions

 Screen (QObject *parent=nullptr, const StylePointer &style=nullptr)
 Constructs a Screen. More...
 
QSize size () const
 Returns the size of this Screen. More...
 
StylePointer style () const
 Returns the default style, shared with all Widget instances.
 
bool canDragWidgets () const
 

Properties

QSize size
 Size of the Screen. More...
 
bool canDragWidgets
 When true, widgets can be dragged around on the Screen using a mouse. More...
 

Friends

class Widget
 

Detailed Description

Screen is the "canvas" on which widgets (subclasses of Widget) are drawn.

Every top-level Widget needs to be a child of Screen. This is done using Widget constructor, which internally calls registerWidget(). When a Widget is deleted, deregisterWidget() is called to notify the Screen.

Internally, Screen uses Terminal to know available space, and to interact with the console.

Constructor & Destructor Documentation

◆ Screen()

Tg::Screen::Screen ( QObject *  parent = nullptr,
const StylePointer style = nullptr 
)

Constructs a Screen.

A Screen is parent for all Widget objects drawn within it's size(). parent is usually nullptr.

style object will be used as base style of all widgets registered under this Screen. If nullptr is passed, a default Style will be constructed.

Member Function Documentation

◆ moveFocusToNextWidget

void Tg::Screen::moveFocusToNextWidget ( )
slot

Finds previous Widget ready to accept keyboard focus and moves the focus to it.

See Widget::setAcceptsFocus().

◆ moveFocusToPreviousWidget

void Tg::Screen::moveFocusToPreviousWidget ( )
slot

Finds next Widget ready to accept keyboard focus and moves the focus to it.

See Widget::setAcceptsFocus().

◆ scheduleRedraw

void Tg::Screen::scheduleRedraw ( const RedrawType  type,
const Widget widget 
)
slot

Schedules a redraw of widget using type.

Draw operations are not performed immediately, but rather use compressRedraws() to only draw Screen changes once in a while.

To force an immedate redraw, call draw().

See also
draw, compressRedraws

◆ size()

QSize Tg::Screen::size ( ) const

Returns the size of this Screen.

Note
Screen size might be different than terminal window size.

Property Documentation

◆ canDragWidgets

bool Tg::Screen::canDragWidgets
readwrite

When true, widgets can be dragged around on the Screen using a mouse.

To drag, click and hold your mouse over Widget's border, then move the mouse.

◆ size

QSize Tg::Screen::size
read

Size of the Screen.

This can be different than size of the actual terminal window (for example, you can have 2 screens drawn in a single terminal).

Warning
More than one Screen is not yet supported. Sorry!
Todo:
Differentiate between Terminal size and size of screen reserved for application

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