diff --git a/dgl/TopLevelWidget.hpp b/dgl/TopLevelWidget.hpp index 5441dbcd..dfdcf750 100644 --- a/dgl/TopLevelWidget.hpp +++ b/dgl/TopLevelWidget.hpp @@ -101,6 +101,8 @@ public: void repaint(const Rectangle& rect) noexcept; // TODO group stuff after here, convenience functions present in Window class + bool setClipboard(const char* mimeType, const void* data, size_t dataSize); + const void* getClipboard(const char*& mimeType, size_t& dataSize); bool addIdleCallback(IdleCallback* callback, uint timerFrequencyInMs = 0); bool removeIdleCallback(IdleCallback* callback); double getScaleFactor() const noexcept; diff --git a/dgl/Window.hpp b/dgl/Window.hpp index 7aaa17df..d884f54f 100644 --- a/dgl/Window.hpp +++ b/dgl/Window.hpp @@ -263,6 +263,27 @@ public: */ void setIgnoringKeyRepeat(bool ignore) noexcept; + /** + 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).@n + The MIME type of the data "text/plain" is assumed if null is used. + */ + bool setClipboard(const char* mimeType, const void* data, size_t dataSize); + + /** + Get the clipboard contents. + + This gets the system clipboard contents, + which may have been set with setClipboard() or copied from another application. + + returns the clipboard contents, or null. + */ + const void* getClipboard(const char*& mimeType, size_t& dataSize); + /** 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(). diff --git a/dgl/src/TopLevelWidget.cpp b/dgl/src/TopLevelWidget.cpp index 556d9bd7..4c0257b6 100644 --- a/dgl/src/TopLevelWidget.cpp +++ b/dgl/src/TopLevelWidget.cpp @@ -60,6 +60,16 @@ void TopLevelWidget::setSize(const Size& size) pData->window.setSize(size); } +bool TopLevelWidget::setClipboard(const char* mimeType, const void* data, size_t dataSize) +{ + return pData->window.setClipboard(mimeType, data, dataSize); +} + +const void* TopLevelWidget::getClipboard(const char*& mimeType, size_t& dataSize) +{ + return pData->window.getClipboard(mimeType, dataSize); +} + bool TopLevelWidget::addIdleCallback(IdleCallback* const callback, const uint timerFrequencyInMs) { return pData->window.addIdleCallback(callback, timerFrequencyInMs); diff --git a/dgl/src/Window.cpp b/dgl/src/Window.cpp index c09106fa..6459163f 100644 --- a/dgl/src/Window.cpp +++ b/dgl/src/Window.cpp @@ -257,6 +257,16 @@ void Window::setIgnoringKeyRepeat(const bool ignore) noexcept puglSetViewHint(pData->view, PUGL_IGNORE_KEY_REPEAT, ignore); } +bool Window::setClipboard(const char* const mimeType, const void* const data, const size_t dataSize) +{ + return puglSetClipboard(pData->view, mimeType, data, dataSize) == PUGL_SUCCESS; +} + +const void* Window::getClipboard(const char*& mimeType, size_t& dataSize) +{ + return puglGetClipboard(pData->view, &mimeType, &dataSize); +} + bool Window::addIdleCallback(IdleCallback* const callback, const uint timerFrequencyInMs) { DISTRHO_SAFE_ASSERT_RETURN(callback != nullptr, false)