From 878778c683e966dab377c6adc677d6153016fdf3 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 22 May 2016 16:16:20 -0400 Subject: [PATCH] Implemented WM_PRINTCLIENT for uiArea and the Direct2D scratch windows. --- README.md | 9 +++++---- windows/areadraw.cpp | 14 ++++++++++---- windows/d2dscratch.cpp | 11 +++++++++-- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 44012e0f..c7cf33f0 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,10 @@ This README is being written.
## Announcements -**21 May 2016** -* 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. -* You can decide if I should also drop OS X 10.7 [here](https://github.com/andlabs/libui/issues/46). +* **21 May 2016** + * 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. + * You can decide if I should also drop OS X 10.7 [here](https://github.com/andlabs/libui/issues/46). ## Updates @@ -19,6 +19,7 @@ This README is being written.
* 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. * 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 diff --git a/windows/areadraw.cpp b/windows/areadraw.cpp index 17b64705..7b3dc696 100644 --- a/windows/areadraw.cpp +++ b/windows/areadraw.cpp @@ -72,7 +72,7 @@ static void onWM_PAINT(uiArea *a) clip.right = 0; clip.bottom = 0; } - hr = doPaint(a, (ID2D1RenderTarget *) (a->rt), &clip); + hr = doPaint(a, a->rt, &clip); switch (hr) { case S_OK: 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; + HRESULT hr; 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) @@ -107,7 +113,7 @@ BOOL areaDoDraw(uiArea *a, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *lRe *lResult = 0; return TRUE; case WM_PRINTCLIENT: - onWM_PRINTCLIENT(a); + onWM_PRINTCLIENT(a, (HDC) wParam); *lResult = 0; return TRUE; } diff --git a/windows/d2dscratch.cpp b/windows/d2dscratch.cpp index 146eea8b..63218adc 100644 --- a/windows/d2dscratch.cpp +++ b/windows/d2dscratch.cpp @@ -65,6 +65,8 @@ static LRESULT CALLBACK d2dScratchWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, L { LONG_PTR init; ID2D1HwndRenderTarget *rt; + ID2D1DCRenderTarget *dcrt; + RECT client; HRESULT hr; init = GetWindowLongPtrW(hwnd, 0); @@ -105,8 +107,13 @@ static LRESULT CALLBACK d2dScratchWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, L } return 0; case WM_PRINTCLIENT: - // TODO - break; + uiWindowsEnsureGetClientRect(hwnd, &client); + 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: d2dScratchDoLButtonDown(hwnd, rt, lParam); return 0;