]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/gtk/dataview.h
remove extraneous class scope qualifier
[wxWidgets.git] / include / wx / gtk / dataview.h
... / ...
CommitLineData
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 _WX_GTKDATAVIEWCTRL_H_
11#define _WX_GTKDATAVIEWCTRL_H_
12
13#include "wx/list.h"
14
15// ---------------------------------------------------------
16// classes
17// ---------------------------------------------------------
18
19class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl;
20class WXDLLIMPEXP_FWD_ADV wxDataViewCtrlInternal;
21
22
23// ---------------------------------------------------------
24// wxDataViewRenderer
25// ---------------------------------------------------------
26
27class WXDLLIMPEXP_ADV wxDataViewRenderer: public wxDataViewRendererBase
28{
29public:
30 wxDataViewRenderer( const wxString &varianttype,
31 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
32 int align = wxDVR_DEFAULT_ALIGNMENT );
33
34 virtual void SetMode( wxDataViewCellMode mode );
35 virtual wxDataViewCellMode GetMode() const;
36
37 virtual void SetAlignment( int align );
38 virtual int GetAlignment() const;
39
40 // implementation
41 GtkCellRenderer* GetGtkHandle() { return m_renderer; }
42 void GtkInitHandlers();
43 virtual bool GtkHasAttributes() { return false; }
44 void GtkUpdateAlignment();
45
46protected:
47 GtkCellRenderer *m_renderer;
48 int m_alignment;
49
50protected:
51 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer)
52};
53
54// ---------------------------------------------------------
55// wxDataViewTextRenderer
56// ---------------------------------------------------------
57
58class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer
59{
60public:
61 wxDataViewTextRenderer( const wxString &varianttype = wxT("string"),
62 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
63 int align = wxDVR_DEFAULT_ALIGNMENT );
64
65 bool SetValue( const wxVariant &value );
66 bool GetValue( wxVariant &value ) const;
67
68 void SetAlignment( int align );
69
70protected:
71 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer)
72};
73
74// ---------------------------------------------------------
75// wxDataViewTextRendererAttr
76// ---------------------------------------------------------
77
78class WXDLLIMPEXP_ADV wxDataViewTextRendererAttr: public wxDataViewTextRenderer
79{
80public:
81 wxDataViewTextRendererAttr( const wxString &varianttype = wxT("string"),
82 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
83 int align = wxDVR_DEFAULT_ALIGNMENT );
84
85 // implementation
86 bool GtkHasAttributes() { return true; }
87
88protected:
89 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRendererAttr)
90};
91
92// ---------------------------------------------------------
93// wxDataViewBitmapRenderer
94// ---------------------------------------------------------
95
96class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewRenderer
97{
98public:
99 wxDataViewBitmapRenderer( const wxString &varianttype = wxT("wxBitmap"),
100 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
101 int align = wxDVR_DEFAULT_ALIGNMENT );
102
103 bool SetValue( const wxVariant &value );
104 bool GetValue( wxVariant &value ) const;
105
106protected:
107 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer)
108};
109
110// ---------------------------------------------------------
111// wxDataViewToggleRenderer
112// ---------------------------------------------------------
113
114class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewRenderer
115{
116public:
117 wxDataViewToggleRenderer( const wxString &varianttype = wxT("bool"),
118 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
119 int align = wxDVR_DEFAULT_ALIGNMENT );
120
121 bool SetValue( const wxVariant &value );
122 bool GetValue( wxVariant &value ) const;
123
124protected:
125 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer)
126};
127
128// ---------------------------------------------------------
129// wxDataViewCustomRenderer
130// ---------------------------------------------------------
131
132class WXDLLIMPEXP_ADV wxDataViewCustomRenderer: public wxDataViewRenderer
133{
134public:
135 wxDataViewCustomRenderer( const wxString &varianttype = wxT("string"),
136 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
137 int align = wxDVR_DEFAULT_ALIGNMENT,
138 bool no_init = false );
139 virtual ~wxDataViewCustomRenderer();
140
141
142 virtual bool Render( wxRect cell, wxDC *dc, int state ) = 0;
143
144 void RenderText( const wxString &text, int xoffset, wxRect cell, wxDC *dc, int state );
145
146 virtual wxSize GetSize() const = 0;
147
148 virtual bool Activate( wxRect WXUNUSED(cell),
149 wxDataViewModel *WXUNUSED(model), const wxDataViewItem &WXUNUSED(item), unsigned int WXUNUSED(col) )
150 { return false; }
151
152 virtual bool LeftClick( wxPoint WXUNUSED(cursor), wxRect WXUNUSED(cell),
153 wxDataViewModel *WXUNUSED(model), const wxDataViewItem &WXUNUSED(item), unsigned int WXUNUSED(col) )
154 { return false; }
155 virtual bool StartDrag( wxPoint WXUNUSED(cursor), wxRect WXUNUSED(cell),
156 wxDataViewModel *WXUNUSED(model), const wxDataViewItem &WXUNUSED(item), unsigned int WXUNUSED(col) )
157 { return false; }
158
159 // Create DC on request
160 virtual wxDC *GetDC();
161
162
163protected:
164
165 bool Init(wxDataViewCellMode mode, int align);
166
167private:
168 wxDC *m_dc;
169
170public:
171 // Internal, temporay for RenderText.
172 GtkCellRenderer *m_text_renderer;
173 GdkWindow *window;
174 GtkWidget *widget;
175 void *background_area;
176 void *cell_area;
177 void *expose_area;
178 int flags;
179
180protected:
181 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer)
182};
183
184// ---------------------------------------------------------
185// wxDataViewProgressRenderer
186// ---------------------------------------------------------
187
188class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewCustomRenderer
189{
190public:
191 wxDataViewProgressRenderer( const wxString &label = wxEmptyString,
192 const wxString &varianttype = wxT("long"),
193 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
194 int align = wxDVR_DEFAULT_ALIGNMENT );
195 virtual ~wxDataViewProgressRenderer();
196
197 bool SetValue( const wxVariant &value );
198 bool GetValue( wxVariant &value ) const;
199
200 virtual bool Render( wxRect cell, wxDC *dc, int state );
201 virtual wxSize GetSize() const;
202
203private:
204 wxString m_label;
205 int m_value;
206
207protected:
208 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer)
209};
210
211// ---------------------------------------------------------
212// wxDataViewIconTextRenderer
213// ---------------------------------------------------------
214
215class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewCustomRenderer
216{
217public:
218 wxDataViewIconTextRenderer( const wxString &varianttype = wxT("wxDataViewIconText"),
219 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
220 int align = wxDVR_DEFAULT_ALIGNMENT );
221 virtual ~wxDataViewIconTextRenderer();
222
223 bool SetValue( const wxVariant &value );
224 bool GetValue( wxVariant &value ) const;
225
226 virtual bool Render( wxRect cell, wxDC *dc, int state );
227 virtual wxSize GetSize() const;
228
229 virtual bool HasEditorCtrl() { return true; }
230 virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value );
231 virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value );
232
233private:
234 wxDataViewIconText m_value;
235
236protected:
237 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer)
238};
239
240// ---------------------------------------------------------
241// wxDataViewDateRenderer
242// ---------------------------------------------------------
243
244class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewCustomRenderer
245{
246public:
247 wxDataViewDateRenderer( const wxString &varianttype = wxT("datetime"),
248 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
249 int align = wxDVR_DEFAULT_ALIGNMENT );
250
251 bool SetValue( const wxVariant &value );
252 bool GetValue( wxVariant &value ) const;
253
254 virtual bool Render( wxRect cell, wxDC *dc, int state );
255 virtual wxSize GetSize() const;
256 virtual bool Activate( wxRect cell,
257 wxDataViewModel *model, const wxDataViewItem &item, unsigned int col );
258
259private:
260 wxDateTime m_date;
261
262protected:
263 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer)
264};
265
266// -------------------------------------
267// wxDataViewChoiceRenderer
268// -------------------------------------
269
270class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer: public wxDataViewCustomRenderer
271{
272public:
273 wxDataViewChoiceRenderer( const wxArrayString &choices,
274 wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
275 int alignment = wxDVR_DEFAULT_ALIGNMENT );
276 virtual bool Render( wxRect rect, wxDC *dc, int state );
277 virtual wxSize GetSize() const;
278 virtual bool SetValue( const wxVariant &value );
279 virtual bool GetValue( wxVariant &value ) const;
280
281 void SetAlignment( int align );
282private:
283 wxArrayString m_choices;
284 wxString m_data;
285};
286
287// ---------------------------------------------------------
288// wxDataViewColumn
289// ---------------------------------------------------------
290
291class WXDLLIMPEXP_ADV wxDataViewColumn: public wxDataViewColumnBase
292{
293public:
294 wxDataViewColumn( const wxString &title, wxDataViewRenderer *renderer,
295 unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
296 wxAlignment align = wxALIGN_CENTER,
297 int flags = wxDATAVIEW_COL_RESIZABLE );
298 wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *renderer,
299 unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
300 wxAlignment align = wxALIGN_CENTER,
301 int flags = wxDATAVIEW_COL_RESIZABLE );
302
303 virtual ~wxDataViewColumn();
304
305
306 // setters:
307
308 virtual void SetTitle( const wxString &title );
309 virtual void SetBitmap( const wxBitmap &bitmap );
310
311 virtual void SetOwner( wxDataViewCtrl *owner );
312
313 virtual void SetAlignment( wxAlignment align );
314
315 virtual void SetSortable( bool sortable );
316 virtual void SetSortOrder( bool ascending );
317
318 virtual void SetResizeable( bool resizeable );
319 virtual void SetHidden( bool hidden );
320
321 virtual void SetMinWidth( int minWidth );
322 virtual void SetWidth( int width );
323
324 virtual void SetReorderable( bool reorderable );
325
326 // getters:
327
328 virtual wxString GetTitle() const;
329 virtual wxAlignment GetAlignment() const;
330
331 virtual bool IsSortable() const;
332 virtual bool IsSortOrderAscending() const;
333 virtual bool IsResizeable() const;
334 virtual bool IsHidden() const;
335
336 virtual int GetWidth() const;
337 virtual int GetMinWidth() const;
338
339 virtual bool IsReorderable() const;
340
341 // implementation
342 GtkWidget* GetGtkHandle() { return m_column; }
343 GtkWidget* GetConstGtkHandle() const { return m_column; }
344
345private:
346 // holds the GTK handle
347 GtkWidget *m_column;
348
349 // holds GTK handles for title/bitmap in the header
350 GtkWidget *m_image;
351 GtkWidget *m_label;
352
353 // delayed connection to mouse events
354 friend class wxDataViewCtrl;
355 void OnInternalIdle();
356 bool m_isConnected;
357
358 void Init(wxAlignment align, int flags, int width);
359
360protected:
361 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn)
362};
363
364WX_DECLARE_LIST_WITH_DECL(wxDataViewColumn, wxDataViewColumnList,
365 class WXDLLIMPEXP_ADV);
366
367// ---------------------------------------------------------
368// wxDataViewCtrl
369// ---------------------------------------------------------
370
371class WXDLLIMPEXP_ADV wxDataViewCtrl: public wxDataViewCtrlBase
372{
373public:
374 wxDataViewCtrl()
375 {
376 Init();
377 }
378
379 wxDataViewCtrl( wxWindow *parent, wxWindowID id,
380 const wxPoint& pos = wxDefaultPosition,
381 const wxSize& size = wxDefaultSize, long style = 0,
382 const wxValidator& validator = wxDefaultValidator )
383 {
384 Create(parent, id, pos, size, style, validator );
385 }
386
387 virtual ~wxDataViewCtrl();
388
389 void Init();
390
391 bool Create(wxWindow *parent, wxWindowID id,
392 const wxPoint& pos = wxDefaultPosition,
393 const wxSize& size = wxDefaultSize, long style = 0,
394 const wxValidator& validator = wxDefaultValidator );
395
396 virtual bool AssociateModel( wxDataViewModel *model );
397
398 virtual bool PrependColumn( wxDataViewColumn *col );
399 virtual bool AppendColumn( wxDataViewColumn *col );
400 virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col );
401
402 virtual unsigned int GetColumnCount() const;
403 virtual wxDataViewColumn* GetColumn( unsigned int pos ) const;
404 virtual bool DeleteColumn( wxDataViewColumn *column );
405 virtual bool ClearColumns();
406 virtual int GetColumnPosition( const wxDataViewColumn *column ) const;
407
408 virtual wxDataViewColumn *GetSortingColumn() const;
409
410 virtual wxDataViewItem GetSelection() const;
411 virtual int GetSelections( wxDataViewItemArray & sel ) const;
412 virtual void SetSelections( const wxDataViewItemArray & sel );
413 virtual void Select( const wxDataViewItem & item );
414 virtual void Unselect( const wxDataViewItem & item );
415 virtual bool IsSelected( const wxDataViewItem & item ) const;
416 virtual void SelectAll();
417 virtual void UnselectAll();
418
419 virtual void EnsureVisible( const wxDataViewItem& item,
420 const wxDataViewColumn *column = NULL );
421 virtual void HitTest( const wxPoint &point,
422 wxDataViewItem &item,
423 wxDataViewColumn *&column ) const;
424 virtual wxRect GetItemRect( const wxDataViewItem &item,
425 const wxDataViewColumn *column = NULL ) const;
426
427 virtual void Expand( const wxDataViewItem & item );
428 virtual void Collapse( const wxDataViewItem & item );
429
430 static wxVisualAttributes
431 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
432
433 wxWindow *GetMainWindow() { return (wxWindow*) this; }
434
435 GtkWidget *GtkGetTreeView() { return m_treeview; }
436 wxDataViewCtrlInternal* GtkGetInternal() { return m_internal; }
437
438 virtual void OnInternalIdle();
439
440protected:
441 virtual void DoSetExpanderColumn();
442 virtual void DoSetIndent();
443
444private:
445 friend class wxDataViewCtrlDCImpl;
446 friend class wxDataViewColumn;
447 friend class wxGtkDataViewModelNotifier;
448 friend class wxDataViewCtrlInternal;
449
450 GtkWidget *m_treeview;
451 wxDataViewModelNotifier *m_notifier;
452 wxDataViewCtrlInternal *m_internal;
453 wxDataViewColumnList m_cols;
454
455 virtual void AddChildGTK(wxWindowGTK* child);
456 void GtkEnableSelectionEvents();
457 void GtkDisableSelectionEvents();
458
459 DECLARE_DYNAMIC_CLASS(wxDataViewCtrl)
460 DECLARE_NO_COPY_CLASS(wxDataViewCtrl)
461};
462
463
464#endif // _WX_GTKDATAVIEWCTRL_H_