]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/dvrenderers.h
Big wxDataViewCtrl renderer classes refactoring.
[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: wxhead.h,v 1.11 2009-06-29 10:23:04 zeitlin Exp $
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 virtual wxDataViewCustomRenderer *WXGetAsCustom() { return this; }
27
28 private:
29 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer)
30 };
31
32
33 // ---------------------------------------------------------
34 // wxDataViewTextRenderer
35 // ---------------------------------------------------------
36
37 class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer
38 {
39 public:
40 wxDataViewTextRenderer( const wxString &varianttype = wxT("string"),
41 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
42 int align = wxDVR_DEFAULT_ALIGNMENT );
43
44 bool SetValue( const wxVariant &value );
45 bool GetValue( wxVariant &value ) const;
46
47 virtual bool RenderWithAttr(wxDC& dc,
48 const wxRect& rect,
49 int align,
50 const wxDataViewItemAttr *attr,
51 int state);
52 virtual bool Render(wxRect cell, wxDC *dc, int state)
53 {
54 return DummyRender(cell, dc, state);
55 }
56
57 wxSize GetSize() const;
58
59 // in-place editing
60 virtual bool HasEditorCtrl() const;
61 virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect,
62 const wxVariant &value );
63 virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value );
64
65 protected:
66 wxString m_text;
67
68 protected:
69 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer)
70 };
71
72 // ---------------------------------------------------------
73 // wxDataViewBitmapRenderer
74 // ---------------------------------------------------------
75
76 class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewRenderer
77 {
78 public:
79 wxDataViewBitmapRenderer( const wxString &varianttype = wxT("wxBitmap"),
80 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
81 int align = wxDVR_DEFAULT_ALIGNMENT );
82
83 bool SetValue( const wxVariant &value );
84 bool GetValue( wxVariant &value ) const;
85
86 bool Render( wxRect cell, wxDC *dc, int state );
87 wxSize GetSize() const;
88
89 private:
90 wxIcon m_icon;
91 wxBitmap m_bitmap;
92
93 protected:
94 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer)
95 };
96
97 // ---------------------------------------------------------
98 // wxDataViewToggleRenderer
99 // ---------------------------------------------------------
100
101 class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewRenderer
102 {
103 public:
104 wxDataViewToggleRenderer( const wxString &varianttype = wxT("bool"),
105 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
106 int align = wxDVR_DEFAULT_ALIGNMENT );
107
108 bool SetValue( const wxVariant &value );
109 bool GetValue( wxVariant &value ) const;
110
111 bool Render( wxRect cell, wxDC *dc, int state );
112 bool Activate( wxRect cell, wxDataViewModel *model, const wxDataViewItem & item,
113 unsigned int col );
114 wxSize GetSize() const;
115
116 private:
117 bool m_toggle;
118
119 protected:
120 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer)
121 };
122
123 // ---------------------------------------------------------
124 // wxDataViewProgressRenderer
125 // ---------------------------------------------------------
126
127 class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewRenderer
128 {
129 public:
130 wxDataViewProgressRenderer( const wxString &label = wxEmptyString,
131 const wxString &varianttype = wxT("long"),
132 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
133 int align = wxDVR_DEFAULT_ALIGNMENT );
134
135 bool SetValue( const wxVariant &value );
136 bool GetValue( wxVariant& value ) const;
137
138 virtual bool RenderWithAttr(wxDC& dc,
139 const wxRect& rect,
140 int align,
141 const wxDataViewItemAttr *attr,
142 int state);
143 virtual bool Render(wxRect cell, wxDC *dc, int state)
144 {
145 return DummyRender(cell, dc, state);
146 }
147 virtual wxSize GetSize() const;
148
149 private:
150 wxString m_label;
151 int m_value;
152
153 protected:
154 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer)
155 };
156
157 // ---------------------------------------------------------
158 // wxDataViewIconTextRenderer
159 // ---------------------------------------------------------
160
161 class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewRenderer
162 {
163 public:
164 wxDataViewIconTextRenderer( const wxString &varianttype = wxT("wxDataViewIconText"),
165 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
166 int align = wxDVR_DEFAULT_ALIGNMENT );
167
168 bool SetValue( const wxVariant &value );
169 bool GetValue( wxVariant &value ) const;
170
171 virtual bool RenderWithAttr(wxDC& dc,
172 const wxRect& rect,
173 int align,
174 const wxDataViewItemAttr *attr,
175 int state);
176 virtual bool Render(wxRect cell, wxDC *dc, int state)
177 {
178 return DummyRender(cell, dc, state);
179 }
180 virtual wxSize GetSize() const;
181
182 virtual bool HasEditorCtrl() const { return true; }
183 virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect,
184 const wxVariant &value );
185 virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value );
186
187 private:
188 wxDataViewIconText m_value;
189
190 protected:
191 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer)
192 };
193
194 // ---------------------------------------------------------
195 // wxDataViewDateRenderer
196 // ---------------------------------------------------------
197
198 class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewRenderer
199 {
200 public:
201 wxDataViewDateRenderer( const wxString &varianttype = wxT("datetime"),
202 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
203 int align = wxDVR_DEFAULT_ALIGNMENT );
204
205 bool SetValue( const wxVariant &value );
206 bool GetValue( wxVariant& value ) const;
207
208 virtual bool Render( wxRect cell, wxDC *dc, int state );
209 virtual wxSize GetSize() const;
210 virtual bool Activate( wxRect cell,
211 wxDataViewModel *model,
212 const wxDataViewItem& item,
213 unsigned int col );
214
215 private:
216 wxDateTime m_date;
217
218 protected:
219 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer)
220 };
221
222
223 #endif // _WX_GENERIC_DVRENDERERS_H_
224