]>
Commit | Line | Data |
---|---|---|
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 VZ |
18 | |
19 | #define wxGRID_VALUE_CHOICEINT _T("choiceint") | |
20 | #define wxGRID_VALUE_DATETIME _T("datetime") | |
21 | ||
e2b87f38 | 22 | #if wxUSE_DATETIME |
6d7aee4f VZ |
23 | |
24 | #include "wx/datetime.h" | |
e2b87f38 | 25 | |
d10f4bf9 | 26 | // the default renderer for the cells containing Time and dates.. |
12f190b0 | 27 | class WXDLLIMPEXP_ADV wxGridCellDateTimeRenderer : public wxGridCellStringRenderer |
d10f4bf9 VZ |
28 | { |
29 | public: | |
fbfb8bcc VZ |
30 | wxGridCellDateTimeRenderer(const wxString& outformat = wxDefaultDateTimeFormat, |
31 | const wxString& informat = wxDefaultDateTimeFormat); | |
d10f4bf9 VZ |
32 | |
33 | // draw the string right aligned | |
34 | virtual void Draw(wxGrid& grid, | |
35 | wxGridCellAttr& attr, | |
36 | wxDC& dc, | |
37 | const wxRect& rect, | |
38 | int row, int col, | |
39 | bool isSelected); | |
40 | ||
41 | virtual wxSize GetBestSize(wxGrid& grid, | |
42 | wxGridCellAttr& attr, | |
43 | wxDC& dc, | |
44 | int row, int col); | |
45 | ||
46 | virtual wxGridCellRenderer *Clone() const; | |
47 | ||
48 | // parameters string format is "width[,precision]" | |
49 | virtual void SetParameters(const wxString& params); | |
50 | ||
51 | protected: | |
fbfb8bcc | 52 | wxString GetString(const wxGrid& grid, int row, int col); |
d10f4bf9 VZ |
53 | |
54 | wxString m_iformat; | |
55 | wxString m_oformat; | |
56 | wxDateTime m_dateDef; | |
57 | wxDateTime::TimeZone m_tz; | |
58 | }; | |
59 | ||
e2b87f38 | 60 | #endif // wxUSE_DATETIME |
d10f4bf9 VZ |
61 | |
62 | // the default renderer for the cells containing Time and dates.. | |
12f190b0 | 63 | class WXDLLIMPEXP_ADV wxGridCellEnumRenderer : public wxGridCellStringRenderer |
d10f4bf9 VZ |
64 | { |
65 | public: | |
66 | wxGridCellEnumRenderer( const wxString& choices = wxEmptyString ); | |
67 | ||
68 | // draw the string right aligned | |
69 | virtual void Draw(wxGrid& grid, | |
70 | wxGridCellAttr& attr, | |
71 | wxDC& dc, | |
72 | const wxRect& rect, | |
73 | int row, int col, | |
74 | bool isSelected); | |
75 | ||
76 | virtual wxSize GetBestSize(wxGrid& grid, | |
77 | wxGridCellAttr& attr, | |
78 | wxDC& dc, | |
79 | int row, int col); | |
80 | ||
81 | virtual wxGridCellRenderer *Clone() const; | |
82 | ||
83 | // parameters string format is "item1[,item2[...,itemN]]" | |
84 | virtual void SetParameters(const wxString& params); | |
85 | ||
86 | protected: | |
fbfb8bcc | 87 | wxString GetString(const wxGrid& grid, int row, int col); |
d10f4bf9 VZ |
88 | |
89 | wxArrayString m_choices; | |
90 | }; | |
91 | ||
92 | ||
3379ed37 VZ |
93 | #if wxUSE_COMBOBOX |
94 | ||
12f190b0 | 95 | class WXDLLIMPEXP_ADV wxGridCellEnumEditor : public wxGridCellChoiceEditor |
d10f4bf9 VZ |
96 | { |
97 | public: | |
98 | wxGridCellEnumEditor( const wxString& choices = wxEmptyString ); | |
6fb99eb3 | 99 | virtual ~wxGridCellEnumEditor() {} |
d10f4bf9 VZ |
100 | |
101 | virtual wxGridCellEditor* Clone() const; | |
102 | ||
d10f4bf9 | 103 | virtual void BeginEdit(int row, int col, wxGrid* grid); |
763163a8 VZ |
104 | virtual bool EndEdit(const wxString& oldval, wxString *newval); |
105 | virtual void ApplyEdit(int row, int col, wxGrid* grid); | |
d10f4bf9 VZ |
106 | |
107 | private: | |
763163a8 | 108 | long m_index; |
fc7a2a60 VZ |
109 | |
110 | DECLARE_NO_COPY_CLASS(wxGridCellEnumEditor) | |
d10f4bf9 VZ |
111 | }; |
112 | ||
3379ed37 | 113 | #endif // wxUSE_COMBOBOX |
d10f4bf9 | 114 | |
12f190b0 | 115 | class WXDLLIMPEXP_ADV wxGridCellAutoWrapStringEditor : public wxGridCellTextEditor |
d10f4bf9 VZ |
116 | { |
117 | public: | |
118 | wxGridCellAutoWrapStringEditor() : wxGridCellTextEditor() { } | |
119 | virtual void Create(wxWindow* parent, | |
120 | wxWindowID id, | |
121 | wxEvtHandler* evtHandler); | |
122 | ||
123 | virtual wxGridCellEditor *Clone() const | |
124 | { return new wxGridCellAutoWrapStringEditor; } | |
fc7a2a60 VZ |
125 | |
126 | DECLARE_NO_COPY_CLASS(wxGridCellAutoWrapStringEditor) | |
d10f4bf9 VZ |
127 | }; |
128 | ||
12f190b0 | 129 | class WXDLLIMPEXP_ADV wxGridCellAutoWrapStringRenderer : public wxGridCellStringRenderer |
d10f4bf9 VZ |
130 | { |
131 | public: | |
132 | wxGridCellAutoWrapStringRenderer() : wxGridCellStringRenderer() { } | |
133 | ||
134 | virtual void Draw(wxGrid& grid, | |
135 | wxGridCellAttr& attr, | |
136 | wxDC& dc, | |
137 | const wxRect& rect, | |
138 | int row, int col, | |
139 | bool isSelected); | |
140 | ||
141 | virtual wxSize GetBestSize(wxGrid& grid, | |
142 | wxGridCellAttr& attr, | |
143 | wxDC& dc, | |
144 | int row, int col); | |
145 | ||
146 | virtual wxGridCellRenderer *Clone() const | |
147 | { return new wxGridCellAutoWrapStringRenderer; } | |
148 | ||
149 | private: | |
150 | wxArrayString GetTextLines( wxGrid& grid, | |
151 | wxDC& dc, | |
fbfb8bcc | 152 | const wxGridCellAttr& attr, |
d10f4bf9 VZ |
153 | const wxRect& rect, |
154 | int row, int col); | |
155 | ||
156 | }; | |
157 | ||
df9fac6d PC |
158 | #endif // wxUSE_GRID |
159 | #endif // _WX_GENERIC_GRIDCTRL_H_ |