Added DoGetClientBestSize() and use it for a couple of controls in wxMSW.
DoGetClientBestSize() returns the best size of the client area, without accounting for the border which is done by GetBestSize() itself and DoGetBorderSize() called from it. Use DoGetClientBestSize() in wxStaticText (where it was done insideDoGetBestSize() before) and in wxListBox, to fix its height calculation. Also use correct height of listbox items as returned by the control itself instead of trying to guess it. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61169 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user