X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d95527de9ac48fa54207ebf698286f92e909faaf..5064e6eff3ca35cb20130dc9e5e53fb3ac02127e:/include/wx/sizer.h?ds=sidebyside diff --git a/include/wx/sizer.h b/include/wx/sizer.h index d477a2e0f4..8aa759e376 100644 --- a/include/wx/sizer.h +++ b/include/wx/sizer.h @@ -75,8 +75,10 @@ public: // some shortcuts for Align() wxSizerFlags& Centre() { return Align(wxCENTRE); } wxSizerFlags& Center() { return Centre(); } + wxSizerFlags& Top() { return Align(wxALIGN_TOP); } wxSizerFlags& Left() { return Align(wxALIGN_LEFT); } wxSizerFlags& Right() { return Align(wxALIGN_RIGHT); } + wxSizerFlags& Bottom() { return Align(wxALIGN_BOTTOM); } // default border size used by Border() below static int GetDefaultBorder() @@ -153,7 +155,6 @@ public: #endif } -#if wxABI_VERSION >= 20802 // setters for the others flags wxSizerFlags& Shaped() { @@ -168,7 +169,6 @@ public: return *this; } -#endif // wx 2.8.2+ // accessors for wxSizer only int GetProportion() const { return m_proportion; } @@ -224,7 +224,7 @@ public: { Init(flags); - SetWindow(window); + DoSetWindow(window); } // subsizer @@ -239,7 +239,7 @@ public: { Init(flags); - SetSizer(sizer); + DoSetSizer(sizer); } // spacer @@ -255,7 +255,7 @@ public: { Init(flags); - SetSpacer(width, height); + DoSetSpacer(wxSize(width, height)); } wxSizerItem(); @@ -340,20 +340,51 @@ public: wxPoint GetPosition() const { return m_pos; } + // these functions delete the current contents of the item if it's a sizer + // or a spacer but not if it is a window + void AssignWindow(wxWindow *window) + { + Free(); + DoSetWindow(window); + } - // these functions do not free old sizer/spacer - void SetWindow(wxWindow *window); - void SetSizer(wxSizer *sizer); - void SetSpacer(const wxSize& size); - void SetSpacer(int width, int height) { SetSpacer(wxSize(width, height)); } + void AssignSizer(wxSizer *sizer) + { + Free(); + DoSetSizer(sizer); + } + + void AssignSpacer(const wxSize& size) + { + Free(); + DoSetSpacer(size); + } + + void AssignSpacer(int w, int h) { AssignSpacer(wxSize(w, h)); } + +#if WXWIN_COMPATIBILITY_2_8 + // these functions do not free the old sizer/spacer and so can easily + // provoke the memory leaks and so shouldn't be used, use Assign() instead + wxDEPRECATED( void SetWindow(wxWindow *window) ); + wxDEPRECATED( void SetSizer(wxSizer *sizer) ); + wxDEPRECATED( void SetSpacer(const wxSize& size) ); + wxDEPRECATED( void SetSpacer(int width, int height) ); +#endif // WXWIN_COMPATIBILITY_2_8 protected: // common part of several ctors - void Init() { m_userData = NULL; } + void Init() { m_userData = NULL; m_kind = Item_None; } // common part of ctors taking wxSizerFlags void Init(const wxSizerFlags& flags); + // free current contents + void Free(); + + // common parts of Set/AssignXXX() + void DoSetWindow(wxWindow *window); + void DoSetSizer(wxSizer *sizer); + void DoSetSpacer(const wxSize& size); // discriminated union: depending on m_kind one of the fields is valid enum @@ -550,6 +581,8 @@ public: wxSizerItemList& GetChildren() { return m_children; } + const wxSizerItemList& GetChildren() const + { return m_children; } void SetDimension( int x, int y, int width, int height ); @@ -841,74 +874,35 @@ private: #endif // wxUSE_BUTTON -#if WXWIN_COMPATIBILITY_2_4 -// NB: wxBookCtrlSizer and wxNotebookSizer are deprecated, they -// don't do anything. wxBookCtrlBase::DoGetBestSize does the job now. // ---------------------------------------------------------------------------- -// wxBookCtrlSizer +// inline functions implementation // ---------------------------------------------------------------------------- -#if wxUSE_BOOKCTRL - -// this sizer works with wxNotebook/wxListbook/... and sizes the control to -// fit its pages -class WXDLLEXPORT wxBookCtrlBase; +#if WXWIN_COMPATIBILITY_2_8 -class WXDLLEXPORT wxBookCtrlSizer : public wxSizer +inline void wxSizerItem::SetWindow(wxWindow *window) { -public: -#if WXWIN_COMPATIBILITY_2_6 - wxDEPRECATED( wxBookCtrlSizer(wxBookCtrlBase *bookctrl) ); -#endif // WXWIN_COMPATIBILITY_2_6 - - wxBookCtrlBase *GetControl() const { return m_bookctrl; } - - virtual void RecalcSizes(); - virtual wxSize CalcMin(); - -protected: - // this protected ctor lets us mark the real one above as deprecated - // and still have warning-free build of the library itself: - wxBookCtrlSizer() {} - - wxBookCtrlBase *m_bookctrl; - -private: - DECLARE_CLASS(wxBookCtrlSizer) - DECLARE_NO_COPY_CLASS(wxBookCtrlSizer) -}; - - -#if wxUSE_NOTEBOOK - -// before wxBookCtrlBase we only had wxNotebookSizer, keep it for backwards -// compatibility -class WXDLLEXPORT wxNotebook; + DoSetWindow(window); +} -class WXDLLEXPORT wxNotebookSizer : public wxBookCtrlSizer +inline void wxSizerItem::SetSizer(wxSizer *sizer) { -public: -#if WXWIN_COMPATIBILITY_2_6 - wxDEPRECATED( wxNotebookSizer(wxNotebook *nb) ); -#endif // WXWIN_COMPATIBILITY_2_6 - - wxNotebook *GetNotebook() const { return (wxNotebook *)m_bookctrl; } - -private: - DECLARE_CLASS(wxNotebookSizer) - DECLARE_NO_COPY_CLASS(wxNotebookSizer) -}; + DoSetSizer(sizer); +} -#endif // wxUSE_NOTEBOOK +inline void wxSizerItem::SetSpacer(const wxSize& size) +{ + DoSetSpacer(size); +} -#endif // wxUSE_BOOKCTRL +inline void wxSizerItem::SetSpacer(int width, int height) +{ + DoSetSpacer(wxSize(width, height)); +} -#endif // WXWIN_COMPATIBILITY_2_4 +#endif // WXWIN_COMPATIBILITY_2_8 -// ---------------------------------------------------------------------------- -// inline functions implementation -// ---------------------------------------------------------------------------- inline wxSizerItem* wxSizer::Add( wxSizerItem *item ) @@ -1064,5 +1058,4 @@ wxSizer::InsertStretchSpacer(size_t index, int prop) return Insert(index, 0, 0, prop); } - #endif // __WXSIZER_H__