No real changes, just remove some unnecessary casts.
[wxWidgets.git] / include / wx / gtk / dvrenderers.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/dvrenderers.h
3 // Purpose: All GTK wxDataViewCtrl renderer classes
4 // Author: Robert Roebling, Vadim Zeitlin
5 // Created: 2009-11-07 (extracted from wx/gtk/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_GTK_DVRENDERERS_H_
13 #define _WX_GTK_DVRENDERERS_H_
14
15 typedef struct _GdkRectangle GdkRectangle;
16
17 // ---------------------------------------------------------
18 // wxDataViewTextRenderer
19 // ---------------------------------------------------------
20
21 class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer
22 {
23 public:
24 wxDataViewTextRenderer( const wxString &varianttype = "string",
25 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
26 int align = wxDVR_DEFAULT_ALIGNMENT );
27
28 virtual bool SetValue( const wxVariant &value )
29 {
30 return SetTextValue(value);
31 }
32
33 virtual bool GetValue( wxVariant &value ) const
34 {
35 wxString str;
36 if ( !GetTextValue(str) )
37 return false;
38
39 value = str;
40
41 return true;
42 }
43
44 virtual void SetAlignment( int align );
45
46 virtual bool GtkSupportsAttrs() const { return true; }
47
48 protected:
49 // implementation of Set/GetValue()
50 bool SetTextValue(const wxString& str);
51 bool GetTextValue(wxString& str) const;
52
53
54 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer)
55 };
56
57 // ---------------------------------------------------------
58 // wxDataViewBitmapRenderer
59 // ---------------------------------------------------------
60
61 class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewRenderer
62 {
63 public:
64 wxDataViewBitmapRenderer( const wxString &varianttype = "wxBitmap",
65 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
66 int align = wxDVR_DEFAULT_ALIGNMENT );
67
68 bool SetValue( const wxVariant &value );
69 bool GetValue( wxVariant &value ) const;
70
71 protected:
72 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer)
73 };
74
75 // ---------------------------------------------------------
76 // wxDataViewToggleRenderer
77 // ---------------------------------------------------------
78
79 class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewRenderer
80 {
81 public:
82 wxDataViewToggleRenderer( const wxString &varianttype = "bool",
83 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
84 int align = wxDVR_DEFAULT_ALIGNMENT );
85
86 bool SetValue( const wxVariant &value );
87 bool GetValue( wxVariant &value ) const;
88
89 protected:
90 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer)
91 };
92
93 // ---------------------------------------------------------
94 // wxDataViewCustomRenderer
95 // ---------------------------------------------------------
96
97 class WXDLLIMPEXP_ADV wxDataViewCustomRenderer: public wxDataViewCustomRendererBase
98 {
99 public:
100 wxDataViewCustomRenderer( const wxString &varianttype = "string",
101 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
102 int align = wxDVR_DEFAULT_ALIGNMENT,
103 bool no_init = false );
104 virtual ~wxDataViewCustomRenderer();
105
106
107 // Create DC on request
108 virtual wxDC *GetDC();
109
110 // override the base class function to use GTK text cell renderer
111 virtual void RenderText(const wxString& text,
112 int xoffset,
113 wxRect cell,
114 wxDC *dc,
115 int state);
116
117 protected:
118
119 bool Init(wxDataViewCellMode mode, int align);
120
121 private:
122 wxDC *m_dc;
123
124 public:
125 // Internal, temporary for RenderText.
126 GtkCellRenderer *m_text_renderer;
127 GdkWindow *window;
128 GtkWidget *widget;
129 GdkRectangle *background_area;
130 GdkRectangle *cell_area;
131 GdkRectangle *expose_area;
132 int flags;
133
134 protected:
135 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer)
136 };
137
138 // ---------------------------------------------------------
139 // wxDataViewProgressRenderer
140 // ---------------------------------------------------------
141
142 class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewCustomRenderer
143 {
144 public:
145 wxDataViewProgressRenderer( const wxString &label = wxEmptyString,
146 const wxString &varianttype = "long",
147 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
148 int align = wxDVR_DEFAULT_ALIGNMENT );
149 virtual ~wxDataViewProgressRenderer();
150
151 bool SetValue( const wxVariant &value );
152 bool GetValue( wxVariant &value ) const;
153
154 virtual bool Render( wxRect cell, wxDC *dc, int state );
155 virtual wxSize GetSize() const;
156
157 private:
158 wxString m_label;
159 int m_value;
160
161 protected:
162 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer)
163 };
164
165 // ---------------------------------------------------------
166 // wxDataViewIconTextRenderer
167 // ---------------------------------------------------------
168
169 class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewTextRenderer
170 {
171 public:
172 wxDataViewIconTextRenderer( const wxString &varianttype = "wxDataViewIconText",
173 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
174 int align = wxDVR_DEFAULT_ALIGNMENT );
175 virtual ~wxDataViewIconTextRenderer();
176
177 bool SetValue( const wxVariant &value );
178 bool GetValue( wxVariant &value ) const;
179
180 virtual void GtkPackIntoColumn(GtkTreeViewColumn *column);
181
182 protected:
183 virtual void GtkOnCellChanged(const wxVariant& value,
184 const wxDataViewItem& item,
185 unsigned col);
186
187 private:
188 wxDataViewIconText m_value;
189
190 // we use the base class m_renderer for the text and this one for the icon
191 GtkCellRenderer *m_rendererIcon;
192
193 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer)
194 };
195
196 // ---------------------------------------------------------
197 // wxDataViewDateRenderer
198 // ---------------------------------------------------------
199
200 class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewCustomRenderer
201 {
202 public:
203 wxDataViewDateRenderer( const wxString &varianttype = "datetime",
204 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
205 int align = wxDVR_DEFAULT_ALIGNMENT );
206
207 bool SetValue( const wxVariant &value );
208 bool GetValue( wxVariant &value ) const;
209
210 virtual bool Render( wxRect cell, wxDC *dc, int state );
211 virtual wxSize GetSize() const;
212 virtual bool Activate( wxRect cell,
213 wxDataViewModel *model,
214 const wxDataViewItem &item,
215 unsigned int col );
216
217 private:
218 wxDateTime m_date;
219
220 protected:
221 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer)
222 };
223
224 // -------------------------------------
225 // wxDataViewChoiceRenderer
226 // -------------------------------------
227
228 class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer: public wxDataViewCustomRenderer
229 {
230 public:
231 wxDataViewChoiceRenderer(const wxArrayString &choices,
232 wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
233 int alignment = wxDVR_DEFAULT_ALIGNMENT );
234 virtual bool Render( wxRect rect, wxDC *dc, int state );
235 virtual wxSize GetSize() const;
236 virtual bool SetValue( const wxVariant &value );
237 virtual bool GetValue( wxVariant &value ) const;
238
239 void SetAlignment( int align );
240
241 private:
242 wxArrayString m_choices;
243 wxString m_data;
244 };
245
246 #endif // _WX_GTK_DVRENDERERS_H_
247