make it also be a thing under Windows

This commit is contained in:
StapleButter
2018-12-30 01:49:47 +01:00
parent fc3952c981
commit 15be25085f
3 changed files with 46 additions and 23 deletions

View File

@ -309,17 +309,9 @@ static void drawGrid(ID2D1RenderTarget *rt, D2D1_RECT_F *fillRect)
size.width = 100 / 10; size.width = 100 / 10;
size.height = 100 / 10; size.height = 100 / 10;
// yay more ABI bugs // 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)); pformat = rt->GetPixelFormat();
(rt->*gpf)(&pformat);
}
#endif
hr = rt->CreateCompatibleRenderTarget(&size, NULL, hr = rt->CreateCompatibleRenderTarget(&size, NULL,
&pformat, D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS_NONE, &pformat, D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS_NONE,
&brt); &brt);

View File

@ -13,6 +13,7 @@ struct uiWindow {
int margined; int margined;
BOOL hasMenubar; BOOL hasMenubar;
BOOL changingSize; BOOL changingSize;
int maximized;
int fullscreen; int fullscreen;
WINDOWPLACEMENT fsPrevPlacement; WINDOWPLACEMENT fsPrevPlacement;
int borderless; int borderless;
@ -248,9 +249,16 @@ static void uiWindowShow(uiControl *c)
return; return;
} }
w->shownOnce = TRUE; w->shownOnce = TRUE;
int cmd;
if (w->maximized)
cmd = SW_SHOWMAXIMIZED;
else
cmd = SW_SHOWDEFAULT;
// make sure the child is the correct size // make sure the child is the correct size
uiWindowsControlMinimumSizeChanged(uiWindowsControl(w)); uiWindowsControlMinimumSizeChanged(uiWindowsControl(w));
ShowWindow(w->hwnd, nCmdShow); ShowWindow(w->hwnd, cmd);//nCmdShow);
if (UpdateWindow(w->hwnd) == 0) if (UpdateWindow(w->hwnd) == 0)
logLastError(L"error calling UpdateWindow() after showing uiWindow for the first time"); 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; 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) int uiWindowFullscreen(uiWindow *w)
{ {
return w->fullscreen; return w->fullscreen;
@ -517,12 +555,14 @@ static void setClientSize(uiWindow *w, int width, int height, BOOL hasMenubar, D
logLastError(L"error resizing window"); 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; uiWindow *w;
WCHAR *wtitle; WCHAR *wtitle;
BOOL hasMenubarBOOL; BOOL hasMenubarBOOL;
if (!resizable) maximized = 0;
uiWindowsNewControl(uiWindow, w); uiWindowsNewControl(uiWindow, w);
hasMenubarBOOL = FALSE; hasMenubarBOOL = FALSE;
@ -559,6 +599,8 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar,
// and use the proper size // and use the proper size
setClientSize(w, width, height, hasMenubarBOOL, style, exstyle); setClientSize(w, width, height, hasMenubarBOOL, style, exstyle);
w->maximized = maximized;
uiWindowOnClosing(w, defaultOnClosing, NULL); uiWindowOnClosing(w, defaultOnClosing, NULL);
uiWindowOnContentSizeChanged(w, defaultOnPositionContentSizeChanged, NULL); uiWindowOnContentSizeChanged(w, defaultOnPositionContentSizeChanged, NULL);

View File

@ -137,18 +137,7 @@ void invalidateRect(HWND hwnd, RECT *r, BOOL erase)
logLastError(L"error invalidating window rect"); logLastError(L"error invalidating window rect");
} }
// that damn ABI bug is never going to escape me is it
D2D1_SIZE_F realGetSize(ID2D1RenderTarget *rt) D2D1_SIZE_F realGetSize(ID2D1RenderTarget *rt)
{ {
#ifdef _MSC_VER
return rt->GetSize(); 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
} }