X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b5dbe15d0bacde245539f54c4d97af6b4696f01f..235a997f9aea9d80774e296d314682e99e0c46f1:/include/wx/gbsizer.h diff --git a/include/wx/gbsizer.h b/include/wx/gbsizer.h index 45812f8f22..9ee4d48635 100644 --- a/include/wx/gbsizer.h +++ b/include/wx/gbsizer.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: gbsizer.h +// Name: wx/gbsizer.h // Purpose: wxGridBagSizer: A sizer that can lay out items in a grid, // with items at specified cells, and with the option of row // and/or column spanning @@ -28,7 +28,7 @@ // is used for this and also for wxGridCellCoords. //--------------------------------------------------------------------------- -class WXDLLEXPORT wxGBPosition +class WXDLLIMPEXP_CORE wxGBPosition { public: wxGBPosition() : m_row(0), m_col(0) {} @@ -50,29 +50,55 @@ private: }; -class WXDLLEXPORT wxGBSpan +class WXDLLIMPEXP_CORE wxGBSpan { public: - wxGBSpan() : m_rowspan(1), m_colspan(1) {} - wxGBSpan(int rowspan, int colspan) : m_rowspan(rowspan), m_colspan(colspan) {} + wxGBSpan() { Init(); } + wxGBSpan(int rowspan, int colspan) + { + // Initialize the members to valid values as not doing it may result in + // infinite loop in wxGBSizer code if the user passed 0 for any of + // them, see #12934. + Init(); + + SetRowspan(rowspan); + SetColspan(colspan); + } // default copy ctor and assignment operator are okay. int GetRowspan() const { return m_rowspan; } int GetColspan() const { return m_colspan; } - void SetRowspan(int rowspan) { m_rowspan = rowspan; } - void SetColspan(int colspan) { m_colspan = colspan; } + void SetRowspan(int rowspan) + { + wxCHECK_RET( rowspan > 0, "Row span should be strictly positive" ); + + m_rowspan = rowspan; + } + + void SetColspan(int colspan) + { + wxCHECK_RET( colspan > 0, "Column span should be strictly positive" ); + + m_colspan = colspan; + } bool operator==(const wxGBSpan& o) const { return m_rowspan == o.m_rowspan && m_colspan == o.m_colspan; } bool operator!=(const wxGBSpan& o) const { return !(*this == o); } private: + void Init() + { + m_rowspan = + m_colspan = 1; + } + int m_rowspan; int m_colspan; }; -extern WXDLLEXPORT_DATA(const wxGBSpan) wxDefaultSpan; +extern WXDLLIMPEXP_DATA_CORE(const wxGBSpan) wxDefaultSpan; //--------------------------------------------------------------------------- @@ -82,33 +108,33 @@ extern WXDLLEXPORT_DATA(const wxGBSpan) wxDefaultSpan; class WXDLLIMPEXP_FWD_CORE wxGridBagSizer; -class WXDLLEXPORT wxGBSizerItem : public wxSizerItem +class WXDLLIMPEXP_CORE wxGBSizerItem : public wxSizerItem { public: // spacer wxGBSizerItem( int width, int height, const wxGBPosition& pos, - const wxGBSpan& span, - int flag, - int border, - wxObject* userData); + const wxGBSpan& span=wxDefaultSpan, + int flag=0, + int border=0, + wxObject* userData=NULL); // window wxGBSizerItem( wxWindow *window, const wxGBPosition& pos, - const wxGBSpan& span, - int flag, - int border, - wxObject* userData ); + const wxGBSpan& span=wxDefaultSpan, + int flag=0, + int border=0, + wxObject* userData=NULL ); // subsizer wxGBSizerItem( wxSizer *sizer, const wxGBPosition& pos, - const wxGBSpan& span, - int flag, - int border, - wxObject* userData ); + const wxGBSpan& span=wxDefaultSpan, + int flag=0, + int border=0, + wxObject* userData=NULL ); // default ctor wxGBSizerItem(); @@ -134,7 +160,7 @@ public: // is successful and after the next Layout the item will be resized. bool SetSpan( const wxGBSpan& span ); - // Returns true if this item and the other item instersect + // Returns true if this item and the other item intersect bool Intersects(const wxGBSizerItem& other); // Returns true if the given pos/span would intersect with this item. @@ -156,7 +182,7 @@ protected: private: DECLARE_DYNAMIC_CLASS(wxGBSizerItem) - DECLARE_NO_COPY_CLASS(wxGBSizerItem) + wxDECLARE_NO_COPY_CLASS(wxGBSizerItem); }; @@ -165,7 +191,7 @@ private: //--------------------------------------------------------------------------- -class WXDLLEXPORT wxGridBagSizer : public wxFlexGridSizer +class WXDLLIMPEXP_CORE wxGridBagSizer : public wxFlexGridSizer { public: wxGridBagSizer(int vgap = 0, int hgap = 0 ); @@ -286,6 +312,7 @@ public: protected: wxGBPosition FindEmptyCell(); + void AdjustForOverflow(); wxSize m_emptyCellSize; @@ -293,7 +320,7 @@ protected: private: DECLARE_CLASS(wxGridBagSizer) - DECLARE_NO_COPY_CLASS(wxGridBagSizer) + wxDECLARE_NO_COPY_CLASS(wxGridBagSizer); }; //---------------------------------------------------------------------------