]> git.saurik.com Git - wxWidgets.git/commitdiff
Invalidate best size of wxOSX wxChoice after its number of items changes.
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 1 Nov 2012 17:15:25 +0000 (17:15 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 1 Nov 2012 17:15:25 +0000 (17:15 +0000)
This fixes the calculation of the initial best size as previously the default
value was not updated even if longer strings were added later.

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

include/wx/osx/choice.h
src/osx/choice_osx.cpp

index 3e8898373c63d40c2b7273d9fb2e2237615a9179..720b9c509d543473695d9aaae2f136a9951e0439 100644 (file)
@@ -93,6 +93,10 @@ protected:
     wxArrayString m_strings;
     wxChoiceDataArray m_datas ;
     wxMenu*    m_popUpMenu ;
     wxArrayString m_strings;
     wxChoiceDataArray m_datas ;
     wxMenu*    m_popUpMenu ;
+
+private:
+    // This should be called when the number of items in the control changes.
+    void DoAfterItemCountChange();
 };
 
 #endif
 };
 
 #endif
index e610b8c86fff6888b364375dbfe10339d198d96c..d26812a571b6efe11f320d7ea6209915f16396bd 100644 (file)
@@ -100,6 +100,13 @@ bool wxChoice::Create(wxWindow *parent,
 // adding/deleting items to/from the list
 // ----------------------------------------------------------------------------
 
 // adding/deleting items to/from the list
 // ----------------------------------------------------------------------------
 
+void wxChoice::DoAfterItemCountChange()
+{
+    InvalidateBestSize();
+
+    GetPeer()->SetMaximum( GetCount() );
+}
+
 int wxChoice::DoInsertItems(const wxArrayStringsAdapter & items,
                             unsigned int pos,
                             void **clientData, wxClientDataType type)
 int wxChoice::DoInsertItems(const wxArrayStringsAdapter & items,
                             unsigned int pos,
                             void **clientData, wxClientDataType type)
@@ -132,7 +139,7 @@ int wxChoice::DoInsertItems(const wxArrayStringsAdapter & items,
         AssignNewItemClientData(idx, clientData, i, type);
     }
 
         AssignNewItemClientData(idx, clientData, i, type);
     }
 
-    GetPeer()->SetMaximum( GetCount() );
+    DoAfterItemCountChange();
 
     return pos - 1;
 }
 
     return pos - 1;
 }
@@ -148,8 +155,8 @@ void wxChoice::DoDeleteOneItem(unsigned int n)
 
     m_strings.RemoveAt( n ) ;
     m_datas.RemoveAt( n ) ;
 
     m_strings.RemoveAt( n ) ;
     m_datas.RemoveAt( n ) ;
-    GetPeer()->SetMaximum( GetCount() ) ;
 
 
+    DoAfterItemCountChange();
 }
 
 void wxChoice::DoClear()
 }
 
 void wxChoice::DoClear()
@@ -162,7 +169,7 @@ void wxChoice::DoClear()
     m_strings.Empty() ;
     m_datas.Empty() ;
 
     m_strings.Empty() ;
     m_datas.Empty() ;
 
-    GetPeer()->SetMaximum( 0 ) ;
+    DoAfterItemCountChange();
 }
 
 // ----------------------------------------------------------------------------
 }
 
 // ----------------------------------------------------------------------------