DISTRHO Plugin Framework
Classes | Public Member Functions | Protected Member Functions | Friends | List of all members
Widget Class Referenceabstract

#include <Widget.hpp>

Inheritance diagram for Widget:
SubWidget TopLevelWidget ImageBaseButton< ImageType > ImageBaseKnob< ImageType > ImageBaseSlider< ImageType > ImageBaseSwitch< ImageType > StandaloneWindow ImageBaseAboutWindow< ImageType >

Classes

struct  BaseEvent
 
struct  CharacterInputEvent
 
struct  KeyboardEvent
 
struct  MotionEvent
 
struct  MouseEvent
 
struct  PositionChangedEvent
 
struct  ResizeEvent
 
struct  ScrollEvent
 

Public Member Functions

virtual ~Widget ()
 
bool isVisible () const noexcept
 
void setVisible (bool visible)
 
void show ()
 
void hide ()
 
uint getWidth () const noexcept
 
uint getHeight () const noexcept
 
const Size< uint > getSize () const noexcept
 
void setWidth (uint width) noexcept
 
void setHeight (uint height) noexcept
 
void setSize (uint width, uint height) noexcept
 
void setSize (const Size< uint > &size) noexcept
 
uint getId () const noexcept
 
const char * getName () const noexcept
 
void setId (uint id) noexcept
 
void setName (const char *name) noexcept
 
ApplicationgetApp () const noexcept
 
WindowgetWindow () const noexcept
 
const GraphicsContextgetGraphicsContext () const noexcept
 
TopLevelWidgetgetTopLevelWidget () const noexcept
 
std::list< SubWidget * > getChildren () const noexcept
 
virtual void repaint () noexcept
 
ApplicationgetParentApp () const noexcept
 
WindowgetParentWindow () const noexcept
 

Protected Member Functions

virtual void onDisplay ()=0
 
virtual bool onKeyboard (const KeyboardEvent &)
 
virtual bool onCharacterInput (const CharacterInputEvent &)
 
virtual bool onMouse (const MouseEvent &)
 
virtual bool onMotion (const MotionEvent &)
 
virtual bool onScroll (const ScrollEvent &)
 
virtual void onResize (const ResizeEvent &)
 
virtual bool onSpecial (const SpecialEvent &)
 

Friends

class SubWidget
 
class TopLevelWidget
 

Detailed Description

Base DGL Widget class.

This is the base Widget class, from which all widgets are built.

All widgets have a parent widget where they'll be drawn, this can be the top-level widget or a group widget. This parent is never changed during a widget's lifetime.

Widgets receive events in relative coordinates. (0, 0) means its top-left position.

The top-level widget will draw subwidgets in the order they are constructed. Early subwidgets are drawn first, at the bottom, then newer ones on top. Events are sent in the inverse order so that the top-most widgets get a chance to catch the event and stop its propagation.

All widget event callbacks do nothing by default and onDisplay MUST be reimplemented by subclasses.

Note
It is not possible to subclass this Widget class directly, you must use SubWidget or TopLevelWidget instead.

Constructor & Destructor Documentation

◆ ~Widget()

virtual Widget::~Widget ( )
virtual

Destructor.

Member Function Documentation

◆ isVisible()

bool Widget::isVisible ( ) const
noexcept

Check if this widget is visible within its parent window. Invisible widgets do not receive events except resize.

◆ setVisible()

void Widget::setVisible ( bool  visible)

Set widget visible (or not) according to visible.

◆ show()

void Widget::show ( )

Show widget. This is the same as calling setVisible(true).

◆ hide()

void Widget::hide ( )

Hide widget. This is the same as calling setVisible(false).

◆ getWidth()

uint Widget::getWidth ( ) const
noexcept

Get width.

◆ getHeight()

uint Widget::getHeight ( ) const
noexcept

Get height.

◆ getSize()

const Size<uint> Widget::getSize ( ) const
noexcept

Get size.

◆ setWidth()

void Widget::setWidth ( uint  width)
noexcept

Set width.

◆ setHeight()

void Widget::setHeight ( uint  height)
noexcept

Set height.

◆ setSize() [1/2]

void Widget::setSize ( uint  width,
uint  height 
)
noexcept

Set size using width and height values.

◆ setSize() [2/2]

void Widget::setSize ( const Size< uint > &  size)
noexcept

Set size.

◆ getId()

uint Widget::getId ( ) const
noexcept

Get the Id associated with this widget. Returns 0 by default.

See also
setId

◆ getName()

const char* Widget::getName ( ) const
noexcept

Get the name associated with this widget. This is complately optional, mostly useful for debugging purposes. Returns an empty string by default.

See also
setName

◆ setId()

void Widget::setId ( uint  id)
noexcept

Set an Id to be associated with this widget.

See also
getId

◆ setName()

void Widget::setName ( const char *  name)
noexcept

Set a name to be associated with this widget. This is complately optional, only useful for debugging purposes.

Note
name must not be null
See also
getName

◆ getApp()

Application& Widget::getApp ( ) const
noexcept

Get the application associated with this widget's window. This is the same as calling getTopLevelWidget()->getApp().

◆ getWindow()

Window& Widget::getWindow ( ) const
noexcept

Get the window associated with this widget. This is the same as calling getTopLevelWidget()->getWindow().

◆ getGraphicsContext()

const GraphicsContext& Widget::getGraphicsContext ( ) const
noexcept

Get the graphics context associated with this widget's window. GraphicsContext is an empty struct and needs to be casted into a different type in order to be usable, for example GraphicsContext.

See also
CairoSubWidget, CairoTopLevelWidget

◆ getTopLevelWidget()

TopLevelWidget* Widget::getTopLevelWidget ( ) const
noexcept

Get top-level widget, as passed directly in the constructor or going up the chain of group widgets until it finds the top-level one.

◆ getChildren()

std::list<SubWidget*> Widget::getChildren ( ) const
noexcept

Get list of children (a subwidgets) that belong to this widget.

◆ repaint()

virtual void Widget::repaint ( )
virtualnoexcept

Request repaint of this widget's area to the window this widget belongs to. On the raw Widget class this function does nothing.

Reimplemented in TopLevelWidget, SubWidget, and StandaloneWindow.

◆ onDisplay()

virtual void Widget::onDisplay ( )
protectedpure virtual

◆ onKeyboard()

virtual bool Widget::onKeyboard ( const KeyboardEvent )
protectedvirtual

A function called when a key is pressed or released.

Returns
True to stop event propagation, false otherwise.

Reimplemented in TopLevelWidget, and ImageBaseAboutWindow< ImageType >.

◆ onCharacterInput()

virtual bool Widget::onCharacterInput ( const CharacterInputEvent )
protectedvirtual

A function called when an UTF-8 character is received.

Returns
True to stop event propagation, false otherwise.

Reimplemented in TopLevelWidget.

◆ onMouse()

virtual bool Widget::onMouse ( const MouseEvent )
protectedvirtual

A function called when a mouse button is pressed or released.

Returns
True to stop event propagation, false otherwise.

Reimplemented in TopLevelWidget, ImageBaseSwitch< ImageType >, ImageBaseSlider< ImageType >, ImageBaseKnob< ImageType >, ImageBaseButton< ImageType >, and ImageBaseAboutWindow< ImageType >.

◆ onMotion()

virtual bool Widget::onMotion ( const MotionEvent )
protectedvirtual

A function called when the pointer moves.

Returns
True to stop event propagation, false otherwise.

Reimplemented in TopLevelWidget, ImageBaseSlider< ImageType >, ImageBaseKnob< ImageType >, and ImageBaseButton< ImageType >.

◆ onScroll()

virtual bool Widget::onScroll ( const ScrollEvent )
protectedvirtual

A function called on scrolling (e.g. mouse wheel or track pad).

Returns
True to stop event propagation, false otherwise.

Reimplemented in TopLevelWidget, and ImageBaseKnob< ImageType >.

◆ onResize()

virtual void Widget::onResize ( const ResizeEvent )
protectedvirtual

A function called when the widget is resized.

◆ onSpecial()

virtual bool Widget::onSpecial ( const SpecialEvent &  )
inlineprotectedvirtual

A function called when a special key is pressed or released. DEPRECATED use onKeyboard or onCharacterInput


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