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

#include <Widget.hpp>

Inheritance diagram for Widget:
ImageAboutWindow ImageButton ImageKnob ImageSlider ImageSwitch NanoWidget

Classes

struct  BaseEvent
 
struct  KeyboardEvent
 
struct  MotionEvent
 
struct  MouseEvent
 
struct  ResizeEvent
 
struct  ScrollEvent
 
struct  SpecialEvent
 

Public Member Functions

 Widget (Window &parent)
 
virtual ~Widget ()
 
bool isVisible () const noexcept
 
void setVisible (bool yesNo)
 
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
 
int getAbsoluteX () const noexcept
 
int getAbsoluteY () const noexcept
 
const Point< int > & getAbsolutePos () const noexcept
 
void setAbsoluteX (int x) noexcept
 
void setAbsoluteY (int y) noexcept
 
void setAbsolutePos (int x, int y) noexcept
 
void setAbsolutePos (const Point< int > &pos) noexcept
 
AppgetParentApp () const noexcept
 
WindowgetParentWindow () const noexcept
 
bool contains (int x, int y) const noexcept
 
bool contains (const Point< int > &pos) const noexcept
 
void repaint () noexcept
 
uint getId () const noexcept
 
void setId (uint id) noexcept
 

Protected Member Functions

virtual void onDisplay ()=0
 
virtual bool onKeyboard (const KeyboardEvent &)
 
virtual bool onSpecial (const SpecialEvent &)
 
virtual bool onMouse (const MouseEvent &)
 
virtual bool onMotion (const MotionEvent &)
 
virtual bool onScroll (const ScrollEvent &)
 
virtual void onResize (const ResizeEvent &)
 
void setNeedsFullViewport (bool yesNo) noexcept
 
void setNeedsScaling (bool yesNo) noexcept
 

Friends

class Window
 
class StandaloneWindow
 

Detailed Description

Base DGL Widget class.

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

All widgets have a parent Window where they'll be drawn. This parent is never changed during the widget lifetime.

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

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

All widget event callbacks do nothing by default.

Constructor & Destructor Documentation

Widget::Widget ( Window parent)
explicit

Constructor.

virtual Widget::~Widget ( )
virtual

Destructor.

Member Function Documentation

bool Widget::isVisible ( ) const
noexcept

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

void Widget::setVisible ( bool  yesNo)

Set widget visible (or not) according to yesNo.

void Widget::show ( )

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

void Widget::hide ( )

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

uint Widget::getWidth ( ) const
noexcept

Get width.

uint Widget::getHeight ( ) const
noexcept

Get height.

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

Get size.

void Widget::setWidth ( uint  width)
noexcept

Set width.

void Widget::setHeight ( uint  height)
noexcept

Set height.

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

Set size using width and height values.

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

Set size.

int Widget::getAbsoluteX ( ) const
noexcept

Get absolute X.

int Widget::getAbsoluteY ( ) const
noexcept

Get absolute Y.

const Point<int>& Widget::getAbsolutePos ( ) const
noexcept

Get absolute position.

void Widget::setAbsoluteX ( int  x)
noexcept

Set absolute X.

void Widget::setAbsoluteY ( int  y)
noexcept

Set absolute Y.

void Widget::setAbsolutePos ( int  x,
int  y 
)
noexcept

Set absolute position using x and y values.

void Widget::setAbsolutePos ( const Point< int > &  pos)
noexcept

Set absolute position.

App& Widget::getParentApp ( ) const
noexcept

Get this widget's window application. Same as calling getParentWindow().getApp().

Window& Widget::getParentWindow ( ) const
noexcept

Get parent window, as passed in the constructor.

bool Widget::contains ( int  x,
int  y 
) const
noexcept

Check if this widget contains the point defined by x and y.

bool Widget::contains ( const Point< int > &  pos) const
noexcept

Check if this widget contains the point pos.

void Widget::repaint ( )
noexcept

Tell this widget's window to repaint itself.

uint Widget::getId ( ) const
noexcept

Get the Id associated with this widget.

See also
setId
void Widget::setId ( uint  id)
noexcept

Set an Id to be associated with this widget.

See also
getId
virtual void Widget::onDisplay ( )
protectedpure virtual

A function called to draw the view contents with OpenGL.

Implemented in ImageKnob, ImageSlider, ImageSwitch, ImageButton, and ImageAboutWindow.

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 ImageAboutWindow.

virtual bool Widget::onSpecial ( const SpecialEvent )
protectedvirtual

A function called when a special key is pressed or released.

Returns
True to stop event propagation, false otherwise.
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 ImageKnob, ImageSlider, ImageSwitch, ImageButton, and ImageAboutWindow.

virtual bool Widget::onMotion ( const MotionEvent )
protectedvirtual

A function called when the pointer moves.

Returns
True to stop event propagation, false otherwise.

Reimplemented in ImageKnob, ImageSlider, and ImageButton.

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 ImageKnob.

virtual void Widget::onResize ( const ResizeEvent )
protectedvirtual

A function called when the widget is resized.

void Widget::setNeedsFullViewport ( bool  yesNo)
protectednoexcept

Tell the parent window this widget needs the full viewport. When enabled, the local widget coordinates are ignored.

Note
: This is an internal function; You do not need it under normal circumstances.
void Widget::setNeedsScaling ( bool  yesNo)
protectednoexcept

Tell the parent window this widget needs scaling. When enabled, the widget viewport is scaled to match width and height.

Note
: This is an internal function; You do not need it under normal circumstances.

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