|
| | Window (Application &app) |
| | Window (Application &app, Window &transientParentWindow) |
| | 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) |
| int | getOffsetX () const noexcept |
| int | getOffsetY () const noexcept |
| Point< int > | getOffset () const noexcept |
| void | setOffsetX (int x) |
| void | setOffsetY (int y) |
| void | setOffset (int x, int y) |
| void | setOffset (const Point< int > &offset) |
| bool | setEmbeddedOffset (int x, int y) |
| 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 |
| const void * | getClipboard (size_t &dataSize) |
| bool | setClipboard (const char *mimeType, const void *data, size_t dataSize) |
| bool | startFileDrag (const char *filename) |
| bool | isAcceptingFileDrops () const noexcept |
| bool | setAcceptingFileDrops (bool accept) |
| bool | setCursor (MouseCursor cursor) |
| 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 |
| const char * | getPortalParentHandle () const noexcept |
| double | getScaleFactor () const noexcept |
| void | focus () |
| bool | anyWidgetWantsKeyboardFocus () |
| void | repaint () noexcept |
| void | repaint (const Rectangle< uint > &rect) noexcept |
| void | renderToPicture (const char *filename) |
| void | runAsModal (bool blockWait=false) |
| Size< uint > | getGeometryConstraints (bool &keepAspectRatio) |
| void | setGeometryConstraints (uint minimumWidth, uint minimumHeight, bool keepAspectRatio=false, bool automaticallyScale=false, bool resizeNowIfAutoScaling=true) |
| void | setTransientParent (uintptr_t transientParentWindowHandle) |
| bool | getIgnoringKeyRepeat () const noexcept |
| double | getScaling () const noexcept |
| void | exec (bool blockWait=false) |
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.
...
| bool Window::setClipboard |
( |
const char * | mimeType, |
|
|
const void * | data, |
|
|
size_t | dataSize ) |
Set the clipboard contents.
This sets the system clipboard contents, which can be retrieved with getClipboard() or pasted into other applications.
If using a string, the use of a null terminator is required (and must be part of dataSize).
The MIME type of the data "text/plain" is assumed if null is used.
| bool Window::startFileDrag |
( |
const char * | filename | ) |
|
Start an outgoing copy-only drag of one existing file, from a primary mouse gesture. The UTF-8 path must identify an absolute file path. Call on the UI thread. Native delivery starts outside drawing, on a subsequent idle call. A true result means the operation was accepted, not that a destination has accepted the file. Keep the file available for asynchronous destination reads, including after this Window closes. The Window cancels its drag on destruction. Supported on Windows, macOS and X11. Returns false for an invalid file/gesture, an active drag, or an unsupported backend.
| bool Window::setAcceptingFileDrops |
( |
bool | accept | ) |
|
Let this window receive files dragged onto it from other applications, such as a file manager. The window then gets onFileDragEnter(), onFileDragMove(), and onFileDragLeave() or onFileDrop().
Only a window of its own can take drops: this fails for an embedded window, and on platforms without support (for now everything but X11, Wayland, macOS and Windows). On Windows it also fails on a thread in COM's multi-threaded apartment, where OLE cannot deliver drops. Turning it off always succeeds, and ends a drag in progress with onFileDragLeave() when the window had the enter. A window that never asks behaves exactly as before.
- See also
- isAcceptingFileDrops()
| 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:
- There is a platform-specific limit to the number of supported timers, and overhead associated with each, so you should create only a few timers and perform several tasks in one if necessary.
- This timer frequency is not guaranteed to have a resolution better than 10ms (the maximum timer resolution on Windows) and may be rounded up if it is too short. On X11 and MacOS, a resolution of about 1ms can usually be relied on.
The callback is not owned or tracked beyond this, so it MUST be removed with removeIdleCallback() before the callback object is destroyed, and while this window still exists. A callback without a timer frequency is registered on the Application rather than on this window, and destroying the window does not remove it, so a forgotten one is called through a dangling pointer.
| const char * Window::getPortalParentHandle |
( |
| ) |
const |
|
noexcept |
Get this window's handle in the form xdg-desktop-portal expects for a dialog's parent, so that a portal file chooser opens on top of it instead of floating free. On X11 that is "x11:" and the window id, on Wayland "wayland:" and an xdg-foreign handle.
Returns an empty string when there is nothing to give: on platforms with no portals, and on a Wayland compositor that has not answered with a handle (or does not implement xdg-foreign). The returned string belongs to the window and is valid until the next call.
| void Window::setGeometryConstraints |
( |
uint | minimumWidth, |
|
|
uint | minimumHeight, |
|
|
bool | keepAspectRatio = false, |
|
|
bool | automaticallyScale = false, |
|
|
bool | resizeNowIfAutoScaling = true ) |
Set geometry constraints for the Window when resized by the user, and optionally scale contents automatically.
The minimum size is given unscaled: with automaticallyScale the constraint handed to the windowing system is the minimum multiplied by the window scale factor.
resizeNowIfAutoScaling additionally resizes the window to that scaled minimum as auto-scaling is switched on. It is ignored once the Window is already auto-scaling, so a later call cannot pull a user-resized window back down to its minimum.
| virtual uint32_t Window::onClipboardDataOffer |
( |
| ) |
|
|
protectedvirtual |
A function called when clipboard has data present, possibly with several datatypes. While handling this event, the data types can be investigated with getClipboardDataOfferTypes() to decide whether to accept the offer.
Reimplement and return a non-zero id to accept the clipboard data offer for a particular type. Applications must ignore any type they do not recognize.
The default implementation accepts the "text/plain" mimetype.
A function called when files dragged from another application first come over this window, once their list is known. Return whether the window would take them if dropped at ev.pos. The answer shows as the platform's drag feedback. The source is only ever told of a copy.
Called on the event thread, like every other window callback, and only for a window that accepts file drops. Keep it short: the window may be closed or deleted from here, but must not block. The default implementation refuses.
- See also
- setAcceptingFileDrops(bool)
| virtual bool Window::onClose |
( |
| ) |
|
|
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.
This method is not used for embed windows, and not even made available in DAF_NAMESPACE::UI. For embed windows, closing is handled by the host/parent process and we have no control over it. As such, a close action on embed windows will always succeed and cannot be cancelled.
NOTE: This currently does not work under macOS.