]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/gridctrl.h
Add ctor and assign() taking an iterator range to wxVector<>.
[wxWidgets.git] / include / wx / generic / gridctrl.h
CommitLineData
d10f4bf9 1///////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: wx/generic/gridctrl.h
d10f4bf9
VZ
3// Purpose: wxGrid controls
4// Author: Paul Gammans, Roger Gammans
5// Modified by:
6// Created: 11/04/2001
7// RCS-ID: $Id$
8// Copyright: (c) The Computer Surgery (paul@compsurg.co.uk)
65571936 9// Licence: wxWindows licence
d10f4bf9
VZ
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_GENERIC_GRIDCTRL_H_
13#define _WX_GENERIC_GRIDCTRL_H_
14
d10f4bf9 15#include "wx/grid.h"
df9fac6d
PC
16
17#if wxUSE_GRID
d10f4bf9 18
9a83f860
VZ
19#define wxGRID_VALUE_CHOICEINT wxT("choiceint")
20#define wxGRID_VALUE_DATETIME wxT("datetime")
d10f4bf9 21
29efc6e4
FM
22
23// the default renderer for the cells containing string data
24class WXDLLIMPEXP_ADV wxGridCellStringRenderer : public wxGridCellRenderer
25{
26public:
27 // draw the string
28 virtual void Draw(wxGrid& grid,
29 wxGridCellAttr& attr,
30 wxDC& dc,
31 const wxRect& rect,
32 int row, int col,
33 bool isSelected);
34
35 // return the string extent
36 virtual wxSize GetBestSize(wxGrid& grid,
37 wxGridCellAttr& attr,
38 wxDC& dc,
39 int row, int col);
40
41 virtual wxGridCellRenderer *Clone() const
42 { return new wxGridCellStringRenderer; }
43
44protected:
45 // set the text colours before drawing
46 void SetTextColoursAndFont(const wxGrid& grid,
47 const wxGridCellAttr& attr,
48 wxDC& dc,
49 bool isSelected);
50
51 // calc the string extent for given string/font
52 wxSize DoGetBestSize(const wxGridCellAttr& attr,
53 wxDC& dc,
54 const wxString& text);
55};
56
57// the default renderer for the cells containing numeric (long) data
58class WXDLLIMPEXP_ADV wxGridCellNumberRenderer : public wxGridCellStringRenderer
59{
60public:
61 // draw the string right aligned
62 virtual void Draw(wxGrid& grid,
63 wxGridCellAttr& attr,
64 wxDC& dc,
65 const wxRect& rect,
66 int row, int col,
67 bool isSelected);
68
69 virtual wxSize GetBestSize(wxGrid& grid,
70 wxGridCellAttr& attr,
71 wxDC& dc,
72 int row, int col);
73
74 virtual wxGridCellRenderer *Clone() const
75 { return new wxGridCellNumberRenderer; }
76
77protected:
78 wxString GetString(const wxGrid& grid, int row, int col);
79};
80
81class WXDLLIMPEXP_ADV wxGridCellFloatRenderer : public wxGridCellStringRenderer
82{
83public:
1d8d3cc5
VZ
84 wxGridCellFloatRenderer(int width = -1,
85 int precision = -1,
86 int format = wxGRID_FLOAT_FORMAT_DEFAULT);
29efc6e4
FM
87
88 // get/change formatting parameters
89 int GetWidth() const { return m_width; }
90 void SetWidth(int width) { m_width = width; m_format.clear(); }
91 int GetPrecision() const { return m_precision; }
92 void SetPrecision(int precision) { m_precision = precision; m_format.clear(); }
1d8d3cc5
VZ
93 int GetFormat() const { return m_style; }
94 void SetFormat(int format) { m_style = format; m_format.clear(); }
29efc6e4
FM
95
96 // draw the string right aligned with given width/precision
97 virtual void Draw(wxGrid& grid,
98 wxGridCellAttr& attr,
99 wxDC& dc,
100 const wxRect& rect,
101 int row, int col,
102 bool isSelected);
103
104 virtual wxSize GetBestSize(wxGrid& grid,
105 wxGridCellAttr& attr,
106 wxDC& dc,
107 int row, int col);
108
1d8d3cc5
VZ
109 // parameters string format is "width[,precision[,format]]"
110 // with format being one of f|e|g|E|F|G
29efc6e4
FM
111 virtual void SetParameters(const wxString& params);
112
113 virtual wxGridCellRenderer *Clone() const;
114
115protected:
116 wxString GetString(const wxGrid& grid, int row, int col);
117
118private:
119 // formatting parameters
120 int m_width,
121 m_precision;
122
1d8d3cc5 123 int m_style;
29efc6e4
FM
124 wxString m_format;
125};
126
127// renderer for boolean fields
128class WXDLLIMPEXP_ADV wxGridCellBoolRenderer : public wxGridCellRenderer
129{
130public:
131 // draw a check mark or nothing
132 virtual void Draw(wxGrid& grid,
133 wxGridCellAttr& attr,
134 wxDC& dc,
135 const wxRect& rect,
136 int row, int col,
137 bool isSelected);
138
139 // return the checkmark size
140 virtual wxSize GetBestSize(wxGrid& grid,
141 wxGridCellAttr& attr,
142 wxDC& dc,
143 int row, int col);
144
145 virtual wxGridCellRenderer *Clone() const
146 { return new wxGridCellBoolRenderer; }
147
148private:
149 static wxSize ms_sizeCheckMark;
150};
151
152
e2b87f38 153#if wxUSE_DATETIME
6d7aee4f
VZ
154
155#include "wx/datetime.h"
e2b87f38 156
db890987 157// the default renderer for the cells containing times and dates
12f190b0 158class WXDLLIMPEXP_ADV wxGridCellDateTimeRenderer : public wxGridCellStringRenderer
d10f4bf9
VZ
159{
160public:
fbfb8bcc
VZ
161 wxGridCellDateTimeRenderer(const wxString& outformat = wxDefaultDateTimeFormat,
162 const wxString& informat = wxDefaultDateTimeFormat);
d10f4bf9
VZ
163
164 // draw the string right aligned
165 virtual void Draw(wxGrid& grid,
166 wxGridCellAttr& attr,
167 wxDC& dc,
168 const wxRect& rect,
169 int row, int col,
170 bool isSelected);
171
172 virtual wxSize GetBestSize(wxGrid& grid,
173 wxGridCellAttr& attr,
174 wxDC& dc,
175 int row, int col);
176
177 virtual wxGridCellRenderer *Clone() const;
178
db890987 179 // output strptime()-like format string
d10f4bf9
VZ
180 virtual void SetParameters(const wxString& params);
181
182protected:
fbfb8bcc 183 wxString GetString(const wxGrid& grid, int row, int col);
d10f4bf9
VZ
184
185 wxString m_iformat;
186 wxString m_oformat;
187 wxDateTime m_dateDef;
188 wxDateTime::TimeZone m_tz;
189};
190
e2b87f38 191#endif // wxUSE_DATETIME
d10f4bf9 192
db890987 193// renders a number using the corresponding text string
12f190b0 194class WXDLLIMPEXP_ADV wxGridCellEnumRenderer : public wxGridCellStringRenderer
d10f4bf9
VZ
195{
196public:
197 wxGridCellEnumRenderer( const wxString& choices = wxEmptyString );
198
199 // draw the string right aligned
200 virtual void Draw(wxGrid& grid,
201 wxGridCellAttr& attr,
202 wxDC& dc,
203 const wxRect& rect,
204 int row, int col,
205 bool isSelected);
206
207 virtual wxSize GetBestSize(wxGrid& grid,
208 wxGridCellAttr& attr,
209 wxDC& dc,
210 int row, int col);
211
212 virtual wxGridCellRenderer *Clone() const;
213
db890987
VZ
214 // parameters string format is "item1[,item2[...,itemN]]" where itemN will
215 // be used if the cell value is N-1
d10f4bf9
VZ
216 virtual void SetParameters(const wxString& params);
217
218protected:
fbfb8bcc 219 wxString GetString(const wxGrid& grid, int row, int col);
d10f4bf9
VZ
220
221 wxArrayString m_choices;
222};
223
d10f4bf9 224
12f190b0 225class WXDLLIMPEXP_ADV wxGridCellAutoWrapStringRenderer : public wxGridCellStringRenderer
d10f4bf9
VZ
226{
227public:
228 wxGridCellAutoWrapStringRenderer() : wxGridCellStringRenderer() { }
229
230 virtual void Draw(wxGrid& grid,
231 wxGridCellAttr& attr,
232 wxDC& dc,
233 const wxRect& rect,
234 int row, int col,
235 bool isSelected);
236
237 virtual wxSize GetBestSize(wxGrid& grid,
238 wxGridCellAttr& attr,
239 wxDC& dc,
240 int row, int col);
241
242 virtual wxGridCellRenderer *Clone() const
243 { return new wxGridCellAutoWrapStringRenderer; }
244
245private:
246 wxArrayString GetTextLines( wxGrid& grid,
247 wxDC& dc,
fbfb8bcc 248 const wxGridCellAttr& attr,
d10f4bf9
VZ
249 const wxRect& rect,
250 int row, int col);
251
252};
253
df9fac6d
PC
254#endif // wxUSE_GRID
255#endif // _WX_GENERIC_GRIDCTRL_H_