diff --git a/include/wx/msw/checklst.h b/include/wx/msw/checklst.h index 8fa50253ba..91180c6a3e 100644 --- a/include/wx/msw/checklst.h +++ b/include/wx/msw/checklst.h @@ -81,6 +81,8 @@ protected: ProcessCommand(event); } + virtual void MSWUpdateFontOnDPIChange(const wxSize& newDPI) wxOVERRIDE; + wxSize DoGetBestClientSize() const wxOVERRIDE; wxDECLARE_EVENT_TABLE(); diff --git a/include/wx/msw/listbox.h b/include/wx/msw/listbox.h index 3ba0175320..3c910e325e 100644 --- a/include/wx/msw/listbox.h +++ b/include/wx/msw/listbox.h @@ -181,6 +181,8 @@ protected: return wxSize(w, h); } + virtual void MSWUpdateFontOnDPIChange(const wxSize& newDPI) wxOVERRIDE; + // free memory (common part of Clear() and dtor) void Free(); diff --git a/src/msw/checklst.cpp b/src/msw/checklst.cpp index 753bccc335..911dd1cb86 100644 --- a/src/msw/checklst.cpp +++ b/src/msw/checklst.cpp @@ -255,7 +255,20 @@ bool wxCheckListBox::MSWOnMeasure(WXMEASUREITEMSTRUCT *item) } return false; - } +} + +void wxCheckListBox::MSWUpdateFontOnDPIChange(const wxSize& newDPI) +{ + wxCheckListBoxBase::MSWUpdateFontOnDPIChange(newDPI); + + wxSize size = wxRendererNative::Get().GetCheckBoxSize(this); + size.x += 2 * CHECKMARK_EXTRA_SPACE + CHECKMARK_LABEL_SPACE; + + for ( unsigned int i = 0; i < GetCount(); ++i ) + { + GetItem(i)->SetMarginWidth(size.GetWidth()); + } +} // check items // ----------- diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp index 02f2ecb9e5..128f679d2c 100644 --- a/src/msw/listbox.cpp +++ b/src/msw/listbox.cpp @@ -190,6 +190,14 @@ WXDWORD wxListBox::MSWGetStyle(long style, WXDWORD *exstyle) const return msStyle; } +void wxListBox::MSWUpdateFontOnDPIChange(const wxSize& newDPI) +{ + wxListBoxBase::MSWUpdateFontOnDPIChange(newDPI); + + if ( m_font.IsOk() ) + SetFont(m_font); +} + void wxListBox::OnInternalIdle() { wxWindow::OnInternalIdle(); @@ -695,22 +703,22 @@ bool wxListBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id)) bool wxListBox::SetFont(const wxFont &font) { + wxListBoxBase::SetFont(font); + if ( HasFlag(wxLB_OWNERDRAW) ) { const unsigned count = m_aItems.GetCount(); for ( unsigned i = 0; i < count; i++ ) - m_aItems[i]->SetFont(font); + m_aItems[i]->SetFont(m_font); // Non owner drawn list boxes update the item height on their own, but // we need to do it manually in the owner drawn case. wxClientDC dc(this); - dc.SetFont(font); + dc.SetFont(m_font); SendMessage(GetHwnd(), LB_SETITEMHEIGHT, 0, dc.GetCharHeight() + 2 * LISTBOX_EXTRA_SPACE); } - wxListBoxBase::SetFont(font); - return true; }