From 462f2a4686855ca2fdaeff1daa537b189d7b6cab Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Wed, 4 Sep 2019 20:53:07 +0200 Subject: [PATCH] Add optional wxWindow parameter to wxButtonBase::GetDefaultSize() When per-monitor DPI is used, the default button size depends on the DPI of the display. Use the window to determine this DPI. --- include/wx/button.h | 5 +++-- interface/wx/button.h | 11 +++++++---- src/gtk/button.cpp | 2 +- src/gtk1/button.cpp | 2 +- src/msw/button.cpp | 4 +--- src/osx/button_osx.cpp | 2 +- src/qt/button.cpp | 2 +- src/univ/button.cpp | 2 +- 8 files changed, 16 insertions(+), 14 deletions(-) diff --git a/include/wx/button.h b/include/wx/button.h index f31166413e..0f26c65b0c 100644 --- a/include/wx/button.h +++ b/include/wx/button.h @@ -39,8 +39,9 @@ public: // returns the old default item (possibly NULL) virtual wxWindow *SetDefault(); - // returns the default button size for this platform - static wxSize GetDefaultSize(); + // returns the default button size for this platform, and optionally for a + // specific window when the platform supports per-monitor DPI + static wxSize GetDefaultSize(wxWindow* win = NULL); protected: wxDECLARE_NO_COPY_CLASS(wxButtonBase); diff --git a/interface/wx/button.h b/interface/wx/button.h index 923415ae17..b4cdbb2517 100644 --- a/interface/wx/button.h +++ b/interface/wx/button.h @@ -179,11 +179,14 @@ public: /** - Returns the default size for the buttons. It is advised to make all the dialog - buttons of the same size and this function allows retrieving the (platform and - current font dependent size) which should be the best suited for this. + Returns the default size for the buttons. It is advised to make all the + dialog buttons of the same size and this function allows retrieving the + (platform, and current font dependent) size which should be the best + suited for this. + The optional wxWindow parameter allows to get a per-monitor DPI + specific size. */ - static wxSize GetDefaultSize(); + static wxSize GetDefaultSize(wxWindow* win = NULL); /** Returns the string label for the button. diff --git a/src/gtk/button.cpp b/src/gtk/button.cpp index ce72ff150a..012aa24b44 100644 --- a/src/gtk/button.cpp +++ b/src/gtk/button.cpp @@ -165,7 +165,7 @@ wxWindow *wxButton::SetDefault() } /* static */ -wxSize wxButtonBase::GetDefaultSize() +wxSize wxButtonBase::GetDefaultSize(wxWindow* WXUNUSED(win)) { static wxSize size = wxDefaultSize; if (size == wxDefaultSize) diff --git a/src/gtk1/button.cpp b/src/gtk1/button.cpp index 3f7c09026b..932ef8bdbc 100644 --- a/src/gtk1/button.cpp +++ b/src/gtk1/button.cpp @@ -166,7 +166,7 @@ wxWindow *wxButton::SetDefault() } /* static */ -wxSize wxButtonBase::GetDefaultSize() +wxSize wxButtonBase::GetDefaultSize(wxWindow* WXUNUSED(win)) { return wxSize(80,26); } diff --git a/src/msw/button.cpp b/src/msw/button.cpp index 786bdc143d..31a27b41d9 100644 --- a/src/msw/button.cpp +++ b/src/msw/button.cpp @@ -160,10 +160,8 @@ WXDWORD wxButton::MSWGetStyle(long style, WXDWORD *exstyle) const } /* static */ -wxSize wxButtonBase::GetDefaultSize() +wxSize wxButtonBase::GetDefaultSize(wxWindow* win) { - wxWindow* win = wxTheApp ? wxTheApp->GetTopWindow() : NULL; - static wxPrivate::DpiDependentValue s_sizeBtn; if ( s_sizeBtn.HasChanged(win) ) diff --git a/src/osx/button_osx.cpp b/src/osx/button_osx.cpp index 8895171565..8ee6dc55b2 100644 --- a/src/osx/button_osx.cpp +++ b/src/osx/button_osx.cpp @@ -137,7 +137,7 @@ bool wxButton::OSXHandleClicked( double WXUNUSED(timestampsec) ) } /* static */ -wxSize wxButtonBase::GetDefaultSize() +wxSize wxButtonBase::GetDefaultSize(wxWindow* WXUNUSED(win)) { return wxAnyButton::GetDefaultSize(); } diff --git a/src/qt/button.cpp b/src/qt/button.cpp index aa61ab127a..3911f987b0 100644 --- a/src/qt/button.cpp +++ b/src/qt/button.cpp @@ -61,7 +61,7 @@ wxWindow *wxButton::SetDefault() } /* static */ -wxSize wxButtonBase::GetDefaultSize() +wxSize wxButtonBase::GetDefaultSize(wxWindow* WXUNUSED(win)) { static wxSize size = wxDefaultSize; if (size == wxDefaultSize) diff --git a/src/univ/button.cpp b/src/univ/button.cpp index 7819391786..aa3a02cceb 100644 --- a/src/univ/button.cpp +++ b/src/univ/button.cpp @@ -110,7 +110,7 @@ wxButton::~wxButton() // ---------------------------------------------------------------------------- /* static */ -wxSize wxButtonBase::GetDefaultSize() +wxSize wxButtonBase::GetDefaultSize(wxWindow* WXUNUSED(win)) { static wxSize s_sizeBtn;