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 // some platforms, such as GTK+, may need a two step procedure for ::Reset()
130 virtual bool BeforeReset() { return true; }
131 virtual bool AfterReset() { return Cleared(); }
133 virtual void Resort() = 0;
135 void SetOwner( wxDataViewModel
*owner
) { m_owner
= owner
; }
136 wxDataViewModel
*GetOwner() const { return m_owner
; }
139 wxDataViewModel
*m_owner
;
144 // ----------------------------------------------------------------------------
145 // wxDataViewItemAttr: a structure containing the visual attributes of an item
146 // ----------------------------------------------------------------------------
148 // TODO: this should be renamed to wxItemAttr or something general like this
150 class WXDLLIMPEXP_ADV wxDataViewItemAttr
161 void SetColour(const wxColour
& colour
) { m_colour
= colour
; }
162 void SetBold( bool set
) { m_bold
= set
; }
163 void SetItalic( bool set
) { m_italic
= set
; }
166 bool HasColour() const { return m_colour
.Ok(); }
167 const wxColour
& GetColour() const { return m_colour
; }
169 bool HasFont() const { return m_bold
|| m_italic
; }
170 bool GetBold() const { return m_bold
; }
171 bool GetItalic() const { return m_italic
; }
173 bool IsDefault() const { return !(HasColour() || HasFont()); }
182 // ---------------------------------------------------------
184 // ---------------------------------------------------------
186 WX_DECLARE_LIST_WITH_DECL(wxDataViewModelNotifier
, wxDataViewModelNotifiers
,
187 class WXDLLIMPEXP_ADV
);
189 class WXDLLIMPEXP_ADV wxDataViewModel
: public wxRefCounter
194 virtual unsigned int GetColumnCount() const = 0;
196 // return type as reported by wxVariant
197 virtual wxString
GetColumnType( unsigned int col
) const = 0;
199 // get value into a wxVariant
200 virtual void GetValue( wxVariant
&variant
,
201 const wxDataViewItem
&item
, unsigned int col
) const = 0;
203 // return true if the given item has a value to display in the given
204 // column: this is always true except for container items which by default
205 // only show their label in the first column (but see HasContainerColumns())
206 bool HasValue(const wxDataViewItem
& item
, unsigned col
) const
208 return col
== 0 || !IsContainer(item
) || HasContainerColumns(item
);
211 // usually ValueChanged() should be called after changing the value in the
212 // model to update the control, ChangeValue() does it on its own while
213 // SetValue() does not -- so while you will override SetValue(), you should
214 // be usually calling ChangeValue()
215 virtual bool SetValue(const wxVariant
&variant
,
216 const wxDataViewItem
&item
,
217 unsigned int col
) = 0;
219 bool ChangeValue(const wxVariant
& variant
,
220 const wxDataViewItem
& item
,
223 return SetValue(variant
, item
, col
) && ValueChanged(item
, col
);
226 // Get text attribute, return false of default attributes should be used
227 virtual bool GetAttr(const wxDataViewItem
&WXUNUSED(item
),
228 unsigned int WXUNUSED(col
),
229 wxDataViewItemAttr
&WXUNUSED(attr
)) const
235 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const = 0;
236 virtual bool IsContainer( const wxDataViewItem
&item
) const = 0;
237 // Is the container just a header or an item with all columns
238 virtual bool HasContainerColumns(const wxDataViewItem
& WXUNUSED(item
)) const
240 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const = 0;
242 // delegated notifiers
243 bool ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
244 bool ItemsAdded( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
245 bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
246 bool ItemsDeleted( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
247 bool ItemChanged( const wxDataViewItem
&item
);
248 bool ItemsChanged( const wxDataViewItemArray
&items
);
249 bool ValueChanged( const wxDataViewItem
&item
, unsigned int col
);
252 // some platforms, such as GTK+, may need a two step procedure for ::Reset()
258 virtual void Resort();
260 void AddNotifier( wxDataViewModelNotifier
*notifier
);
261 void RemoveNotifier( wxDataViewModelNotifier
*notifier
);
263 // default compare function
264 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
265 unsigned int column
, bool ascending
) const;
266 virtual bool HasDefaultCompare() const { return false; }
269 virtual bool IsListModel() const { return false; }
270 virtual bool IsVirtualListModel() const { return false; }
273 // the user should not delete this class directly: he should use DecRef() instead!
274 virtual ~wxDataViewModel() { }
276 wxDataViewModelNotifiers m_notifiers
;
279 // ----------------------------------------------------------------------------
280 // wxDataViewListModel: a model of a list, i.e. flat data structure without any
281 // branches/containers, used as base class by wxDataViewIndexListModel and
282 // wxDataViewVirtualListModel
283 // ----------------------------------------------------------------------------
285 class WXDLLIMPEXP_ADV wxDataViewListModel
: public wxDataViewModel
288 // derived classes should override these methods instead of
289 // {Get,Set}Value() and GetAttr() inherited from the base class
291 virtual void GetValueByRow(wxVariant
&variant
,
292 unsigned row
, unsigned col
) const = 0;
294 virtual bool SetValueByRow(const wxVariant
&variant
,
295 unsigned row
, unsigned col
) = 0;
298 GetAttrByRow(unsigned WXUNUSED(row
), unsigned WXUNUSED(col
),
299 wxDataViewItemAttr
&WXUNUSED(attr
)) const
305 // helper methods provided by list models only
306 virtual unsigned GetRow( const wxDataViewItem
&item
) const = 0;
308 // returns the number of rows
309 virtual unsigned int GetCount() const = 0;
311 // implement some base class pure virtual directly
312 virtual wxDataViewItem
313 GetParent( const wxDataViewItem
& WXUNUSED(item
) ) const
315 // items never have valid parent in this model
316 return wxDataViewItem();
319 virtual bool IsContainer( const wxDataViewItem
&item
) const
321 // only the invisible (and invalid) root item has children
325 // and implement some others by forwarding them to our own ones
326 virtual void GetValue( wxVariant
&variant
,
327 const wxDataViewItem
&item
, unsigned int col
) const
329 GetValueByRow(variant
, GetRow(item
), col
);
332 virtual bool SetValue( const wxVariant
&variant
,
333 const wxDataViewItem
&item
, unsigned int col
)
335 return SetValueByRow( variant
, GetRow(item
), col
);
338 virtual bool GetAttr(const wxDataViewItem
&item
, unsigned int col
,
339 wxDataViewItemAttr
&attr
) const
341 return GetAttrByRow( GetRow(item
), col
, attr
);
345 virtual bool IsListModel() const { return true; }
348 // ---------------------------------------------------------
349 // wxDataViewIndexListModel
350 // ---------------------------------------------------------
352 class WXDLLIMPEXP_ADV wxDataViewIndexListModel
: public wxDataViewListModel
355 wxDataViewIndexListModel( unsigned int initial_size
= 0 );
358 void RowInserted( unsigned int before
);
360 void RowDeleted( unsigned int row
);
361 void RowsDeleted( const wxArrayInt
&rows
);
362 void RowChanged( unsigned int row
);
363 void RowValueChanged( unsigned int row
, unsigned int col
);
364 void Reset( unsigned int new_size
);
366 // convert to/from row/wxDataViewItem
368 virtual unsigned GetRow( const wxDataViewItem
&item
) const;
369 wxDataViewItem
GetItem( unsigned int row
) const;
371 // compare based on index
373 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
374 unsigned int column
, bool ascending
) const;
375 virtual bool HasDefaultCompare() const;
377 // implement base methods
378 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
380 unsigned int GetCount() const { return m_hash
.GetCount(); }
383 wxDataViewItemArray m_hash
;
384 unsigned int m_nextFreeID
;
388 // ---------------------------------------------------------
389 // wxDataViewVirtualListModel
390 // ---------------------------------------------------------
393 // better than nothing
394 typedef wxDataViewIndexListModel wxDataViewVirtualListModel
;
397 class WXDLLIMPEXP_ADV wxDataViewVirtualListModel
: public wxDataViewListModel
400 wxDataViewVirtualListModel( unsigned int initial_size
= 0 );
403 void RowInserted( unsigned int before
);
405 void RowDeleted( unsigned int row
);
406 void RowsDeleted( const wxArrayInt
&rows
);
407 void RowChanged( unsigned int row
);
408 void RowValueChanged( unsigned int row
, unsigned int col
);
409 void Reset( unsigned int new_size
);
411 // convert to/from row/wxDataViewItem
413 virtual unsigned GetRow( const wxDataViewItem
&item
) const;
414 wxDataViewItem
GetItem( unsigned int row
) const;
416 // compare based on index
418 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
419 unsigned int column
, bool ascending
) const;
420 virtual bool HasDefaultCompare() const;
422 // implement base methods
423 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
425 unsigned int GetCount() const { return m_size
; }
428 virtual bool IsVirtualListModel() const { return true; }
436 // ----------------------------------------------------------------------------
437 // wxDataViewRenderer and related classes
438 // ----------------------------------------------------------------------------
440 #include "wx/dvrenderers.h"
442 // ---------------------------------------------------------
443 // wxDataViewColumnBase
444 // ---------------------------------------------------------
446 // for compatibility only, do not use
447 enum wxDataViewColumnFlags
449 wxDATAVIEW_COL_RESIZABLE
= wxCOL_RESIZABLE
,
450 wxDATAVIEW_COL_SORTABLE
= wxCOL_SORTABLE
,
451 wxDATAVIEW_COL_REORDERABLE
= wxCOL_REORDERABLE
,
452 wxDATAVIEW_COL_HIDDEN
= wxCOL_HIDDEN
455 class WXDLLIMPEXP_ADV wxDataViewColumnBase
: public wxSettableHeaderColumn
458 // ctor for the text columns: takes ownership of renderer
459 wxDataViewColumnBase(wxDataViewRenderer
*renderer
,
460 unsigned int model_column
)
462 Init(renderer
, model_column
);
465 // ctor for the bitmap columns
466 wxDataViewColumnBase(const wxBitmap
& bitmap
,
467 wxDataViewRenderer
*renderer
,
468 unsigned int model_column
)
471 Init(renderer
, model_column
);
474 virtual ~wxDataViewColumnBase();
477 virtual void SetOwner( wxDataViewCtrl
*owner
)
481 unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column
); }
482 wxDataViewCtrl
*GetOwner() const { return m_owner
; }
483 wxDataViewRenderer
* GetRenderer() const { return m_renderer
; }
485 // implement some of base class pure virtuals (the rest is port-dependent
486 // and done differently in generic and native versions)
487 virtual void SetBitmap( const wxBitmap
& bitmap
) { m_bitmap
= bitmap
; }
488 virtual wxBitmap
GetBitmap() const { return m_bitmap
; }
491 wxDataViewRenderer
*m_renderer
;
494 wxDataViewCtrl
*m_owner
;
497 // common part of all ctors
498 void Init(wxDataViewRenderer
*renderer
, unsigned int model_column
);
501 // ---------------------------------------------------------
502 // wxDataViewCtrlBase
503 // ---------------------------------------------------------
505 #define wxDV_SINGLE 0x0000 // for convenience
506 #define wxDV_MULTIPLE 0x0001 // can select multiple items
508 #define wxDV_NO_HEADER 0x0002 // column titles not visible
509 #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows
510 #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns
512 #define wxDV_ROW_LINES 0x0010 // alternating colour in rows
513 #define wxDV_VARIABLE_LINE_HEIGHT 0x0020 // variable line height
515 class WXDLLIMPEXP_ADV wxDataViewCtrlBase
: public wxControl
518 wxDataViewCtrlBase();
519 virtual ~wxDataViewCtrlBase();
524 virtual bool AssociateModel( wxDataViewModel
*model
);
525 wxDataViewModel
* GetModel();
526 const wxDataViewModel
* GetModel() const;
532 wxDataViewColumn
*PrependTextColumn( const wxString
&label
, unsigned int model_column
,
533 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
534 wxAlignment align
= wxALIGN_NOT
,
535 int flags
= wxDATAVIEW_COL_RESIZABLE
);
536 wxDataViewColumn
*PrependIconTextColumn( const wxString
&label
, unsigned int model_column
,
537 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
538 wxAlignment align
= wxALIGN_NOT
,
539 int flags
= wxDATAVIEW_COL_RESIZABLE
);
540 wxDataViewColumn
*PrependToggleColumn( const wxString
&label
, unsigned int model_column
,
541 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
542 wxAlignment align
= wxALIGN_CENTER
,
543 int flags
= wxDATAVIEW_COL_RESIZABLE
);
544 wxDataViewColumn
*PrependProgressColumn( const wxString
&label
, unsigned int model_column
,
545 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
546 wxAlignment align
= wxALIGN_CENTER
,
547 int flags
= wxDATAVIEW_COL_RESIZABLE
);
548 wxDataViewColumn
*PrependDateColumn( const wxString
&label
, unsigned int model_column
,
549 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
550 wxAlignment align
= wxALIGN_NOT
,
551 int flags
= wxDATAVIEW_COL_RESIZABLE
);
552 wxDataViewColumn
*PrependBitmapColumn( const wxString
&label
, unsigned int model_column
,
553 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
554 wxAlignment align
= wxALIGN_CENTER
,
555 int flags
= wxDATAVIEW_COL_RESIZABLE
);
556 wxDataViewColumn
*PrependTextColumn( const wxBitmap
&label
, unsigned int model_column
,
557 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
558 wxAlignment align
= wxALIGN_NOT
,
559 int flags
= wxDATAVIEW_COL_RESIZABLE
);
560 wxDataViewColumn
*PrependIconTextColumn( const wxBitmap
&label
, unsigned int model_column
,
561 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
562 wxAlignment align
= wxALIGN_NOT
,
563 int flags
= wxDATAVIEW_COL_RESIZABLE
);
564 wxDataViewColumn
*PrependToggleColumn( const wxBitmap
&label
, unsigned int model_column
,
565 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
566 wxAlignment align
= wxALIGN_CENTER
,
567 int flags
= wxDATAVIEW_COL_RESIZABLE
);
568 wxDataViewColumn
*PrependProgressColumn( const wxBitmap
&label
, unsigned int model_column
,
569 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
570 wxAlignment align
= wxALIGN_CENTER
,
571 int flags
= wxDATAVIEW_COL_RESIZABLE
);
572 wxDataViewColumn
*PrependDateColumn( const wxBitmap
&label
, unsigned int model_column
,
573 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
574 wxAlignment align
= wxALIGN_NOT
,
575 int flags
= wxDATAVIEW_COL_RESIZABLE
);
576 wxDataViewColumn
*PrependBitmapColumn( const wxBitmap
&label
, unsigned int model_column
,
577 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
578 wxAlignment align
= wxALIGN_CENTER
,
579 int flags
= wxDATAVIEW_COL_RESIZABLE
);
581 wxDataViewColumn
*AppendTextColumn( const wxString
&label
, unsigned int model_column
,
582 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
583 wxAlignment align
= wxALIGN_NOT
,
584 int flags
= wxDATAVIEW_COL_RESIZABLE
);
585 wxDataViewColumn
*AppendIconTextColumn( const wxString
&label
, unsigned int model_column
,
586 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
587 wxAlignment align
= wxALIGN_NOT
,
588 int flags
= wxDATAVIEW_COL_RESIZABLE
);
589 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
, unsigned int model_column
,
590 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
591 wxAlignment align
= wxALIGN_CENTER
,
592 int flags
= wxDATAVIEW_COL_RESIZABLE
);
593 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
, unsigned int model_column
,
594 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
595 wxAlignment align
= wxALIGN_CENTER
,
596 int flags
= wxDATAVIEW_COL_RESIZABLE
);
597 wxDataViewColumn
*AppendDateColumn( const wxString
&label
, unsigned int model_column
,
598 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
599 wxAlignment align
= wxALIGN_NOT
,
600 int flags
= wxDATAVIEW_COL_RESIZABLE
);
601 wxDataViewColumn
*AppendBitmapColumn( const wxString
&label
, unsigned int model_column
,
602 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
603 wxAlignment align
= wxALIGN_CENTER
,
604 int flags
= wxDATAVIEW_COL_RESIZABLE
);
605 wxDataViewColumn
*AppendTextColumn( const wxBitmap
&label
, unsigned int model_column
,
606 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
607 wxAlignment align
= wxALIGN_NOT
,
608 int flags
= wxDATAVIEW_COL_RESIZABLE
);
609 wxDataViewColumn
*AppendIconTextColumn( const wxBitmap
&label
, unsigned int model_column
,
610 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
611 wxAlignment align
= wxALIGN_NOT
,
612 int flags
= wxDATAVIEW_COL_RESIZABLE
);
613 wxDataViewColumn
*AppendToggleColumn( const wxBitmap
&label
, unsigned int model_column
,
614 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
615 wxAlignment align
= wxALIGN_CENTER
,
616 int flags
= wxDATAVIEW_COL_RESIZABLE
);
617 wxDataViewColumn
*AppendProgressColumn( const wxBitmap
&label
, unsigned int model_column
,
618 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
619 wxAlignment align
= wxALIGN_CENTER
,
620 int flags
= wxDATAVIEW_COL_RESIZABLE
);
621 wxDataViewColumn
*AppendDateColumn( const wxBitmap
&label
, unsigned int model_column
,
622 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
623 wxAlignment align
= wxALIGN_NOT
,
624 int flags
= wxDATAVIEW_COL_RESIZABLE
);
625 wxDataViewColumn
*AppendBitmapColumn( const wxBitmap
&label
, unsigned int model_column
,
626 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
627 wxAlignment align
= wxALIGN_CENTER
,
628 int flags
= wxDATAVIEW_COL_RESIZABLE
);
630 virtual bool PrependColumn( wxDataViewColumn
*col
);
631 virtual bool InsertColumn( unsigned int pos
, wxDataViewColumn
*col
);
632 virtual bool AppendColumn( wxDataViewColumn
*col
);
634 virtual unsigned int GetColumnCount() const = 0;
635 virtual wxDataViewColumn
* GetColumn( unsigned int pos
) const = 0;
636 virtual int GetColumnPosition( const wxDataViewColumn
*column
) const = 0;
638 virtual bool DeleteColumn( wxDataViewColumn
*column
) = 0;
639 virtual bool ClearColumns() = 0;
641 void SetExpanderColumn( wxDataViewColumn
*col
)
642 { m_expander_column
= col
; DoSetExpanderColumn(); }
643 wxDataViewColumn
*GetExpanderColumn() const
644 { return m_expander_column
; }
646 virtual wxDataViewColumn
*GetSortingColumn() const = 0;
652 void SetIndent( int indent
)
653 { m_indent
= indent
; DoSetIndent(); }
654 int GetIndent() const
657 // Current item is the one used by the keyboard navigation, it is the same
658 // as the (unique) selected item in single selection mode so these
659 // functions are mostly useful for controls with wxDV_MULTIPLE style.
660 wxDataViewItem
GetCurrentItem() const;
661 void SetCurrentItem(const wxDataViewItem
& item
);
663 virtual wxDataViewItem
GetSelection() const = 0;
664 virtual int GetSelections( wxDataViewItemArray
& sel
) const = 0;
665 virtual void SetSelections( const wxDataViewItemArray
& sel
) = 0;
666 virtual void Select( const wxDataViewItem
& item
) = 0;
667 virtual void Unselect( const wxDataViewItem
& item
) = 0;
668 virtual bool IsSelected( const wxDataViewItem
& item
) const = 0;
670 virtual void SelectAll() = 0;
671 virtual void UnselectAll() = 0;
673 virtual void Expand( const wxDataViewItem
& item
) = 0;
674 virtual void ExpandAncestors( const wxDataViewItem
& item
);
675 virtual void Collapse( const wxDataViewItem
& item
) = 0;
676 virtual bool IsExpanded( const wxDataViewItem
& item
) const = 0;
678 virtual void EnsureVisible( const wxDataViewItem
& item
,
679 const wxDataViewColumn
*column
= NULL
) = 0;
680 virtual void HitTest( const wxPoint
& point
, wxDataViewItem
&item
, wxDataViewColumn
* &column
) const = 0;
681 virtual wxRect
GetItemRect( const wxDataViewItem
& item
, const wxDataViewColumn
*column
= NULL
) const = 0;
683 #if wxUSE_DRAG_AND_DROP
684 virtual bool EnableDragSource(const wxDataFormat
& WXUNUSED(format
))
686 virtual bool EnableDropTarget(const wxDataFormat
& WXUNUSED(format
))
688 #endif // wxUSE_DRAG_AND_DROP
690 // define control visual attributes
691 // --------------------------------
693 virtual wxVisualAttributes
GetDefaultAttributes() const
695 return GetClassDefaultAttributes(GetWindowVariant());
698 static wxVisualAttributes
699 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
)
701 return wxControl::GetCompositeControlsDefaultAttributes(variant
);
705 virtual void DoSetExpanderColumn() = 0 ;
706 virtual void DoSetIndent() = 0;
709 // Implementation of the public Set/GetCurrentItem() methods which are only
710 // called in multi selection case (for single selection controls their
711 // implementation is trivial and is done in the base class itself).
712 virtual wxDataViewItem
DoGetCurrentItem() const = 0;
713 virtual void DoSetCurrentItem(const wxDataViewItem
& item
) = 0;
715 wxDataViewModel
*m_model
;
716 wxDataViewColumn
*m_expander_column
;
720 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase
)
723 // ----------------------------------------------------------------------------
724 // wxDataViewEvent - the event class for the wxDataViewCtrl notifications
725 // ----------------------------------------------------------------------------
727 class WXDLLIMPEXP_ADV wxDataViewEvent
: public wxNotifyEvent
730 wxDataViewEvent(wxEventType commandType
= wxEVT_NULL
, int winid
= 0)
731 : wxNotifyEvent(commandType
, winid
),
735 m_value(wxNullVariant
),
740 #if wxUSE_DRAG_AND_DROP
741 , m_dataObject(NULL
),
747 wxDataViewEvent(const wxDataViewEvent
& event
)
748 : wxNotifyEvent(event
),
749 m_item(event
.m_item
),
751 m_model(event
.m_model
),
752 m_value(event
.m_value
),
753 m_column(event
.m_column
),
755 m_cacheFrom(event
.m_cacheFrom
),
756 m_cacheTo(event
.m_cacheTo
)
757 #if wxUSE_DRAG_AND_DROP
758 , m_dataObject(event
.m_dataObject
),
759 m_dataFormat(event
.m_dataFormat
),
760 m_dataBuffer(event
.m_dataBuffer
),
761 m_dataSize(event
.m_dataSize
)
765 wxDataViewItem
GetItem() const { return m_item
; }
766 void SetItem( const wxDataViewItem
&item
) { m_item
= item
; }
768 int GetColumn() const { return m_col
; }
769 void SetColumn( int col
) { m_col
= col
; }
771 wxDataViewModel
* GetModel() const { return m_model
; }
772 void SetModel( wxDataViewModel
*model
) { m_model
= model
; }
774 const wxVariant
&GetValue() const { return m_value
; }
775 void SetValue( const wxVariant
&value
) { m_value
= value
; }
777 // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only
778 void SetDataViewColumn( wxDataViewColumn
*col
) { m_column
= col
; }
779 wxDataViewColumn
*GetDataViewColumn() const { return m_column
; }
781 // for wxEVT_DATAVIEW_CONTEXT_MENU only
782 wxPoint
GetPosition() const { return m_pos
; }
783 void SetPosition( int x
, int y
) { m_pos
.x
= x
; m_pos
.y
= y
; }
785 // For wxEVT_COMMAND_DATAVIEW_CACHE_HINT
786 int GetCacheFrom() const { return m_cacheFrom
; }
787 int GetCacheTo() const { return m_cacheTo
; }
788 void SetCache(int from
, int to
) { m_cacheFrom
= from
; m_cacheTo
= to
; }
791 #if wxUSE_DRAG_AND_DROP
792 // For drag operations
793 void SetDataObject( wxDataObject
*obj
) { m_dataObject
= obj
; }
794 wxDataObject
*GetDataObject() const { return m_dataObject
; }
796 // For drop operations
797 void SetDataFormat( const wxDataFormat
&format
) { m_dataFormat
= format
; }
798 wxDataFormat
GetDataFormat() const { return m_dataFormat
; }
799 void SetDataSize( size_t size
) { m_dataSize
= size
; }
800 size_t GetDataSize() const { return m_dataSize
; }
801 void SetDataBuffer( void* buf
) { m_dataBuffer
= buf
;}
802 void *GetDataBuffer() const { return m_dataBuffer
; }
803 #endif // wxUSE_DRAG_AND_DROP
805 virtual wxEvent
*Clone() const { return new wxDataViewEvent(*this); }
808 wxDataViewItem m_item
;
810 wxDataViewModel
*m_model
;
812 wxDataViewColumn
*m_column
;
817 #if wxUSE_DRAG_AND_DROP
818 wxDataObject
*m_dataObject
;
820 wxDataFormat m_dataFormat
;
823 #endif // wxUSE_DRAG_AND_DROP
826 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent
)
829 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED
, wxDataViewEvent
);
831 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED
, wxDataViewEvent
);
832 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED
, wxDataViewEvent
);
833 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED
, wxDataViewEvent
);
834 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING
, wxDataViewEvent
);
835 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING
, wxDataViewEvent
);
836 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING
, wxDataViewEvent
);
837 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED
, wxDataViewEvent
);
838 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE
, wxDataViewEvent
);
839 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED
, wxDataViewEvent
);
841 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU
, wxDataViewEvent
);
843 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK
, wxDataViewEvent
);
844 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK
, wxDataViewEvent
);
845 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED
, wxDataViewEvent
);
846 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED
, wxDataViewEvent
);
848 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_CACHE_HINT
, wxDataViewEvent
);
850 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG
, wxDataViewEvent
);
851 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE
, wxDataViewEvent
);
852 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_DROP
, wxDataViewEvent
);
854 typedef void (wxEvtHandler::*wxDataViewEventFunction
)(wxDataViewEvent
&);
856 #define wxDataViewEventHandler(func) \
857 wxEVENT_HANDLER_CAST(wxDataViewEventFunction, func)
859 #define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \
860 wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn))
862 #define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn)
864 #define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn)
865 #define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn)
866 #define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn)
867 #define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn)
868 #define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn)
869 #define EVT_DATAVIEW_ITEM_START_EDITING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_START_EDITING, id, fn)
870 #define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn)
871 #define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn)
872 #define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn)
874 #define EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_CONTEXT_MENU, id, fn)
876 #define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn)
877 #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn)
878 #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn)
879 #define EVT_DATAVIEW_COLUMN_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_REORDERED, id, fn)
880 #define EVT_DATAVIEW_CACHE_HINT(id, fn) wx__DECLARE_DATAVIEWEVT(CACHE_HINT, id, fn)
882 #define EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_BEGIN_DRAG, id, fn)
883 #define EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP_POSSIBLE, id, fn)
884 #define EVT_DATAVIEW_ITEM_DROP(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP, id, fn)
886 #ifdef wxHAS_GENERIC_DATAVIEWCTRL
887 #include "wx/generic/dataview.h"
888 #elif defined(__WXGTK20__)
889 #include "wx/gtk/dataview.h"
890 #elif defined(__WXMAC__)
891 #include "wx/osx/dataview.h"
893 #error "unknown native wxDataViewCtrl implementation"
896 //-----------------------------------------------------------------------------
897 // wxDataViewListStore
898 //-----------------------------------------------------------------------------
900 class WXDLLIMPEXP_ADV wxDataViewListStoreLine
903 wxDataViewListStoreLine( wxClientData
*data
= NULL
)
907 virtual ~wxDataViewListStoreLine()
912 void SetData( wxClientData
*data
)
913 { if (m_data
) delete m_data
; m_data
= data
; }
914 wxClientData
*GetData() const
917 wxVector
<wxVariant
> m_values
;
920 wxClientData
*m_data
;
924 class WXDLLIMPEXP_ADV wxDataViewListStore
: public wxDataViewIndexListModel
927 wxDataViewListStore();
928 ~wxDataViewListStore();
930 void PrependColumn( const wxString
&varianttype
);
931 void InsertColumn( unsigned int pos
, const wxString
&varianttype
);
932 void AppendColumn( const wxString
&varianttype
);
934 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
935 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
936 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
937 void DeleteItem( unsigned int pos
);
938 void DeleteAllItems();
940 // override base virtuals
942 virtual unsigned int GetColumnCount() const;
944 virtual wxString
GetColumnType( unsigned int col
) const;
946 virtual void GetValueByRow( wxVariant
&value
,
947 unsigned int row
, unsigned int col
) const;
949 virtual bool SetValueByRow( const wxVariant
&value
,
950 unsigned int row
, unsigned int col
);
954 wxVector
<wxDataViewListStoreLine
*> m_data
;
955 wxArrayString m_cols
;
958 //-----------------------------------------------------------------------------
960 class WXDLLIMPEXP_ADV wxDataViewListCtrl
: public wxDataViewCtrl
963 wxDataViewListCtrl();
964 wxDataViewListCtrl( wxWindow
*parent
, wxWindowID id
,
965 const wxPoint
& pos
= wxDefaultPosition
,
966 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
967 const wxValidator
& validator
= wxDefaultValidator
);
968 ~wxDataViewListCtrl();
970 bool Create( wxWindow
*parent
, wxWindowID id
,
971 const wxPoint
& pos
= wxDefaultPosition
,
972 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
973 const wxValidator
& validator
= wxDefaultValidator
);
975 wxDataViewListStore
*GetStore()
976 { return (wxDataViewListStore
*) GetModel(); }
977 const wxDataViewListStore
*GetStore() const
978 { return (const wxDataViewListStore
*) GetModel(); }
980 int ItemToRow(const wxDataViewItem
&item
) const
981 { return item
.IsOk() ? (int)GetStore()->GetRow(item
) : wxNOT_FOUND
; }
982 wxDataViewItem
RowToItem(int row
) const
983 { return row
== wxNOT_FOUND
? wxDataViewItem() : GetStore()->GetItem(row
); }
985 int GetSelectedRow() const
986 { return ItemToRow(GetSelection()); }
987 void SelectRow(unsigned row
)
988 { Select(RowToItem(row
)); }
989 void UnselectRow(unsigned row
)
990 { Unselect(RowToItem(row
)); }
991 bool IsRowSelected(unsigned row
) const
992 { return IsSelected(RowToItem(row
)); }
994 bool AppendColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
995 bool PrependColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
996 bool InsertColumn( unsigned int pos
, wxDataViewColumn
*column
, const wxString
&varianttype
);
998 // overridden from base class
999 virtual bool PrependColumn( wxDataViewColumn
*col
);
1000 virtual bool InsertColumn( unsigned int pos
, wxDataViewColumn
*col
);
1001 virtual bool AppendColumn( wxDataViewColumn
*col
);
1003 wxDataViewColumn
*AppendTextColumn( const wxString
&label
,
1004 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1005 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1006 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
,
1007 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
1008 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1009 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
,
1010 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1011 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1012 wxDataViewColumn
*AppendIconTextColumn( const wxString
&label
,
1013 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1014 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1016 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1017 { GetStore()->AppendItem( values
, data
); }
1018 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1019 { GetStore()->PrependItem( values
, data
); }
1020 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1021 { GetStore()->InsertItem( row
, values
, data
); }
1022 void DeleteItem( unsigned row
)
1023 { GetStore()->DeleteItem( row
); }
1024 void DeleteAllItems()
1025 { GetStore()->DeleteAllItems(); }
1027 void SetValue( const wxVariant
&value
, unsigned int row
, unsigned int col
)
1028 { GetStore()->SetValueByRow( value
, row
, col
);
1029 GetStore()->RowValueChanged( row
, col
); }
1030 void GetValue( wxVariant
&value
, unsigned int row
, unsigned int col
)
1031 { GetStore()->GetValueByRow( value
, row
, col
); }
1033 void SetTextValue( const wxString
&value
, unsigned int row
, unsigned int col
)
1034 { GetStore()->SetValueByRow( value
, row
, col
);
1035 GetStore()->RowValueChanged( row
, col
); }
1036 wxString
GetTextValue( unsigned int row
, unsigned int col
) const
1037 { wxVariant value
; GetStore()->GetValueByRow( value
, row
, col
); return value
.GetString(); }
1039 void SetToggleValue( bool value
, unsigned int row
, unsigned int col
)
1040 { GetStore()->SetValueByRow( value
, row
, col
);
1041 GetStore()->RowValueChanged( row
, col
); }
1042 bool GetToggleValue( unsigned int row
, unsigned int col
) const
1043 { wxVariant value
; GetStore()->GetValueByRow( value
, row
, col
); return value
.GetBool(); }
1045 void OnSize( wxSizeEvent
&event
);
1048 DECLARE_EVENT_TABLE()
1049 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewListCtrl
)
1052 //-----------------------------------------------------------------------------
1053 // wxDataViewTreeStore
1054 //-----------------------------------------------------------------------------
1056 class WXDLLIMPEXP_ADV wxDataViewTreeStoreNode
1059 wxDataViewTreeStoreNode( wxDataViewTreeStoreNode
*parent
,
1060 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1061 virtual ~wxDataViewTreeStoreNode();
1063 void SetText( const wxString
&text
)
1065 wxString
GetText() const
1067 void SetIcon( const wxIcon
&icon
)
1069 const wxIcon
&GetIcon() const
1071 void SetData( wxClientData
*data
)
1072 { if (m_data
) delete m_data
; m_data
= data
; }
1073 wxClientData
*GetData() const
1076 wxDataViewItem
GetItem() const
1077 { return wxDataViewItem( (void*) this ); }
1079 virtual bool IsContainer()
1082 wxDataViewTreeStoreNode
*GetParent()
1083 { return m_parent
; }
1086 wxDataViewTreeStoreNode
*m_parent
;
1089 wxClientData
*m_data
;
1092 WX_DECLARE_LIST_WITH_DECL(wxDataViewTreeStoreNode
, wxDataViewTreeStoreNodeList
,
1093 class WXDLLIMPEXP_ADV
);
1095 class WXDLLIMPEXP_ADV wxDataViewTreeStoreContainerNode
: public wxDataViewTreeStoreNode
1098 wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode
*parent
,
1099 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1100 wxClientData
*data
= NULL
);
1101 virtual ~wxDataViewTreeStoreContainerNode();
1103 const wxDataViewTreeStoreNodeList
&GetChildren() const
1104 { return m_children
; }
1105 wxDataViewTreeStoreNodeList
&GetChildren()
1106 { return m_children
; }
1108 void SetExpandedIcon( const wxIcon
&icon
)
1109 { m_iconExpanded
= icon
; }
1110 const wxIcon
&GetExpandedIcon() const
1111 { return m_iconExpanded
; }
1113 void SetExpanded( bool expanded
= true )
1114 { m_isExpanded
= expanded
; }
1115 bool IsExpanded() const
1116 { return m_isExpanded
; }
1118 virtual bool IsContainer()
1122 wxDataViewTreeStoreNodeList m_children
;
1123 wxIcon m_iconExpanded
;
1127 //-----------------------------------------------------------------------------
1129 class WXDLLIMPEXP_ADV wxDataViewTreeStore
: public wxDataViewModel
1132 wxDataViewTreeStore();
1133 ~wxDataViewTreeStore();
1135 wxDataViewItem
AppendItem( const wxDataViewItem
& parent
,
1136 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1137 wxDataViewItem
PrependItem( const wxDataViewItem
& parent
,
1138 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1139 wxDataViewItem
InsertItem( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1140 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1142 wxDataViewItem
PrependContainer( const wxDataViewItem
& parent
,
1143 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1144 wxClientData
*data
= NULL
);
1145 wxDataViewItem
AppendContainer( const wxDataViewItem
& parent
,
1146 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1147 wxClientData
*data
= NULL
);
1148 wxDataViewItem
InsertContainer( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1149 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1150 wxClientData
*data
= NULL
);
1152 wxDataViewItem
GetNthChild( const wxDataViewItem
& parent
, unsigned int pos
) const;
1153 int GetChildCount( const wxDataViewItem
& parent
) const;
1155 void SetItemText( const wxDataViewItem
& item
, const wxString
&text
);
1156 wxString
GetItemText( const wxDataViewItem
& item
) const;
1157 void SetItemIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1158 const wxIcon
&GetItemIcon( const wxDataViewItem
& item
) const;
1159 void SetItemExpandedIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1160 const wxIcon
&GetItemExpandedIcon( const wxDataViewItem
& item
) const;
1161 void SetItemData( const wxDataViewItem
& item
, wxClientData
*data
);
1162 wxClientData
*GetItemData( const wxDataViewItem
& item
) const;
1164 void DeleteItem( const wxDataViewItem
& item
);
1165 void DeleteChildren( const wxDataViewItem
& item
);
1166 void DeleteAllItems();
1168 // implement base methods
1170 virtual void GetValue( wxVariant
&variant
,
1171 const wxDataViewItem
&item
, unsigned int col
) const;
1172 virtual bool SetValue( const wxVariant
&variant
,
1173 const wxDataViewItem
&item
, unsigned int col
);
1174 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const;
1175 virtual bool IsContainer( const wxDataViewItem
&item
) const;
1176 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
1178 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
1179 unsigned int column
, bool ascending
) const;
1181 virtual bool HasDefaultCompare() const
1183 virtual unsigned int GetColumnCount() const
1185 virtual wxString
GetColumnType( unsigned int WXUNUSED(col
) ) const
1186 { return wxT("wxDataViewIconText"); }
1188 wxDataViewTreeStoreNode
*FindNode( const wxDataViewItem
&item
) const;
1189 wxDataViewTreeStoreContainerNode
*FindContainerNode( const wxDataViewItem
&item
) const;
1190 wxDataViewTreeStoreNode
*GetRoot() const { return m_root
; }
1193 wxDataViewTreeStoreNode
*m_root
;
1196 //-----------------------------------------------------------------------------
1198 class WXDLLIMPEXP_ADV wxDataViewTreeCtrl
: public wxDataViewCtrl
1201 wxDataViewTreeCtrl() { Init(); }
1202 wxDataViewTreeCtrl(wxWindow
*parent
,
1204 const wxPoint
& pos
= wxDefaultPosition
,
1205 const wxSize
& size
= wxDefaultSize
,
1206 long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
1207 const wxValidator
& validator
= wxDefaultValidator
)
1211 Create(parent
, id
, pos
, size
, style
, validator
);
1214 virtual ~wxDataViewTreeCtrl();
1216 bool Create(wxWindow
*parent
,
1218 const wxPoint
& pos
= wxDefaultPosition
,
1219 const wxSize
& size
= wxDefaultSize
,
1220 long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
1221 const wxValidator
& validator
= wxDefaultValidator
);
1223 wxDataViewTreeStore
*GetStore()
1224 { return (wxDataViewTreeStore
*) GetModel(); }
1225 const wxDataViewTreeStore
*GetStore() const
1226 { return (const wxDataViewTreeStore
*) GetModel(); }
1228 bool IsContainer( const wxDataViewItem
& item
) const
1229 { return GetStore()->IsContainer(item
); }
1231 void SetImageList( wxImageList
*imagelist
);
1232 wxImageList
* GetImageList() { return m_imageList
; }
1234 wxDataViewItem
AppendItem( const wxDataViewItem
& parent
,
1235 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1236 wxDataViewItem
PrependItem( const wxDataViewItem
& parent
,
1237 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1238 wxDataViewItem
InsertItem( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1239 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1241 wxDataViewItem
PrependContainer( const wxDataViewItem
& parent
,
1242 const wxString
&text
, int icon
= -1, int expanded
= -1,
1243 wxClientData
*data
= NULL
);
1244 wxDataViewItem
AppendContainer( const wxDataViewItem
& parent
,
1245 const wxString
&text
, int icon
= -1, int expanded
= -1,
1246 wxClientData
*data
= NULL
);
1247 wxDataViewItem
InsertContainer( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1248 const wxString
&text
, int icon
= -1, int expanded
= -1,
1249 wxClientData
*data
= NULL
);
1251 wxDataViewItem
GetNthChild( const wxDataViewItem
& parent
, unsigned int pos
) const
1252 { return GetStore()->GetNthChild(parent
, pos
); }
1253 int GetChildCount( const wxDataViewItem
& parent
) const
1254 { return GetStore()->GetChildCount(parent
); }
1256 void SetItemText( const wxDataViewItem
& item
, const wxString
&text
);
1257 wxString
GetItemText( const wxDataViewItem
& item
) const
1258 { return GetStore()->GetItemText(item
); }
1259 void SetItemIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1260 const wxIcon
&GetItemIcon( const wxDataViewItem
& item
) const
1261 { return GetStore()->GetItemIcon(item
); }
1262 void SetItemExpandedIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1263 const wxIcon
&GetItemExpandedIcon( const wxDataViewItem
& item
) const
1264 { return GetStore()->GetItemExpandedIcon(item
); }
1265 void SetItemData( const wxDataViewItem
& item
, wxClientData
*data
)
1266 { GetStore()->SetItemData(item
,data
); }
1267 wxClientData
*GetItemData( const wxDataViewItem
& item
) const
1268 { return GetStore()->GetItemData(item
); }
1270 void DeleteItem( const wxDataViewItem
& item
);
1271 void DeleteChildren( const wxDataViewItem
& item
);
1272 void DeleteAllItems();
1274 void OnExpanded( wxDataViewEvent
&event
);
1275 void OnCollapsed( wxDataViewEvent
&event
);
1276 void OnSize( wxSizeEvent
&event
);
1284 wxImageList
*m_imageList
;
1287 DECLARE_EVENT_TABLE()
1288 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl
)
1291 #endif // wxUSE_DATAVIEWCTRL
1294 // _WX_DATAVIEW_H_BASE_