]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/sizer.h
As per wx-dev, split the sort arrow options out to a separate parameter.
[wxWidgets.git] / include / wx / sizer.h
index 4593844fdbb94fd52a30b5e24b632615403befaa..e278b0d2bac35e2cbc114d3da8946fa3b300b87a 100644 (file)
 
 #include "wx/defs.h"
 
-#include "wx/button.h"
 #include "wx/window.h"
-#include "wx/frame.h"
-#include "wx/dialog.h"
 
 //---------------------------------------------------------------------------
 // classes
 //---------------------------------------------------------------------------
 
+class WXDLLEXPORT wxButton;
+class WXDLLEXPORT wxBoxSizer;
 class WXDLLEXPORT wxSizerItem;
 class WXDLLEXPORT wxSizer;
-class WXDLLEXPORT wxBoxSizer;
-
 
 // ----------------------------------------------------------------------------
 // wxSizerFlags: flags used for an item in the sizer
@@ -54,7 +51,7 @@ public:
 
     wxSizerFlags& Align(int alignment) // combination of wxAlignment values
     {
-        m_flags &= wxALIGN_MASK;
+        m_flags &= ~wxALIGN_MASK;
         m_flags |= alignment;
 
         return *this;
@@ -229,9 +226,11 @@ public:
     bool IsSizer() const { return m_kind == Item_Sizer; }
     bool IsSpacer() const { return m_kind == Item_Spacer; }
 
+#if WXWIN_COMPATIBILITY_2_6
     // Deprecated in 2.6, use {G,S}etProportion instead.
     wxDEPRECATED( void SetOption( int option ) );
     wxDEPRECATED( int GetOption() const );
+#endif // WXWIN_COMPATIBILITY_2_6
 
     void SetProportion( int proportion )
         { m_proportion = proportion; }
@@ -252,9 +251,14 @@ public:
         { return m_kind == Item_Sizer ? m_sizer : NULL; }
     wxSize GetSpacer() const;
 
-    void Show(bool show);
+    // this function behaves obviously for the windows and spacers but for the
+    // sizers it returns true if any sizer element is shown and only returns
+    // false if all of them are hidden
     bool IsShown() const;
+    void Show(bool show);
 
+    void SetUserData(wxObject* userData)
+        { delete m_userData; m_userData = userData; }
     wxObject* GetUserData() const
         { return m_userData; }
     wxPoint GetPosition() const
@@ -274,6 +278,8 @@ protected:
     // common part of ctors taking wxSizerFlags
     void Init(const wxSizerFlags& flags);
 
+
+    // discriminated union: depending on m_kind one of the fields is valid
     enum
     {
         Item_None,
@@ -320,91 +326,98 @@ WX_DECLARE_EXPORTED_LIST( wxSizerItem, wxSizerItemList );
 class WXDLLEXPORT wxSizer: public wxObject, public wxClientDataContainer
 {
 public:
-    wxSizer();
-    ~wxSizer();
+    wxSizer() { m_containingWindow = NULL; }
+    virtual ~wxSizer();
 
     // methods for adding elements to the sizer: there are Add/Insert/Prepend
     // overloads for each of window/sizer/spacer/wxSizerItem
-    inline wxSizerItem* Add( wxWindow *window,
-                             int proportion = 0,
-                             int flag = 0,
-                             int border = 0,
-                             wxObject* userData = NULL );
-    inline wxSizerItem* Add( wxSizer *sizer,
-                             int proportion = 0,
-                             int flag = 0,
-                             int border = 0,
-                             wxObject* userData = NULL );
-    inline wxSizerItem* Add( int width,
-                             int height,
-                             int proportion = 0,
-                             int flag = 0,
-                             int border = 0,
-                             wxObject* userData = NULL );
-    inline wxSizerItem* Add( wxWindow *window, const wxSizerFlags& flags );
-    inline wxSizerItem* Add( wxSizer *sizer, const wxSizerFlags& flags );
-    inline wxSizerItem* Add( wxSizerItem *item );
-
-    inline wxSizerItem* AddSpacer(int size);
-    inline wxSizerItem* AddStretchSpacer(int prop = 1);
-
-    inline wxSizerItem* Insert( size_t index,
-                                wxWindow *window,
-                                int proportion = 0,
-                                int flag = 0,
-                                int border = 0,
-                                wxObject* userData = NULL );
-    inline wxSizerItem* Insert( size_t index,
-                                wxSizer *sizer,
-                                int proportion = 0,
-                                int flag = 0,
-                                int border = 0,
-                                wxObject* userData = NULL );
-    inline wxSizerItem* Insert( size_t index,
-                                int width,
-                                int height,
-                                int proportion = 0,
-                                int flag = 0,
-                                int border = 0,
-                                wxObject* userData = NULL );
-    inline wxSizerItem* Insert( size_t index,
-                                wxWindow *window,
-                                const wxSizerFlags& flags );
-    inline wxSizerItem* Insert( size_t index,
-                                wxSizer *sizer,
-                                const wxSizerFlags& flags );
-    virtual wxSizerItem* Insert( size_t index, wxSizerItem *item );
-
-    inline wxSizerItem* InsertSpacer(size_t index, int size);
-    inline wxSizerItem* InsertStretchSpacer(size_t index, int prop = 1);
-
-    inline wxSizerItem* Prepend( wxWindow *window,
-                                 int proportion = 0,
-                                 int flag = 0,
-                                 int border = 0,
-                                 wxObject* userData = NULL );
-    inline wxSizerItem* Prepend( wxSizer *sizer,
-                                 int proportion = 0,
-                                 int flag = 0,
-                                 int border = 0,
-                                 wxObject* userData = NULL );
-    inline wxSizerItem* Prepend( int width,
-                                 int height,
-                                 int proportion = 0,
-                                 int flag = 0,
-                                 int border = 0,
-                                 wxObject* userData = NULL );
-    inline wxSizerItem* Prepend( wxWindow *window, const wxSizerFlags& flags );
-    inline wxSizerItem* Prepend( wxSizer *sizer, const wxSizerFlags& flags );
-    inline wxSizerItem* Prepend( wxSizerItem *item );
-
-    inline wxSizerItem* PrependSpacer(int size);
-    inline wxSizerItem* PrependStretchSpacer(int prop = 1);
-
-
+    wxSizerItem* Add(wxWindow *window,
+                     int proportion = 0,
+                     int flag = 0,
+                     int border = 0,
+                     wxObject* userData = NULL);
+    wxSizerItem* Add(wxSizer *sizer,
+                     int proportion = 0,
+                     int flag = 0,
+                     int border = 0,
+                     wxObject* userData = NULL);
+    wxSizerItem* Add(int width,
+                     int height,
+                     int proportion = 0,
+                     int flag = 0,
+                     int border = 0,
+                     wxObject* userData = NULL);
+    wxSizerItem* Add( wxWindow *window, const wxSizerFlags& flags);
+    wxSizerItem* Add( wxSizer *sizer, const wxSizerFlags& flags);
+    wxSizerItem* Add( wxSizerItem *item);
+
+    wxSizerItem* AddSpacer(int size);
+    wxSizerItem* AddStretchSpacer(int prop = 1);
+
+    wxSizerItem* Insert(size_t index,
+                        wxWindow *window,
+                        int proportion = 0,
+                        int flag = 0,
+                        int border = 0,
+                        wxObject* userData = NULL);
+    wxSizerItem* Insert(size_t index,
+                        wxSizer *sizer,
+                        int proportion = 0,
+                        int flag = 0,
+                        int border = 0,
+                        wxObject* userData = NULL);
+    wxSizerItem* Insert(size_t index,
+                        int width,
+                        int height,
+                        int proportion = 0,
+                        int flag = 0,
+                        int border = 0,
+                        wxObject* userData = NULL);
+    wxSizerItem* Insert(size_t index,
+                        wxWindow *window,
+                        const wxSizerFlags& flags);
+    wxSizerItem* Insert(size_t index,
+                        wxSizer *sizer,
+                        const wxSizerFlags& flags);
+    virtual wxSizerItem* Insert( size_t index, wxSizerItem *item);
+
+    wxSizerItem* InsertSpacer(size_t index, int size);
+    wxSizerItem* InsertStretchSpacer(size_t index, int prop = 1);
+
+    wxSizerItem* Prepend(wxWindow *window,
+                         int proportion = 0,
+                         int flag = 0,
+                         int border = 0,
+                         wxObject* userData = NULL);
+    wxSizerItem* Prepend(wxSizer *sizer,
+                         int proportion = 0,
+                         int flag = 0,
+                         int border = 0,
+                         wxObject* userData = NULL);
+    wxSizerItem* Prepend(int width,
+                         int height,
+                         int proportion = 0,
+                         int flag = 0,
+                         int border = 0,
+                         wxObject* userData = NULL);
+    wxSizerItem* Prepend(wxWindow *window, const wxSizerFlags& flags);
+    wxSizerItem* Prepend(wxSizer *sizer, const wxSizerFlags& flags);
+    wxSizerItem* Prepend(wxSizerItem *item);
+
+    wxSizerItem* PrependSpacer(int size);
+    wxSizerItem* PrependStretchSpacer(int prop = 1);
+
+    // set (or possibly unset if window is NULL) or get the window this sizer
+    // is used in 
+    void SetContainingWindow(wxWindow *window);
+    wxWindow *GetContainingWindow() const { return m_containingWindow; }
+
+#if WXWIN_COMPATIBILITY_2_6
     // Deprecated in 2.6 since historically it does not delete the window,
     // use Detach instead.
     wxDEPRECATED( virtual bool Remove( wxWindow *window ) );
+#endif // WXWIN_COMPATIBILITY_2_6
+
     virtual bool Remove( wxSizer *sizer );
     virtual bool Remove( int index );
 
@@ -412,6 +425,10 @@ public:
     virtual bool Detach( wxSizer *sizer );
     virtual bool Detach( int index );
 
+    virtual bool Replace( wxWindow *oldwin, wxWindow *newwin, bool recursive = false );  
+    virtual bool Replace( wxSizer *oldsz, wxSizer *newsz, bool recursive = false );  
+    virtual bool Replace( size_t index, wxSizerItem *newitem );  
+
     virtual void Clear( bool delete_windows = false );
     virtual void DeleteWindows();
 
@@ -484,18 +501,16 @@ public:
     // Recursively call wxWindow::Show () on all sizer items.
     virtual void ShowItems (bool show);
 
-    void Show(bool show)
-    {   m_isShown = show;
-        ShowItems(show);
-    }
-    bool IsShown() const { return m_isShown; }
+    void Show(bool show) { ShowItems(show); }
 
 protected:
     wxSize              m_size;
     wxSize              m_minSize;
     wxPoint             m_position;
     wxSizerItemList     m_children;
-    bool                m_isShown;
+
+    // the window this sizer is used in, can be NULL
+    wxWindow *m_containingWindow;
 
     wxSize GetMaxWindowSize( wxWindow *window ) const;
     wxSize GetMinWindowSize( wxWindow *window );
@@ -678,6 +693,7 @@ class WXDLLEXPORT wxStaticBoxSizer: public wxBoxSizer
 public:
     wxStaticBoxSizer(wxStaticBox *box, int orient);
     wxStaticBoxSizer(int orient, wxWindow *win, const wxString& label = wxEmptyString);
+    virtual ~wxStaticBoxSizer();
 
     void RecalcSizes();
     wxSize CalcMin();
@@ -688,6 +704,10 @@ public:
     // override to hide/show the static box as well
     virtual void ShowItems (bool show);
 
+    virtual bool Detach( wxWindow *window );
+    virtual bool Detach( wxSizer *sizer ) { return wxBoxSizer::Detach(sizer); }
+    virtual bool Detach( int index ) { return wxBoxSizer::Detach(index); }
+
 protected:
     wxStaticBox   *m_staticBox;
 
@@ -763,7 +783,9 @@ class WXDLLEXPORT wxBookCtrlBase;
 class WXDLLEXPORT wxBookCtrlSizer : public wxSizer
 {
 public:
+#if WXWIN_COMPATIBILITY_2_6
     wxDEPRECATED( wxBookCtrlSizer(wxBookCtrlBase *bookctrl) );
+#endif // WXWIN_COMPATIBILITY_2_6
 
     wxBookCtrlBase *GetControl() const { return m_bookctrl; }
 
@@ -792,7 +814,9 @@ class WXDLLEXPORT wxNotebook;
 class WXDLLEXPORT wxNotebookSizer : public wxBookCtrlSizer
 {
 public:
+#if WXWIN_COMPATIBILITY_2_6
     wxDEPRECATED( wxNotebookSizer(wxNotebook *nb) );
+#endif // WXWIN_COMPATIBILITY_2_6
 
     wxNotebook *GetNotebook() const { return (wxNotebook *)m_bookctrl; }