More Windows uiArea migration and compiler error fixes. Now to figure out what happened with GetSize again...

This commit is contained in:
Pietro Gagliardi 2015-12-18 14:21:35 -05:00
parent e76b34b670
commit 6d06e15390
4 changed files with 30 additions and 19 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -12,18 +12,19 @@ static HRESULT doPaint(uiArea *a, ID2D1RenderTarget *rt, RECT *clip)
dp.Context = newContext(rt);
dp.AreaWidth = 0;
dp.AreaHeight = 0;
if (!a->scrolling) {
size = ID2D1RenderTarget_GetSize(rt);
dp.ClientWidth = size.width;
dp.ClientHeight = size.height;
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;
}

View File

@ -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;
me.AreaWidth = 0;
me.AreaHeight = 0;
if (!a->scrolling) {
size = ID2D1HwndRenderTarget_GetSize(a->rt);
me.ClientWidth = size.width;
me.ClientHeight = size.height;
me.HScrollPos = a->hscrollpos;
me.VScrollPos = a->vscrollpos;
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: