DISTRHO Plugin Framework
|
#include <Window.hpp>
Public Member Functions | |
Window (Application &app) | |
Window (Application &app, Window &parent) | |
Window (Application &app, uintptr_t parentWindowHandle, double scaleFactor, bool resizable) | |
Window (Application &app, uintptr_t parentWindowHandle, uint width, uint height, double scaleFactor, bool resizable) | |
virtual | ~Window () |
bool | isEmbed () const noexcept |
bool | isVisible () const noexcept |
void | setVisible (bool visible) |
void | show () |
void | hide () |
void | close () |
bool | isResizable () const noexcept |
void | setResizable (bool resizable) |
uint | getWidth () const noexcept |
uint | getHeight () const noexcept |
Size< uint > | getSize () const noexcept |
void | setWidth (uint width) |
void | setHeight (uint height) |
void | setSize (uint width, uint height) |
void | setSize (const Size< uint > &size) |
const char * | getTitle () const noexcept |
void | setTitle (const char *title) |
bool | isIgnoringKeyRepeat () const noexcept |
void | setIgnoringKeyRepeat (bool ignore) noexcept |
bool | addIdleCallback (IdleCallback *callback, uint timerFrequencyInMs=0) |
bool | removeIdleCallback (IdleCallback *callback) |
Application & | getApp () const noexcept |
const GraphicsContext & | getGraphicsContext () const noexcept |
uintptr_t | getNativeWindowHandle () const noexcept |
double | getScaleFactor () const noexcept |
void | focus () |
void | repaint () noexcept |
void | repaint (const Rectangle< uint > &rect) noexcept |
void | runAsModal (bool blockWait=false) |
void | setGeometryConstraints (uint minimumWidth, uint minimumHeight, bool keepAspectRatio=false, bool automaticallyScale=false) |
bool | getIgnoringKeyRepeat () const noexcept |
double | getScaling () const noexcept |
void | exec (bool blockWait=false) |
Protected Member Functions | |
virtual bool | onClose () |
virtual void | onFocus (bool focus, CrossingMode mode) |
virtual void | onReshape (uint width, uint height) |
Friends | |
class | Application |
class | TopLevelWidget |
DGL Window class.
This is the where all OS-related events initially happen, before being propagated to any widgets.
A Window MUST have an Application instance tied to it. It is not possible to swap Application instances from within the lifetime of a Window. But it is possible to completely change the Widgets that a Window contains during its lifetime.
Typically the event handling functions as following: Application -> Window -> Top-Level-Widget -> SubWidgets
Please note that, unlike many other graphical toolkits out there, DGL makes a clear distinction between a Window and a Widget. You cannot directly draw in a Window, you need to create a Widget for that.
Also, a Window MUST have a single top-level Widget. The Window will take care of global screen positioning and resizing, everything else is sent for widgets to handle.
...
|
explicit |
Constructor for a regular, standalone window.
|
explicit |
Constructor for a modal window, by having another window as its parent. The Application instance must be the same between the 2 windows.
|
explicit |
Constructor for an embed Window without known size, typically used in modules or plugins that run inside another host.
|
explicit |
Constructor for an embed Window with known size, typically used in modules or plugins that run inside another host.
|
virtual |
Destructor.
|
noexcept |
|
noexcept |
Check if this window is visible / mapped. Invisible windows do not receive events except resize.
void Window::setVisible | ( | bool | visible | ) |
Set windows visible (or not) according to visible. Only valid for standalones, embed windows are always visible.
void Window::show | ( | ) |
Show window. This is the same as calling setVisible(true).
void Window::hide | ( | ) |
Hide window. This is the same as calling setVisible(false).
void Window::close | ( | ) |
Hide window and notify application of a window close event. The application event-loop will stop when all windows have been closed. For standalone windows only, has no effect if window is embed.
|
noexcept |
Get width.
|
noexcept |
Get height.
|
noexcept |
Get size.
void Window::setWidth | ( | uint | width | ) |
Set width.
void Window::setHeight | ( | uint | height | ) |
Set height.
void Window::setSize | ( | uint | width, |
uint | height | ||
) |
Set size using width and height values.
void Window::setSize | ( | const Size< uint > & | size | ) |
Set size.
|
noexcept |
Get the title of the window previously set with setTitle().
void Window::setTitle | ( | const char * | title | ) |
Set the title of the window, typically displayed in the title bar or in window switchers.
This only makes sense for non-embedded windows.
|
noexcept |
Check if key repeat events are ignored.
|
noexcept |
Set to ignore (or not) key repeat events according to ignore.
bool Window::addIdleCallback | ( | IdleCallback * | callback, |
uint | timerFrequencyInMs = 0 |
||
) |
Add a callback function to be triggered on every idle cycle or on a specific timer frequency. You can add more than one, and remove them at anytime with removeIdleCallback(). This can be used to perform some action at a regular interval with relatively low frequency.
If providing a timer frequency, there are a few things to note:
bool Window::removeIdleCallback | ( | IdleCallback * | callback | ) |
Remove an idle callback previously added via addIdleCallback().
|
noexcept |
Get the application associated with this window.
|
noexcept |
Get the graphics context associated with this window. GraphicsContext is an empty struct and needs to be casted into a different type in order to be usable, for example GraphicsContext.
|
noexcept |
Get the "native" window handle. Returned value depends on the platform:
BView
.NSView*
.HWND
.Window
.
|
noexcept |
Get the scale factor requested for this window. This is purely informational, and up to developers to choose what to do with it.
If you do not want to deal with this yourself, consider using setGeometryConstraints() where you can specify to automatically scale the window contents.
void Window::focus | ( | ) |
Grab the keyboard input focus.
|
noexcept |
Request repaint of this window, for the entire area.
|
noexcept |
Request partial repaint of this window, with bounds according to rect.
void Window::runAsModal | ( | bool | blockWait = false | ) |
Run this window as a modal, blocking input events from the parent. Only valid for windows that have been created with another window as parent (as passed in the constructor). Can optionally block-wait, but such option is only available if the application is running as standalone.
void Window::setGeometryConstraints | ( | uint | minimumWidth, |
uint | minimumHeight, | ||
bool | keepAspectRatio = false , |
||
bool | automaticallyScale = false |
||
) |
Set geometry constraints for the Window when resized by the user, and optionally scale contents automatically.
|
protectedvirtual |
A function called when the window is attempted to be closed. Returning true closes the window, which is the default behaviour. Override this method and return false to prevent the window from being closed by the user.
|
protectedvirtual |
A function called when the window gains or loses the keyboard focus. The default implementation does nothing.
|
protectedvirtual |
A function called when the window is resized. If there is a top-level widget associated with this window, its size will be set right after this function.
Reimplemented in ImageBaseAboutWindow< ImageType >.