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
),
214 unsigned int WXUNUSED(col
),
215 wxDataViewItemAttr
&WXUNUSED(attr
)) const
221 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const = 0;
222 virtual bool IsContainer( const wxDataViewItem
&item
) const = 0;
223 // Is the container just a header or an item with all columns
224 virtual bool HasContainerColumns(const wxDataViewItem
& WXUNUSED(item
)) const
226 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const = 0;
228 // delegated notifiers
229 virtual bool ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
230 virtual bool ItemsAdded( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
231 virtual bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
232 virtual bool ItemsDeleted( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
233 virtual bool ItemChanged( const wxDataViewItem
&item
);
234 virtual bool ItemsChanged( const wxDataViewItemArray
&items
);
235 virtual bool ValueChanged( const wxDataViewItem
&item
, unsigned int col
);
236 virtual bool Cleared();
239 virtual void Resort();
241 void AddNotifier( wxDataViewModelNotifier
*notifier
);
242 void RemoveNotifier( wxDataViewModelNotifier
*notifier
);
244 // default compare function
245 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
246 unsigned int column
, bool ascending
) const;
247 virtual bool HasDefaultCompare() const { return false; }
250 virtual bool IsVirtualListModel() const { return false; }
253 // the user should not delete this class directly: he should use DecRef() instead!
254 virtual ~wxDataViewModel() { }
256 wxDataViewModelNotifiers m_notifiers
;
259 // ----------------------------------------------------------------------------
260 // wxDataViewListModel: a model of a list, i.e. flat data structure without any
261 // branches/containers, used as base class by wxDataViewIndexListModel and
262 // wxDataViewVirtualListModel
263 // ----------------------------------------------------------------------------
265 class WXDLLIMPEXP_ADV wxDataViewListModel
: public wxDataViewModel
268 // derived classes should override these methods instead of
269 // {Get,Set}Value() and GetAttr() inherited from the base class
271 virtual void GetValueByRow(wxVariant
&variant
,
272 unsigned row
, unsigned col
) const = 0;
274 virtual bool SetValueByRow(const wxVariant
&variant
,
275 unsigned row
, unsigned col
) = 0;
278 GetAttrByRow(unsigned WXUNUSED(row
), unsigned WXUNUSED(col
),
279 wxDataViewItemAttr
&WXUNUSED(attr
)) const
285 // helper methods provided by list models only
286 virtual unsigned GetRow( const wxDataViewItem
&item
) const = 0;
289 // implement some base class pure virtual directly
290 virtual wxDataViewItem
291 GetParent( const wxDataViewItem
& WXUNUSED(item
) ) const
293 // items never have valid parent in this model
294 return wxDataViewItem();
297 virtual bool IsContainer( const wxDataViewItem
&item
) const
299 // only the invisible (and invalid) root item has children
303 // and implement some others by forwarding them to our own ones
304 virtual void GetValue( wxVariant
&variant
,
305 const wxDataViewItem
&item
, unsigned int col
) const
307 GetValueByRow(variant
, GetRow(item
), col
);
310 virtual bool SetValue( const wxVariant
&variant
,
311 const wxDataViewItem
&item
, unsigned int col
)
313 return SetValueByRow( variant
, GetRow(item
), col
);
316 virtual bool GetAttr(const wxDataViewItem
&item
, unsigned int col
,
317 wxDataViewItemAttr
&attr
) const
319 return GetAttrByRow( GetRow(item
), col
, attr
);
323 // ---------------------------------------------------------
324 // wxDataViewIndexListModel
325 // ---------------------------------------------------------
327 class WXDLLIMPEXP_ADV wxDataViewIndexListModel
: public wxDataViewListModel
330 wxDataViewIndexListModel( unsigned int initial_size
= 0 );
333 void RowInserted( unsigned int before
);
335 void RowDeleted( unsigned int row
);
336 void RowsDeleted( const wxArrayInt
&rows
);
337 void RowChanged( unsigned int row
);
338 void RowValueChanged( unsigned int row
, unsigned int col
);
339 void Reset( unsigned int new_size
);
341 // convert to/from row/wxDataViewItem
343 virtual unsigned GetRow( const wxDataViewItem
&item
) const;
344 wxDataViewItem
GetItem( unsigned int row
) const;
346 // compare based on index
348 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
349 unsigned int column
, bool ascending
) const;
350 virtual bool HasDefaultCompare() const;
352 // implement base methods
353 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
355 unsigned int GetCount() const { return m_hash
.GetCount(); }
358 wxDataViewItemArray m_hash
;
359 unsigned int m_nextFreeID
;
363 // ---------------------------------------------------------
364 // wxDataViewVirtualListModel
365 // ---------------------------------------------------------
368 // better than nothing
369 typedef wxDataViewIndexListModel wxDataViewVirtualListModel
;
372 class WXDLLIMPEXP_ADV wxDataViewVirtualListModel
: public wxDataViewListModel
375 wxDataViewVirtualListModel( unsigned int initial_size
= 0 );
378 void RowInserted( unsigned int before
);
380 void RowDeleted( unsigned int row
);
381 void RowsDeleted( const wxArrayInt
&rows
);
382 void RowChanged( unsigned int row
);
383 void RowValueChanged( unsigned int row
, unsigned int col
);
384 void Reset( unsigned int new_size
);
386 // convert to/from row/wxDataViewItem
388 virtual unsigned GetRow( const wxDataViewItem
&item
) const;
389 wxDataViewItem
GetItem( unsigned int row
) const;
391 // compare based on index
393 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
394 unsigned int column
, bool ascending
) const;
395 virtual bool HasDefaultCompare() const;
397 // implement base methods
398 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
400 unsigned int GetCount() const { return m_size
; }
403 virtual bool IsVirtualListModel() const { return true; }
411 //-----------------------------------------------------------------------------
412 // wxDataViewEditorCtrlEvtHandler
413 //-----------------------------------------------------------------------------
415 class wxDataViewEditorCtrlEvtHandler
: public wxEvtHandler
418 wxDataViewEditorCtrlEvtHandler( wxControl
*editor
, wxDataViewRenderer
*owner
);
420 void AcceptChangesAndFinish();
421 void SetFocusOnIdle( bool focus
= true ) { m_focusOnIdle
= focus
; }
424 void OnChar( wxKeyEvent
&event
);
425 void OnTextEnter( wxCommandEvent
&event
);
426 void OnKillFocus( wxFocusEvent
&event
);
427 void OnIdle( wxIdleEvent
&event
);
430 wxDataViewRenderer
*m_owner
;
431 wxControl
*m_editorCtrl
;
436 DECLARE_EVENT_TABLE()
439 // ---------------------------------------------------------
440 // wxDataViewRendererBase
441 // ---------------------------------------------------------
443 enum wxDataViewCellMode
445 wxDATAVIEW_CELL_INERT
,
446 wxDATAVIEW_CELL_ACTIVATABLE
,
447 wxDATAVIEW_CELL_EDITABLE
450 enum wxDataViewCellRenderState
452 wxDATAVIEW_CELL_SELECTED
= 1,
453 wxDATAVIEW_CELL_PRELIT
= 2,
454 wxDATAVIEW_CELL_INSENSITIVE
= 4,
455 wxDATAVIEW_CELL_FOCUSED
= 8
458 class WXDLLIMPEXP_ADV wxDataViewRendererBase
: public wxObject
461 wxDataViewRendererBase( const wxString
&varianttype
,
462 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
463 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
464 virtual ~wxDataViewRendererBase();
466 virtual bool Validate( wxVariant
& WXUNUSED(value
) )
469 void SetOwner( wxDataViewColumn
*owner
) { m_owner
= owner
; }
470 wxDataViewColumn
* GetOwner() const { return m_owner
; }
472 // renderer properties:
474 virtual bool SetValue( const wxVariant
& WXUNUSED(value
) ) = 0;
475 virtual bool GetValue( wxVariant
& WXUNUSED(value
) ) const = 0;
477 wxString
GetVariantType() const { return m_variantType
; }
479 virtual void SetMode( wxDataViewCellMode mode
) = 0;
480 virtual wxDataViewCellMode
GetMode() const = 0;
482 // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but
483 // rather an "int"; that's because for rendering cells it's allowed
484 // to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM)
485 virtual void SetAlignment( int align
) = 0;
486 virtual int GetAlignment() const = 0;
488 // enable or disable (if called with wxELLIPSIZE_NONE) replacing parts of
489 // the item text (hence this only makes sense for renderers showing
490 // text...) with ellipsis in order to make it fit the column width
491 virtual void EnableEllipsize(wxEllipsizeMode mode
= wxELLIPSIZE_MIDDLE
) = 0;
492 void DisableEllipsize() { EnableEllipsize(wxELLIPSIZE_NONE
); }
494 virtual wxEllipsizeMode
GetEllipsizeMode() const = 0;
497 virtual bool HasEditorCtrl() const
499 virtual wxControl
* CreateEditorCtrl(wxWindow
* WXUNUSED(parent
),
500 wxRect
WXUNUSED(labelRect
),
501 const wxVariant
& WXUNUSED(value
))
503 virtual bool GetValueFromEditorCtrl(wxControl
* WXUNUSED(editor
),
504 wxVariant
& WXUNUSED(value
))
507 virtual bool StartEditing( const wxDataViewItem
&item
, wxRect labelRect
);
508 virtual void CancelEditing();
509 virtual bool FinishEditing();
511 wxControl
*GetEditorCtrl() { return m_editorCtrl
; }
514 wxString m_variantType
;
515 wxDataViewColumn
*m_owner
;
516 wxWeakRef
<wxControl
> m_editorCtrl
;
517 wxDataViewItem m_item
; // for m_editorCtrl
520 const wxDataViewCtrl
* GetView() const;
523 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase
)
526 //-----------------------------------------------------------------------------
527 // wxDataViewIconText
528 //-----------------------------------------------------------------------------
530 class WXDLLIMPEXP_ADV wxDataViewIconText
: public wxObject
533 wxDataViewIconText( const wxString
&text
= wxEmptyString
, const wxIcon
& icon
= wxNullIcon
)
534 : m_text(text
), m_icon(icon
)
536 wxDataViewIconText( const wxDataViewIconText
&other
)
538 { m_icon
= other
.m_icon
; m_text
= other
.m_text
; }
540 void SetText( const wxString
&text
) { m_text
= text
; }
541 wxString
GetText() const { return m_text
; }
542 void SetIcon( const wxIcon
&icon
) { m_icon
= icon
; }
543 const wxIcon
&GetIcon() const { return m_icon
; }
550 DECLARE_DYNAMIC_CLASS(wxDataViewIconText
)
554 bool operator==(const wxDataViewIconText
& left
, const wxDataViewIconText
& right
)
556 return left
.GetText() == right
.GetText() &&
557 left
.GetIcon().IsSameAs(right
.GetIcon());
561 bool operator!=(const wxDataViewIconText
& left
, const wxDataViewIconText
& right
)
563 return !(left
== right
);
566 DECLARE_VARIANT_OBJECT_EXPORTED(wxDataViewIconText
, WXDLLIMPEXP_ADV
)
568 // ---------------------------------------------------------
569 // wxDataViewColumnBase
570 // ---------------------------------------------------------
572 // for compatibility only, do not use
573 enum wxDataViewColumnFlags
575 wxDATAVIEW_COL_RESIZABLE
= wxCOL_RESIZABLE
,
576 wxDATAVIEW_COL_SORTABLE
= wxCOL_SORTABLE
,
577 wxDATAVIEW_COL_REORDERABLE
= wxCOL_REORDERABLE
,
578 wxDATAVIEW_COL_HIDDEN
= wxCOL_HIDDEN
581 class WXDLLIMPEXP_ADV wxDataViewColumnBase
: public wxSettableHeaderColumn
584 // ctor for the text columns: takes ownership of renderer
585 wxDataViewColumnBase(wxDataViewRenderer
*renderer
,
586 unsigned int model_column
)
588 Init(renderer
, model_column
);
591 // ctor for the bitmap columns
592 wxDataViewColumnBase(const wxBitmap
& bitmap
,
593 wxDataViewRenderer
*renderer
,
594 unsigned int model_column
)
597 Init(renderer
, model_column
);
600 virtual ~wxDataViewColumnBase();
603 virtual void SetOwner( wxDataViewCtrl
*owner
)
607 unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column
); }
608 wxDataViewCtrl
*GetOwner() const { return m_owner
; }
609 wxDataViewRenderer
* GetRenderer() const { return m_renderer
; }
611 // implement some of base class pure virtuals (the rest is port-dependent
612 // and done differently in generic and native versions)
613 virtual void SetBitmap( const wxBitmap
& bitmap
) { m_bitmap
= bitmap
; }
614 virtual wxBitmap
GetBitmap() const { return m_bitmap
; }
617 wxDataViewRenderer
*m_renderer
;
620 wxDataViewCtrl
*m_owner
;
623 // common part of all ctors
624 void Init(wxDataViewRenderer
*renderer
, unsigned int model_column
);
627 // ---------------------------------------------------------
628 // wxDataViewCtrlBase
629 // ---------------------------------------------------------
631 #define wxDV_SINGLE 0x0000 // for convenience
632 #define wxDV_MULTIPLE 0x0001 // can select multiple items
634 #define wxDV_NO_HEADER 0x0002 // column titles not visible
635 #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows
636 #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns
638 #define wxDV_ROW_LINES 0x0010 // alternating colour in rows
639 #define wxDV_VARIABLE_LINE_HEIGHT 0x0020 // variable line height
641 class WXDLLIMPEXP_ADV wxDataViewCtrlBase
: public wxControl
644 wxDataViewCtrlBase();
645 virtual ~wxDataViewCtrlBase();
650 virtual bool AssociateModel( wxDataViewModel
*model
);
651 wxDataViewModel
* GetModel();
652 const wxDataViewModel
* GetModel() const;
658 wxDataViewColumn
*PrependTextColumn( 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
*PrependIconTextColumn( const wxString
&label
, unsigned int model_column
,
663 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
664 wxAlignment align
= wxALIGN_NOT
,
665 int flags
= wxDATAVIEW_COL_RESIZABLE
);
666 wxDataViewColumn
*PrependToggleColumn( const wxString
&label
, unsigned int model_column
,
667 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
668 wxAlignment align
= wxALIGN_CENTER
,
669 int flags
= wxDATAVIEW_COL_RESIZABLE
);
670 wxDataViewColumn
*PrependProgressColumn( const wxString
&label
, unsigned int model_column
,
671 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
672 wxAlignment align
= wxALIGN_CENTER
,
673 int flags
= wxDATAVIEW_COL_RESIZABLE
);
674 wxDataViewColumn
*PrependDateColumn( const wxString
&label
, unsigned int model_column
,
675 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
676 wxAlignment align
= wxALIGN_NOT
,
677 int flags
= wxDATAVIEW_COL_RESIZABLE
);
678 wxDataViewColumn
*PrependBitmapColumn( const wxString
&label
, unsigned int model_column
,
679 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
680 wxAlignment align
= wxALIGN_CENTER
,
681 int flags
= wxDATAVIEW_COL_RESIZABLE
);
682 wxDataViewColumn
*PrependTextColumn( 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
*PrependIconTextColumn( const wxBitmap
&label
, unsigned int model_column
,
687 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
688 wxAlignment align
= wxALIGN_NOT
,
689 int flags
= wxDATAVIEW_COL_RESIZABLE
);
690 wxDataViewColumn
*PrependToggleColumn( const wxBitmap
&label
, unsigned int model_column
,
691 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
692 wxAlignment align
= wxALIGN_CENTER
,
693 int flags
= wxDATAVIEW_COL_RESIZABLE
);
694 wxDataViewColumn
*PrependProgressColumn( const wxBitmap
&label
, unsigned int model_column
,
695 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
696 wxAlignment align
= wxALIGN_CENTER
,
697 int flags
= wxDATAVIEW_COL_RESIZABLE
);
698 wxDataViewColumn
*PrependDateColumn( const wxBitmap
&label
, unsigned int model_column
,
699 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
700 wxAlignment align
= wxALIGN_NOT
,
701 int flags
= wxDATAVIEW_COL_RESIZABLE
);
702 wxDataViewColumn
*PrependBitmapColumn( const wxBitmap
&label
, unsigned int model_column
,
703 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
704 wxAlignment align
= wxALIGN_CENTER
,
705 int flags
= wxDATAVIEW_COL_RESIZABLE
);
707 wxDataViewColumn
*AppendTextColumn( 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
*AppendIconTextColumn( const wxString
&label
, unsigned int model_column
,
712 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
713 wxAlignment align
= wxALIGN_NOT
,
714 int flags
= wxDATAVIEW_COL_RESIZABLE
);
715 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
, unsigned int model_column
,
716 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
717 wxAlignment align
= wxALIGN_CENTER
,
718 int flags
= wxDATAVIEW_COL_RESIZABLE
);
719 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
, unsigned int model_column
,
720 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
721 wxAlignment align
= wxALIGN_CENTER
,
722 int flags
= wxDATAVIEW_COL_RESIZABLE
);
723 wxDataViewColumn
*AppendDateColumn( const wxString
&label
, unsigned int model_column
,
724 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
725 wxAlignment align
= wxALIGN_NOT
,
726 int flags
= wxDATAVIEW_COL_RESIZABLE
);
727 wxDataViewColumn
*AppendBitmapColumn( const wxString
&label
, unsigned int model_column
,
728 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
729 wxAlignment align
= wxALIGN_CENTER
,
730 int flags
= wxDATAVIEW_COL_RESIZABLE
);
731 wxDataViewColumn
*AppendTextColumn( 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
*AppendIconTextColumn( const wxBitmap
&label
, unsigned int model_column
,
736 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
737 wxAlignment align
= wxALIGN_NOT
,
738 int flags
= wxDATAVIEW_COL_RESIZABLE
);
739 wxDataViewColumn
*AppendToggleColumn( const wxBitmap
&label
, unsigned int model_column
,
740 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
741 wxAlignment align
= wxALIGN_CENTER
,
742 int flags
= wxDATAVIEW_COL_RESIZABLE
);
743 wxDataViewColumn
*AppendProgressColumn( const wxBitmap
&label
, unsigned int model_column
,
744 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
745 wxAlignment align
= wxALIGN_CENTER
,
746 int flags
= wxDATAVIEW_COL_RESIZABLE
);
747 wxDataViewColumn
*AppendDateColumn( const wxBitmap
&label
, unsigned int model_column
,
748 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
749 wxAlignment align
= wxALIGN_NOT
,
750 int flags
= wxDATAVIEW_COL_RESIZABLE
);
751 wxDataViewColumn
*AppendBitmapColumn( const wxBitmap
&label
, unsigned int model_column
,
752 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
753 wxAlignment align
= wxALIGN_CENTER
,
754 int flags
= wxDATAVIEW_COL_RESIZABLE
);
756 virtual bool PrependColumn( wxDataViewColumn
*col
);
757 virtual bool InsertColumn( unsigned int pos
, wxDataViewColumn
*col
);
758 virtual bool AppendColumn( wxDataViewColumn
*col
);
760 virtual unsigned int GetColumnCount() const = 0;
761 virtual wxDataViewColumn
* GetColumn( unsigned int pos
) const = 0;
762 virtual int GetColumnPosition( const wxDataViewColumn
*column
) const = 0;
764 virtual bool DeleteColumn( wxDataViewColumn
*column
) = 0;
765 virtual bool ClearColumns() = 0;
767 void SetExpanderColumn( wxDataViewColumn
*col
)
768 { m_expander_column
= col
; DoSetExpanderColumn(); }
769 wxDataViewColumn
*GetExpanderColumn() const
770 { return m_expander_column
; }
772 virtual wxDataViewColumn
*GetSortingColumn() const = 0;
778 void SetIndent( int indent
)
779 { m_indent
= indent
; DoSetIndent(); }
780 int GetIndent() const
783 virtual wxDataViewItem
GetSelection() const = 0;
784 virtual int GetSelections( wxDataViewItemArray
& sel
) const = 0;
785 virtual void SetSelections( const wxDataViewItemArray
& sel
) = 0;
786 virtual void Select( const wxDataViewItem
& item
) = 0;
787 virtual void Unselect( const wxDataViewItem
& item
) = 0;
788 virtual bool IsSelected( const wxDataViewItem
& item
) const = 0;
790 virtual void SelectAll() = 0;
791 virtual void UnselectAll() = 0;
793 virtual void Expand( const wxDataViewItem
& item
) = 0;
794 virtual void ExpandAncestors( const wxDataViewItem
& item
);
795 virtual void Collapse( const wxDataViewItem
& item
) = 0;
796 virtual bool IsExpanded( const wxDataViewItem
& item
) const = 0;
798 virtual void EnsureVisible( const wxDataViewItem
& item
,
799 const wxDataViewColumn
*column
= NULL
) = 0;
800 virtual void HitTest( const wxPoint
& point
, wxDataViewItem
&item
, wxDataViewColumn
* &column
) const = 0;
801 virtual wxRect
GetItemRect( const wxDataViewItem
& item
, const wxDataViewColumn
*column
= NULL
) const = 0;
803 #if wxUSE_DRAG_AND_DROP
804 virtual bool EnableDragSource(const wxDataFormat
& WXUNUSED(format
))
806 virtual bool EnableDropTarget(const wxDataFormat
& WXUNUSED(format
))
808 #endif // wxUSE_DRAG_AND_DROP
810 // define control visual attributes
811 // --------------------------------
813 virtual wxVisualAttributes
GetDefaultAttributes() const
815 return GetClassDefaultAttributes(GetWindowVariant());
818 static wxVisualAttributes
819 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
)
821 return wxControl::GetCompositeControlsDefaultAttributes(variant
);
825 virtual void DoSetExpanderColumn() = 0 ;
826 virtual void DoSetIndent() = 0;
829 wxDataViewModel
*m_model
;
830 wxDataViewColumn
*m_expander_column
;
834 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase
)
837 // ----------------------------------------------------------------------------
838 // wxDataViewEvent - the event class for the wxDataViewCtrl notifications
839 // ----------------------------------------------------------------------------
841 class WXDLLIMPEXP_ADV wxDataViewEvent
: public wxNotifyEvent
844 wxDataViewEvent(wxEventType commandType
= wxEVT_NULL
, int winid
= 0)
845 : wxNotifyEvent(commandType
, winid
),
849 m_value(wxNullVariant
),
854 #if wxUSE_DRAG_AND_DROP
855 , m_dataObject(NULL
),
861 wxDataViewEvent(const wxDataViewEvent
& event
)
862 : wxNotifyEvent(event
),
863 m_item(event
.m_item
),
865 m_model(event
.m_model
),
866 m_value(event
.m_value
),
867 m_column(event
.m_column
),
869 m_cacheFrom(event
.m_cacheFrom
),
870 m_cacheTo(event
.m_cacheTo
)
871 #if wxUSE_DRAG_AND_DROP
872 , m_dataObject(event
.m_dataObject
),
873 m_dataFormat(event
.m_dataFormat
),
874 m_dataBuffer(event
.m_dataBuffer
),
875 m_dataSize(event
.m_dataSize
)
879 wxDataViewItem
GetItem() const { return m_item
; }
880 void SetItem( const wxDataViewItem
&item
) { m_item
= item
; }
882 int GetColumn() const { return m_col
; }
883 void SetColumn( int col
) { m_col
= col
; }
885 wxDataViewModel
* GetModel() const { return m_model
; }
886 void SetModel( wxDataViewModel
*model
) { m_model
= model
; }
888 const wxVariant
&GetValue() const { return m_value
; }
889 void SetValue( const wxVariant
&value
) { m_value
= value
; }
891 // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only
892 void SetDataViewColumn( wxDataViewColumn
*col
) { m_column
= col
; }
893 wxDataViewColumn
*GetDataViewColumn() const { return m_column
; }
895 // for wxEVT_DATAVIEW_CONTEXT_MENU only
896 wxPoint
GetPosition() const { return m_pos
; }
897 void SetPosition( int x
, int y
) { m_pos
.x
= x
; m_pos
.y
= y
; }
899 // For wxEVT_COMMAND_DATAVIEW_CACHE_HINT
900 int GetCacheFrom() const { return m_cacheFrom
; }
901 int GetCacheTo() const { return m_cacheTo
; }
902 void SetCache(int from
, int to
) { m_cacheFrom
= from
; m_cacheTo
= to
; }
905 #if wxUSE_DRAG_AND_DROP
906 // For drag operations
907 void SetDataObject( wxDataObject
*obj
) { m_dataObject
= obj
; }
908 wxDataObject
*GetDataObject() const { return m_dataObject
; }
910 // For drop operations
911 void SetDataFormat( const wxDataFormat
&format
) { m_dataFormat
= format
; }
912 wxDataFormat
GetDataFormat() const { return m_dataFormat
; }
913 void SetDataSize( size_t size
) { m_dataSize
= size
; }
914 size_t GetDataSize() const { return m_dataSize
; }
915 void SetDataBuffer( void* buf
) { m_dataBuffer
= buf
;}
916 void *GetDataBuffer() const { return m_dataBuffer
; }
917 #endif // wxUSE_DRAG_AND_DROP
919 virtual wxEvent
*Clone() const { return new wxDataViewEvent(*this); }
922 wxDataViewItem m_item
;
924 wxDataViewModel
*m_model
;
926 wxDataViewColumn
*m_column
;
931 #if wxUSE_DRAG_AND_DROP
932 wxDataObject
*m_dataObject
;
934 wxDataFormat m_dataFormat
;
937 #endif // wxUSE_DRAG_AND_DROP
940 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent
)
943 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED
, wxDataViewEvent
);
945 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED
, wxDataViewEvent
);
946 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED
, wxDataViewEvent
);
947 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED
, wxDataViewEvent
);
948 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING
, wxDataViewEvent
);
949 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING
, wxDataViewEvent
);
950 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING
, wxDataViewEvent
);
951 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED
, wxDataViewEvent
);
952 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE
, wxDataViewEvent
);
953 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED
, wxDataViewEvent
);
955 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU
, wxDataViewEvent
);
957 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK
, wxDataViewEvent
);
958 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK
, wxDataViewEvent
);
959 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED
, wxDataViewEvent
);
960 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED
, wxDataViewEvent
);
962 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_CACHE_HINT
, wxDataViewEvent
);
964 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG
, wxDataViewEvent
);
965 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE
, wxDataViewEvent
);
966 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_DROP
, wxDataViewEvent
);
968 typedef void (wxEvtHandler::*wxDataViewEventFunction
)(wxDataViewEvent
&);
970 #define wxDataViewEventHandler(func) \
971 wxEVENT_HANDLER_CAST(wxDataViewEventFunction, func)
973 #define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \
974 wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn))
976 #define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn)
978 #define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn)
979 #define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn)
980 #define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn)
981 #define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn)
982 #define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn)
983 #define EVT_DATAVIEW_ITEM_START_EDITING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_START_EDITING, id, fn)
984 #define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn)
985 #define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn)
986 #define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn)
988 #define EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_CONTEXT_MENU, id, fn)
990 #define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn)
991 #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn)
992 #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn)
993 #define EVT_DATAVIEW_COLUMN_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_REORDERED, id, fn)
994 #define EVT_DATAVIEW_CACHE_HINT(id, fn) wx__DECLARE_DATAVIEWEVT(CACHE_HINT, id, fn)
996 #define EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_BEGIN_DRAG, id, fn)
997 #define EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP_POSSIBLE, id, fn)
998 #define EVT_DATAVIEW_ITEM_DROP(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP, id, fn)
1000 #ifdef wxHAS_GENERIC_DATAVIEWCTRL
1001 // this symbol doesn't follow the convention for wxUSE_XXX symbols which
1002 // are normally always defined as either 0 or 1, so its use is deprecated
1003 // and it only exists for backwards compatibility, don't use it any more
1004 // and use wxHAS_GENERIC_DATAVIEWCTRL instead
1005 #define wxUSE_GENERICDATAVIEWCTRL
1007 #include "wx/generic/dataview.h"
1008 #elif defined(__WXGTK20__)
1009 #include "wx/gtk/dataview.h"
1010 #elif defined(__WXMAC__)
1011 #include "wx/osx/dataview.h"
1013 #error "unknown native wxDataViewCtrl implementation"
1016 // -------------------------------------
1017 // wxDataViewSpinRenderer
1018 // -------------------------------------
1020 class WXDLLIMPEXP_ADV wxDataViewSpinRenderer
: public wxDataViewCustomRenderer
1023 wxDataViewSpinRenderer( int min
, int max
,
1024 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
1025 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
1026 virtual bool HasEditorCtrl() const { return true; }
1027 virtual wxControl
* CreateEditorCtrl( wxWindow
*parent
, wxRect labelRect
, const wxVariant
&value
);
1028 virtual bool GetValueFromEditorCtrl( wxControl
* editor
, wxVariant
&value
);
1029 virtual bool Render( wxRect rect
, wxDC
*dc
, int state
);
1030 virtual wxSize
GetSize() const;
1031 virtual bool SetValue( const wxVariant
&value
);
1032 virtual bool GetValue( wxVariant
&value
) const;
1039 #if defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXOSX_CARBON__)
1041 // -------------------------------------
1042 // wxDataViewChoiceRenderer
1043 // -------------------------------------
1045 class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer
: public wxDataViewCustomRenderer
1048 wxDataViewChoiceRenderer( const wxArrayString
&choices
,
1049 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
1050 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
1051 virtual bool HasEditorCtrl() const { return true; }
1052 virtual wxControl
* CreateEditorCtrl( wxWindow
*parent
, wxRect labelRect
, const wxVariant
&value
);
1053 virtual bool GetValueFromEditorCtrl( wxControl
* editor
, wxVariant
&value
);
1054 virtual bool Render( wxRect rect
, wxDC
*dc
, int state
);
1055 virtual wxSize
GetSize() const;
1056 virtual bool SetValue( const wxVariant
&value
);
1057 virtual bool GetValue( wxVariant
&value
) const;
1060 wxArrayString m_choices
;
1066 // this class is obsolete, its functionality was merged in
1067 // wxDataViewTextRenderer itself now, don't use it any more
1068 #define wxDataViewTextRendererAttr wxDataViewTextRenderer
1070 //-----------------------------------------------------------------------------
1071 // wxDataViewListStore
1072 //-----------------------------------------------------------------------------
1074 class WXDLLIMPEXP_ADV wxDataViewListStoreLine
1077 wxDataViewListStoreLine( wxClientData
*data
= NULL
)
1081 virtual ~wxDataViewListStoreLine()
1086 void SetData( wxClientData
*data
)
1087 { if (m_data
) delete m_data
; m_data
= data
; }
1088 wxClientData
*GetData() const
1091 wxVector
<wxVariant
> m_values
;
1094 wxClientData
*m_data
;
1098 class WXDLLIMPEXP_ADV wxDataViewListStore
: public wxDataViewIndexListModel
1101 wxDataViewListStore();
1102 ~wxDataViewListStore();
1104 void PrependColumn( const wxString
&varianttype
);
1105 void InsertColumn( unsigned int pos
, const wxString
&varianttype
);
1106 void AppendColumn( const wxString
&varianttype
);
1108 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1109 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1110 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1111 void DeleteItem( unsigned int pos
);
1112 void DeleteAllItems();
1114 // override base virtuals
1116 virtual unsigned int GetColumnCount() const;
1118 virtual wxString
GetColumnType( unsigned int col
) const;
1120 virtual void GetValueByRow( wxVariant
&value
,
1121 unsigned int row
, unsigned int col
) const;
1123 virtual bool SetValueByRow( const wxVariant
&value
,
1124 unsigned int row
, unsigned int col
);
1128 wxVector
<wxDataViewListStoreLine
*> m_data
;
1129 wxArrayString m_cols
;
1132 //-----------------------------------------------------------------------------
1134 class WXDLLIMPEXP_ADV wxDataViewListCtrl
: public wxDataViewCtrl
1137 wxDataViewListCtrl();
1138 wxDataViewListCtrl( wxWindow
*parent
, wxWindowID id
,
1139 const wxPoint
& pos
= wxDefaultPosition
,
1140 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
1141 const wxValidator
& validator
= wxDefaultValidator
);
1142 ~wxDataViewListCtrl();
1144 bool Create( wxWindow
*parent
, wxWindowID id
,
1145 const wxPoint
& pos
= wxDefaultPosition
,
1146 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
1147 const wxValidator
& validator
= wxDefaultValidator
);
1149 wxDataViewListStore
*GetStore()
1150 { return (wxDataViewListStore
*) GetModel(); }
1151 const wxDataViewListStore
*GetStore() const
1152 { return (const wxDataViewListStore
*) GetModel(); }
1154 bool AppendColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
1155 bool PrependColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
1156 bool InsertColumn( unsigned int pos
, wxDataViewColumn
*column
, const wxString
&varianttype
);
1158 // overridden from base class
1159 virtual bool PrependColumn( wxDataViewColumn
*col
);
1160 virtual bool InsertColumn( unsigned int pos
, wxDataViewColumn
*col
);
1161 virtual bool AppendColumn( wxDataViewColumn
*col
);
1163 wxDataViewColumn
*AppendTextColumn( const wxString
&label
,
1164 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1165 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1166 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
,
1167 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
1168 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1169 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
,
1170 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1171 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1172 wxDataViewColumn
*AppendIconTextColumn( const wxString
&label
,
1173 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1174 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1176 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1177 { GetStore()->AppendItem( values
, data
); }
1178 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1179 { GetStore()->PrependItem( values
, data
); }
1180 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1181 { GetStore()->InsertItem( row
, values
, data
); }
1182 void DeleteItem( unsigned row
)
1183 { GetStore()->DeleteItem( row
); }
1184 void DeleteAllItems()
1185 { GetStore()->DeleteAllItems(); }
1187 void SetValue( const wxVariant
&value
, unsigned int row
, unsigned int col
)
1188 { GetStore()->SetValueByRow( value
, row
, col
);
1189 GetStore()->RowValueChanged( row
, col
); }
1190 void GetValue( wxVariant
&value
, unsigned int row
, unsigned int col
)
1191 { GetStore()->GetValueByRow( value
, row
, col
); }
1193 void SetTextValue( const wxString
&value
, unsigned int row
, unsigned int col
)
1194 { GetStore()->SetValueByRow( value
, row
, col
);
1195 GetStore()->RowValueChanged( row
, col
); }
1196 wxString
GetTextValue( unsigned int row
, unsigned int col
) const
1197 { wxVariant value
; GetStore()->GetValueByRow( value
, row
, col
); return value
.GetString(); }
1199 void SetToggleValue( bool value
, unsigned int row
, unsigned int col
)
1200 { GetStore()->SetValueByRow( value
, row
, col
);
1201 GetStore()->RowValueChanged( row
, col
); }
1202 bool GetToggleValue( unsigned int row
, unsigned int col
) const
1203 { wxVariant value
; GetStore()->GetValueByRow( value
, row
, col
); return value
.GetBool(); }
1205 void OnSize( wxSizeEvent
&event
);
1208 DECLARE_EVENT_TABLE()
1209 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewListCtrl
)
1212 //-----------------------------------------------------------------------------
1213 // wxDataViewTreeStore
1214 //-----------------------------------------------------------------------------
1216 class WXDLLIMPEXP_ADV wxDataViewTreeStoreNode
1219 wxDataViewTreeStoreNode( wxDataViewTreeStoreNode
*parent
,
1220 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1221 virtual ~wxDataViewTreeStoreNode();
1223 void SetText( const wxString
&text
)
1225 wxString
GetText() const
1227 void SetIcon( const wxIcon
&icon
)
1229 const wxIcon
&GetIcon() const
1231 void SetData( wxClientData
*data
)
1232 { if (m_data
) delete m_data
; m_data
= data
; }
1233 wxClientData
*GetData() const
1236 wxDataViewItem
GetItem() const
1237 { return wxDataViewItem( (void*) this ); }
1239 virtual bool IsContainer()
1242 wxDataViewTreeStoreNode
*GetParent()
1243 { return m_parent
; }
1246 wxDataViewTreeStoreNode
*m_parent
;
1249 wxClientData
*m_data
;
1252 WX_DECLARE_LIST_WITH_DECL(wxDataViewTreeStoreNode
, wxDataViewTreeStoreNodeList
,
1253 class WXDLLIMPEXP_ADV
);
1255 class WXDLLIMPEXP_ADV wxDataViewTreeStoreContainerNode
: public wxDataViewTreeStoreNode
1258 wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode
*parent
,
1259 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1260 wxClientData
*data
= NULL
);
1261 virtual ~wxDataViewTreeStoreContainerNode();
1263 const wxDataViewTreeStoreNodeList
&GetChildren() const
1264 { return m_children
; }
1265 wxDataViewTreeStoreNodeList
&GetChildren()
1266 { return m_children
; }
1268 void SetExpandedIcon( const wxIcon
&icon
)
1269 { m_iconExpanded
= icon
; }
1270 const wxIcon
&GetExpandedIcon() const
1271 { return m_iconExpanded
; }
1273 void SetExpanded( bool expanded
= true )
1274 { m_isExpanded
= expanded
; }
1275 bool IsExpanded() const
1276 { return m_isExpanded
; }
1278 virtual bool IsContainer()
1282 wxDataViewTreeStoreNodeList m_children
;
1283 wxIcon m_iconExpanded
;
1287 //-----------------------------------------------------------------------------
1289 class WXDLLIMPEXP_ADV wxDataViewTreeStore
: public wxDataViewModel
1292 wxDataViewTreeStore();
1293 ~wxDataViewTreeStore();
1295 wxDataViewItem
AppendItem( const wxDataViewItem
& parent
,
1296 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1297 wxDataViewItem
PrependItem( const wxDataViewItem
& parent
,
1298 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1299 wxDataViewItem
InsertItem( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1300 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1302 wxDataViewItem
PrependContainer( const wxDataViewItem
& parent
,
1303 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1304 wxClientData
*data
= NULL
);
1305 wxDataViewItem
AppendContainer( const wxDataViewItem
& parent
,
1306 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1307 wxClientData
*data
= NULL
);
1308 wxDataViewItem
InsertContainer( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1309 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1310 wxClientData
*data
= NULL
);
1312 wxDataViewItem
GetNthChild( const wxDataViewItem
& parent
, unsigned int pos
) const;
1313 int GetChildCount( const wxDataViewItem
& parent
) const;
1315 void SetItemText( const wxDataViewItem
& item
, const wxString
&text
);
1316 wxString
GetItemText( const wxDataViewItem
& item
) const;
1317 void SetItemIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1318 const wxIcon
&GetItemIcon( const wxDataViewItem
& item
) const;
1319 void SetItemExpandedIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1320 const wxIcon
&GetItemExpandedIcon( const wxDataViewItem
& item
) const;
1321 void SetItemData( const wxDataViewItem
& item
, wxClientData
*data
);
1322 wxClientData
*GetItemData( const wxDataViewItem
& item
) const;
1324 void DeleteItem( const wxDataViewItem
& item
);
1325 void DeleteChildren( const wxDataViewItem
& item
);
1326 void DeleteAllItems();
1328 // implement base methods
1330 virtual void GetValue( wxVariant
&variant
,
1331 const wxDataViewItem
&item
, unsigned int col
) const;
1332 virtual bool SetValue( const wxVariant
&variant
,
1333 const wxDataViewItem
&item
, unsigned int col
);
1334 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const;
1335 virtual bool IsContainer( const wxDataViewItem
&item
) const;
1336 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
1338 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
1339 unsigned int column
, bool ascending
) const;
1341 virtual bool HasDefaultCompare() const
1343 virtual unsigned int GetColumnCount() const
1345 virtual wxString
GetColumnType( unsigned int WXUNUSED(col
) ) const
1346 { return wxT("wxDataViewIconText"); }
1348 wxDataViewTreeStoreNode
*FindNode( const wxDataViewItem
&item
) const;
1349 wxDataViewTreeStoreContainerNode
*FindContainerNode( const wxDataViewItem
&item
) const;
1350 wxDataViewTreeStoreNode
*GetRoot() const { return m_root
; }
1353 wxDataViewTreeStoreNode
*m_root
;
1356 //-----------------------------------------------------------------------------
1358 class WXDLLIMPEXP_ADV wxDataViewTreeCtrl
: public wxDataViewCtrl
1361 wxDataViewTreeCtrl() { Init(); }
1362 wxDataViewTreeCtrl(wxWindow
*parent
,
1364 const wxPoint
& pos
= wxDefaultPosition
,
1365 const wxSize
& size
= wxDefaultSize
,
1366 long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
1367 const wxValidator
& validator
= wxDefaultValidator
)
1371 Create(parent
, id
, pos
, size
, style
, validator
);
1374 virtual ~wxDataViewTreeCtrl();
1376 bool Create(wxWindow
*parent
,
1378 const wxPoint
& pos
= wxDefaultPosition
,
1379 const wxSize
& size
= wxDefaultSize
,
1380 long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
1381 const wxValidator
& validator
= wxDefaultValidator
);
1383 wxDataViewTreeStore
*GetStore()
1384 { return (wxDataViewTreeStore
*) GetModel(); }
1385 const wxDataViewTreeStore
*GetStore() const
1386 { return (const wxDataViewTreeStore
*) GetModel(); }
1388 void SetImageList( wxImageList
*imagelist
);
1389 wxImageList
* GetImageList() { return m_imageList
; }
1391 wxDataViewItem
AppendItem( const wxDataViewItem
& parent
,
1392 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1393 wxDataViewItem
PrependItem( const wxDataViewItem
& parent
,
1394 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1395 wxDataViewItem
InsertItem( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1396 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1398 wxDataViewItem
PrependContainer( const wxDataViewItem
& parent
,
1399 const wxString
&text
, int icon
= -1, int expanded
= -1,
1400 wxClientData
*data
= NULL
);
1401 wxDataViewItem
AppendContainer( const wxDataViewItem
& parent
,
1402 const wxString
&text
, int icon
= -1, int expanded
= -1,
1403 wxClientData
*data
= NULL
);
1404 wxDataViewItem
InsertContainer( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1405 const wxString
&text
, int icon
= -1, int expanded
= -1,
1406 wxClientData
*data
= NULL
);
1408 wxDataViewItem
GetNthChild( const wxDataViewItem
& parent
, unsigned int pos
) const
1409 { return GetStore()->GetNthChild(parent
, pos
); }
1410 int GetChildCount( const wxDataViewItem
& parent
) const
1411 { return GetStore()->GetChildCount(parent
); }
1413 void SetItemText( const wxDataViewItem
& item
, const wxString
&text
);
1414 wxString
GetItemText( const wxDataViewItem
& item
) const
1415 { return GetStore()->GetItemText(item
); }
1416 void SetItemIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1417 const wxIcon
&GetItemIcon( const wxDataViewItem
& item
) const
1418 { return GetStore()->GetItemIcon(item
); }
1419 void SetItemExpandedIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1420 const wxIcon
&GetItemExpandedIcon( const wxDataViewItem
& item
) const
1421 { return GetStore()->GetItemExpandedIcon(item
); }
1422 void SetItemData( const wxDataViewItem
& item
, wxClientData
*data
)
1423 { GetStore()->SetItemData(item
,data
); }
1424 wxClientData
*GetItemData( const wxDataViewItem
& item
) const
1425 { return GetStore()->GetItemData(item
); }
1427 void DeleteItem( const wxDataViewItem
& item
);
1428 void DeleteChildren( const wxDataViewItem
& item
);
1429 void DeleteAllItems();
1431 void OnExpanded( wxDataViewEvent
&event
);
1432 void OnCollapsed( wxDataViewEvent
&event
);
1433 void OnSize( wxSizeEvent
&event
);
1441 wxImageList
*m_imageList
;
1444 DECLARE_EVENT_TABLE()
1445 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl
)
1448 #endif // wxUSE_DATAVIEWCTRL
1451 // _WX_DATAVIEW_H_BASE_