aboutsummaryrefslogtreecommitdiff
path: root/src/libui_sdl/libui/windows
diff options
context:
space:
mode:
authorStapleButter <thetotalworm@gmail.com>2018-12-30 01:49:47 +0100
committerStapleButter <thetotalworm@gmail.com>2018-12-30 01:49:47 +0100
commit15be25085fb68b675f0a874dbdd474ec584e61d1 (patch)
tree5c464c41892c035f8d458668f5e09ad33baf1580 /src/libui_sdl/libui/windows
parentfc3952c9812095eb25b5061a0ca3a9a559f2e0ed (diff)
make it also be a thing under Windows
Diffstat (limited to 'src/libui_sdl/libui/windows')
-rw-r--r--src/libui_sdl/libui/windows/colordialog.cpp10
-rw-r--r--src/libui_sdl/libui/windows/window.cpp46
-rw-r--r--src/libui_sdl/libui/windows/winutil.cpp11
3 files changed, 45 insertions, 22 deletions
diff --git a/src/libui_sdl/libui/windows/colordialog.cpp b/src/libui_sdl/libui/windows/colordialog.cpp
index 9c2551a..86d046d 100644
--- a/src/libui_sdl/libui/windows/colordialog.cpp
+++ b/src/libui_sdl/libui/windows/colordialog.cpp
@@ -309,17 +309,9 @@ static void drawGrid(ID2D1RenderTarget *rt, D2D1_RECT_F *fillRect)
size.width = 100 / 10;
size.height = 100 / 10;
// yay more ABI bugs
-#ifdef _MSC_VER
+
pformat = rt->GetPixelFormat();
-#else
- {
- typedef D2D1_PIXEL_FORMAT *(__stdcall ID2D1RenderTarget::* GetPixelFormatF)(D2D1_PIXEL_FORMAT *);
- GetPixelFormatF gpf;
- gpf = (GetPixelFormatF) (&(rt->GetPixelFormat));
- (rt->*gpf)(&pformat);
- }
-#endif
hr = rt->CreateCompatibleRenderTarget(&size, NULL,
&pformat, D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS_NONE,
&brt);
diff --git a/src/libui_sdl/libui/windows/window.cpp b/src/libui_sdl/libui/windows/window.cpp
index e2127cb..f52e2f6 100644
--- a/src/libui_sdl/libui/windows/window.cpp
+++ b/src/libui_sdl/libui/windows/window.cpp
@@ -13,6 +13,7 @@ struct uiWindow {
int margined;
BOOL hasMenubar;
BOOL changingSize;
+ int maximized;
int fullscreen;
WINDOWPLACEMENT fsPrevPlacement;
int borderless;
@@ -248,9 +249,16 @@ static void uiWindowShow(uiControl *c)
return;
}
w->shownOnce = TRUE;
+
+ int cmd;
+ if (w->maximized)
+ cmd = SW_SHOWMAXIMIZED;
+ else
+ cmd = SW_SHOWDEFAULT;
+
// make sure the child is the correct size
uiWindowsControlMinimumSizeChanged(uiWindowsControl(w));
- ShowWindow(w->hwnd, nCmdShow);
+ ShowWindow(w->hwnd, cmd);//nCmdShow);
if (UpdateWindow(w->hwnd) == 0)
logLastError(L"error calling UpdateWindow() after showing uiWindow for the first time");
}
@@ -374,6 +382,36 @@ void uiWindowSetContentSize(uiWindow *w, int width, int height)
w->changingSize = FALSE;
}
+int uiWindowMinimized(uiWindow *w)
+{
+ return IsIconic(w->hwnd);
+}
+
+void uiWindowSetMinimized(uiWindow *w, int minimized)
+{
+ if (minimized)
+ ShowWindow(w->hwnd, SW_MINIMIZE);
+ else if (w->maximized)
+ ShowWindow(w->hwnd, SW_MAXIMIZE);
+ else
+ ShowWindow(w->hwnd, SW_RESTORE);
+}
+
+int uiWindowMaximized(uiWindow *w)
+{
+ return IsZoomed(w->hwnd);
+}
+
+void uiWindowSetMaximized(uiWindow *w, int maximized)
+{
+ w->maximized = maximized;
+ if (maximized)
+ ShowWindow(w->hwnd, SW_MAXIMIZE);
+ else
+ ShowWindow(w->hwnd, SW_RESTORE);
+}
+
+
int uiWindowFullscreen(uiWindow *w)
{
return w->fullscreen;
@@ -517,12 +555,14 @@ static void setClientSize(uiWindow *w, int width, int height, BOOL hasMenubar, D
logLastError(L"error resizing window");
}
-uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar, int resizable)
+uiWindow *uiNewWindow(const char *title, int width, int height, int maximized, int hasMenubar, int resizable)
{
uiWindow *w;
WCHAR *wtitle;
BOOL hasMenubarBOOL;
+ if (!resizable) maximized = 0;
+
uiWindowsNewControl(uiWindow, w);
hasMenubarBOOL = FALSE;
@@ -559,6 +599,8 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar,
// and use the proper size
setClientSize(w, width, height, hasMenubarBOOL, style, exstyle);
+ w->maximized = maximized;
+
uiWindowOnClosing(w, defaultOnClosing, NULL);
uiWindowOnContentSizeChanged(w, defaultOnPositionContentSizeChanged, NULL);
diff --git a/src/libui_sdl/libui/windows/winutil.cpp b/src/libui_sdl/libui/windows/winutil.cpp
index 507c5a3..2552893 100644
--- a/src/libui_sdl/libui/windows/winutil.cpp
+++ b/src/libui_sdl/libui/windows/winutil.cpp
@@ -137,18 +137,7 @@ void invalidateRect(HWND hwnd, RECT *r, BOOL erase)
logLastError(L"error invalidating window rect");
}
-// that damn ABI bug is never going to escape me is it
D2D1_SIZE_F realGetSize(ID2D1RenderTarget *rt)
{
-#ifdef _MSC_VER
return rt->GetSize();
-#else
- D2D1_SIZE_F size;
- typedef D2D1_SIZE_F *(__stdcall ID2D1RenderTarget::* GetSizeF)(D2D1_SIZE_F *);
- GetSizeF gs;
-
- gs = (GetSizeF) (&(rt->GetSize));
- (rt->*gs)(&size);
- return size;
-#endif
}