]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/gizmos/multicell.h
Include wx/dialog.h according to precompiled headers of wx/wx.h (with other minor...
[wxWidgets.git] / contrib / include / wx / gizmos / multicell.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: multicell.h
3 // Purpose: provide two new classes for layout, wxMultiCellSizer and wxMultiCellCanvas
4 // Author: Jonathan Bayer
5 // Modified by:
6 // Created:
7 // RCS-ID: $Id$
8 // Copyright: (c) Jonathan Bayer
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // This was inspired by the gbsizer class written by Alex Andruschak
13
14
15 #ifndef __WX_MULTICELL_H__
16 #define __WX_MULTICELL_H__
17
18 #include "wx/gizmos/gizmos.h"
19
20 // ----------------------------------------------------------------------------
21 // headers
22 // ----------------------------------------------------------------------------
23 // The classes are derived from wxSizer
24 #include "wx/sizer.h"
25
26
27 // ----------------------------------------------------------------------------
28 // constants
29 // ----------------------------------------------------------------------------
30 enum wxResizable
31 {
32 wxNOT_RESIZABLE = 0x00,
33 wxHORIZONTAL_RESIZABLE = 0x01,
34 wxVERTICAL_RESIZABLE = 0x10,
35 wxRESIZABLE = 0x11
36 };
37
38 //---------------------------------------------------------------------------
39 // classes
40 //---------------------------------------------------------------------------
41
42 //---------------------------------------------------------------------------
43 // wxMultiCellItemHandle
44 //---------------------------------------------------------------------------
45
46 class WXDLLIMPEXP_GIZMOS wxMultiCellItemHandle: public wxObject
47 {
48 DECLARE_CLASS(wxMultiCellItemHandle)
49 protected:
50 int m_column;
51 int m_row;
52 int m_width;
53 int m_height;
54 wxResizable m_style;
55 wxSize m_fixedSize;
56 int m_alignment;
57 wxSize m_weight;
58
59 public:
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);
63 int GetColumn();
64 int GetRow();
65 int GetWidth();
66 int GetHeight();
67 wxResizable GetStyle();
68 wxSize GetLocalSize();
69 int GetAlignment();
70 wxSize GetWeight();
71
72 private:
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);
74
75 };
76
77 //---------------------------------------------------------------------------
78 // wxMultiCellSizer
79 //---------------------------------------------------------------------------
80
81 class WXDLLIMPEXP_GIZMOS wxMultiCellSizer : virtual public wxSizer
82 {
83 DECLARE_CLASS(wxMultiCellSizer)
84
85 protected:
86 wxSize m_cell_count;
87
88 public:
89 wxMultiCellSizer(wxSize & size);
90 wxMultiCellSizer(int rows, int cols);
91 ~wxMultiCellSizer();
92
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(const wxPen *pen);
100 void OnPaint(wxDC& dc);
101
102 private:
103 void GetMinimums();
104 int Sum(int *array, int x);
105
106 private:
107 int *m_maxHeight;
108 int *m_maxWidth;
109 int *m_rowStretch;
110 int *m_colStretch;
111 wxSize **m_weights;
112 wxSize **m_minSizes;
113 int m_maxWeights;
114 wxSize m_defaultCellSize;
115 wxWindow *m_win; // usually used for debugging
116 const wxPen *m_pen;
117
118 void DrawGridLines(wxDC& dc);
119 void Initialize(wxSize size);
120 };
121
122
123 // wxCell is used internally, so we don't need to declare it here
124
125 class wxCell;
126
127 //---------------------------------------------------------------------------
128 // wxMultiCellCanvas
129 //---------------------------------------------------------------------------
130
131 class WXDLLIMPEXP_GIZMOS wxMultiCellCanvas : public wxFlexGridSizer
132 {
133 public:
134 wxMultiCellCanvas(wxWindow *parent, int numRows = 2, int numCols = 2);
135 void Add(wxWindow *win, unsigned int row, unsigned int col);
136
137 void Resize(int numRows, int numCols);
138 int MaxRows()
139 {
140 return m_maxRows;
141 };
142 int MaxCols()
143 {
144 return m_maxCols;
145 };
146 void CalculateConstraints();
147 void SetMinCellSize(const wxSize size)
148 {
149 m_minCellSize = size;
150 };
151
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); }
161
162 private:
163 wxWindow *m_parent;
164 unsigned int m_maxRows, m_maxCols;
165
166 wxSize m_minCellSize;
167 wxCell **m_cells;
168 };
169
170 #endif
171
172
173
174 /*** End of File ***/