Get rid of WXGetAsCustom().
[wxWidgets.git] / include / wx / generic / dvrenderers.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/dvrenderers.h
3 // Purpose: All generic wxDataViewCtrl renderer classes
4 // Author: Robert Roebling, Vadim Zeitlin
5 // Created: 2009-11-07 (extracted from wx/generic/dataview.h)
6 // RCS-ID: $Id$
7 // Copyright: (c) 2006 Robert Roebling
8 // (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_GENERIC_DVRENDERERS_H_
13 #define _WX_GENERIC_DVRENDERERS_H_
14
15 // ---------------------------------------------------------
16 // wxDataViewCustomRenderer
17 // ---------------------------------------------------------
18
19 class WXDLLIMPEXP_ADV wxDataViewCustomRenderer: public wxDataViewRenderer
20 {
21 public:
22 wxDataViewCustomRenderer( const wxString &varianttype = wxT("string"),
23 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
24 int align = wxDVR_DEFAULT_ALIGNMENT );
25
26
27 // see the explanation of the following WXOnXXX() methods in wx/generic/dvrenderer.h
28
29 virtual bool WXOnActivate(wxRect cell,
30 wxDataViewModel *model,
31 const wxDataViewItem& item,
32 unsigned int col)
33 {
34 return Activate(cell, model, item, col);
35 }
36
37 virtual bool WXOnLeftClick(wxPoint cursor,
38 wxRect cell,
39 wxDataViewModel *model,
40 const wxDataViewItem &item,
41 unsigned int col)
42 {
43 return LeftClick(cursor, cell, model, item, col);
44 }
45
46 private:
47 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer)
48 };
49
50
51 // ---------------------------------------------------------
52 // wxDataViewTextRenderer
53 // ---------------------------------------------------------
54
55 class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer
56 {
57 public:
58 wxDataViewTextRenderer( const wxString &varianttype = wxT("string"),
59 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
60 int align = wxDVR_DEFAULT_ALIGNMENT );
61
62 bool SetValue( const wxVariant &value );
63 bool GetValue( wxVariant &value ) const;
64
65 virtual bool Render(wxRect cell, wxDC *dc, int state);
66 virtual wxSize GetSize() const;
67
68 // in-place editing
69 virtual bool HasEditorCtrl() const;
70 virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect,
71 const wxVariant &value );
72 virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value );
73
74 protected:
75 wxString m_text;
76
77 protected:
78 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer)
79 };
80
81 // ---------------------------------------------------------
82 // wxDataViewBitmapRenderer
83 // ---------------------------------------------------------
84
85 class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewRenderer
86 {
87 public:
88 wxDataViewBitmapRenderer( const wxString &varianttype = wxT("wxBitmap"),
89 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
90 int align = wxDVR_DEFAULT_ALIGNMENT );
91
92 bool SetValue( const wxVariant &value );
93 bool GetValue( wxVariant &value ) const;
94
95 bool Render( wxRect cell, wxDC *dc, int state );
96 wxSize GetSize() const;
97
98 private:
99 wxIcon m_icon;
100 wxBitmap m_bitmap;
101
102 protected:
103 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer)
104 };
105
106 // ---------------------------------------------------------
107 // wxDataViewToggleRenderer
108 // ---------------------------------------------------------
109
110 class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewRenderer
111 {
112 public:
113 wxDataViewToggleRenderer( const wxString &varianttype = wxT("bool"),
114 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
115 int align = wxDVR_DEFAULT_ALIGNMENT );
116
117 bool SetValue( const wxVariant &value );
118 bool GetValue( wxVariant &value ) const;
119
120 bool Render( wxRect cell, wxDC *dc, int state );
121 wxSize GetSize() const;
122
123 // Implementation only, don't use nor override
124 virtual bool WXOnActivate(wxRect cell,
125 wxDataViewModel *model,
126 const wxDataViewItem& item,
127 unsigned int col);
128 private:
129 bool m_toggle;
130
131 protected:
132 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer)
133 };
134
135 // ---------------------------------------------------------
136 // wxDataViewProgressRenderer
137 // ---------------------------------------------------------
138
139 class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewRenderer
140 {
141 public:
142 wxDataViewProgressRenderer( const wxString &label = wxEmptyString,
143 const wxString &varianttype = wxT("long"),
144 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
145 int align = wxDVR_DEFAULT_ALIGNMENT );
146
147 bool SetValue( const wxVariant &value );
148 bool GetValue( wxVariant& value ) const;
149
150 virtual bool Render(wxRect cell, wxDC *dc, int state);
151 virtual wxSize GetSize() const;
152
153 private:
154 wxString m_label;
155 int m_value;
156
157 protected:
158 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer)
159 };
160
161 // ---------------------------------------------------------
162 // wxDataViewIconTextRenderer
163 // ---------------------------------------------------------
164
165 class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewRenderer
166 {
167 public:
168 wxDataViewIconTextRenderer( const wxString &varianttype = wxT("wxDataViewIconText"),
169 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
170 int align = wxDVR_DEFAULT_ALIGNMENT );
171
172 bool SetValue( const wxVariant &value );
173 bool GetValue( wxVariant &value ) const;
174
175 virtual bool Render(wxRect cell, wxDC *dc, int state);
176 virtual wxSize GetSize() const;
177
178 virtual bool HasEditorCtrl() const { return true; }
179 virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect,
180 const wxVariant &value );
181 virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value );
182
183 private:
184 wxDataViewIconText m_value;
185
186 protected:
187 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer)
188 };
189
190 // ---------------------------------------------------------
191 // wxDataViewDateRenderer
192 // ---------------------------------------------------------
193
194 class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewRenderer
195 {
196 public:
197 wxDataViewDateRenderer( const wxString &varianttype = wxT("datetime"),
198 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
199 int align = wxDVR_DEFAULT_ALIGNMENT );
200
201 bool SetValue( const wxVariant &value );
202 bool GetValue( wxVariant& value ) const;
203
204 virtual bool Render( wxRect cell, wxDC *dc, int state );
205 virtual wxSize GetSize() const;
206
207 // Implementation only, don't use nor override
208 virtual bool WXOnActivate(wxRect cell,
209 wxDataViewModel *model,
210 const wxDataViewItem& item,
211 unsigned int col);
212
213 private:
214 wxDateTime m_date;
215
216 protected:
217 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer)
218 };
219
220
221 #endif // _WX_GENERIC_DVRENDERERS_H_
222