1
///////////////////////////////////////////////////////////////////////////
2
// Name: wx/generic/gridctrl.h
3
// Purpose: wxGrid controls
4
// Author: Paul Gammans, Roger Gammans
7
// Copyright: (c) The Computer Surgery (paul@compsurg.co.uk)
8
// Licence: wxWindows licence
9
/////////////////////////////////////////////////////////////////////////////
11
#ifndef _WX_GENERIC_GRIDCTRL_H_
12
#define _WX_GENERIC_GRIDCTRL_H_
18
#define wxGRID_VALUE_CHOICEINT wxT("choiceint")
19
#define wxGRID_VALUE_DATETIME wxT("datetime")
22
// the default renderer for the cells containing string data
23
class WXDLLIMPEXP_ADV wxGridCellStringRenderer : public wxGridCellRenderer
27
virtual void Draw(wxGrid& grid,
34
// return the string extent
35
virtual wxSize GetBestSize(wxGrid& grid,
40
virtual wxGridCellRenderer *Clone() const
41
{ return new wxGridCellStringRenderer; }
44
// set the text colours before drawing
45
void SetTextColoursAndFont(const wxGrid& grid,
46
const wxGridCellAttr& attr,
50
// calc the string extent for given string/font
51
wxSize DoGetBestSize(const wxGridCellAttr& attr,
53
const wxString& text);
56
// the default renderer for the cells containing numeric (long) data
57
class WXDLLIMPEXP_ADV wxGridCellNumberRenderer : public wxGridCellStringRenderer
60
// draw the string right aligned
61
virtual void Draw(wxGrid& grid,
68
virtual wxSize GetBestSize(wxGrid& grid,
73
virtual wxGridCellRenderer *Clone() const
74
{ return new wxGridCellNumberRenderer; }
77
wxString GetString(const wxGrid& grid, int row, int col);
80
class WXDLLIMPEXP_ADV wxGridCellFloatRenderer : public wxGridCellStringRenderer
83
wxGridCellFloatRenderer(int width = -1,
85
int format = wxGRID_FLOAT_FORMAT_DEFAULT);
87
// get/change formatting parameters
88
int GetWidth() const { return m_width; }
89
void SetWidth(int width) { m_width = width; m_format.clear(); }
90
int GetPrecision() const { return m_precision; }
91
void SetPrecision(int precision) { m_precision = precision; m_format.clear(); }
92
int GetFormat() const { return m_style; }
93
void SetFormat(int format) { m_style = format; m_format.clear(); }
95
// draw the string right aligned with given width/precision
96
virtual void Draw(wxGrid& grid,
103
virtual wxSize GetBestSize(wxGrid& grid,
104
wxGridCellAttr& attr,
108
// parameters string format is "width[,precision[,format]]"
109
// with format being one of f|e|g|E|F|G
110
virtual void SetParameters(const wxString& params);
112
virtual wxGridCellRenderer *Clone() const;
115
wxString GetString(const wxGrid& grid, int row, int col);
118
// formatting parameters
126
// renderer for boolean fields
127
class WXDLLIMPEXP_ADV wxGridCellBoolRenderer : public wxGridCellRenderer
130
// draw a check mark or nothing
131
virtual void Draw(wxGrid& grid,
132
wxGridCellAttr& attr,
138
// return the checkmark size
139
virtual wxSize GetBestSize(wxGrid& grid,
140
wxGridCellAttr& attr,
144
virtual wxGridCellRenderer *Clone() const
145
{ return new wxGridCellBoolRenderer; }
148
static wxSize ms_sizeCheckMark;
154
#include "wx/datetime.h"
156
// the default renderer for the cells containing times and dates
157
class WXDLLIMPEXP_ADV wxGridCellDateTimeRenderer : public wxGridCellStringRenderer
160
wxGridCellDateTimeRenderer(const wxString& outformat = wxDefaultDateTimeFormat,
161
const wxString& informat = wxDefaultDateTimeFormat);
163
// draw the string right aligned
164
virtual void Draw(wxGrid& grid,
165
wxGridCellAttr& attr,
171
virtual wxSize GetBestSize(wxGrid& grid,
172
wxGridCellAttr& attr,
176
virtual wxGridCellRenderer *Clone() const;
178
// output strptime()-like format string
179
virtual void SetParameters(const wxString& params);
182
wxString GetString(const wxGrid& grid, int row, int col);
186
wxDateTime m_dateDef;
187
wxDateTime::TimeZone m_tz;
190
#endif // wxUSE_DATETIME
192
// renders a number using the corresponding text string
193
class WXDLLIMPEXP_ADV wxGridCellEnumRenderer : public wxGridCellStringRenderer
196
wxGridCellEnumRenderer( const wxString& choices = wxEmptyString );
198
// draw the string right aligned
199
virtual void Draw(wxGrid& grid,
200
wxGridCellAttr& attr,
206
virtual wxSize GetBestSize(wxGrid& grid,
207
wxGridCellAttr& attr,
211
virtual wxGridCellRenderer *Clone() const;
213
// parameters string format is "item1[,item2[...,itemN]]" where itemN will
214
// be used if the cell value is N-1
215
virtual void SetParameters(const wxString& params);
218
wxString GetString(const wxGrid& grid, int row, int col);
220
wxArrayString m_choices;
224
class WXDLLIMPEXP_ADV wxGridCellAutoWrapStringRenderer : public wxGridCellStringRenderer
227
wxGridCellAutoWrapStringRenderer() : wxGridCellStringRenderer() { }
229
virtual void Draw(wxGrid& grid,
230
wxGridCellAttr& attr,
236
virtual wxSize GetBestSize(wxGrid& grid,
237
wxGridCellAttr& attr,
241
virtual wxGridCellRenderer *Clone() const
242
{ return new wxGridCellAutoWrapStringRenderer; }
245
wxArrayString GetTextLines( wxGrid& grid,
247
const wxGridCellAttr& attr,
251
// Helper methods of GetTextLines()
253
// Break a single logical line of text into several physical lines, all of
254
// which are added to the lines array. The lines are broken at maxWidth and
255
// the dc is used for measuring text extent only.
256
void BreakLine(wxDC& dc,
257
const wxString& logicalLine,
259
wxArrayString& lines);
261
// Break a word, which is supposed to be wider than maxWidth, into several
262
// lines, which are added to lines array and the last, incomplete, of which
263
// is returned in line output parameter.
265
// Returns the width of the last line.
266
wxCoord BreakWord(wxDC& dc,
267
const wxString& word,
269
wxArrayString& lines,
276
#endif // _WX_GENERIC_GRIDCTRL_H_