adding bestsize for osx_cocoa combobox
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64668 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
c14ae7f5b3
commit
5bd7710593
@ -165,9 +165,9 @@ protected:
|
||||
#endif
|
||||
virtual wxWindow *GetEditableWindow() { return this; }
|
||||
|
||||
#if wxOSX_USE_CARBON
|
||||
// override the base class virtuals involved in geometry calculations
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
#if wxOSX_USE_CARBON
|
||||
virtual void DoMoveWindow(int x, int y, int width, int height);
|
||||
#endif
|
||||
|
||||
|
@ -154,4 +154,33 @@ wxWidgetImplType* wxWidgetImpl::CreateComboBox( wxWindowMac* wxpeer,
|
||||
return c;
|
||||
}
|
||||
|
||||
wxSize wxComboBox::DoGetBestSize() const
|
||||
{
|
||||
int lbWidth = GetCount() > 0 ? 20 : 100; // some defaults
|
||||
wxSize baseSize = wxWindow::DoGetBestSize();
|
||||
int lbHeight = baseSize.y;
|
||||
int wLine;
|
||||
|
||||
{
|
||||
wxClientDC dc(const_cast<wxComboBox*>(this));
|
||||
|
||||
// Find the widest line
|
||||
for(unsigned int i = 0; i < GetCount(); i++)
|
||||
{
|
||||
wxString str(GetString(i));
|
||||
|
||||
wxCoord width, height ;
|
||||
dc.GetTextExtent( str , &width, &height);
|
||||
wLine = width ;
|
||||
|
||||
lbWidth = wxMax( lbWidth, wLine ) ;
|
||||
}
|
||||
|
||||
// Add room for the popup arrow
|
||||
lbWidth += 2 * lbHeight ;
|
||||
}
|
||||
|
||||
return wxSize( lbWidth, lbHeight );
|
||||
}
|
||||
|
||||
#endif // wxUSE_COMBOBOX
|
Loading…
Reference in New Issue
Block a user