#include <Widget.hpp>
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 |
App & | getParentApp () const noexcept |
Window & | getParentWindow () 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 |
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.
|
explicit |
Constructor.
|
virtual |
Destructor.
|
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).
|
noexcept |
Get width.
|
noexcept |
Get height.
|
noexcept |
Get size.
|
noexcept |
Set width.
|
noexcept |
Set height.
|
noexcept |
Set size using width and height values.
|
noexcept |
Set size.
|
noexcept |
Get absolute X.
|
noexcept |
Get absolute Y.
|
noexcept |
Get absolute position.
|
noexcept |
Set absolute X.
|
noexcept |
Set absolute Y.
|
noexcept |
Set absolute position using x and y values.
|
noexcept |
Set absolute position.
|
noexcept |
Get this widget's window application. Same as calling getParentWindow().getApp().
|
noexcept |
Get parent window, as passed in the constructor.
|
noexcept |
Check if this widget contains the point defined by x and y.
|
noexcept |
Check if this widget contains the point pos.
|
noexcept |
Tell this widget's window to repaint itself.
|
noexcept |
Get the Id associated with this widget.
|
noexcept |
Set an Id to be associated with this widget.
|
protectedpure virtual |
A function called to draw the view contents with OpenGL.
Implemented in ImageKnob, ImageSlider, ImageSwitch, ImageButton, and ImageAboutWindow.
|
protectedvirtual |
A function called when a key is pressed or released.
Reimplemented in ImageAboutWindow.
|
protectedvirtual |
A function called when a special key is pressed or released.
|
protectedvirtual |
A function called when a mouse button is pressed or released.
Reimplemented in ImageKnob, ImageSlider, ImageSwitch, ImageButton, and ImageAboutWindow.
|
protectedvirtual |
A function called when the pointer moves.
Reimplemented in ImageKnob, ImageSlider, and ImageButton.
|
protectedvirtual |
A function called on scrolling (e.g. mouse wheel or track pad).
Reimplemented in ImageKnob.
|
protectedvirtual |
A function called when the widget is resized.
|
protectednoexcept |
Tell the parent window this widget needs the full viewport. When enabled, the local widget coordinates are ignored.
|
protectednoexcept |
Tell the parent window this widget needs scaling. When enabled, the widget viewport is scaled to match width and height.