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 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_GTK_DVRENDERERS_H_
13 #define _WX_GTK_DVRENDERERS_H_
15 typedef struct _GdkRectangle GdkRectangle
;
16 typedef struct _GtkCellRendererText GtkCellRendererText
;
18 // ---------------------------------------------------------
19 // wxDataViewTextRenderer
20 // ---------------------------------------------------------
22 class WXDLLIMPEXP_ADV wxDataViewTextRenderer
: public wxDataViewRenderer
25 wxDataViewTextRenderer( const wxString
&varianttype
= "string",
26 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
27 int align
= wxDVR_DEFAULT_ALIGNMENT
);
29 virtual bool SetValue( const wxVariant
&value
)
31 return SetTextValue(value
);
34 virtual bool GetValue( wxVariant
&value
) const
37 if ( !GetTextValue(str
) )
45 virtual void SetAlignment( int align
);
47 virtual bool GtkSupportsAttrs() const { return true; }
48 virtual bool GtkSetAttr(const wxDataViewItemAttr
& attr
);
51 // implementation of Set/GetValue()
52 bool SetTextValue(const wxString
& str
);
53 bool GetTextValue(wxString
& str
) const;
56 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer
)
59 // ---------------------------------------------------------
60 // wxDataViewBitmapRenderer
61 // ---------------------------------------------------------
63 class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer
: public wxDataViewRenderer
66 wxDataViewBitmapRenderer( const wxString
&varianttype
= "wxBitmap",
67 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
68 int align
= wxDVR_DEFAULT_ALIGNMENT
);
70 bool SetValue( const wxVariant
&value
);
71 bool GetValue( wxVariant
&value
) const;
74 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer
)
77 // ---------------------------------------------------------
78 // wxDataViewToggleRenderer
79 // ---------------------------------------------------------
81 class WXDLLIMPEXP_ADV wxDataViewToggleRenderer
: public wxDataViewRenderer
84 wxDataViewToggleRenderer( const wxString
&varianttype
= "bool",
85 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
86 int align
= wxDVR_DEFAULT_ALIGNMENT
);
88 bool SetValue( const wxVariant
&value
);
89 bool GetValue( wxVariant
&value
) const;
92 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer
)
95 // ---------------------------------------------------------
96 // wxDataViewCustomRenderer
97 // ---------------------------------------------------------
99 class WXDLLIMPEXP_ADV wxDataViewCustomRenderer
: public wxDataViewCustomRendererBase
102 wxDataViewCustomRenderer( const wxString
&varianttype
= "string",
103 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
104 int align
= wxDVR_DEFAULT_ALIGNMENT
,
105 bool no_init
= false );
106 virtual ~wxDataViewCustomRenderer();
109 // Create DC on request
110 virtual wxDC
*GetDC();
112 // override the base class function to use GTK text cell renderer
113 virtual void RenderText(const wxString
& text
,
119 // store GTK render call parameters for possible later use
120 void GTKStashRenderParams(GdkWindow
*window
,
122 GdkRectangle
*background_area
,
123 GdkRectangle
*expose_area
,
126 m_renderParams
.window
= window
;
127 m_renderParams
.widget
= widget
;
128 m_renderParams
.background_area
= background_area
;
129 m_renderParams
.expose_area
= expose_area
;
130 m_renderParams
.flags
= flags
;
133 // we may or not support attributes, as we don't know it, return true to
134 // make it possible to use them
135 virtual bool GtkSupportsAttrs() const { return true; }
137 virtual bool GtkSetAttr(const wxDataViewItemAttr
& attr
)
140 return !attr
.IsDefault();
144 bool Init(wxDataViewCellMode mode
, int align
);
149 GtkCellRendererText
*m_text_renderer
;
151 // parameters of the original render() call stored so that we could pass
152 // them forward to m_text_renderer if our RenderText() is called
153 struct GTKRenderParams
157 GdkRectangle
*background_area
;
158 GdkRectangle
*expose_area
;
162 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer
)
165 // ---------------------------------------------------------
166 // wxDataViewProgressRenderer
167 // ---------------------------------------------------------
169 class WXDLLIMPEXP_ADV wxDataViewProgressRenderer
: public wxDataViewCustomRenderer
172 wxDataViewProgressRenderer( const wxString
&label
= wxEmptyString
,
173 const wxString
&varianttype
= "long",
174 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
175 int align
= wxDVR_DEFAULT_ALIGNMENT
);
176 virtual ~wxDataViewProgressRenderer();
178 bool SetValue( const wxVariant
&value
);
179 bool GetValue( wxVariant
&value
) const;
181 virtual bool Render( wxRect cell
, wxDC
*dc
, int state
);
182 virtual wxSize
GetSize() const;
189 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer
)
192 // ---------------------------------------------------------
193 // wxDataViewIconTextRenderer
194 // ---------------------------------------------------------
196 class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer
: public wxDataViewTextRenderer
199 wxDataViewIconTextRenderer( const wxString
&varianttype
= "wxDataViewIconText",
200 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
201 int align
= wxDVR_DEFAULT_ALIGNMENT
);
202 virtual ~wxDataViewIconTextRenderer();
204 bool SetValue( const wxVariant
&value
);
205 bool GetValue( wxVariant
&value
) const;
207 virtual void GtkPackIntoColumn(GtkTreeViewColumn
*column
);
210 virtual void GtkOnCellChanged(const wxVariant
& value
,
211 const wxDataViewItem
& item
,
215 wxDataViewIconText m_value
;
217 // we use the base class m_renderer for the text and this one for the icon
218 GtkCellRenderer
*m_rendererIcon
;
220 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer
)
223 // ---------------------------------------------------------
224 // wxDataViewDateRenderer
225 // ---------------------------------------------------------
227 class WXDLLIMPEXP_ADV wxDataViewDateRenderer
: public wxDataViewCustomRenderer
230 wxDataViewDateRenderer( const wxString
&varianttype
= "datetime",
231 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
232 int align
= wxDVR_DEFAULT_ALIGNMENT
);
234 bool SetValue( const wxVariant
&value
);
235 bool GetValue( wxVariant
&value
) const;
237 virtual bool Render( wxRect cell
, wxDC
*dc
, int state
);
238 virtual wxSize
GetSize() const;
239 virtual bool Activate( wxRect cell
,
240 wxDataViewModel
*model
,
241 const wxDataViewItem
&item
,
248 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer
)
251 // -------------------------------------
252 // wxDataViewChoiceRenderer
253 // -------------------------------------
255 class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer
: public wxDataViewCustomRenderer
258 wxDataViewChoiceRenderer(const wxArrayString
&choices
,
259 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
260 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
261 virtual bool Render( wxRect rect
, wxDC
*dc
, int state
);
262 virtual wxSize
GetSize() const;
263 virtual bool SetValue( const wxVariant
&value
);
264 virtual bool GetValue( wxVariant
&value
) const;
266 void SetAlignment( int align
);
269 wxArrayString m_choices
;
273 #endif // _WX_GTK_DVRENDERERS_H_