diff --git a/include/wx/collpane.h b/include/wx/collpane.h index 54ccd73650..168dc7c06e 100644 --- a/include/wx/collpane.h +++ b/include/wx/collpane.h @@ -43,6 +43,23 @@ public: virtual wxString GetLabel() const wxOVERRIDE = 0; virtual void SetLabel(const wxString& label) wxOVERRIDE = 0; + + virtual bool + InformFirstDirection(int direction, + int size, + int availableOtherDir) wxOVERRIDE + { + wxWindow* const p = GetPane(); + if ( !p ) + return false; + + if ( !p->InformFirstDirection(direction, size, availableOtherDir) ) + return false; + + InvalidateBestSize(); + + return true; + } }; diff --git a/include/wx/sizer.h b/include/wx/sizer.h index 14b446a71a..16c86222a1 100644 --- a/include/wx/sizer.h +++ b/include/wx/sizer.h @@ -619,6 +619,10 @@ public: // Inform sizer about the first direction that has been decided (by parent item) // Returns true if it made use of the information (and recalculated min size) + // + // Note that while this method doesn't do anything by default, it should + // almost always be overridden in the derived classes and should have been + // pure virtual if not for backwards compatibility constraints. virtual bool InformFirstDirection( int WXUNUSED(direction), int WXUNUSED(size), int WXUNUSED(availableOtherDir) ) { return false; } @@ -958,6 +962,10 @@ public: virtual wxSize CalcMin() wxOVERRIDE; virtual void RecalcSizes() wxOVERRIDE; + virtual bool InformFirstDirection(int direction, + int size, + int availableOtherDir) wxOVERRIDE; + protected: // Only overridden to perform extra debugging checks. virtual wxSizerItem *DoInsert(size_t index, wxSizerItem *item) wxOVERRIDE; diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp index ba50b6c9c0..fa42c07497 100644 --- a/src/common/sizer.cpp +++ b/src/common/sizer.cpp @@ -2544,6 +2544,31 @@ wxSize wxBoxSizer::CalcMin() return m_calculatedMinSize; } +bool +wxBoxSizer::InformFirstDirection(int direction, int size, int availableOtherDir) +{ + // In principle, we could propagate the information about the size in the + // sizer major direction too, but this would require refactoring CalcMin() + // to determine the actual sizes all our items would have with the given + // size and we don't do this yet, so for now handle only the simpler case + // of informing all our items about their size in the orthogonal direction. + if ( direction == GetOrientation() ) + return false; + + bool didUse = false; + + for ( wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); + node; + node = node->GetNext() ) + { + didUse |= node->GetData()->InformFirstDirection(direction, + size, + availableOtherDir); + } + + return didUse; +} + //--------------------------------------------------------------------------- // wxStaticBoxSizer //---------------------------------------------------------------------------