1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxDataViewCtrl base classes
4 // Author: Robert Roebling
5 // Modified by: Bo Yang
8 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_DATAVIEW_H_BASE_
13 #define _WX_DATAVIEW_H_BASE_
17 #if wxUSE_DATAVIEWCTRL
19 #include "wx/textctrl.h"
20 #include "wx/headercol.h"
21 #include "wx/variant.h"
22 #include "wx/dynarray.h"
24 #include "wx/weakref.h"
25 #include "wx/vector.h"
26 #include "wx/dataobj.h"
28 class WXDLLIMPEXP_FWD_CORE wxImageList
;
30 #if !(defined(__WXGTK20__) || defined(__WXOSX__)) || defined(__WXUNIVERSAL__)
31 // #if !(defined(__WXOSX__)) || defined(__WXUNIVERSAL__)
32 #define wxHAS_GENERIC_DATAVIEWCTRL
35 #ifdef wxHAS_GENERIC_DATAVIEWCTRL
36 // this symbol doesn't follow the convention for wxUSE_XXX symbols which
37 // are normally always defined as either 0 or 1, so its use is deprecated
38 // and it only exists for backwards compatibility, don't use it any more
39 // and use wxHAS_GENERIC_DATAVIEWCTRL instead
40 #define wxUSE_GENERICDATAVIEWCTRL
43 // ----------------------------------------------------------------------------
44 // wxDataViewCtrl globals
45 // ----------------------------------------------------------------------------
47 class WXDLLIMPEXP_FWD_ADV wxDataViewItem
;
48 class WXDLLIMPEXP_FWD_ADV wxDataViewModel
;
49 class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl
;
50 class WXDLLIMPEXP_FWD_ADV wxDataViewColumn
;
51 class WXDLLIMPEXP_FWD_ADV wxDataViewRenderer
;
52 class WXDLLIMPEXP_FWD_ADV wxDataViewModelNotifier
;
54 extern WXDLLIMPEXP_DATA_ADV(const char) wxDataViewCtrlNameStr
[];
56 // ----------------------------------------------------------------------------
57 // wxDataViewCtrl flags
58 // ----------------------------------------------------------------------------
60 // size of a wxDataViewRenderer without contents:
61 #define wxDVC_DEFAULT_RENDERER_SIZE 20
63 // the default width of new (text) columns:
64 #define wxDVC_DEFAULT_WIDTH 80
66 // the default width of new toggle columns:
67 #define wxDVC_TOGGLE_DEFAULT_WIDTH 30
69 // the default minimal width of the columns:
70 #define wxDVC_DEFAULT_MINWIDTH 30
72 // The default alignment of wxDataViewRenderers is to take
73 // the alignment from the column it owns.
74 #define wxDVR_DEFAULT_ALIGNMENT -1
77 // ---------------------------------------------------------
79 // ---------------------------------------------------------
81 class WXDLLIMPEXP_ADV wxDataViewItem
84 wxDataViewItem( void* id
= NULL
)
86 wxDataViewItem( const wxDataViewItem
&item
)
88 bool IsOk() const { return m_id
!= NULL
; }
89 void* GetID() const { return m_id
; }
90 operator const void* () const { return m_id
; }
97 bool operator==(const wxDataViewItem
& left
, const wxDataViewItem
& right
)
99 return left
.GetID() == right
.GetID();
103 bool operator!=(const wxDataViewItem
& left
, const wxDataViewItem
& right
)
105 return !(left
== right
);
108 WX_DEFINE_ARRAY(wxDataViewItem
, wxDataViewItemArray
);
110 // ---------------------------------------------------------
111 // wxDataViewModelNotifier
112 // ---------------------------------------------------------
114 class WXDLLIMPEXP_ADV wxDataViewModelNotifier
117 wxDataViewModelNotifier() { m_owner
= NULL
; }
118 virtual ~wxDataViewModelNotifier() { m_owner
= NULL
; }
120 virtual bool ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
) = 0;
121 virtual bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
) = 0;
122 virtual bool ItemChanged( const wxDataViewItem
&item
) = 0;
123 virtual bool ItemsAdded( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
124 virtual bool ItemsDeleted( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
125 virtual bool ItemsChanged( const wxDataViewItemArray
&items
);
126 virtual bool ValueChanged( const wxDataViewItem
&item
, unsigned int col
) = 0;
127 virtual bool Cleared() = 0;
129 virtual void Resort() = 0;
131 void SetOwner( wxDataViewModel
*owner
) { m_owner
= owner
; }
132 wxDataViewModel
*GetOwner() const { return m_owner
; }
135 wxDataViewModel
*m_owner
;
140 // ----------------------------------------------------------------------------
141 // wxDataViewItemAttr: a structure containing the visual attributes of an item
142 // ----------------------------------------------------------------------------
144 // TODO: this should be renamed to wxItemAttr or something general like this
146 class WXDLLIMPEXP_ADV wxDataViewItemAttr
157 void SetColour(const wxColour
& colour
) { m_colour
= colour
; }
158 void SetBold( bool set
) { m_bold
= set
; }
159 void SetItalic( bool set
) { m_italic
= set
; }
162 bool HasColour() const { return m_colour
.Ok(); }
163 const wxColour
& GetColour() const { return m_colour
; }
165 bool HasFont() const { return m_bold
|| m_italic
; }
166 bool GetBold() const { return m_bold
; }
167 bool GetItalic() const { return m_italic
; }
176 // ---------------------------------------------------------
178 // ---------------------------------------------------------
180 WX_DECLARE_LIST_WITH_DECL(wxDataViewModelNotifier
, wxDataViewModelNotifiers
,
181 class WXDLLIMPEXP_ADV
);
183 class WXDLLIMPEXP_ADV wxDataViewModel
: public wxRefCounter
188 virtual unsigned int GetColumnCount() const = 0;
190 // return type as reported by wxVariant
191 virtual wxString
GetColumnType( unsigned int col
) const = 0;
193 // get value into a wxVariant
194 virtual void GetValue( wxVariant
&variant
,
195 const wxDataViewItem
&item
, unsigned int col
) const = 0;
197 // return true if the given item has a value to display in the given
198 // column: this is always true except for container items which by default
199 // only show their label in the first column (but see HasContainerColumns())
200 bool HasValue(const wxDataViewItem
& item
, unsigned col
) const
202 return col
== 0 || !IsContainer(item
) || HasContainerColumns(item
);
205 // usually ValueChanged() should be called after changing the value in the
206 // model to update the control, ChangeValue() does it on its own while
207 // SetValue() does not -- so while you will override SetValue(), you should
208 // be usually calling ChangeValue()
209 virtual bool SetValue(const wxVariant
&variant
,
210 const wxDataViewItem
&item
,
211 unsigned int col
) = 0;
213 bool ChangeValue(const wxVariant
& variant
,
214 const wxDataViewItem
& item
,
217 return SetValue(variant
, item
, col
) && ValueChanged(item
, col
);
220 // Get text attribute, return false of default attributes should be used
221 virtual bool GetAttr(const wxDataViewItem
&WXUNUSED(item
),
222 unsigned int WXUNUSED(col
),
223 wxDataViewItemAttr
&WXUNUSED(attr
)) const
229 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const = 0;
230 virtual bool IsContainer( const wxDataViewItem
&item
) const = 0;
231 // Is the container just a header or an item with all columns
232 virtual bool HasContainerColumns(const wxDataViewItem
& WXUNUSED(item
)) const
234 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const = 0;
236 // delegated notifiers
237 virtual bool ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
238 virtual bool ItemsAdded( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
239 virtual bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
240 virtual bool ItemsDeleted( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
241 virtual bool ItemChanged( const wxDataViewItem
&item
);
242 virtual bool ItemsChanged( const wxDataViewItemArray
&items
);
243 virtual bool ValueChanged( const wxDataViewItem
&item
, unsigned int col
);
244 virtual bool Cleared();
247 virtual void Resort();
249 void AddNotifier( wxDataViewModelNotifier
*notifier
);
250 void RemoveNotifier( wxDataViewModelNotifier
*notifier
);
252 // default compare function
253 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
254 unsigned int column
, bool ascending
) const;
255 virtual bool HasDefaultCompare() const { return false; }
258 virtual bool IsVirtualListModel() const { return false; }
261 // the user should not delete this class directly: he should use DecRef() instead!
262 virtual ~wxDataViewModel() { }
264 wxDataViewModelNotifiers m_notifiers
;
267 // ----------------------------------------------------------------------------
268 // wxDataViewListModel: a model of a list, i.e. flat data structure without any
269 // branches/containers, used as base class by wxDataViewIndexListModel and
270 // wxDataViewVirtualListModel
271 // ----------------------------------------------------------------------------
273 class WXDLLIMPEXP_ADV wxDataViewListModel
: public wxDataViewModel
276 // derived classes should override these methods instead of
277 // {Get,Set}Value() and GetAttr() inherited from the base class
279 virtual void GetValueByRow(wxVariant
&variant
,
280 unsigned row
, unsigned col
) const = 0;
282 virtual bool SetValueByRow(const wxVariant
&variant
,
283 unsigned row
, unsigned col
) = 0;
286 GetAttrByRow(unsigned WXUNUSED(row
), unsigned WXUNUSED(col
),
287 wxDataViewItemAttr
&WXUNUSED(attr
)) const
293 // helper methods provided by list models only
294 virtual unsigned GetRow( const wxDataViewItem
&item
) const = 0;
297 // implement some base class pure virtual directly
298 virtual wxDataViewItem
299 GetParent( const wxDataViewItem
& WXUNUSED(item
) ) const
301 // items never have valid parent in this model
302 return wxDataViewItem();
305 virtual bool IsContainer( const wxDataViewItem
&item
) const
307 // only the invisible (and invalid) root item has children
311 // and implement some others by forwarding them to our own ones
312 virtual void GetValue( wxVariant
&variant
,
313 const wxDataViewItem
&item
, unsigned int col
) const
315 GetValueByRow(variant
, GetRow(item
), col
);
318 virtual bool SetValue( const wxVariant
&variant
,
319 const wxDataViewItem
&item
, unsigned int col
)
321 return SetValueByRow( variant
, GetRow(item
), col
);
324 virtual bool GetAttr(const wxDataViewItem
&item
, unsigned int col
,
325 wxDataViewItemAttr
&attr
) const
327 return GetAttrByRow( GetRow(item
), col
, attr
);
331 // ---------------------------------------------------------
332 // wxDataViewIndexListModel
333 // ---------------------------------------------------------
335 class WXDLLIMPEXP_ADV wxDataViewIndexListModel
: public wxDataViewListModel
338 wxDataViewIndexListModel( unsigned int initial_size
= 0 );
341 void RowInserted( unsigned int before
);
343 void RowDeleted( unsigned int row
);
344 void RowsDeleted( const wxArrayInt
&rows
);
345 void RowChanged( unsigned int row
);
346 void RowValueChanged( unsigned int row
, unsigned int col
);
347 void Reset( unsigned int new_size
);
349 // convert to/from row/wxDataViewItem
351 virtual unsigned GetRow( const wxDataViewItem
&item
) const;
352 wxDataViewItem
GetItem( unsigned int row
) const;
354 // compare based on index
356 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
357 unsigned int column
, bool ascending
) const;
358 virtual bool HasDefaultCompare() const;
360 // implement base methods
361 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
363 unsigned int GetCount() const { return m_hash
.GetCount(); }
366 wxDataViewItemArray m_hash
;
367 unsigned int m_nextFreeID
;
371 // ---------------------------------------------------------
372 // wxDataViewVirtualListModel
373 // ---------------------------------------------------------
376 // better than nothing
377 typedef wxDataViewIndexListModel wxDataViewVirtualListModel
;
380 class WXDLLIMPEXP_ADV wxDataViewVirtualListModel
: public wxDataViewListModel
383 wxDataViewVirtualListModel( unsigned int initial_size
= 0 );
386 void RowInserted( unsigned int before
);
388 void RowDeleted( unsigned int row
);
389 void RowsDeleted( const wxArrayInt
&rows
);
390 void RowChanged( unsigned int row
);
391 void RowValueChanged( unsigned int row
, unsigned int col
);
392 void Reset( unsigned int new_size
);
394 // convert to/from row/wxDataViewItem
396 virtual unsigned GetRow( const wxDataViewItem
&item
) const;
397 wxDataViewItem
GetItem( unsigned int row
) const;
399 // compare based on index
401 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
402 unsigned int column
, bool ascending
) const;
403 virtual bool HasDefaultCompare() const;
405 // implement base methods
406 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
408 unsigned int GetCount() const { return m_size
; }
411 virtual bool IsVirtualListModel() const { return true; }
419 //-----------------------------------------------------------------------------
420 // wxDataViewEditorCtrlEvtHandler
421 //-----------------------------------------------------------------------------
423 class wxDataViewEditorCtrlEvtHandler
: public wxEvtHandler
426 wxDataViewEditorCtrlEvtHandler( wxControl
*editor
, wxDataViewRenderer
*owner
);
428 void AcceptChangesAndFinish();
429 void SetFocusOnIdle( bool focus
= true ) { m_focusOnIdle
= focus
; }
432 void OnChar( wxKeyEvent
&event
);
433 void OnTextEnter( wxCommandEvent
&event
);
434 void OnKillFocus( wxFocusEvent
&event
);
435 void OnIdle( wxIdleEvent
&event
);
438 wxDataViewRenderer
*m_owner
;
439 wxControl
*m_editorCtrl
;
444 DECLARE_EVENT_TABLE()
447 // ----------------------------------------------------------------------------
448 // wxDataViewRenderer and related classes
449 // ----------------------------------------------------------------------------
451 #include "wx/dvrenderers.h"
453 // ---------------------------------------------------------
454 // wxDataViewColumnBase
455 // ---------------------------------------------------------
457 // for compatibility only, do not use
458 enum wxDataViewColumnFlags
460 wxDATAVIEW_COL_RESIZABLE
= wxCOL_RESIZABLE
,
461 wxDATAVIEW_COL_SORTABLE
= wxCOL_SORTABLE
,
462 wxDATAVIEW_COL_REORDERABLE
= wxCOL_REORDERABLE
,
463 wxDATAVIEW_COL_HIDDEN
= wxCOL_HIDDEN
466 class WXDLLIMPEXP_ADV wxDataViewColumnBase
: public wxSettableHeaderColumn
469 // ctor for the text columns: takes ownership of renderer
470 wxDataViewColumnBase(wxDataViewRenderer
*renderer
,
471 unsigned int model_column
)
473 Init(renderer
, model_column
);
476 // ctor for the bitmap columns
477 wxDataViewColumnBase(const wxBitmap
& bitmap
,
478 wxDataViewRenderer
*renderer
,
479 unsigned int model_column
)
482 Init(renderer
, model_column
);
485 virtual ~wxDataViewColumnBase();
488 virtual void SetOwner( wxDataViewCtrl
*owner
)
492 unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column
); }
493 wxDataViewCtrl
*GetOwner() const { return m_owner
; }
494 wxDataViewRenderer
* GetRenderer() const { return m_renderer
; }
496 // implement some of base class pure virtuals (the rest is port-dependent
497 // and done differently in generic and native versions)
498 virtual void SetBitmap( const wxBitmap
& bitmap
) { m_bitmap
= bitmap
; }
499 virtual wxBitmap
GetBitmap() const { return m_bitmap
; }
502 wxDataViewRenderer
*m_renderer
;
505 wxDataViewCtrl
*m_owner
;
508 // common part of all ctors
509 void Init(wxDataViewRenderer
*renderer
, unsigned int model_column
);
512 // ---------------------------------------------------------
513 // wxDataViewCtrlBase
514 // ---------------------------------------------------------
516 #define wxDV_SINGLE 0x0000 // for convenience
517 #define wxDV_MULTIPLE 0x0001 // can select multiple items
519 #define wxDV_NO_HEADER 0x0002 // column titles not visible
520 #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows
521 #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns
523 #define wxDV_ROW_LINES 0x0010 // alternating colour in rows
524 #define wxDV_VARIABLE_LINE_HEIGHT 0x0020 // variable line height
526 class WXDLLIMPEXP_ADV wxDataViewCtrlBase
: public wxControl
529 wxDataViewCtrlBase();
530 virtual ~wxDataViewCtrlBase();
535 virtual bool AssociateModel( wxDataViewModel
*model
);
536 wxDataViewModel
* GetModel();
537 const wxDataViewModel
* GetModel() const;
543 wxDataViewColumn
*PrependTextColumn( const wxString
&label
, unsigned int model_column
,
544 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
545 wxAlignment align
= wxALIGN_NOT
,
546 int flags
= wxDATAVIEW_COL_RESIZABLE
);
547 wxDataViewColumn
*PrependIconTextColumn( const wxString
&label
, unsigned int model_column
,
548 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
549 wxAlignment align
= wxALIGN_NOT
,
550 int flags
= wxDATAVIEW_COL_RESIZABLE
);
551 wxDataViewColumn
*PrependToggleColumn( const wxString
&label
, unsigned int model_column
,
552 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
553 wxAlignment align
= wxALIGN_CENTER
,
554 int flags
= wxDATAVIEW_COL_RESIZABLE
);
555 wxDataViewColumn
*PrependProgressColumn( const wxString
&label
, unsigned int model_column
,
556 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
557 wxAlignment align
= wxALIGN_CENTER
,
558 int flags
= wxDATAVIEW_COL_RESIZABLE
);
559 wxDataViewColumn
*PrependDateColumn( const wxString
&label
, unsigned int model_column
,
560 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
561 wxAlignment align
= wxALIGN_NOT
,
562 int flags
= wxDATAVIEW_COL_RESIZABLE
);
563 wxDataViewColumn
*PrependBitmapColumn( const wxString
&label
, unsigned int model_column
,
564 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
565 wxAlignment align
= wxALIGN_CENTER
,
566 int flags
= wxDATAVIEW_COL_RESIZABLE
);
567 wxDataViewColumn
*PrependTextColumn( const wxBitmap
&label
, unsigned int model_column
,
568 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
569 wxAlignment align
= wxALIGN_NOT
,
570 int flags
= wxDATAVIEW_COL_RESIZABLE
);
571 wxDataViewColumn
*PrependIconTextColumn( const wxBitmap
&label
, unsigned int model_column
,
572 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
573 wxAlignment align
= wxALIGN_NOT
,
574 int flags
= wxDATAVIEW_COL_RESIZABLE
);
575 wxDataViewColumn
*PrependToggleColumn( const wxBitmap
&label
, unsigned int model_column
,
576 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
577 wxAlignment align
= wxALIGN_CENTER
,
578 int flags
= wxDATAVIEW_COL_RESIZABLE
);
579 wxDataViewColumn
*PrependProgressColumn( const wxBitmap
&label
, unsigned int model_column
,
580 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
581 wxAlignment align
= wxALIGN_CENTER
,
582 int flags
= wxDATAVIEW_COL_RESIZABLE
);
583 wxDataViewColumn
*PrependDateColumn( const wxBitmap
&label
, unsigned int model_column
,
584 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
585 wxAlignment align
= wxALIGN_NOT
,
586 int flags
= wxDATAVIEW_COL_RESIZABLE
);
587 wxDataViewColumn
*PrependBitmapColumn( const wxBitmap
&label
, unsigned int model_column
,
588 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
589 wxAlignment align
= wxALIGN_CENTER
,
590 int flags
= wxDATAVIEW_COL_RESIZABLE
);
592 wxDataViewColumn
*AppendTextColumn( const wxString
&label
, unsigned int model_column
,
593 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
594 wxAlignment align
= wxALIGN_NOT
,
595 int flags
= wxDATAVIEW_COL_RESIZABLE
);
596 wxDataViewColumn
*AppendIconTextColumn( const wxString
&label
, unsigned int model_column
,
597 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
598 wxAlignment align
= wxALIGN_NOT
,
599 int flags
= wxDATAVIEW_COL_RESIZABLE
);
600 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
, unsigned int model_column
,
601 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
602 wxAlignment align
= wxALIGN_CENTER
,
603 int flags
= wxDATAVIEW_COL_RESIZABLE
);
604 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
, unsigned int model_column
,
605 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
606 wxAlignment align
= wxALIGN_CENTER
,
607 int flags
= wxDATAVIEW_COL_RESIZABLE
);
608 wxDataViewColumn
*AppendDateColumn( const wxString
&label
, unsigned int model_column
,
609 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
610 wxAlignment align
= wxALIGN_NOT
,
611 int flags
= wxDATAVIEW_COL_RESIZABLE
);
612 wxDataViewColumn
*AppendBitmapColumn( const wxString
&label
, unsigned int model_column
,
613 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
614 wxAlignment align
= wxALIGN_CENTER
,
615 int flags
= wxDATAVIEW_COL_RESIZABLE
);
616 wxDataViewColumn
*AppendTextColumn( const wxBitmap
&label
, unsigned int model_column
,
617 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
618 wxAlignment align
= wxALIGN_NOT
,
619 int flags
= wxDATAVIEW_COL_RESIZABLE
);
620 wxDataViewColumn
*AppendIconTextColumn( const wxBitmap
&label
, unsigned int model_column
,
621 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
622 wxAlignment align
= wxALIGN_NOT
,
623 int flags
= wxDATAVIEW_COL_RESIZABLE
);
624 wxDataViewColumn
*AppendToggleColumn( const wxBitmap
&label
, unsigned int model_column
,
625 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
626 wxAlignment align
= wxALIGN_CENTER
,
627 int flags
= wxDATAVIEW_COL_RESIZABLE
);
628 wxDataViewColumn
*AppendProgressColumn( const wxBitmap
&label
, unsigned int model_column
,
629 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
630 wxAlignment align
= wxALIGN_CENTER
,
631 int flags
= wxDATAVIEW_COL_RESIZABLE
);
632 wxDataViewColumn
*AppendDateColumn( const wxBitmap
&label
, unsigned int model_column
,
633 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
634 wxAlignment align
= wxALIGN_NOT
,
635 int flags
= wxDATAVIEW_COL_RESIZABLE
);
636 wxDataViewColumn
*AppendBitmapColumn( const wxBitmap
&label
, unsigned int model_column
,
637 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
638 wxAlignment align
= wxALIGN_CENTER
,
639 int flags
= wxDATAVIEW_COL_RESIZABLE
);
641 virtual bool PrependColumn( wxDataViewColumn
*col
);
642 virtual bool InsertColumn( unsigned int pos
, wxDataViewColumn
*col
);
643 virtual bool AppendColumn( wxDataViewColumn
*col
);
645 virtual unsigned int GetColumnCount() const = 0;
646 virtual wxDataViewColumn
* GetColumn( unsigned int pos
) const = 0;
647 virtual int GetColumnPosition( const wxDataViewColumn
*column
) const = 0;
649 virtual bool DeleteColumn( wxDataViewColumn
*column
) = 0;
650 virtual bool ClearColumns() = 0;
652 void SetExpanderColumn( wxDataViewColumn
*col
)
653 { m_expander_column
= col
; DoSetExpanderColumn(); }
654 wxDataViewColumn
*GetExpanderColumn() const
655 { return m_expander_column
; }
657 virtual wxDataViewColumn
*GetSortingColumn() const = 0;
663 void SetIndent( int indent
)
664 { m_indent
= indent
; DoSetIndent(); }
665 int GetIndent() const
668 virtual wxDataViewItem
GetSelection() const = 0;
669 virtual int GetSelections( wxDataViewItemArray
& sel
) const = 0;
670 virtual void SetSelections( const wxDataViewItemArray
& sel
) = 0;
671 virtual void Select( const wxDataViewItem
& item
) = 0;
672 virtual void Unselect( const wxDataViewItem
& item
) = 0;
673 virtual bool IsSelected( const wxDataViewItem
& item
) const = 0;
675 virtual void SelectAll() = 0;
676 virtual void UnselectAll() = 0;
678 virtual void Expand( const wxDataViewItem
& item
) = 0;
679 virtual void ExpandAncestors( const wxDataViewItem
& item
);
680 virtual void Collapse( const wxDataViewItem
& item
) = 0;
681 virtual bool IsExpanded( const wxDataViewItem
& item
) const = 0;
683 virtual void EnsureVisible( const wxDataViewItem
& item
,
684 const wxDataViewColumn
*column
= NULL
) = 0;
685 virtual void HitTest( const wxPoint
& point
, wxDataViewItem
&item
, wxDataViewColumn
* &column
) const = 0;
686 virtual wxRect
GetItemRect( const wxDataViewItem
& item
, const wxDataViewColumn
*column
= NULL
) const = 0;
688 #if wxUSE_DRAG_AND_DROP
689 virtual bool EnableDragSource(const wxDataFormat
& WXUNUSED(format
))
691 virtual bool EnableDropTarget(const wxDataFormat
& WXUNUSED(format
))
693 #endif // wxUSE_DRAG_AND_DROP
695 // define control visual attributes
696 // --------------------------------
698 virtual wxVisualAttributes
GetDefaultAttributes() const
700 return GetClassDefaultAttributes(GetWindowVariant());
703 static wxVisualAttributes
704 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
)
706 return wxControl::GetCompositeControlsDefaultAttributes(variant
);
710 virtual void DoSetExpanderColumn() = 0 ;
711 virtual void DoSetIndent() = 0;
714 wxDataViewModel
*m_model
;
715 wxDataViewColumn
*m_expander_column
;
719 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase
)
722 // ----------------------------------------------------------------------------
723 // wxDataViewEvent - the event class for the wxDataViewCtrl notifications
724 // ----------------------------------------------------------------------------
726 class WXDLLIMPEXP_ADV wxDataViewEvent
: public wxNotifyEvent
729 wxDataViewEvent(wxEventType commandType
= wxEVT_NULL
, int winid
= 0)
730 : wxNotifyEvent(commandType
, winid
),
734 m_value(wxNullVariant
),
739 #if wxUSE_DRAG_AND_DROP
740 , m_dataObject(NULL
),
746 wxDataViewEvent(const wxDataViewEvent
& event
)
747 : wxNotifyEvent(event
),
748 m_item(event
.m_item
),
750 m_model(event
.m_model
),
751 m_value(event
.m_value
),
752 m_column(event
.m_column
),
754 m_cacheFrom(event
.m_cacheFrom
),
755 m_cacheTo(event
.m_cacheTo
)
756 #if wxUSE_DRAG_AND_DROP
757 , m_dataObject(event
.m_dataObject
),
758 m_dataFormat(event
.m_dataFormat
),
759 m_dataBuffer(event
.m_dataBuffer
),
760 m_dataSize(event
.m_dataSize
)
764 wxDataViewItem
GetItem() const { return m_item
; }
765 void SetItem( const wxDataViewItem
&item
) { m_item
= item
; }
767 int GetColumn() const { return m_col
; }
768 void SetColumn( int col
) { m_col
= col
; }
770 wxDataViewModel
* GetModel() const { return m_model
; }
771 void SetModel( wxDataViewModel
*model
) { m_model
= model
; }
773 const wxVariant
&GetValue() const { return m_value
; }
774 void SetValue( const wxVariant
&value
) { m_value
= value
; }
776 // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only
777 void SetDataViewColumn( wxDataViewColumn
*col
) { m_column
= col
; }
778 wxDataViewColumn
*GetDataViewColumn() const { return m_column
; }
780 // for wxEVT_DATAVIEW_CONTEXT_MENU only
781 wxPoint
GetPosition() const { return m_pos
; }
782 void SetPosition( int x
, int y
) { m_pos
.x
= x
; m_pos
.y
= y
; }
784 // For wxEVT_COMMAND_DATAVIEW_CACHE_HINT
785 int GetCacheFrom() const { return m_cacheFrom
; }
786 int GetCacheTo() const { return m_cacheTo
; }
787 void SetCache(int from
, int to
) { m_cacheFrom
= from
; m_cacheTo
= to
; }
790 #if wxUSE_DRAG_AND_DROP
791 // For drag operations
792 void SetDataObject( wxDataObject
*obj
) { m_dataObject
= obj
; }
793 wxDataObject
*GetDataObject() const { return m_dataObject
; }
795 // For drop operations
796 void SetDataFormat( const wxDataFormat
&format
) { m_dataFormat
= format
; }
797 wxDataFormat
GetDataFormat() const { return m_dataFormat
; }
798 void SetDataSize( size_t size
) { m_dataSize
= size
; }
799 size_t GetDataSize() const { return m_dataSize
; }
800 void SetDataBuffer( void* buf
) { m_dataBuffer
= buf
;}
801 void *GetDataBuffer() const { return m_dataBuffer
; }
802 #endif // wxUSE_DRAG_AND_DROP
804 virtual wxEvent
*Clone() const { return new wxDataViewEvent(*this); }
807 wxDataViewItem m_item
;
809 wxDataViewModel
*m_model
;
811 wxDataViewColumn
*m_column
;
816 #if wxUSE_DRAG_AND_DROP
817 wxDataObject
*m_dataObject
;
819 wxDataFormat m_dataFormat
;
822 #endif // wxUSE_DRAG_AND_DROP
825 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent
)
828 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED
, wxDataViewEvent
);
830 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED
, wxDataViewEvent
);
831 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED
, wxDataViewEvent
);
832 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED
, wxDataViewEvent
);
833 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING
, wxDataViewEvent
);
834 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING
, wxDataViewEvent
);
835 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING
, wxDataViewEvent
);
836 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED
, wxDataViewEvent
);
837 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE
, wxDataViewEvent
);
838 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED
, wxDataViewEvent
);
840 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU
, wxDataViewEvent
);
842 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK
, wxDataViewEvent
);
843 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK
, wxDataViewEvent
);
844 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED
, wxDataViewEvent
);
845 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED
, wxDataViewEvent
);
847 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_CACHE_HINT
, wxDataViewEvent
);
849 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG
, wxDataViewEvent
);
850 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE
, wxDataViewEvent
);
851 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_DROP
, wxDataViewEvent
);
853 typedef void (wxEvtHandler::*wxDataViewEventFunction
)(wxDataViewEvent
&);
855 #define wxDataViewEventHandler(func) \
856 wxEVENT_HANDLER_CAST(wxDataViewEventFunction, func)
858 #define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \
859 wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn))
861 #define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn)
863 #define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn)
864 #define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn)
865 #define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn)
866 #define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn)
867 #define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn)
868 #define EVT_DATAVIEW_ITEM_START_EDITING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_START_EDITING, id, fn)
869 #define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn)
870 #define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn)
871 #define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn)
873 #define EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_CONTEXT_MENU, id, fn)
875 #define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn)
876 #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn)
877 #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn)
878 #define EVT_DATAVIEW_COLUMN_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_REORDERED, id, fn)
879 #define EVT_DATAVIEW_CACHE_HINT(id, fn) wx__DECLARE_DATAVIEWEVT(CACHE_HINT, id, fn)
881 #define EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_BEGIN_DRAG, id, fn)
882 #define EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP_POSSIBLE, id, fn)
883 #define EVT_DATAVIEW_ITEM_DROP(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP, id, fn)
885 #ifdef wxHAS_GENERIC_DATAVIEWCTRL
886 #include "wx/generic/dataview.h"
887 #elif defined(__WXGTK20__)
888 #include "wx/gtk/dataview.h"
889 #elif defined(__WXMAC__)
890 #include "wx/osx/dataview.h"
892 #error "unknown native wxDataViewCtrl implementation"
895 //-----------------------------------------------------------------------------
896 // wxDataViewListStore
897 //-----------------------------------------------------------------------------
899 class WXDLLIMPEXP_ADV wxDataViewListStoreLine
902 wxDataViewListStoreLine( wxClientData
*data
= NULL
)
906 virtual ~wxDataViewListStoreLine()
911 void SetData( wxClientData
*data
)
912 { if (m_data
) delete m_data
; m_data
= data
; }
913 wxClientData
*GetData() const
916 wxVector
<wxVariant
> m_values
;
919 wxClientData
*m_data
;
923 class WXDLLIMPEXP_ADV wxDataViewListStore
: public wxDataViewIndexListModel
926 wxDataViewListStore();
927 ~wxDataViewListStore();
929 void PrependColumn( const wxString
&varianttype
);
930 void InsertColumn( unsigned int pos
, const wxString
&varianttype
);
931 void AppendColumn( const wxString
&varianttype
);
933 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
934 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
935 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
936 void DeleteItem( unsigned int pos
);
937 void DeleteAllItems();
939 // override base virtuals
941 virtual unsigned int GetColumnCount() const;
943 virtual wxString
GetColumnType( unsigned int col
) const;
945 virtual void GetValueByRow( wxVariant
&value
,
946 unsigned int row
, unsigned int col
) const;
948 virtual bool SetValueByRow( const wxVariant
&value
,
949 unsigned int row
, unsigned int col
);
953 wxVector
<wxDataViewListStoreLine
*> m_data
;
954 wxArrayString m_cols
;
957 //-----------------------------------------------------------------------------
959 class WXDLLIMPEXP_ADV wxDataViewListCtrl
: public wxDataViewCtrl
962 wxDataViewListCtrl();
963 wxDataViewListCtrl( wxWindow
*parent
, wxWindowID id
,
964 const wxPoint
& pos
= wxDefaultPosition
,
965 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
966 const wxValidator
& validator
= wxDefaultValidator
);
967 ~wxDataViewListCtrl();
969 bool Create( wxWindow
*parent
, wxWindowID id
,
970 const wxPoint
& pos
= wxDefaultPosition
,
971 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
972 const wxValidator
& validator
= wxDefaultValidator
);
974 wxDataViewListStore
*GetStore()
975 { return (wxDataViewListStore
*) GetModel(); }
976 const wxDataViewListStore
*GetStore() const
977 { return (const wxDataViewListStore
*) GetModel(); }
979 bool AppendColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
980 bool PrependColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
981 bool InsertColumn( unsigned int pos
, wxDataViewColumn
*column
, const wxString
&varianttype
);
983 // overridden from base class
984 virtual bool PrependColumn( wxDataViewColumn
*col
);
985 virtual bool InsertColumn( unsigned int pos
, wxDataViewColumn
*col
);
986 virtual bool AppendColumn( wxDataViewColumn
*col
);
988 wxDataViewColumn
*AppendTextColumn( const wxString
&label
,
989 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
990 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
991 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
,
992 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
993 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
994 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
,
995 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
996 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
997 wxDataViewColumn
*AppendIconTextColumn( const wxString
&label
,
998 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
999 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1001 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1002 { GetStore()->AppendItem( values
, data
); }
1003 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1004 { GetStore()->PrependItem( values
, data
); }
1005 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1006 { GetStore()->InsertItem( row
, values
, data
); }
1007 void DeleteItem( unsigned row
)
1008 { GetStore()->DeleteItem( row
); }
1009 void DeleteAllItems()
1010 { GetStore()->DeleteAllItems(); }
1012 void SetValue( const wxVariant
&value
, unsigned int row
, unsigned int col
)
1013 { GetStore()->SetValueByRow( value
, row
, col
);
1014 GetStore()->RowValueChanged( row
, col
); }
1015 void GetValue( wxVariant
&value
, unsigned int row
, unsigned int col
)
1016 { GetStore()->GetValueByRow( value
, row
, col
); }
1018 void SetTextValue( const wxString
&value
, unsigned int row
, unsigned int col
)
1019 { GetStore()->SetValueByRow( value
, row
, col
);
1020 GetStore()->RowValueChanged( row
, col
); }
1021 wxString
GetTextValue( unsigned int row
, unsigned int col
) const
1022 { wxVariant value
; GetStore()->GetValueByRow( value
, row
, col
); return value
.GetString(); }
1024 void SetToggleValue( bool value
, unsigned int row
, unsigned int col
)
1025 { GetStore()->SetValueByRow( value
, row
, col
);
1026 GetStore()->RowValueChanged( row
, col
); }
1027 bool GetToggleValue( unsigned int row
, unsigned int col
) const
1028 { wxVariant value
; GetStore()->GetValueByRow( value
, row
, col
); return value
.GetBool(); }
1030 void OnSize( wxSizeEvent
&event
);
1033 DECLARE_EVENT_TABLE()
1034 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewListCtrl
)
1037 //-----------------------------------------------------------------------------
1038 // wxDataViewTreeStore
1039 //-----------------------------------------------------------------------------
1041 class WXDLLIMPEXP_ADV wxDataViewTreeStoreNode
1044 wxDataViewTreeStoreNode( wxDataViewTreeStoreNode
*parent
,
1045 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1046 virtual ~wxDataViewTreeStoreNode();
1048 void SetText( const wxString
&text
)
1050 wxString
GetText() const
1052 void SetIcon( const wxIcon
&icon
)
1054 const wxIcon
&GetIcon() const
1056 void SetData( wxClientData
*data
)
1057 { if (m_data
) delete m_data
; m_data
= data
; }
1058 wxClientData
*GetData() const
1061 wxDataViewItem
GetItem() const
1062 { return wxDataViewItem( (void*) this ); }
1064 virtual bool IsContainer()
1067 wxDataViewTreeStoreNode
*GetParent()
1068 { return m_parent
; }
1071 wxDataViewTreeStoreNode
*m_parent
;
1074 wxClientData
*m_data
;
1077 WX_DECLARE_LIST_WITH_DECL(wxDataViewTreeStoreNode
, wxDataViewTreeStoreNodeList
,
1078 class WXDLLIMPEXP_ADV
);
1080 class WXDLLIMPEXP_ADV wxDataViewTreeStoreContainerNode
: public wxDataViewTreeStoreNode
1083 wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode
*parent
,
1084 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1085 wxClientData
*data
= NULL
);
1086 virtual ~wxDataViewTreeStoreContainerNode();
1088 const wxDataViewTreeStoreNodeList
&GetChildren() const
1089 { return m_children
; }
1090 wxDataViewTreeStoreNodeList
&GetChildren()
1091 { return m_children
; }
1093 void SetExpandedIcon( const wxIcon
&icon
)
1094 { m_iconExpanded
= icon
; }
1095 const wxIcon
&GetExpandedIcon() const
1096 { return m_iconExpanded
; }
1098 void SetExpanded( bool expanded
= true )
1099 { m_isExpanded
= expanded
; }
1100 bool IsExpanded() const
1101 { return m_isExpanded
; }
1103 virtual bool IsContainer()
1107 wxDataViewTreeStoreNodeList m_children
;
1108 wxIcon m_iconExpanded
;
1112 //-----------------------------------------------------------------------------
1114 class WXDLLIMPEXP_ADV wxDataViewTreeStore
: public wxDataViewModel
1117 wxDataViewTreeStore();
1118 ~wxDataViewTreeStore();
1120 wxDataViewItem
AppendItem( const wxDataViewItem
& parent
,
1121 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1122 wxDataViewItem
PrependItem( const wxDataViewItem
& parent
,
1123 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1124 wxDataViewItem
InsertItem( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1125 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1127 wxDataViewItem
PrependContainer( const wxDataViewItem
& parent
,
1128 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1129 wxClientData
*data
= NULL
);
1130 wxDataViewItem
AppendContainer( const wxDataViewItem
& parent
,
1131 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1132 wxClientData
*data
= NULL
);
1133 wxDataViewItem
InsertContainer( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1134 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1135 wxClientData
*data
= NULL
);
1137 wxDataViewItem
GetNthChild( const wxDataViewItem
& parent
, unsigned int pos
) const;
1138 int GetChildCount( const wxDataViewItem
& parent
) const;
1140 void SetItemText( const wxDataViewItem
& item
, const wxString
&text
);
1141 wxString
GetItemText( const wxDataViewItem
& item
) const;
1142 void SetItemIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1143 const wxIcon
&GetItemIcon( const wxDataViewItem
& item
) const;
1144 void SetItemExpandedIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1145 const wxIcon
&GetItemExpandedIcon( const wxDataViewItem
& item
) const;
1146 void SetItemData( const wxDataViewItem
& item
, wxClientData
*data
);
1147 wxClientData
*GetItemData( const wxDataViewItem
& item
) const;
1149 void DeleteItem( const wxDataViewItem
& item
);
1150 void DeleteChildren( const wxDataViewItem
& item
);
1151 void DeleteAllItems();
1153 // implement base methods
1155 virtual void GetValue( wxVariant
&variant
,
1156 const wxDataViewItem
&item
, unsigned int col
) const;
1157 virtual bool SetValue( const wxVariant
&variant
,
1158 const wxDataViewItem
&item
, unsigned int col
);
1159 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const;
1160 virtual bool IsContainer( const wxDataViewItem
&item
) const;
1161 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
1163 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
1164 unsigned int column
, bool ascending
) const;
1166 virtual bool HasDefaultCompare() const
1168 virtual unsigned int GetColumnCount() const
1170 virtual wxString
GetColumnType( unsigned int WXUNUSED(col
) ) const
1171 { return wxT("wxDataViewIconText"); }
1173 wxDataViewTreeStoreNode
*FindNode( const wxDataViewItem
&item
) const;
1174 wxDataViewTreeStoreContainerNode
*FindContainerNode( const wxDataViewItem
&item
) const;
1175 wxDataViewTreeStoreNode
*GetRoot() const { return m_root
; }
1178 wxDataViewTreeStoreNode
*m_root
;
1181 //-----------------------------------------------------------------------------
1183 class WXDLLIMPEXP_ADV wxDataViewTreeCtrl
: public wxDataViewCtrl
1186 wxDataViewTreeCtrl() { Init(); }
1187 wxDataViewTreeCtrl(wxWindow
*parent
,
1189 const wxPoint
& pos
= wxDefaultPosition
,
1190 const wxSize
& size
= wxDefaultSize
,
1191 long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
1192 const wxValidator
& validator
= wxDefaultValidator
)
1196 Create(parent
, id
, pos
, size
, style
, validator
);
1199 virtual ~wxDataViewTreeCtrl();
1201 bool Create(wxWindow
*parent
,
1203 const wxPoint
& pos
= wxDefaultPosition
,
1204 const wxSize
& size
= wxDefaultSize
,
1205 long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
1206 const wxValidator
& validator
= wxDefaultValidator
);
1208 wxDataViewTreeStore
*GetStore()
1209 { return (wxDataViewTreeStore
*) GetModel(); }
1210 const wxDataViewTreeStore
*GetStore() const
1211 { return (const wxDataViewTreeStore
*) GetModel(); }
1213 void SetImageList( wxImageList
*imagelist
);
1214 wxImageList
* GetImageList() { return m_imageList
; }
1216 wxDataViewItem
AppendItem( const wxDataViewItem
& parent
,
1217 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1218 wxDataViewItem
PrependItem( const wxDataViewItem
& parent
,
1219 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1220 wxDataViewItem
InsertItem( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1221 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1223 wxDataViewItem
PrependContainer( const wxDataViewItem
& parent
,
1224 const wxString
&text
, int icon
= -1, int expanded
= -1,
1225 wxClientData
*data
= NULL
);
1226 wxDataViewItem
AppendContainer( const wxDataViewItem
& parent
,
1227 const wxString
&text
, int icon
= -1, int expanded
= -1,
1228 wxClientData
*data
= NULL
);
1229 wxDataViewItem
InsertContainer( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1230 const wxString
&text
, int icon
= -1, int expanded
= -1,
1231 wxClientData
*data
= NULL
);
1233 wxDataViewItem
GetNthChild( const wxDataViewItem
& parent
, unsigned int pos
) const
1234 { return GetStore()->GetNthChild(parent
, pos
); }
1235 int GetChildCount( const wxDataViewItem
& parent
) const
1236 { return GetStore()->GetChildCount(parent
); }
1238 void SetItemText( const wxDataViewItem
& item
, const wxString
&text
);
1239 wxString
GetItemText( const wxDataViewItem
& item
) const
1240 { return GetStore()->GetItemText(item
); }
1241 void SetItemIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1242 const wxIcon
&GetItemIcon( const wxDataViewItem
& item
) const
1243 { return GetStore()->GetItemIcon(item
); }
1244 void SetItemExpandedIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1245 const wxIcon
&GetItemExpandedIcon( const wxDataViewItem
& item
) const
1246 { return GetStore()->GetItemExpandedIcon(item
); }
1247 void SetItemData( const wxDataViewItem
& item
, wxClientData
*data
)
1248 { GetStore()->SetItemData(item
,data
); }
1249 wxClientData
*GetItemData( const wxDataViewItem
& item
) const
1250 { return GetStore()->GetItemData(item
); }
1252 void DeleteItem( const wxDataViewItem
& item
);
1253 void DeleteChildren( const wxDataViewItem
& item
);
1254 void DeleteAllItems();
1256 void OnExpanded( wxDataViewEvent
&event
);
1257 void OnCollapsed( wxDataViewEvent
&event
);
1258 void OnSize( wxSizeEvent
&event
);
1266 wxImageList
*m_imageList
;
1269 DECLARE_EVENT_TABLE()
1270 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl
)
1273 #endif // wxUSE_DATAVIEWCTRL
1276 // _WX_DATAVIEW_H_BASE_