]>
Commit | Line | Data |
---|---|---|
239eaa41 RR |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/gtk/dataview.h | |
3 | // Purpose: wxDataViewCtrl GTK+2 implementation header | |
4 | // Author: Robert Roebling | |
5 | // Id: $Id$ | |
6 | // Copyright: (c) 1998 Robert Roebling | |
7 | // Licence: wxWindows licence | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | #ifndef __GTKDATAVIEWCTRLH__ | |
11 | #define __GTKDATAVIEWCTRLH__ | |
12 | ||
13 | #include "wx/defs.h" | |
14 | #include "wx/object.h" | |
15 | #include "wx/list.h" | |
16 | #include "wx/control.h" | |
17 | ||
18 | // --------------------------------------------------------- | |
19 | // classes | |
20 | // --------------------------------------------------------- | |
21 | ||
b5dbe15d | 22 | class WXDLLIMPEXP_FWD_CORE wxDataViewCtrl; |
55fbde12 | 23 | class WXDLLIMPEXP_FWD_CORE wxDataViewCtrlInternal; |
239eaa41 | 24 | |
87f0efe2 | 25 | |
6842a71a | 26 | // --------------------------------------------------------- |
baa9ebc4 | 27 | // wxDataViewRenderer |
6842a71a RR |
28 | // --------------------------------------------------------- |
29 | ||
baa9ebc4 | 30 | class wxDataViewRenderer: public wxDataViewRendererBase |
6842a71a RR |
31 | { |
32 | public: | |
87f0efe2 | 33 | wxDataViewRenderer( const wxString &varianttype, |
9861f022 RR |
34 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
35 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
6842a71a RR |
36 | |
37 | // implementation | |
ed38aa55 | 38 | GtkCellRenderer* GetGtkHandle() { return m_renderer; } |
9861f022 RR |
39 | |
40 | virtual void SetMode( wxDataViewCellMode mode ); | |
41 | virtual wxDataViewCellMode GetMode() const; | |
42 | ||
43 | virtual void SetAlignment( int align ); | |
44 | virtual int GetAlignment() const; | |
6842a71a RR |
45 | |
46 | protected: | |
ed38aa55 | 47 | GtkCellRenderer *m_renderer; |
6842a71a RR |
48 | |
49 | protected: | |
baa9ebc4 | 50 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer) |
6842a71a | 51 | }; |
9861f022 | 52 | |
6842a71a | 53 | // --------------------------------------------------------- |
baa9ebc4 | 54 | // wxDataViewTextRenderer |
6842a71a RR |
55 | // --------------------------------------------------------- |
56 | ||
baa9ebc4 | 57 | class wxDataViewTextRenderer: public wxDataViewRenderer |
6842a71a RR |
58 | { |
59 | public: | |
baa9ebc4 | 60 | wxDataViewTextRenderer( const wxString &varianttype = wxT("string"), |
9861f022 RR |
61 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
62 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
6842a71a | 63 | |
7b4fde82 | 64 | bool SetValue( const wxVariant &value ); |
9861f022 RR |
65 | bool GetValue( wxVariant &value ) const; |
66 | ||
67 | void SetAlignment( int align ); | |
68 | ||
6842a71a | 69 | protected: |
baa9ebc4 | 70 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer) |
6842a71a RR |
71 | }; |
72 | ||
cbc9145c | 73 | // --------------------------------------------------------- |
baa9ebc4 | 74 | // wxDataViewBitmapRenderer |
cbc9145c RR |
75 | // --------------------------------------------------------- |
76 | ||
baa9ebc4 | 77 | class wxDataViewBitmapRenderer: public wxDataViewRenderer |
cbc9145c RR |
78 | { |
79 | public: | |
baa9ebc4 | 80 | wxDataViewBitmapRenderer( const wxString &varianttype = wxT("wxBitmap"), |
9861f022 RR |
81 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
82 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
cbc9145c RR |
83 | |
84 | bool SetValue( const wxVariant &value ); | |
9861f022 | 85 | bool GetValue( wxVariant &value ) const; |
cbc9145c RR |
86 | |
87 | protected: | |
baa9ebc4 | 88 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer) |
cbc9145c RR |
89 | }; |
90 | ||
605c2c4a | 91 | // --------------------------------------------------------- |
baa9ebc4 | 92 | // wxDataViewToggleRenderer |
605c2c4a RR |
93 | // --------------------------------------------------------- |
94 | ||
baa9ebc4 | 95 | class wxDataViewToggleRenderer: public wxDataViewRenderer |
605c2c4a RR |
96 | { |
97 | public: | |
baa9ebc4 | 98 | wxDataViewToggleRenderer( const wxString &varianttype = wxT("bool"), |
9861f022 RR |
99 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
100 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
605c2c4a RR |
101 | |
102 | bool SetValue( const wxVariant &value ); | |
9861f022 | 103 | bool GetValue( wxVariant &value ) const; |
605c2c4a RR |
104 | |
105 | protected: | |
baa9ebc4 | 106 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer) |
605c2c4a RR |
107 | }; |
108 | ||
e152afc3 | 109 | // --------------------------------------------------------- |
baa9ebc4 | 110 | // wxDataViewCustomRenderer |
e152afc3 RR |
111 | // --------------------------------------------------------- |
112 | ||
baa9ebc4 | 113 | class wxDataViewCustomRenderer: public wxDataViewRenderer |
e152afc3 RR |
114 | { |
115 | public: | |
baa9ebc4 RR |
116 | wxDataViewCustomRenderer( const wxString &varianttype = wxT("string"), |
117 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
9861f022 | 118 | int align = wxDVR_DEFAULT_ALIGNMENT, |
baa9ebc4 RR |
119 | bool no_init = false ); |
120 | virtual ~wxDataViewCustomRenderer(); | |
9861f022 RR |
121 | |
122 | ||
e152afc3 | 123 | virtual bool Render( wxRect cell, wxDC *dc, int state ) = 0; |
9861f022 RR |
124 | virtual wxSize GetSize() const = 0; |
125 | ||
4d496ecb | 126 | virtual bool Activate( wxRect cell, |
e0062c04 | 127 | wxDataViewModel *model, const wxDataViewItem &item, unsigned int col ) |
4d496ecb | 128 | { return false; } |
9861f022 | 129 | |
4d496ecb | 130 | virtual bool LeftClick( wxPoint cursor, wxRect cell, |
e0062c04 | 131 | wxDataViewModel *model, const wxDataViewItem &item, unsigned int col ) |
4d496ecb RR |
132 | { return false; } |
133 | virtual bool RightClick( wxPoint cursor, wxRect cell, | |
e0062c04 | 134 | wxDataViewModel *model, const wxDataViewItem &item, unsigned int col ) |
4d496ecb RR |
135 | { return false; } |
136 | virtual bool StartDrag( wxPoint cursor, wxRect cell, | |
e0062c04 | 137 | wxDataViewModel *model, const wxDataViewItem &item, unsigned int col ) |
4d496ecb | 138 | { return false; } |
e152afc3 RR |
139 | |
140 | // Create DC on request | |
141 | virtual wxDC *GetDC(); | |
142 | ||
9861f022 RR |
143 | |
144 | protected: | |
145 | ||
146 | bool Init(wxDataViewCellMode mode, int align); | |
147 | ||
e152afc3 RR |
148 | private: |
149 | wxDC *m_dc; | |
150 | ||
151 | protected: | |
baa9ebc4 | 152 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer) |
e152afc3 RR |
153 | }; |
154 | ||
ad63bf41 | 155 | // --------------------------------------------------------- |
baa9ebc4 | 156 | // wxDataViewProgressRenderer |
ad63bf41 RR |
157 | // --------------------------------------------------------- |
158 | ||
baa9ebc4 | 159 | class wxDataViewProgressRenderer: public wxDataViewCustomRenderer |
ad63bf41 RR |
160 | { |
161 | public: | |
baa9ebc4 RR |
162 | wxDataViewProgressRenderer( const wxString &label = wxEmptyString, |
163 | const wxString &varianttype = wxT("long"), | |
9861f022 RR |
164 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
165 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
baa9ebc4 | 166 | virtual ~wxDataViewProgressRenderer(); |
ad63bf41 RR |
167 | |
168 | bool SetValue( const wxVariant &value ); | |
9861f022 | 169 | bool GetValue( wxVariant &value ) const; |
ad63bf41 RR |
170 | |
171 | virtual bool Render( wxRect cell, wxDC *dc, int state ); | |
9861f022 | 172 | virtual wxSize GetSize() const; |
ad63bf41 RR |
173 | |
174 | private: | |
175 | wxString m_label; | |
176 | int m_value; | |
177 | ||
178 | protected: | |
baa9ebc4 | 179 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer) |
ad63bf41 RR |
180 | }; |
181 | ||
4d496ecb | 182 | // --------------------------------------------------------- |
baa9ebc4 | 183 | // wxDataViewDateRenderer |
4d496ecb RR |
184 | // --------------------------------------------------------- |
185 | ||
baa9ebc4 | 186 | class wxDataViewDateRenderer: public wxDataViewCustomRenderer |
4d496ecb RR |
187 | { |
188 | public: | |
baa9ebc4 | 189 | wxDataViewDateRenderer( const wxString &varianttype = wxT("datetime"), |
9861f022 RR |
190 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, |
191 | int align = wxDVR_DEFAULT_ALIGNMENT ); | |
4d496ecb RR |
192 | |
193 | bool SetValue( const wxVariant &value ); | |
9861f022 | 194 | bool GetValue( wxVariant &value ) const; |
4d496ecb RR |
195 | |
196 | virtual bool Render( wxRect cell, wxDC *dc, int state ); | |
9861f022 | 197 | virtual wxSize GetSize() const; |
4d496ecb | 198 | virtual bool Activate( wxRect cell, |
e0062c04 | 199 | wxDataViewModel *model, const wxDataViewItem &item, unsigned int col ); |
4d496ecb RR |
200 | |
201 | private: | |
202 | wxDateTime m_date; | |
203 | ||
204 | protected: | |
baa9ebc4 | 205 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer) |
4d496ecb RR |
206 | }; |
207 | ||
fa28826d RR |
208 | // --------------------------------------------------------- |
209 | // wxDataViewColumn | |
210 | // --------------------------------------------------------- | |
211 | ||
212 | class WXDLLIMPEXP_CORE wxDataViewColumn: public wxDataViewColumnBase | |
213 | { | |
214 | public: | |
87f0efe2 RR |
215 | wxDataViewColumn( const wxString &title, wxDataViewRenderer *renderer, |
216 | unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH, | |
217 | wxAlignment align = wxALIGN_CENTER, | |
218 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
219 | wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *renderer, | |
220 | unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH, | |
221 | wxAlignment align = wxALIGN_CENTER, | |
222 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
223 | ||
fa28826d RR |
224 | virtual ~wxDataViewColumn(); |
225 | ||
9861f022 RR |
226 | |
227 | // setters: | |
228 | ||
fa28826d | 229 | virtual void SetTitle( const wxString &title ); |
07a84e7b | 230 | virtual void SetBitmap( const wxBitmap &bitmap ); |
47cef10f | 231 | |
b94db696 RR |
232 | virtual void SetOwner( wxDataViewCtrl *owner ); |
233 | ||
47cef10f | 234 | virtual void SetAlignment( wxAlignment align ); |
31fb32e1 RR |
235 | |
236 | virtual void SetSortable( bool sortable ); | |
47cef10f RR |
237 | virtual void SetSortOrder( bool ascending ); |
238 | ||
9861f022 RR |
239 | virtual void SetResizeable( bool resizeable ); |
240 | virtual void SetHidden( bool hidden ); | |
241 | ||
242 | virtual void SetMinWidth( int minWidth ); | |
243 | virtual void SetWidth( int width ); | |
244 | ||
245 | ||
246 | // getters: | |
247 | ||
248 | virtual wxString GetTitle() const; | |
249 | virtual wxAlignment GetAlignment() const; | |
250 | ||
87f0efe2 RR |
251 | virtual bool IsSortable() const; |
252 | virtual bool IsSortOrderAscending() const; | |
9861f022 RR |
253 | virtual bool IsResizeable() const; |
254 | virtual bool IsHidden() const; | |
87f0efe2 RR |
255 | |
256 | virtual int GetWidth() const; | |
9861f022 RR |
257 | virtual int GetMinWidth() const; |
258 | ||
fa28826d | 259 | // implementation |
9861f022 | 260 | GtkWidget* GetGtkHandle() { return m_column; } |
fa28826d RR |
261 | |
262 | private: | |
6842a71a | 263 | // holds the GTK handle |
9861f022 | 264 | GtkWidget *m_column; |
31fb32e1 RR |
265 | |
266 | // delayed connection to mouse events | |
267 | friend class wxDataViewCtrl; | |
268 | void OnInternalIdle(); | |
9861f022 RR |
269 | bool m_isConnected; |
270 | ||
271 | void Init(wxAlignment align, int flags, int width); | |
272 | ||
fa28826d RR |
273 | protected: |
274 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn) | |
275 | }; | |
276 | ||
239eaa41 RR |
277 | // --------------------------------------------------------- |
278 | // wxDataViewCtrl | |
279 | // --------------------------------------------------------- | |
280 | ||
281 | class WXDLLIMPEXP_CORE wxDataViewCtrl: public wxDataViewCtrlBase | |
282 | { | |
283 | public: | |
284 | wxDataViewCtrl() | |
285 | { | |
286 | Init(); | |
287 | } | |
288 | ||
289 | wxDataViewCtrl( wxWindow *parent, wxWindowID id, | |
290 | const wxPoint& pos = wxDefaultPosition, | |
291 | const wxSize& size = wxDefaultSize, long style = 0, | |
292 | const wxValidator& validator = wxDefaultValidator ) | |
293 | { | |
294 | Create(parent, id, pos, size, style, validator ); | |
295 | } | |
296 | ||
297 | virtual ~wxDataViewCtrl(); | |
298 | ||
299 | void Init(); | |
300 | ||
301 | bool Create(wxWindow *parent, wxWindowID id, | |
302 | const wxPoint& pos = wxDefaultPosition, | |
303 | const wxSize& size = wxDefaultSize, long style = 0, | |
304 | const wxValidator& validator = wxDefaultValidator ); | |
305 | ||
e0062c04 | 306 | virtual bool AssociateModel( wxDataViewModel *model ); |
1a367564 | 307 | virtual bool AppendColumn( wxDataViewColumn *col ); |
1e08ad10 | 308 | |
55fbde12 | 309 | // selection code |
1e08ad10 | 310 | virtual wxDataViewItem GetSelection(); |
1a367564 | 311 | |
b94db696 RR |
312 | |
313 | static wxVisualAttributes | |
314 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
6ff7eee7 | 315 | |
1e510b1e | 316 | wxWindow *GetMainWindow() { return (wxWindow*) this; } |
55fbde12 RR |
317 | |
318 | GtkWidget *GtkGetTreeView() { return m_treeview; } | |
319 | wxDataViewCtrlInternal* GtkGetInternal() { return m_internal; } | |
3b6280be RR |
320 | |
321 | protected: | |
322 | virtual void DoSetExpanderColumn(); | |
323 | virtual void DoSetIndent(); | |
324 | ||
1a367564 RR |
325 | private: |
326 | friend class wxDataViewCtrlDC; | |
31fb32e1 | 327 | friend class wxDataViewColumn; |
e0062c04 RR |
328 | friend class wxGtkDataViewModelNotifier; |
329 | GtkWidget *m_treeview; | |
330 | wxDataViewModelNotifier *m_notifier; | |
55fbde12 | 331 | wxDataViewCtrlInternal *m_internal; |
3b6280be | 332 | |
239eaa41 | 333 | |
31fb32e1 RR |
334 | virtual void OnInternalIdle(); |
335 | ||
b086d55f RR |
336 | void GtkEnableSelectionEvents(); |
337 | void GtkDisableSelectionEvents(); | |
338 | ||
239eaa41 RR |
339 | private: |
340 | DECLARE_DYNAMIC_CLASS(wxDataViewCtrl) | |
341 | DECLARE_NO_COPY_CLASS(wxDataViewCtrl) | |
342 | }; | |
343 | ||
344 | ||
345 | #endif // __GTKDATAVIEWCTRLH__ |