+class WXDLLIMPEXP_CORE wxSizer: public wxObject, public wxClientDataContainer
+{
+public:
+ 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
+ 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( int width, int height, const wxSizerFlags& flags);
+ wxSizerItem* Add( wxSizerItem *item);
+
+ virtual 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);
+ wxSizerItem* Insert(size_t index,
+ int width,
+ int height,
+ 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(int width, int height, 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 );
+
+ virtual bool Detach( wxWindow *window );
+ 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();
+
+ // Inform sizer about the first direction that has been decided (by parent item)
+ // Returns true if it made use of the informtion (and recalculated min size)
+ virtual bool InformFirstDirection( int WXUNUSED(direction), int WXUNUSED(size), int WXUNUSED(availableOtherDir) )
+ { return false; }
+
+ void SetMinSize( int width, int height )
+ { DoSetMinSize( width, height ); }
+ void SetMinSize( const wxSize& size )
+ { DoSetMinSize( size.x, size.y ); }
+
+ // Searches recursively
+ bool SetItemMinSize( wxWindow *window, int width, int height )
+ { return DoSetItemMinSize( window, width, height ); }
+ bool SetItemMinSize( wxWindow *window, const wxSize& size )
+ { return DoSetItemMinSize( window, size.x, size.y ); }
+
+ // Searches recursively
+ bool SetItemMinSize( wxSizer *sizer, int width, int height )
+ { return DoSetItemMinSize( sizer, width, height ); }
+ bool SetItemMinSize( wxSizer *sizer, const wxSize& size )
+ { return DoSetItemMinSize( sizer, size.x, size.y ); }
+
+ bool SetItemMinSize( size_t index, int width, int height )
+ { return DoSetItemMinSize( index, width, height ); }
+ bool SetItemMinSize( size_t index, const wxSize& size )
+ { return DoSetItemMinSize( index, size.x, size.y ); }
+
+ wxSize GetSize() const
+ { return m_size; }
+ wxPoint GetPosition() const
+ { return m_position; }
+
+ // Calculate the minimal size or return m_minSize if bigger.
+ wxSize GetMinSize();
+
+ // These virtual functions are used by the layout algorithm: first
+ // CalcMin() is called to calculate the minimal size of the sizer and
+ // prepare for laying it out and then RecalcSizes() is called to really
+ // update all the sizer items
+ virtual wxSize CalcMin() = 0;
+ virtual void RecalcSizes() = 0;
+
+ virtual void Layout();
+
+ wxSize ComputeFittingClientSize(wxWindow *window);
+ wxSize ComputeFittingWindowSize(wxWindow *window);
+
+ wxSize Fit( wxWindow *window );
+ void FitInside( wxWindow *window );
+ void SetSizeHints( wxWindow *window );
+#if WXWIN_COMPATIBILITY_2_8
+ // This only calls FitInside() since 2.9
+ wxDEPRECATED( void SetVirtualSizeHints( wxWindow *window ) );
+#endif
+
+ wxSizerItemList& GetChildren()
+ { return m_children; }
+ const wxSizerItemList& GetChildren() const
+ { return m_children; }
+
+ void SetDimension(const wxPoint& pos, const wxSize& size)
+ {
+ m_position = pos;
+ m_size = size;
+ Layout();
+ }
+ void SetDimension(int x, int y, int width, int height)
+ { SetDimension(wxPoint(x, y), wxSize(width, height)); }
+
+ size_t GetItemCount() const { return m_children.GetCount(); }
+ bool IsEmpty() const { return m_children.IsEmpty(); }
+
+ wxSizerItem* GetItem( wxWindow *window, bool recursive = false );
+ wxSizerItem* GetItem( wxSizer *sizer, bool recursive = false );
+ wxSizerItem* GetItem( size_t index );
+ wxSizerItem* GetItemById( int id, bool recursive = false );
+
+ // Manage whether individual scene items are considered
+ // in the layout calculations or not.
+ bool Show( wxWindow *window, bool show = true, bool recursive = false );
+ bool Show( wxSizer *sizer, bool show = true, bool recursive = false );
+ bool Show( size_t index, bool show = true );
+
+ bool Hide( wxSizer *sizer, bool recursive = false )
+ { return Show( sizer, false, recursive ); }
+ bool Hide( wxWindow *window, bool recursive = false )
+ { return Show( window, false, recursive ); }
+ bool Hide( size_t index )
+ { return Show( index, false ); }
+
+ bool IsShown( wxWindow *window ) const;
+ bool IsShown( wxSizer *sizer ) const;
+ bool IsShown( size_t index ) const;
+
+ // Recursively call wxWindow::Show () on all sizer items.
+ virtual void ShowItems (bool show);
+
+ void Show(bool show) { ShowItems(show); }
+
+protected:
+ wxSize m_size;
+ wxSize m_minSize;
+ wxPoint m_position;
+ wxSizerItemList m_children;
+
+ // the window this sizer is used in, can be NULL
+ wxWindow *m_containingWindow;
+
+ wxSize GetMaxClientSize( wxWindow *window ) const;
+ wxSize GetMinClientSize( wxWindow *window );
+ wxSize VirtualFitSize( wxWindow *window );
+
+ virtual void DoSetMinSize( int width, int height );
+ virtual bool DoSetItemMinSize( wxWindow *window, int width, int height );
+ virtual bool DoSetItemMinSize( wxSizer *sizer, int width, int height );
+ virtual bool DoSetItemMinSize( size_t index, int width, int height );
+
+private:
+ DECLARE_CLASS(wxSizer)
+};
+
+//---------------------------------------------------------------------------
+// wxGridSizer
+//---------------------------------------------------------------------------
+
+class WXDLLIMPEXP_CORE wxGridSizer: public wxSizer
+{
+public:
+ // ctors specifying the number of columns only: number of rows will be
+ // deduced automatically depending on the number of sizer elements
+ wxGridSizer( int cols, int vgap, int hgap );
+ wxGridSizer( int cols, const wxSize& gap = wxSize(0, 0) );
+
+ // ctors specifying the number of rows and columns
+ wxGridSizer( int rows, int cols, int vgap, int hgap );
+ wxGridSizer( int rows, int cols, const wxSize& gap );
+
+ virtual wxSizerItem *Insert(size_t index, wxSizerItem *item);
+
+ virtual void RecalcSizes();
+ virtual wxSize CalcMin();
+
+ void SetCols( int cols )
+ {
+ wxASSERT_MSG( cols >= 0, "Number of columns must be non-negative");
+ m_cols = cols;
+ }
+
+ void SetRows( int rows )
+ {
+ wxASSERT_MSG( rows >= 0, "Number of rows must be non-negative");
+ m_rows = rows;
+ }
+
+ void SetVGap( int gap ) { m_vgap = gap; }
+ void SetHGap( int gap ) { m_hgap = gap; }
+ int GetCols() const { return m_cols; }
+ int GetRows() const { return m_rows; }
+ int GetVGap() const { return m_vgap; }
+ int GetHGap() const { return m_hgap; }
+
+ int GetEffectiveColsCount() const { return m_cols ? m_cols : CalcCols(); }
+ int GetEffectiveRowsCount() const { return m_rows ? m_rows : CalcRows(); }
+
+ // return the number of total items and the number of columns and rows
+ // (for internal use only)
+ int CalcRowsCols(int& rows, int& cols) const;
+
+protected:
+ // the number of rows/columns in the sizer, if 0 then it is determined
+ // dynamically depending on the total number of items
+ int m_rows;
+ int m_cols;
+
+ // gaps between rows and columns
+ int m_vgap;
+ int m_hgap;
+
+ void SetItemBounds( wxSizerItem *item, int x, int y, int w, int h );
+
+ // returns the number of columns/rows needed for the current total number
+ // of children (and the fixed number of rows/columns)
+ int CalcCols() const
+ {
+ wxCHECK_MSG
+ (
+ m_rows, 0,
+ "Can't calculate number of cols if number of rows is not specified"
+ );
+
+ return (m_children.GetCount() + m_rows - 1) / m_rows;
+ }
+
+ int CalcRows() const
+ {
+ wxCHECK_MSG
+ (
+ m_cols, 0,
+ "Can't calculate number of cols if number of rows is not specified"
+ );
+
+ return (m_children.GetCount() + m_cols - 1) / m_cols;
+ }
+
+private:
+ DECLARE_CLASS(wxGridSizer)
+};
+
+//---------------------------------------------------------------------------
+// wxFlexGridSizer
+//---------------------------------------------------------------------------
+
+// values which define the behaviour for resizing wxFlexGridSizer cells in the
+// "non-flexible" direction
+enum wxFlexSizerGrowMode
+{
+ // don't resize the cells in non-flexible direction at all
+ wxFLEX_GROWMODE_NONE,
+
+ // uniformly resize only the specified ones (default)
+ wxFLEX_GROWMODE_SPECIFIED,
+
+ // uniformly resize all cells
+ wxFLEX_GROWMODE_ALL
+};
+
+class WXDLLIMPEXP_CORE wxFlexGridSizer: public wxGridSizer
+{
+public:
+ // ctors specifying the number of columns only: number of rows will be
+ // deduced automatically depending on the number of sizer elements
+ wxFlexGridSizer( int cols, int vgap, int hgap );
+ wxFlexGridSizer( int cols, const wxSize& gap = wxSize(0, 0) );
+
+ // ctors specifying the number of rows and columns
+ wxFlexGridSizer( int rows, int cols, int vgap, int hgap );
+ wxFlexGridSizer( int rows, int cols, const wxSize& gap );
+
+ // dtor
+ virtual ~wxFlexGridSizer();
+
+ // set the rows/columns which will grow (the others will remain of the
+ // constant initial size)
+ void AddGrowableRow( size_t idx, int proportion = 0 );
+ void RemoveGrowableRow( size_t idx );
+ void AddGrowableCol( size_t idx, int proportion = 0 );
+ void RemoveGrowableCol( size_t idx );
+
+ bool IsRowGrowable( size_t idx );
+ bool IsColGrowable( size_t idx );
+
+ // the sizer cells may grow in both directions, not grow at all or only
+ // grow in one direction but not the other
+
+ // the direction may be wxVERTICAL, wxHORIZONTAL or wxBOTH (default)
+ void SetFlexibleDirection(int direction) { m_flexDirection = direction; }
+ int GetFlexibleDirection() const { return m_flexDirection; }
+
+ // note that the grow mode only applies to the direction which is not
+ // flexible
+ void SetNonFlexibleGrowMode(wxFlexSizerGrowMode mode) { m_growMode = mode; }
+ wxFlexSizerGrowMode GetNonFlexibleGrowMode() const { return m_growMode; }
+
+ // Read-only access to the row heights and col widths arrays
+ const wxArrayInt& GetRowHeights() const { return m_rowHeights; }
+ const wxArrayInt& GetColWidths() const { return m_colWidths; }
+
+ // implementation
+ virtual void RecalcSizes();
+ virtual wxSize CalcMin();
+
+protected:
+ void AdjustForFlexDirection();
+ void AdjustForGrowables(const wxSize& sz);
+ void FindWidthsAndHeights(int nrows, int ncols);
+
+ // the heights/widths of all rows/columns
+ wxArrayInt m_rowHeights,
+ m_colWidths;
+
+ // indices of the growable columns and rows
+ wxArrayInt m_growableRows,
+ m_growableCols;
+
+ // proportion values of the corresponding growable rows and columns
+ wxArrayInt m_growableRowsProportions,
+ m_growableColsProportions;
+
+ // parameters describing whether the growable cells should be resized in
+ // both directions or only one
+ int m_flexDirection;
+ wxFlexSizerGrowMode m_growMode;
+
+ // saves CalcMin result to optimize RecalcSizes
+ wxSize m_calculatedMinSize;
+
+private:
+ DECLARE_CLASS(wxFlexGridSizer)
+ wxDECLARE_NO_COPY_CLASS(wxFlexGridSizer);
+};
+
+//---------------------------------------------------------------------------
+// wxBoxSizer
+//---------------------------------------------------------------------------
+
+class WXDLLIMPEXP_CORE wxBoxSizer: public wxSizer