1 ///////////////////////////////////////////////////////////////////////////
2 // Name: 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 _T("choiceint")
20 #define wxGRID_VALUE_DATETIME _T("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 Time 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 // parameters string format is "width[,precision]"
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 // the default renderer for the cells containing Time and dates..
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]]"
209 virtual void SetParameters(const wxString
& params
);
212 wxString
GetString(const wxGrid
& grid
, int row
, int col
);
214 wxArrayString m_choices
;
218 class WXDLLIMPEXP_ADV wxGridCellAutoWrapStringRenderer
: public wxGridCellStringRenderer
221 wxGridCellAutoWrapStringRenderer() : wxGridCellStringRenderer() { }
223 virtual void Draw(wxGrid
& grid
,
224 wxGridCellAttr
& attr
,
230 virtual wxSize
GetBestSize(wxGrid
& grid
,
231 wxGridCellAttr
& attr
,
235 virtual wxGridCellRenderer
*Clone() const
236 { return new wxGridCellAutoWrapStringRenderer
; }
239 wxArrayString
GetTextLines( wxGrid
& grid
,
241 const wxGridCellAttr
& attr
,
248 #endif // _WX_GENERIC_GRIDCTRL_H_