]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/dvrenderers.h
Implement support for wxRIBBON_PANEL_EXT_BUTTON wxRibbonPanel style.
[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)
b1153ed6 6// RCS-ID: $Id$
6eec70b9
VZ
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
02800dde
PC
120 struct GTKRenderParams;
121
2a454ffd 122 // store GTK render call parameters for possible later use
02800dde 123 void GTKSetRenderParams(GTKRenderParams* renderParams)
2a454ffd 124 {
02800dde 125 m_renderParams = renderParams;
2a454ffd 126 }
6eec70b9 127
c80cde00
VZ
128 // we may or not support attributes, as we don't know it, return true to
129 // make it possible to use them
130 virtual bool GtkSupportsAttrs() const { return true; }
131
132 virtual bool GtkSetAttr(const wxDataViewItemAttr& attr)
133 {
134 SetAttr(attr);
135 return !attr.IsDefault();
136 }
137
17cbc244
VZ
138 virtual GtkCellRendererText *GtkGetTextRenderer() const;
139
2a454ffd 140protected:
6eec70b9
VZ
141 bool Init(wxDataViewCellMode mode, int align);
142
143private:
3e81bbbf
VZ
144 // Called from GtkGetTextRenderer() to really create the renderer if
145 // necessary.
146 void GtkInitTextRenderer();
147
6eec70b9
VZ
148 wxDC *m_dc;
149
c80cde00 150 GtkCellRendererText *m_text_renderer;
6eec70b9 151
2a454ffd
VZ
152 // parameters of the original render() call stored so that we could pass
153 // them forward to m_text_renderer if our RenderText() is called
02800dde 154 GTKRenderParams* m_renderParams;
2a454ffd 155
6eec70b9
VZ
156 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer)
157};
158
159// ---------------------------------------------------------
160// wxDataViewProgressRenderer
161// ---------------------------------------------------------
162
163class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewCustomRenderer
164{
165public:
166 wxDataViewProgressRenderer( const wxString &label = wxEmptyString,
167 const wxString &varianttype = "long",
168 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
169 int align = wxDVR_DEFAULT_ALIGNMENT );
170 virtual ~wxDataViewProgressRenderer();
171
172 bool SetValue( const wxVariant &value );
173 bool GetValue( wxVariant &value ) const;
174
175 virtual bool Render( wxRect cell, wxDC *dc, int state );
176 virtual wxSize GetSize() const;
177
178private:
fdd67a6a
VZ
179 void GTKSetLabel();
180
6eec70b9
VZ
181 wxString m_label;
182 int m_value;
183
fdd67a6a
VZ
184#if !wxUSE_UNICODE
185 // Flag used to indicate that we need to set the label because we were
186 // unable to do it in the ctor (see comments there).
187 bool m_needsToSetLabel;
188#endif // !wxUSE_UNICODE
189
6eec70b9
VZ
190protected:
191 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer)
192};
193
194// ---------------------------------------------------------
195// wxDataViewIconTextRenderer
196// ---------------------------------------------------------
197
198class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewTextRenderer
199{
200public:
201 wxDataViewIconTextRenderer( const wxString &varianttype = "wxDataViewIconText",
202 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
203 int align = wxDVR_DEFAULT_ALIGNMENT );
204 virtual ~wxDataViewIconTextRenderer();
205
206 bool SetValue( const wxVariant &value );
207 bool GetValue( wxVariant &value ) const;
208
209 virtual void GtkPackIntoColumn(GtkTreeViewColumn *column);
210
211protected:
212 virtual void GtkOnCellChanged(const wxVariant& value,
213 const wxDataViewItem& item,
214 unsigned col);
215
216private:
217 wxDataViewIconText m_value;
218
219 // we use the base class m_renderer for the text and this one for the icon
220 GtkCellRenderer *m_rendererIcon;
221
222 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer)
223};
224
6eec70b9
VZ
225// -------------------------------------
226// wxDataViewChoiceRenderer
227// -------------------------------------
228
229class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer: public wxDataViewCustomRenderer
230{
231public:
232 wxDataViewChoiceRenderer(const wxArrayString &choices,
233 wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
234 int alignment = wxDVR_DEFAULT_ALIGNMENT );
235 virtual bool Render( wxRect rect, wxDC *dc, int state );
236 virtual wxSize GetSize() const;
237 virtual bool SetValue( const wxVariant &value );
238 virtual bool GetValue( wxVariant &value ) const;
239
240 void SetAlignment( int align );
241
f4fcd648
RR
242 wxString GetChoice(size_t index) const { return m_choices[index]; }
243 const wxArrayString& GetChoices() const { return m_choices; }
244
6eec70b9
VZ
245private:
246 wxArrayString m_choices;
247 wxString m_data;
248};
249
65887bd0
RR
250// ----------------------------------------------------------------------------
251// wxDataViewChoiceByIndexRenderer
252// ----------------------------------------------------------------------------
253
254class WXDLLIMPEXP_ADV wxDataViewChoiceByIndexRenderer: public wxDataViewChoiceRenderer
255{
256public:
257 wxDataViewChoiceByIndexRenderer( const wxArrayString &choices,
258 wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
259 int alignment = wxDVR_DEFAULT_ALIGNMENT );
ce00f59b 260
65887bd0
RR
261 virtual bool SetValue( const wxVariant &value );
262 virtual bool GetValue( wxVariant &value ) const;
ce00f59b 263
65887bd0 264private:
29e461a2 265 virtual void GtkOnTextEdited(const char *itempath, const wxString& str);
65887bd0
RR
266};
267
268
269
6eec70b9
VZ
270#endif // _WX_GTK_DVRENDERERS_H_
271