Browse Source

Fix DPT for win32 API

tags/1.9.4
falkTX 12 years ago
parent
commit
d1be4d8ac4
5 changed files with 50 additions and 5 deletions
  1. +5
    -1
      source/libs/distrho/dgl/Window.hpp
  2. +6
    -0
      source/libs/distrho/dgl/src/ImageAboutWindow.cpp
  3. +8
    -1
      source/libs/distrho/dgl/src/Widget.cpp
  4. +29
    -1
      source/libs/distrho/dgl/src/Window.cpp
  5. +2
    -2
      source/libs/distrho/dgl/src/pugl/pugl_win.cpp

+ 5
- 1
source/libs/distrho/dgl/Window.hpp View File

@@ -17,7 +17,7 @@
#ifndef __DGL_WINDOW_HPP__
#define __DGL_WINDOW_HPP__

#include "Base.hpp"
#include "Geometry.hpp"

START_NAMESPACE_DISTRHO

@@ -61,6 +61,10 @@ public:
setVisible(false);
}

#if DISTRHO_OS_WINDOWS
Rectangle<int> getBounds();
#endif

private:
class Private;
Private* const kPrivate;


+ 6
- 0
source/libs/distrho/dgl/src/ImageAboutWindow.cpp View File

@@ -25,7 +25,13 @@ ImageAboutWindow::ImageAboutWindow(App* app, Window* parent, const Image& image)
Widget(this),
fImgBackground(image)
{
#if DISTRHO_OS_WINDOWS
// FIXME
Window::setSize(image.getWidth()+1, image.getHeight()+1);
#else
Window::setSize(image.getWidth(), image.getHeight());
#endif

Window::setWindowTitle("About");
Window::show();
}


+ 8
- 1
source/libs/distrho/dgl/src/Widget.cpp View File

@@ -217,8 +217,15 @@ void Widget::onReshape(int width, int height)

glMatrixMode(GL_PROJECTION);
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);
#endif

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();


+ 29
- 1
source/libs/distrho/dgl/src/Window.cpp View File

@@ -85,6 +85,7 @@ public:

#if DISTRHO_OS_WINDOWS
hwnd = impl->hwnd;

#elif DISTRHO_OS_LINUX
xDisplay = impl->display;
xWindow = impl->win;
@@ -222,7 +223,17 @@ public:

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;
memset(&sizeHints, 0, sizeof(sizeHints));

@@ -273,6 +284,16 @@ public:
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:
void onDisplay()
{
@@ -542,6 +563,13 @@ void Window::removeWidget(Widget* widget)
kPrivate->removeWidget(widget);
}

#if DISTRHO_OS_WINDOWS
Rectangle<int> Window::getBounds()
{
return kPrivate->getBounds();
}
#endif

// -------------------------------------------------

END_NAMESPACE_DISTRHO

+ 2
- 2
source/libs/distrho/dgl/src/pugl/pugl_win.cpp View File

@@ -74,8 +74,8 @@ puglCreate(PuglNativeWindow parent,

impl->hwnd = CreateWindow(
"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);
if (!impl->hwnd) {
free(impl);


Loading…
Cancel
Save