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 #if defined(__GNUG__) && !defined(__APPLE__)
19 #pragma interface "multicell.h"
22 #include "wx/gizmos/gizmos.h"
24 // ----------------------------------------------------------------------------
26 // ----------------------------------------------------------------------------
27 // The classes are derived from wxSizer
31 // ----------------------------------------------------------------------------
33 // ----------------------------------------------------------------------------
36 wxNOT_RESIZABLE
= 0x00,
37 wxHORIZONTAL_RESIZABLE
= 0x01,
38 wxVERTICAL_RESIZABLE
= 0x10,
42 //---------------------------------------------------------------------------
44 //---------------------------------------------------------------------------
46 //---------------------------------------------------------------------------
47 // wxMultiCellItemHandle
48 //---------------------------------------------------------------------------
50 class WXDLLIMPEXP_GIZMOS wxMultiCellItemHandle
: public wxObject
52 DECLARE_CLASS(wxMultiCellItemHandle
)
64 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
);
65 wxMultiCellItemHandle( int row
, int column
, wxSize size
, wxResizable style
= wxNOT_RESIZABLE
, wxSize weight
= wxSize(1,1), int align
= wxALIGN_NOT
);
66 wxMultiCellItemHandle( int row
, int column
, wxResizable style
, wxSize weight
= wxSize(1,1), int align
= wxALIGN_NOT
);
71 wxResizable
GetStyle();
72 wxSize
GetLocalSize();
77 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
);
81 //---------------------------------------------------------------------------
83 //---------------------------------------------------------------------------
85 class WXDLLIMPEXP_GIZMOS wxMultiCellSizer
: virtual public wxSizer
87 DECLARE_CLASS(wxMultiCellSizer
)
93 wxMultiCellSizer(wxSize
& size
);
94 wxMultiCellSizer(int rows
, int cols
);
97 virtual void RecalcSizes();
98 virtual wxSize
CalcMin();
99 bool SetDefaultCellSize(wxSize size
);
100 bool SetColumnWidth(int column
, int colSize
= 5, bool expandable
= false);
101 bool SetRowHeight(int row
, int rowSize
= 5, bool expandable
= false);
102 bool EnableGridLines(wxWindow
*win
);
103 bool SetGridPen(wxPen
*pen
);
104 void OnPaint(wxDC
& dc
);
108 int Sum(int *array
, int x
);
118 wxSize m_defaultCellSize
;
119 wxWindow
*m_win
; // usually used for debugging
122 void DrawGridLines(wxDC
& dc
);
123 void Initialize(wxSize size
);
127 // wxCell is used internally, so we don't need to declare it here
131 //---------------------------------------------------------------------------
133 //---------------------------------------------------------------------------
135 class WXDLLIMPEXP_GIZMOS wxMultiCellCanvas
: public wxFlexGridSizer
138 wxMultiCellCanvas(wxWindow
*parent
, int numRows
= 2, int numCols
= 2);
139 void Add(wxWindow
*win
, unsigned int row
, unsigned int col
);
141 void Resize(int numRows
, int numCols
);
150 void CalculateConstraints();
151 void SetMinCellSize(const wxSize size
)
153 m_minCellSize
= size
;
156 /* These are to hide Add() method of parents and to avoid Borland warning about hiding virtual functions */
157 void Add( wxWindow
*window
, int proportion
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
)
158 { wxFlexGridSizer::Add( window
, proportion
, flag
, border
, userData
); }
159 void Add( wxSizer
*sizer
, int proportion
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
)
160 { wxFlexGridSizer::Add( sizer
, proportion
, flag
, border
, userData
); }
161 void Add( int width
, int height
, int proportion
= 0, int flag
= 0, int border
= 0, wxObject
* userData
= NULL
)
162 { wxFlexGridSizer::Add( width
, height
, proportion
, flag
, border
, userData
); }
163 void Add( wxSizerItem
*item
)
164 { wxFlexGridSizer::Add( item
); }
168 unsigned int m_maxRows
, m_maxCols
;
170 wxSize m_minCellSize
;
178 /*** End of File ***/