From: Robin Dunn Date: Fri, 7 May 2004 04:31:12 +0000 (+0000) Subject: SetInitialBestSize changes for wxMac X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/d3b5db4b25043b35e93215b36e4d82e0e163fe43 SetInitialBestSize changes for wxMac git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27132 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/window.h b/include/wx/window.h index 28ad751f8e..d529e08099 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -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 // --------------------------- diff --git a/src/mac/carbon/choice.cpp b/src/mac/carbon/choice.cpp index 7f264b39a9..489243e04a 100644 --- a/src/mac/carbon/choice.cpp +++ b/src/mac/carbon/choice.cpp @@ -82,6 +82,7 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, { Append(choices[i]); } + SetBestSize(size); // Needed because it is a wxControlWithItems return TRUE; } diff --git a/src/mac/carbon/combobox.cpp b/src/mac/carbon/combobox.cpp index c1fbe261a1..6b5d168080 100644 --- a/src/mac/carbon/combobox.cpp +++ b/src/mac/carbon/combobox.cpp @@ -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; } diff --git a/src/mac/carbon/listbox.cpp b/src/mac/carbon/listbox.cpp index b6d64e7087..a566f19391 100644 --- a/src/mac/carbon/listbox.cpp +++ b/src/mac/carbon/listbox.cpp @@ -246,6 +246,8 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, Append( choices[i] ) ; } + SetBestSize(size); // Needed because it is a wxControlWithItems + return TRUE; } diff --git a/src/mac/carbon/stattext.cpp b/src/mac/carbon/stattext.cpp index 3536eb11e9..e2bd22ed23 100644 --- a/src/mac/carbon/stattext.cpp +++ b/src/mac/carbon/stattext.cpp @@ -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; diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index 773b9a2391..34bb95396f 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -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 ) ;