From 87a97054f2ca89e2932df9d91da1bd526faa85cf Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sun, 13 Jan 2019 15:45:06 +0100 Subject: [PATCH] Allow to retrieve the wxWindow associated with a wxBufferedPaintDC When a wxBufferedPaintDC is created, the base classes does not initialize the m_window variable with the used wxWindow. Only the associated m_paintdc initializes this variable. Add a protected function that allows to set the wxWindow of a wxDC so GetWindow() will return the window. This fixes the font size of custom attributes in wxDataViewCtrl when the DPI changes. --- include/wx/dc.h | 5 +++++ include/wx/dcbuffer.h | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/include/wx/dc.h b/include/wx/dc.h index 847b7f64e5..cc0a48238e 100644 --- a/include/wx/dc.h +++ b/include/wx/dc.h @@ -269,6 +269,8 @@ public: wxWindow* GetWindow() const { return m_window; } + void SetWindow(wxWindow* w) { m_window = w; } + virtual bool IsOk() const { return m_ok; } // query capabilities @@ -1364,6 +1366,9 @@ protected: wxDCImpl * const m_pimpl; + void SetWindow(wxWindow* w) + { return m_pimpl->SetWindow(w); } + private: wxDECLARE_ABSTRACT_CLASS(wxDC); wxDECLARE_NO_COPY_CLASS(wxDC); diff --git a/include/wx/dcbuffer.h b/include/wx/dcbuffer.h index 4a29fda820..8fc23d66cd 100644 --- a/include/wx/dcbuffer.h +++ b/include/wx/dcbuffer.h @@ -153,6 +153,8 @@ public: wxBufferedPaintDC(wxWindow *window, wxBitmap& buffer, int style = wxBUFFER_CLIENT_AREA) : m_paintdc(window) { + SetWindow(window); + // If we're buffering the virtual window, scale the paint DC as well if (style & wxBUFFER_VIRTUAL_AREA) window->PrepareDC( m_paintdc ); @@ -167,6 +169,8 @@ public: wxBufferedPaintDC(wxWindow *window, int style = wxBUFFER_CLIENT_AREA) : m_paintdc(window) { + SetWindow(window); + // If we're using the virtual window, scale the paint DC as well if (style & wxBUFFER_VIRTUAL_AREA) window->PrepareDC( m_paintdc );