From b15f361171afeadc8147b4ffd03b0e5cd8fbceba Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 9 Jun 2014 00:54:17 +0000 Subject: [PATCH] Fix wxMSW wxCheckListBox appearance when using larger than normal fonts. Update the height of the items when changing the font to ensure that there is enough space to show the item text when using fonts larger than normal. Closes #3577. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76673 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/listbox.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp index 4a452a16bf..5509e049cf 100644 --- a/src/msw/listbox.cpp +++ b/src/msw/listbox.cpp @@ -37,7 +37,13 @@ #if wxUSE_OWNER_DRAWN #include "wx/ownerdrw.h" -#endif + + namespace + { + // space beneath/above each row in pixels + const int LISTBOX_EXTRA_SPACE = 1; + } // anonymous namespace +#endif // wxUSE_OWNER_DRAWN // ============================================================================ // list box item declaration and implementation @@ -642,6 +648,13 @@ bool wxListBox::SetFont(const wxFont &font) const unsigned count = m_aItems.GetCount(); for ( unsigned i = 0; i < count; i++ ) m_aItems[i]->SetFont(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); + SendMessage(GetHwnd(), LB_SETITEMHEIGHT, 0, + dc.GetCharHeight() + 2 * LISTBOX_EXTRA_SPACE); } wxListBoxBase::SetFont(font); @@ -684,13 +697,6 @@ bool wxListBox::RefreshItem(size_t n) // drawing // ------- -namespace -{ - // space beneath/above each row in pixels - static const int LISTBOX_EXTRA_SPACE = 1; - -} // anonymous namespace - // the height is the same for all items // TODO should be changed for LBS_OWNERDRAWVARIABLE style listboxes