aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-05-13 17:11:19 +0000
committerDavid Robillard <d@drobilla.net>2014-05-13 17:11:19 +0000
commit85ee7c8408240526ed8b7c9877c7fe15536aa7f2 (patch)
treea4b66225f4d3ed4234f53349ef350a5f29d5cab4
parent4b3c289fdac8a7d189464f3a56b076038aa000e0 (diff)
Fix compilation on Windows. Maybe.
-rw-r--r--pugl/pugl_win.cpp56
1 files changed, 33 insertions, 23 deletions
diff --git a/pugl/pugl_win.cpp b/pugl/pugl_win.cpp
index b823001..31fe2d3 100644
--- a/pugl/pugl_win.cpp
+++ b/pugl/pugl_win.cpp
@@ -65,23 +65,20 @@ puglInit()
return view;
}
-PuglView*
-puglCreateInternals(PuglNativeWindow parent,
- const char* title,
- int width,
- int height,
- bool resizable,
- bool visible)
+PuglInternals*
+puglInitInternals()
{
- PuglView* view = (PuglView*)calloc(1, sizeof(PuglView));
- PuglInternals* impl = (PuglInternals*)calloc(1, sizeof(PuglInternals));
- if (!view || !impl) {
- return NULL;
- }
+ return (PuglInternals*)calloc(1, sizeof(PuglInternals));
+}
- view->impl = impl;
- view->width = width;
- view->height = height;
+int
+puglCreateWindow(PuglView* view, const char* title)
+{
+ PuglInternals* impl = view->impl;
+
+ if (!title) {
+ title = "Window";
+ }
// FIXME: This is nasty, and pugl should not have static anything.
// Should class be a parameter? Does this make sense on other platforms?
@@ -102,25 +99,25 @@ puglCreateInternals(PuglNativeWindow parent,
RegisterClass(&impl->wc);
int winFlags = WS_POPUPWINDOW | WS_CAPTION;
- if (resizable) {
+ if (view->resizable) {
winFlags |= WS_SIZEBOX;
}
// Adjust the overall window size to accomodate our requested client size
- RECT wr = { 0, 0, width, height };
+ RECT wr = { 0, 0, view->width, view->height };
AdjustWindowRectEx(&wr, winFlags, FALSE, WS_EX_TOPMOST);
impl->hwnd = CreateWindowEx(
WS_EX_TOPMOST,
classNameBuf, title,
- (visible ? WS_VISIBLE : 0) | (parent ? WS_CHILD : winFlags),
+ (view->parent ? WS_CHILD : winFlags),
CW_USEDEFAULT, CW_USEDEFAULT, wr.right-wr.left, wr.bottom-wr.top,
- (HWND)parent, NULL, NULL, NULL);
+ (HWND)view->parent, NULL, NULL, NULL);
if (!impl->hwnd) {
free(impl);
free(view);
- return NULL;
+ return 1;
}
#ifdef _WIN64
@@ -147,10 +144,23 @@ puglCreateInternals(PuglNativeWindow parent,
impl->hglrc = wglCreateContext(impl->hdc);
wglMakeCurrent(impl->hdc, impl->hglrc);
- view->width = width;
- view->height = height;
+ return 0;
+}
- return view;
+void
+puglShowWindow(PuglView* view)
+{
+ PuglInternals* impl = view->impl;
+
+ ShowWindow(impl->hwnd, SW_SHOWNORMAL);
+}
+
+void
+puglHideWindow(PuglView* view)
+{
+ PuglInternals* impl = view->impl;
+
+ ShowWindow(impl->hwnd, SW_HIDE);
}
void