From f9df538788aa51fd94bdcf6043b561749b66640a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 1 Jul 2016 20:37:19 +0200 Subject: [PATCH] Make empty list boxes narrower by default in wxMSW Allocating 100px (+ margins) for empty listboxes in wxMSW resulted in a surprising behaviour when the best size of a listbox became (significantly) smaller after adding some items to it. One possible solution could be to ensure that all listboxes are at least as wide as empty ones, but it seems wrong to insist on always allocating 100+ px when a listbox could be much narrower. So try to mitigate the problem by making the empty listboxes narrower by default which should reduce the chance of them becoming narrower still after appending some items to them, even if it doesn't completely eliminate it. Also, as a side effect, this commit replaces non-font-and-DPI-dependent hard-coded 100px value with a more reasonable value based on text metrics. --- src/msw/listbox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp index a99c1ff7e6..03636174d5 100644 --- a/src/msw/listbox.cpp +++ b/src/msw/listbox.cpp @@ -616,7 +616,7 @@ wxSize wxListBox::DoGetBestClientSize() const // give it some reasonable default value if there are no strings in the // list if ( wListbox == 0 ) - wListbox = 100; + wListbox = 6*GetCharWidth(); // the listbox should be slightly larger than the widest string wListbox += 3*GetCharWidth();