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 // usually ValueChanged() should be called after changing the value in the
190 // model to update the control, ChangeValue() does it on its own while
191 // SetValue() does not -- so while you will override SetValue(), you should
192 // be usually calling ChangeValue()
193 virtual bool SetValue(const wxVariant
&variant
,
194 const wxDataViewItem
&item
,
195 unsigned int col
) = 0;
197 bool ChangeValue(const wxVariant
& variant
,
198 const wxDataViewItem
& item
,
201 return SetValue(variant
, item
, col
) && ValueChanged(item
, col
);
204 // Get text attribute, return false of default attributes should be used
205 virtual bool GetAttr( const wxDataViewItem
&WXUNUSED(item
), unsigned int WXUNUSED(col
), wxDataViewItemAttr
&WXUNUSED(attr
) )
209 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const = 0;
210 virtual bool IsContainer( const wxDataViewItem
&item
) const = 0;
211 // Is the container just a header or an item with all columns
212 virtual bool HasContainerColumns(const wxDataViewItem
& WXUNUSED(item
)) const
214 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const = 0;
216 // delegated notifiers
217 virtual bool ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
218 virtual bool ItemsAdded( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
219 virtual bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
220 virtual bool ItemsDeleted( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
221 virtual bool ItemChanged( const wxDataViewItem
&item
);
222 virtual bool ItemsChanged( const wxDataViewItemArray
&items
);
223 virtual bool ValueChanged( const wxDataViewItem
&item
, unsigned int col
);
224 virtual bool Cleared();
227 virtual void Resort();
229 void AddNotifier( wxDataViewModelNotifier
*notifier
);
230 void RemoveNotifier( wxDataViewModelNotifier
*notifier
);
232 // default compare function
233 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
234 unsigned int column
, bool ascending
) const;
235 virtual bool HasDefaultCompare() const { return false; }
238 virtual bool IsVirtualListModel() const { return false; }
241 // the user should not delete this class directly: he should use DecRef() instead!
242 virtual ~wxDataViewModel() { }
244 wxDataViewModelNotifiers m_notifiers
;
247 // ---------------------------------------------------------
248 // wxDataViewIndexListModel
249 // ---------------------------------------------------------
251 class WXDLLIMPEXP_ADV wxDataViewIndexListModel
: public wxDataViewModel
254 wxDataViewIndexListModel( unsigned int initial_size
= 0 );
255 ~wxDataViewIndexListModel();
257 virtual void GetValueByRow( wxVariant
&variant
,
258 unsigned int row
, unsigned int col
) const = 0;
260 virtual bool SetValueByRow( const wxVariant
&variant
,
261 unsigned int row
, unsigned int col
) = 0;
263 virtual bool GetAttrByRow( unsigned int WXUNUSED(row
), unsigned int WXUNUSED(col
), wxDataViewItemAttr
&WXUNUSED(attr
) )
267 void RowInserted( unsigned int before
);
269 void RowDeleted( unsigned int row
);
270 void RowsDeleted( const wxArrayInt
&rows
);
271 void RowChanged( unsigned int row
);
272 void RowValueChanged( unsigned int row
, unsigned int col
);
273 void Reset( unsigned int new_size
);
275 // convert to/from row/wxDataViewItem
277 unsigned int GetRow( const wxDataViewItem
&item
) const;
278 wxDataViewItem
GetItem( unsigned int row
) const;
280 // compare based on index
282 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
283 unsigned int column
, bool ascending
) const;
284 virtual bool HasDefaultCompare() const;
286 // implement base methods
288 virtual void GetValue( wxVariant
&variant
,
289 const wxDataViewItem
&item
, unsigned int col
) const;
290 virtual bool SetValue( const wxVariant
&variant
,
291 const wxDataViewItem
&item
, unsigned int col
);
292 virtual bool GetAttr( const wxDataViewItem
&item
, unsigned int col
, wxDataViewItemAttr
&attr
);
293 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const;
294 virtual bool IsContainer( const wxDataViewItem
&item
) const;
295 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
298 virtual bool IsVirtualListModel() const { return false; }
299 unsigned int GetCount() const { return m_hash
.GetCount(); }
302 wxDataViewItemArray m_hash
;
303 unsigned int m_nextFreeID
;
307 // ---------------------------------------------------------
308 // wxDataViewVirtualListModel
309 // ---------------------------------------------------------
312 // better than nothing
313 typedef wxDataViewIndexListModel wxDataViewVirtualListModel
;
316 class WXDLLIMPEXP_ADV wxDataViewVirtualListModel
: public wxDataViewModel
319 wxDataViewVirtualListModel( unsigned int initial_size
= 0 );
320 ~wxDataViewVirtualListModel();
322 virtual void GetValueByRow( wxVariant
&variant
,
323 unsigned int row
, unsigned int col
) const = 0;
325 virtual bool SetValueByRow( const wxVariant
&variant
,
326 unsigned int row
, unsigned int col
) = 0;
328 virtual bool GetAttrByRow( unsigned int WXUNUSED(row
), unsigned int WXUNUSED(col
), wxDataViewItemAttr
&WXUNUSED(attr
) )
332 void RowInserted( unsigned int before
);
334 void RowDeleted( unsigned int row
);
335 void RowsDeleted( const wxArrayInt
&rows
);
336 void RowChanged( unsigned int row
);
337 void RowValueChanged( unsigned int row
, unsigned int col
);
338 void Reset( unsigned int new_size
);
340 // convert to/from row/wxDataViewItem
342 unsigned int GetRow( const wxDataViewItem
&item
) const;
343 wxDataViewItem
GetItem( unsigned int row
) const;
345 // compare based on index
347 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
348 unsigned int column
, bool ascending
) const;
349 virtual bool HasDefaultCompare() const;
351 // implement base methods
353 virtual void GetValue( wxVariant
&variant
,
354 const wxDataViewItem
&item
, unsigned int col
) const;
355 virtual bool SetValue( const wxVariant
&variant
,
356 const wxDataViewItem
&item
, unsigned int col
);
357 virtual bool GetAttr( const wxDataViewItem
&item
, unsigned int col
, wxDataViewItemAttr
&attr
);
358 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const;
359 virtual bool IsContainer( const wxDataViewItem
&item
) const;
360 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
363 virtual bool IsVirtualListModel() const { return true; }
364 unsigned int GetCount() const { return m_size
; }
372 //-----------------------------------------------------------------------------
373 // wxDataViewEditorCtrlEvtHandler
374 //-----------------------------------------------------------------------------
376 class wxDataViewEditorCtrlEvtHandler
: public wxEvtHandler
379 wxDataViewEditorCtrlEvtHandler( wxControl
*editor
, wxDataViewRenderer
*owner
);
381 void AcceptChangesAndFinish();
382 void SetFocusOnIdle( bool focus
= true ) { m_focusOnIdle
= focus
; }
385 void OnChar( wxKeyEvent
&event
);
386 void OnTextEnter( wxCommandEvent
&event
);
387 void OnKillFocus( wxFocusEvent
&event
);
388 void OnIdle( wxIdleEvent
&event
);
391 wxDataViewRenderer
*m_owner
;
392 wxControl
*m_editorCtrl
;
397 DECLARE_EVENT_TABLE()
400 // ---------------------------------------------------------
401 // wxDataViewRendererBase
402 // ---------------------------------------------------------
404 enum wxDataViewCellMode
406 wxDATAVIEW_CELL_INERT
,
407 wxDATAVIEW_CELL_ACTIVATABLE
,
408 wxDATAVIEW_CELL_EDITABLE
411 enum wxDataViewCellRenderState
413 wxDATAVIEW_CELL_SELECTED
= 1,
414 wxDATAVIEW_CELL_PRELIT
= 2,
415 wxDATAVIEW_CELL_INSENSITIVE
= 4,
416 wxDATAVIEW_CELL_FOCUSED
= 8
419 class WXDLLIMPEXP_ADV wxDataViewRendererBase
: public wxObject
422 wxDataViewRendererBase( const wxString
&varianttype
,
423 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
424 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
425 virtual ~wxDataViewRendererBase();
427 virtual bool Validate( wxVariant
& WXUNUSED(value
) )
430 void SetOwner( wxDataViewColumn
*owner
) { m_owner
= owner
; }
431 wxDataViewColumn
* GetOwner() const { return m_owner
; }
433 // renderer properties:
435 virtual bool SetValue( const wxVariant
& WXUNUSED(value
) ) = 0;
436 virtual bool GetValue( wxVariant
& WXUNUSED(value
) ) const = 0;
438 wxString
GetVariantType() const { return m_variantType
; }
440 virtual void SetMode( wxDataViewCellMode mode
) = 0;
441 virtual wxDataViewCellMode
GetMode() const = 0;
443 // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but
444 // rather an "int"; that's because for rendering cells it's allowed
445 // to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM)
446 virtual void SetAlignment( int align
) = 0;
447 virtual int GetAlignment() const = 0;
449 // enable or disable (if called with wxELLIPSIZE_NONE) replacing parts of
450 // the item text (hence this only makes sense for renderers showing
451 // text...) with ellipsis in order to make it fit the column width
452 virtual void EnableEllipsize(wxEllipsizeMode mode
= wxELLIPSIZE_MIDDLE
) = 0;
453 void DisableEllipsize() { EnableEllipsize(wxELLIPSIZE_NONE
); }
455 virtual wxEllipsizeMode
GetEllipsizeMode() const = 0;
458 virtual bool HasEditorCtrl() const
460 virtual wxControl
* CreateEditorCtrl(wxWindow
* WXUNUSED(parent
),
461 wxRect
WXUNUSED(labelRect
),
462 const wxVariant
& WXUNUSED(value
))
464 virtual bool GetValueFromEditorCtrl(wxControl
* WXUNUSED(editor
),
465 wxVariant
& WXUNUSED(value
))
468 virtual bool StartEditing( const wxDataViewItem
&item
, wxRect labelRect
);
469 virtual void CancelEditing();
470 virtual bool FinishEditing();
472 wxControl
*GetEditorCtrl() { return m_editorCtrl
; }
475 wxString m_variantType
;
476 wxDataViewColumn
*m_owner
;
477 wxWeakRef
<wxControl
> m_editorCtrl
;
478 wxDataViewItem m_item
; // for m_editorCtrl
481 const wxDataViewCtrl
* GetView() const;
484 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase
)
487 //-----------------------------------------------------------------------------
488 // wxDataViewIconText
489 //-----------------------------------------------------------------------------
491 class WXDLLIMPEXP_ADV wxDataViewIconText
: public wxObject
494 wxDataViewIconText( const wxString
&text
= wxEmptyString
, const wxIcon
& icon
= wxNullIcon
)
495 : m_text(text
), m_icon(icon
)
497 wxDataViewIconText( const wxDataViewIconText
&other
)
499 { m_icon
= other
.m_icon
; m_text
= other
.m_text
; }
501 void SetText( const wxString
&text
) { m_text
= text
; }
502 wxString
GetText() const { return m_text
; }
503 void SetIcon( const wxIcon
&icon
) { m_icon
= icon
; }
504 const wxIcon
&GetIcon() const { return m_icon
; }
511 DECLARE_DYNAMIC_CLASS(wxDataViewIconText
)
515 bool operator==(const wxDataViewIconText
& left
, const wxDataViewIconText
& right
)
517 return left
.GetText() == right
.GetText() &&
518 left
.GetIcon().IsSameAs(right
.GetIcon());
522 bool operator!=(const wxDataViewIconText
& left
, const wxDataViewIconText
& right
)
524 return !(left
== right
);
527 DECLARE_VARIANT_OBJECT_EXPORTED(wxDataViewIconText
, WXDLLIMPEXP_ADV
)
529 // ---------------------------------------------------------
530 // wxDataViewColumnBase
531 // ---------------------------------------------------------
533 // for compatibility only, do not use
534 enum wxDataViewColumnFlags
536 wxDATAVIEW_COL_RESIZABLE
= wxCOL_RESIZABLE
,
537 wxDATAVIEW_COL_SORTABLE
= wxCOL_SORTABLE
,
538 wxDATAVIEW_COL_REORDERABLE
= wxCOL_REORDERABLE
,
539 wxDATAVIEW_COL_HIDDEN
= wxCOL_HIDDEN
542 class WXDLLIMPEXP_ADV wxDataViewColumnBase
: public wxSettableHeaderColumn
545 // ctor for the text columns: takes ownership of renderer
546 wxDataViewColumnBase(wxDataViewRenderer
*renderer
,
547 unsigned int model_column
)
549 Init(renderer
, model_column
);
552 // ctor for the bitmap columns
553 wxDataViewColumnBase(const wxBitmap
& bitmap
,
554 wxDataViewRenderer
*renderer
,
555 unsigned int model_column
)
558 Init(renderer
, model_column
);
561 virtual ~wxDataViewColumnBase();
564 virtual void SetOwner( wxDataViewCtrl
*owner
)
568 unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column
); }
569 wxDataViewCtrl
*GetOwner() const { return m_owner
; }
570 wxDataViewRenderer
* GetRenderer() const { return m_renderer
; }
572 // implement some of base class pure virtuals (the rest is port-dependent
573 // and done differently in generic and native versions)
574 virtual void SetBitmap( const wxBitmap
& bitmap
) { m_bitmap
= bitmap
; }
575 virtual wxBitmap
GetBitmap() const { return m_bitmap
; }
578 wxDataViewRenderer
*m_renderer
;
581 wxDataViewCtrl
*m_owner
;
584 // common part of all ctors
585 void Init(wxDataViewRenderer
*renderer
, unsigned int model_column
);
588 // ---------------------------------------------------------
589 // wxDataViewCtrlBase
590 // ---------------------------------------------------------
592 #define wxDV_SINGLE 0x0000 // for convenience
593 #define wxDV_MULTIPLE 0x0001 // can select multiple items
595 #define wxDV_NO_HEADER 0x0002 // column titles not visible
596 #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows
597 #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns
599 #define wxDV_ROW_LINES 0x0010 // alternating colour in rows
600 #define wxDV_VARIABLE_LINE_HEIGHT 0x0020 // variable line height
602 class WXDLLIMPEXP_ADV wxDataViewCtrlBase
: public wxControl
605 wxDataViewCtrlBase();
606 virtual ~wxDataViewCtrlBase();
611 virtual bool AssociateModel( wxDataViewModel
*model
);
612 wxDataViewModel
* GetModel();
613 const wxDataViewModel
* GetModel() const;
619 wxDataViewColumn
*PrependTextColumn( const wxString
&label
, unsigned int model_column
,
620 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
621 wxAlignment align
= wxALIGN_NOT
,
622 int flags
= wxDATAVIEW_COL_RESIZABLE
);
623 wxDataViewColumn
*PrependIconTextColumn( const wxString
&label
, unsigned int model_column
,
624 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
625 wxAlignment align
= wxALIGN_NOT
,
626 int flags
= wxDATAVIEW_COL_RESIZABLE
);
627 wxDataViewColumn
*PrependToggleColumn( const wxString
&label
, unsigned int model_column
,
628 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
629 wxAlignment align
= wxALIGN_CENTER
,
630 int flags
= wxDATAVIEW_COL_RESIZABLE
);
631 wxDataViewColumn
*PrependProgressColumn( const wxString
&label
, unsigned int model_column
,
632 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
633 wxAlignment align
= wxALIGN_CENTER
,
634 int flags
= wxDATAVIEW_COL_RESIZABLE
);
635 wxDataViewColumn
*PrependDateColumn( const wxString
&label
, unsigned int model_column
,
636 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
637 wxAlignment align
= wxALIGN_NOT
,
638 int flags
= wxDATAVIEW_COL_RESIZABLE
);
639 wxDataViewColumn
*PrependBitmapColumn( const wxString
&label
, unsigned int model_column
,
640 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
641 wxAlignment align
= wxALIGN_CENTER
,
642 int flags
= wxDATAVIEW_COL_RESIZABLE
);
643 wxDataViewColumn
*PrependTextColumn( const wxBitmap
&label
, unsigned int model_column
,
644 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
645 wxAlignment align
= wxALIGN_NOT
,
646 int flags
= wxDATAVIEW_COL_RESIZABLE
);
647 wxDataViewColumn
*PrependIconTextColumn( const wxBitmap
&label
, unsigned int model_column
,
648 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
649 wxAlignment align
= wxALIGN_NOT
,
650 int flags
= wxDATAVIEW_COL_RESIZABLE
);
651 wxDataViewColumn
*PrependToggleColumn( const wxBitmap
&label
, unsigned int model_column
,
652 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
653 wxAlignment align
= wxALIGN_CENTER
,
654 int flags
= wxDATAVIEW_COL_RESIZABLE
);
655 wxDataViewColumn
*PrependProgressColumn( const wxBitmap
&label
, unsigned int model_column
,
656 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
657 wxAlignment align
= wxALIGN_CENTER
,
658 int flags
= wxDATAVIEW_COL_RESIZABLE
);
659 wxDataViewColumn
*PrependDateColumn( const wxBitmap
&label
, unsigned int model_column
,
660 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
661 wxAlignment align
= wxALIGN_NOT
,
662 int flags
= wxDATAVIEW_COL_RESIZABLE
);
663 wxDataViewColumn
*PrependBitmapColumn( const wxBitmap
&label
, unsigned int model_column
,
664 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
665 wxAlignment align
= wxALIGN_CENTER
,
666 int flags
= wxDATAVIEW_COL_RESIZABLE
);
668 wxDataViewColumn
*AppendTextColumn( const wxString
&label
, unsigned int model_column
,
669 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
670 wxAlignment align
= wxALIGN_NOT
,
671 int flags
= wxDATAVIEW_COL_RESIZABLE
);
672 wxDataViewColumn
*AppendIconTextColumn( const wxString
&label
, unsigned int model_column
,
673 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
674 wxAlignment align
= wxALIGN_NOT
,
675 int flags
= wxDATAVIEW_COL_RESIZABLE
);
676 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
, unsigned int model_column
,
677 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
678 wxAlignment align
= wxALIGN_CENTER
,
679 int flags
= wxDATAVIEW_COL_RESIZABLE
);
680 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
, unsigned int model_column
,
681 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
682 wxAlignment align
= wxALIGN_CENTER
,
683 int flags
= wxDATAVIEW_COL_RESIZABLE
);
684 wxDataViewColumn
*AppendDateColumn( const wxString
&label
, unsigned int model_column
,
685 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
686 wxAlignment align
= wxALIGN_NOT
,
687 int flags
= wxDATAVIEW_COL_RESIZABLE
);
688 wxDataViewColumn
*AppendBitmapColumn( const wxString
&label
, unsigned int model_column
,
689 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
690 wxAlignment align
= wxALIGN_CENTER
,
691 int flags
= wxDATAVIEW_COL_RESIZABLE
);
692 wxDataViewColumn
*AppendTextColumn( const wxBitmap
&label
, unsigned int model_column
,
693 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
694 wxAlignment align
= wxALIGN_NOT
,
695 int flags
= wxDATAVIEW_COL_RESIZABLE
);
696 wxDataViewColumn
*AppendIconTextColumn( const wxBitmap
&label
, unsigned int model_column
,
697 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
698 wxAlignment align
= wxALIGN_NOT
,
699 int flags
= wxDATAVIEW_COL_RESIZABLE
);
700 wxDataViewColumn
*AppendToggleColumn( const wxBitmap
&label
, unsigned int model_column
,
701 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
702 wxAlignment align
= wxALIGN_CENTER
,
703 int flags
= wxDATAVIEW_COL_RESIZABLE
);
704 wxDataViewColumn
*AppendProgressColumn( const wxBitmap
&label
, unsigned int model_column
,
705 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
706 wxAlignment align
= wxALIGN_CENTER
,
707 int flags
= wxDATAVIEW_COL_RESIZABLE
);
708 wxDataViewColumn
*AppendDateColumn( const wxBitmap
&label
, unsigned int model_column
,
709 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
710 wxAlignment align
= wxALIGN_NOT
,
711 int flags
= wxDATAVIEW_COL_RESIZABLE
);
712 wxDataViewColumn
*AppendBitmapColumn( const wxBitmap
&label
, unsigned int model_column
,
713 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
714 wxAlignment align
= wxALIGN_CENTER
,
715 int flags
= wxDATAVIEW_COL_RESIZABLE
);
717 virtual bool PrependColumn( wxDataViewColumn
*col
);
718 virtual bool InsertColumn( unsigned int pos
, wxDataViewColumn
*col
);
719 virtual bool AppendColumn( wxDataViewColumn
*col
);
721 virtual unsigned int GetColumnCount() const = 0;
722 virtual wxDataViewColumn
* GetColumn( unsigned int pos
) const = 0;
723 virtual int GetColumnPosition( const wxDataViewColumn
*column
) const = 0;
725 virtual bool DeleteColumn( wxDataViewColumn
*column
) = 0;
726 virtual bool ClearColumns() = 0;
728 void SetExpanderColumn( wxDataViewColumn
*col
)
729 { m_expander_column
= col
; DoSetExpanderColumn(); }
730 wxDataViewColumn
*GetExpanderColumn() const
731 { return m_expander_column
; }
733 virtual wxDataViewColumn
*GetSortingColumn() const = 0;
739 void SetIndent( int indent
)
740 { m_indent
= indent
; DoSetIndent(); }
741 int GetIndent() const
744 virtual wxDataViewItem
GetSelection() const = 0;
745 virtual int GetSelections( wxDataViewItemArray
& sel
) const = 0;
746 virtual void SetSelections( const wxDataViewItemArray
& sel
) = 0;
747 virtual void Select( const wxDataViewItem
& item
) = 0;
748 virtual void Unselect( const wxDataViewItem
& item
) = 0;
749 virtual bool IsSelected( const wxDataViewItem
& item
) const = 0;
751 virtual void SelectAll() = 0;
752 virtual void UnselectAll() = 0;
754 virtual void Expand( const wxDataViewItem
& item
) = 0;
755 virtual void ExpandAncestors( const wxDataViewItem
& item
);
756 virtual void Collapse( const wxDataViewItem
& item
) = 0;
757 virtual bool IsExpanded( const wxDataViewItem
& item
) const = 0;
759 virtual void EnsureVisible( const wxDataViewItem
& item
,
760 const wxDataViewColumn
*column
= NULL
) = 0;
761 virtual void HitTest( const wxPoint
& point
, wxDataViewItem
&item
, wxDataViewColumn
* &column
) const = 0;
762 virtual wxRect
GetItemRect( const wxDataViewItem
& item
, const wxDataViewColumn
*column
= NULL
) const = 0;
764 #if wxUSE_DRAG_AND_DROP
765 virtual bool EnableDragSource(const wxDataFormat
& WXUNUSED(format
))
767 virtual bool EnableDropTarget(const wxDataFormat
& WXUNUSED(format
))
769 #endif // wxUSE_DRAG_AND_DROP
771 // define control visual attributes
772 // --------------------------------
774 virtual wxVisualAttributes
GetDefaultAttributes() const
776 return GetClassDefaultAttributes(GetWindowVariant());
779 static wxVisualAttributes
780 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
)
782 return wxControl
::GetCompositeControlsDefaultAttributes(variant
);
786 virtual void DoSetExpanderColumn() = 0 ;
787 virtual void DoSetIndent() = 0;
790 wxDataViewModel
*m_model
;
791 wxDataViewColumn
*m_expander_column
;
795 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase
)
798 // ----------------------------------------------------------------------------
799 // wxDataViewEvent - the event class for the wxDataViewCtrl notifications
800 // ----------------------------------------------------------------------------
802 class WXDLLIMPEXP_ADV wxDataViewEvent
: public wxNotifyEvent
805 wxDataViewEvent(wxEventType commandType
= wxEVT_NULL
, int winid
= 0)
806 : wxNotifyEvent(commandType
, winid
),
810 m_value(wxNullVariant
),
815 #if wxUSE_DRAG_AND_DROP
816 , m_dataObject(NULL
),
822 wxDataViewEvent(const wxDataViewEvent
& event
)
823 : wxNotifyEvent(event
),
824 m_item(event
.m_item
),
826 m_model(event
.m_model
),
827 m_value(event
.m_value
),
828 m_column(event
.m_column
),
830 m_cacheFrom(event
.m_cacheFrom
),
831 m_cacheTo(event
.m_cacheTo
)
832 #if wxUSE_DRAG_AND_DROP
833 , m_dataObject(event
.m_dataObject
),
834 m_dataFormat(event
.m_dataFormat
),
835 m_dataBuffer(event
.m_dataBuffer
),
836 m_dataSize(event
.m_dataSize
)
840 wxDataViewItem
GetItem() const { return m_item
; }
841 void SetItem( const wxDataViewItem
&item
) { m_item
= item
; }
843 int GetColumn() const { return m_col
; }
844 void SetColumn( int col
) { m_col
= col
; }
846 wxDataViewModel
* GetModel() const { return m_model
; }
847 void SetModel( wxDataViewModel
*model
) { m_model
= model
; }
849 const wxVariant
&GetValue() const { return m_value
; }
850 void SetValue( const wxVariant
&value
) { m_value
= value
; }
852 // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only
853 void SetDataViewColumn( wxDataViewColumn
*col
) { m_column
= col
; }
854 wxDataViewColumn
*GetDataViewColumn() const { return m_column
; }
856 // for wxEVT_DATAVIEW_CONTEXT_MENU only
857 wxPoint
GetPosition() const { return m_pos
; }
858 void SetPosition( int x
, int y
) { m_pos
.x
= x
; m_pos
.y
= y
; }
860 // For wxEVT_COMMAND_DATAVIEW_CACHE_HINT
861 int GetCacheFrom() const { return m_cacheFrom
; }
862 int GetCacheTo() const { return m_cacheTo
; }
863 void SetCache(int from
, int to
) { m_cacheFrom
= from
; m_cacheTo
= to
; }
866 #if wxUSE_DRAG_AND_DROP
867 // For drag operations
868 void SetDataObject( wxDataObject
*obj
) { m_dataObject
= obj
; }
869 wxDataObject
*GetDataObject() const { return m_dataObject
; }
871 // For drop operations
872 void SetDataFormat( const wxDataFormat
&format
) { m_dataFormat
= format
; }
873 wxDataFormat
GetDataFormat() const { return m_dataFormat
; }
874 void SetDataSize( size_t size
) { m_dataSize
= size
; }
875 size_t GetDataSize() const { return m_dataSize
; }
876 void SetDataBuffer( void* buf
) { m_dataBuffer
= buf
;}
877 void *GetDataBuffer() const { return m_dataBuffer
; }
878 #endif // wxUSE_DRAG_AND_DROP
880 virtual wxEvent
*Clone() const { return new wxDataViewEvent(*this); }
883 wxDataViewItem m_item
;
885 wxDataViewModel
*m_model
;
887 wxDataViewColumn
*m_column
;
892 #if wxUSE_DRAG_AND_DROP
893 wxDataObject
*m_dataObject
;
895 wxDataFormat m_dataFormat
;
898 #endif // wxUSE_DRAG_AND_DROP
901 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent
)
904 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED
, wxDataViewEvent
);
906 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED
, wxDataViewEvent
);
907 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED
, wxDataViewEvent
);
908 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED
, wxDataViewEvent
);
909 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING
, wxDataViewEvent
);
910 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING
, wxDataViewEvent
);
911 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING
, wxDataViewEvent
);
912 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED
, wxDataViewEvent
);
913 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE
, wxDataViewEvent
);
914 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED
, wxDataViewEvent
);
916 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU
, wxDataViewEvent
);
918 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK
, wxDataViewEvent
);
919 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK
, wxDataViewEvent
);
920 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED
, wxDataViewEvent
);
921 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED
, wxDataViewEvent
);
923 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_CACHE_HINT
, wxDataViewEvent
);
925 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG
, wxDataViewEvent
);
926 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE
, wxDataViewEvent
);
927 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_DROP
, wxDataViewEvent
);
929 typedef void (wxEvtHandler
::*wxDataViewEventFunction
)(wxDataViewEvent
&);
931 #define wxDataViewEventHandler(func) \
932 wxEVENT_HANDLER_CAST(wxDataViewEventFunction, func)
934 #define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \
935 wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn))
937 #define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn)
939 #define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn)
940 #define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn)
941 #define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn)
942 #define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn)
943 #define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn)
944 #define EVT_DATAVIEW_ITEM_START_EDITING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_START_EDITING, id, fn)
945 #define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn)
946 #define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn)
947 #define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn)
949 #define EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_CONTEXT_MENU, id, fn)
951 #define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn)
952 #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn)
953 #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn)
954 #define EVT_DATAVIEW_COLUMN_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_REORDERED, id, fn)
955 #define EVT_DATAVIEW_CACHE_HINT(id, fn) wx__DECLARE_DATAVIEWEVT(CACHE_HINT, id, fn)
957 #define EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_BEGIN_DRAG, id, fn)
958 #define EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP_POSSIBLE, id, fn)
959 #define EVT_DATAVIEW_ITEM_DROP(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP, id, fn)
961 #ifdef wxHAS_GENERIC_DATAVIEWCTRL
962 // this symbol doesn't follow the convention for wxUSE_XXX symbols which
963 // are normally always defined as either 0 or 1, so its use is deprecated
964 // and it only exists for backwards compatibility, don't use it any more
965 // and use wxHAS_GENERIC_DATAVIEWCTRL instead
966 #define wxUSE_GENERICDATAVIEWCTRL
968 #include "wx/generic/dataview.h"
969 #elif defined(__WXGTK20__)
970 #include "wx/gtk/dataview.h"
971 #elif defined(__WXMAC__)
972 #include "wx/osx/dataview.h"
974 #error "unknown native wxDataViewCtrl implementation"
977 // -------------------------------------
978 // wxDataViewSpinRenderer
979 // -------------------------------------
981 class WXDLLIMPEXP_ADV wxDataViewSpinRenderer
: public wxDataViewCustomRenderer
984 wxDataViewSpinRenderer( int min
, int max
,
985 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
986 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
987 virtual bool HasEditorCtrl() const { return true; }
988 virtual wxControl
* CreateEditorCtrl( wxWindow
*parent
, wxRect labelRect
, const wxVariant
&value
);
989 virtual bool GetValueFromEditorCtrl( wxControl
* editor
, wxVariant
&value
);
990 virtual bool Render( wxRect rect
, wxDC
*dc
, int state
);
991 virtual wxSize
GetSize() const;
992 virtual bool SetValue( const wxVariant
&value
);
993 virtual bool GetValue( wxVariant
&value
) const;
1000 #if defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXOSX_CARBON__)
1002 // -------------------------------------
1003 // wxDataViewChoiceRenderer
1004 // -------------------------------------
1006 class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer
: public wxDataViewCustomRenderer
1009 wxDataViewChoiceRenderer( const wxArrayString
&choices
,
1010 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
1011 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
1012 virtual bool HasEditorCtrl() const { return true; }
1013 virtual wxControl
* CreateEditorCtrl( wxWindow
*parent
, wxRect labelRect
, const wxVariant
&value
);
1014 virtual bool GetValueFromEditorCtrl( wxControl
* editor
, wxVariant
&value
);
1015 virtual bool Render( wxRect rect
, wxDC
*dc
, int state
);
1016 virtual wxSize
GetSize() const;
1017 virtual bool SetValue( const wxVariant
&value
);
1018 virtual bool GetValue( wxVariant
&value
) const;
1021 wxArrayString m_choices
;
1027 // this class is obsolete, its functionality was merged in
1028 // wxDataViewTextRenderer itself now, don't use it any more
1029 #define wxDataViewTextRendererAttr wxDataViewTextRenderer
1031 //-----------------------------------------------------------------------------
1032 // wxDataViewListStore
1033 //-----------------------------------------------------------------------------
1035 class WXDLLIMPEXP_ADV wxDataViewListStoreLine
1038 wxDataViewListStoreLine( wxClientData
*data
= NULL
)
1042 virtual ~wxDataViewListStoreLine()
1047 void SetData( wxClientData
*data
)
1048 { if (m_data
) delete m_data
; m_data
= data
; }
1049 wxClientData
*GetData() const
1052 wxVector
<wxVariant
> m_values
;
1055 wxClientData
*m_data
;
1059 class WXDLLIMPEXP_ADV wxDataViewListStore
: public wxDataViewIndexListModel
1062 wxDataViewListStore();
1063 ~wxDataViewListStore();
1065 void PrependColumn( const wxString
&varianttype
);
1066 void InsertColumn( unsigned int pos
, const wxString
&varianttype
);
1067 void AppendColumn( const wxString
&varianttype
);
1069 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1070 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1071 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1072 void DeleteItem( unsigned int pos
);
1073 void DeleteAllItems();
1075 // override base virtuals
1077 virtual unsigned int GetColumnCount() const;
1079 virtual wxString
GetColumnType( unsigned int col
) const;
1081 virtual void GetValueByRow( wxVariant
&value
,
1082 unsigned int row
, unsigned int col
) const;
1084 virtual bool SetValueByRow( const wxVariant
&value
,
1085 unsigned int row
, unsigned int col
);
1089 wxVector
<wxDataViewListStoreLine
*> m_data
;
1090 wxArrayString m_cols
;
1093 //-----------------------------------------------------------------------------
1095 class WXDLLIMPEXP_ADV wxDataViewListCtrl
: public wxDataViewCtrl
1098 wxDataViewListCtrl();
1099 wxDataViewListCtrl( wxWindow
*parent
, wxWindowID id
,
1100 const wxPoint
& pos
= wxDefaultPosition
,
1101 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
1102 const wxValidator
& validator
= wxDefaultValidator
);
1103 ~wxDataViewListCtrl();
1105 bool Create( wxWindow
*parent
, wxWindowID id
,
1106 const wxPoint
& pos
= wxDefaultPosition
,
1107 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
1108 const wxValidator
& validator
= wxDefaultValidator
);
1110 wxDataViewListStore
*GetStore()
1111 { return (wxDataViewListStore
*) GetModel(); }
1112 const wxDataViewListStore
*GetStore() const
1113 { return (const wxDataViewListStore
*) GetModel(); }
1115 bool AppendColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
1116 bool PrependColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
1117 bool InsertColumn( unsigned int pos
, wxDataViewColumn
*column
, const wxString
&varianttype
);
1119 // overridden from base class
1120 virtual bool PrependColumn( wxDataViewColumn
*col
);
1121 virtual bool InsertColumn( unsigned int pos
, wxDataViewColumn
*col
);
1122 virtual bool AppendColumn( wxDataViewColumn
*col
);
1124 wxDataViewColumn
*AppendTextColumn( const wxString
&label
,
1125 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1126 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1127 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
,
1128 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
1129 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1130 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
,
1131 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1132 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1133 wxDataViewColumn
*AppendIconTextColumn( const wxString
&label
,
1134 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1135 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1137 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1138 { GetStore()->AppendItem( values
, data
); }
1139 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1140 { GetStore()->PrependItem( values
, data
); }
1141 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1142 { GetStore()->InsertItem( row
, values
, data
); }
1143 void DeleteItem( unsigned row
)
1144 { GetStore()->DeleteItem( row
); }
1145 void DeleteAllItems()
1146 { GetStore()->DeleteAllItems(); }
1148 void SetValue( const wxVariant
&value
, unsigned int row
, unsigned int col
)
1149 { GetStore()->SetValueByRow( value
, row
, col
);
1150 GetStore()->RowValueChanged( row
, col
); }
1151 void GetValue( wxVariant
&value
, unsigned int row
, unsigned int col
)
1152 { GetStore()->GetValueByRow( value
, row
, col
); }
1154 void SetTextValue( const wxString
&value
, unsigned int row
, unsigned int col
)
1155 { GetStore()->SetValueByRow( value
, row
, col
);
1156 GetStore()->RowValueChanged( row
, col
); }
1157 wxString
GetTextValue( unsigned int row
, unsigned int col
) const
1158 { wxVariant value
; GetStore()->GetValueByRow( value
, row
, col
); return value
.GetString(); }
1160 void SetToggleValue( bool value
, unsigned int row
, unsigned int col
)
1161 { GetStore()->SetValueByRow( value
, row
, col
);
1162 GetStore()->RowValueChanged( row
, col
); }
1163 bool GetToggleValue( unsigned int row
, unsigned int col
) const
1164 { wxVariant value
; GetStore()->GetValueByRow( value
, row
, col
); return value
.GetBool(); }
1166 void OnSize( wxSizeEvent
&event
);
1169 DECLARE_EVENT_TABLE()
1170 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewListCtrl
)
1173 //-----------------------------------------------------------------------------
1174 // wxDataViewTreeStore
1175 //-----------------------------------------------------------------------------
1177 class WXDLLIMPEXP_ADV wxDataViewTreeStoreNode
1180 wxDataViewTreeStoreNode( wxDataViewTreeStoreNode
*parent
,
1181 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1182 virtual ~wxDataViewTreeStoreNode();
1184 void SetText( const wxString
&text
)
1186 wxString
GetText() const
1188 void SetIcon( const wxIcon
&icon
)
1190 const wxIcon
&GetIcon() const
1192 void SetData( wxClientData
*data
)
1193 { if (m_data
) delete m_data
; m_data
= data
; }
1194 wxClientData
*GetData() const
1197 wxDataViewItem
GetItem() const
1198 { return wxDataViewItem( (void*) this ); }
1200 virtual bool IsContainer()
1203 wxDataViewTreeStoreNode
*GetParent()
1204 { return m_parent
; }
1207 wxDataViewTreeStoreNode
*m_parent
;
1210 wxClientData
*m_data
;
1213 WX_DECLARE_LIST_WITH_DECL(wxDataViewTreeStoreNode
, wxDataViewTreeStoreNodeList
,
1214 class WXDLLIMPEXP_ADV
);
1216 class WXDLLIMPEXP_ADV wxDataViewTreeStoreContainerNode
: public wxDataViewTreeStoreNode
1219 wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode
*parent
,
1220 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1221 wxClientData
*data
= NULL
);
1222 virtual ~wxDataViewTreeStoreContainerNode();
1224 const wxDataViewTreeStoreNodeList
&GetChildren() const
1225 { return m_children
; }
1226 wxDataViewTreeStoreNodeList
&GetChildren()
1227 { return m_children
; }
1229 void SetExpandedIcon( const wxIcon
&icon
)
1230 { m_iconExpanded
= icon
; }
1231 const wxIcon
&GetExpandedIcon() const
1232 { return m_iconExpanded
; }
1234 void SetExpanded( bool expanded
= true )
1235 { m_isExpanded
= expanded
; }
1236 bool IsExpanded() const
1237 { return m_isExpanded
; }
1239 virtual bool IsContainer()
1243 wxDataViewTreeStoreNodeList m_children
;
1244 wxIcon m_iconExpanded
;
1248 //-----------------------------------------------------------------------------
1250 class WXDLLIMPEXP_ADV wxDataViewTreeStore
: public wxDataViewModel
1253 wxDataViewTreeStore();
1254 ~wxDataViewTreeStore();
1256 wxDataViewItem
AppendItem( const wxDataViewItem
& parent
,
1257 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1258 wxDataViewItem
PrependItem( const wxDataViewItem
& parent
,
1259 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1260 wxDataViewItem
InsertItem( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1261 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1263 wxDataViewItem
PrependContainer( const wxDataViewItem
& parent
,
1264 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1265 wxClientData
*data
= NULL
);
1266 wxDataViewItem
AppendContainer( const wxDataViewItem
& parent
,
1267 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1268 wxClientData
*data
= NULL
);
1269 wxDataViewItem
InsertContainer( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1270 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1271 wxClientData
*data
= NULL
);
1273 wxDataViewItem
GetNthChild( const wxDataViewItem
& parent
, unsigned int pos
) const;
1274 int GetChildCount( const wxDataViewItem
& parent
) const;
1276 void SetItemText( const wxDataViewItem
& item
, const wxString
&text
);
1277 wxString
GetItemText( const wxDataViewItem
& item
) const;
1278 void SetItemIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1279 const wxIcon
&GetItemIcon( const wxDataViewItem
& item
) const;
1280 void SetItemExpandedIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1281 const wxIcon
&GetItemExpandedIcon( const wxDataViewItem
& item
) const;
1282 void SetItemData( const wxDataViewItem
& item
, wxClientData
*data
);
1283 wxClientData
*GetItemData( const wxDataViewItem
& item
) const;
1285 void DeleteItem( const wxDataViewItem
& item
);
1286 void DeleteChildren( const wxDataViewItem
& item
);
1287 void DeleteAllItems();
1289 // implement base methods
1291 virtual void GetValue( wxVariant
&variant
,
1292 const wxDataViewItem
&item
, unsigned int col
) const;
1293 virtual bool SetValue( const wxVariant
&variant
,
1294 const wxDataViewItem
&item
, unsigned int col
);
1295 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const;
1296 virtual bool IsContainer( const wxDataViewItem
&item
) const;
1297 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
1299 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
1300 unsigned int column
, bool ascending
) const;
1302 virtual bool HasDefaultCompare() const
1304 virtual unsigned int GetColumnCount() const
1306 virtual wxString
GetColumnType( unsigned int WXUNUSED(col
) ) const
1307 { return wxT("wxDataViewIconText"); }
1309 wxDataViewTreeStoreNode
*FindNode( const wxDataViewItem
&item
) const;
1310 wxDataViewTreeStoreContainerNode
*FindContainerNode( const wxDataViewItem
&item
) const;
1311 wxDataViewTreeStoreNode
*GetRoot() const { return m_root
; }
1314 wxDataViewTreeStoreNode
*m_root
;
1317 //-----------------------------------------------------------------------------
1319 class WXDLLIMPEXP_ADV wxDataViewTreeCtrl
: public wxDataViewCtrl
1322 wxDataViewTreeCtrl();
1323 wxDataViewTreeCtrl( wxWindow
*parent
, wxWindowID id
,
1324 const wxPoint
& pos
= wxDefaultPosition
,
1325 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
1326 const wxValidator
& validator
= wxDefaultValidator
);
1327 ~wxDataViewTreeCtrl();
1329 bool Create( wxWindow
*parent
, wxWindowID id
,
1330 const wxPoint
& pos
= wxDefaultPosition
,
1331 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
1332 const wxValidator
& validator
= wxDefaultValidator
);
1334 wxDataViewTreeStore
*GetStore()
1335 { return (wxDataViewTreeStore
*) GetModel(); }
1336 const wxDataViewTreeStore
*GetStore() const
1337 { return (const wxDataViewTreeStore
*) GetModel(); }
1339 void SetImageList( wxImageList
*imagelist
);
1340 wxImageList
* GetImageList() { return m_imageList
; }
1342 wxDataViewItem
AppendItem( const wxDataViewItem
& parent
,
1343 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1344 wxDataViewItem
PrependItem( const wxDataViewItem
& parent
,
1345 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1346 wxDataViewItem
InsertItem( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1347 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1349 wxDataViewItem
PrependContainer( const wxDataViewItem
& parent
,
1350 const wxString
&text
, int icon
= -1, int expanded
= -1,
1351 wxClientData
*data
= NULL
);
1352 wxDataViewItem
AppendContainer( const wxDataViewItem
& parent
,
1353 const wxString
&text
, int icon
= -1, int expanded
= -1,
1354 wxClientData
*data
= NULL
);
1355 wxDataViewItem
InsertContainer( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1356 const wxString
&text
, int icon
= -1, int expanded
= -1,
1357 wxClientData
*data
= NULL
);
1359 wxDataViewItem
GetNthChild( const wxDataViewItem
& parent
, unsigned int pos
) const
1360 { return GetStore()->GetNthChild(parent
, pos
); }
1361 int GetChildCount( const wxDataViewItem
& parent
) const
1362 { return GetStore()->GetChildCount(parent
); }
1364 void SetItemText( const wxDataViewItem
& item
, const wxString
&text
);
1365 wxString
GetItemText( const wxDataViewItem
& item
) const
1366 { return GetStore()->GetItemText(item
); }
1367 void SetItemIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1368 const wxIcon
&GetItemIcon( const wxDataViewItem
& item
) const
1369 { return GetStore()->GetItemIcon(item
); }
1370 void SetItemExpandedIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1371 const wxIcon
&GetItemExpandedIcon( const wxDataViewItem
& item
) const
1372 { return GetStore()->GetItemExpandedIcon(item
); }
1373 void SetItemData( const wxDataViewItem
& item
, wxClientData
*data
)
1374 { GetStore()->SetItemData(item
,data
); }
1375 wxClientData
*GetItemData( const wxDataViewItem
& item
) const
1376 { return GetStore()->GetItemData(item
); }
1378 void DeleteItem( const wxDataViewItem
& item
);
1379 void DeleteChildren( const wxDataViewItem
& item
);
1380 void DeleteAllItems();
1382 void OnExpanded( wxDataViewEvent
&event
);
1383 void OnCollapsed( wxDataViewEvent
&event
);
1384 void OnSize( wxSizeEvent
&event
);
1387 wxImageList
*m_imageList
;
1390 DECLARE_EVENT_TABLE()
1391 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl
)
1394 #endif // wxUSE_DATAVIEWCTRL
1397 // _WX_DATAVIEW_H_BASE_