diff --git a/include/wx/odcombo.h b/include/wx/odcombo.h index d147cd49b0..a8ffa9570a 100644 --- a/include/wx/odcombo.h +++ b/include/wx/odcombo.h @@ -93,6 +93,7 @@ public: virtual void OnComboDoubleClick() wxOVERRIDE; virtual bool LazyCreate() wxOVERRIDE; virtual bool FindItem(const wxString& item, wxString* trueItem) wxOVERRIDE; + virtual void OnDPIChanged(wxDPIChangedEvent& event); // Item management void SetSelection( int item ); diff --git a/samples/combo/combo.cpp b/samples/combo/combo.cpp index 9a55db88de..6176989941 100644 --- a/samples/combo/combo.cpp +++ b/samples/combo/combo.cpp @@ -252,10 +252,7 @@ public: virtual wxCoord OnMeasureItem( size_t item ) const wxOVERRIDE { // Simply demonstrate the ability to have variable-height items - if ( item & 1 ) - return 36; - else - return 24; + return FromDIP( item & 1 ? 36 : 24 ); } virtual wxCoord OnMeasureItemWidth( size_t WXUNUSED(item) ) const wxOVERRIDE diff --git a/src/common/combocmn.cpp b/src/common/combocmn.cpp index 7383ea013d..b61aac35bf 100644 --- a/src/common/combocmn.cpp +++ b/src/common/combocmn.cpp @@ -20,6 +20,7 @@ #include "wx/combo.h" +#include "wx/display.h" #ifdef __WXMSW__ #include "wx/msw/private.h" @@ -2292,10 +2293,11 @@ void wxComboCtrlBase::ShowPopup() int maxHeightPopup; wxSize ctrlSz = GetSize(); - screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y, this ); + wxRect displayRect = wxDisplay(this).GetGeometry(); + screenHeight = displayRect.GetHeight(); scrPos = GetScreenPosition(); - spaceAbove = scrPos.y; + spaceAbove = scrPos.y - displayRect.GetY(); spaceBelow = screenHeight - spaceAbove - ctrlSz.y; maxHeightPopup = spaceBelow; @@ -2370,7 +2372,7 @@ void wxComboCtrlBase::ShowPopup() if ( wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft ) leftX -= ctrlSz.x; - int screenWidth = wxSystemSettings::GetMetric( wxSYS_SCREEN_X, this ); + int screenWidth = displayRect.GetWidth(); // If there is not enough horizontal space, anchor on the other side. // If there is no space even then, place the popup at x 0. diff --git a/src/generic/odcombo.cpp b/src/generic/odcombo.cpp index 49a3cd8141..22b4eefeda 100644 --- a/src/generic/odcombo.cpp +++ b/src/generic/odcombo.cpp @@ -84,6 +84,10 @@ bool wxVListBoxComboPopup::Create(wxWindow* parent) // TODO: Move this to SetFont m_itemHeight = m_combo->GetCharHeight(); + // Bind to the DPI event of the combobox. We get our own once the popup + // is shown, but this is too late, m_itemHeight is already being used. + m_combo->Bind(wxEVT_DPI_CHANGED, &wxVListBoxComboPopup::OnDPIChanged, this); + return true; } @@ -104,6 +108,11 @@ void wxVListBoxComboPopup::SetFocus() #endif } +void wxVListBoxComboPopup::OnDPIChanged(wxDPIChangedEvent& WXUNUSED(event)) +{ + m_itemHeight = m_combo->GetCharHeight(); +} + bool wxVListBoxComboPopup::LazyCreate() { // NB: There is a bug with wxVListBox that can be avoided by creating diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index 8fa51de825..61be08bb01 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -62,6 +62,7 @@ #include "wx/timer.h" #include "wx/dcbuffer.h" #include "wx/scopeguard.h" +#include "wx/display.h" // Two pics for the expand / collapse buttons. // Files are not supplied with this project (since it is @@ -1715,27 +1716,29 @@ wxPoint wxPropertyGrid::GetGoodEditorDialogPosition( wxPGProperty* p, ImprovedClientToScreen( &x, &y ); - int sw = wxSystemSettings::GetMetric( ::wxSYS_SCREEN_X, this ); - int sh = wxSystemSettings::GetMetric( ::wxSYS_SCREEN_Y, this ); + wxRect displayRect = wxDisplay(this).GetGeometry(); + + x -= displayRect.GetX(); + y -= displayRect.GetY(); int new_x; int new_y; - if ( x > (sw/2) ) + if ( x > (displayRect.GetWidth()/2) ) // left new_x = x + (m_width-splitterX) - sz.x; else // right new_x = x; - if ( y > (sh/2) ) + if ( y > (displayRect.GetHeight()/2) ) // above new_y = y - sz.y; else // below new_y = y + m_lineHeight; - return wxPoint(new_x,new_y); + return wxPoint(new_x + displayRect.GetX(), new_y + displayRect.GetY()); } // -----------------------------------------------------------------------