Merge branch 'msw-offset-fixes'

Fix handling client area offset in wxMSW for different DC classes.

See #24924.
This commit is contained in:
Vadim Zeitlin
2024-11-02 03:40:32 +01:00
3 changed files with 17 additions and 4 deletions
+5
View File
@@ -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
-----------------------------------------------------
+5 -3
View File
@@ -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);
+7 -1
View File
@@ -161,9 +161,15 @@ void wxOverlayImpl::Init(wxDC* dc, int , int , int , int )
m_window = dc->GetWindow();
// The rectangle must be in screen coordinates
m_rect = m_window->GetClientRect();
m_rect = m_window->GetClientSize();
m_window->ClientToScreen(&m_rect.x, &m_rect.y);
// Because wxClientDC adjusts the origin of the device context to the
// origin of the client area of the window, we need to compensate for it
// here, to make sure that (0, 0) of the rectangle corresponds to the point
// (0, 0) of the window client area.
m_rect.Offset(-m_window->GetClientAreaOrigin());
if ( IsUsingConstantOpacity() )
{
m_bitmap.CreateWithDIPSize(m_rect.GetSize(), m_window->GetDPIScaleFactor());