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 // ----------------------------------------------------------------------------
36 // wxDataViewCtrl globals
37 // ----------------------------------------------------------------------------
39 class WXDLLIMPEXP_FWD_ADV wxDataViewItem
;
40 class WXDLLIMPEXP_FWD_ADV wxDataViewModel
;
41 class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl
;
42 class WXDLLIMPEXP_FWD_ADV wxDataViewColumn
;
43 class WXDLLIMPEXP_FWD_ADV wxDataViewRenderer
;
44 class WXDLLIMPEXP_FWD_ADV wxDataViewModelNotifier
;
46 extern WXDLLIMPEXP_DATA_ADV(const char) wxDataViewCtrlNameStr
[];
48 // ----------------------------------------------------------------------------
49 // wxDataViewCtrl flags
50 // ----------------------------------------------------------------------------
52 // size of a wxDataViewRenderer without contents:
53 #define wxDVC_DEFAULT_RENDERER_SIZE 20
55 // the default width of new (text) columns:
56 #define wxDVC_DEFAULT_WIDTH 80
58 // the default width of new toggle columns:
59 #define wxDVC_TOGGLE_DEFAULT_WIDTH 30
61 // the default minimal width of the columns:
62 #define wxDVC_DEFAULT_MINWIDTH 30
64 // The default alignment of wxDataViewRenderers is to take
65 // the alignment from the column it owns.
66 #define wxDVR_DEFAULT_ALIGNMENT -1
69 // ---------------------------------------------------------
71 // ---------------------------------------------------------
73 class WXDLLIMPEXP_ADV wxDataViewItem
76 wxDataViewItem( void* id
= NULL
)
78 wxDataViewItem( const wxDataViewItem
&item
)
80 bool IsOk() const { return m_id
!= NULL
; }
81 void* GetID() const { return m_id
; }
82 operator const void* () const { return m_id
; }
89 bool operator==(const wxDataViewItem
& left
, const wxDataViewItem
& right
)
91 return left
.GetID() == right
.GetID();
95 bool operator!=(const wxDataViewItem
& left
, const wxDataViewItem
& right
)
97 return !(left
== right
);
100 WX_DEFINE_ARRAY(wxDataViewItem
, wxDataViewItemArray
);
102 // ---------------------------------------------------------
103 // wxDataViewModelNotifier
104 // ---------------------------------------------------------
106 class WXDLLIMPEXP_ADV wxDataViewModelNotifier
109 wxDataViewModelNotifier() { m_owner
= NULL
; }
110 virtual ~wxDataViewModelNotifier() { m_owner
= NULL
; }
112 virtual bool ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
) = 0;
113 virtual bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
) = 0;
114 virtual bool ItemChanged( const wxDataViewItem
&item
) = 0;
115 virtual bool ItemsAdded( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
116 virtual bool ItemsDeleted( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
117 virtual bool ItemsChanged( const wxDataViewItemArray
&items
);
118 virtual bool ValueChanged( const wxDataViewItem
&item
, unsigned int col
) = 0;
119 virtual bool Cleared() = 0;
121 virtual void Resort() = 0;
123 void SetOwner( wxDataViewModel
*owner
) { m_owner
= owner
; }
124 wxDataViewModel
*GetOwner() const { return m_owner
; }
127 wxDataViewModel
*m_owner
;
132 // ----------------------------------------------------------------------------
133 // wxDataViewItemAttr: a structure containing the visual attributes of an item
134 // ----------------------------------------------------------------------------
136 // TODO: this should be renamed to wxItemAttr or something general like this
138 class WXDLLIMPEXP_ADV wxDataViewItemAttr
149 void SetColour(const wxColour
& colour
) { m_colour
= colour
; }
150 void SetBold( bool set
) { m_bold
= set
; }
151 void SetItalic( bool set
) { m_italic
= set
; }
154 bool HasColour() const { return m_colour
.Ok(); }
155 const wxColour
& GetColour() const { return m_colour
; }
157 bool HasFont() const { return m_bold
|| m_italic
; }
158 bool GetBold() const { return m_bold
; }
159 bool GetItalic() const { return m_italic
; }
168 // ---------------------------------------------------------
170 // ---------------------------------------------------------
172 WX_DECLARE_LIST_WITH_DECL(wxDataViewModelNotifier
, wxDataViewModelNotifiers
,
173 class WXDLLIMPEXP_ADV
);
175 class WXDLLIMPEXP_ADV wxDataViewModel
: public wxRefCounter
180 virtual unsigned int GetColumnCount() const = 0;
182 // return type as reported by wxVariant
183 virtual wxString
GetColumnType( unsigned int col
) const = 0;
185 // get value into a wxVariant
186 virtual void GetValue( wxVariant
&variant
,
187 const wxDataViewItem
&item
, unsigned int col
) const = 0;
189 // return true if the given item has a value to display in the given
190 // column: this is always true except for container items which by default
191 // only show their label in the first column (but see HasContainerColumns())
192 bool HasValue(const wxDataViewItem
& item
, unsigned col
) const
194 return col
== 0 || !IsContainer(item
) || HasContainerColumns(item
);
197 // usually ValueChanged() should be called after changing the value in the
198 // model to update the control, ChangeValue() does it on its own while
199 // SetValue() does not -- so while you will override SetValue(), you should
200 // be usually calling ChangeValue()
201 virtual bool SetValue(const wxVariant
&variant
,
202 const wxDataViewItem
&item
,
203 unsigned int col
) = 0;
205 bool ChangeValue(const wxVariant
& variant
,
206 const wxDataViewItem
& item
,
209 return SetValue(variant
, item
, col
) && ValueChanged(item
, col
);
212 // Get text attribute, return false of default attributes should be used
213 virtual bool GetAttr( const wxDataViewItem
&WXUNUSED(item
), unsigned int WXUNUSED(col
), wxDataViewItemAttr
&WXUNUSED(attr
) )
217 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const = 0;
218 virtual bool IsContainer( const wxDataViewItem
&item
) const = 0;
219 // Is the container just a header or an item with all columns
220 virtual bool HasContainerColumns(const wxDataViewItem
& WXUNUSED(item
)) const
222 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const = 0;
224 // delegated notifiers
225 virtual bool ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
226 virtual bool ItemsAdded( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
227 virtual bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
228 virtual bool ItemsDeleted( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
229 virtual bool ItemChanged( const wxDataViewItem
&item
);
230 virtual bool ItemsChanged( const wxDataViewItemArray
&items
);
231 virtual bool ValueChanged( const wxDataViewItem
&item
, unsigned int col
);
232 virtual bool Cleared();
235 virtual void Resort();
237 void AddNotifier( wxDataViewModelNotifier
*notifier
);
238 void RemoveNotifier( wxDataViewModelNotifier
*notifier
);
240 // default compare function
241 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
242 unsigned int column
, bool ascending
) const;
243 virtual bool HasDefaultCompare() const { return false; }
246 virtual bool IsVirtualListModel() const { return false; }
249 // the user should not delete this class directly: he should use DecRef() instead!
250 virtual ~wxDataViewModel() { }
252 wxDataViewModelNotifiers m_notifiers
;
255 // ----------------------------------------------------------------------------
256 // wxDataViewListModel: a model of a list, i.e. flat data structure without any
257 // branches/containers, used as base class by wxDataViewIndexListModel and
258 // wxDataViewVirtualListModel
259 // ----------------------------------------------------------------------------
261 class WXDLLIMPEXP_ADV wxDataViewListModel
: public wxDataViewModel
264 // derived classes should override these methods instead of
265 // {Get,Set}Value() and GetAttr() inherited from the base class
267 virtual void GetValueByRow(wxVariant
&variant
,
268 unsigned row
, unsigned col
) const = 0;
270 virtual bool SetValueByRow(const wxVariant
&variant
,
271 unsigned row
, unsigned col
) = 0;
274 GetAttrByRow(unsigned WXUNUSED(row
), unsigned WXUNUSED(col
),
275 wxDataViewItemAttr
&WXUNUSED(attr
))
281 // helper methods provided by list models only
282 virtual unsigned GetRow( const wxDataViewItem
&item
) const = 0;
285 // implement some base class pure virtual directly
286 virtual wxDataViewItem
287 GetParent( const wxDataViewItem
& WXUNUSED(item
) ) const
289 // items never have valid parent in this model
290 return wxDataViewItem();
293 virtual bool IsContainer( const wxDataViewItem
&item
) const
295 // only the invisible (and invalid) root item has children
299 // and implement some others by forwarding them to our own ones
300 virtual void GetValue( wxVariant
&variant
,
301 const wxDataViewItem
&item
, unsigned int col
) const
303 GetValueByRow(variant
, GetRow(item
), col
);
306 virtual bool SetValue( const wxVariant
&variant
,
307 const wxDataViewItem
&item
, unsigned int col
)
309 return SetValueByRow( variant
, GetRow(item
), col
);
312 virtual bool GetAttr(const wxDataViewItem
&item
, unsigned int col
,
313 wxDataViewItemAttr
&attr
)
315 return GetAttrByRow( GetRow(item
), col
, attr
);
319 // ---------------------------------------------------------
320 // wxDataViewIndexListModel
321 // ---------------------------------------------------------
323 class WXDLLIMPEXP_ADV wxDataViewIndexListModel
: public wxDataViewListModel
326 wxDataViewIndexListModel( unsigned int initial_size
= 0 );
329 void RowInserted( unsigned int before
);
331 void RowDeleted( unsigned int row
);
332 void RowsDeleted( const wxArrayInt
&rows
);
333 void RowChanged( unsigned int row
);
334 void RowValueChanged( unsigned int row
, unsigned int col
);
335 void Reset( unsigned int new_size
);
337 // convert to/from row/wxDataViewItem
339 virtual unsigned GetRow( const wxDataViewItem
&item
) const;
340 wxDataViewItem
GetItem( unsigned int row
) const;
342 // compare based on index
344 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
345 unsigned int column
, bool ascending
) const;
346 virtual bool HasDefaultCompare() const;
348 // implement base methods
349 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
352 unsigned int GetCount() const { return m_hash
.GetCount(); }
355 wxDataViewItemArray m_hash
;
356 unsigned int m_nextFreeID
;
360 // ---------------------------------------------------------
361 // wxDataViewVirtualListModel
362 // ---------------------------------------------------------
365 // better than nothing
366 typedef wxDataViewIndexListModel wxDataViewVirtualListModel
;
369 class WXDLLIMPEXP_ADV wxDataViewVirtualListModel
: public wxDataViewListModel
372 wxDataViewVirtualListModel( unsigned int initial_size
= 0 );
375 void RowInserted( unsigned int before
);
377 void RowDeleted( unsigned int row
);
378 void RowsDeleted( const wxArrayInt
&rows
);
379 void RowChanged( unsigned int row
);
380 void RowValueChanged( unsigned int row
, unsigned int col
);
381 void Reset( unsigned int new_size
);
383 // convert to/from row/wxDataViewItem
385 virtual unsigned GetRow( const wxDataViewItem
&item
) const;
386 wxDataViewItem
GetItem( unsigned int row
) const;
388 // compare based on index
390 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
391 unsigned int column
, bool ascending
) const;
392 virtual bool HasDefaultCompare() const;
394 // implement base methods
395 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
398 virtual bool IsVirtualListModel() const { return true; }
399 unsigned int GetCount() const { return m_size
; }
407 //-----------------------------------------------------------------------------
408 // wxDataViewEditorCtrlEvtHandler
409 //-----------------------------------------------------------------------------
411 class wxDataViewEditorCtrlEvtHandler
: public wxEvtHandler
414 wxDataViewEditorCtrlEvtHandler( wxControl
*editor
, wxDataViewRenderer
*owner
);
416 void AcceptChangesAndFinish();
417 void SetFocusOnIdle( bool focus
= true ) { m_focusOnIdle
= focus
; }
420 void OnChar( wxKeyEvent
&event
);
421 void OnTextEnter( wxCommandEvent
&event
);
422 void OnKillFocus( wxFocusEvent
&event
);
423 void OnIdle( wxIdleEvent
&event
);
426 wxDataViewRenderer
*m_owner
;
427 wxControl
*m_editorCtrl
;
432 DECLARE_EVENT_TABLE()
435 // ---------------------------------------------------------
436 // wxDataViewRendererBase
437 // ---------------------------------------------------------
439 enum wxDataViewCellMode
441 wxDATAVIEW_CELL_INERT
,
442 wxDATAVIEW_CELL_ACTIVATABLE
,
443 wxDATAVIEW_CELL_EDITABLE
446 enum wxDataViewCellRenderState
448 wxDATAVIEW_CELL_SELECTED
= 1,
449 wxDATAVIEW_CELL_PRELIT
= 2,
450 wxDATAVIEW_CELL_INSENSITIVE
= 4,
451 wxDATAVIEW_CELL_FOCUSED
= 8
454 class WXDLLIMPEXP_ADV wxDataViewRendererBase
: public wxObject
457 wxDataViewRendererBase( const wxString
&varianttype
,
458 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
459 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
460 virtual ~wxDataViewRendererBase();
462 virtual bool Validate( wxVariant
& WXUNUSED(value
) )
465 void SetOwner( wxDataViewColumn
*owner
) { m_owner
= owner
; }
466 wxDataViewColumn
* GetOwner() const { return m_owner
; }
468 // renderer properties:
470 virtual bool SetValue( const wxVariant
& WXUNUSED(value
) ) = 0;
471 virtual bool GetValue( wxVariant
& WXUNUSED(value
) ) const = 0;
473 wxString
GetVariantType() const { return m_variantType
; }
475 virtual void SetMode( wxDataViewCellMode mode
) = 0;
476 virtual wxDataViewCellMode
GetMode() const = 0;
478 // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but
479 // rather an "int"; that's because for rendering cells it's allowed
480 // to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM)
481 virtual void SetAlignment( int align
) = 0;
482 virtual int GetAlignment() const = 0;
484 // enable or disable (if called with wxELLIPSIZE_NONE) replacing parts of
485 // the item text (hence this only makes sense for renderers showing
486 // text...) with ellipsis in order to make it fit the column width
487 virtual void EnableEllipsize(wxEllipsizeMode mode
= wxELLIPSIZE_MIDDLE
) = 0;
488 void DisableEllipsize() { EnableEllipsize(wxELLIPSIZE_NONE
); }
490 virtual wxEllipsizeMode
GetEllipsizeMode() const = 0;
493 virtual bool HasEditorCtrl() const
495 virtual wxControl
* CreateEditorCtrl(wxWindow
* WXUNUSED(parent
),
496 wxRect
WXUNUSED(labelRect
),
497 const wxVariant
& WXUNUSED(value
))
499 virtual bool GetValueFromEditorCtrl(wxControl
* WXUNUSED(editor
),
500 wxVariant
& WXUNUSED(value
))
503 virtual bool StartEditing( const wxDataViewItem
&item
, wxRect labelRect
);
504 virtual void CancelEditing();
505 virtual bool FinishEditing();
507 wxControl
*GetEditorCtrl() { return m_editorCtrl
; }
510 wxString m_variantType
;
511 wxDataViewColumn
*m_owner
;
512 wxWeakRef
<wxControl
> m_editorCtrl
;
513 wxDataViewItem m_item
; // for m_editorCtrl
516 const wxDataViewCtrl
* GetView() const;
519 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase
)
522 //-----------------------------------------------------------------------------
523 // wxDataViewIconText
524 //-----------------------------------------------------------------------------
526 class WXDLLIMPEXP_ADV wxDataViewIconText
: public wxObject
529 wxDataViewIconText( const wxString
&text
= wxEmptyString
, const wxIcon
& icon
= wxNullIcon
)
530 : m_text(text
), m_icon(icon
)
532 wxDataViewIconText( const wxDataViewIconText
&other
)
534 { m_icon
= other
.m_icon
; m_text
= other
.m_text
; }
536 void SetText( const wxString
&text
) { m_text
= text
; }
537 wxString
GetText() const { return m_text
; }
538 void SetIcon( const wxIcon
&icon
) { m_icon
= icon
; }
539 const wxIcon
&GetIcon() const { return m_icon
; }
546 DECLARE_DYNAMIC_CLASS(wxDataViewIconText
)
550 bool operator==(const wxDataViewIconText
& left
, const wxDataViewIconText
& right
)
552 return left
.GetText() == right
.GetText() &&
553 left
.GetIcon().IsSameAs(right
.GetIcon());
557 bool operator!=(const wxDataViewIconText
& left
, const wxDataViewIconText
& right
)
559 return !(left
== right
);
562 DECLARE_VARIANT_OBJECT_EXPORTED(wxDataViewIconText
, WXDLLIMPEXP_ADV
)
564 // ---------------------------------------------------------
565 // wxDataViewColumnBase
566 // ---------------------------------------------------------
568 // for compatibility only, do not use
569 enum wxDataViewColumnFlags
571 wxDATAVIEW_COL_RESIZABLE
= wxCOL_RESIZABLE
,
572 wxDATAVIEW_COL_SORTABLE
= wxCOL_SORTABLE
,
573 wxDATAVIEW_COL_REORDERABLE
= wxCOL_REORDERABLE
,
574 wxDATAVIEW_COL_HIDDEN
= wxCOL_HIDDEN
577 class WXDLLIMPEXP_ADV wxDataViewColumnBase
: public wxSettableHeaderColumn
580 // ctor for the text columns: takes ownership of renderer
581 wxDataViewColumnBase(wxDataViewRenderer
*renderer
,
582 unsigned int model_column
)
584 Init(renderer
, model_column
);
587 // ctor for the bitmap columns
588 wxDataViewColumnBase(const wxBitmap
& bitmap
,
589 wxDataViewRenderer
*renderer
,
590 unsigned int model_column
)
593 Init(renderer
, model_column
);
596 virtual ~wxDataViewColumnBase();
599 virtual void SetOwner( wxDataViewCtrl
*owner
)
603 unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column
); }
604 wxDataViewCtrl
*GetOwner() const { return m_owner
; }
605 wxDataViewRenderer
* GetRenderer() const { return m_renderer
; }
607 // implement some of base class pure virtuals (the rest is port-dependent
608 // and done differently in generic and native versions)
609 virtual void SetBitmap( const wxBitmap
& bitmap
) { m_bitmap
= bitmap
; }
610 virtual wxBitmap
GetBitmap() const { return m_bitmap
; }
613 wxDataViewRenderer
*m_renderer
;
616 wxDataViewCtrl
*m_owner
;
619 // common part of all ctors
620 void Init(wxDataViewRenderer
*renderer
, unsigned int model_column
);
623 // ---------------------------------------------------------
624 // wxDataViewCtrlBase
625 // ---------------------------------------------------------
627 #define wxDV_SINGLE 0x0000 // for convenience
628 #define wxDV_MULTIPLE 0x0001 // can select multiple items
630 #define wxDV_NO_HEADER 0x0002 // column titles not visible
631 #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows
632 #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns
634 #define wxDV_ROW_LINES 0x0010 // alternating colour in rows
635 #define wxDV_VARIABLE_LINE_HEIGHT 0x0020 // variable line height
637 class WXDLLIMPEXP_ADV wxDataViewCtrlBase
: public wxControl
640 wxDataViewCtrlBase();
641 virtual ~wxDataViewCtrlBase();
646 virtual bool AssociateModel( wxDataViewModel
*model
);
647 wxDataViewModel
* GetModel();
648 const wxDataViewModel
* GetModel() const;
654 wxDataViewColumn
*PrependTextColumn( const wxString
&label
, unsigned int model_column
,
655 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
656 wxAlignment align
= wxALIGN_NOT
,
657 int flags
= wxDATAVIEW_COL_RESIZABLE
);
658 wxDataViewColumn
*PrependIconTextColumn( const wxString
&label
, unsigned int model_column
,
659 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
660 wxAlignment align
= wxALIGN_NOT
,
661 int flags
= wxDATAVIEW_COL_RESIZABLE
);
662 wxDataViewColumn
*PrependToggleColumn( const wxString
&label
, unsigned int model_column
,
663 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
664 wxAlignment align
= wxALIGN_CENTER
,
665 int flags
= wxDATAVIEW_COL_RESIZABLE
);
666 wxDataViewColumn
*PrependProgressColumn( const wxString
&label
, unsigned int model_column
,
667 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
668 wxAlignment align
= wxALIGN_CENTER
,
669 int flags
= wxDATAVIEW_COL_RESIZABLE
);
670 wxDataViewColumn
*PrependDateColumn( const wxString
&label
, unsigned int model_column
,
671 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
672 wxAlignment align
= wxALIGN_NOT
,
673 int flags
= wxDATAVIEW_COL_RESIZABLE
);
674 wxDataViewColumn
*PrependBitmapColumn( const wxString
&label
, unsigned int model_column
,
675 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
676 wxAlignment align
= wxALIGN_CENTER
,
677 int flags
= wxDATAVIEW_COL_RESIZABLE
);
678 wxDataViewColumn
*PrependTextColumn( const wxBitmap
&label
, unsigned int model_column
,
679 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
680 wxAlignment align
= wxALIGN_NOT
,
681 int flags
= wxDATAVIEW_COL_RESIZABLE
);
682 wxDataViewColumn
*PrependIconTextColumn( const wxBitmap
&label
, unsigned int model_column
,
683 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
684 wxAlignment align
= wxALIGN_NOT
,
685 int flags
= wxDATAVIEW_COL_RESIZABLE
);
686 wxDataViewColumn
*PrependToggleColumn( const wxBitmap
&label
, unsigned int model_column
,
687 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
688 wxAlignment align
= wxALIGN_CENTER
,
689 int flags
= wxDATAVIEW_COL_RESIZABLE
);
690 wxDataViewColumn
*PrependProgressColumn( const wxBitmap
&label
, unsigned int model_column
,
691 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
692 wxAlignment align
= wxALIGN_CENTER
,
693 int flags
= wxDATAVIEW_COL_RESIZABLE
);
694 wxDataViewColumn
*PrependDateColumn( const wxBitmap
&label
, unsigned int model_column
,
695 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
696 wxAlignment align
= wxALIGN_NOT
,
697 int flags
= wxDATAVIEW_COL_RESIZABLE
);
698 wxDataViewColumn
*PrependBitmapColumn( const wxBitmap
&label
, unsigned int model_column
,
699 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
700 wxAlignment align
= wxALIGN_CENTER
,
701 int flags
= wxDATAVIEW_COL_RESIZABLE
);
703 wxDataViewColumn
*AppendTextColumn( const wxString
&label
, unsigned int model_column
,
704 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
705 wxAlignment align
= wxALIGN_NOT
,
706 int flags
= wxDATAVIEW_COL_RESIZABLE
);
707 wxDataViewColumn
*AppendIconTextColumn( const wxString
&label
, unsigned int model_column
,
708 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
709 wxAlignment align
= wxALIGN_NOT
,
710 int flags
= wxDATAVIEW_COL_RESIZABLE
);
711 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
, unsigned int model_column
,
712 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
713 wxAlignment align
= wxALIGN_CENTER
,
714 int flags
= wxDATAVIEW_COL_RESIZABLE
);
715 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
, unsigned int model_column
,
716 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
717 wxAlignment align
= wxALIGN_CENTER
,
718 int flags
= wxDATAVIEW_COL_RESIZABLE
);
719 wxDataViewColumn
*AppendDateColumn( const wxString
&label
, unsigned int model_column
,
720 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
721 wxAlignment align
= wxALIGN_NOT
,
722 int flags
= wxDATAVIEW_COL_RESIZABLE
);
723 wxDataViewColumn
*AppendBitmapColumn( const wxString
&label
, unsigned int model_column
,
724 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
725 wxAlignment align
= wxALIGN_CENTER
,
726 int flags
= wxDATAVIEW_COL_RESIZABLE
);
727 wxDataViewColumn
*AppendTextColumn( const wxBitmap
&label
, unsigned int model_column
,
728 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
729 wxAlignment align
= wxALIGN_NOT
,
730 int flags
= wxDATAVIEW_COL_RESIZABLE
);
731 wxDataViewColumn
*AppendIconTextColumn( const wxBitmap
&label
, unsigned int model_column
,
732 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
733 wxAlignment align
= wxALIGN_NOT
,
734 int flags
= wxDATAVIEW_COL_RESIZABLE
);
735 wxDataViewColumn
*AppendToggleColumn( const wxBitmap
&label
, unsigned int model_column
,
736 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
737 wxAlignment align
= wxALIGN_CENTER
,
738 int flags
= wxDATAVIEW_COL_RESIZABLE
);
739 wxDataViewColumn
*AppendProgressColumn( const wxBitmap
&label
, unsigned int model_column
,
740 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
741 wxAlignment align
= wxALIGN_CENTER
,
742 int flags
= wxDATAVIEW_COL_RESIZABLE
);
743 wxDataViewColumn
*AppendDateColumn( const wxBitmap
&label
, unsigned int model_column
,
744 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
745 wxAlignment align
= wxALIGN_NOT
,
746 int flags
= wxDATAVIEW_COL_RESIZABLE
);
747 wxDataViewColumn
*AppendBitmapColumn( const wxBitmap
&label
, unsigned int model_column
,
748 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
749 wxAlignment align
= wxALIGN_CENTER
,
750 int flags
= wxDATAVIEW_COL_RESIZABLE
);
752 virtual bool PrependColumn( wxDataViewColumn
*col
);
753 virtual bool InsertColumn( unsigned int pos
, wxDataViewColumn
*col
);
754 virtual bool AppendColumn( wxDataViewColumn
*col
);
756 virtual unsigned int GetColumnCount() const = 0;
757 virtual wxDataViewColumn
* GetColumn( unsigned int pos
) const = 0;
758 virtual int GetColumnPosition( const wxDataViewColumn
*column
) const = 0;
760 virtual bool DeleteColumn( wxDataViewColumn
*column
) = 0;
761 virtual bool ClearColumns() = 0;
763 void SetExpanderColumn( wxDataViewColumn
*col
)
764 { m_expander_column
= col
; DoSetExpanderColumn(); }
765 wxDataViewColumn
*GetExpanderColumn() const
766 { return m_expander_column
; }
768 virtual wxDataViewColumn
*GetSortingColumn() const = 0;
774 void SetIndent( int indent
)
775 { m_indent
= indent
; DoSetIndent(); }
776 int GetIndent() const
779 virtual wxDataViewItem
GetSelection() const = 0;
780 virtual int GetSelections( wxDataViewItemArray
& sel
) const = 0;
781 virtual void SetSelections( const wxDataViewItemArray
& sel
) = 0;
782 virtual void Select( const wxDataViewItem
& item
) = 0;
783 virtual void Unselect( const wxDataViewItem
& item
) = 0;
784 virtual bool IsSelected( const wxDataViewItem
& item
) const = 0;
786 virtual void SelectAll() = 0;
787 virtual void UnselectAll() = 0;
789 virtual void Expand( const wxDataViewItem
& item
) = 0;
790 virtual void ExpandAncestors( const wxDataViewItem
& item
);
791 virtual void Collapse( const wxDataViewItem
& item
) = 0;
792 virtual bool IsExpanded( const wxDataViewItem
& item
) const = 0;
794 virtual void EnsureVisible( const wxDataViewItem
& item
,
795 const wxDataViewColumn
*column
= NULL
) = 0;
796 virtual void HitTest( const wxPoint
& point
, wxDataViewItem
&item
, wxDataViewColumn
* &column
) const = 0;
797 virtual wxRect
GetItemRect( const wxDataViewItem
& item
, const wxDataViewColumn
*column
= NULL
) const = 0;
799 #if wxUSE_DRAG_AND_DROP
800 virtual bool EnableDragSource(const wxDataFormat
& WXUNUSED(format
))
802 virtual bool EnableDropTarget(const wxDataFormat
& WXUNUSED(format
))
804 #endif // wxUSE_DRAG_AND_DROP
806 // define control visual attributes
807 // --------------------------------
809 virtual wxVisualAttributes
GetDefaultAttributes() const
811 return GetClassDefaultAttributes(GetWindowVariant());
814 static wxVisualAttributes
815 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
)
817 return wxControl::GetCompositeControlsDefaultAttributes(variant
);
821 virtual void DoSetExpanderColumn() = 0 ;
822 virtual void DoSetIndent() = 0;
825 wxDataViewModel
*m_model
;
826 wxDataViewColumn
*m_expander_column
;
830 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase
)
833 // ----------------------------------------------------------------------------
834 // wxDataViewEvent - the event class for the wxDataViewCtrl notifications
835 // ----------------------------------------------------------------------------
837 class WXDLLIMPEXP_ADV wxDataViewEvent
: public wxNotifyEvent
840 wxDataViewEvent(wxEventType commandType
= wxEVT_NULL
, int winid
= 0)
841 : wxNotifyEvent(commandType
, winid
),
845 m_value(wxNullVariant
),
850 #if wxUSE_DRAG_AND_DROP
851 , m_dataObject(NULL
),
857 wxDataViewEvent(const wxDataViewEvent
& event
)
858 : wxNotifyEvent(event
),
859 m_item(event
.m_item
),
861 m_model(event
.m_model
),
862 m_value(event
.m_value
),
863 m_column(event
.m_column
),
865 m_cacheFrom(event
.m_cacheFrom
),
866 m_cacheTo(event
.m_cacheTo
)
867 #if wxUSE_DRAG_AND_DROP
868 , m_dataObject(event
.m_dataObject
),
869 m_dataFormat(event
.m_dataFormat
),
870 m_dataBuffer(event
.m_dataBuffer
),
871 m_dataSize(event
.m_dataSize
)
875 wxDataViewItem
GetItem() const { return m_item
; }
876 void SetItem( const wxDataViewItem
&item
) { m_item
= item
; }
878 int GetColumn() const { return m_col
; }
879 void SetColumn( int col
) { m_col
= col
; }
881 wxDataViewModel
* GetModel() const { return m_model
; }
882 void SetModel( wxDataViewModel
*model
) { m_model
= model
; }
884 const wxVariant
&GetValue() const { return m_value
; }
885 void SetValue( const wxVariant
&value
) { m_value
= value
; }
887 // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only
888 void SetDataViewColumn( wxDataViewColumn
*col
) { m_column
= col
; }
889 wxDataViewColumn
*GetDataViewColumn() const { return m_column
; }
891 // for wxEVT_DATAVIEW_CONTEXT_MENU only
892 wxPoint
GetPosition() const { return m_pos
; }
893 void SetPosition( int x
, int y
) { m_pos
.x
= x
; m_pos
.y
= y
; }
895 // For wxEVT_COMMAND_DATAVIEW_CACHE_HINT
896 int GetCacheFrom() const { return m_cacheFrom
; }
897 int GetCacheTo() const { return m_cacheTo
; }
898 void SetCache(int from
, int to
) { m_cacheFrom
= from
; m_cacheTo
= to
; }
901 #if wxUSE_DRAG_AND_DROP
902 // For drag operations
903 void SetDataObject( wxDataObject
*obj
) { m_dataObject
= obj
; }
904 wxDataObject
*GetDataObject() const { return m_dataObject
; }
906 // For drop operations
907 void SetDataFormat( const wxDataFormat
&format
) { m_dataFormat
= format
; }
908 wxDataFormat
GetDataFormat() const { return m_dataFormat
; }
909 void SetDataSize( size_t size
) { m_dataSize
= size
; }
910 size_t GetDataSize() const { return m_dataSize
; }
911 void SetDataBuffer( void* buf
) { m_dataBuffer
= buf
;}
912 void *GetDataBuffer() const { return m_dataBuffer
; }
913 #endif // wxUSE_DRAG_AND_DROP
915 virtual wxEvent
*Clone() const { return new wxDataViewEvent(*this); }
918 wxDataViewItem m_item
;
920 wxDataViewModel
*m_model
;
922 wxDataViewColumn
*m_column
;
927 #if wxUSE_DRAG_AND_DROP
928 wxDataObject
*m_dataObject
;
930 wxDataFormat m_dataFormat
;
933 #endif // wxUSE_DRAG_AND_DROP
936 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent
)
939 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED
, wxDataViewEvent
);
941 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED
, wxDataViewEvent
);
942 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED
, wxDataViewEvent
);
943 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED
, wxDataViewEvent
);
944 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING
, wxDataViewEvent
);
945 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING
, wxDataViewEvent
);
946 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING
, wxDataViewEvent
);
947 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED
, wxDataViewEvent
);
948 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE
, wxDataViewEvent
);
949 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED
, wxDataViewEvent
);
951 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU
, wxDataViewEvent
);
953 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK
, wxDataViewEvent
);
954 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK
, wxDataViewEvent
);
955 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED
, wxDataViewEvent
);
956 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED
, wxDataViewEvent
);
958 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_CACHE_HINT
, wxDataViewEvent
);
960 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG
, wxDataViewEvent
);
961 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE
, wxDataViewEvent
);
962 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_DROP
, wxDataViewEvent
);
964 typedef void (wxEvtHandler::*wxDataViewEventFunction
)(wxDataViewEvent
&);
966 #define wxDataViewEventHandler(func) \
967 wxEVENT_HANDLER_CAST(wxDataViewEventFunction, func)
969 #define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \
970 wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn))
972 #define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn)
974 #define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn)
975 #define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn)
976 #define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn)
977 #define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn)
978 #define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn)
979 #define EVT_DATAVIEW_ITEM_START_EDITING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_START_EDITING, id, fn)
980 #define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn)
981 #define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn)
982 #define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn)
984 #define EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_CONTEXT_MENU, id, fn)
986 #define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn)
987 #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn)
988 #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn)
989 #define EVT_DATAVIEW_COLUMN_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_REORDERED, id, fn)
990 #define EVT_DATAVIEW_CACHE_HINT(id, fn) wx__DECLARE_DATAVIEWEVT(CACHE_HINT, id, fn)
992 #define EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_BEGIN_DRAG, id, fn)
993 #define EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP_POSSIBLE, id, fn)
994 #define EVT_DATAVIEW_ITEM_DROP(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP, id, fn)
996 #ifdef wxHAS_GENERIC_DATAVIEWCTRL
997 // this symbol doesn't follow the convention for wxUSE_XXX symbols which
998 // are normally always defined as either 0 or 1, so its use is deprecated
999 // and it only exists for backwards compatibility, don't use it any more
1000 // and use wxHAS_GENERIC_DATAVIEWCTRL instead
1001 #define wxUSE_GENERICDATAVIEWCTRL
1003 #include "wx/generic/dataview.h"
1004 #elif defined(__WXGTK20__)
1005 #include "wx/gtk/dataview.h"
1006 #elif defined(__WXMAC__)
1007 #include "wx/osx/dataview.h"
1009 #error "unknown native wxDataViewCtrl implementation"
1012 // -------------------------------------
1013 // wxDataViewSpinRenderer
1014 // -------------------------------------
1016 class WXDLLIMPEXP_ADV wxDataViewSpinRenderer
: public wxDataViewCustomRenderer
1019 wxDataViewSpinRenderer( int min
, int max
,
1020 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
1021 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
1022 virtual bool HasEditorCtrl() const { return true; }
1023 virtual wxControl
* CreateEditorCtrl( wxWindow
*parent
, wxRect labelRect
, const wxVariant
&value
);
1024 virtual bool GetValueFromEditorCtrl( wxControl
* editor
, wxVariant
&value
);
1025 virtual bool Render( wxRect rect
, wxDC
*dc
, int state
);
1026 virtual wxSize
GetSize() const;
1027 virtual bool SetValue( const wxVariant
&value
);
1028 virtual bool GetValue( wxVariant
&value
) const;
1035 #if defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXOSX_CARBON__)
1037 // -------------------------------------
1038 // wxDataViewChoiceRenderer
1039 // -------------------------------------
1041 class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer
: public wxDataViewCustomRenderer
1044 wxDataViewChoiceRenderer( const wxArrayString
&choices
,
1045 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
1046 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
1047 virtual bool HasEditorCtrl() const { return true; }
1048 virtual wxControl
* CreateEditorCtrl( wxWindow
*parent
, wxRect labelRect
, const wxVariant
&value
);
1049 virtual bool GetValueFromEditorCtrl( wxControl
* editor
, wxVariant
&value
);
1050 virtual bool Render( wxRect rect
, wxDC
*dc
, int state
);
1051 virtual wxSize
GetSize() const;
1052 virtual bool SetValue( const wxVariant
&value
);
1053 virtual bool GetValue( wxVariant
&value
) const;
1056 wxArrayString m_choices
;
1062 // this class is obsolete, its functionality was merged in
1063 // wxDataViewTextRenderer itself now, don't use it any more
1064 #define wxDataViewTextRendererAttr wxDataViewTextRenderer
1066 //-----------------------------------------------------------------------------
1067 // wxDataViewListStore
1068 //-----------------------------------------------------------------------------
1070 class WXDLLIMPEXP_ADV wxDataViewListStoreLine
1073 wxDataViewListStoreLine( wxClientData
*data
= NULL
)
1077 virtual ~wxDataViewListStoreLine()
1082 void SetData( wxClientData
*data
)
1083 { if (m_data
) delete m_data
; m_data
= data
; }
1084 wxClientData
*GetData() const
1087 wxVector
<wxVariant
> m_values
;
1090 wxClientData
*m_data
;
1094 class WXDLLIMPEXP_ADV wxDataViewListStore
: public wxDataViewIndexListModel
1097 wxDataViewListStore();
1098 ~wxDataViewListStore();
1100 void PrependColumn( const wxString
&varianttype
);
1101 void InsertColumn( unsigned int pos
, const wxString
&varianttype
);
1102 void AppendColumn( const wxString
&varianttype
);
1104 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1105 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1106 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1107 void DeleteItem( unsigned int pos
);
1108 void DeleteAllItems();
1110 // override base virtuals
1112 virtual unsigned int GetColumnCount() const;
1114 virtual wxString
GetColumnType( unsigned int col
) const;
1116 virtual void GetValueByRow( wxVariant
&value
,
1117 unsigned int row
, unsigned int col
) const;
1119 virtual bool SetValueByRow( const wxVariant
&value
,
1120 unsigned int row
, unsigned int col
);
1124 wxVector
<wxDataViewListStoreLine
*> m_data
;
1125 wxArrayString m_cols
;
1128 //-----------------------------------------------------------------------------
1130 class WXDLLIMPEXP_ADV wxDataViewListCtrl
: public wxDataViewCtrl
1133 wxDataViewListCtrl();
1134 wxDataViewListCtrl( wxWindow
*parent
, wxWindowID id
,
1135 const wxPoint
& pos
= wxDefaultPosition
,
1136 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
1137 const wxValidator
& validator
= wxDefaultValidator
);
1138 ~wxDataViewListCtrl();
1140 bool Create( wxWindow
*parent
, wxWindowID id
,
1141 const wxPoint
& pos
= wxDefaultPosition
,
1142 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
1143 const wxValidator
& validator
= wxDefaultValidator
);
1145 wxDataViewListStore
*GetStore()
1146 { return (wxDataViewListStore
*) GetModel(); }
1147 const wxDataViewListStore
*GetStore() const
1148 { return (const wxDataViewListStore
*) GetModel(); }
1150 bool AppendColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
1151 bool PrependColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
1152 bool InsertColumn( unsigned int pos
, wxDataViewColumn
*column
, const wxString
&varianttype
);
1154 // overridden from base class
1155 virtual bool PrependColumn( wxDataViewColumn
*col
);
1156 virtual bool InsertColumn( unsigned int pos
, wxDataViewColumn
*col
);
1157 virtual bool AppendColumn( wxDataViewColumn
*col
);
1159 wxDataViewColumn
*AppendTextColumn( const wxString
&label
,
1160 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1161 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1162 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
,
1163 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
1164 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1165 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
,
1166 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1167 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1168 wxDataViewColumn
*AppendIconTextColumn( const wxString
&label
,
1169 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1170 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1172 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1173 { GetStore()->AppendItem( values
, data
); }
1174 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1175 { GetStore()->PrependItem( values
, data
); }
1176 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1177 { GetStore()->InsertItem( row
, values
, data
); }
1178 void DeleteItem( unsigned row
)
1179 { GetStore()->DeleteItem( row
); }
1180 void DeleteAllItems()
1181 { GetStore()->DeleteAllItems(); }
1183 void SetValue( const wxVariant
&value
, unsigned int row
, unsigned int col
)
1184 { GetStore()->SetValueByRow( value
, row
, col
);
1185 GetStore()->RowValueChanged( row
, col
); }
1186 void GetValue( wxVariant
&value
, unsigned int row
, unsigned int col
)
1187 { GetStore()->GetValueByRow( value
, row
, col
); }
1189 void SetTextValue( const wxString
&value
, unsigned int row
, unsigned int col
)
1190 { GetStore()->SetValueByRow( value
, row
, col
);
1191 GetStore()->RowValueChanged( row
, col
); }
1192 wxString
GetTextValue( unsigned int row
, unsigned int col
) const
1193 { wxVariant value
; GetStore()->GetValueByRow( value
, row
, col
); return value
.GetString(); }
1195 void SetToggleValue( bool value
, unsigned int row
, unsigned int col
)
1196 { GetStore()->SetValueByRow( value
, row
, col
);
1197 GetStore()->RowValueChanged( row
, col
); }
1198 bool GetToggleValue( unsigned int row
, unsigned int col
) const
1199 { wxVariant value
; GetStore()->GetValueByRow( value
, row
, col
); return value
.GetBool(); }
1201 void OnSize( wxSizeEvent
&event
);
1204 DECLARE_EVENT_TABLE()
1205 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewListCtrl
)
1208 //-----------------------------------------------------------------------------
1209 // wxDataViewTreeStore
1210 //-----------------------------------------------------------------------------
1212 class WXDLLIMPEXP_ADV wxDataViewTreeStoreNode
1215 wxDataViewTreeStoreNode( wxDataViewTreeStoreNode
*parent
,
1216 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1217 virtual ~wxDataViewTreeStoreNode();
1219 void SetText( const wxString
&text
)
1221 wxString
GetText() const
1223 void SetIcon( const wxIcon
&icon
)
1225 const wxIcon
&GetIcon() const
1227 void SetData( wxClientData
*data
)
1228 { if (m_data
) delete m_data
; m_data
= data
; }
1229 wxClientData
*GetData() const
1232 wxDataViewItem
GetItem() const
1233 { return wxDataViewItem( (void*) this ); }
1235 virtual bool IsContainer()
1238 wxDataViewTreeStoreNode
*GetParent()
1239 { return m_parent
; }
1242 wxDataViewTreeStoreNode
*m_parent
;
1245 wxClientData
*m_data
;
1248 WX_DECLARE_LIST_WITH_DECL(wxDataViewTreeStoreNode
, wxDataViewTreeStoreNodeList
,
1249 class WXDLLIMPEXP_ADV
);
1251 class WXDLLIMPEXP_ADV wxDataViewTreeStoreContainerNode
: public wxDataViewTreeStoreNode
1254 wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode
*parent
,
1255 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1256 wxClientData
*data
= NULL
);
1257 virtual ~wxDataViewTreeStoreContainerNode();
1259 const wxDataViewTreeStoreNodeList
&GetChildren() const
1260 { return m_children
; }
1261 wxDataViewTreeStoreNodeList
&GetChildren()
1262 { return m_children
; }
1264 void SetExpandedIcon( const wxIcon
&icon
)
1265 { m_iconExpanded
= icon
; }
1266 const wxIcon
&GetExpandedIcon() const
1267 { return m_iconExpanded
; }
1269 void SetExpanded( bool expanded
= true )
1270 { m_isExpanded
= expanded
; }
1271 bool IsExpanded() const
1272 { return m_isExpanded
; }
1274 virtual bool IsContainer()
1278 wxDataViewTreeStoreNodeList m_children
;
1279 wxIcon m_iconExpanded
;
1283 //-----------------------------------------------------------------------------
1285 class WXDLLIMPEXP_ADV wxDataViewTreeStore
: public wxDataViewModel
1288 wxDataViewTreeStore();
1289 ~wxDataViewTreeStore();
1291 wxDataViewItem
AppendItem( const wxDataViewItem
& parent
,
1292 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1293 wxDataViewItem
PrependItem( const wxDataViewItem
& parent
,
1294 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1295 wxDataViewItem
InsertItem( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1296 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1298 wxDataViewItem
PrependContainer( const wxDataViewItem
& parent
,
1299 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1300 wxClientData
*data
= NULL
);
1301 wxDataViewItem
AppendContainer( const wxDataViewItem
& parent
,
1302 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1303 wxClientData
*data
= NULL
);
1304 wxDataViewItem
InsertContainer( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1305 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1306 wxClientData
*data
= NULL
);
1308 wxDataViewItem
GetNthChild( const wxDataViewItem
& parent
, unsigned int pos
) const;
1309 int GetChildCount( const wxDataViewItem
& parent
) const;
1311 void SetItemText( const wxDataViewItem
& item
, const wxString
&text
);
1312 wxString
GetItemText( const wxDataViewItem
& item
) const;
1313 void SetItemIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1314 const wxIcon
&GetItemIcon( const wxDataViewItem
& item
) const;
1315 void SetItemExpandedIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1316 const wxIcon
&GetItemExpandedIcon( const wxDataViewItem
& item
) const;
1317 void SetItemData( const wxDataViewItem
& item
, wxClientData
*data
);
1318 wxClientData
*GetItemData( const wxDataViewItem
& item
) const;
1320 void DeleteItem( const wxDataViewItem
& item
);
1321 void DeleteChildren( const wxDataViewItem
& item
);
1322 void DeleteAllItems();
1324 // implement base methods
1326 virtual void GetValue( wxVariant
&variant
,
1327 const wxDataViewItem
&item
, unsigned int col
) const;
1328 virtual bool SetValue( const wxVariant
&variant
,
1329 const wxDataViewItem
&item
, unsigned int col
);
1330 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const;
1331 virtual bool IsContainer( const wxDataViewItem
&item
) const;
1332 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
1334 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
1335 unsigned int column
, bool ascending
) const;
1337 virtual bool HasDefaultCompare() const
1339 virtual unsigned int GetColumnCount() const
1341 virtual wxString
GetColumnType( unsigned int WXUNUSED(col
) ) const
1342 { return wxT("wxDataViewIconText"); }
1344 wxDataViewTreeStoreNode
*FindNode( const wxDataViewItem
&item
) const;
1345 wxDataViewTreeStoreContainerNode
*FindContainerNode( const wxDataViewItem
&item
) const;
1346 wxDataViewTreeStoreNode
*GetRoot() const { return m_root
; }
1349 wxDataViewTreeStoreNode
*m_root
;
1352 //-----------------------------------------------------------------------------
1354 class WXDLLIMPEXP_ADV wxDataViewTreeCtrl
: public wxDataViewCtrl
1357 wxDataViewTreeCtrl() { Init(); }
1358 wxDataViewTreeCtrl(wxWindow
*parent
,
1360 const wxPoint
& pos
= wxDefaultPosition
,
1361 const wxSize
& size
= wxDefaultSize
,
1362 long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
1363 const wxValidator
& validator
= wxDefaultValidator
)
1367 Create(parent
, id
, pos
, size
, style
, validator
);
1370 virtual ~wxDataViewTreeCtrl();
1372 bool Create(wxWindow
*parent
,
1374 const wxPoint
& pos
= wxDefaultPosition
,
1375 const wxSize
& size
= wxDefaultSize
,
1376 long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
1377 const wxValidator
& validator
= wxDefaultValidator
);
1379 wxDataViewTreeStore
*GetStore()
1380 { return (wxDataViewTreeStore
*) GetModel(); }
1381 const wxDataViewTreeStore
*GetStore() const
1382 { return (const wxDataViewTreeStore
*) GetModel(); }
1384 void SetImageList( wxImageList
*imagelist
);
1385 wxImageList
* GetImageList() { return m_imageList
; }
1387 wxDataViewItem
AppendItem( const wxDataViewItem
& parent
,
1388 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1389 wxDataViewItem
PrependItem( const wxDataViewItem
& parent
,
1390 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1391 wxDataViewItem
InsertItem( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1392 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1394 wxDataViewItem
PrependContainer( const wxDataViewItem
& parent
,
1395 const wxString
&text
, int icon
= -1, int expanded
= -1,
1396 wxClientData
*data
= NULL
);
1397 wxDataViewItem
AppendContainer( const wxDataViewItem
& parent
,
1398 const wxString
&text
, int icon
= -1, int expanded
= -1,
1399 wxClientData
*data
= NULL
);
1400 wxDataViewItem
InsertContainer( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1401 const wxString
&text
, int icon
= -1, int expanded
= -1,
1402 wxClientData
*data
= NULL
);
1404 wxDataViewItem
GetNthChild( const wxDataViewItem
& parent
, unsigned int pos
) const
1405 { return GetStore()->GetNthChild(parent
, pos
); }
1406 int GetChildCount( const wxDataViewItem
& parent
) const
1407 { return GetStore()->GetChildCount(parent
); }
1409 void SetItemText( const wxDataViewItem
& item
, const wxString
&text
);
1410 wxString
GetItemText( const wxDataViewItem
& item
) const
1411 { return GetStore()->GetItemText(item
); }
1412 void SetItemIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1413 const wxIcon
&GetItemIcon( const wxDataViewItem
& item
) const
1414 { return GetStore()->GetItemIcon(item
); }
1415 void SetItemExpandedIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1416 const wxIcon
&GetItemExpandedIcon( const wxDataViewItem
& item
) const
1417 { return GetStore()->GetItemExpandedIcon(item
); }
1418 void SetItemData( const wxDataViewItem
& item
, wxClientData
*data
)
1419 { GetStore()->SetItemData(item
,data
); }
1420 wxClientData
*GetItemData( const wxDataViewItem
& item
) const
1421 { return GetStore()->GetItemData(item
); }
1423 void DeleteItem( const wxDataViewItem
& item
);
1424 void DeleteChildren( const wxDataViewItem
& item
);
1425 void DeleteAllItems();
1427 void OnExpanded( wxDataViewEvent
&event
);
1428 void OnCollapsed( wxDataViewEvent
&event
);
1429 void OnSize( wxSizeEvent
&event
);
1437 wxImageList
*m_imageList
;
1440 DECLARE_EVENT_TABLE()
1441 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl
)
1444 #endif // wxUSE_DATAVIEWCTRL
1447 // _WX_DATAVIEW_H_BASE_