]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/gizmos/multicell.h
Applied patch [ 905577 ] Removed copystring from OGL library
[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 #if defined(__GNUG__) && !defined(__APPLE__)
19 #pragma interface "multicell.h"
20 #endif
21
22 #include "wx/gizmos/gizmos.h"
23
24 // ----------------------------------------------------------------------------
25 // headers
26 // ----------------------------------------------------------------------------
27 // The classes are derived from wxSizer
28 #include "wx/sizer.h"
29
30
31 // ----------------------------------------------------------------------------
32 // constants
33 // ----------------------------------------------------------------------------
34 enum wxResizable
35 {
36 wxNOT_RESIZABLE = 0x00,
37 wxHORIZONTAL_RESIZABLE = 0x01,
38 wxVERTICAL_RESIZABLE = 0x10,
39 wxRESIZABLE = 0x11
40 };
41
42 //---------------------------------------------------------------------------
43 // classes
44 //---------------------------------------------------------------------------
45
46 //---------------------------------------------------------------------------
47 // wxMultiCellItemHandle
48 //---------------------------------------------------------------------------
49
50 class WXDLLIMPEXP_GIZMOS wxMultiCellItemHandle: public wxObject
51 {
52 DECLARE_CLASS(wxMultiCellItemHandle);
53 protected:
54 int m_column;
55 int m_row;
56 int m_width;
57 int m_height;
58 wxResizable m_style;
59 wxSize m_fixedSize;
60 int m_alignment;
61 wxSize m_weight;
62
63 public:
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);
67 wxMultiCellItemHandle( int row, int column, int align);
68 int GetColumn();
69 int GetRow();
70 int GetWidth();
71 int GetHeight();
72 wxResizable GetStyle();
73 wxSize GetLocalSize();
74 int GetAlignment();
75 wxSize GetWeight();
76
77 private:
78 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);
79
80 };
81
82 //---------------------------------------------------------------------------
83 // wxMultiCellSizer
84 //---------------------------------------------------------------------------
85
86 class WXDLLIMPEXP_GIZMOS wxMultiCellSizer : virtual public wxSizer
87 {
88 DECLARE_CLASS(wxMultiCellSizer);
89
90 protected:
91 wxSize m_cell_count;
92
93 public:
94 wxMultiCellSizer(wxSize & size);
95 wxMultiCellSizer(int rows, int cols);
96 ~wxMultiCellSizer();
97
98 virtual void RecalcSizes();
99 virtual wxSize CalcMin();
100 bool SetDefaultCellSize(wxSize size);
101 bool SetColumnWidth(int column, int colSize = 5, bool expandable = FALSE);
102 bool SetRowHeight(int row, int rowSize = 5, bool expandable = FALSE);
103 bool EnableGridLines(wxWindow *win);
104 bool SetGridPen(wxPen *pen);
105 void OnPaint(wxDC& dc);
106
107 private:
108 void GetMinimums();
109 int Sum(int *array, int x);
110
111 private:
112 int *m_maxHeight;
113 int *m_maxWidth;
114 int *m_rowStretch;
115 int *m_colStretch;
116 wxSize **m_weights;
117 wxSize **m_minSizes;
118 int m_maxWeights;
119 wxSize m_defaultCellSize;
120 wxWindow *m_win; // usually used for debugging
121 wxPen *m_pen;
122
123 void DrawGridLines(wxDC& dc);
124 void Initialize(wxSize size);
125 };
126
127
128 // wxCell is used internally, so we don't need to declare it here
129
130 class wxCell;
131
132 //---------------------------------------------------------------------------
133 // wxMultiCellCanvas
134 //---------------------------------------------------------------------------
135
136 class WXDLLIMPEXP_GIZMOS wxMultiCellCanvas : public wxFlexGridSizer
137 {
138 public:
139 wxMultiCellCanvas(wxWindow *parent, int numRows = 2, int numCols = 2);
140 void Add(wxWindow *win, unsigned int row, unsigned int col);
141
142 void Resize(int numRows, int numCols);
143 int MaxRows()
144 {
145 return m_maxRows;
146 };
147 int MaxCols()
148 {
149 return m_maxCols;
150 };
151 void CalculateConstraints();
152 void SetMinCellSize(const wxSize size)
153 {
154 m_minCellSize = size;
155 };
156
157 /* These are to hide Add() method of parents and to avoid Borland warning about hiding virtual functions */
158 void Add( wxWindow *window, int proportion = 0, int flag = 0, int border = 0, wxObject* userData = NULL )
159 { wxFlexGridSizer::Add( window, proportion, flag, border, userData); }
160 void Add( wxSizer *sizer, int proportion = 0, int flag = 0, int border = 0, wxObject* userData = NULL )
161 { wxFlexGridSizer::Add( sizer, proportion, flag, border, userData); }
162 void Add( int width, int height, int proportion = 0, int flag = 0, int border = 0, wxObject* userData = NULL )
163 { wxFlexGridSizer::Add( width, height, proportion, flag, border, userData); }
164 void Add( wxSizerItem *item )
165 { wxFlexGridSizer::Add( item); }
166
167 private:
168 wxWindow *m_parent;
169 unsigned int m_maxRows, m_maxCols;
170
171 wxSize m_minCellSize;
172 wxCell **m_cells;
173 };
174
175 #endif
176
177
178
179 /*** End of File ***/