libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
TuiWidget Class Reference

Base class for all TUI widgets. More...

#include <widget.h>

Inheritance diagram for TuiWidget:
Collaboration diagram for TuiWidget:

Public Member Functions

 TuiWidget (ObjectBase *parent=nullptr)
 Constructs a TuiWidget.
 
virtual ~TuiWidget ()
 Destructor.
 
const Rect2Di32geometry () const
 Returns the geometry relative to parent.
 
void setGeometry (const Rect2Di32 &rect)
 Sets the geometry.
 
int x () const
 Returns the X coordinate relative to parent.
 
int y () const
 Returns the Y coordinate relative to parent.
 
int width () const
 Returns the width.
 
int height () const
 Returns the height.
 
Size2Di32 size () const
 Returns the size.
 
const Size2Di32minimumSize () const
 Returns the minimum size constraint.
 
void setMinimumSize (const Size2Di32 &size)
 Sets the minimum size constraint.
 
const Size2Di32maximumSize () const
 Returns the maximum size constraint.
 
void setMaximumSize (const Size2Di32 &size)
 Sets the maximum size constraint.
 
TuiSizePolicy sizePolicy () const
 Returns the size policy.
 
void setSizePolicy (TuiSizePolicy policy)
 Sets the size policy.
 
bool isVisible () const
 Returns true if the widget's own visibility flag is set.
 
bool isEffectivelyVisible () const
 Returns true if the widget and all its ancestors are visible.
 
void show ()
 Shows the widget.
 
void hide ()
 Hides the widget.
 
void setVisible (bool visible)
 Sets visibility.
 
bool isEnabled () const
 Returns true if the widget is enabled.
 
void setEnabled (bool enabled)
 Sets enabled state.
 
TuiFocusPolicy focusPolicy () const
 Returns the focus policy.
 
void setFocusPolicy (TuiFocusPolicy policy)
 Sets the focus policy.
 
bool hasFocus () const
 Returns true if this widget has focus.
 
void setFocus ()
 Requests focus for this widget.
 
void update ()
 Marks the widget as needing a repaint.
 
bool isDirty () const
 Returns true if the widget needs repainting.
 
void clearDirty ()
 Clears the dirty flag.
 
TuiLayoutlayout () const
 Returns the layout, if one is set.
 
void setLayout (TuiLayout *layout)
 Sets the layout for this widget.
 
Point2Di32 mapToParent (const Point2Di32 &p) const
 Maps a local point to the parent's coordinate system.
 
Point2Di32 mapFromParent (const Point2Di32 &p) const
 Maps a parent point to local coordinates.
 
Point2Di32 mapToGlobal (const Point2Di32 &p) const
 Maps a local point to global (screen) coordinates.
 
Point2Di32 mapFromGlobal (const Point2Di32 &p) const
 Maps a global (screen) point to local coordinates.
 
virtual Size2Di32 sizeHint () const
 Returns the preferred size. Override in subclasses.
 
virtual Size2Di32 minimumSizeHint () const
 Returns the minimum size hint. Override in subclasses.
 
- Public Member Functions inherited from ObjectBase
 ObjectBase (ObjectBase *p=nullptr)
 Default ObjectBase constructor.
 
virtual ~ObjectBase ()
 Destructor. Emits aboutToDestroy, detaches from parent, and destroys children.
 
ObjectBaseparent () const
 Returns the parent object, if one. nullptr if none.
 
void setParent (ObjectBase *p)
 Sets the parent of this object. If the object already has a parent, it will be removed as a child from the old parent and added as a child to the new one.
 
const ObjectBaseListchildList () const
 Returns a list of children of this object.
 
template<typename... Args>
int registerSlot (Slot< Args... > *slot)
 Registers a slot with this object and assigns it an ID.
 
EventLoopeventLoop () const
 Returns the EventLoop this object is affiliated with.
 
void moveToThread (EventLoop *loop)
 Changes the EventLoop affinity of this object.
 
int startTimer (unsigned int intervalMs, bool singleShot=false)
 Starts a timer on this object's EventLoop.
 
void stopTimer (int timerId)
 Stops a timer previously started with startTimer().
 
template<typename... Args>
PROMEKI_NAMESPACE_BEGIN void connect (Signal< Args... > *signal, Slot< Args... > *slot)
 

Protected Member Functions

virtual void paintEvent (TuiPaintEvent *e)
 Called to paint the widget. Override in subclasses.
 
virtual void keyEvent (KeyEvent *e)
 Called on keyboard input. Override in subclasses.
 
virtual void mouseEvent (MouseEvent *e)
 Called on mouse input. Override in subclasses.
 
virtual void resizeEvent (TuiResizeEvent *e)
 Called when the widget is resized. Override in subclasses.
 
virtual void focusInEvent (Event *e)
 Called when the widget gains focus.
 
virtual void focusOutEvent (Event *e)
 Called when the widget loses focus.
 
void event (Event *e) override
 Event dispatch override.
 
- Protected Member Functions inherited from ObjectBase
ObjectBasesignalSender ()
 Returns the ObjectBase that emitted the signal currently being handled.
 
virtual void timerEvent (TimerEvent *e)
 Called when a timer fires for this object.
 

Friends

class TuiApplication
 

Additional Inherited Members

- Public Types inherited from ObjectBase
using SlotVariantFunc = std::function< void(const VariantList &)>
 Function type for invoking a slot with a list of Variants.
 
- Static Public Member Functions inherited from ObjectBase
static const MetaInfometaInfo ()
 Returns the MetaInfo for the ObjectBase class.
 
template<typename... Args>
static void connect (Signal< Args... > *signal, Slot< Args... > *slot)
 connects a signal and slot together. This function assumes both the signal and slot exist in a ObjectBase or derived object
 
- Public Attributes inherited from ObjectBase
Signal< ObjectBase * > aboutToDestroySignal = Signal< ObjectBase * >(this, aboutToDestroySignalName)
 
- Static Public Attributes inherited from ObjectBase
static constexpr const charaboutToDestroySignalName = PROMEKI_STRINGIFY( aboutToDestroy ) "(" PROMEKI_STRINGIFY_ARGS( ObjectBase * ) ")"
 
static SignalMeta aboutToDestroySignalMeta = SignalMeta(metaInfo(), aboutToDestroySignalName)
 

Detailed Description

Base class for all TUI widgets.

Derives from ObjectBase to inherit signals/slots, parent/child relationships, event dispatch, and timer support. Provides geometry management, focus handling, visibility control, and virtual methods

Example
class MyWidget : public TuiWidget {
protected:
void paintEvent(TuiPaintEvent *) override {
Painter p(this);
p.drawText(0, 0, "Hello, TUI!");
}
};
Dynamic array container wrapping std::vector.
Definition list.h:40
Event delivered when a TUI widget needs to repaint.
Definition widget.h:28
Base class for all TUI widgets.
Definition widget.h:88
for paint/key/mouse/resize events.

Constructor & Destructor Documentation

◆ TuiWidget()

TuiWidget::TuiWidget ( ObjectBase parent = nullptr)

Constructs a TuiWidget.

Parameters
parentOptional parent widget.

Member Function Documentation

◆ event()

void TuiWidget::event ( Event e)
overrideprotectedvirtual

Event dispatch override.

Reimplemented from ObjectBase.

◆ focusInEvent()

virtual void TuiWidget::focusInEvent ( Event e)
protectedvirtual

Called when the widget gains focus.

Reimplemented in TuiButton, TuiCheckBox, TuiLineEdit, and TuiTabWidget.

◆ focusOutEvent()

virtual void TuiWidget::focusOutEvent ( Event e)
protectedvirtual

Called when the widget loses focus.

Reimplemented in TuiButton, TuiCheckBox, TuiLineEdit, and TuiTabWidget.

◆ isEffectivelyVisible()

bool TuiWidget::isEffectivelyVisible ( ) const

Returns true if the widget and all its ancestors are visible.

A widget is effectively visible only if its own visibility flag is set AND every TuiWidget ancestor is also visible.

◆ keyEvent()

virtual void TuiWidget::keyEvent ( KeyEvent e)
protectedvirtual

Called on keyboard input. Override in subclasses.

Reimplemented in TuiButton, TuiCheckBox, TuiLineEdit, TuiListView, TuiMenu, TuiMenuBar, TuiScrollArea, TuiSplitter, TuiTabWidget, and TuiTextArea.

◆ minimumSizeHint()

virtual Size2Di32 TuiWidget::minimumSizeHint ( ) const
virtual

Returns the minimum size hint. Override in subclasses.

Reimplemented in TuiButton.

◆ mouseEvent()

virtual void TuiWidget::mouseEvent ( MouseEvent e)
protectedvirtual

Called on mouse input. Override in subclasses.

Reimplemented in TuiButton, TuiCheckBox, TuiListView, TuiSplitter, and TuiTabWidget.

◆ paintEvent()

virtual void TuiWidget::paintEvent ( TuiPaintEvent e)
protectedvirtual

Called to paint the widget. Override in subclasses.

Reimplemented in TuiButton, TuiCheckBox, TuiFrame, TuiLabel, TuiLineEdit, TuiListView, TuiMenu, TuiMenuBar, TuiProgressBar, TuiScrollArea, TuiSplitter, TuiStatusBar, TuiTabWidget, and TuiTextArea.

◆ resizeEvent()

virtual void TuiWidget::resizeEvent ( TuiResizeEvent e)
protectedvirtual

Called when the widget is resized. Override in subclasses.

Reimplemented in TuiFrame, TuiScrollArea, TuiSplitter, and TuiTabWidget.

◆ sizeHint()

virtual Size2Di32 TuiWidget::sizeHint ( ) const
virtual

Returns the preferred size. Override in subclasses.

Reimplemented in TuiButton, TuiCheckBox, TuiFrame, TuiLabel, TuiLineEdit, TuiListView, TuiMenu, TuiMenuBar, TuiProgressBar, TuiScrollArea, TuiSplitter, TuiStatusBar, TuiTabWidget, and TuiTextArea.


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