]> git.saurik.com Git - wxWidgets.git/commitdiff
Limit wxListBox best size to 100x100. Particularly important on trunk where
authorDavid Elliott <dfe@tgwbd.org>
Mon, 18 Feb 2008 21:51:29 +0000 (21:51 +0000)
committerDavid Elliott <dfe@tgwbd.org>
Mon, 18 Feb 2008 21:51:29 +0000 (21:51 +0000)
the best size is not cached and will thus keep telling the sizers that the
best size is the full size of the content (i.e. such that you wouldn't need
to scroll it).

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51894 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/cocoa/listbox.h
src/cocoa/listbox.mm

index d7bae5cb5228d4929a13b0fa13147b512db663d2..2d4c74b94e083d58928db4f9bbf8e91539469d7f 100644 (file)
@@ -84,6 +84,7 @@ protected:
 // Implementation
 // ------------------------------------------------------------------------
 public:
+    virtual wxSize DoGetBestSize() const;
 // pure virtuals from wxListBoxBase
     virtual bool IsSelected(int n) const;
     virtual int GetSelections(wxArrayInt& aSelections) const;
index 969dff944541ddae3832a541bb83b38f9a0accf7..3731f9461bd9154cdb0eb8908992704b09a432b0 100644 (file)
@@ -173,6 +173,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];