From 6d06e15390a5d8a613261f6f6df98a4cee40e54b Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Fri, 18 Dec 2015 14:21:35 -0500 Subject: [PATCH] More Windows uiArea migration and compiler error fixes. Now to figure out what happened with GetSize again... --- test/page7b.c | 4 +++- windows/area.c | 16 +++++++++++----- windows/areadraw.c | 15 ++++++++------- windows/areaevents.c | 14 ++++++++------ 4 files changed, 30 insertions(+), 19 deletions(-) diff --git a/test/page7b.c b/test/page7b.c index b59cb41a..420155c8 100644 --- a/test/page7b.c +++ b/test/page7b.c @@ -19,7 +19,9 @@ static void handlerMouseEvent(uiAreaHandler *a, uiArea *area, uiAreaMouseEvent * { char pos[128]; - snprintf(pos, 127, "X %g Y %g", e->X, e->Y); + // wonderful, vanilla snprintf() isn't in visual studio 2013 - http://blogs.msdn.com/b/vcblog/archive/2013/07/19/c99-library-support-in-visual-studio-2013.aspx + // we can't use _snprintf() in the test suite because that's msvc-only, so oops. sprintf() it is. + sprintf(pos, "X %g Y %g", e->X, e->Y); uiCheckboxSetText(label, pos); } diff --git a/windows/area.c b/windows/area.c index a7c2950b..86d88266 100644 --- a/windows/area.c +++ b/windows/area.c @@ -17,8 +17,12 @@ static LRESULT CALLBACK areaWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM a = (uiArea *) GetWindowLongPtrW(hwnd, GWLP_USERDATA); if (a == NULL) { - if (uMsg == WM_CREATE) - SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR) (cs->lpCreateParams)); + if (uMsg == WM_CREATE) { + a = (uiArea *) (cs->lpCreateParams); + // assign a->hwnd here so we can use it immediately + a->hwnd = hwnd; + SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR) a); + } // fall through to DefWindowProcW() anyway return DefWindowProcW(hwnd, uMsg, wParam, lParam); } @@ -103,7 +107,8 @@ uiArea *uiNewArea(uiAreaHandler *ah) a->scrolling = FALSE; clickCounterReset(&(a->cc)); - a->hwnd = uiWindowsEnsureCreateControlHWND(0, + // a->hwnd is assigned in areaWndProc() + uiWindowsEnsureCreateControlHWND(0, areaClass, L"", 0, hInstance, a, @@ -126,13 +131,14 @@ uiArea *uiNewScrollingArea(uiAreaHandler *ah, intmax_t width, intmax_t height) a->scrollHeight = height; clickCounterReset(&(a->cc)); - a->hwnd = uiWindowsEnsureCreateControlHWND(0, + // a->hwnd is assigned in areaWndProc() + uiWindowsEnsureCreateControlHWND(0, areaClass, L"", WS_HSCROLL | WS_VSCROLL, hInstance, a, FALSE); - areaUpdateScroll(a->hwnd); + areaUpdateScroll(a); uiWindowsFinishNewControl(a, uiArea); diff --git a/windows/areadraw.c b/windows/areadraw.c index 92ac2fc2..09701499 100644 --- a/windows/areadraw.c +++ b/windows/areadraw.c @@ -12,18 +12,19 @@ static HRESULT doPaint(uiArea *a, ID2D1RenderTarget *rt, RECT *clip) dp.Context = newContext(rt); - size = ID2D1RenderTarget_GetSize(rt); - dp.ClientWidth = size.width; - dp.ClientHeight = size.height; + dp.AreaWidth = 0; + dp.AreaHeight = 0; + if (!a->scrolling) { + size = ID2D1RenderTarget_GetSize(rt); + dp.AreaWidth = size.width; + dp.AreaHeight = size.height; + } dp.ClipX = clip->left; dp.ClipY = clip->top; dp.ClipWidth = clip->right - clip->left; dp.ClipHeight = clip->bottom - clip->top; - dp.HScrollPos = a->hscrollpos; - dp.VScrollPos = a->vscrollpos; - ID2D1RenderTarget_BeginDraw(rt); // TODO only clear the clip area @@ -94,7 +95,7 @@ BOOL areaDoDraw(uiArea *a, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *lRe *lResult = 0; return TRUE; case WM_PRINTCLIENT: - onWM_PRINTCLIENT(xxxx); + onWM_PRINTCLIENT(a); *lResult = 0; return TRUE; } diff --git a/windows/areaevents.c b/windows/areaevents.c index 188a13ed..c4ac0f54 100644 --- a/windows/areaevents.c +++ b/windows/areaevents.c @@ -38,11 +38,13 @@ static void areaMouseEvent(uiArea *a, uintmax_t down, uintmax_t up, WPARAM wPar me.X = (xpix * 96) / dpix; me.Y = (ypix * 96) / dpiy; - size = ID2D1HwndRenderTarget_GetSize(a->rt); - me.ClientWidth = size.width; - me.ClientHeight = size.height; - me.HScrollPos = a->hscrollpos; - me.VScrollPos = a->vscrollpos; + me.AreaWidth = 0; + me.AreaHeight = 0; + if (!a->scrolling) { + size = ID2D1HwndRenderTarget_GetSize(a->rt); + me.AreaWidth = size.width; + me.AreaHeight = size.height; + } me.Down = down; me.Up = up; @@ -233,7 +235,7 @@ enum { msgAreaKeyUp, }; -BOOL areaDoScroll(uiArea *a, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *lResult) +BOOL areaDoEvents(uiArea *a, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *lResult) { switch (uMsg) { case WM_ACTIVATE: