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
,
119 bool Init(wxDataViewCellMode mode
, int align
);
125 // Internal, temporary for RenderText.
126 GtkCellRenderer
*m_text_renderer
;
129 GdkRectangle
*background_area
;
130 GdkRectangle
*cell_area
;
131 GdkRectangle
*expose_area
;
135 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer
)
138 // ---------------------------------------------------------
139 // wxDataViewProgressRenderer
140 // ---------------------------------------------------------
142 class WXDLLIMPEXP_ADV wxDataViewProgressRenderer
: public wxDataViewCustomRenderer
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();
151 bool SetValue( const wxVariant
&value
);
152 bool GetValue( wxVariant
&value
) const;
154 virtual bool Render( wxRect cell
, wxDC
*dc
, int state
);
155 virtual wxSize
GetSize() const;
162 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer
)
165 // ---------------------------------------------------------
166 // wxDataViewIconTextRenderer
167 // ---------------------------------------------------------
169 class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer
: public wxDataViewTextRenderer
172 wxDataViewIconTextRenderer( const wxString
&varianttype
= "wxDataViewIconText",
173 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
174 int align
= wxDVR_DEFAULT_ALIGNMENT
);
175 virtual ~wxDataViewIconTextRenderer();
177 bool SetValue( const wxVariant
&value
);
178 bool GetValue( wxVariant
&value
) const;
180 virtual void GtkPackIntoColumn(GtkTreeViewColumn
*column
);
183 virtual void GtkOnCellChanged(const wxVariant
& value
,
184 const wxDataViewItem
& item
,
188 wxDataViewIconText m_value
;
190 // we use the base class m_renderer for the text and this one for the icon
191 GtkCellRenderer
*m_rendererIcon
;
193 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer
)
196 // ---------------------------------------------------------
197 // wxDataViewDateRenderer
198 // ---------------------------------------------------------
200 class WXDLLIMPEXP_ADV wxDataViewDateRenderer
: public wxDataViewCustomRenderer
203 wxDataViewDateRenderer( const wxString
&varianttype
= "datetime",
204 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
205 int align
= wxDVR_DEFAULT_ALIGNMENT
);
207 bool SetValue( const wxVariant
&value
);
208 bool GetValue( wxVariant
&value
) const;
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
,
221 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer
)
224 // -------------------------------------
225 // wxDataViewChoiceRenderer
226 // -------------------------------------
228 class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer
: public wxDataViewCustomRenderer
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;
239 void SetAlignment( int align
);
242 wxArrayString m_choices
;
246 #endif // _WX_GTK_DVRENDERERS_H_