From 75c473501622d61a0898a2e0647cfd5044938a1e Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Wed, 7 Jul 2021 22:47:15 +0200 Subject: [PATCH 1/5] Fix using wxDCTextBgModeChanger Correctly initialize the old background mode. --- include/wx/dc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/wx/dc.h b/include/wx/dc.h index 6dcf24c1c3..2131ca91a1 100644 --- a/include/wx/dc.h +++ b/include/wx/dc.h @@ -1478,7 +1478,7 @@ class WXDLLIMPEXP_CORE wxDCTextBgModeChanger public: wxDCTextBgModeChanger(wxDC& dc) : m_dc(dc), m_modeOld(wxBRUSHSTYLE_INVALID) { } - wxDCTextBgModeChanger(wxDC& dc, int mode) : m_dc(dc) + wxDCTextBgModeChanger(wxDC& dc, int mode) : m_dc(dc), m_modeOld(wxBRUSHSTYLE_INVALID) { Set(mode); } From 170631ff93735f655f8e1b5ed0f3a3f1afa1ddd0 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Wed, 7 Jul 2021 22:48:53 +0200 Subject: [PATCH 2/5] Renderer theme with EXPLORER::LISTVIEW is not always available It works in the render sample, but not in the dataview sample. Fallback to using LISTVIEW if EXPLORER::LISTVIEW results in an invalid hTheme. --- src/msw/renderer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/msw/renderer.cpp b/src/msw/renderer.cpp index 6cfdb37fab..df0259409d 100644 --- a/src/msw/renderer.cpp +++ b/src/msw/renderer.cpp @@ -1011,7 +1011,7 @@ wxRendererXP::DrawItemSelectionRect(wxWindow *win, const wxRect& rect, int flags) { - wxUxThemeHandle hTheme(win, L"EXPLORER::LISTVIEW"); + wxUxThemeHandle hTheme(win, L"EXPLORER::LISTVIEW;LISTVIEW"); const int itemState = GetListItemState(flags); @@ -1038,7 +1038,7 @@ void wxRendererXP::DrawItemText(wxWindow* win, int flags, wxEllipsizeMode ellipsizeMode) { - wxUxThemeHandle hTheme(win, L"EXPLORER::LISTVIEW"); + wxUxThemeHandle hTheme(win, L"EXPLORER::LISTVIEW;LISTVIEW"); const int itemState = GetListItemState(flags); From f1eeeb02af69ebedf0cd80a6d602220dcebe1732 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 10 Jul 2021 22:53:01 +0100 Subject: [PATCH 3/5] Rename variable in render sample to a more generic name This will be used for things other than the header button too, so don't use "Hdr" in its name. No real changes, this is just a refactoring. --- samples/render/render.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/render/render.cpp b/samples/render/render.cpp index dd1a4bc6df..e16d7b0c98 100644 --- a/samples/render/render.cpp +++ b/samples/render/render.cpp @@ -247,7 +247,7 @@ private: y += lineHeight*3; const wxCoord heightHdr = renderer.GetHeaderButtonHeight(this); - const wxCoord widthHdr = 120; + const wxCoord width = 120; const wxHeaderSortIconType hdrSortIcon = m_useIcon ? wxHDR_SORT_ICON_UP @@ -266,13 +266,13 @@ private: // implementation. dc.DrawText("DrawHeaderButton() (default)", x1, y); wxRendererNative::GetDefault().DrawHeaderButton(this, dc, - wxRect(x2, y, widthHdr, heightHdr), m_flags, + wxRect(x2, y, width, heightHdr), m_flags, hdrSortIcon, &hdrParams); y += lineHeight + heightHdr; dc.DrawText("DrawHeaderButton() (overridden)", x1, y); renderer.DrawHeaderButton(this, dc, - wxRect(x2, y, widthHdr, heightHdr), m_flags, + wxRect(x2, y, width, heightHdr), m_flags, hdrSortIcon, &hdrParams); y += lineHeight + heightHdr; From c95a04310de00b4a657a154c20da80d7fd3d2ab9 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 10 Jul 2021 22:53:46 +0100 Subject: [PATCH 4/5] Use more appropriate size for DrawChoice() in the render sample The drawn combobox was so huge that it looked wrong, use a more reasonable size for it. --- samples/render/render.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/samples/render/render.cpp b/samples/render/render.cpp index e16d7b0c98..a8cd136125 100644 --- a/samples/render/render.cpp +++ b/samples/render/render.cpp @@ -352,8 +352,10 @@ private: y += heightListItem; - dc.DrawText("DrawChoice()", x1, y + 20); - renderer.DrawChoice(this, dc, wxRect(x2, y, 80, 50), m_flags); + y += lineHeight; + dc.DrawText("DrawChoice()", x1, y); + renderer.DrawChoice(this, dc, + wxRect(x2, y, width, 1.5*GetCharHeight()), m_flags); y += 50; } From 3a587cee195a0e745c10786a86746c0a4984df17 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 10 Jul 2021 22:57:18 +0100 Subject: [PATCH 5/5] Use DPI-independent positions and sizes in render sample Don't hardcode physical pixel values, use GetCharWidth() or FromDIP() to make the sample appear correctly in high DPI too. --- samples/render/render.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/samples/render/render.cpp b/samples/render/render.cpp index a8cd136125..f6589271f6 100644 --- a/samples/render/render.cpp +++ b/samples/render/render.cpp @@ -219,9 +219,9 @@ private: wxRendererNative& renderer = m_useGeneric ? wxRendererNative::GetGeneric() : wxRendererNative::Get(); - int x1 = 10, // text offset - x2 = 300, // drawing offset - y = 10; + int x1 = FromDIP(10), // text offset + x2 = FromDIP(300), // drawing offset + y = FromDIP(10); const int lineHeight = dc.GetCharHeight(); dc.DrawText("Demonstration of various wxRenderer functions:", x1, y); @@ -247,7 +247,7 @@ private: y += lineHeight*3; const wxCoord heightHdr = renderer.GetHeaderButtonHeight(this); - const wxCoord width = 120; + const wxCoord width = 15*GetCharWidth(); const wxHeaderSortIconType hdrSortIcon = m_useIcon ? wxHDR_SORT_ICON_UP @@ -307,7 +307,7 @@ private: #ifdef wxHAS_DRAW_TITLE_BAR_BITMAP dc.DrawText("DrawTitleBarBitmap()", x1, y); - wxRect rBtn(x2, y, 21, 21); + wxRect rBtn(x2, y, FromDIP(21), FromDIP(21)); renderer.DrawTitleBarBitmap(this, dc, rBtn, wxTITLEBAR_BUTTON_HELP, m_flags); rBtn.x += 2*rBtn.width; @@ -327,21 +327,21 @@ private: #endif // wxHAS_DRAW_TITLE_BAR_BITMAP // The meanings of those are reversed for the vertical gauge below. - const wxCoord heightGauge = 24; - const wxCoord widthGauge = 180; + const wxCoord heightGauge = FromDIP(24); + const wxCoord widthGauge = 30*GetCharWidth(); dc.DrawText("DrawGauge()", x1, y); renderer.DrawGauge(this, dc, wxRect(x2, y, widthGauge, heightGauge), 25, 100, m_flags); renderer.DrawGauge(this, dc, - wxRect(x2 + widthGauge + 30, y + heightGauge - widthGauge, + wxRect(x2 + widthGauge + FromDIP(30), y + heightGauge - widthGauge, heightGauge, widthGauge), 25, 100, m_flags | wxCONTROL_SPECIAL); y += lineHeight + heightGauge; - const wxCoord heightListItem = 48; - const wxCoord widthListItem = 260; + const wxCoord heightListItem = FromDIP(48); + const wxCoord widthListItem = 30*GetCharWidth(); dc.DrawText("DrawItemSelectionRect()", x1, y); renderer.DrawItemSelectionRect(this, dc, @@ -356,8 +356,6 @@ private: dc.DrawText("DrawChoice()", x1, y); renderer.DrawChoice(this, dc, wxRect(x2, y, width, 1.5*GetCharHeight()), m_flags); - y += 50; - } int m_flags;