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.
This commit is contained in:
Maarten Bent 2019-01-13 15:45:06 +01:00
parent a1c3fa0468
commit 87a97054f2
2 changed files with 9 additions and 0 deletions

View File

@ -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);

View File

@ -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 );