]> git.saurik.com Git - wxWidgets.git/blob - include/wx/dataview.h
only declare AddProcessCallback for wxMotif and wxGTK
[wxWidgets.git] / include / wx / dataview.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/dataview.h
3 // Purpose: wxDataViewCtrl base classes
4 // Author: Robert Roebling
5 // Modified by: Bo Yang
6 // Created: 08.01.06
7 // RCS-ID: $Id$
8 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_DATAVIEW_H_BASE_
13 #define _WX_DATAVIEW_H_BASE_
14
15 #include "wx/defs.h"
16
17 #if wxUSE_DATAVIEWCTRL
18
19 #include "wx/control.h"
20 #include "wx/textctrl.h"
21 #include "wx/bitmap.h"
22 #include "wx/variant.h"
23 #include "wx/dynarray.h"
24 #include "wx/icon.h"
25 #include "wx/imaglist.h"
26
27 class WXDLLIMPEXP_FWD_CORE wxDataFormat;
28
29 #if defined(__WXGTK20__)
30 // for testing
31 // #define wxUSE_GENERICDATAVIEWCTRL 1
32 #elif defined(__WXMAC__)
33 #else
34 #define wxUSE_GENERICDATAVIEWCTRL 1
35 #endif
36
37 // ----------------------------------------------------------------------------
38 // wxDataViewCtrl flags
39 // ----------------------------------------------------------------------------
40
41 // ----------------------------------------------------------------------------
42 // wxDataViewCtrl globals
43 // ----------------------------------------------------------------------------
44
45 class WXDLLIMPEXP_FWD_ADV wxDataViewItem;
46 class WXDLLIMPEXP_FWD_ADV wxDataViewModel;
47 class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl;
48 class WXDLLIMPEXP_FWD_ADV wxDataViewColumn;
49 class WXDLLIMPEXP_FWD_ADV wxDataViewRenderer;
50 class WXDLLIMPEXP_FWD_ADV wxDataViewModelNotifier;
51
52 extern WXDLLIMPEXP_DATA_ADV(const wxChar) wxDataViewCtrlNameStr[];
53
54 // the default width of new (text) columns:
55 #define wxDVC_DEFAULT_WIDTH 80
56
57 // the default width of new toggle columns:
58 #define wxDVC_TOGGLE_DEFAULT_WIDTH 30
59
60 // the default minimal width of the columns:
61 #define wxDVC_DEFAULT_MINWIDTH 30
62
63 // The default alignment of wxDataViewRenderers is to take
64 // the alignment from the column it owns.
65 #define wxDVR_DEFAULT_ALIGNMENT -1
66
67
68 // ---------------------------------------------------------
69 // wxDataViewItem
70 // ---------------------------------------------------------
71
72 class WXDLLIMPEXP_ADV wxDataViewItem
73 {
74 public:
75 wxDataViewItem( void* id = NULL )
76 { m_id = id; }
77 wxDataViewItem( const wxDataViewItem &item )
78 { m_id = item.m_id; }
79 bool IsOk() const { return m_id != NULL; }
80 void* GetID() const { return m_id; }
81 operator const void* () const { return m_id; }
82
83 #ifdef __WXDEBUG__
84 void Print( const wxString &text ) const;
85 #endif
86
87 private:
88 void* m_id;
89 };
90
91 bool operator == (const wxDataViewItem &left, const wxDataViewItem &right);
92
93 WX_DEFINE_ARRAY(wxDataViewItem, wxDataViewItemArray);
94
95 // ---------------------------------------------------------
96 // wxDataViewModelNotifier
97 // ---------------------------------------------------------
98
99 class WXDLLIMPEXP_ADV wxDataViewModelNotifier
100 {
101 public:
102 wxDataViewModelNotifier() { m_owner = NULL; }
103 virtual ~wxDataViewModelNotifier() { m_owner = NULL; }
104
105 virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ) = 0;
106 virtual bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item ) = 0;
107 virtual bool ItemChanged( const wxDataViewItem &item ) = 0;
108 virtual bool ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items );
109 virtual bool ItemsDeleted( const wxDataViewItem &parent, const wxDataViewItemArray &items );
110 virtual bool ItemsChanged( const wxDataViewItemArray &items );
111 virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col ) = 0;
112 virtual bool Cleared() = 0;
113
114 virtual void Resort() = 0;
115
116 void SetOwner( wxDataViewModel *owner ) { m_owner = owner; }
117 wxDataViewModel *GetOwner() const { return m_owner; }
118
119 private:
120 wxDataViewModel *m_owner;
121 };
122
123
124
125 // ----------------------------------------------------------------------------
126 // wxDataViewItemAttr: a structure containing the visual attributes of an item
127 // ----------------------------------------------------------------------------
128
129 // TODO: this should be renamed to wxItemAttr or something general like this
130
131 class WXDLLIMPEXP_ADV wxDataViewItemAttr
132 {
133 public:
134 // ctors
135 wxDataViewItemAttr()
136 {
137 m_bold = false;
138 m_italic = false;
139 }
140
141 // setters
142 void SetColour(const wxColour& colour) { m_colour = colour; }
143 void SetBold( bool set ) { m_bold = set; }
144 void SetItalic( bool set ) { m_italic = set; }
145
146 // accessors
147 bool HasColour() const { return m_colour.Ok(); }
148 const wxColour& GetColour() const { return m_colour; }
149
150 bool GetBold() const { return m_bold; }
151 bool GetItalic() const { return m_italic; }
152
153 private:
154 wxColour m_colour;
155 bool m_bold;
156 bool m_italic;
157 };
158
159
160 // ---------------------------------------------------------
161 // wxDataViewModel
162 // ---------------------------------------------------------
163
164 WX_DECLARE_LIST_WITH_DECL(wxDataViewModelNotifier, wxDataViewModelNotifiers,
165 class WXDLLIMPEXP_ADV);
166
167 class WXDLLIMPEXP_ADV wxDataViewModel: public wxObjectRefData
168 {
169 public:
170 wxDataViewModel();
171
172 virtual unsigned int GetColumnCount() const = 0;
173
174 // return type as reported by wxVariant
175 virtual wxString GetColumnType( unsigned int col ) const = 0;
176
177 // get value into a wxVariant
178 virtual void GetValue( wxVariant &variant,
179 const wxDataViewItem &item, unsigned int col ) const = 0;
180
181 // set value, call ValueChanged() afterwards!
182 virtual bool SetValue( const wxVariant &variant,
183 const wxDataViewItem &item, unsigned int col ) = 0;
184
185 // Get text attribute, return false of default attributes should be used
186 virtual bool GetAttr( const wxDataViewItem &WXUNUSED(item), unsigned int WXUNUSED(col), wxDataViewItemAttr &WXUNUSED(attr) )
187 { return false; }
188
189 // define hierachy
190 virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const = 0;
191 virtual bool IsContainer( const wxDataViewItem &item ) const = 0;
192 // Is the container just a header or an item with all columns
193 virtual bool HasContainerColumns(const wxDataViewItem& WXUNUSED(item)) const
194 { return false; }
195 virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const = 0;
196
197 // define DnD capabilities
198 virtual bool IsDraggable( const wxDataViewItem &WXUNUSED(item) )
199 { return false; }
200 virtual size_t GetDragDataSize( const wxDataViewItem &WXUNUSED(item), const wxDataFormat &WXUNUSED(format) )
201 { return 0; }
202 virtual bool GetDragData( const wxDataViewItem &WXUNUSED(item), const wxDataFormat &WXUNUSED(format),
203 void* WXUNUSED(data), size_t WXUNUSED(size) )
204 { return FALSE; }
205
206 // delegated notifiers
207 virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item );
208 virtual bool ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items );
209 virtual bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item );
210 virtual bool ItemsDeleted( const wxDataViewItem &parent, const wxDataViewItemArray &items );
211 virtual bool ItemChanged( const wxDataViewItem &item );
212 virtual bool ItemsChanged( const wxDataViewItemArray &items );
213 virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col );
214 virtual bool Cleared();
215
216 // delegatd action
217 virtual void Resort();
218
219 void AddNotifier( wxDataViewModelNotifier *notifier );
220 void RemoveNotifier( wxDataViewModelNotifier *notifier );
221
222 // default compare function
223 virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
224 unsigned int column, bool ascending );
225 virtual bool HasDefaultCompare() const { return false; }
226
227 // internal
228 virtual bool IsVirtualListModel() const { return false; }
229
230 protected:
231 // the user should not delete this class directly: he should use DecRef() instead!
232 virtual ~wxDataViewModel() { }
233
234 wxDataViewModelNotifiers m_notifiers;
235 };
236
237 // ---------------------------------------------------------
238 // wxDataViewIndexListModel
239 // ---------------------------------------------------------
240
241 class WXDLLIMPEXP_ADV wxDataViewIndexListModel: public wxDataViewModel
242 {
243 public:
244 wxDataViewIndexListModel( unsigned int initial_size = 0 );
245 ~wxDataViewIndexListModel();
246
247 virtual void GetValue( wxVariant &variant,
248 unsigned int row, unsigned int col ) const = 0;
249
250 virtual bool SetValue( const wxVariant &variant,
251 unsigned int row, unsigned int col ) = 0;
252
253 virtual bool GetAttr( unsigned int WXUNUSED(row), unsigned int WXUNUSED(col), wxDataViewItemAttr &WXUNUSED(attr) )
254 { return false; }
255
256 void RowPrepended();
257 void RowInserted( unsigned int before );
258 void RowAppended();
259 void RowDeleted( unsigned int row );
260 void RowsDeleted( const wxArrayInt &rows );
261 void RowChanged( unsigned int row );
262 void RowValueChanged( unsigned int row, unsigned int col );
263 void Reset( unsigned int new_size );
264
265 // convert to/from row/wxDataViewItem
266
267 unsigned int GetRow( const wxDataViewItem &item ) const;
268 wxDataViewItem GetItem( unsigned int row ) const;
269
270 // compare based on index
271
272 virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
273 unsigned int column, bool ascending );
274 virtual bool HasDefaultCompare() const;
275
276 // implement base methods
277
278 virtual void GetValue( wxVariant &variant,
279 const wxDataViewItem &item, unsigned int col ) const;
280 virtual bool SetValue( const wxVariant &variant,
281 const wxDataViewItem &item, unsigned int col );
282 virtual bool GetAttr( const wxDataViewItem &item, unsigned int col, wxDataViewItemAttr &attr );
283 virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const;
284 virtual bool IsContainer( const wxDataViewItem &item ) const;
285 virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const;
286
287 // internal
288 virtual bool IsVirtualListModel() const { return false; }
289 unsigned int GetLastIndex() const { return m_lastIndex; }
290
291 private:
292 wxDataViewItemArray m_hash;
293 unsigned int m_lastIndex;
294 bool m_ordered;
295 bool m_useHash;
296 };
297
298 // ---------------------------------------------------------
299 // wxDataViewVirtualListModel
300 // ---------------------------------------------------------
301
302 #ifdef __WXMAC__
303 // better than nothing
304 typedef wxDataViewIndexListModel wxDataViewVirtualListModel;
305 #else
306
307 class WXDLLIMPEXP_ADV wxDataViewVirtualListModel: public wxDataViewModel
308 {
309 public:
310 wxDataViewVirtualListModel( unsigned int initial_size = 0 );
311 ~wxDataViewVirtualListModel();
312
313 virtual void GetValue( wxVariant &variant,
314 unsigned int row, unsigned int col ) const = 0;
315
316 virtual bool SetValue( const wxVariant &variant,
317 unsigned int row, unsigned int col ) = 0;
318
319 virtual bool GetAttr( unsigned int WXUNUSED(row), unsigned int WXUNUSED(col), wxDataViewItemAttr &WXUNUSED(attr) )
320 { return false; }
321
322 void RowPrepended();
323 void RowInserted( unsigned int before );
324 void RowAppended();
325 void RowDeleted( unsigned int row );
326 void RowsDeleted( const wxArrayInt &rows );
327 void RowChanged( unsigned int row );
328 void RowValueChanged( unsigned int row, unsigned int col );
329 void Reset( unsigned int new_size );
330
331 // convert to/from row/wxDataViewItem
332
333 unsigned int GetRow( const wxDataViewItem &item ) const;
334 wxDataViewItem GetItem( unsigned int row ) const;
335
336 // compare based on index
337
338 virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
339 unsigned int column, bool ascending );
340 virtual bool HasDefaultCompare() const;
341
342 // implement base methods
343
344 virtual void GetValue( wxVariant &variant,
345 const wxDataViewItem &item, unsigned int col ) const;
346 virtual bool SetValue( const wxVariant &variant,
347 const wxDataViewItem &item, unsigned int col );
348 virtual bool GetAttr( const wxDataViewItem &item, unsigned int col, wxDataViewItemAttr &attr );
349 virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const;
350 virtual bool IsContainer( const wxDataViewItem &item ) const;
351 virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const;
352
353 // internal
354 virtual bool IsVirtualListModel() const { return true; }
355 unsigned int GetLastIndex() const { return m_lastIndex; }
356
357 private:
358 wxDataViewItemArray m_hash;
359 unsigned int m_lastIndex;
360 bool m_ordered;
361 };
362 #endif
363
364 //-----------------------------------------------------------------------------
365 // wxDataViewEditorCtrlEvtHandler
366 //-----------------------------------------------------------------------------
367
368 class wxDataViewEditorCtrlEvtHandler: public wxEvtHandler
369 {
370 public:
371 wxDataViewEditorCtrlEvtHandler( wxControl *editor, wxDataViewRenderer *owner );
372
373 void AcceptChangesAndFinish();
374 void SetFocusOnIdle( bool focus = true ) { m_focusOnIdle = focus; }
375
376 protected:
377 void OnChar( wxKeyEvent &event );
378 void OnKillFocus( wxFocusEvent &event );
379 void OnIdle( wxIdleEvent &event );
380
381 private:
382 wxDataViewRenderer *m_owner;
383 wxControl *m_editorCtrl;
384 bool m_finished;
385 bool m_focusOnIdle;
386
387 private:
388 DECLARE_EVENT_TABLE()
389 };
390
391 // ---------------------------------------------------------
392 // wxDataViewRendererBase
393 // ---------------------------------------------------------
394
395 enum wxDataViewCellMode
396 {
397 wxDATAVIEW_CELL_INERT,
398 wxDATAVIEW_CELL_ACTIVATABLE,
399 wxDATAVIEW_CELL_EDITABLE
400 };
401
402 enum wxDataViewCellRenderState
403 {
404 wxDATAVIEW_CELL_SELECTED = 1,
405 wxDATAVIEW_CELL_PRELIT = 2,
406 wxDATAVIEW_CELL_INSENSITIVE = 4,
407 wxDATAVIEW_CELL_FOCUSED = 8
408 };
409
410 class WXDLLIMPEXP_ADV wxDataViewRendererBase: public wxObject
411 {
412 public:
413 wxDataViewRendererBase( const wxString &varianttype,
414 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
415 int alignment = wxDVR_DEFAULT_ALIGNMENT );
416
417 virtual bool Validate( wxVariant& WXUNUSED(value) )
418 { return true; }
419
420 void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; }
421 wxDataViewColumn* GetOwner() const { return m_owner; }
422
423 // renderer properties:
424
425 virtual bool SetValue( const wxVariant& WXUNUSED(value) ) = 0;
426 virtual bool GetValue( wxVariant& WXUNUSED(value) ) const = 0;
427
428 wxString GetVariantType() const { return m_variantType; }
429
430 virtual void SetMode( wxDataViewCellMode mode ) = 0;
431 virtual wxDataViewCellMode GetMode() const = 0;
432
433 // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but
434 // rather an "int"; that's because for rendering cells it's allowed
435 // to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM)
436 virtual void SetAlignment( int align ) = 0;
437 virtual int GetAlignment() const = 0;
438
439 // in-place editing
440 virtual bool HasEditorCtrl()
441 { return false; }
442 virtual wxControl* CreateEditorCtrl(wxWindow * WXUNUSED(parent),
443 wxRect WXUNUSED(labelRect),
444 const wxVariant& WXUNUSED(value))
445 { return NULL; }
446 virtual bool GetValueFromEditorCtrl(wxControl * WXUNUSED(editor),
447 wxVariant& WXUNUSED(value))
448 { return false; }
449
450 virtual bool StartEditing( const wxDataViewItem &item, wxRect labelRect );
451 virtual void CancelEditing();
452 virtual bool FinishEditing();
453
454 wxControl *GetEditorCtrl() { return m_editorCtrl; }
455
456 protected:
457 wxString m_variantType;
458 wxDataViewColumn *m_owner;
459 wxControl *m_editorCtrl;
460 wxDataViewItem m_item; // for m_editorCtrl
461
462 // internal utility:
463 const wxDataViewCtrl* GetView() const;
464
465 protected:
466 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase)
467 };
468
469 //-----------------------------------------------------------------------------
470 // wxDataViewIconText
471 //-----------------------------------------------------------------------------
472
473 class WXDLLIMPEXP_ADV wxDataViewIconText: public wxObject
474 {
475 public:
476 wxDataViewIconText( const wxString &text = wxEmptyString, const wxIcon& icon = wxNullIcon )
477 : m_text(text), m_icon(icon)
478 { }
479 wxDataViewIconText( const wxDataViewIconText &other )
480 { m_icon = other.m_icon; m_text = other.m_text; }
481
482 void SetText( const wxString &text ) { m_text = text; }
483 wxString GetText() const { return m_text; }
484 void SetIcon( const wxIcon &icon ) { m_icon = icon; }
485 const wxIcon &GetIcon() const { return m_icon; }
486
487 private:
488 wxString m_text;
489 wxIcon m_icon;
490
491 private:
492 DECLARE_DYNAMIC_CLASS(wxDataViewIconText)
493 };
494
495 bool operator == (const wxDataViewIconText &one, const wxDataViewIconText &two);
496
497 DECLARE_VARIANT_OBJECT_EXPORTED(wxDataViewIconText, WXDLLIMPEXP_ADV)
498
499 // ---------------------------------------------------------
500 // wxDataViewColumnBase
501 // ---------------------------------------------------------
502
503 enum wxDataViewColumnFlags
504 {
505 wxDATAVIEW_COL_RESIZABLE = 1,
506 wxDATAVIEW_COL_SORTABLE = 2,
507 wxDATAVIEW_COL_REORDERABLE = 4,
508 wxDATAVIEW_COL_HIDDEN = 8
509 };
510
511 class WXDLLIMPEXP_ADV wxDataViewColumnBase: public wxObject
512 {
513 public:
514 wxDataViewColumnBase( const wxString &title, wxDataViewRenderer *renderer,
515 unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
516 wxAlignment align = wxALIGN_CENTER,
517 int flags = wxDATAVIEW_COL_RESIZABLE );
518 wxDataViewColumnBase( const wxBitmap &bitmap, wxDataViewRenderer *renderer,
519 unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
520 wxAlignment align = wxALIGN_CENTER,
521 int flags = wxDATAVIEW_COL_RESIZABLE );
522 virtual ~wxDataViewColumnBase();
523
524 // setters:
525
526 virtual void SetTitle( const wxString &title ) = 0;
527 virtual void SetAlignment( wxAlignment align ) = 0;
528 virtual void SetSortable( bool sortable ) = 0;
529 virtual void SetReorderable(bool reorderable) = 0;
530 virtual void SetResizeable( bool resizeable ) = 0;
531 virtual void SetHidden( bool hidden ) = 0;
532 virtual void SetSortOrder( bool ascending ) = 0;
533 virtual void SetFlags( int flags );
534 virtual void SetOwner( wxDataViewCtrl *owner )
535 { m_owner = owner; }
536 virtual void SetBitmap( const wxBitmap &bitmap )
537 { m_bitmap=bitmap; }
538
539 virtual void SetMinWidth( int minWidth ) = 0;
540 virtual void SetWidth( int width ) = 0;
541
542
543 // getters:
544
545 virtual wxString GetTitle() const = 0;
546 virtual wxAlignment GetAlignment() const = 0;
547 virtual int GetWidth() const = 0;
548 virtual int GetMinWidth() const = 0;
549
550 virtual int GetFlags() const;
551
552 virtual bool IsHidden() const = 0;
553 virtual bool IsReorderable() const = 0;
554 virtual bool IsResizeable() const = 0;
555 virtual bool IsSortable() const = 0;
556 virtual bool IsSortOrderAscending() const = 0;
557
558 const wxBitmap &GetBitmap() const { return m_bitmap; }
559 unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column); }
560
561 wxDataViewCtrl *GetOwner() const { return m_owner; }
562 wxDataViewRenderer* GetRenderer() const { return m_renderer; }
563
564 protected:
565 wxDataViewRenderer *m_renderer;
566 int m_model_column;
567 wxBitmap m_bitmap;
568 wxDataViewCtrl *m_owner;
569
570 protected:
571 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase)
572 };
573
574 // ---------------------------------------------------------
575 // wxDataViewCtrlBase
576 // ---------------------------------------------------------
577
578 #define wxDV_SINGLE 0x0000 // for convenience
579 #define wxDV_MULTIPLE 0x0001 // can select multiple items
580
581 #define wxDV_NO_HEADER 0x0002 // column titles not visible
582 #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows
583 #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns
584
585 #define wxDV_ROW_LINES 0x0010 // alternating colour in rows
586
587 class WXDLLIMPEXP_ADV wxDataViewCtrlBase: public wxControl
588 {
589 public:
590 wxDataViewCtrlBase();
591 virtual ~wxDataViewCtrlBase();
592
593 virtual bool AssociateModel( wxDataViewModel *model );
594 wxDataViewModel* GetModel();
595 const wxDataViewModel* GetModel() const;
596
597 // short cuts
598 wxDataViewColumn *PrependTextColumn( const wxString &label, unsigned int model_column,
599 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
600 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
601 int flags = wxDATAVIEW_COL_RESIZABLE );
602 wxDataViewColumn *PrependIconTextColumn( const wxString &label, unsigned int model_column,
603 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
604 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
605 int flags = wxDATAVIEW_COL_RESIZABLE );
606 wxDataViewColumn *PrependToggleColumn( const wxString &label, unsigned int model_column,
607 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
608 wxAlignment align = wxALIGN_CENTER,
609 int flags = wxDATAVIEW_COL_RESIZABLE );
610 wxDataViewColumn *PrependProgressColumn( const wxString &label, unsigned int model_column,
611 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
612 wxAlignment align = wxALIGN_CENTER,
613 int flags = wxDATAVIEW_COL_RESIZABLE );
614 wxDataViewColumn *PrependDateColumn( const wxString &label, unsigned int model_column,
615 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
616 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
617 int flags = wxDATAVIEW_COL_RESIZABLE );
618 wxDataViewColumn *PrependBitmapColumn( const wxString &label, unsigned int model_column,
619 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
620 wxAlignment align = wxALIGN_CENTER,
621 int flags = wxDATAVIEW_COL_RESIZABLE );
622 wxDataViewColumn *PrependTextColumn( const wxBitmap &label, unsigned int model_column,
623 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
624 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
625 int flags = wxDATAVIEW_COL_RESIZABLE );
626 wxDataViewColumn *PrependIconTextColumn( const wxBitmap &label, unsigned int model_column,
627 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
628 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
629 int flags = wxDATAVIEW_COL_RESIZABLE );
630 wxDataViewColumn *PrependToggleColumn( const wxBitmap &label, unsigned int model_column,
631 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
632 wxAlignment align = wxALIGN_CENTER,
633 int flags = wxDATAVIEW_COL_RESIZABLE );
634 wxDataViewColumn *PrependProgressColumn( const wxBitmap &label, unsigned int model_column,
635 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
636 wxAlignment align = wxALIGN_CENTER,
637 int flags = wxDATAVIEW_COL_RESIZABLE );
638 wxDataViewColumn *PrependDateColumn( const wxBitmap &label, unsigned int model_column,
639 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
640 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
641 int flags = wxDATAVIEW_COL_RESIZABLE );
642 wxDataViewColumn *PrependBitmapColumn( const wxBitmap &label, unsigned int model_column,
643 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
644 wxAlignment align = wxALIGN_CENTER,
645 int flags = wxDATAVIEW_COL_RESIZABLE );
646
647 wxDataViewColumn *AppendTextColumn( const wxString &label, unsigned int model_column,
648 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
649 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
650 int flags = wxDATAVIEW_COL_RESIZABLE );
651 wxDataViewColumn *AppendIconTextColumn( const wxString &label, unsigned int model_column,
652 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
653 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
654 int flags = wxDATAVIEW_COL_RESIZABLE );
655 wxDataViewColumn *AppendToggleColumn( const wxString &label, unsigned int model_column,
656 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
657 wxAlignment align = wxALIGN_CENTER,
658 int flags = wxDATAVIEW_COL_RESIZABLE );
659 wxDataViewColumn *AppendProgressColumn( const wxString &label, unsigned int model_column,
660 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
661 wxAlignment align = wxALIGN_CENTER,
662 int flags = wxDATAVIEW_COL_RESIZABLE );
663 wxDataViewColumn *AppendDateColumn( const wxString &label, unsigned int model_column,
664 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
665 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
666 int flags = wxDATAVIEW_COL_RESIZABLE );
667 wxDataViewColumn *AppendBitmapColumn( const wxString &label, unsigned int model_column,
668 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
669 wxAlignment align = wxALIGN_CENTER,
670 int flags = wxDATAVIEW_COL_RESIZABLE );
671 wxDataViewColumn *AppendTextColumn( const wxBitmap &label, unsigned int model_column,
672 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
673 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
674 int flags = wxDATAVIEW_COL_RESIZABLE );
675 wxDataViewColumn *AppendIconTextColumn( const wxBitmap &label, unsigned int model_column,
676 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
677 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
678 int flags = wxDATAVIEW_COL_RESIZABLE );
679 wxDataViewColumn *AppendToggleColumn( const wxBitmap &label, unsigned int model_column,
680 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
681 wxAlignment align = wxALIGN_CENTER,
682 int flags = wxDATAVIEW_COL_RESIZABLE );
683 wxDataViewColumn *AppendProgressColumn( const wxBitmap &label, unsigned int model_column,
684 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
685 wxAlignment align = wxALIGN_CENTER,
686 int flags = wxDATAVIEW_COL_RESIZABLE );
687 wxDataViewColumn *AppendDateColumn( const wxBitmap &label, unsigned int model_column,
688 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
689 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
690 int flags = wxDATAVIEW_COL_RESIZABLE );
691 wxDataViewColumn *AppendBitmapColumn( const wxBitmap &label, unsigned int model_column,
692 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
693 wxAlignment align = wxALIGN_CENTER,
694 int flags = wxDATAVIEW_COL_RESIZABLE );
695
696
697 virtual bool PrependColumn( wxDataViewColumn *col );
698 virtual bool AppendColumn( wxDataViewColumn *col );
699
700 virtual unsigned int GetColumnCount() const = 0;
701 virtual wxDataViewColumn* GetColumn( unsigned int pos ) const = 0;
702 virtual int GetColumnPosition( const wxDataViewColumn *column ) const = 0;
703
704 virtual bool DeleteColumn( wxDataViewColumn *column ) = 0;
705 virtual bool ClearColumns() = 0;
706
707 void SetExpanderColumn( wxDataViewColumn *col )
708 { m_expander_column = col ; DoSetExpanderColumn(); }
709 wxDataViewColumn *GetExpanderColumn() const
710 { return m_expander_column; }
711
712 virtual wxDataViewColumn *GetSortingColumn() const = 0;
713
714 void SetIndent( int indent )
715 { m_indent = indent ; DoSetIndent(); }
716 int GetIndent() const
717 { return m_indent; }
718
719 virtual wxDataViewItem GetSelection() const = 0;
720 virtual int GetSelections( wxDataViewItemArray & sel ) const = 0;
721 virtual void SetSelections( const wxDataViewItemArray & sel ) = 0;
722 virtual void Select( const wxDataViewItem & item ) = 0;
723 virtual void Unselect( const wxDataViewItem & item ) = 0;
724 virtual bool IsSelected( const wxDataViewItem & item ) const = 0;
725
726 virtual void SelectAll() = 0;
727 virtual void UnselectAll() = 0;
728
729 virtual void Expand( const wxDataViewItem & item ) = 0;
730 virtual void Collapse( const wxDataViewItem & item ) = 0;
731
732 virtual void EnsureVisible( const wxDataViewItem & item,
733 const wxDataViewColumn *column = NULL ) = 0;
734 virtual void HitTest( const wxPoint & point, wxDataViewItem &item, wxDataViewColumn* &column ) const = 0;
735 virtual wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ) const = 0;
736
737 protected:
738 virtual void DoSetExpanderColumn() = 0 ;
739 virtual void DoSetIndent() = 0;
740
741 private:
742 wxDataViewModel *m_model;
743 wxDataViewColumn *m_expander_column;
744 int m_indent ;
745
746 protected:
747 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase)
748 };
749
750 // ----------------------------------------------------------------------------
751 // wxDataViewEvent - the event class for the wxDataViewCtrl notifications
752 // ----------------------------------------------------------------------------
753
754 class WXDLLIMPEXP_ADV wxDataViewEvent : public wxNotifyEvent
755 {
756 public:
757 wxDataViewEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
758 : wxNotifyEvent(commandType, winid),
759 m_item(0),
760 m_col(-1),
761 m_model(NULL),
762 m_value(wxNullVariant),
763 m_column(NULL),
764 m_pos(-1,-1)
765 { }
766
767 wxDataViewEvent(const wxDataViewEvent& event)
768 : wxNotifyEvent(event),
769 m_item(event.m_item),
770 m_col(event.m_col),
771 m_model(event.m_model),
772 m_value(event.m_value),
773 m_column(event.m_column),
774 m_pos(m_pos)
775 { }
776
777 wxDataViewItem GetItem() const { return m_item; }
778 void SetItem( const wxDataViewItem &item ) { m_item = item; }
779
780 int GetColumn() const { return m_col; }
781 void SetColumn( int col ) { m_col = col; }
782
783 wxDataViewModel* GetModel() const { return m_model; }
784 void SetModel( wxDataViewModel *model ) { m_model = model; }
785
786 const wxVariant &GetValue() const { return m_value; }
787 void SetValue( const wxVariant &value ) { m_value = value; }
788
789 // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only
790 void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; }
791 wxDataViewColumn *GetDataViewColumn() const { return m_column; }
792
793 // for wxEVT_DATAVIEW_CONTEXT_MENU only
794 wxPoint GetPosition() const { return m_pos; }
795 void SetPosition( int x, int y ) { m_pos.x = x; m_pos.y = y; }
796
797 virtual wxEvent *Clone() const { return new wxDataViewEvent(*this); }
798
799 protected:
800 wxDataViewItem m_item;
801 int m_col;
802 wxDataViewModel *m_model;
803 wxVariant m_value;
804 wxDataViewColumn *m_column;
805 wxPoint m_pos;
806
807 private:
808 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent)
809 };
810
811 extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED;
812
813 extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED;
814 extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED;
815 extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED;
816 extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING;
817 extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING;
818 extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED;
819 extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE;
820 extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED;
821
822 extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU;
823
824 extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK;
825 extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK;
826 extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED;
827 extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED;
828
829 typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&);
830
831 #define wxDataViewEventHandler(func) \
832 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxDataViewEventFunction, &func)
833
834 #define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \
835 wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn))
836
837 #define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn)
838
839 #define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn)
840 #define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn)
841 #define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn)
842 #define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn)
843 #define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn)
844 #define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn)
845 #define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn)
846 #define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn)
847
848 #define EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_CONTEXT_MENU, id, fn)
849
850 #define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn)
851 #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn)
852 #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn)
853 #define EVT_DATAVIEW_COLUMN_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_REORDERED, id, fn)
854
855 #if defined(wxUSE_GENERICDATAVIEWCTRL)
856 #include "wx/generic/dataview.h"
857 #elif defined(__WXGTK20__)
858 #include "wx/gtk/dataview.h"
859 #elif defined(__WXMAC__)
860 #include "wx/mac/dataview.h"
861 #else
862 #include "wx/generic/dataview.h"
863 #endif
864
865 // -------------------------------------
866 // wxDataViewSpinRenderer
867 // -------------------------------------
868
869 class WXDLLIMPEXP_ADV wxDataViewSpinRenderer: public wxDataViewCustomRenderer
870 {
871 public:
872 wxDataViewSpinRenderer( int min, int max,
873 wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
874 int alignment = wxDVR_DEFAULT_ALIGNMENT );
875 virtual bool HasEditorCtrl() { return true; }
876 virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value );
877 virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value );
878 virtual bool Render( wxRect rect, wxDC *dc, int state );
879 virtual wxSize GetSize() const;
880 virtual bool SetValue( const wxVariant &value );
881 virtual bool GetValue( wxVariant &value ) const;
882
883 private:
884 long m_data;
885 long m_min,m_max;
886 };
887
888 //-----------------------------------------------------------------------------
889 // wxDataViewTreeStore
890 //-----------------------------------------------------------------------------
891
892 class WXDLLIMPEXP_ADV wxDataViewTreeStoreNode
893 {
894 public:
895 wxDataViewTreeStoreNode( wxDataViewTreeStoreNode *parent,
896 const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
897 virtual ~wxDataViewTreeStoreNode();
898
899 void SetText( const wxString &text )
900 { m_text = text; }
901 wxString GetText() const
902 { return m_text; }
903 void SetIcon( const wxIcon &icon )
904 { m_icon = icon; }
905 const wxIcon &GetIcon() const
906 { return m_icon; }
907 void SetData( wxClientData *data )
908 { if (m_data) delete m_data; m_data = data; }
909 wxClientData *GetData() const
910 { return m_data; }
911
912 wxDataViewItem GetItem() const
913 { return wxDataViewItem( (void*) this ); }
914
915 virtual bool IsContainer()
916 { return false; }
917
918 wxDataViewTreeStoreNode *GetParent()
919 { return m_parent; }
920
921 private:
922 wxDataViewTreeStoreNode *m_parent;
923 wxString m_text;
924 wxIcon m_icon;
925 wxClientData *m_data;
926 };
927
928 WX_DECLARE_LIST_WITH_DECL(wxDataViewTreeStoreNode, wxDataViewTreeStoreNodeList,
929 class WXDLLIMPEXP_ADV);
930
931 class WXDLLIMPEXP_ADV wxDataViewTreeStoreContainerNode: public wxDataViewTreeStoreNode
932 {
933 public:
934 wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode *parent,
935 const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
936 wxClientData *data = NULL );
937 virtual ~wxDataViewTreeStoreContainerNode();
938
939 const wxDataViewTreeStoreNodeList &GetChildren() const
940 { return m_children; }
941 wxDataViewTreeStoreNodeList &GetChildren()
942 { return m_children; }
943
944 void SetExpandedIcon( const wxIcon &icon )
945 { m_iconExpanded = icon; }
946 const wxIcon &GetExpandedIcon() const
947 { return m_iconExpanded; }
948
949 void SetExpanded( bool expanded = true )
950 { m_isExpanded = expanded; }
951 bool IsExpanded() const
952 { return m_isExpanded; }
953
954 virtual bool IsContainer()
955 { return true; }
956
957 private:
958 wxDataViewTreeStoreNodeList m_children;
959 wxIcon m_iconExpanded;
960 bool m_isExpanded;
961 };
962
963 //-----------------------------------------------------------------------------
964
965 class WXDLLIMPEXP_ADV wxDataViewTreeStore: public wxDataViewModel
966 {
967 public:
968 wxDataViewTreeStore();
969 ~wxDataViewTreeStore();
970
971 wxDataViewItem AppendItem( const wxDataViewItem& parent,
972 const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
973 wxDataViewItem PrependItem( const wxDataViewItem& parent,
974 const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
975 wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous,
976 const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
977
978 wxDataViewItem PrependContainer( const wxDataViewItem& parent,
979 const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
980 wxClientData *data = NULL );
981 wxDataViewItem AppendContainer( const wxDataViewItem& parent,
982 const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
983 wxClientData *data = NULL );
984 wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous,
985 const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
986 wxClientData *data = NULL );
987
988 wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const;
989 int GetChildCount( const wxDataViewItem& parent ) const;
990
991 void SetItemText( const wxDataViewItem& item, const wxString &text );
992 wxString GetItemText( const wxDataViewItem& item ) const;
993 void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon );
994 const wxIcon &GetItemIcon( const wxDataViewItem& item ) const;
995 void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon );
996 const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const;
997 void SetItemData( const wxDataViewItem& item, wxClientData *data );
998 wxClientData *GetItemData( const wxDataViewItem& item ) const;
999
1000 void DeleteItem( const wxDataViewItem& item );
1001 void DeleteChildren( const wxDataViewItem& item );
1002 void DeleteAllItems();
1003
1004 // implement base methods
1005
1006 virtual void GetValue( wxVariant &variant,
1007 const wxDataViewItem &item, unsigned int col ) const;
1008 virtual bool SetValue( const wxVariant &variant,
1009 const wxDataViewItem &item, unsigned int col );
1010 virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const;
1011 virtual bool IsContainer( const wxDataViewItem &item ) const;
1012 virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const;
1013
1014 virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
1015 unsigned int column, bool ascending );
1016
1017 virtual bool HasDefaultCompare() const
1018 { return true; }
1019 virtual unsigned int GetColumnCount() const
1020 { return 1; };
1021 virtual wxString GetColumnType( unsigned int WXUNUSED(col) ) const
1022 { return wxT("wxDataViewIconText"); }
1023
1024 wxDataViewTreeStoreNode *FindNode( const wxDataViewItem &item ) const;
1025 wxDataViewTreeStoreContainerNode *FindContainerNode( const wxDataViewItem &item ) const;
1026 wxDataViewTreeStoreNode *GetRoot() const { return m_root; }
1027
1028 public:
1029 wxDataViewTreeStoreNode *m_root;
1030 };
1031
1032 class WXDLLIMPEXP_ADV wxDataViewTreeCtrl: public wxDataViewCtrl
1033 {
1034 public:
1035 wxDataViewTreeCtrl();
1036 wxDataViewTreeCtrl( wxWindow *parent, wxWindowID id,
1037 const wxPoint& pos = wxDefaultPosition,
1038 const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
1039 const wxValidator& validator = wxDefaultValidator );
1040 ~wxDataViewTreeCtrl();
1041
1042 bool Create( wxWindow *parent, wxWindowID id,
1043 const wxPoint& pos = wxDefaultPosition,
1044 const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
1045 const wxValidator& validator = wxDefaultValidator );
1046
1047 wxDataViewTreeStore *GetStore()
1048 { return (wxDataViewTreeStore*) GetModel(); }
1049 const wxDataViewTreeStore *GetStore() const
1050 { return (const wxDataViewTreeStore*) GetModel(); }
1051
1052 void SetImageList( wxImageList *imagelist );
1053 wxImageList* GetImageList() { return m_imageList; }
1054
1055 wxDataViewItem AppendItem( const wxDataViewItem& parent,
1056 const wxString &text, int icon = -1, wxClientData *data = NULL );
1057 wxDataViewItem PrependItem( const wxDataViewItem& parent,
1058 const wxString &text, int icon = -1, wxClientData *data = NULL );
1059 wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous,
1060 const wxString &text, int icon = -1, wxClientData *data = NULL );
1061
1062 wxDataViewItem PrependContainer( const wxDataViewItem& parent,
1063 const wxString &text, int icon = -1, int expanded = -1,
1064 wxClientData *data = NULL );
1065 wxDataViewItem AppendContainer( const wxDataViewItem& parent,
1066 const wxString &text, int icon = -1, int expanded = -1,
1067 wxClientData *data = NULL );
1068 wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous,
1069 const wxString &text, int icon = -1, int expanded = -1,
1070 wxClientData *data = NULL );
1071
1072 wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const
1073 { return GetStore()->GetNthChild(parent, pos); }
1074 int GetChildCount( const wxDataViewItem& parent ) const
1075 { return GetStore()->GetChildCount(parent); }
1076
1077 void SetItemText( const wxDataViewItem& item, const wxString &text )
1078 { GetStore()->SetItemText(item,text); }
1079 wxString GetItemText( const wxDataViewItem& item ) const
1080 { return GetStore()->GetItemText(item); }
1081 void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon )
1082 { GetStore()->SetItemIcon(item,icon); }
1083 const wxIcon &GetItemIcon( const wxDataViewItem& item ) const
1084 { return GetStore()->GetItemIcon(item); }
1085 void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon )
1086 { GetStore()->SetItemExpandedIcon(item,icon); }
1087 const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const
1088 { return GetStore()->GetItemExpandedIcon(item); }
1089 void SetItemData( const wxDataViewItem& item, wxClientData *data )
1090 { GetStore()->SetItemData(item,data); }
1091 wxClientData *GetItemData( const wxDataViewItem& item ) const
1092 { return GetStore()->GetItemData(item); }
1093
1094 void DeleteItem( const wxDataViewItem& item )
1095 { GetStore()->DeleteItem(item); }
1096 void DeleteChildren( const wxDataViewItem& item )
1097 { GetStore()->DeleteChildren(item); }
1098 void DeleteAllItems()
1099 { GetStore()->DeleteAllItems(); }
1100
1101 void OnExpanded( wxDataViewEvent &event );
1102 void OnCollapsed( wxDataViewEvent &event );
1103 void OnSize( wxSizeEvent &event );
1104
1105 private:
1106 wxImageList *m_imageList;
1107
1108 private:
1109 DECLARE_EVENT_TABLE()
1110 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl)
1111 };
1112
1113 #endif // wxUSE_DATAVIEWCTRL
1114
1115 #endif
1116 // _WX_DATAVIEW_H_BASE_