From 2765d8098fb105c98d5f006fb124e9a94efec44a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 28 Oct 2024 23:37:50 +0100 Subject: [PATCH] Do offset wxClientDC and wxPaintDC by client area origin in wxMSW We didn't use GetClientAreaOrigin() in wxMSW, unlike in all the other ports, meaning that for the frames with a toolbar the origin of wxPaintDC was hidden behind the toolbar itself. Fix this and ensure that the origin is the point just below (or to the right of) the toolbar instead. --- docs/changes.txt | 5 +++++ src/msw/dcclient.cpp | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index f682d2c833..cf98b6a78f 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -108,6 +108,11 @@ Changes in behaviour not resulting in compilation errors platforms with RTF support. If you need to save/load plain text even for the files with the .rtf extension, specify wxTEXT_TYPE_PLAIN explicitly. +- wxClientDC and wxPaintDC now correctly offset their origin by wxFrame + toolbar, if any. This is consistent with the behaviour of the other ports + but may require removing any compensation for not doing this before that may + be present in the application code. + Changes in behaviour which may result in build errors ----------------------------------------------------- diff --git a/src/msw/dcclient.cpp b/src/msw/dcclient.cpp index cc2549ca7c..5818562618 100644 --- a/src/msw/dcclient.cpp +++ b/src/msw/dcclient.cpp @@ -188,9 +188,8 @@ void wxClientDCImpl::InitDC() { wxWindowDCImpl::InitDC(); - // in wxUniv build we must manually do some DC adjustments usually - // performed by Windows for us -#if defined(__WXUNIVERSAL__) + // Account for the origin of the client area which is non-zero only for + // TLWs with (left or top) toolbar: we shouldn't draw over the toolbar. wxPoint ptOrigin = m_window->GetClientAreaOrigin(); if ( ptOrigin.x || ptOrigin.y ) { @@ -198,6 +197,9 @@ void wxClientDCImpl::InitDC() SetDeviceOrigin(ptOrigin.x, ptOrigin.y); } + // in wxUniv build we must manually do some DC adjustments usually + // performed by Windows for us +#if defined(__WXUNIVERSAL__) // clip the DC to avoid overwriting the non client area wxSize size = m_window->GetClientSize(); DoSetClippingRegion(0, 0, size.x, size.y);