1 ///////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/gridctrl.h
3 // Purpose: wxGrid controls
4 // Author: Paul Gammans, Roger Gammans
8 // Copyright: (c) The Computer Surgery (paul@compsurg.co.uk)
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_GENERIC_GRIDCTRL_H_
13 #define _WX_GENERIC_GRIDCTRL_H_
19 #define wxGRID_VALUE_CHOICEINT wxT("choiceint")
20 #define wxGRID_VALUE_DATETIME wxT("datetime")
23 // the default renderer for the cells containing string data
24 class WXDLLIMPEXP_ADV wxGridCellStringRenderer
: public wxGridCellRenderer
28 virtual void Draw(wxGrid
& grid
,
35 // return the string extent
36 virtual wxSize
GetBestSize(wxGrid
& grid
,
41 virtual wxGridCellRenderer
*Clone() const
42 { return new wxGridCellStringRenderer
; }
45 // set the text colours before drawing
46 void SetTextColoursAndFont(const wxGrid
& grid
,
47 const wxGridCellAttr
& attr
,
51 // calc the string extent for given string/font
52 wxSize
DoGetBestSize(const wxGridCellAttr
& attr
,
54 const wxString
& text
);
57 // the default renderer for the cells containing numeric (long) data
58 class WXDLLIMPEXP_ADV wxGridCellNumberRenderer
: public wxGridCellStringRenderer
61 // draw the string right aligned
62 virtual void Draw(wxGrid
& grid
,
69 virtual wxSize
GetBestSize(wxGrid
& grid
,
74 virtual wxGridCellRenderer
*Clone() const
75 { return new wxGridCellNumberRenderer
; }
78 wxString
GetString(const wxGrid
& grid
, int row
, int col
);
81 class WXDLLIMPEXP_ADV wxGridCellFloatRenderer
: public wxGridCellStringRenderer
84 wxGridCellFloatRenderer(int width
= -1, int precision
= -1);
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(); }
92 // draw the string right aligned with given width/precision
93 virtual void Draw(wxGrid
& grid
,
100 virtual wxSize
GetBestSize(wxGrid
& grid
,
101 wxGridCellAttr
& attr
,
105 // parameters string format is "width[,precision]"
106 virtual void SetParameters(const wxString
& params
);
108 virtual wxGridCellRenderer
*Clone() const;
111 wxString
GetString(const wxGrid
& grid
, int row
, int col
);
114 // formatting parameters
121 // renderer for boolean fields
122 class WXDLLIMPEXP_ADV wxGridCellBoolRenderer
: public wxGridCellRenderer
125 // draw a check mark or nothing
126 virtual void Draw(wxGrid
& grid
,
127 wxGridCellAttr
& attr
,
133 // return the checkmark size
134 virtual wxSize
GetBestSize(wxGrid
& grid
,
135 wxGridCellAttr
& attr
,
139 virtual wxGridCellRenderer
*Clone() const
140 { return new wxGridCellBoolRenderer
; }
143 static wxSize ms_sizeCheckMark
;
149 #include "wx/datetime.h"
151 // the default renderer for the cells containing times and dates
152 class WXDLLIMPEXP_ADV wxGridCellDateTimeRenderer
: public wxGridCellStringRenderer
155 wxGridCellDateTimeRenderer(const wxString
& outformat
= wxDefaultDateTimeFormat
,
156 const wxString
& informat
= wxDefaultDateTimeFormat
);
158 // draw the string right aligned
159 virtual void Draw(wxGrid
& grid
,
160 wxGridCellAttr
& attr
,
166 virtual wxSize
GetBestSize(wxGrid
& grid
,
167 wxGridCellAttr
& attr
,
171 virtual wxGridCellRenderer
*Clone() const;
173 // output strptime()-like format string
174 virtual void SetParameters(const wxString
& params
);
177 wxString
GetString(const wxGrid
& grid
, int row
, int col
);
181 wxDateTime m_dateDef
;
182 wxDateTime::TimeZone m_tz
;
185 #endif // wxUSE_DATETIME
187 // renders a number using the corresponding text string
188 class WXDLLIMPEXP_ADV wxGridCellEnumRenderer
: public wxGridCellStringRenderer
191 wxGridCellEnumRenderer( const wxString
& choices
= wxEmptyString
);
193 // draw the string right aligned
194 virtual void Draw(wxGrid
& grid
,
195 wxGridCellAttr
& attr
,
201 virtual wxSize
GetBestSize(wxGrid
& grid
,
202 wxGridCellAttr
& attr
,
206 virtual wxGridCellRenderer
*Clone() const;
208 // parameters string format is "item1[,item2[...,itemN]]" where itemN will
209 // be used if the cell value is N-1
210 virtual void SetParameters(const wxString
& params
);
213 wxString
GetString(const wxGrid
& grid
, int row
, int col
);
215 wxArrayString m_choices
;
219 class WXDLLIMPEXP_ADV wxGridCellAutoWrapStringRenderer
: public wxGridCellStringRenderer
222 wxGridCellAutoWrapStringRenderer() : wxGridCellStringRenderer() { }
224 virtual void Draw(wxGrid
& grid
,
225 wxGridCellAttr
& attr
,
231 virtual wxSize
GetBestSize(wxGrid
& grid
,
232 wxGridCellAttr
& attr
,
236 virtual wxGridCellRenderer
*Clone() const
237 { return new wxGridCellAutoWrapStringRenderer
; }
240 wxArrayString
GetTextLines( wxGrid
& grid
,
242 const wxGridCellAttr
& attr
,
249 #endif // _WX_GENERIC_GRIDCTRL_H_