]> git.saurik.com Git - wxWidgets.git/commitdiff
SetInitialBestSize changes for wxMac
authorRobin Dunn <robin@alldunn.com>
Fri, 7 May 2004 04:31:12 +0000 (04:31 +0000)
committerRobin Dunn <robin@alldunn.com>
Fri, 7 May 2004 04:31:12 +0000 (04:31 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27132 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/window.h
src/mac/carbon/choice.cpp
src/mac/carbon/combobox.cpp
src/mac/carbon/listbox.cpp
src/mac/carbon/stattext.cpp
src/mac/carbon/window.cpp

index 28ad751f8e5b3c885a7fda387ac08bea87a3e044..d529e080997f616778da95859a60a505e2512626 100644 (file)
@@ -1140,6 +1140,16 @@ protected:
     // at all.
     void SetBestSize(const wxSize& size);
 
+    // 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() for controls, 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& WXUNUSED(size)) {}
+
+
     // more pure virtual functions
     // ---------------------------
 
index 7f264b39a9282839cdded35c73e4f5423d38c041..489243e04a7a7f24e6972954dcb942896881cd8d 100644 (file)
@@ -82,6 +82,7 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
     {
         Append(choices[i]);
     }
+    SetBestSize(size);   // Needed because it is a wxControlWithItems
     return TRUE;
 }
 
index c1fbe261a143e803ca18016433da099b065dfa6d..6b5d168080f322fc34e54bd844f39e3d1f463980 100644 (file)
@@ -311,6 +311,8 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
         m_choice->DoAppend( choices[ i ] );
     }
 
+    SetBestSize(csize);   // Needed because it is a wxControlWithItems
+
     return TRUE;
 }
 
index b6d64e70871509e0de1f0979b10f755a9a46004c..a566f193910532c9b305e237377c8498a2508f50 100644 (file)
@@ -246,6 +246,8 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
         Append( choices[i] ) ;
     }
 
+    SetBestSize(size);   // Needed because it is a wxControlWithItems
+    
     return TRUE;
 }
 
index 3536eb11e9359d6c78e8d2f51bac138c0d37fd61..e2bd22ed23209477b5493424df7809f5e04bff95 100644 (file)
@@ -92,7 +92,10 @@ void wxStaticText::SetLabel(const wxString& st )
                &ref );
 
     if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) )
+    {
         SetSize( GetBestSize() ) ;
+        SetSizeHints(GetSize());
+    }
 
     Update() ;
 }
@@ -104,7 +107,10 @@ bool wxStaticText::SetFont(const wxFont& font)
        if ( ret )
        {
            if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) )
+            {
                SetSize( GetBestSize() );
+                SetSizeHints(GetSize());
+            }
        }
 
     return ret;
index 773b9a239135f4f147089b2409a9093331aae03c..34bb95396f04a029b4fe9757298c726f89c92fc0 100644 (file)
@@ -683,16 +683,8 @@ void wxWindowMac::MacPostControlCreate(const wxPoint& pos, const wxSize& size)
 
     wxSize new_size = size ;
     if (!m_macIsUserPane)
-    {    
-        wxSize best_size( DoGetBestSize() );
-        
-        if (size.x == -1) {
-            new_size.x = best_size.x;
-        }
-        if (size.y == -1) {
-            new_size.y = best_size.y;
-        }
-        SetSize( pos.x, pos.y , new_size.x, new_size.y,wxSIZE_USE_EXISTING );
+    {
+        SetInitialBestSize(size);
     }
 
     SetCursor( *wxSTANDARD_CURSOR ) ;