From 5e90cbcb93a7cd993311c5670310390501e34d91 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Fri, 18 Dec 2015 21:15:40 -0500 Subject: [PATCH] Started a windows/areautil.c for miscellaneous functions, mostly (completely for now) having to do with coordinates and sizes. Right now it only has renderTargetGetSize(). --- windows/GNUfiles.mk | 1 + windows/area.c | 16 ---------------- windows/area.h | 6 +++--- windows/areautil.c | 19 +++++++++++++++++++ 4 files changed, 23 insertions(+), 19 deletions(-) create mode 100644 windows/areautil.c diff --git a/windows/GNUfiles.mk b/windows/GNUfiles.mk index 1eb2f202..a08e0730 100644 --- a/windows/GNUfiles.mk +++ b/windows/GNUfiles.mk @@ -6,6 +6,7 @@ CFILES += \ windows/areadraw.c \ windows/areaevents.c \ windows/areascroll.c \ + windows/areautil.c \ windows/box.c \ windows/button.c \ windows/checkbox.c \ diff --git a/windows/area.c b/windows/area.c index 396722f3..e0fed706 100644 --- a/windows/area.c +++ b/windows/area.c @@ -7,22 +7,6 @@ uiWindowsDefineControl( uiAreaType // type function ) -// I love COM interfaces that actually only work on C++ -// ID2D1RenderTarget::GetSize is defined as returninig a structure -// with stdcall, this means it's an extra last argument -// the compiler tries to return it directly, and crashes -// I originally thought this was a bug in MinGW-w64, but it turns out it also affects MSVC! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64384 -// So we have to work around it. -// TODO is the return type correct? or should we just use C++? -void renderTargetGetSize(ID2D1RenderTarget *rt, D2D1_SIZE_F *size) -{ - typedef void (STDMETHODCALLTYPE *fptr)(ID2D1RenderTarget *, D2D1_SIZE_F *); - fptr f; - - f = (fptr) (rt->lpVtbl->GetSize); - (*f)(rt, size); -} - static LRESULT CALLBACK areaWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { uiArea *a; diff --git a/windows/area.h b/windows/area.h index 0de8f470..73ea30c6 100644 --- a/windows/area.h +++ b/windows/area.h @@ -27,9 +27,6 @@ struct uiArea { ID2D1HwndRenderTarget *rt; }; -// area.c -extern void renderTargetGetSize(ID2D1RenderTarget *rt, D2D1_SIZE_F *size); - // areadraw.h extern BOOL areaDoDraw(uiArea *a, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *lResult); extern void areaDrawOnResize(uiArea *, RECT *); @@ -41,3 +38,6 @@ extern void areaUpdateScroll(uiArea *a); // areaevents.c extern BOOL areaDoEvents(uiArea *a, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *lResult); extern void unregisterAreaFilter(void); + +// areautil.c +extern void renderTargetGetSize(ID2D1RenderTarget *rt, D2D1_SIZE_F *size); diff --git a/windows/areautil.c b/windows/areautil.c new file mode 100644 index 00000000..f1b9377c --- /dev/null +++ b/windows/areautil.c @@ -0,0 +1,19 @@ +// 18 december 2015 +#include "uipriv_windows.h" +#include "area.h" + +// I love COM interfaces that actually only work on C++ +// ID2D1RenderTarget::GetSize is defined as returninig a structure +// with stdcall, this means it's an extra last argument +// the compiler tries to return it directly, and crashes +// I originally thought this was a bug in MinGW-w64, but it turns out it also affects MSVC! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64384 +// So we have to work around it. +// TODO is the return type correct? or should we just use C++? +void renderTargetGetSize(ID2D1RenderTarget *rt, D2D1_SIZE_F *size) +{ + typedef void (STDMETHODCALLTYPE *fptr)(ID2D1RenderTarget *, D2D1_SIZE_F *); + fptr f; + + f = (fptr) (rt->lpVtbl->GetSize); + (*f)(rt, size); +}