diff --git a/include/wx/cocoa/listbox.h b/include/wx/cocoa/listbox.h index fac2a73aa4..847bf2bbe8 100644 --- a/include/wx/cocoa/listbox.h +++ b/include/wx/cocoa/listbox.h @@ -83,6 +83,7 @@ protected: // Implementation // ------------------------------------------------------------------------ public: + virtual wxSize DoGetBestSize() const; // pure virtuals from wxListBoxBase virtual bool IsSelected(int n) const; virtual int GetSelections(wxArrayInt& aSelections) const; diff --git a/src/cocoa/listbox.mm b/src/cocoa/listbox.mm index 25c66be336..ded31aa7db 100644 --- a/src/cocoa/listbox.mm +++ b/src/cocoa/listbox.mm @@ -191,6 +191,20 @@ The listbox contents are sorted in alphabetical order. return true; } +wxSize wxListBox::DoGetBestSize() const +{ + wxSize size = wxControlWithItems::DoGetBestSize(); + // Limit best size to 100x100. It can be smaller if none of the items are very + // wide or if there aren't many items, but anything bigger than 100x100 ought + // to be asked for by the programmer. The 100x100 size is based on being barely + // enough for a scroller to be usable. + if(size.GetWidth() > 100) + size.SetWidth(100); + if(size.GetHeight() > 100) + size.SetHeight(100); + return size; +} + wxListBox::~wxListBox() { [GetNSTableView() setDataSource: nil];