]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/gridctrl.h
Rename wxGenericDirCtrl::ExpandDir() to PopulateNode().
[wxWidgets.git] / include / wx / generic / gridctrl.h
CommitLineData
d10f4bf9
VZ
1///////////////////////////////////////////////////////////////////////////
2// Name: generic/gridctrl.h
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:
84 wxGridCellFloatRenderer(int width = -1, int precision = -1);
85
86 // get/change formatting parameters
87 int GetWidth() const { return m_width; }
88 void SetWidth(int width) { m_width = width; m_format.clear(); }
89 int GetPrecision() const { return m_precision; }
90 void SetPrecision(int precision) { m_precision = precision; m_format.clear(); }
91
92 // draw the string right aligned with given width/precision
93 virtual void Draw(wxGrid& grid,
94 wxGridCellAttr& attr,
95 wxDC& dc,
96 const wxRect& rect,
97 int row, int col,
98 bool isSelected);
99
100 virtual wxSize GetBestSize(wxGrid& grid,
101 wxGridCellAttr& attr,
102 wxDC& dc,
103 int row, int col);
104
105 // parameters string format is "width[,precision]"
106 virtual void SetParameters(const wxString& params);
107
108 virtual wxGridCellRenderer *Clone() const;
109
110protected:
111 wxString GetString(const wxGrid& grid, int row, int col);
112
113private:
114 // formatting parameters
115 int m_width,
116 m_precision;
117
118 wxString m_format;
119};
120
121// renderer for boolean fields
122class WXDLLIMPEXP_ADV wxGridCellBoolRenderer : public wxGridCellRenderer
123{
124public:
125 // draw a check mark or nothing
126 virtual void Draw(wxGrid& grid,
127 wxGridCellAttr& attr,
128 wxDC& dc,
129 const wxRect& rect,
130 int row, int col,
131 bool isSelected);
132
133 // return the checkmark size
134 virtual wxSize GetBestSize(wxGrid& grid,
135 wxGridCellAttr& attr,
136 wxDC& dc,
137 int row, int col);
138
139 virtual wxGridCellRenderer *Clone() const
140 { return new wxGridCellBoolRenderer; }
141
142private:
143 static wxSize ms_sizeCheckMark;
144};
145
146
e2b87f38 147#if wxUSE_DATETIME
6d7aee4f
VZ
148
149#include "wx/datetime.h"
e2b87f38 150
db890987 151// the default renderer for the cells containing times and dates
12f190b0 152class WXDLLIMPEXP_ADV wxGridCellDateTimeRenderer : public wxGridCellStringRenderer
d10f4bf9
VZ
153{
154public:
fbfb8bcc
VZ
155 wxGridCellDateTimeRenderer(const wxString& outformat = wxDefaultDateTimeFormat,
156 const wxString& informat = wxDefaultDateTimeFormat);
d10f4bf9
VZ
157
158 // draw the string right aligned
159 virtual void Draw(wxGrid& grid,
160 wxGridCellAttr& attr,
161 wxDC& dc,
162 const wxRect& rect,
163 int row, int col,
164 bool isSelected);
165
166 virtual wxSize GetBestSize(wxGrid& grid,
167 wxGridCellAttr& attr,
168 wxDC& dc,
169 int row, int col);
170
171 virtual wxGridCellRenderer *Clone() const;
172
db890987 173 // output strptime()-like format string
d10f4bf9
VZ
174 virtual void SetParameters(const wxString& params);
175
176protected:
fbfb8bcc 177 wxString GetString(const wxGrid& grid, int row, int col);
d10f4bf9
VZ
178
179 wxString m_iformat;
180 wxString m_oformat;
181 wxDateTime m_dateDef;
182 wxDateTime::TimeZone m_tz;
183};
184
e2b87f38 185#endif // wxUSE_DATETIME
d10f4bf9 186
db890987 187// renders a number using the corresponding text string
12f190b0 188class WXDLLIMPEXP_ADV wxGridCellEnumRenderer : public wxGridCellStringRenderer
d10f4bf9
VZ
189{
190public:
191 wxGridCellEnumRenderer( const wxString& choices = wxEmptyString );
192
193 // draw the string right aligned
194 virtual void Draw(wxGrid& grid,
195 wxGridCellAttr& attr,
196 wxDC& dc,
197 const wxRect& rect,
198 int row, int col,
199 bool isSelected);
200
201 virtual wxSize GetBestSize(wxGrid& grid,
202 wxGridCellAttr& attr,
203 wxDC& dc,
204 int row, int col);
205
206 virtual wxGridCellRenderer *Clone() const;
207
db890987
VZ
208 // parameters string format is "item1[,item2[...,itemN]]" where itemN will
209 // be used if the cell value is N-1
d10f4bf9
VZ
210 virtual void SetParameters(const wxString& params);
211
212protected:
fbfb8bcc 213 wxString GetString(const wxGrid& grid, int row, int col);
d10f4bf9
VZ
214
215 wxArrayString m_choices;
216};
217
d10f4bf9 218
12f190b0 219class WXDLLIMPEXP_ADV wxGridCellAutoWrapStringRenderer : public wxGridCellStringRenderer
d10f4bf9
VZ
220{
221public:
222 wxGridCellAutoWrapStringRenderer() : wxGridCellStringRenderer() { }
223
224 virtual void Draw(wxGrid& grid,
225 wxGridCellAttr& attr,
226 wxDC& dc,
227 const wxRect& rect,
228 int row, int col,
229 bool isSelected);
230
231 virtual wxSize GetBestSize(wxGrid& grid,
232 wxGridCellAttr& attr,
233 wxDC& dc,
234 int row, int col);
235
236 virtual wxGridCellRenderer *Clone() const
237 { return new wxGridCellAutoWrapStringRenderer; }
238
239private:
240 wxArrayString GetTextLines( wxGrid& grid,
241 wxDC& dc,
fbfb8bcc 242 const wxGridCellAttr& attr,
d10f4bf9
VZ
243 const wxRect& rect,
244 int row, int col);
245
246};
247
df9fac6d
PC
248#endif // wxUSE_GRID
249#endif // _WX_GENERIC_GRIDCTRL_H_