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() : m_id(NULL
) {}
85 wxDataViewItem(const wxDataViewItem
&item
) : m_id(item
.m_id
) {}
87 wxEXPLICIT
wxDataViewItem(void* id
) : m_id(id
) {}
89 bool IsOk() const { return m_id
!= NULL
; }
90 void* GetID() const { return m_id
; }
91 operator const void* () const { return m_id
; }
98 bool operator==(const wxDataViewItem
& left
, const wxDataViewItem
& right
)
100 return left
.GetID() == right
.GetID();
104 bool operator!=(const wxDataViewItem
& left
, const wxDataViewItem
& right
)
106 return !(left
== right
);
109 WX_DEFINE_ARRAY(wxDataViewItem
, wxDataViewItemArray
);
111 // ---------------------------------------------------------
112 // wxDataViewModelNotifier
113 // ---------------------------------------------------------
115 class WXDLLIMPEXP_ADV wxDataViewModelNotifier
118 wxDataViewModelNotifier() { m_owner
= NULL
; }
119 virtual ~wxDataViewModelNotifier() { m_owner
= NULL
; }
121 virtual bool ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
) = 0;
122 virtual bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
) = 0;
123 virtual bool ItemChanged( const wxDataViewItem
&item
) = 0;
124 virtual bool ItemsAdded( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
125 virtual bool ItemsDeleted( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
126 virtual bool ItemsChanged( const wxDataViewItemArray
&items
);
127 virtual bool ValueChanged( const wxDataViewItem
&item
, unsigned int col
) = 0;
128 virtual bool Cleared() = 0;
130 // some platforms, such as GTK+, may need a two step procedure for ::Reset()
131 virtual bool BeforeReset() { return true; }
132 virtual bool AfterReset() { return Cleared(); }
134 virtual void Resort() = 0;
136 void SetOwner( wxDataViewModel
*owner
) { m_owner
= owner
; }
137 wxDataViewModel
*GetOwner() const { return m_owner
; }
140 wxDataViewModel
*m_owner
;
145 // ----------------------------------------------------------------------------
146 // wxDataViewItemAttr: a structure containing the visual attributes of an item
147 // ----------------------------------------------------------------------------
149 // TODO: this should be renamed to wxItemAttr or something general like this
151 class WXDLLIMPEXP_ADV wxDataViewItemAttr
162 void SetColour(const wxColour
& colour
) { m_colour
= colour
; }
163 void SetBold( bool set
) { m_bold
= set
; }
164 void SetItalic( bool set
) { m_italic
= set
; }
167 bool HasColour() const { return m_colour
.IsOk(); }
168 const wxColour
& GetColour() const { return m_colour
; }
170 bool HasFont() const { return m_bold
|| m_italic
; }
171 bool GetBold() const { return m_bold
; }
172 bool GetItalic() const { return m_italic
; }
174 bool IsDefault() const { return !(HasColour() || HasFont()); }
176 // Return the font based on the given one with this attribute applied to it.
177 wxFont
GetEffectiveFont(const wxFont
& font
) const;
186 // ---------------------------------------------------------
188 // ---------------------------------------------------------
190 WX_DECLARE_LIST_WITH_DECL(wxDataViewModelNotifier
, wxDataViewModelNotifiers
,
191 class WXDLLIMPEXP_ADV
);
193 class WXDLLIMPEXP_ADV wxDataViewModel
: public wxRefCounter
198 virtual unsigned int GetColumnCount() const = 0;
200 // return type as reported by wxVariant
201 virtual wxString
GetColumnType( unsigned int col
) const = 0;
203 // get value into a wxVariant
204 virtual void GetValue( wxVariant
&variant
,
205 const wxDataViewItem
&item
, unsigned int col
) const = 0;
207 // return true if the given item has a value to display in the given
208 // column: this is always true except for container items which by default
209 // only show their label in the first column (but see HasContainerColumns())
210 bool HasValue(const wxDataViewItem
& item
, unsigned col
) const
212 return col
== 0 || !IsContainer(item
) || HasContainerColumns(item
);
215 // usually ValueChanged() should be called after changing the value in the
216 // model to update the control, ChangeValue() does it on its own while
217 // SetValue() does not -- so while you will override SetValue(), you should
218 // be usually calling ChangeValue()
219 virtual bool SetValue(const wxVariant
&variant
,
220 const wxDataViewItem
&item
,
221 unsigned int col
) = 0;
223 bool ChangeValue(const wxVariant
& variant
,
224 const wxDataViewItem
& item
,
227 return SetValue(variant
, item
, col
) && ValueChanged(item
, col
);
230 // Get text attribute, return false of default attributes should be used
231 virtual bool GetAttr(const wxDataViewItem
&WXUNUSED(item
),
232 unsigned int WXUNUSED(col
),
233 wxDataViewItemAttr
&WXUNUSED(attr
)) const
238 // Override this if you want to disable specific items
239 virtual bool IsEnabled(const wxDataViewItem
&WXUNUSED(item
),
240 unsigned int WXUNUSED(col
)) const
246 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const = 0;
247 virtual bool IsContainer( const wxDataViewItem
&item
) const = 0;
248 // Is the container just a header or an item with all columns
249 virtual bool HasContainerColumns(const wxDataViewItem
& WXUNUSED(item
)) const
251 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const = 0;
253 // delegated notifiers
254 bool ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
255 bool ItemsAdded( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
256 bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
257 bool ItemsDeleted( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
258 bool ItemChanged( const wxDataViewItem
&item
);
259 bool ItemsChanged( const wxDataViewItemArray
&items
);
260 bool ValueChanged( const wxDataViewItem
&item
, unsigned int col
);
263 // some platforms, such as GTK+, may need a two step procedure for ::Reset()
269 virtual void Resort();
271 void AddNotifier( wxDataViewModelNotifier
*notifier
);
272 void RemoveNotifier( wxDataViewModelNotifier
*notifier
);
274 // default compare function
275 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
276 unsigned int column
, bool ascending
) const;
277 virtual bool HasDefaultCompare() const { return false; }
280 virtual bool IsListModel() const { return false; }
281 virtual bool IsVirtualListModel() const { return false; }
284 // the user should not delete this class directly: he should use DecRef() instead!
285 virtual ~wxDataViewModel() { }
287 wxDataViewModelNotifiers m_notifiers
;
290 // ----------------------------------------------------------------------------
291 // wxDataViewListModel: a model of a list, i.e. flat data structure without any
292 // branches/containers, used as base class by wxDataViewIndexListModel and
293 // wxDataViewVirtualListModel
294 // ----------------------------------------------------------------------------
296 class WXDLLIMPEXP_ADV wxDataViewListModel
: public wxDataViewModel
299 // derived classes should override these methods instead of
300 // {Get,Set}Value() and GetAttr() inherited from the base class
302 virtual void GetValueByRow(wxVariant
&variant
,
303 unsigned row
, unsigned col
) const = 0;
305 virtual bool SetValueByRow(const wxVariant
&variant
,
306 unsigned row
, unsigned col
) = 0;
309 GetAttrByRow(unsigned WXUNUSED(row
), unsigned WXUNUSED(col
),
310 wxDataViewItemAttr
&WXUNUSED(attr
)) const
315 virtual bool IsEnabledByRow(unsigned int WXUNUSED(row
),
316 unsigned int WXUNUSED(col
)) const
322 // helper methods provided by list models only
323 virtual unsigned GetRow( const wxDataViewItem
&item
) const = 0;
325 // returns the number of rows
326 virtual unsigned int GetCount() const = 0;
328 // implement some base class pure virtual directly
329 virtual wxDataViewItem
330 GetParent( const wxDataViewItem
& WXUNUSED(item
) ) const
332 // items never have valid parent in this model
333 return wxDataViewItem();
336 virtual bool IsContainer( const wxDataViewItem
&item
) const
338 // only the invisible (and invalid) root item has children
342 // and implement some others by forwarding them to our own ones
343 virtual void GetValue( wxVariant
&variant
,
344 const wxDataViewItem
&item
, unsigned int col
) const
346 GetValueByRow(variant
, GetRow(item
), col
);
349 virtual bool SetValue( const wxVariant
&variant
,
350 const wxDataViewItem
&item
, unsigned int col
)
352 return SetValueByRow( variant
, GetRow(item
), col
);
355 virtual bool GetAttr(const wxDataViewItem
&item
, unsigned int col
,
356 wxDataViewItemAttr
&attr
) const
358 return GetAttrByRow( GetRow(item
), col
, attr
);
361 virtual bool IsEnabled(const wxDataViewItem
&item
, unsigned int col
) const
363 return IsEnabledByRow( GetRow(item
), col
);
367 virtual bool IsListModel() const { return true; }
370 // ---------------------------------------------------------
371 // wxDataViewIndexListModel
372 // ---------------------------------------------------------
374 class WXDLLIMPEXP_ADV wxDataViewIndexListModel
: public wxDataViewListModel
377 wxDataViewIndexListModel( unsigned int initial_size
= 0 );
380 void RowInserted( unsigned int before
);
382 void RowDeleted( unsigned int row
);
383 void RowsDeleted( const wxArrayInt
&rows
);
384 void RowChanged( unsigned int row
);
385 void RowValueChanged( unsigned int row
, unsigned int col
);
386 void Reset( unsigned int new_size
);
388 // convert to/from row/wxDataViewItem
390 virtual unsigned GetRow( const wxDataViewItem
&item
) const;
391 wxDataViewItem
GetItem( unsigned int row
) const;
393 // compare based on index
395 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
396 unsigned int column
, bool ascending
) const;
397 virtual bool HasDefaultCompare() const;
399 // implement base methods
400 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
402 unsigned int GetCount() const { return m_hash
.GetCount(); }
405 wxDataViewItemArray m_hash
;
406 unsigned int m_nextFreeID
;
410 // ---------------------------------------------------------
411 // wxDataViewVirtualListModel
412 // ---------------------------------------------------------
415 // better than nothing
416 typedef wxDataViewIndexListModel wxDataViewVirtualListModel
;
419 class WXDLLIMPEXP_ADV wxDataViewVirtualListModel
: public wxDataViewListModel
422 wxDataViewVirtualListModel( unsigned int initial_size
= 0 );
425 void RowInserted( unsigned int before
);
427 void RowDeleted( unsigned int row
);
428 void RowsDeleted( const wxArrayInt
&rows
);
429 void RowChanged( unsigned int row
);
430 void RowValueChanged( unsigned int row
, unsigned int col
);
431 void Reset( unsigned int new_size
);
433 // convert to/from row/wxDataViewItem
435 virtual unsigned GetRow( const wxDataViewItem
&item
) const;
436 wxDataViewItem
GetItem( unsigned int row
) const;
438 // compare based on index
440 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
441 unsigned int column
, bool ascending
) const;
442 virtual bool HasDefaultCompare() const;
444 // implement base methods
445 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
447 unsigned int GetCount() const { return m_size
; }
450 virtual bool IsVirtualListModel() const { return true; }
458 // ----------------------------------------------------------------------------
459 // wxDataViewRenderer and related classes
460 // ----------------------------------------------------------------------------
462 #include "wx/dvrenderers.h"
464 // ---------------------------------------------------------
465 // wxDataViewColumnBase
466 // ---------------------------------------------------------
468 // for compatibility only, do not use
469 enum wxDataViewColumnFlags
471 wxDATAVIEW_COL_RESIZABLE
= wxCOL_RESIZABLE
,
472 wxDATAVIEW_COL_SORTABLE
= wxCOL_SORTABLE
,
473 wxDATAVIEW_COL_REORDERABLE
= wxCOL_REORDERABLE
,
474 wxDATAVIEW_COL_HIDDEN
= wxCOL_HIDDEN
477 class WXDLLIMPEXP_ADV wxDataViewColumnBase
: public wxSettableHeaderColumn
480 // ctor for the text columns: takes ownership of renderer
481 wxDataViewColumnBase(wxDataViewRenderer
*renderer
,
482 unsigned int model_column
)
484 Init(renderer
, model_column
);
487 // ctor for the bitmap columns
488 wxDataViewColumnBase(const wxBitmap
& bitmap
,
489 wxDataViewRenderer
*renderer
,
490 unsigned int model_column
)
493 Init(renderer
, model_column
);
496 virtual ~wxDataViewColumnBase();
499 virtual void SetOwner( wxDataViewCtrl
*owner
)
503 unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column
); }
504 wxDataViewCtrl
*GetOwner() const { return m_owner
; }
505 wxDataViewRenderer
* GetRenderer() const { return m_renderer
; }
507 // implement some of base class pure virtuals (the rest is port-dependent
508 // and done differently in generic and native versions)
509 virtual void SetBitmap( const wxBitmap
& bitmap
) { m_bitmap
= bitmap
; }
510 virtual wxBitmap
GetBitmap() const { return m_bitmap
; }
513 wxDataViewRenderer
*m_renderer
;
516 wxDataViewCtrl
*m_owner
;
519 // common part of all ctors
520 void Init(wxDataViewRenderer
*renderer
, unsigned int model_column
);
523 // ---------------------------------------------------------
524 // wxDataViewCtrlBase
525 // ---------------------------------------------------------
527 #define wxDV_SINGLE 0x0000 // for convenience
528 #define wxDV_MULTIPLE 0x0001 // can select multiple items
530 #define wxDV_NO_HEADER 0x0002 // column titles not visible
531 #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows
532 #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns
534 #define wxDV_ROW_LINES 0x0010 // alternating colour in rows
535 #define wxDV_VARIABLE_LINE_HEIGHT 0x0020 // variable line height
537 class WXDLLIMPEXP_ADV wxDataViewCtrlBase
: public wxControl
540 wxDataViewCtrlBase();
541 virtual ~wxDataViewCtrlBase();
546 virtual bool AssociateModel( wxDataViewModel
*model
);
547 wxDataViewModel
* GetModel();
548 const wxDataViewModel
* GetModel() const;
554 wxDataViewColumn
*PrependTextColumn( const wxString
&label
, unsigned int model_column
,
555 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
556 wxAlignment align
= wxALIGN_NOT
,
557 int flags
= wxDATAVIEW_COL_RESIZABLE
);
558 wxDataViewColumn
*PrependIconTextColumn( const wxString
&label
, unsigned int model_column
,
559 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
560 wxAlignment align
= wxALIGN_NOT
,
561 int flags
= wxDATAVIEW_COL_RESIZABLE
);
562 wxDataViewColumn
*PrependToggleColumn( const wxString
&label
, unsigned int model_column
,
563 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
564 wxAlignment align
= wxALIGN_CENTER
,
565 int flags
= wxDATAVIEW_COL_RESIZABLE
);
566 wxDataViewColumn
*PrependProgressColumn( const wxString
&label
, unsigned int model_column
,
567 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
568 wxAlignment align
= wxALIGN_CENTER
,
569 int flags
= wxDATAVIEW_COL_RESIZABLE
);
570 wxDataViewColumn
*PrependDateColumn( const wxString
&label
, unsigned int model_column
,
571 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
572 wxAlignment align
= wxALIGN_NOT
,
573 int flags
= wxDATAVIEW_COL_RESIZABLE
);
574 wxDataViewColumn
*PrependBitmapColumn( const wxString
&label
, unsigned int model_column
,
575 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
576 wxAlignment align
= wxALIGN_CENTER
,
577 int flags
= wxDATAVIEW_COL_RESIZABLE
);
578 wxDataViewColumn
*PrependTextColumn( const wxBitmap
&label
, unsigned int model_column
,
579 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
580 wxAlignment align
= wxALIGN_NOT
,
581 int flags
= wxDATAVIEW_COL_RESIZABLE
);
582 wxDataViewColumn
*PrependIconTextColumn( const wxBitmap
&label
, unsigned int model_column
,
583 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
584 wxAlignment align
= wxALIGN_NOT
,
585 int flags
= wxDATAVIEW_COL_RESIZABLE
);
586 wxDataViewColumn
*PrependToggleColumn( const wxBitmap
&label
, unsigned int model_column
,
587 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
588 wxAlignment align
= wxALIGN_CENTER
,
589 int flags
= wxDATAVIEW_COL_RESIZABLE
);
590 wxDataViewColumn
*PrependProgressColumn( const wxBitmap
&label
, unsigned int model_column
,
591 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
592 wxAlignment align
= wxALIGN_CENTER
,
593 int flags
= wxDATAVIEW_COL_RESIZABLE
);
594 wxDataViewColumn
*PrependDateColumn( const wxBitmap
&label
, unsigned int model_column
,
595 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
596 wxAlignment align
= wxALIGN_NOT
,
597 int flags
= wxDATAVIEW_COL_RESIZABLE
);
598 wxDataViewColumn
*PrependBitmapColumn( const wxBitmap
&label
, unsigned int model_column
,
599 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
600 wxAlignment align
= wxALIGN_CENTER
,
601 int flags
= wxDATAVIEW_COL_RESIZABLE
);
603 wxDataViewColumn
*AppendTextColumn( const wxString
&label
, unsigned int model_column
,
604 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
605 wxAlignment align
= wxALIGN_NOT
,
606 int flags
= wxDATAVIEW_COL_RESIZABLE
);
607 wxDataViewColumn
*AppendIconTextColumn( const wxString
&label
, unsigned int model_column
,
608 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
609 wxAlignment align
= wxALIGN_NOT
,
610 int flags
= wxDATAVIEW_COL_RESIZABLE
);
611 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
, unsigned int model_column
,
612 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
613 wxAlignment align
= wxALIGN_CENTER
,
614 int flags
= wxDATAVIEW_COL_RESIZABLE
);
615 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
, unsigned int model_column
,
616 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
617 wxAlignment align
= wxALIGN_CENTER
,
618 int flags
= wxDATAVIEW_COL_RESIZABLE
);
619 wxDataViewColumn
*AppendDateColumn( const wxString
&label
, unsigned int model_column
,
620 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
621 wxAlignment align
= wxALIGN_NOT
,
622 int flags
= wxDATAVIEW_COL_RESIZABLE
);
623 wxDataViewColumn
*AppendBitmapColumn( const wxString
&label
, unsigned int model_column
,
624 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
625 wxAlignment align
= wxALIGN_CENTER
,
626 int flags
= wxDATAVIEW_COL_RESIZABLE
);
627 wxDataViewColumn
*AppendTextColumn( const wxBitmap
&label
, unsigned int model_column
,
628 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
629 wxAlignment align
= wxALIGN_NOT
,
630 int flags
= wxDATAVIEW_COL_RESIZABLE
);
631 wxDataViewColumn
*AppendIconTextColumn( const wxBitmap
&label
, unsigned int model_column
,
632 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
633 wxAlignment align
= wxALIGN_NOT
,
634 int flags
= wxDATAVIEW_COL_RESIZABLE
);
635 wxDataViewColumn
*AppendToggleColumn( const wxBitmap
&label
, unsigned int model_column
,
636 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
637 wxAlignment align
= wxALIGN_CENTER
,
638 int flags
= wxDATAVIEW_COL_RESIZABLE
);
639 wxDataViewColumn
*AppendProgressColumn( const wxBitmap
&label
, unsigned int model_column
,
640 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
641 wxAlignment align
= wxALIGN_CENTER
,
642 int flags
= wxDATAVIEW_COL_RESIZABLE
);
643 wxDataViewColumn
*AppendDateColumn( const wxBitmap
&label
, unsigned int model_column
,
644 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
645 wxAlignment align
= wxALIGN_NOT
,
646 int flags
= wxDATAVIEW_COL_RESIZABLE
);
647 wxDataViewColumn
*AppendBitmapColumn( const wxBitmap
&label
, unsigned int model_column
,
648 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
649 wxAlignment align
= wxALIGN_CENTER
,
650 int flags
= wxDATAVIEW_COL_RESIZABLE
);
652 virtual bool PrependColumn( wxDataViewColumn
*col
);
653 virtual bool InsertColumn( unsigned int pos
, wxDataViewColumn
*col
);
654 virtual bool AppendColumn( wxDataViewColumn
*col
);
656 virtual unsigned int GetColumnCount() const = 0;
657 virtual wxDataViewColumn
* GetColumn( unsigned int pos
) const = 0;
658 virtual int GetColumnPosition( const wxDataViewColumn
*column
) const = 0;
660 virtual bool DeleteColumn( wxDataViewColumn
*column
) = 0;
661 virtual bool ClearColumns() = 0;
663 void SetExpanderColumn( wxDataViewColumn
*col
)
664 { m_expander_column
= col
; DoSetExpanderColumn(); }
665 wxDataViewColumn
*GetExpanderColumn() const
666 { return m_expander_column
; }
668 virtual wxDataViewColumn
*GetSortingColumn() const = 0;
674 void SetIndent( int indent
)
675 { m_indent
= indent
; DoSetIndent(); }
676 int GetIndent() const
679 // Current item is the one used by the keyboard navigation, it is the same
680 // as the (unique) selected item in single selection mode so these
681 // functions are mostly useful for controls with wxDV_MULTIPLE style.
682 wxDataViewItem
GetCurrentItem() const;
683 void SetCurrentItem(const wxDataViewItem
& item
);
685 virtual wxDataViewItem
GetSelection() const = 0;
686 virtual int GetSelections( wxDataViewItemArray
& sel
) const = 0;
687 virtual void SetSelections( const wxDataViewItemArray
& sel
) = 0;
688 virtual void Select( const wxDataViewItem
& item
) = 0;
689 virtual void Unselect( const wxDataViewItem
& item
) = 0;
690 virtual bool IsSelected( const wxDataViewItem
& item
) const = 0;
692 virtual void SelectAll() = 0;
693 virtual void UnselectAll() = 0;
695 virtual void Expand( const wxDataViewItem
& item
) = 0;
696 virtual void ExpandAncestors( const wxDataViewItem
& item
);
697 virtual void Collapse( const wxDataViewItem
& item
) = 0;
698 virtual bool IsExpanded( const wxDataViewItem
& item
) const = 0;
700 virtual void EnsureVisible( const wxDataViewItem
& item
,
701 const wxDataViewColumn
*column
= NULL
) = 0;
702 virtual void HitTest( const wxPoint
& point
, wxDataViewItem
&item
, wxDataViewColumn
* &column
) const = 0;
703 virtual wxRect
GetItemRect( const wxDataViewItem
& item
, const wxDataViewColumn
*column
= NULL
) const = 0;
705 virtual bool SetRowHeight( int WXUNUSED(rowHeight
) ) { return false; }
707 virtual void StartEditor( const wxDataViewItem
& WXUNUSED(item
),
708 unsigned int WXUNUSED(column
) )
711 #if wxUSE_DRAG_AND_DROP
712 virtual bool EnableDragSource(const wxDataFormat
& WXUNUSED(format
))
714 virtual bool EnableDropTarget(const wxDataFormat
& WXUNUSED(format
))
716 #endif // wxUSE_DRAG_AND_DROP
718 // define control visual attributes
719 // --------------------------------
721 virtual wxVisualAttributes
GetDefaultAttributes() const
723 return GetClassDefaultAttributes(GetWindowVariant());
726 static wxVisualAttributes
727 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
)
729 return wxControl::GetCompositeControlsDefaultAttributes(variant
);
733 virtual void DoSetExpanderColumn() = 0 ;
734 virtual void DoSetIndent() = 0;
737 // Implementation of the public Set/GetCurrentItem() methods which are only
738 // called in multi selection case (for single selection controls their
739 // implementation is trivial and is done in the base class itself).
740 virtual wxDataViewItem
DoGetCurrentItem() const = 0;
741 virtual void DoSetCurrentItem(const wxDataViewItem
& item
) = 0;
743 wxDataViewModel
*m_model
;
744 wxDataViewColumn
*m_expander_column
;
748 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase
)
751 // ----------------------------------------------------------------------------
752 // wxDataViewEvent - the event class for the wxDataViewCtrl notifications
753 // ----------------------------------------------------------------------------
755 class WXDLLIMPEXP_ADV wxDataViewEvent
: public wxNotifyEvent
758 wxDataViewEvent(wxEventType commandType
= wxEVT_NULL
, int winid
= 0)
759 : wxNotifyEvent(commandType
, winid
),
763 m_value(wxNullVariant
),
768 m_editCancelled(false)
769 #if wxUSE_DRAG_AND_DROP
770 , m_dataObject(NULL
),
776 wxDataViewEvent(const wxDataViewEvent
& event
)
777 : wxNotifyEvent(event
),
778 m_item(event
.m_item
),
780 m_model(event
.m_model
),
781 m_value(event
.m_value
),
782 m_column(event
.m_column
),
784 m_cacheFrom(event
.m_cacheFrom
),
785 m_cacheTo(event
.m_cacheTo
),
786 m_editCancelled(event
.m_editCancelled
)
787 #if wxUSE_DRAG_AND_DROP
788 , m_dataObject(event
.m_dataObject
),
789 m_dataFormat(event
.m_dataFormat
),
790 m_dataBuffer(event
.m_dataBuffer
),
791 m_dataSize(event
.m_dataSize
)
795 wxDataViewItem
GetItem() const { return m_item
; }
796 void SetItem( const wxDataViewItem
&item
) { m_item
= item
; }
798 int GetColumn() const { return m_col
; }
799 void SetColumn( int col
) { m_col
= col
; }
801 wxDataViewModel
* GetModel() const { return m_model
; }
802 void SetModel( wxDataViewModel
*model
) { m_model
= model
; }
804 const wxVariant
&GetValue() const { return m_value
; }
805 void SetValue( const wxVariant
&value
) { m_value
= value
; }
807 // for wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE only
808 bool IsEditCancelled() const { return m_editCancelled
; }
809 void SetEditCanceled(bool editCancelled
) { m_editCancelled
= editCancelled
; }
811 // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only
812 void SetDataViewColumn( wxDataViewColumn
*col
) { m_column
= col
; }
813 wxDataViewColumn
*GetDataViewColumn() const { return m_column
; }
815 // for wxEVT_DATAVIEW_CONTEXT_MENU only
816 wxPoint
GetPosition() const { return m_pos
; }
817 void SetPosition( int x
, int y
) { m_pos
.x
= x
; m_pos
.y
= y
; }
819 // For wxEVT_COMMAND_DATAVIEW_CACHE_HINT
820 int GetCacheFrom() const { return m_cacheFrom
; }
821 int GetCacheTo() const { return m_cacheTo
; }
822 void SetCache(int from
, int to
) { m_cacheFrom
= from
; m_cacheTo
= to
; }
825 #if wxUSE_DRAG_AND_DROP
826 // For drag operations
827 void SetDataObject( wxDataObject
*obj
) { m_dataObject
= obj
; }
828 wxDataObject
*GetDataObject() const { return m_dataObject
; }
830 // For drop operations
831 void SetDataFormat( const wxDataFormat
&format
) { m_dataFormat
= format
; }
832 wxDataFormat
GetDataFormat() const { return m_dataFormat
; }
833 void SetDataSize( size_t size
) { m_dataSize
= size
; }
834 size_t GetDataSize() const { return m_dataSize
; }
835 void SetDataBuffer( void* buf
) { m_dataBuffer
= buf
;}
836 void *GetDataBuffer() const { return m_dataBuffer
; }
837 #endif // wxUSE_DRAG_AND_DROP
839 virtual wxEvent
*Clone() const { return new wxDataViewEvent(*this); }
842 wxDataViewItem m_item
;
844 wxDataViewModel
*m_model
;
846 wxDataViewColumn
*m_column
;
850 bool m_editCancelled
;
852 #if wxUSE_DRAG_AND_DROP
853 wxDataObject
*m_dataObject
;
855 wxDataFormat m_dataFormat
;
858 #endif // wxUSE_DRAG_AND_DROP
861 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent
)
864 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED
, wxDataViewEvent
);
866 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED
, wxDataViewEvent
);
867 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED
, wxDataViewEvent
);
868 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED
, wxDataViewEvent
);
869 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING
, wxDataViewEvent
);
870 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING
, wxDataViewEvent
);
871 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING
, wxDataViewEvent
);
872 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED
, wxDataViewEvent
);
873 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE
, wxDataViewEvent
);
874 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED
, wxDataViewEvent
);
876 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU
, wxDataViewEvent
);
878 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK
, wxDataViewEvent
);
879 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK
, wxDataViewEvent
);
880 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED
, wxDataViewEvent
);
881 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED
, wxDataViewEvent
);
883 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_CACHE_HINT
, wxDataViewEvent
);
885 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG
, wxDataViewEvent
);
886 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE
, wxDataViewEvent
);
887 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_DROP
, wxDataViewEvent
);
889 typedef void (wxEvtHandler::*wxDataViewEventFunction
)(wxDataViewEvent
&);
891 #define wxDataViewEventHandler(func) \
892 wxEVENT_HANDLER_CAST(wxDataViewEventFunction, func)
894 #define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \
895 wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn))
897 #define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn)
899 #define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn)
900 #define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn)
901 #define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn)
902 #define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn)
903 #define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn)
904 #define EVT_DATAVIEW_ITEM_START_EDITING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_START_EDITING, id, fn)
905 #define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn)
906 #define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn)
907 #define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn)
909 #define EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_CONTEXT_MENU, id, fn)
911 #define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn)
912 #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn)
913 #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn)
914 #define EVT_DATAVIEW_COLUMN_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_REORDERED, id, fn)
915 #define EVT_DATAVIEW_CACHE_HINT(id, fn) wx__DECLARE_DATAVIEWEVT(CACHE_HINT, id, fn)
917 #define EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_BEGIN_DRAG, id, fn)
918 #define EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP_POSSIBLE, id, fn)
919 #define EVT_DATAVIEW_ITEM_DROP(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP, id, fn)
921 #ifdef wxHAS_GENERIC_DATAVIEWCTRL
922 #include "wx/generic/dataview.h"
923 #elif defined(__WXGTK20__)
924 #include "wx/gtk/dataview.h"
925 #elif defined(__WXMAC__)
926 #include "wx/osx/dataview.h"
928 #error "unknown native wxDataViewCtrl implementation"
931 //-----------------------------------------------------------------------------
932 // wxDataViewListStore
933 //-----------------------------------------------------------------------------
935 class WXDLLIMPEXP_ADV wxDataViewListStoreLine
938 wxDataViewListStoreLine( wxClientData
*data
= NULL
)
942 virtual ~wxDataViewListStoreLine()
947 void SetData( wxClientData
*data
)
948 { if (m_data
) delete m_data
; m_data
= data
; }
949 wxClientData
*GetData() const
952 wxVector
<wxVariant
> m_values
;
955 wxClientData
*m_data
;
959 class WXDLLIMPEXP_ADV wxDataViewListStore
: public wxDataViewIndexListModel
962 wxDataViewListStore();
963 ~wxDataViewListStore();
965 void PrependColumn( const wxString
&varianttype
);
966 void InsertColumn( unsigned int pos
, const wxString
&varianttype
);
967 void AppendColumn( const wxString
&varianttype
);
969 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
970 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
971 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
972 void DeleteItem( unsigned int pos
);
973 void DeleteAllItems();
975 // override base virtuals
977 virtual unsigned int GetColumnCount() const;
979 virtual wxString
GetColumnType( unsigned int col
) const;
981 virtual void GetValueByRow( wxVariant
&value
,
982 unsigned int row
, unsigned int col
) const;
984 virtual bool SetValueByRow( const wxVariant
&value
,
985 unsigned int row
, unsigned int col
);
989 wxVector
<wxDataViewListStoreLine
*> m_data
;
990 wxArrayString m_cols
;
993 //-----------------------------------------------------------------------------
995 class WXDLLIMPEXP_ADV wxDataViewListCtrl
: public wxDataViewCtrl
998 wxDataViewListCtrl();
999 wxDataViewListCtrl( wxWindow
*parent
, wxWindowID id
,
1000 const wxPoint
& pos
= wxDefaultPosition
,
1001 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
1002 const wxValidator
& validator
= wxDefaultValidator
);
1003 ~wxDataViewListCtrl();
1005 bool Create( wxWindow
*parent
, wxWindowID id
,
1006 const wxPoint
& pos
= wxDefaultPosition
,
1007 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
1008 const wxValidator
& validator
= wxDefaultValidator
);
1010 wxDataViewListStore
*GetStore()
1011 { return (wxDataViewListStore
*) GetModel(); }
1012 const wxDataViewListStore
*GetStore() const
1013 { return (const wxDataViewListStore
*) GetModel(); }
1015 int ItemToRow(const wxDataViewItem
&item
) const
1016 { return item
.IsOk() ? (int)GetStore()->GetRow(item
) : wxNOT_FOUND
; }
1017 wxDataViewItem
RowToItem(int row
) const
1018 { return row
== wxNOT_FOUND
? wxDataViewItem() : GetStore()->GetItem(row
); }
1020 int GetSelectedRow() const
1021 { return ItemToRow(GetSelection()); }
1022 void SelectRow(unsigned row
)
1023 { Select(RowToItem(row
)); }
1024 void UnselectRow(unsigned row
)
1025 { Unselect(RowToItem(row
)); }
1026 bool IsRowSelected(unsigned row
) const
1027 { return IsSelected(RowToItem(row
)); }
1029 bool AppendColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
1030 bool PrependColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
1031 bool InsertColumn( unsigned int pos
, wxDataViewColumn
*column
, const wxString
&varianttype
);
1033 // overridden from base class
1034 virtual bool PrependColumn( wxDataViewColumn
*col
);
1035 virtual bool InsertColumn( unsigned int pos
, wxDataViewColumn
*col
);
1036 virtual bool AppendColumn( wxDataViewColumn
*col
);
1038 wxDataViewColumn
*AppendTextColumn( const wxString
&label
,
1039 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1040 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1041 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
,
1042 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
1043 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1044 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
,
1045 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1046 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1047 wxDataViewColumn
*AppendIconTextColumn( const wxString
&label
,
1048 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1049 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1051 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1052 { GetStore()->AppendItem( values
, data
); }
1053 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1054 { GetStore()->PrependItem( values
, data
); }
1055 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1056 { GetStore()->InsertItem( row
, values
, data
); }
1057 void DeleteItem( unsigned row
)
1058 { GetStore()->DeleteItem( row
); }
1059 void DeleteAllItems()
1060 { GetStore()->DeleteAllItems(); }
1062 void SetValue( const wxVariant
&value
, unsigned int row
, unsigned int col
)
1063 { GetStore()->SetValueByRow( value
, row
, col
);
1064 GetStore()->RowValueChanged( row
, col
); }
1065 void GetValue( wxVariant
&value
, unsigned int row
, unsigned int col
)
1066 { GetStore()->GetValueByRow( value
, row
, col
); }
1068 void SetTextValue( const wxString
&value
, unsigned int row
, unsigned int col
)
1069 { GetStore()->SetValueByRow( value
, row
, col
);
1070 GetStore()->RowValueChanged( row
, col
); }
1071 wxString
GetTextValue( unsigned int row
, unsigned int col
) const
1072 { wxVariant value
; GetStore()->GetValueByRow( value
, row
, col
); return value
.GetString(); }
1074 void SetToggleValue( bool value
, unsigned int row
, unsigned int col
)
1075 { GetStore()->SetValueByRow( value
, row
, col
);
1076 GetStore()->RowValueChanged( row
, col
); }
1077 bool GetToggleValue( unsigned int row
, unsigned int col
) const
1078 { wxVariant value
; GetStore()->GetValueByRow( value
, row
, col
); return value
.GetBool(); }
1080 void OnSize( wxSizeEvent
&event
);
1083 DECLARE_EVENT_TABLE()
1084 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewListCtrl
)
1087 //-----------------------------------------------------------------------------
1088 // wxDataViewTreeStore
1089 //-----------------------------------------------------------------------------
1091 class WXDLLIMPEXP_ADV wxDataViewTreeStoreNode
1094 wxDataViewTreeStoreNode( wxDataViewTreeStoreNode
*parent
,
1095 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1096 virtual ~wxDataViewTreeStoreNode();
1098 void SetText( const wxString
&text
)
1100 wxString
GetText() const
1102 void SetIcon( const wxIcon
&icon
)
1104 const wxIcon
&GetIcon() const
1106 void SetData( wxClientData
*data
)
1107 { if (m_data
) delete m_data
; m_data
= data
; }
1108 wxClientData
*GetData() const
1111 wxDataViewItem
GetItem() const
1112 { return wxDataViewItem( (void*) this ); }
1114 virtual bool IsContainer()
1117 wxDataViewTreeStoreNode
*GetParent()
1118 { return m_parent
; }
1121 wxDataViewTreeStoreNode
*m_parent
;
1124 wxClientData
*m_data
;
1127 WX_DECLARE_LIST_WITH_DECL(wxDataViewTreeStoreNode
, wxDataViewTreeStoreNodeList
,
1128 class WXDLLIMPEXP_ADV
);
1130 class WXDLLIMPEXP_ADV wxDataViewTreeStoreContainerNode
: public wxDataViewTreeStoreNode
1133 wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode
*parent
,
1134 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1135 wxClientData
*data
= NULL
);
1136 virtual ~wxDataViewTreeStoreContainerNode();
1138 const wxDataViewTreeStoreNodeList
&GetChildren() const
1139 { return m_children
; }
1140 wxDataViewTreeStoreNodeList
&GetChildren()
1141 { return m_children
; }
1143 void SetExpandedIcon( const wxIcon
&icon
)
1144 { m_iconExpanded
= icon
; }
1145 const wxIcon
&GetExpandedIcon() const
1146 { return m_iconExpanded
; }
1148 void SetExpanded( bool expanded
= true )
1149 { m_isExpanded
= expanded
; }
1150 bool IsExpanded() const
1151 { return m_isExpanded
; }
1153 virtual bool IsContainer()
1157 wxDataViewTreeStoreNodeList m_children
;
1158 wxIcon m_iconExpanded
;
1162 //-----------------------------------------------------------------------------
1164 class WXDLLIMPEXP_ADV wxDataViewTreeStore
: public wxDataViewModel
1167 wxDataViewTreeStore();
1168 ~wxDataViewTreeStore();
1170 wxDataViewItem
AppendItem( const wxDataViewItem
& parent
,
1171 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1172 wxDataViewItem
PrependItem( const wxDataViewItem
& parent
,
1173 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1174 wxDataViewItem
InsertItem( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1175 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1177 wxDataViewItem
PrependContainer( const wxDataViewItem
& parent
,
1178 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1179 wxClientData
*data
= NULL
);
1180 wxDataViewItem
AppendContainer( const wxDataViewItem
& parent
,
1181 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1182 wxClientData
*data
= NULL
);
1183 wxDataViewItem
InsertContainer( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1184 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1185 wxClientData
*data
= NULL
);
1187 wxDataViewItem
GetNthChild( const wxDataViewItem
& parent
, unsigned int pos
) const;
1188 int GetChildCount( const wxDataViewItem
& parent
) const;
1190 void SetItemText( const wxDataViewItem
& item
, const wxString
&text
);
1191 wxString
GetItemText( const wxDataViewItem
& item
) const;
1192 void SetItemIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1193 const wxIcon
&GetItemIcon( const wxDataViewItem
& item
) const;
1194 void SetItemExpandedIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1195 const wxIcon
&GetItemExpandedIcon( const wxDataViewItem
& item
) const;
1196 void SetItemData( const wxDataViewItem
& item
, wxClientData
*data
);
1197 wxClientData
*GetItemData( const wxDataViewItem
& item
) const;
1199 void DeleteItem( const wxDataViewItem
& item
);
1200 void DeleteChildren( const wxDataViewItem
& item
);
1201 void DeleteAllItems();
1203 // implement base methods
1205 virtual void GetValue( wxVariant
&variant
,
1206 const wxDataViewItem
&item
, unsigned int col
) const;
1207 virtual bool SetValue( const wxVariant
&variant
,
1208 const wxDataViewItem
&item
, unsigned int col
);
1209 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const;
1210 virtual bool IsContainer( const wxDataViewItem
&item
) const;
1211 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
1213 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
1214 unsigned int column
, bool ascending
) const;
1216 virtual bool HasDefaultCompare() const
1218 virtual unsigned int GetColumnCount() const
1220 virtual wxString
GetColumnType( unsigned int WXUNUSED(col
) ) const
1221 { return wxT("wxDataViewIconText"); }
1223 wxDataViewTreeStoreNode
*FindNode( const wxDataViewItem
&item
) const;
1224 wxDataViewTreeStoreContainerNode
*FindContainerNode( const wxDataViewItem
&item
) const;
1225 wxDataViewTreeStoreNode
*GetRoot() const { return m_root
; }
1228 wxDataViewTreeStoreNode
*m_root
;
1231 //-----------------------------------------------------------------------------
1233 class WXDLLIMPEXP_ADV wxDataViewTreeCtrl
: public wxDataViewCtrl
1236 wxDataViewTreeCtrl() { Init(); }
1237 wxDataViewTreeCtrl(wxWindow
*parent
,
1239 const wxPoint
& pos
= wxDefaultPosition
,
1240 const wxSize
& size
= wxDefaultSize
,
1241 long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
1242 const wxValidator
& validator
= wxDefaultValidator
)
1246 Create(parent
, id
, pos
, size
, style
, validator
);
1249 virtual ~wxDataViewTreeCtrl();
1251 bool Create(wxWindow
*parent
,
1253 const wxPoint
& pos
= wxDefaultPosition
,
1254 const wxSize
& size
= wxDefaultSize
,
1255 long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
1256 const wxValidator
& validator
= wxDefaultValidator
);
1258 wxDataViewTreeStore
*GetStore()
1259 { return (wxDataViewTreeStore
*) GetModel(); }
1260 const wxDataViewTreeStore
*GetStore() const
1261 { return (const wxDataViewTreeStore
*) GetModel(); }
1263 bool IsContainer( const wxDataViewItem
& item
) const
1264 { return GetStore()->IsContainer(item
); }
1266 void SetImageList( wxImageList
*imagelist
);
1267 wxImageList
* GetImageList() { return m_imageList
; }
1269 wxDataViewItem
AppendItem( const wxDataViewItem
& parent
,
1270 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1271 wxDataViewItem
PrependItem( const wxDataViewItem
& parent
,
1272 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1273 wxDataViewItem
InsertItem( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1274 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1276 wxDataViewItem
PrependContainer( const wxDataViewItem
& parent
,
1277 const wxString
&text
, int icon
= -1, int expanded
= -1,
1278 wxClientData
*data
= NULL
);
1279 wxDataViewItem
AppendContainer( const wxDataViewItem
& parent
,
1280 const wxString
&text
, int icon
= -1, int expanded
= -1,
1281 wxClientData
*data
= NULL
);
1282 wxDataViewItem
InsertContainer( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1283 const wxString
&text
, int icon
= -1, int expanded
= -1,
1284 wxClientData
*data
= NULL
);
1286 wxDataViewItem
GetNthChild( const wxDataViewItem
& parent
, unsigned int pos
) const
1287 { return GetStore()->GetNthChild(parent
, pos
); }
1288 int GetChildCount( const wxDataViewItem
& parent
) const
1289 { return GetStore()->GetChildCount(parent
); }
1291 void SetItemText( const wxDataViewItem
& item
, const wxString
&text
);
1292 wxString
GetItemText( const wxDataViewItem
& item
) const
1293 { return GetStore()->GetItemText(item
); }
1294 void SetItemIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1295 const wxIcon
&GetItemIcon( const wxDataViewItem
& item
) const
1296 { return GetStore()->GetItemIcon(item
); }
1297 void SetItemExpandedIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1298 const wxIcon
&GetItemExpandedIcon( const wxDataViewItem
& item
) const
1299 { return GetStore()->GetItemExpandedIcon(item
); }
1300 void SetItemData( const wxDataViewItem
& item
, wxClientData
*data
)
1301 { GetStore()->SetItemData(item
,data
); }
1302 wxClientData
*GetItemData( const wxDataViewItem
& item
) const
1303 { return GetStore()->GetItemData(item
); }
1305 void DeleteItem( const wxDataViewItem
& item
);
1306 void DeleteChildren( const wxDataViewItem
& item
);
1307 void DeleteAllItems();
1309 void OnExpanded( wxDataViewEvent
&event
);
1310 void OnCollapsed( wxDataViewEvent
&event
);
1311 void OnSize( wxSizeEvent
&event
);
1319 wxImageList
*m_imageList
;
1322 DECLARE_EVENT_TABLE()
1323 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl
)
1326 #endif // wxUSE_DATAVIEWCTRL
1329 // _WX_DATAVIEW_H_BASE_