]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/listbox.cpp
Added DoGetClientBestSize() and use it for a couple of controls in wxMSW.
[wxWidgets.git] / src / msw / listbox.cpp
index 3e6b8a7612eb47f17c0fd49f2bac850459e66923..84634d3088dc02fce0ceaead97dbddc56e897d02 100644 (file)
@@ -590,7 +590,7 @@ void wxListBox::SetHorizontalExtent(const wxString& s)
     //else: it shouldn't change
 }
 
-wxSize wxListBox::DoGetBestSize() const
+wxSize wxListBox::DoGetBestClientSize() const
 {
     // find the widest string
     int wLine;
@@ -609,22 +609,17 @@ wxSize wxListBox::DoGetBestSize() const
         wListbox = 100;
 
     // the listbox should be slightly larger than the widest string
-    int cx, cy;
-    wxGetCharSize(GetHWND(), &cx, &cy, GetFont());
+    wListbox += 3*GetCharWidth();
 
-    wListbox += 3*cx;
-
-    // Add room for the scrollbar
+    // add room for the scrollbar
     wListbox += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
 
     // don't make the listbox too tall (limit height to 10 items) but don't
     // make it too small neither
-    int hListbox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy)*
+    int hListbox = SendMessage(GetHwnd(), LB_GETITEMHEIGHT, 0, 0)*
                     wxMin(wxMax(m_noItems, 3), 10);
 
-    wxSize best(wListbox, hListbox);
-    CacheBestSize(best);
-    return best;
+    return wxSize(wListbox, hListbox);
 }
 
 // ----------------------------------------------------------------------------