Implemented WM_PRINTCLIENT for uiArea and the Direct2D scratch windows.

This commit is contained in:
Pietro Gagliardi 2016-05-22 16:16:20 -04:00
parent 585872839d
commit 878778c683
3 changed files with 24 additions and 10 deletions

View File

@ -5,7 +5,7 @@ This README is being written.<br>
## Announcements ## Announcements
**21 May 2016** * **21 May 2016**
* I will now post announcements and updates here. * I will now post announcements and updates here.
* Now that Ubuntu 16.04 LTS is here, no earlier than next Saturday, 28 May 2016 at noon EDT, **I will bump the minimum GTK+ version from 3.4 to 3.10**. This will add a lot of new features that I can now add to libui, such as search-oriented uiEntries, lists of arbitrary control layouts, and more. If you are still running a Linux distribution that doesn't come with 3.10, you will either need to upgrade or use jhbuild to set up a newer version of GTK+ in a private environment. * Now that Ubuntu 16.04 LTS is here, no earlier than next Saturday, 28 May 2016 at noon EDT, **I will bump the minimum GTK+ version from 3.4 to 3.10**. This will add a lot of new features that I can now add to libui, such as search-oriented uiEntries, lists of arbitrary control layouts, and more. If you are still running a Linux distribution that doesn't come with 3.10, you will either need to upgrade or use jhbuild to set up a newer version of GTK+ in a private environment.
* You can decide if I should also drop OS X 10.7 [here](https://github.com/andlabs/libui/issues/46). * You can decide if I should also drop OS X 10.7 [here](https://github.com/andlabs/libui/issues/46).
@ -19,6 +19,7 @@ This README is being written.<br>
* Added `uiPi`, a constant for π. This is provided for C and C++ programmers, where there is no standard named constant for π; bindings authors shouldn't need to worry about this. * Added `uiPi`, a constant for π. This is provided for C and C++ programmers, where there is no standard named constant for π; bindings authors shouldn't need to worry about this.
* Fixed uiMultilineEntry not properly having line breaks on Windows. * Fixed uiMultilineEntry not properly having line breaks on Windows.
* Added `uiNewNonWrappingMultilineEntry()`, which creates a uiMultilineEntry that scrolls horizontally instead of wrapping lines. (This is not documented as being changeable after the fact on Windows, hence it's a creation-time choice.) * Added `uiNewNonWrappingMultilineEntry()`, which creates a uiMultilineEntry that scrolls horizontally instead of wrapping lines. (This is not documented as being changeable after the fact on Windows, hence it's a creation-time choice.)
* uiArea and some internal Direct2D windows now respond to `WM_PRINTCLIENT` properly, which should hopefully increase the quality of screenshots.
## Runtime Requirements ## Runtime Requirements

View File

@ -72,7 +72,7 @@ static void onWM_PAINT(uiArea *a)
clip.right = 0; clip.right = 0;
clip.bottom = 0; clip.bottom = 0;
} }
hr = doPaint(a, (ID2D1RenderTarget *) (a->rt), &clip); hr = doPaint(a, a->rt, &clip);
switch (hr) { switch (hr) {
case S_OK: case S_OK:
if (ValidateRect(a->hwnd, NULL) == 0) if (ValidateRect(a->hwnd, NULL) == 0)
@ -91,12 +91,18 @@ static void onWM_PAINT(uiArea *a)
} }
} }
static void onWM_PRINTCLIENT(uiArea *a) static void onWM_PRINTCLIENT(uiArea *a, HDC dc)
{ {
ID2D1DCRenderTarget *rt;
RECT client; RECT client;
HRESULT hr;
uiWindowsEnsureGetClientRect(a->hwnd, &client); uiWindowsEnsureGetClientRect(a->hwnd, &client);
//TODO doPaint(a, (HDC) wParam, &client); rt = makeHDCRenderTarget(dc, &client);
hr = doPaint(a, rt, &client);
if (hr != S_OK)
logHRESULT(L"error printing uiArea client area", hr);
rt->Release();
} }
BOOL areaDoDraw(uiArea *a, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *lResult) BOOL areaDoDraw(uiArea *a, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
@ -107,7 +113,7 @@ BOOL areaDoDraw(uiArea *a, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *lRe
*lResult = 0; *lResult = 0;
return TRUE; return TRUE;
case WM_PRINTCLIENT: case WM_PRINTCLIENT:
onWM_PRINTCLIENT(a); onWM_PRINTCLIENT(a, (HDC) wParam);
*lResult = 0; *lResult = 0;
return TRUE; return TRUE;
} }

View File

@ -65,6 +65,8 @@ static LRESULT CALLBACK d2dScratchWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, L
{ {
LONG_PTR init; LONG_PTR init;
ID2D1HwndRenderTarget *rt; ID2D1HwndRenderTarget *rt;
ID2D1DCRenderTarget *dcrt;
RECT client;
HRESULT hr; HRESULT hr;
init = GetWindowLongPtrW(hwnd, 0); init = GetWindowLongPtrW(hwnd, 0);
@ -105,8 +107,13 @@ static LRESULT CALLBACK d2dScratchWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, L
} }
return 0; return 0;
case WM_PRINTCLIENT: case WM_PRINTCLIENT:
// TODO uiWindowsEnsureGetClientRect(hwnd, &client);
break; dcrt = makeHDCRenderTarget((HDC) wParam, &client);
hr = d2dScratchDoPaint(hwnd, dcrt);
if (hr != S_OK)
logHRESULT(L"error printing D2D scratch window client area", hr);
dcrt->Release();
return 0;
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
d2dScratchDoLButtonDown(hwnd, rt, lParam); d2dScratchDoLButtonDown(hwnd, rt, lParam);
return 0; return 0;