wxGTK's wxListBox now returns a meaningful value for DoGetBestSize

instead of just 100x110.  (Needed by wxSTC.)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12056 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2001-10-18 16:56:01 +00:00
parent f056ea60f3
commit f96b15a3c2
2 changed files with 72 additions and 26 deletions

View File

@@ -1053,7 +1053,30 @@ void wxListBox::OnInternalIdle()
wxSize wxListBox::DoGetBestSize() const
{
return wxSize(100, 110);
int lbWidth = 100; // some defaults
int lbHeight = 110;
int wLine;
// Find the widest line
for(int i = 0; i < GetCount(); i++) {
wxString str(GetString(i));
GetTextExtent(str, &wLine, NULL);
lbWidth = wxMax(lbWidth, wLine);
}
// Add room for the scrollbar
lbWidth += wxSystemSettings::GetSystemMetric(wxSYS_VSCROLL_X);
// And just a bit more
int cx, cy;
GetTextExtent("X", &cx, &cy);
lbWidth += 3 * cx;
// don't make the listbox too tall (limit height to around 10 items) but don't
// make it too small neither
lbHeight = (cy+4) * wxMin(wxMax(GetCount(), 3), 10);
return wxSize(lbWidth, lbHeight);
}
#endif

View File

@@ -1053,7 +1053,30 @@ void wxListBox::OnInternalIdle()
wxSize wxListBox::DoGetBestSize() const
{
return wxSize(100, 110);
int lbWidth = 100; // some defaults
int lbHeight = 110;
int wLine;
// Find the widest line
for(int i = 0; i < GetCount(); i++) {
wxString str(GetString(i));
GetTextExtent(str, &wLine, NULL);
lbWidth = wxMax(lbWidth, wLine);
}
// Add room for the scrollbar
lbWidth += wxSystemSettings::GetSystemMetric(wxSYS_VSCROLL_X);
// And just a bit more
int cx, cy;
GetTextExtent("X", &cx, &cy);
lbWidth += 3 * cx;
// don't make the listbox too tall (limit height to around 10 items) but don't
// make it too small neither
lbHeight = (cy+4) * wxMin(wxMax(GetCount(), 3), 10);
return wxSize(lbWidth, lbHeight);
}
#endif