]> git.saurik.com Git - wxWidgets.git/commitdiff
call SetInitialBestSize(), not SetBestSize(), when setting the best size initially
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 3 May 2004 12:38:20 +0000 (12:38 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 3 May 2004 12:38:20 +0000 (12:38 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27073 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/control.h
src/msw/control.cpp

index 62ea97b1b357308d88982341a5e606e5d4bbcf3e..b891236e4a4c3bf25485c022c660f9be40ffd0aa 100644 (file)
@@ -77,6 +77,17 @@ protected:
     // initialize the common fields of wxCommandEvent
     void InitCommandEvent(wxCommandEvent& event) const;
 
+    // set the initial window size if none is given (i.e. at least one of the
+    // components of the size passed to ctor/Create() is -1)
+    //
+    // normally just calls SetBestSize() but can be overridden not to do it for
+    // the controls which have to do some additional initialization (e.g. add
+    // strings to list box) before their best size can be accurately calculated
+    virtual void SetInitialBestSize(const wxSize& size)
+    {
+        SetBestSize(size);
+    }
+
     DECLARE_NO_COPY_CLASS(wxControlBase)
 };
 
index 3b6083693312c75521e6d5e378fededc805fe35b..a4b4718831da045155d80a470d460ae4208c904b 100644 (file)
@@ -171,10 +171,7 @@ bool wxControl::MSWCreateControl(const wxChar *classname,
     SetFont(GetDefaultAttributes().font);
 
     // set the size now if no initial size specified
-    if ( w <= 0 || h <= 0 )
-    {
-        SetBestSize(size);
-    }
+    SetInitialBestSize(size);
 
     return TRUE;
 }