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
; }
169 bool IsDefault() const { return !(HasColour() || HasFont()); }
178 // ---------------------------------------------------------
180 // ---------------------------------------------------------
182 WX_DECLARE_LIST_WITH_DECL(wxDataViewModelNotifier
, wxDataViewModelNotifiers
,
183 class WXDLLIMPEXP_ADV
);
185 class WXDLLIMPEXP_ADV wxDataViewModel
: public wxRefCounter
190 virtual unsigned int GetColumnCount() const = 0;
192 // return type as reported by wxVariant
193 virtual wxString
GetColumnType( unsigned int col
) const = 0;
195 // get value into a wxVariant
196 virtual void GetValue( wxVariant
&variant
,
197 const wxDataViewItem
&item
, unsigned int col
) const = 0;
199 // return true if the given item has a value to display in the given
200 // column: this is always true except for container items which by default
201 // only show their label in the first column (but see HasContainerColumns())
202 bool HasValue(const wxDataViewItem
& item
, unsigned col
) const
204 return col
== 0 || !IsContainer(item
) || HasContainerColumns(item
);
207 // usually ValueChanged() should be called after changing the value in the
208 // model to update the control, ChangeValue() does it on its own while
209 // SetValue() does not -- so while you will override SetValue(), you should
210 // be usually calling ChangeValue()
211 virtual bool SetValue(const wxVariant
&variant
,
212 const wxDataViewItem
&item
,
213 unsigned int col
) = 0;
215 bool ChangeValue(const wxVariant
& variant
,
216 const wxDataViewItem
& item
,
219 return SetValue(variant
, item
, col
) && ValueChanged(item
, col
);
222 // Get text attribute, return false of default attributes should be used
223 virtual bool GetAttr(const wxDataViewItem
&WXUNUSED(item
),
224 unsigned int WXUNUSED(col
),
225 wxDataViewItemAttr
&WXUNUSED(attr
)) const
231 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const = 0;
232 virtual bool IsContainer( const wxDataViewItem
&item
) const = 0;
233 // Is the container just a header or an item with all columns
234 virtual bool HasContainerColumns(const wxDataViewItem
& WXUNUSED(item
)) const
236 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const = 0;
238 // delegated notifiers
239 bool ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
240 bool ItemsAdded( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
241 bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
242 bool ItemsDeleted( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
243 bool ItemChanged( const wxDataViewItem
&item
);
244 bool ItemsChanged( const wxDataViewItemArray
&items
);
245 bool ValueChanged( const wxDataViewItem
&item
, unsigned int col
);
249 virtual void Resort();
251 void AddNotifier( wxDataViewModelNotifier
*notifier
);
252 void RemoveNotifier( wxDataViewModelNotifier
*notifier
);
254 // default compare function
255 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
256 unsigned int column
, bool ascending
) const;
257 virtual bool HasDefaultCompare() const { return false; }
260 virtual bool IsListModel() const { return false; }
261 virtual bool IsVirtualListModel() const { return false; }
264 // the user should not delete this class directly: he should use DecRef() instead!
265 virtual ~wxDataViewModel() { }
267 wxDataViewModelNotifiers m_notifiers
;
270 // ----------------------------------------------------------------------------
271 // wxDataViewListModel: a model of a list, i.e. flat data structure without any
272 // branches/containers, used as base class by wxDataViewIndexListModel and
273 // wxDataViewVirtualListModel
274 // ----------------------------------------------------------------------------
276 class WXDLLIMPEXP_ADV wxDataViewListModel
: public wxDataViewModel
279 // derived classes should override these methods instead of
280 // {Get,Set}Value() and GetAttr() inherited from the base class
282 virtual void GetValueByRow(wxVariant
&variant
,
283 unsigned row
, unsigned col
) const = 0;
285 virtual bool SetValueByRow(const wxVariant
&variant
,
286 unsigned row
, unsigned col
) = 0;
289 GetAttrByRow(unsigned WXUNUSED(row
), unsigned WXUNUSED(col
),
290 wxDataViewItemAttr
&WXUNUSED(attr
)) const
296 // helper methods provided by list models only
297 virtual unsigned GetRow( const wxDataViewItem
&item
) const = 0;
300 // implement some base class pure virtual directly
301 virtual wxDataViewItem
302 GetParent( const wxDataViewItem
& WXUNUSED(item
) ) const
304 // items never have valid parent in this model
305 return wxDataViewItem();
308 virtual bool IsContainer( const wxDataViewItem
&item
) const
310 // only the invisible (and invalid) root item has children
314 // and implement some others by forwarding them to our own ones
315 virtual void GetValue( wxVariant
&variant
,
316 const wxDataViewItem
&item
, unsigned int col
) const
318 GetValueByRow(variant
, GetRow(item
), col
);
321 virtual bool SetValue( const wxVariant
&variant
,
322 const wxDataViewItem
&item
, unsigned int col
)
324 return SetValueByRow( variant
, GetRow(item
), col
);
327 virtual bool GetAttr(const wxDataViewItem
&item
, unsigned int col
,
328 wxDataViewItemAttr
&attr
) const
330 return GetAttrByRow( GetRow(item
), col
, attr
);
333 virtual bool IsListModel() const { return true; }
336 // ---------------------------------------------------------
337 // wxDataViewIndexListModel
338 // ---------------------------------------------------------
340 class WXDLLIMPEXP_ADV wxDataViewIndexListModel
: public wxDataViewListModel
343 wxDataViewIndexListModel( unsigned int initial_size
= 0 );
346 void RowInserted( unsigned int before
);
348 void RowDeleted( unsigned int row
);
349 void RowsDeleted( const wxArrayInt
&rows
);
350 void RowChanged( unsigned int row
);
351 void RowValueChanged( unsigned int row
, unsigned int col
);
352 void Reset( unsigned int new_size
);
354 // convert to/from row/wxDataViewItem
356 virtual unsigned GetRow( const wxDataViewItem
&item
) const;
357 wxDataViewItem
GetItem( unsigned int row
) const;
359 // compare based on index
361 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
362 unsigned int column
, bool ascending
) const;
363 virtual bool HasDefaultCompare() const;
365 // implement base methods
366 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
368 unsigned int GetCount() const { return m_hash
.GetCount(); }
371 wxDataViewItemArray m_hash
;
372 unsigned int m_nextFreeID
;
376 // ---------------------------------------------------------
377 // wxDataViewVirtualListModel
378 // ---------------------------------------------------------
381 // better than nothing
382 typedef wxDataViewIndexListModel wxDataViewVirtualListModel
;
385 class WXDLLIMPEXP_ADV wxDataViewVirtualListModel
: public wxDataViewListModel
388 wxDataViewVirtualListModel( unsigned int initial_size
= 0 );
391 void RowInserted( unsigned int before
);
393 void RowDeleted( unsigned int row
);
394 void RowsDeleted( const wxArrayInt
&rows
);
395 void RowChanged( unsigned int row
);
396 void RowValueChanged( unsigned int row
, unsigned int col
);
397 void Reset( unsigned int new_size
);
399 // convert to/from row/wxDataViewItem
401 virtual unsigned GetRow( const wxDataViewItem
&item
) const;
402 wxDataViewItem
GetItem( unsigned int row
) const;
404 // compare based on index
406 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
407 unsigned int column
, bool ascending
) const;
408 virtual bool HasDefaultCompare() const;
410 // implement base methods
411 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
413 unsigned int GetCount() const { return m_size
; }
416 virtual bool IsVirtualListModel() const { return true; }
424 // ----------------------------------------------------------------------------
425 // wxDataViewRenderer and related classes
426 // ----------------------------------------------------------------------------
428 #include "wx/dvrenderers.h"
430 // ---------------------------------------------------------
431 // wxDataViewColumnBase
432 // ---------------------------------------------------------
434 // for compatibility only, do not use
435 enum wxDataViewColumnFlags
437 wxDATAVIEW_COL_RESIZABLE
= wxCOL_RESIZABLE
,
438 wxDATAVIEW_COL_SORTABLE
= wxCOL_SORTABLE
,
439 wxDATAVIEW_COL_REORDERABLE
= wxCOL_REORDERABLE
,
440 wxDATAVIEW_COL_HIDDEN
= wxCOL_HIDDEN
443 class WXDLLIMPEXP_ADV wxDataViewColumnBase
: public wxSettableHeaderColumn
446 // ctor for the text columns: takes ownership of renderer
447 wxDataViewColumnBase(wxDataViewRenderer
*renderer
,
448 unsigned int model_column
)
450 Init(renderer
, model_column
);
453 // ctor for the bitmap columns
454 wxDataViewColumnBase(const wxBitmap
& bitmap
,
455 wxDataViewRenderer
*renderer
,
456 unsigned int model_column
)
459 Init(renderer
, model_column
);
462 virtual ~wxDataViewColumnBase();
465 virtual void SetOwner( wxDataViewCtrl
*owner
)
469 unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column
); }
470 wxDataViewCtrl
*GetOwner() const { return m_owner
; }
471 wxDataViewRenderer
* GetRenderer() const { return m_renderer
; }
473 // implement some of base class pure virtuals (the rest is port-dependent
474 // and done differently in generic and native versions)
475 virtual void SetBitmap( const wxBitmap
& bitmap
) { m_bitmap
= bitmap
; }
476 virtual wxBitmap
GetBitmap() const { return m_bitmap
; }
479 wxDataViewRenderer
*m_renderer
;
482 wxDataViewCtrl
*m_owner
;
485 // common part of all ctors
486 void Init(wxDataViewRenderer
*renderer
, unsigned int model_column
);
489 // ---------------------------------------------------------
490 // wxDataViewCtrlBase
491 // ---------------------------------------------------------
493 #define wxDV_SINGLE 0x0000 // for convenience
494 #define wxDV_MULTIPLE 0x0001 // can select multiple items
496 #define wxDV_NO_HEADER 0x0002 // column titles not visible
497 #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows
498 #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns
500 #define wxDV_ROW_LINES 0x0010 // alternating colour in rows
501 #define wxDV_VARIABLE_LINE_HEIGHT 0x0020 // variable line height
503 class WXDLLIMPEXP_ADV wxDataViewCtrlBase
: public wxControl
506 wxDataViewCtrlBase();
507 virtual ~wxDataViewCtrlBase();
512 virtual bool AssociateModel( wxDataViewModel
*model
);
513 wxDataViewModel
* GetModel();
514 const wxDataViewModel
* GetModel() const;
520 wxDataViewColumn
*PrependTextColumn( const wxString
&label
, unsigned int model_column
,
521 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
522 wxAlignment align
= wxALIGN_NOT
,
523 int flags
= wxDATAVIEW_COL_RESIZABLE
);
524 wxDataViewColumn
*PrependIconTextColumn( const wxString
&label
, unsigned int model_column
,
525 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
526 wxAlignment align
= wxALIGN_NOT
,
527 int flags
= wxDATAVIEW_COL_RESIZABLE
);
528 wxDataViewColumn
*PrependToggleColumn( const wxString
&label
, unsigned int model_column
,
529 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
530 wxAlignment align
= wxALIGN_CENTER
,
531 int flags
= wxDATAVIEW_COL_RESIZABLE
);
532 wxDataViewColumn
*PrependProgressColumn( const wxString
&label
, unsigned int model_column
,
533 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
534 wxAlignment align
= wxALIGN_CENTER
,
535 int flags
= wxDATAVIEW_COL_RESIZABLE
);
536 wxDataViewColumn
*PrependDateColumn( const wxString
&label
, unsigned int model_column
,
537 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
538 wxAlignment align
= wxALIGN_NOT
,
539 int flags
= wxDATAVIEW_COL_RESIZABLE
);
540 wxDataViewColumn
*PrependBitmapColumn( const wxString
&label
, unsigned int model_column
,
541 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
542 wxAlignment align
= wxALIGN_CENTER
,
543 int flags
= wxDATAVIEW_COL_RESIZABLE
);
544 wxDataViewColumn
*PrependTextColumn( const wxBitmap
&label
, unsigned int model_column
,
545 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
546 wxAlignment align
= wxALIGN_NOT
,
547 int flags
= wxDATAVIEW_COL_RESIZABLE
);
548 wxDataViewColumn
*PrependIconTextColumn( const wxBitmap
&label
, unsigned int model_column
,
549 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
550 wxAlignment align
= wxALIGN_NOT
,
551 int flags
= wxDATAVIEW_COL_RESIZABLE
);
552 wxDataViewColumn
*PrependToggleColumn( const wxBitmap
&label
, unsigned int model_column
,
553 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
554 wxAlignment align
= wxALIGN_CENTER
,
555 int flags
= wxDATAVIEW_COL_RESIZABLE
);
556 wxDataViewColumn
*PrependProgressColumn( const wxBitmap
&label
, unsigned int model_column
,
557 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
558 wxAlignment align
= wxALIGN_CENTER
,
559 int flags
= wxDATAVIEW_COL_RESIZABLE
);
560 wxDataViewColumn
*PrependDateColumn( const wxBitmap
&label
, unsigned int model_column
,
561 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
562 wxAlignment align
= wxALIGN_NOT
,
563 int flags
= wxDATAVIEW_COL_RESIZABLE
);
564 wxDataViewColumn
*PrependBitmapColumn( const wxBitmap
&label
, unsigned int model_column
,
565 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
566 wxAlignment align
= wxALIGN_CENTER
,
567 int flags
= wxDATAVIEW_COL_RESIZABLE
);
569 wxDataViewColumn
*AppendTextColumn( const wxString
&label
, unsigned int model_column
,
570 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
571 wxAlignment align
= wxALIGN_NOT
,
572 int flags
= wxDATAVIEW_COL_RESIZABLE
);
573 wxDataViewColumn
*AppendIconTextColumn( const wxString
&label
, unsigned int model_column
,
574 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
575 wxAlignment align
= wxALIGN_NOT
,
576 int flags
= wxDATAVIEW_COL_RESIZABLE
);
577 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
, unsigned int model_column
,
578 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
579 wxAlignment align
= wxALIGN_CENTER
,
580 int flags
= wxDATAVIEW_COL_RESIZABLE
);
581 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
, unsigned int model_column
,
582 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
583 wxAlignment align
= wxALIGN_CENTER
,
584 int flags
= wxDATAVIEW_COL_RESIZABLE
);
585 wxDataViewColumn
*AppendDateColumn( const wxString
&label
, unsigned int model_column
,
586 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
587 wxAlignment align
= wxALIGN_NOT
,
588 int flags
= wxDATAVIEW_COL_RESIZABLE
);
589 wxDataViewColumn
*AppendBitmapColumn( const wxString
&label
, unsigned int model_column
,
590 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
591 wxAlignment align
= wxALIGN_CENTER
,
592 int flags
= wxDATAVIEW_COL_RESIZABLE
);
593 wxDataViewColumn
*AppendTextColumn( const wxBitmap
&label
, unsigned int model_column
,
594 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
595 wxAlignment align
= wxALIGN_NOT
,
596 int flags
= wxDATAVIEW_COL_RESIZABLE
);
597 wxDataViewColumn
*AppendIconTextColumn( const wxBitmap
&label
, unsigned int model_column
,
598 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
599 wxAlignment align
= wxALIGN_NOT
,
600 int flags
= wxDATAVIEW_COL_RESIZABLE
);
601 wxDataViewColumn
*AppendToggleColumn( const wxBitmap
&label
, unsigned int model_column
,
602 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
603 wxAlignment align
= wxALIGN_CENTER
,
604 int flags
= wxDATAVIEW_COL_RESIZABLE
);
605 wxDataViewColumn
*AppendProgressColumn( const wxBitmap
&label
, unsigned int model_column
,
606 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
607 wxAlignment align
= wxALIGN_CENTER
,
608 int flags
= wxDATAVIEW_COL_RESIZABLE
);
609 wxDataViewColumn
*AppendDateColumn( const wxBitmap
&label
, unsigned int model_column
,
610 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
611 wxAlignment align
= wxALIGN_NOT
,
612 int flags
= wxDATAVIEW_COL_RESIZABLE
);
613 wxDataViewColumn
*AppendBitmapColumn( const wxBitmap
&label
, unsigned int model_column
,
614 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
615 wxAlignment align
= wxALIGN_CENTER
,
616 int flags
= wxDATAVIEW_COL_RESIZABLE
);
618 virtual bool PrependColumn( wxDataViewColumn
*col
);
619 virtual bool InsertColumn( unsigned int pos
, wxDataViewColumn
*col
);
620 virtual bool AppendColumn( wxDataViewColumn
*col
);
622 virtual unsigned int GetColumnCount() const = 0;
623 virtual wxDataViewColumn
* GetColumn( unsigned int pos
) const = 0;
624 virtual int GetColumnPosition( const wxDataViewColumn
*column
) const = 0;
626 virtual bool DeleteColumn( wxDataViewColumn
*column
) = 0;
627 virtual bool ClearColumns() = 0;
629 void SetExpanderColumn( wxDataViewColumn
*col
)
630 { m_expander_column
= col
; DoSetExpanderColumn(); }
631 wxDataViewColumn
*GetExpanderColumn() const
632 { return m_expander_column
; }
634 virtual wxDataViewColumn
*GetSortingColumn() const = 0;
640 void SetIndent( int indent
)
641 { m_indent
= indent
; DoSetIndent(); }
642 int GetIndent() const
645 virtual wxDataViewItem
GetSelection() const = 0;
646 virtual int GetSelections( wxDataViewItemArray
& sel
) const = 0;
647 virtual void SetSelections( const wxDataViewItemArray
& sel
) = 0;
648 virtual void Select( const wxDataViewItem
& item
) = 0;
649 virtual void Unselect( const wxDataViewItem
& item
) = 0;
650 virtual bool IsSelected( const wxDataViewItem
& item
) const = 0;
652 virtual void SelectAll() = 0;
653 virtual void UnselectAll() = 0;
655 virtual void Expand( const wxDataViewItem
& item
) = 0;
656 virtual void ExpandAncestors( const wxDataViewItem
& item
);
657 virtual void Collapse( const wxDataViewItem
& item
) = 0;
658 virtual bool IsExpanded( const wxDataViewItem
& item
) const = 0;
660 virtual void EnsureVisible( const wxDataViewItem
& item
,
661 const wxDataViewColumn
*column
= NULL
) = 0;
662 virtual void HitTest( const wxPoint
& point
, wxDataViewItem
&item
, wxDataViewColumn
* &column
) const = 0;
663 virtual wxRect
GetItemRect( const wxDataViewItem
& item
, const wxDataViewColumn
*column
= NULL
) const = 0;
665 #if wxUSE_DRAG_AND_DROP
666 virtual bool EnableDragSource(const wxDataFormat
& WXUNUSED(format
))
668 virtual bool EnableDropTarget(const wxDataFormat
& WXUNUSED(format
))
670 #endif // wxUSE_DRAG_AND_DROP
672 // define control visual attributes
673 // --------------------------------
675 virtual wxVisualAttributes
GetDefaultAttributes() const
677 return GetClassDefaultAttributes(GetWindowVariant());
680 static wxVisualAttributes
681 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
)
683 return wxControl::GetCompositeControlsDefaultAttributes(variant
);
687 virtual void DoSetExpanderColumn() = 0 ;
688 virtual void DoSetIndent() = 0;
691 wxDataViewModel
*m_model
;
692 wxDataViewColumn
*m_expander_column
;
696 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase
)
699 // ----------------------------------------------------------------------------
700 // wxDataViewEvent - the event class for the wxDataViewCtrl notifications
701 // ----------------------------------------------------------------------------
703 class WXDLLIMPEXP_ADV wxDataViewEvent
: public wxNotifyEvent
706 wxDataViewEvent(wxEventType commandType
= wxEVT_NULL
, int winid
= 0)
707 : wxNotifyEvent(commandType
, winid
),
711 m_value(wxNullVariant
),
716 #if wxUSE_DRAG_AND_DROP
717 , m_dataObject(NULL
),
723 wxDataViewEvent(const wxDataViewEvent
& event
)
724 : wxNotifyEvent(event
),
725 m_item(event
.m_item
),
727 m_model(event
.m_model
),
728 m_value(event
.m_value
),
729 m_column(event
.m_column
),
731 m_cacheFrom(event
.m_cacheFrom
),
732 m_cacheTo(event
.m_cacheTo
)
733 #if wxUSE_DRAG_AND_DROP
734 , m_dataObject(event
.m_dataObject
),
735 m_dataFormat(event
.m_dataFormat
),
736 m_dataBuffer(event
.m_dataBuffer
),
737 m_dataSize(event
.m_dataSize
)
741 wxDataViewItem
GetItem() const { return m_item
; }
742 void SetItem( const wxDataViewItem
&item
) { m_item
= item
; }
744 int GetColumn() const { return m_col
; }
745 void SetColumn( int col
) { m_col
= col
; }
747 wxDataViewModel
* GetModel() const { return m_model
; }
748 void SetModel( wxDataViewModel
*model
) { m_model
= model
; }
750 const wxVariant
&GetValue() const { return m_value
; }
751 void SetValue( const wxVariant
&value
) { m_value
= value
; }
753 // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only
754 void SetDataViewColumn( wxDataViewColumn
*col
) { m_column
= col
; }
755 wxDataViewColumn
*GetDataViewColumn() const { return m_column
; }
757 // for wxEVT_DATAVIEW_CONTEXT_MENU only
758 wxPoint
GetPosition() const { return m_pos
; }
759 void SetPosition( int x
, int y
) { m_pos
.x
= x
; m_pos
.y
= y
; }
761 // For wxEVT_COMMAND_DATAVIEW_CACHE_HINT
762 int GetCacheFrom() const { return m_cacheFrom
; }
763 int GetCacheTo() const { return m_cacheTo
; }
764 void SetCache(int from
, int to
) { m_cacheFrom
= from
; m_cacheTo
= to
; }
767 #if wxUSE_DRAG_AND_DROP
768 // For drag operations
769 void SetDataObject( wxDataObject
*obj
) { m_dataObject
= obj
; }
770 wxDataObject
*GetDataObject() const { return m_dataObject
; }
772 // For drop operations
773 void SetDataFormat( const wxDataFormat
&format
) { m_dataFormat
= format
; }
774 wxDataFormat
GetDataFormat() const { return m_dataFormat
; }
775 void SetDataSize( size_t size
) { m_dataSize
= size
; }
776 size_t GetDataSize() const { return m_dataSize
; }
777 void SetDataBuffer( void* buf
) { m_dataBuffer
= buf
;}
778 void *GetDataBuffer() const { return m_dataBuffer
; }
779 #endif // wxUSE_DRAG_AND_DROP
781 virtual wxEvent
*Clone() const { return new wxDataViewEvent(*this); }
784 wxDataViewItem m_item
;
786 wxDataViewModel
*m_model
;
788 wxDataViewColumn
*m_column
;
793 #if wxUSE_DRAG_AND_DROP
794 wxDataObject
*m_dataObject
;
796 wxDataFormat m_dataFormat
;
799 #endif // wxUSE_DRAG_AND_DROP
802 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent
)
805 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED
, wxDataViewEvent
);
807 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED
, wxDataViewEvent
);
808 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED
, wxDataViewEvent
);
809 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED
, wxDataViewEvent
);
810 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING
, wxDataViewEvent
);
811 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING
, wxDataViewEvent
);
812 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING
, wxDataViewEvent
);
813 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED
, wxDataViewEvent
);
814 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE
, wxDataViewEvent
);
815 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED
, wxDataViewEvent
);
817 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU
, wxDataViewEvent
);
819 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK
, wxDataViewEvent
);
820 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK
, wxDataViewEvent
);
821 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED
, wxDataViewEvent
);
822 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED
, wxDataViewEvent
);
824 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_CACHE_HINT
, wxDataViewEvent
);
826 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG
, wxDataViewEvent
);
827 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE
, wxDataViewEvent
);
828 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_DROP
, wxDataViewEvent
);
830 typedef void (wxEvtHandler::*wxDataViewEventFunction
)(wxDataViewEvent
&);
832 #define wxDataViewEventHandler(func) \
833 wxEVENT_HANDLER_CAST(wxDataViewEventFunction, func)
835 #define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \
836 wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn))
838 #define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn)
840 #define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn)
841 #define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn)
842 #define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn)
843 #define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn)
844 #define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn)
845 #define EVT_DATAVIEW_ITEM_START_EDITING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_START_EDITING, id, fn)
846 #define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn)
847 #define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn)
848 #define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn)
850 #define EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_CONTEXT_MENU, id, fn)
852 #define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn)
853 #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn)
854 #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn)
855 #define EVT_DATAVIEW_COLUMN_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_REORDERED, id, fn)
856 #define EVT_DATAVIEW_CACHE_HINT(id, fn) wx__DECLARE_DATAVIEWEVT(CACHE_HINT, id, fn)
858 #define EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_BEGIN_DRAG, id, fn)
859 #define EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP_POSSIBLE, id, fn)
860 #define EVT_DATAVIEW_ITEM_DROP(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP, id, fn)
862 #ifdef wxHAS_GENERIC_DATAVIEWCTRL
863 #include "wx/generic/dataview.h"
864 #elif defined(__WXGTK20__)
865 #include "wx/gtk/dataview.h"
866 #elif defined(__WXMAC__)
867 #include "wx/osx/dataview.h"
869 #error "unknown native wxDataViewCtrl implementation"
872 //-----------------------------------------------------------------------------
873 // wxDataViewListStore
874 //-----------------------------------------------------------------------------
876 class WXDLLIMPEXP_ADV wxDataViewListStoreLine
879 wxDataViewListStoreLine( wxClientData
*data
= NULL
)
883 virtual ~wxDataViewListStoreLine()
888 void SetData( wxClientData
*data
)
889 { if (m_data
) delete m_data
; m_data
= data
; }
890 wxClientData
*GetData() const
893 wxVector
<wxVariant
> m_values
;
896 wxClientData
*m_data
;
900 class WXDLLIMPEXP_ADV wxDataViewListStore
: public wxDataViewIndexListModel
903 wxDataViewListStore();
904 ~wxDataViewListStore();
906 void PrependColumn( const wxString
&varianttype
);
907 void InsertColumn( unsigned int pos
, const wxString
&varianttype
);
908 void AppendColumn( const wxString
&varianttype
);
910 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
911 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
912 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
913 void DeleteItem( unsigned int pos
);
914 void DeleteAllItems();
916 // override base virtuals
918 virtual unsigned int GetColumnCount() const;
920 virtual wxString
GetColumnType( unsigned int col
) const;
922 virtual void GetValueByRow( wxVariant
&value
,
923 unsigned int row
, unsigned int col
) const;
925 virtual bool SetValueByRow( const wxVariant
&value
,
926 unsigned int row
, unsigned int col
);
930 wxVector
<wxDataViewListStoreLine
*> m_data
;
931 wxArrayString m_cols
;
934 //-----------------------------------------------------------------------------
936 class WXDLLIMPEXP_ADV wxDataViewListCtrl
: public wxDataViewCtrl
939 wxDataViewListCtrl();
940 wxDataViewListCtrl( wxWindow
*parent
, wxWindowID id
,
941 const wxPoint
& pos
= wxDefaultPosition
,
942 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
943 const wxValidator
& validator
= wxDefaultValidator
);
944 ~wxDataViewListCtrl();
946 bool Create( wxWindow
*parent
, wxWindowID id
,
947 const wxPoint
& pos
= wxDefaultPosition
,
948 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
949 const wxValidator
& validator
= wxDefaultValidator
);
951 wxDataViewListStore
*GetStore()
952 { return (wxDataViewListStore
*) GetModel(); }
953 const wxDataViewListStore
*GetStore() const
954 { return (const wxDataViewListStore
*) GetModel(); }
956 int ItemToRow(const wxDataViewItem
&item
) const
957 { return item
.IsOk() ? (int)GetStore()->GetRow(item
) : wxNOT_FOUND
; }
958 wxDataViewItem
RowToItem(int row
) const
959 { return row
== wxNOT_FOUND
? wxDataViewItem() : GetStore()->GetItem(row
); }
961 int GetSelectedRow() const
962 { return ItemToRow(GetSelection()); }
963 void SelectRow(unsigned row
)
964 { Select(RowToItem(row
)); }
965 void UnselectRow(unsigned row
)
966 { Unselect(RowToItem(row
)); }
967 bool IsRowSelected(unsigned row
) const
968 { return IsSelected(RowToItem(row
)); }
970 bool AppendColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
971 bool PrependColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
972 bool InsertColumn( unsigned int pos
, wxDataViewColumn
*column
, const wxString
&varianttype
);
974 // overridden from base class
975 virtual bool PrependColumn( wxDataViewColumn
*col
);
976 virtual bool InsertColumn( unsigned int pos
, wxDataViewColumn
*col
);
977 virtual bool AppendColumn( wxDataViewColumn
*col
);
979 wxDataViewColumn
*AppendTextColumn( const wxString
&label
,
980 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
981 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
982 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
,
983 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
984 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
985 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
,
986 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
987 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
988 wxDataViewColumn
*AppendIconTextColumn( const wxString
&label
,
989 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
990 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
992 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
993 { GetStore()->AppendItem( values
, data
); }
994 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
995 { GetStore()->PrependItem( values
, data
); }
996 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
997 { GetStore()->InsertItem( row
, values
, data
); }
998 void DeleteItem( unsigned row
)
999 { GetStore()->DeleteItem( row
); }
1000 void DeleteAllItems()
1001 { GetStore()->DeleteAllItems(); }
1003 void SetValue( const wxVariant
&value
, unsigned int row
, unsigned int col
)
1004 { GetStore()->SetValueByRow( value
, row
, col
);
1005 GetStore()->RowValueChanged( row
, col
); }
1006 void GetValue( wxVariant
&value
, unsigned int row
, unsigned int col
)
1007 { GetStore()->GetValueByRow( value
, row
, col
); }
1009 void SetTextValue( const wxString
&value
, unsigned int row
, unsigned int col
)
1010 { GetStore()->SetValueByRow( value
, row
, col
);
1011 GetStore()->RowValueChanged( row
, col
); }
1012 wxString
GetTextValue( unsigned int row
, unsigned int col
) const
1013 { wxVariant value
; GetStore()->GetValueByRow( value
, row
, col
); return value
.GetString(); }
1015 void SetToggleValue( bool value
, unsigned int row
, unsigned int col
)
1016 { GetStore()->SetValueByRow( value
, row
, col
);
1017 GetStore()->RowValueChanged( row
, col
); }
1018 bool GetToggleValue( unsigned int row
, unsigned int col
) const
1019 { wxVariant value
; GetStore()->GetValueByRow( value
, row
, col
); return value
.GetBool(); }
1021 void OnSize( wxSizeEvent
&event
);
1024 DECLARE_EVENT_TABLE()
1025 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewListCtrl
)
1028 //-----------------------------------------------------------------------------
1029 // wxDataViewTreeStore
1030 //-----------------------------------------------------------------------------
1032 class WXDLLIMPEXP_ADV wxDataViewTreeStoreNode
1035 wxDataViewTreeStoreNode( wxDataViewTreeStoreNode
*parent
,
1036 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1037 virtual ~wxDataViewTreeStoreNode();
1039 void SetText( const wxString
&text
)
1041 wxString
GetText() const
1043 void SetIcon( const wxIcon
&icon
)
1045 const wxIcon
&GetIcon() const
1047 void SetData( wxClientData
*data
)
1048 { if (m_data
) delete m_data
; m_data
= data
; }
1049 wxClientData
*GetData() const
1052 wxDataViewItem
GetItem() const
1053 { return wxDataViewItem( (void*) this ); }
1055 virtual bool IsContainer()
1058 wxDataViewTreeStoreNode
*GetParent()
1059 { return m_parent
; }
1062 wxDataViewTreeStoreNode
*m_parent
;
1065 wxClientData
*m_data
;
1068 WX_DECLARE_LIST_WITH_DECL(wxDataViewTreeStoreNode
, wxDataViewTreeStoreNodeList
,
1069 class WXDLLIMPEXP_ADV
);
1071 class WXDLLIMPEXP_ADV wxDataViewTreeStoreContainerNode
: public wxDataViewTreeStoreNode
1074 wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode
*parent
,
1075 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1076 wxClientData
*data
= NULL
);
1077 virtual ~wxDataViewTreeStoreContainerNode();
1079 const wxDataViewTreeStoreNodeList
&GetChildren() const
1080 { return m_children
; }
1081 wxDataViewTreeStoreNodeList
&GetChildren()
1082 { return m_children
; }
1084 void SetExpandedIcon( const wxIcon
&icon
)
1085 { m_iconExpanded
= icon
; }
1086 const wxIcon
&GetExpandedIcon() const
1087 { return m_iconExpanded
; }
1089 void SetExpanded( bool expanded
= true )
1090 { m_isExpanded
= expanded
; }
1091 bool IsExpanded() const
1092 { return m_isExpanded
; }
1094 virtual bool IsContainer()
1098 wxDataViewTreeStoreNodeList m_children
;
1099 wxIcon m_iconExpanded
;
1103 //-----------------------------------------------------------------------------
1105 class WXDLLIMPEXP_ADV wxDataViewTreeStore
: public wxDataViewModel
1108 wxDataViewTreeStore();
1109 ~wxDataViewTreeStore();
1111 wxDataViewItem
AppendItem( const wxDataViewItem
& parent
,
1112 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1113 wxDataViewItem
PrependItem( const wxDataViewItem
& parent
,
1114 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1115 wxDataViewItem
InsertItem( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1116 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1118 wxDataViewItem
PrependContainer( const wxDataViewItem
& parent
,
1119 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1120 wxClientData
*data
= NULL
);
1121 wxDataViewItem
AppendContainer( const wxDataViewItem
& parent
,
1122 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1123 wxClientData
*data
= NULL
);
1124 wxDataViewItem
InsertContainer( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1125 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1126 wxClientData
*data
= NULL
);
1128 wxDataViewItem
GetNthChild( const wxDataViewItem
& parent
, unsigned int pos
) const;
1129 int GetChildCount( const wxDataViewItem
& parent
) const;
1131 void SetItemText( const wxDataViewItem
& item
, const wxString
&text
);
1132 wxString
GetItemText( const wxDataViewItem
& item
) const;
1133 void SetItemIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1134 const wxIcon
&GetItemIcon( const wxDataViewItem
& item
) const;
1135 void SetItemExpandedIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1136 const wxIcon
&GetItemExpandedIcon( const wxDataViewItem
& item
) const;
1137 void SetItemData( const wxDataViewItem
& item
, wxClientData
*data
);
1138 wxClientData
*GetItemData( const wxDataViewItem
& item
) const;
1140 void DeleteItem( const wxDataViewItem
& item
);
1141 void DeleteChildren( const wxDataViewItem
& item
);
1142 void DeleteAllItems();
1144 // implement base methods
1146 virtual void GetValue( wxVariant
&variant
,
1147 const wxDataViewItem
&item
, unsigned int col
) const;
1148 virtual bool SetValue( const wxVariant
&variant
,
1149 const wxDataViewItem
&item
, unsigned int col
);
1150 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const;
1151 virtual bool IsContainer( const wxDataViewItem
&item
) const;
1152 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
1154 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
1155 unsigned int column
, bool ascending
) const;
1157 virtual bool HasDefaultCompare() const
1159 virtual unsigned int GetColumnCount() const
1161 virtual wxString
GetColumnType( unsigned int WXUNUSED(col
) ) const
1162 { return wxT("wxDataViewIconText"); }
1164 wxDataViewTreeStoreNode
*FindNode( const wxDataViewItem
&item
) const;
1165 wxDataViewTreeStoreContainerNode
*FindContainerNode( const wxDataViewItem
&item
) const;
1166 wxDataViewTreeStoreNode
*GetRoot() const { return m_root
; }
1169 wxDataViewTreeStoreNode
*m_root
;
1172 //-----------------------------------------------------------------------------
1174 class WXDLLIMPEXP_ADV wxDataViewTreeCtrl
: public wxDataViewCtrl
1177 wxDataViewTreeCtrl() { Init(); }
1178 wxDataViewTreeCtrl(wxWindow
*parent
,
1180 const wxPoint
& pos
= wxDefaultPosition
,
1181 const wxSize
& size
= wxDefaultSize
,
1182 long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
1183 const wxValidator
& validator
= wxDefaultValidator
)
1187 Create(parent
, id
, pos
, size
, style
, validator
);
1190 virtual ~wxDataViewTreeCtrl();
1192 bool Create(wxWindow
*parent
,
1194 const wxPoint
& pos
= wxDefaultPosition
,
1195 const wxSize
& size
= wxDefaultSize
,
1196 long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
1197 const wxValidator
& validator
= wxDefaultValidator
);
1199 wxDataViewTreeStore
*GetStore()
1200 { return (wxDataViewTreeStore
*) GetModel(); }
1201 const wxDataViewTreeStore
*GetStore() const
1202 { return (const wxDataViewTreeStore
*) GetModel(); }
1204 bool IsContainer( const wxDataViewItem
& item
) const
1205 { return GetStore()->IsContainer(item
); }
1207 void SetImageList( wxImageList
*imagelist
);
1208 wxImageList
* GetImageList() { return m_imageList
; }
1210 wxDataViewItem
AppendItem( const wxDataViewItem
& parent
,
1211 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1212 wxDataViewItem
PrependItem( const wxDataViewItem
& parent
,
1213 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1214 wxDataViewItem
InsertItem( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1215 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1217 wxDataViewItem
PrependContainer( const wxDataViewItem
& parent
,
1218 const wxString
&text
, int icon
= -1, int expanded
= -1,
1219 wxClientData
*data
= NULL
);
1220 wxDataViewItem
AppendContainer( const wxDataViewItem
& parent
,
1221 const wxString
&text
, int icon
= -1, int expanded
= -1,
1222 wxClientData
*data
= NULL
);
1223 wxDataViewItem
InsertContainer( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1224 const wxString
&text
, int icon
= -1, int expanded
= -1,
1225 wxClientData
*data
= NULL
);
1227 wxDataViewItem
GetNthChild( const wxDataViewItem
& parent
, unsigned int pos
) const
1228 { return GetStore()->GetNthChild(parent
, pos
); }
1229 int GetChildCount( const wxDataViewItem
& parent
) const
1230 { return GetStore()->GetChildCount(parent
); }
1232 void SetItemText( const wxDataViewItem
& item
, const wxString
&text
);
1233 wxString
GetItemText( const wxDataViewItem
& item
) const
1234 { return GetStore()->GetItemText(item
); }
1235 void SetItemIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1236 const wxIcon
&GetItemIcon( const wxDataViewItem
& item
) const
1237 { return GetStore()->GetItemIcon(item
); }
1238 void SetItemExpandedIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1239 const wxIcon
&GetItemExpandedIcon( const wxDataViewItem
& item
) const
1240 { return GetStore()->GetItemExpandedIcon(item
); }
1241 void SetItemData( const wxDataViewItem
& item
, wxClientData
*data
)
1242 { GetStore()->SetItemData(item
,data
); }
1243 wxClientData
*GetItemData( const wxDataViewItem
& item
) const
1244 { return GetStore()->GetItemData(item
); }
1246 void DeleteItem( const wxDataViewItem
& item
);
1247 void DeleteChildren( const wxDataViewItem
& item
);
1248 void DeleteAllItems();
1250 void OnExpanded( wxDataViewEvent
&event
);
1251 void OnCollapsed( wxDataViewEvent
&event
);
1252 void OnSize( wxSizeEvent
&event
);
1260 wxImageList
*m_imageList
;
1263 DECLARE_EVENT_TABLE()
1264 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl
)
1267 #endif // wxUSE_DATAVIEWCTRL
1270 // _WX_DATAVIEW_H_BASE_