| @@ -17,7 +17,7 @@ | |||||
| #ifndef __DGL_WINDOW_HPP__ | #ifndef __DGL_WINDOW_HPP__ | ||||
| #define __DGL_WINDOW_HPP__ | #define __DGL_WINDOW_HPP__ | ||||
| #include "Base.hpp" | |||||
| #include "Geometry.hpp" | |||||
| START_NAMESPACE_DISTRHO | START_NAMESPACE_DISTRHO | ||||
| @@ -61,6 +61,10 @@ public: | |||||
| setVisible(false); | setVisible(false); | ||||
| } | } | ||||
| #if DISTRHO_OS_WINDOWS | |||||
| Rectangle<int> getBounds(); | |||||
| #endif | |||||
| private: | private: | ||||
| class Private; | class Private; | ||||
| Private* const kPrivate; | Private* const kPrivate; | ||||
| @@ -25,7 +25,13 @@ ImageAboutWindow::ImageAboutWindow(App* app, Window* parent, const Image& image) | |||||
| Widget(this), | Widget(this), | ||||
| fImgBackground(image) | fImgBackground(image) | ||||
| { | { | ||||
| #if DISTRHO_OS_WINDOWS | |||||
| // FIXME | |||||
| Window::setSize(image.getWidth()+1, image.getHeight()+1); | |||||
| #else | |||||
| Window::setSize(image.getWidth(), image.getHeight()); | Window::setSize(image.getWidth(), image.getHeight()); | ||||
| #endif | |||||
| Window::setWindowTitle("About"); | Window::setWindowTitle("About"); | ||||
| Window::show(); | Window::show(); | ||||
| } | } | ||||
| @@ -217,8 +217,15 @@ void Widget::onReshape(int width, int height) | |||||
| glMatrixMode(GL_PROJECTION); | glMatrixMode(GL_PROJECTION); | ||||
| glLoadIdentity(); | glLoadIdentity(); | ||||
| glOrtho(0, width, height, 0, 0, 1); | |||||
| #if DISTRHO_OS_WINDOWS | |||||
| Rectangle<int> r(fParent->getBounds()); | |||||
| glOrtho(r.getX(), r.getWidth(), r.getHeight(), r.getY(), -1.0f, 1.0f); | |||||
| glViewport(0, 0, r.getWidth() - r.getX(), r.getHeight() - r.getY()); | |||||
| #else | |||||
| glOrtho(0, width, height, 0, 0.0f, 1.0f); | |||||
| glViewport(0, 0, width, height); | glViewport(0, 0, width, height); | ||||
| #endif | |||||
| glMatrixMode(GL_MODELVIEW); | glMatrixMode(GL_MODELVIEW); | ||||
| glLoadIdentity(); | glLoadIdentity(); | ||||
| @@ -85,6 +85,7 @@ public: | |||||
| #if DISTRHO_OS_WINDOWS | #if DISTRHO_OS_WINDOWS | ||||
| hwnd = impl->hwnd; | hwnd = impl->hwnd; | ||||
| #elif DISTRHO_OS_LINUX | #elif DISTRHO_OS_LINUX | ||||
| xDisplay = impl->display; | xDisplay = impl->display; | ||||
| xWindow = impl->win; | xWindow = impl->win; | ||||
| @@ -222,7 +223,17 @@ public: | |||||
| void setSize(unsigned int width, unsigned int height) | void setSize(unsigned int width, unsigned int height) | ||||
| { | { | ||||
| #if DISTRHO_OS_LINUX | |||||
| #if DISTRHO_OS_WINDOWS | |||||
| RECT rcClient; | |||||
| RECT rcWindow; | |||||
| POINT ptDiff; | |||||
| GetClientRect(hwnd, &rcClient); | |||||
| GetWindowRect(hwnd, &rcWindow); | |||||
| ptDiff.x = (rcWindow.right - rcWindow.left) - rcClient.right; | |||||
| ptDiff.y = (rcWindow.bottom - rcWindow.top) - rcClient.bottom; | |||||
| SetWindowPos(hwnd, 0, 0, 0, width + ptDiff.x, height + ptDiff.y, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOZORDER); | |||||
| UpdateWindow(hwnd); | |||||
| #elif DISTRHO_OS_LINUX | |||||
| XSizeHints sizeHints; | XSizeHints sizeHints; | ||||
| memset(&sizeHints, 0, sizeof(sizeHints)); | memset(&sizeHints, 0, sizeof(sizeHints)); | ||||
| @@ -273,6 +284,16 @@ public: | |||||
| fWidgets.remove(widget); | fWidgets.remove(widget); | ||||
| } | } | ||||
| #if DISTRHO_OS_WINDOWS | |||||
| Rectangle<int> getBounds() | |||||
| { | |||||
| RECT rcClient; | |||||
| GetClientRect(hwnd, &rcClient); | |||||
| return Rectangle<int>(rcClient.left, rcClient.top, rcClient.right, rcClient.bottom); | |||||
| } | |||||
| #endif | |||||
| protected: | protected: | ||||
| void onDisplay() | void onDisplay() | ||||
| { | { | ||||
| @@ -542,6 +563,13 @@ void Window::removeWidget(Widget* widget) | |||||
| kPrivate->removeWidget(widget); | kPrivate->removeWidget(widget); | ||||
| } | } | ||||
| #if DISTRHO_OS_WINDOWS | |||||
| Rectangle<int> Window::getBounds() | |||||
| { | |||||
| return kPrivate->getBounds(); | |||||
| } | |||||
| #endif | |||||
| // ------------------------------------------------- | // ------------------------------------------------- | ||||
| END_NAMESPACE_DISTRHO | END_NAMESPACE_DISTRHO | ||||
| @@ -74,8 +74,8 @@ puglCreate(PuglNativeWindow parent, | |||||
| impl->hwnd = CreateWindow( | impl->hwnd = CreateWindow( | ||||
| "Pugl", title, | "Pugl", title, | ||||
| (addToDesktop ? WS_VISIBLE : 0) | (parent ? WS_CHILD : (WS_POPUPWINDOW | WS_CAPTION)), | |||||
| 0, 0, width, height, | |||||
| (addToDesktop ? WS_VISIBLE : 0) | (parent ? WS_CHILD : (WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME & ~WS_MAXIMIZEBOX)), | |||||
| CW_USEDEFAULT, CW_USEDEFAULT, width, height, | |||||
| (HWND)parent, NULL, NULL, NULL); | (HWND)parent, NULL, NULL, NULL); | ||||
| if (!impl->hwnd) { | if (!impl->hwnd) { | ||||
| free(impl); | free(impl); | ||||