]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/dvrenderers.h
Add wxTransparentColour global pseudo-variable.
[wxWidgets.git] / include / wx / gtk / dvrenderers.h
CommitLineData
6eec70b9
VZ
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
70884c6f
VZ
15typedef struct _GdkRectangle GdkRectangle;
16
6eec70b9
VZ
17// ---------------------------------------------------------
18// wxDataViewTextRenderer
19// ---------------------------------------------------------
20
21class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer
22{
23public:
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
c2a738e3 46 virtual bool GtkSupportsAttrs() const { return true; }
c80cde00 47 virtual bool GtkSetAttr(const wxDataViewItemAttr& attr);
c2a738e3 48
17cbc244
VZ
49 virtual GtkCellRendererText *GtkGetTextRenderer() const;
50
6eec70b9
VZ
51protected:
52 // implementation of Set/GetValue()
53 bool SetTextValue(const wxString& str);
54 bool GetTextValue(wxString& str) const;
55
56
57 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer)
58};
59
60// ---------------------------------------------------------
61// wxDataViewBitmapRenderer
62// ---------------------------------------------------------
63
64class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewRenderer
65{
66public:
67 wxDataViewBitmapRenderer( const wxString &varianttype = "wxBitmap",
68 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
69 int align = wxDVR_DEFAULT_ALIGNMENT );
70
71 bool SetValue( const wxVariant &value );
72 bool GetValue( wxVariant &value ) const;
73
74protected:
75 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer)
76};
77
78// ---------------------------------------------------------
79// wxDataViewToggleRenderer
80// ---------------------------------------------------------
81
82class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewRenderer
83{
84public:
85 wxDataViewToggleRenderer( const wxString &varianttype = "bool",
86 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
87 int align = wxDVR_DEFAULT_ALIGNMENT );
88
89 bool SetValue( const wxVariant &value );
90 bool GetValue( wxVariant &value ) const;
91
92protected:
93 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer)
94};
95
96// ---------------------------------------------------------
97// wxDataViewCustomRenderer
98// ---------------------------------------------------------
99
100class WXDLLIMPEXP_ADV wxDataViewCustomRenderer: public wxDataViewCustomRendererBase
101{
102public:
103 wxDataViewCustomRenderer( const wxString &varianttype = "string",
104 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
105 int align = wxDVR_DEFAULT_ALIGNMENT,
106 bool no_init = false );
107 virtual ~wxDataViewCustomRenderer();
108
109
6eec70b9
VZ
110 // Create DC on request
111 virtual wxDC *GetDC();
112
62265c2c
VZ
113 // override the base class function to use GTK text cell renderer
114 virtual void RenderText(const wxString& text,
115 int xoffset,
116 wxRect cell,
117 wxDC *dc,
118 int state);
6eec70b9 119
2a454ffd
VZ
120 // store GTK render call parameters for possible later use
121 void GTKStashRenderParams(GdkWindow *window,
122 GtkWidget *widget,
123 GdkRectangle *background_area,
124 GdkRectangle *expose_area,
125 int flags)
126 {
127 m_renderParams.window = window;
128 m_renderParams.widget = widget;
129 m_renderParams.background_area = background_area;
130 m_renderParams.expose_area = expose_area;
131 m_renderParams.flags = flags;
132 }
6eec70b9 133
c80cde00
VZ
134 // we may or not support attributes, as we don't know it, return true to
135 // make it possible to use them
136 virtual bool GtkSupportsAttrs() const { return true; }
137
138 virtual bool GtkSetAttr(const wxDataViewItemAttr& attr)
139 {
140 SetAttr(attr);
141 return !attr.IsDefault();
142 }
143
17cbc244
VZ
144 virtual GtkCellRendererText *GtkGetTextRenderer() const;
145
2a454ffd 146protected:
6eec70b9
VZ
147 bool Init(wxDataViewCellMode mode, int align);
148
149private:
150 wxDC *m_dc;
151
c80cde00 152 GtkCellRendererText *m_text_renderer;
6eec70b9 153
2a454ffd
VZ
154 // parameters of the original render() call stored so that we could pass
155 // them forward to m_text_renderer if our RenderText() is called
156 struct GTKRenderParams
157 {
158 GdkWindow *window;
159 GtkWidget *widget;
160 GdkRectangle *background_area;
161 GdkRectangle *expose_area;
162 int flags;
163 } m_renderParams;
164
6eec70b9
VZ
165 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer)
166};
167
168// ---------------------------------------------------------
169// wxDataViewProgressRenderer
170// ---------------------------------------------------------
171
172class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewCustomRenderer
173{
174public:
175 wxDataViewProgressRenderer( const wxString &label = wxEmptyString,
176 const wxString &varianttype = "long",
177 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
178 int align = wxDVR_DEFAULT_ALIGNMENT );
179 virtual ~wxDataViewProgressRenderer();
180
181 bool SetValue( const wxVariant &value );
182 bool GetValue( wxVariant &value ) const;
183
184 virtual bool Render( wxRect cell, wxDC *dc, int state );
185 virtual wxSize GetSize() const;
186
187private:
188 wxString m_label;
189 int m_value;
190
191protected:
192 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer)
193};
194
195// ---------------------------------------------------------
196// wxDataViewIconTextRenderer
197// ---------------------------------------------------------
198
199class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewTextRenderer
200{
201public:
202 wxDataViewIconTextRenderer( const wxString &varianttype = "wxDataViewIconText",
203 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
204 int align = wxDVR_DEFAULT_ALIGNMENT );
205 virtual ~wxDataViewIconTextRenderer();
206
207 bool SetValue( const wxVariant &value );
208 bool GetValue( wxVariant &value ) const;
209
210 virtual void GtkPackIntoColumn(GtkTreeViewColumn *column);
211
212protected:
213 virtual void GtkOnCellChanged(const wxVariant& value,
214 const wxDataViewItem& item,
215 unsigned col);
216
217private:
218 wxDataViewIconText m_value;
219
220 // we use the base class m_renderer for the text and this one for the icon
221 GtkCellRenderer *m_rendererIcon;
222
223 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer)
224};
225
226// ---------------------------------------------------------
227// wxDataViewDateRenderer
228// ---------------------------------------------------------
229
230class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewCustomRenderer
231{
232public:
233 wxDataViewDateRenderer( const wxString &varianttype = "datetime",
234 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
235 int align = wxDVR_DEFAULT_ALIGNMENT );
236
237 bool SetValue( const wxVariant &value );
238 bool GetValue( wxVariant &value ) const;
239
240 virtual bool Render( wxRect cell, wxDC *dc, int state );
241 virtual wxSize GetSize() const;
242 virtual bool Activate( wxRect cell,
243 wxDataViewModel *model,
244 const wxDataViewItem &item,
245 unsigned int col );
246
247private:
248 wxDateTime m_date;
249
250protected:
251 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer)
252};
253
254// -------------------------------------
255// wxDataViewChoiceRenderer
256// -------------------------------------
257
258class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer: public wxDataViewCustomRenderer
259{
260public:
261 wxDataViewChoiceRenderer(const wxArrayString &choices,
262 wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
263 int alignment = wxDVR_DEFAULT_ALIGNMENT );
264 virtual bool Render( wxRect rect, wxDC *dc, int state );
265 virtual wxSize GetSize() const;
266 virtual bool SetValue( const wxVariant &value );
267 virtual bool GetValue( wxVariant &value ) const;
268
269 void SetAlignment( int align );
270
271private:
272 wxArrayString m_choices;
273 wxString m_data;
274};
275
276#endif // _WX_GTK_DVRENDERERS_H_
277