]> git.saurik.com Git - wxWidgets.git/blame - contrib/include/wx/gizmos/multicell.h
Fixups for solaris; remove '-mt' from pkg-config output and add '-lX11' for a static...
[wxWidgets.git] / contrib / include / wx / gizmos / multicell.h
CommitLineData
58580a7e
JS
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:
118cc185 7// RCS-ID: $Id$
58580a7e
JS
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
936a13b5 18#include "wx/gizmos/gizmos.h"
086ab766 19
58580a7e
JS
20// ----------------------------------------------------------------------------
21// headers
22// ----------------------------------------------------------------------------
23// The classes are derived from wxSizer
24#include "wx/sizer.h"
25
26
27// ----------------------------------------------------------------------------
28// constants
29// ----------------------------------------------------------------------------
30enum wxResizable
31{
a2d49353
WS
32 wxNOT_RESIZABLE = 0x00,
33 wxHORIZONTAL_RESIZABLE = 0x01,
34 wxVERTICAL_RESIZABLE = 0x10,
35 wxRESIZABLE = 0x11
58580a7e
JS
36};
37
38//---------------------------------------------------------------------------
39// classes
40//---------------------------------------------------------------------------
41
42//---------------------------------------------------------------------------
43// wxMultiCellItemHandle
44//---------------------------------------------------------------------------
45
936a13b5 46class WXDLLIMPEXP_GIZMOS wxMultiCellItemHandle: public wxObject
58580a7e 47{
fde63257 48 DECLARE_CLASS(wxMultiCellItemHandle)
58580a7e 49protected:
a2d49353
WS
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;
58580a7e
JS
58
59public:
a2d49353
WS
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);
a2d49353
WS
63 int GetColumn();
64 int GetRow();
65 int GetWidth();
66 int GetHeight();
67 wxResizable GetStyle();
68 wxSize GetLocalSize();
69 int GetAlignment();
70 wxSize GetWeight();
58580a7e
JS
71
72private:
a2d49353 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);
58580a7e
JS
74
75};
76
77//---------------------------------------------------------------------------
78// wxMultiCellSizer
79//---------------------------------------------------------------------------
80
936a13b5 81class WXDLLIMPEXP_GIZMOS wxMultiCellSizer : virtual public wxSizer
58580a7e 82{
fde63257 83 DECLARE_CLASS(wxMultiCellSizer)
58580a7e
JS
84
85protected:
a2d49353 86 wxSize m_cell_count;
58580a7e
JS
87
88public:
a2d49353
WS
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(wxPen *pen);
100 void OnPaint(wxDC& dc);
58580a7e
JS
101
102private:
a2d49353
WS
103 void GetMinimums();
104 int Sum(int *array, int x);
58580a7e
JS
105
106private:
a2d49353
WS
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 wxPen *m_pen;
117
118 void DrawGridLines(wxDC& dc);
119 void Initialize(wxSize size);
58580a7e
JS
120};
121
122
123// wxCell is used internally, so we don't need to declare it here
124
125class wxCell;
126
127//---------------------------------------------------------------------------
128// wxMultiCellCanvas
129//---------------------------------------------------------------------------
130
936a13b5 131class WXDLLIMPEXP_GIZMOS wxMultiCellCanvas : public wxFlexGridSizer
58580a7e
JS
132{
133public:
a2d49353
WS
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 };
58580a7e 151
ba597ca8
JS
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
58580a7e 162private:
a2d49353
WS
163 wxWindow *m_parent;
164 unsigned int m_maxRows, m_maxCols;
58580a7e 165
a2d49353
WS
166 wxSize m_minCellSize;
167 wxCell **m_cells;
58580a7e
JS
168};
169
170#endif
171
172
173
174/*** End of File ***/