1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: provide two new classes for layout, wxMultiCellSizer and wxMultiCellCanvas
4 // Author: Jonathan Bayer
8 // Copyright: (c) Jonathan Bayer
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // This was inspired by the gbsizer class written by Alex Andruschak
15 #ifndef __WX_MULTICELL_H__
16 #define __WX_MULTICELL_H__
18 #include "wx/gizmos/gizmos.h"
20 // ----------------------------------------------------------------------------
22 // ----------------------------------------------------------------------------
23 // The classes are derived from wxSizer
27 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
32 wxNOT_RESIZABLE
= 0x00,
33 wxHORIZONTAL_RESIZABLE
= 0x01,
34 wxVERTICAL_RESIZABLE
= 0x10,
38 //---------------------------------------------------------------------------
40 //---------------------------------------------------------------------------
42 //---------------------------------------------------------------------------
43 // wxMultiCellItemHandle
44 //---------------------------------------------------------------------------
46 class WXDLLIMPEXP_GIZMOS wxMultiCellItemHandle
: public wxObject
48 DECLARE_CLASS(wxMultiCellItemHandle
)
60 wxMultiCellItemHandle( int row
, int column
, int height
= 1, int width
= 1, wxSize size
= wxDefaultSize
, wxResizable style
= wxNOT_RESIZABLE
, wxSize weight
= wxSize(1,1), int align
= wxALIGN_NOT
);
61 wxMultiCellItemHandle( int row
, int column
, wxSize size
, wxResizable style
= wxNOT_RESIZABLE
, wxSize weight
= wxSize(1,1), int align
= wxALIGN_NOT
);
62 wxMultiCellItemHandle( int row
, int column
, wxResizable style
, wxSize weight
= wxSize(1,1), int align
= wxALIGN_NOT
);
67 wxResizable
GetStyle();
68 wxSize
GetLocalSize();
73 void Initialize( int row
, int column
, int height
= 1, int width
= 1, wxSize size
= wxDefaultSize
, wxResizable style
= wxNOT_RESIZABLE
, wxSize weight
= wxSize(1,1), int align
= wxALIGN_NOT
);
77 //---------------------------------------------------------------------------
79 //---------------------------------------------------------------------------
81 class WXDLLIMPEXP_GIZMOS wxMultiCellSizer
: virtual public wxSizer
83 DECLARE_CLASS(wxMultiCellSizer
)
89 wxMultiCellSizer(wxSize
& size
);
90 wxMultiCellSizer(int rows
, int cols
);
93 virtual void RecalcSizes();
94 virtual wxSize
CalcMin();
95 bool SetDefaultCellSize(wxSize size
);
96 bool SetColumnWidth(int column
, int colSize
= 5, bool expandable
= false);
97 bool SetRowHeight(int row
, int rowSize
= 5, bool expandable
= false);
98 bool EnableGridLines(wxWindow
*win
);
99 bool SetGridPen(wxPen
*pen
);
100 void OnPaint(wxDC
& dc
);
104 int Sum(int *array
, int x
);
114 wxSize m_defaultCellSize
;
115 wxWindow
*m_win
; // usually used for debugging
118 void DrawGridLines(wxDC
& dc
);
119 void Initialize(wxSize size
);
123 // wxCell is used internally, so we don't need to declare it here
127 //---------------------------------------------------------------------------
129 //---------------------------------------------------------------------------
131 class WXDLLIMPEXP_GIZMOS wxMultiCellCanvas
: public wxFlexGridSizer
134 wxMultiCellCanvas(wxWindow
*parent
, int numRows
= 2, int numCols
= 2);
135 void Add(wxWindow
*win
, unsigned int row
, unsigned int col
);
137 void Resize(int numRows
, int numCols
);
146 void CalculateConstraints();
147 void SetMinCellSize(const wxSize size
)
149 m_minCellSize
= size
;
152 /* These are to hide Add() method of parents and to avoid Borland warning about hiding virtual functions */
153 void Add( wxWindow
*window
, int proportion
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
)
154 { wxFlexGridSizer::Add( window
, proportion
, flag
, border
, userData
); }
155 void Add( wxSizer
*sizer
, int proportion
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
)
156 { wxFlexGridSizer::Add( sizer
, proportion
, flag
, border
, userData
); }
157 void Add( int width
, int height
, int proportion
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
)
158 { wxFlexGridSizer::Add( width
, height
, proportion
, flag
, border
, userData
); }
159 void Add( wxSizerItem
*item
)
160 { wxFlexGridSizer::Add( item
); }
164 unsigned int m_maxRows
, m_maxCols
;
166 wxSize m_minCellSize
;
174 /*** End of File ***/