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
;
17 // ---------------------------------------------------------
18 // wxDataViewTextRenderer
19 // ---------------------------------------------------------
21 class WXDLLIMPEXP_ADV wxDataViewTextRenderer
: public wxDataViewRenderer
24 wxDataViewTextRenderer( const wxString
&varianttype
= "string",
25 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
26 int align
= wxDVR_DEFAULT_ALIGNMENT
);
28 virtual bool SetValue( const wxVariant
&value
)
30 return SetTextValue(value
);
33 virtual bool GetValue( wxVariant
&value
) const
36 if ( !GetTextValue(str
) )
44 virtual void SetAlignment( int align
);
46 virtual bool GtkSupportsAttrs() const { return true; }
49 // implementation of Set/GetValue()
50 bool SetTextValue(const wxString
& str
);
51 bool GetTextValue(wxString
& str
) const;
54 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer
)
57 // ---------------------------------------------------------
58 // wxDataViewBitmapRenderer
59 // ---------------------------------------------------------
61 class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer
: public wxDataViewRenderer
64 wxDataViewBitmapRenderer( const wxString
&varianttype
= "wxBitmap",
65 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
66 int align
= wxDVR_DEFAULT_ALIGNMENT
);
68 bool SetValue( const wxVariant
&value
);
69 bool GetValue( wxVariant
&value
) const;
72 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer
)
75 // ---------------------------------------------------------
76 // wxDataViewToggleRenderer
77 // ---------------------------------------------------------
79 class WXDLLIMPEXP_ADV wxDataViewToggleRenderer
: public wxDataViewRenderer
82 wxDataViewToggleRenderer( const wxString
&varianttype
= "bool",
83 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
84 int align
= wxDVR_DEFAULT_ALIGNMENT
);
86 bool SetValue( const wxVariant
&value
);
87 bool GetValue( wxVariant
&value
) const;
90 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer
)
93 // ---------------------------------------------------------
94 // wxDataViewCustomRenderer
95 // ---------------------------------------------------------
97 class WXDLLIMPEXP_ADV wxDataViewCustomRenderer
: public wxDataViewCustomRendererBase
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();
107 // Create DC on request
108 virtual wxDC
*GetDC();
110 // override the base class function to use GTK text cell renderer
111 virtual void RenderText(const wxString
& text
,
117 // store GTK render call parameters for possible later use
118 void GTKStashRenderParams(GdkWindow
*window
,
120 GdkRectangle
*background_area
,
121 GdkRectangle
*expose_area
,
124 m_renderParams
.window
= window
;
125 m_renderParams
.widget
= widget
;
126 m_renderParams
.background_area
= background_area
;
127 m_renderParams
.expose_area
= expose_area
;
128 m_renderParams
.flags
= flags
;
132 bool Init(wxDataViewCellMode mode
, int align
);
137 GtkCellRenderer
*m_text_renderer
;
139 // parameters of the original render() call stored so that we could pass
140 // them forward to m_text_renderer if our RenderText() is called
141 struct GTKRenderParams
145 GdkRectangle
*background_area
;
146 GdkRectangle
*expose_area
;
150 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer
)
153 // ---------------------------------------------------------
154 // wxDataViewProgressRenderer
155 // ---------------------------------------------------------
157 class WXDLLIMPEXP_ADV wxDataViewProgressRenderer
: public wxDataViewCustomRenderer
160 wxDataViewProgressRenderer( const wxString
&label
= wxEmptyString
,
161 const wxString
&varianttype
= "long",
162 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
163 int align
= wxDVR_DEFAULT_ALIGNMENT
);
164 virtual ~wxDataViewProgressRenderer();
166 bool SetValue( const wxVariant
&value
);
167 bool GetValue( wxVariant
&value
) const;
169 virtual bool Render( wxRect cell
, wxDC
*dc
, int state
);
170 virtual wxSize
GetSize() const;
177 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer
)
180 // ---------------------------------------------------------
181 // wxDataViewIconTextRenderer
182 // ---------------------------------------------------------
184 class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer
: public wxDataViewTextRenderer
187 wxDataViewIconTextRenderer( const wxString
&varianttype
= "wxDataViewIconText",
188 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
189 int align
= wxDVR_DEFAULT_ALIGNMENT
);
190 virtual ~wxDataViewIconTextRenderer();
192 bool SetValue( const wxVariant
&value
);
193 bool GetValue( wxVariant
&value
) const;
195 virtual void GtkPackIntoColumn(GtkTreeViewColumn
*column
);
198 virtual void GtkOnCellChanged(const wxVariant
& value
,
199 const wxDataViewItem
& item
,
203 wxDataViewIconText m_value
;
205 // we use the base class m_renderer for the text and this one for the icon
206 GtkCellRenderer
*m_rendererIcon
;
208 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer
)
211 // ---------------------------------------------------------
212 // wxDataViewDateRenderer
213 // ---------------------------------------------------------
215 class WXDLLIMPEXP_ADV wxDataViewDateRenderer
: public wxDataViewCustomRenderer
218 wxDataViewDateRenderer( const wxString
&varianttype
= "datetime",
219 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
220 int align
= wxDVR_DEFAULT_ALIGNMENT
);
222 bool SetValue( const wxVariant
&value
);
223 bool GetValue( wxVariant
&value
) const;
225 virtual bool Render( wxRect cell
, wxDC
*dc
, int state
);
226 virtual wxSize
GetSize() const;
227 virtual bool Activate( wxRect cell
,
228 wxDataViewModel
*model
,
229 const wxDataViewItem
&item
,
236 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer
)
239 // -------------------------------------
240 // wxDataViewChoiceRenderer
241 // -------------------------------------
243 class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer
: public wxDataViewCustomRenderer
246 wxDataViewChoiceRenderer(const wxArrayString
&choices
,
247 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
248 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
249 virtual bool Render( wxRect rect
, wxDC
*dc
, int state
);
250 virtual wxSize
GetSize() const;
251 virtual bool SetValue( const wxVariant
&value
);
252 virtual bool GetValue( wxVariant
&value
) const;
254 void SetAlignment( int align
);
257 wxArrayString m_choices
;
261 #endif // _WX_GTK_DVRENDERERS_H_