Move DPI handling from wxTopLevelWindow to wxNonOwnedWindow

This way, other windows (like wxPopupWindow) will also be able to handle DPI events.

Override InheritAttributes() and use it to set the initial DPI values.
This commit is contained in:
Maarten Bent
2020-06-01 13:58:12 +02:00
parent a29aae25fc
commit 4700298c26
4 changed files with 122 additions and 107 deletions

View File

@@ -27,11 +27,27 @@ protected:
virtual bool DoSetRegionShape(const wxRegion& region) wxOVERRIDE;
#if wxUSE_GRAPHICS_CONTEXT
virtual bool DoSetPathShape(const wxGraphicsPath& path) wxOVERRIDE;
#endif // wxUSE_GRAPHICS_CONTEXT
virtual WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) wxOVERRIDE;
virtual void InheritAttributes() wxOVERRIDE;
private:
bool HandleDPIChange(const wxSize& newDPI, const wxRect& newRect);
#if wxUSE_GRAPHICS_CONTEXT
wxNonOwnedWindowShapeImpl* m_shapeImpl;
#endif // wxUSE_GRAPHICS_CONTEXT
// Keep track of the DPI used in this window. So when per-monitor dpi
// awareness is enabled, both old and new DPI are known for
// wxDPIChangedEvent and wxWindow::MSWUpdateOnDPIChange.
wxSize m_activeDPI;
// This window supports handling per-monitor DPI awareness when the
// application manifest contains <dpiAwareness>PerMonitorV2</dpiAwareness>.
bool m_perMonitorDPIaware;
wxDECLARE_NO_COPY_CLASS(wxNonOwnedWindow);
};

View File

@@ -115,7 +115,7 @@ public:
virtual WXHWND MSWGetParent() const wxOVERRIDE;
// window proc for the frames
WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) wxOVERRIDE;
virtual WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) wxOVERRIDE;
// returns true if the platform should explicitly apply a theme border
virtual bool CanApplyThemeBorder() const wxOVERRIDE { return false; }
@@ -166,9 +166,6 @@ protected:
int& x, int& y,
int& w, int& h) const wxOVERRIDE;
// WM_DPICHANGED handler.
bool HandleDPIChange(const wxSize& newDPI, const wxRect& newRect);
// This field contains the show command to use when showing the window the
// next time and also indicates whether the window should be considered
// being iconized or maximized (which may be different from whether it's
@@ -195,15 +192,6 @@ protected:
wxWindowRef m_winLastFocused;
private:
// Keep track of the DPI used in this window. So when per-monitor dpi
// awareness is enabled, both old and new DPI are known for
// wxDPIChangedEvent and wxWindow::MSWUpdateOnDPIChange.
wxSize m_activeDPI;
// This window supports handling per-monitor DPI awareness when the
// application manifest contains <dpiAwareness>PerMonitorV2</dpiAwareness>.
bool m_perMonitorDPIaware;
// The system menu: initially NULL but can be set (once) by
// MSWGetSystemMenu(). Owned by this window.
wxMenu *m_menuSystem;