1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxDataViewCtrl base classes
4 // Author: Robert Roebling
5 // Modified by: Bo Yang
8 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_DATAVIEW_H_BASE_
13 #define _WX_DATAVIEW_H_BASE_
17 #if wxUSE_DATAVIEWCTRL
19 #include "wx/textctrl.h"
20 #include "wx/headercol.h"
21 #include "wx/variant.h"
22 #include "wx/dynarray.h"
24 #include "wx/weakref.h"
25 #include "wx/vector.h"
26 #include "wx/dataobj.h"
28 class WXDLLIMPEXP_FWD_CORE wxImageList
;
30 #if !(defined(__WXGTK20__) || defined(__WXOSX__)) || defined(__WXUNIVERSAL__)
31 // #if !(defined(__WXOSX__)) || defined(__WXUNIVERSAL__)
32 #define wxHAS_GENERIC_DATAVIEWCTRL
35 // ----------------------------------------------------------------------------
36 // wxDataViewCtrl globals
37 // ----------------------------------------------------------------------------
39 class WXDLLIMPEXP_FWD_ADV wxDataViewItem
;
40 class WXDLLIMPEXP_FWD_ADV wxDataViewModel
;
41 class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl
;
42 class WXDLLIMPEXP_FWD_ADV wxDataViewColumn
;
43 class WXDLLIMPEXP_FWD_ADV wxDataViewRenderer
;
44 class WXDLLIMPEXP_FWD_ADV wxDataViewModelNotifier
;
46 extern WXDLLIMPEXP_DATA_ADV(const char) wxDataViewCtrlNameStr
[];
48 // ----------------------------------------------------------------------------
49 // wxDataViewCtrl flags
50 // ----------------------------------------------------------------------------
52 // size of a wxDataViewRenderer without contents:
53 #define wxDVC_DEFAULT_RENDERER_SIZE 20
55 // the default width of new (text) columns:
56 #define wxDVC_DEFAULT_WIDTH 80
58 // the default width of new toggle columns:
59 #define wxDVC_TOGGLE_DEFAULT_WIDTH 30
61 // the default minimal width of the columns:
62 #define wxDVC_DEFAULT_MINWIDTH 30
64 // The default alignment of wxDataViewRenderers is to take
65 // the alignment from the column it owns.
66 #define wxDVR_DEFAULT_ALIGNMENT -1
69 // ---------------------------------------------------------
71 // ---------------------------------------------------------
73 class WXDLLIMPEXP_ADV wxDataViewItem
76 wxDataViewItem( void* id
= NULL
)
78 wxDataViewItem( const wxDataViewItem
&item
)
80 bool IsOk() const { return m_id
!= NULL
; }
81 void* GetID() const { return m_id
; }
82 operator const void* () const { return m_id
; }
89 bool operator==(const wxDataViewItem
& left
, const wxDataViewItem
& right
)
91 return left
.GetID() == right
.GetID();
95 bool operator!=(const wxDataViewItem
& left
, const wxDataViewItem
& right
)
97 return !(left
== right
);
100 WX_DEFINE_ARRAY(wxDataViewItem
, wxDataViewItemArray
);
102 // ---------------------------------------------------------
103 // wxDataViewModelNotifier
104 // ---------------------------------------------------------
106 class WXDLLIMPEXP_ADV wxDataViewModelNotifier
109 wxDataViewModelNotifier() { m_owner
= NULL
; }
110 virtual ~wxDataViewModelNotifier() { m_owner
= NULL
; }
112 virtual bool ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
) = 0;
113 virtual bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
) = 0;
114 virtual bool ItemChanged( const wxDataViewItem
&item
) = 0;
115 virtual bool ItemsAdded( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
116 virtual bool ItemsDeleted( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
117 virtual bool ItemsChanged( const wxDataViewItemArray
&items
);
118 virtual bool ValueChanged( const wxDataViewItem
&item
, unsigned int col
) = 0;
119 virtual bool Cleared() = 0;
121 virtual void Resort() = 0;
123 void SetOwner( wxDataViewModel
*owner
) { m_owner
= owner
; }
124 wxDataViewModel
*GetOwner() const { return m_owner
; }
127 wxDataViewModel
*m_owner
;
132 // ----------------------------------------------------------------------------
133 // wxDataViewItemAttr: a structure containing the visual attributes of an item
134 // ----------------------------------------------------------------------------
136 // TODO: this should be renamed to wxItemAttr or something general like this
138 class WXDLLIMPEXP_ADV wxDataViewItemAttr
149 void SetColour(const wxColour
& colour
) { m_colour
= colour
; }
150 void SetBold( bool set
) { m_bold
= set
; }
151 void SetItalic( bool set
) { m_italic
= set
; }
154 bool HasColour() const { return m_colour
.Ok(); }
155 const wxColour
& GetColour() const { return m_colour
; }
157 bool HasFont() const { return m_bold
|| m_italic
; }
158 bool GetBold() const { return m_bold
; }
159 bool GetItalic() const { return m_italic
; }
168 // ---------------------------------------------------------
170 // ---------------------------------------------------------
172 WX_DECLARE_LIST_WITH_DECL(wxDataViewModelNotifier
, wxDataViewModelNotifiers
,
173 class WXDLLIMPEXP_ADV
);
175 class WXDLLIMPEXP_ADV wxDataViewModel
: public wxRefCounter
180 virtual unsigned int GetColumnCount() const = 0;
182 // return type as reported by wxVariant
183 virtual wxString
GetColumnType( unsigned int col
) const = 0;
185 // get value into a wxVariant
186 virtual void GetValue( wxVariant
&variant
,
187 const wxDataViewItem
&item
, unsigned int col
) const = 0;
189 // return true if the given item has a value to display in the given
190 // column: this is always true except for container items which by default
191 // only show their label in the first column (but see HasContainerColumns())
192 bool HasValue(const wxDataViewItem
& item
, unsigned col
) const
194 return col
== 0 || !IsContainer(item
) || HasContainerColumns(item
);
197 // usually ValueChanged() should be called after changing the value in the
198 // model to update the control, ChangeValue() does it on its own while
199 // SetValue() does not -- so while you will override SetValue(), you should
200 // be usually calling ChangeValue()
201 virtual bool SetValue(const wxVariant
&variant
,
202 const wxDataViewItem
&item
,
203 unsigned int col
) = 0;
205 bool ChangeValue(const wxVariant
& variant
,
206 const wxDataViewItem
& item
,
209 return SetValue(variant
, item
, col
) && ValueChanged(item
, col
);
212 // Get text attribute, return false of default attributes should be used
213 virtual bool GetAttr( const wxDataViewItem
&WXUNUSED(item
), unsigned int WXUNUSED(col
), wxDataViewItemAttr
&WXUNUSED(attr
) )
217 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const = 0;
218 virtual bool IsContainer( const wxDataViewItem
&item
) const = 0;
219 // Is the container just a header or an item with all columns
220 virtual bool HasContainerColumns(const wxDataViewItem
& WXUNUSED(item
)) const
222 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const = 0;
224 // delegated notifiers
225 virtual bool ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
226 virtual bool ItemsAdded( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
227 virtual bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
228 virtual bool ItemsDeleted( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
229 virtual bool ItemChanged( const wxDataViewItem
&item
);
230 virtual bool ItemsChanged( const wxDataViewItemArray
&items
);
231 virtual bool ValueChanged( const wxDataViewItem
&item
, unsigned int col
);
232 virtual bool Cleared();
235 virtual void Resort();
237 void AddNotifier( wxDataViewModelNotifier
*notifier
);
238 void RemoveNotifier( wxDataViewModelNotifier
*notifier
);
240 // default compare function
241 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
242 unsigned int column
, bool ascending
) const;
243 virtual bool HasDefaultCompare() const { return false; }
246 virtual bool IsVirtualListModel() const { return false; }
249 // the user should not delete this class directly: he should use DecRef() instead!
250 virtual ~wxDataViewModel() { }
252 wxDataViewModelNotifiers m_notifiers
;
255 // ---------------------------------------------------------
256 // wxDataViewIndexListModel
257 // ---------------------------------------------------------
259 class WXDLLIMPEXP_ADV wxDataViewIndexListModel
: public wxDataViewModel
262 wxDataViewIndexListModel( unsigned int initial_size
= 0 );
263 ~wxDataViewIndexListModel();
265 virtual void GetValueByRow( wxVariant
&variant
,
266 unsigned int row
, unsigned int col
) const = 0;
268 virtual bool SetValueByRow( const wxVariant
&variant
,
269 unsigned int row
, unsigned int col
) = 0;
271 virtual bool GetAttrByRow( unsigned int WXUNUSED(row
), unsigned int WXUNUSED(col
), wxDataViewItemAttr
&WXUNUSED(attr
) )
275 void RowInserted( unsigned int before
);
277 void RowDeleted( unsigned int row
);
278 void RowsDeleted( const wxArrayInt
&rows
);
279 void RowChanged( unsigned int row
);
280 void RowValueChanged( unsigned int row
, unsigned int col
);
281 void Reset( unsigned int new_size
);
283 // convert to/from row/wxDataViewItem
285 unsigned int GetRow( const wxDataViewItem
&item
) const;
286 wxDataViewItem
GetItem( unsigned int row
) const;
288 // compare based on index
290 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
291 unsigned int column
, bool ascending
) const;
292 virtual bool HasDefaultCompare() const;
294 // implement base methods
296 virtual void GetValue( wxVariant
&variant
,
297 const wxDataViewItem
&item
, unsigned int col
) const;
298 virtual bool SetValue( const wxVariant
&variant
,
299 const wxDataViewItem
&item
, unsigned int col
);
300 virtual bool GetAttr( const wxDataViewItem
&item
, unsigned int col
, wxDataViewItemAttr
&attr
);
301 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const;
302 virtual bool IsContainer( const wxDataViewItem
&item
) const;
303 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
306 virtual bool IsVirtualListModel() const { return false; }
307 unsigned int GetCount() const { return m_hash
.GetCount(); }
310 wxDataViewItemArray m_hash
;
311 unsigned int m_nextFreeID
;
315 // ---------------------------------------------------------
316 // wxDataViewVirtualListModel
317 // ---------------------------------------------------------
320 // better than nothing
321 typedef wxDataViewIndexListModel wxDataViewVirtualListModel
;
324 class WXDLLIMPEXP_ADV wxDataViewVirtualListModel
: public wxDataViewModel
327 wxDataViewVirtualListModel( unsigned int initial_size
= 0 );
328 ~wxDataViewVirtualListModel();
330 virtual void GetValueByRow( wxVariant
&variant
,
331 unsigned int row
, unsigned int col
) const = 0;
333 virtual bool SetValueByRow( const wxVariant
&variant
,
334 unsigned int row
, unsigned int col
) = 0;
336 virtual bool GetAttrByRow( unsigned int WXUNUSED(row
), unsigned int WXUNUSED(col
), wxDataViewItemAttr
&WXUNUSED(attr
) )
340 void RowInserted( unsigned int before
);
342 void RowDeleted( unsigned int row
);
343 void RowsDeleted( const wxArrayInt
&rows
);
344 void RowChanged( unsigned int row
);
345 void RowValueChanged( unsigned int row
, unsigned int col
);
346 void Reset( unsigned int new_size
);
348 // convert to/from row/wxDataViewItem
350 unsigned int GetRow( const wxDataViewItem
&item
) const;
351 wxDataViewItem
GetItem( unsigned int row
) const;
353 // compare based on index
355 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
356 unsigned int column
, bool ascending
) const;
357 virtual bool HasDefaultCompare() const;
359 // implement base methods
361 virtual void GetValue( wxVariant
&variant
,
362 const wxDataViewItem
&item
, unsigned int col
) const;
363 virtual bool SetValue( const wxVariant
&variant
,
364 const wxDataViewItem
&item
, unsigned int col
);
365 virtual bool GetAttr( const wxDataViewItem
&item
, unsigned int col
, wxDataViewItemAttr
&attr
);
366 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const;
367 virtual bool IsContainer( const wxDataViewItem
&item
) const;
368 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
371 virtual bool IsVirtualListModel() const { return true; }
372 unsigned int GetCount() const { return m_size
; }
380 //-----------------------------------------------------------------------------
381 // wxDataViewEditorCtrlEvtHandler
382 //-----------------------------------------------------------------------------
384 class wxDataViewEditorCtrlEvtHandler
: public wxEvtHandler
387 wxDataViewEditorCtrlEvtHandler( wxControl
*editor
, wxDataViewRenderer
*owner
);
389 void AcceptChangesAndFinish();
390 void SetFocusOnIdle( bool focus
= true ) { m_focusOnIdle
= focus
; }
393 void OnChar( wxKeyEvent
&event
);
394 void OnTextEnter( wxCommandEvent
&event
);
395 void OnKillFocus( wxFocusEvent
&event
);
396 void OnIdle( wxIdleEvent
&event
);
399 wxDataViewRenderer
*m_owner
;
400 wxControl
*m_editorCtrl
;
405 DECLARE_EVENT_TABLE()
408 // ---------------------------------------------------------
409 // wxDataViewRendererBase
410 // ---------------------------------------------------------
412 enum wxDataViewCellMode
414 wxDATAVIEW_CELL_INERT
,
415 wxDATAVIEW_CELL_ACTIVATABLE
,
416 wxDATAVIEW_CELL_EDITABLE
419 enum wxDataViewCellRenderState
421 wxDATAVIEW_CELL_SELECTED
= 1,
422 wxDATAVIEW_CELL_PRELIT
= 2,
423 wxDATAVIEW_CELL_INSENSITIVE
= 4,
424 wxDATAVIEW_CELL_FOCUSED
= 8
427 class WXDLLIMPEXP_ADV wxDataViewRendererBase
: public wxObject
430 wxDataViewRendererBase( const wxString
&varianttype
,
431 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
432 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
433 virtual ~wxDataViewRendererBase();
435 virtual bool Validate( wxVariant
& WXUNUSED(value
) )
438 void SetOwner( wxDataViewColumn
*owner
) { m_owner
= owner
; }
439 wxDataViewColumn
* GetOwner() const { return m_owner
; }
441 // renderer properties:
443 virtual bool SetValue( const wxVariant
& WXUNUSED(value
) ) = 0;
444 virtual bool GetValue( wxVariant
& WXUNUSED(value
) ) const = 0;
446 wxString
GetVariantType() const { return m_variantType
; }
448 virtual void SetMode( wxDataViewCellMode mode
) = 0;
449 virtual wxDataViewCellMode
GetMode() const = 0;
451 // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but
452 // rather an "int"; that's because for rendering cells it's allowed
453 // to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM)
454 virtual void SetAlignment( int align
) = 0;
455 virtual int GetAlignment() const = 0;
457 // enable or disable (if called with wxELLIPSIZE_NONE) replacing parts of
458 // the item text (hence this only makes sense for renderers showing
459 // text...) with ellipsis in order to make it fit the column width
460 virtual void EnableEllipsize(wxEllipsizeMode mode
= wxELLIPSIZE_MIDDLE
) = 0;
461 void DisableEllipsize() { EnableEllipsize(wxELLIPSIZE_NONE
); }
463 virtual wxEllipsizeMode
GetEllipsizeMode() const = 0;
466 virtual bool HasEditorCtrl() const
468 virtual wxControl
* CreateEditorCtrl(wxWindow
* WXUNUSED(parent
),
469 wxRect
WXUNUSED(labelRect
),
470 const wxVariant
& WXUNUSED(value
))
472 virtual bool GetValueFromEditorCtrl(wxControl
* WXUNUSED(editor
),
473 wxVariant
& WXUNUSED(value
))
476 virtual bool StartEditing( const wxDataViewItem
&item
, wxRect labelRect
);
477 virtual void CancelEditing();
478 virtual bool FinishEditing();
480 wxControl
*GetEditorCtrl() { return m_editorCtrl
; }
483 wxString m_variantType
;
484 wxDataViewColumn
*m_owner
;
485 wxWeakRef
<wxControl
> m_editorCtrl
;
486 wxDataViewItem m_item
; // for m_editorCtrl
489 const wxDataViewCtrl
* GetView() const;
492 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase
)
495 //-----------------------------------------------------------------------------
496 // wxDataViewIconText
497 //-----------------------------------------------------------------------------
499 class WXDLLIMPEXP_ADV wxDataViewIconText
: public wxObject
502 wxDataViewIconText( const wxString
&text
= wxEmptyString
, const wxIcon
& icon
= wxNullIcon
)
503 : m_text(text
), m_icon(icon
)
505 wxDataViewIconText( const wxDataViewIconText
&other
)
507 { m_icon
= other
.m_icon
; m_text
= other
.m_text
; }
509 void SetText( const wxString
&text
) { m_text
= text
; }
510 wxString
GetText() const { return m_text
; }
511 void SetIcon( const wxIcon
&icon
) { m_icon
= icon
; }
512 const wxIcon
&GetIcon() const { return m_icon
; }
519 DECLARE_DYNAMIC_CLASS(wxDataViewIconText
)
523 bool operator==(const wxDataViewIconText
& left
, const wxDataViewIconText
& right
)
525 return left
.GetText() == right
.GetText() &&
526 left
.GetIcon().IsSameAs(right
.GetIcon());
530 bool operator!=(const wxDataViewIconText
& left
, const wxDataViewIconText
& right
)
532 return !(left
== right
);
535 DECLARE_VARIANT_OBJECT_EXPORTED(wxDataViewIconText
, WXDLLIMPEXP_ADV
)
537 // ---------------------------------------------------------
538 // wxDataViewColumnBase
539 // ---------------------------------------------------------
541 // for compatibility only, do not use
542 enum wxDataViewColumnFlags
544 wxDATAVIEW_COL_RESIZABLE
= wxCOL_RESIZABLE
,
545 wxDATAVIEW_COL_SORTABLE
= wxCOL_SORTABLE
,
546 wxDATAVIEW_COL_REORDERABLE
= wxCOL_REORDERABLE
,
547 wxDATAVIEW_COL_HIDDEN
= wxCOL_HIDDEN
550 class WXDLLIMPEXP_ADV wxDataViewColumnBase
: public wxSettableHeaderColumn
553 // ctor for the text columns: takes ownership of renderer
554 wxDataViewColumnBase(wxDataViewRenderer
*renderer
,
555 unsigned int model_column
)
557 Init(renderer
, model_column
);
560 // ctor for the bitmap columns
561 wxDataViewColumnBase(const wxBitmap
& bitmap
,
562 wxDataViewRenderer
*renderer
,
563 unsigned int model_column
)
566 Init(renderer
, model_column
);
569 virtual ~wxDataViewColumnBase();
572 virtual void SetOwner( wxDataViewCtrl
*owner
)
576 unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column
); }
577 wxDataViewCtrl
*GetOwner() const { return m_owner
; }
578 wxDataViewRenderer
* GetRenderer() const { return m_renderer
; }
580 // implement some of base class pure virtuals (the rest is port-dependent
581 // and done differently in generic and native versions)
582 virtual void SetBitmap( const wxBitmap
& bitmap
) { m_bitmap
= bitmap
; }
583 virtual wxBitmap
GetBitmap() const { return m_bitmap
; }
586 wxDataViewRenderer
*m_renderer
;
589 wxDataViewCtrl
*m_owner
;
592 // common part of all ctors
593 void Init(wxDataViewRenderer
*renderer
, unsigned int model_column
);
596 // ---------------------------------------------------------
597 // wxDataViewCtrlBase
598 // ---------------------------------------------------------
600 #define wxDV_SINGLE 0x0000 // for convenience
601 #define wxDV_MULTIPLE 0x0001 // can select multiple items
603 #define wxDV_NO_HEADER 0x0002 // column titles not visible
604 #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows
605 #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns
607 #define wxDV_ROW_LINES 0x0010 // alternating colour in rows
608 #define wxDV_VARIABLE_LINE_HEIGHT 0x0020 // variable line height
610 class WXDLLIMPEXP_ADV wxDataViewCtrlBase
: public wxControl
613 wxDataViewCtrlBase();
614 virtual ~wxDataViewCtrlBase();
619 virtual bool AssociateModel( wxDataViewModel
*model
);
620 wxDataViewModel
* GetModel();
621 const wxDataViewModel
* GetModel() const;
627 wxDataViewColumn
*PrependTextColumn( const wxString
&label
, unsigned int model_column
,
628 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
629 wxAlignment align
= wxALIGN_NOT
,
630 int flags
= wxDATAVIEW_COL_RESIZABLE
);
631 wxDataViewColumn
*PrependIconTextColumn( const wxString
&label
, unsigned int model_column
,
632 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
633 wxAlignment align
= wxALIGN_NOT
,
634 int flags
= wxDATAVIEW_COL_RESIZABLE
);
635 wxDataViewColumn
*PrependToggleColumn( const wxString
&label
, unsigned int model_column
,
636 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
637 wxAlignment align
= wxALIGN_CENTER
,
638 int flags
= wxDATAVIEW_COL_RESIZABLE
);
639 wxDataViewColumn
*PrependProgressColumn( const wxString
&label
, unsigned int model_column
,
640 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
641 wxAlignment align
= wxALIGN_CENTER
,
642 int flags
= wxDATAVIEW_COL_RESIZABLE
);
643 wxDataViewColumn
*PrependDateColumn( const wxString
&label
, unsigned int model_column
,
644 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
645 wxAlignment align
= wxALIGN_NOT
,
646 int flags
= wxDATAVIEW_COL_RESIZABLE
);
647 wxDataViewColumn
*PrependBitmapColumn( const wxString
&label
, unsigned int model_column
,
648 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
649 wxAlignment align
= wxALIGN_CENTER
,
650 int flags
= wxDATAVIEW_COL_RESIZABLE
);
651 wxDataViewColumn
*PrependTextColumn( const wxBitmap
&label
, unsigned int model_column
,
652 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
653 wxAlignment align
= wxALIGN_NOT
,
654 int flags
= wxDATAVIEW_COL_RESIZABLE
);
655 wxDataViewColumn
*PrependIconTextColumn( const wxBitmap
&label
, unsigned int model_column
,
656 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
657 wxAlignment align
= wxALIGN_NOT
,
658 int flags
= wxDATAVIEW_COL_RESIZABLE
);
659 wxDataViewColumn
*PrependToggleColumn( const wxBitmap
&label
, unsigned int model_column
,
660 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
661 wxAlignment align
= wxALIGN_CENTER
,
662 int flags
= wxDATAVIEW_COL_RESIZABLE
);
663 wxDataViewColumn
*PrependProgressColumn( const wxBitmap
&label
, unsigned int model_column
,
664 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
665 wxAlignment align
= wxALIGN_CENTER
,
666 int flags
= wxDATAVIEW_COL_RESIZABLE
);
667 wxDataViewColumn
*PrependDateColumn( const wxBitmap
&label
, unsigned int model_column
,
668 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
669 wxAlignment align
= wxALIGN_NOT
,
670 int flags
= wxDATAVIEW_COL_RESIZABLE
);
671 wxDataViewColumn
*PrependBitmapColumn( const wxBitmap
&label
, unsigned int model_column
,
672 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
673 wxAlignment align
= wxALIGN_CENTER
,
674 int flags
= wxDATAVIEW_COL_RESIZABLE
);
676 wxDataViewColumn
*AppendTextColumn( const wxString
&label
, unsigned int model_column
,
677 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
678 wxAlignment align
= wxALIGN_NOT
,
679 int flags
= wxDATAVIEW_COL_RESIZABLE
);
680 wxDataViewColumn
*AppendIconTextColumn( const wxString
&label
, unsigned int model_column
,
681 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
682 wxAlignment align
= wxALIGN_NOT
,
683 int flags
= wxDATAVIEW_COL_RESIZABLE
);
684 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
, unsigned int model_column
,
685 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
686 wxAlignment align
= wxALIGN_CENTER
,
687 int flags
= wxDATAVIEW_COL_RESIZABLE
);
688 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
, unsigned int model_column
,
689 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
690 wxAlignment align
= wxALIGN_CENTER
,
691 int flags
= wxDATAVIEW_COL_RESIZABLE
);
692 wxDataViewColumn
*AppendDateColumn( const wxString
&label
, unsigned int model_column
,
693 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
694 wxAlignment align
= wxALIGN_NOT
,
695 int flags
= wxDATAVIEW_COL_RESIZABLE
);
696 wxDataViewColumn
*AppendBitmapColumn( const wxString
&label
, unsigned int model_column
,
697 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
698 wxAlignment align
= wxALIGN_CENTER
,
699 int flags
= wxDATAVIEW_COL_RESIZABLE
);
700 wxDataViewColumn
*AppendTextColumn( const wxBitmap
&label
, unsigned int model_column
,
701 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
702 wxAlignment align
= wxALIGN_NOT
,
703 int flags
= wxDATAVIEW_COL_RESIZABLE
);
704 wxDataViewColumn
*AppendIconTextColumn( const wxBitmap
&label
, unsigned int model_column
,
705 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
706 wxAlignment align
= wxALIGN_NOT
,
707 int flags
= wxDATAVIEW_COL_RESIZABLE
);
708 wxDataViewColumn
*AppendToggleColumn( const wxBitmap
&label
, unsigned int model_column
,
709 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
710 wxAlignment align
= wxALIGN_CENTER
,
711 int flags
= wxDATAVIEW_COL_RESIZABLE
);
712 wxDataViewColumn
*AppendProgressColumn( const wxBitmap
&label
, unsigned int model_column
,
713 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
714 wxAlignment align
= wxALIGN_CENTER
,
715 int flags
= wxDATAVIEW_COL_RESIZABLE
);
716 wxDataViewColumn
*AppendDateColumn( const wxBitmap
&label
, unsigned int model_column
,
717 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
718 wxAlignment align
= wxALIGN_NOT
,
719 int flags
= wxDATAVIEW_COL_RESIZABLE
);
720 wxDataViewColumn
*AppendBitmapColumn( const wxBitmap
&label
, unsigned int model_column
,
721 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
722 wxAlignment align
= wxALIGN_CENTER
,
723 int flags
= wxDATAVIEW_COL_RESIZABLE
);
725 virtual bool PrependColumn( wxDataViewColumn
*col
);
726 virtual bool InsertColumn( unsigned int pos
, wxDataViewColumn
*col
);
727 virtual bool AppendColumn( wxDataViewColumn
*col
);
729 virtual unsigned int GetColumnCount() const = 0;
730 virtual wxDataViewColumn
* GetColumn( unsigned int pos
) const = 0;
731 virtual int GetColumnPosition( const wxDataViewColumn
*column
) const = 0;
733 virtual bool DeleteColumn( wxDataViewColumn
*column
) = 0;
734 virtual bool ClearColumns() = 0;
736 void SetExpanderColumn( wxDataViewColumn
*col
)
737 { m_expander_column
= col
; DoSetExpanderColumn(); }
738 wxDataViewColumn
*GetExpanderColumn() const
739 { return m_expander_column
; }
741 virtual wxDataViewColumn
*GetSortingColumn() const = 0;
747 void SetIndent( int indent
)
748 { m_indent
= indent
; DoSetIndent(); }
749 int GetIndent() const
752 virtual wxDataViewItem
GetSelection() const = 0;
753 virtual int GetSelections( wxDataViewItemArray
& sel
) const = 0;
754 virtual void SetSelections( const wxDataViewItemArray
& sel
) = 0;
755 virtual void Select( const wxDataViewItem
& item
) = 0;
756 virtual void Unselect( const wxDataViewItem
& item
) = 0;
757 virtual bool IsSelected( const wxDataViewItem
& item
) const = 0;
759 virtual void SelectAll() = 0;
760 virtual void UnselectAll() = 0;
762 virtual void Expand( const wxDataViewItem
& item
) = 0;
763 virtual void ExpandAncestors( const wxDataViewItem
& item
);
764 virtual void Collapse( const wxDataViewItem
& item
) = 0;
765 virtual bool IsExpanded( const wxDataViewItem
& item
) const = 0;
767 virtual void EnsureVisible( const wxDataViewItem
& item
,
768 const wxDataViewColumn
*column
= NULL
) = 0;
769 virtual void HitTest( const wxPoint
& point
, wxDataViewItem
&item
, wxDataViewColumn
* &column
) const = 0;
770 virtual wxRect
GetItemRect( const wxDataViewItem
& item
, const wxDataViewColumn
*column
= NULL
) const = 0;
772 #if wxUSE_DRAG_AND_DROP
773 virtual bool EnableDragSource(const wxDataFormat
& WXUNUSED(format
))
775 virtual bool EnableDropTarget(const wxDataFormat
& WXUNUSED(format
))
777 #endif // wxUSE_DRAG_AND_DROP
779 // define control visual attributes
780 // --------------------------------
782 virtual wxVisualAttributes
GetDefaultAttributes() const
784 return GetClassDefaultAttributes(GetWindowVariant());
787 static wxVisualAttributes
788 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
)
790 return wxControl
::GetCompositeControlsDefaultAttributes(variant
);
794 virtual void DoSetExpanderColumn() = 0 ;
795 virtual void DoSetIndent() = 0;
798 wxDataViewModel
*m_model
;
799 wxDataViewColumn
*m_expander_column
;
803 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase
)
806 // ----------------------------------------------------------------------------
807 // wxDataViewEvent - the event class for the wxDataViewCtrl notifications
808 // ----------------------------------------------------------------------------
810 class WXDLLIMPEXP_ADV wxDataViewEvent
: public wxNotifyEvent
813 wxDataViewEvent(wxEventType commandType
= wxEVT_NULL
, int winid
= 0)
814 : wxNotifyEvent(commandType
, winid
),
818 m_value(wxNullVariant
),
823 #if wxUSE_DRAG_AND_DROP
824 , m_dataObject(NULL
),
830 wxDataViewEvent(const wxDataViewEvent
& event
)
831 : wxNotifyEvent(event
),
832 m_item(event
.m_item
),
834 m_model(event
.m_model
),
835 m_value(event
.m_value
),
836 m_column(event
.m_column
),
838 m_cacheFrom(event
.m_cacheFrom
),
839 m_cacheTo(event
.m_cacheTo
)
840 #if wxUSE_DRAG_AND_DROP
841 , m_dataObject(event
.m_dataObject
),
842 m_dataFormat(event
.m_dataFormat
),
843 m_dataBuffer(event
.m_dataBuffer
),
844 m_dataSize(event
.m_dataSize
)
848 wxDataViewItem
GetItem() const { return m_item
; }
849 void SetItem( const wxDataViewItem
&item
) { m_item
= item
; }
851 int GetColumn() const { return m_col
; }
852 void SetColumn( int col
) { m_col
= col
; }
854 wxDataViewModel
* GetModel() const { return m_model
; }
855 void SetModel( wxDataViewModel
*model
) { m_model
= model
; }
857 const wxVariant
&GetValue() const { return m_value
; }
858 void SetValue( const wxVariant
&value
) { m_value
= value
; }
860 // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only
861 void SetDataViewColumn( wxDataViewColumn
*col
) { m_column
= col
; }
862 wxDataViewColumn
*GetDataViewColumn() const { return m_column
; }
864 // for wxEVT_DATAVIEW_CONTEXT_MENU only
865 wxPoint
GetPosition() const { return m_pos
; }
866 void SetPosition( int x
, int y
) { m_pos
.x
= x
; m_pos
.y
= y
; }
868 // For wxEVT_COMMAND_DATAVIEW_CACHE_HINT
869 int GetCacheFrom() const { return m_cacheFrom
; }
870 int GetCacheTo() const { return m_cacheTo
; }
871 void SetCache(int from
, int to
) { m_cacheFrom
= from
; m_cacheTo
= to
; }
874 #if wxUSE_DRAG_AND_DROP
875 // For drag operations
876 void SetDataObject( wxDataObject
*obj
) { m_dataObject
= obj
; }
877 wxDataObject
*GetDataObject() const { return m_dataObject
; }
879 // For drop operations
880 void SetDataFormat( const wxDataFormat
&format
) { m_dataFormat
= format
; }
881 wxDataFormat
GetDataFormat() const { return m_dataFormat
; }
882 void SetDataSize( size_t size
) { m_dataSize
= size
; }
883 size_t GetDataSize() const { return m_dataSize
; }
884 void SetDataBuffer( void* buf
) { m_dataBuffer
= buf
;}
885 void *GetDataBuffer() const { return m_dataBuffer
; }
886 #endif // wxUSE_DRAG_AND_DROP
888 virtual wxEvent
*Clone() const { return new wxDataViewEvent(*this); }
891 wxDataViewItem m_item
;
893 wxDataViewModel
*m_model
;
895 wxDataViewColumn
*m_column
;
900 #if wxUSE_DRAG_AND_DROP
901 wxDataObject
*m_dataObject
;
903 wxDataFormat m_dataFormat
;
906 #endif // wxUSE_DRAG_AND_DROP
909 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent
)
912 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED
, wxDataViewEvent
);
914 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED
, wxDataViewEvent
);
915 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED
, wxDataViewEvent
);
916 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED
, wxDataViewEvent
);
917 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING
, wxDataViewEvent
);
918 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING
, wxDataViewEvent
);
919 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING
, wxDataViewEvent
);
920 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED
, wxDataViewEvent
);
921 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE
, wxDataViewEvent
);
922 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED
, wxDataViewEvent
);
924 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU
, wxDataViewEvent
);
926 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK
, wxDataViewEvent
);
927 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK
, wxDataViewEvent
);
928 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED
, wxDataViewEvent
);
929 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED
, wxDataViewEvent
);
931 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_CACHE_HINT
, wxDataViewEvent
);
933 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG
, wxDataViewEvent
);
934 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE
, wxDataViewEvent
);
935 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_DROP
, wxDataViewEvent
);
937 typedef void (wxEvtHandler
::*wxDataViewEventFunction
)(wxDataViewEvent
&);
939 #define wxDataViewEventHandler(func) \
940 wxEVENT_HANDLER_CAST(wxDataViewEventFunction, func)
942 #define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \
943 wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn))
945 #define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn)
947 #define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn)
948 #define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn)
949 #define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn)
950 #define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn)
951 #define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn)
952 #define EVT_DATAVIEW_ITEM_START_EDITING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_START_EDITING, id, fn)
953 #define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn)
954 #define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn)
955 #define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn)
957 #define EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_CONTEXT_MENU, id, fn)
959 #define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn)
960 #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn)
961 #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn)
962 #define EVT_DATAVIEW_COLUMN_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_REORDERED, id, fn)
963 #define EVT_DATAVIEW_CACHE_HINT(id, fn) wx__DECLARE_DATAVIEWEVT(CACHE_HINT, id, fn)
965 #define EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_BEGIN_DRAG, id, fn)
966 #define EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP_POSSIBLE, id, fn)
967 #define EVT_DATAVIEW_ITEM_DROP(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP, id, fn)
969 #ifdef wxHAS_GENERIC_DATAVIEWCTRL
970 // this symbol doesn't follow the convention for wxUSE_XXX symbols which
971 // are normally always defined as either 0 or 1, so its use is deprecated
972 // and it only exists for backwards compatibility, don't use it any more
973 // and use wxHAS_GENERIC_DATAVIEWCTRL instead
974 #define wxUSE_GENERICDATAVIEWCTRL
976 #include "wx/generic/dataview.h"
977 #elif defined(__WXGTK20__)
978 #include "wx/gtk/dataview.h"
979 #elif defined(__WXMAC__)
980 #include "wx/osx/dataview.h"
982 #error "unknown native wxDataViewCtrl implementation"
985 // -------------------------------------
986 // wxDataViewSpinRenderer
987 // -------------------------------------
989 class WXDLLIMPEXP_ADV wxDataViewSpinRenderer
: public wxDataViewCustomRenderer
992 wxDataViewSpinRenderer( int min
, int max
,
993 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
994 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
995 virtual bool HasEditorCtrl() const { return true; }
996 virtual wxControl
* CreateEditorCtrl( wxWindow
*parent
, wxRect labelRect
, const wxVariant
&value
);
997 virtual bool GetValueFromEditorCtrl( wxControl
* editor
, wxVariant
&value
);
998 virtual bool Render( wxRect rect
, wxDC
*dc
, int state
);
999 virtual wxSize
GetSize() const;
1000 virtual bool SetValue( const wxVariant
&value
);
1001 virtual bool GetValue( wxVariant
&value
) const;
1008 #if defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXOSX_CARBON__)
1010 // -------------------------------------
1011 // wxDataViewChoiceRenderer
1012 // -------------------------------------
1014 class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer
: public wxDataViewCustomRenderer
1017 wxDataViewChoiceRenderer( const wxArrayString
&choices
,
1018 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
1019 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
1020 virtual bool HasEditorCtrl() const { return true; }
1021 virtual wxControl
* CreateEditorCtrl( wxWindow
*parent
, wxRect labelRect
, const wxVariant
&value
);
1022 virtual bool GetValueFromEditorCtrl( wxControl
* editor
, wxVariant
&value
);
1023 virtual bool Render( wxRect rect
, wxDC
*dc
, int state
);
1024 virtual wxSize
GetSize() const;
1025 virtual bool SetValue( const wxVariant
&value
);
1026 virtual bool GetValue( wxVariant
&value
) const;
1029 wxArrayString m_choices
;
1035 // this class is obsolete, its functionality was merged in
1036 // wxDataViewTextRenderer itself now, don't use it any more
1037 #define wxDataViewTextRendererAttr wxDataViewTextRenderer
1039 //-----------------------------------------------------------------------------
1040 // wxDataViewListStore
1041 //-----------------------------------------------------------------------------
1043 class WXDLLIMPEXP_ADV wxDataViewListStoreLine
1046 wxDataViewListStoreLine( wxClientData
*data
= NULL
)
1050 virtual ~wxDataViewListStoreLine()
1055 void SetData( wxClientData
*data
)
1056 { if (m_data
) delete m_data
; m_data
= data
; }
1057 wxClientData
*GetData() const
1060 wxVector
<wxVariant
> m_values
;
1063 wxClientData
*m_data
;
1067 class WXDLLIMPEXP_ADV wxDataViewListStore
: public wxDataViewIndexListModel
1070 wxDataViewListStore();
1071 ~wxDataViewListStore();
1073 void PrependColumn( const wxString
&varianttype
);
1074 void InsertColumn( unsigned int pos
, const wxString
&varianttype
);
1075 void AppendColumn( const wxString
&varianttype
);
1077 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1078 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1079 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1080 void DeleteItem( unsigned int pos
);
1081 void DeleteAllItems();
1083 // override base virtuals
1085 virtual unsigned int GetColumnCount() const;
1087 virtual wxString
GetColumnType( unsigned int col
) const;
1089 virtual void GetValueByRow( wxVariant
&value
,
1090 unsigned int row
, unsigned int col
) const;
1092 virtual bool SetValueByRow( const wxVariant
&value
,
1093 unsigned int row
, unsigned int col
);
1097 wxVector
<wxDataViewListStoreLine
*> m_data
;
1098 wxArrayString m_cols
;
1101 //-----------------------------------------------------------------------------
1103 class WXDLLIMPEXP_ADV wxDataViewListCtrl
: public wxDataViewCtrl
1106 wxDataViewListCtrl();
1107 wxDataViewListCtrl( wxWindow
*parent
, wxWindowID id
,
1108 const wxPoint
& pos
= wxDefaultPosition
,
1109 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
1110 const wxValidator
& validator
= wxDefaultValidator
);
1111 ~wxDataViewListCtrl();
1113 bool Create( wxWindow
*parent
, wxWindowID id
,
1114 const wxPoint
& pos
= wxDefaultPosition
,
1115 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
1116 const wxValidator
& validator
= wxDefaultValidator
);
1118 wxDataViewListStore
*GetStore()
1119 { return (wxDataViewListStore
*) GetModel(); }
1120 const wxDataViewListStore
*GetStore() const
1121 { return (const wxDataViewListStore
*) GetModel(); }
1123 bool AppendColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
1124 bool PrependColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
1125 bool InsertColumn( unsigned int pos
, wxDataViewColumn
*column
, const wxString
&varianttype
);
1127 // overridden from base class
1128 virtual bool PrependColumn( wxDataViewColumn
*col
);
1129 virtual bool InsertColumn( unsigned int pos
, wxDataViewColumn
*col
);
1130 virtual bool AppendColumn( wxDataViewColumn
*col
);
1132 wxDataViewColumn
*AppendTextColumn( const wxString
&label
,
1133 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1134 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1135 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
,
1136 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
1137 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1138 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
,
1139 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1140 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1141 wxDataViewColumn
*AppendIconTextColumn( const wxString
&label
,
1142 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1143 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1145 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1146 { GetStore()->AppendItem( values
, data
); }
1147 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1148 { GetStore()->PrependItem( values
, data
); }
1149 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1150 { GetStore()->InsertItem( row
, values
, data
); }
1151 void DeleteItem( unsigned row
)
1152 { GetStore()->DeleteItem( row
); }
1153 void DeleteAllItems()
1154 { GetStore()->DeleteAllItems(); }
1156 void SetValue( const wxVariant
&value
, unsigned int row
, unsigned int col
)
1157 { GetStore()->SetValueByRow( value
, row
, col
);
1158 GetStore()->RowValueChanged( row
, col
); }
1159 void GetValue( wxVariant
&value
, unsigned int row
, unsigned int col
)
1160 { GetStore()->GetValueByRow( value
, row
, col
); }
1162 void SetTextValue( const wxString
&value
, unsigned int row
, unsigned int col
)
1163 { GetStore()->SetValueByRow( value
, row
, col
);
1164 GetStore()->RowValueChanged( row
, col
); }
1165 wxString
GetTextValue( unsigned int row
, unsigned int col
) const
1166 { wxVariant value
; GetStore()->GetValueByRow( value
, row
, col
); return value
.GetString(); }
1168 void SetToggleValue( bool value
, unsigned int row
, unsigned int col
)
1169 { GetStore()->SetValueByRow( value
, row
, col
);
1170 GetStore()->RowValueChanged( row
, col
); }
1171 bool GetToggleValue( unsigned int row
, unsigned int col
) const
1172 { wxVariant value
; GetStore()->GetValueByRow( value
, row
, col
); return value
.GetBool(); }
1174 void OnSize( wxSizeEvent
&event
);
1177 DECLARE_EVENT_TABLE()
1178 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewListCtrl
)
1181 //-----------------------------------------------------------------------------
1182 // wxDataViewTreeStore
1183 //-----------------------------------------------------------------------------
1185 class WXDLLIMPEXP_ADV wxDataViewTreeStoreNode
1188 wxDataViewTreeStoreNode( wxDataViewTreeStoreNode
*parent
,
1189 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1190 virtual ~wxDataViewTreeStoreNode();
1192 void SetText( const wxString
&text
)
1194 wxString
GetText() const
1196 void SetIcon( const wxIcon
&icon
)
1198 const wxIcon
&GetIcon() const
1200 void SetData( wxClientData
*data
)
1201 { if (m_data
) delete m_data
; m_data
= data
; }
1202 wxClientData
*GetData() const
1205 wxDataViewItem
GetItem() const
1206 { return wxDataViewItem( (void*) this ); }
1208 virtual bool IsContainer()
1211 wxDataViewTreeStoreNode
*GetParent()
1212 { return m_parent
; }
1215 wxDataViewTreeStoreNode
*m_parent
;
1218 wxClientData
*m_data
;
1221 WX_DECLARE_LIST_WITH_DECL(wxDataViewTreeStoreNode
, wxDataViewTreeStoreNodeList
,
1222 class WXDLLIMPEXP_ADV
);
1224 class WXDLLIMPEXP_ADV wxDataViewTreeStoreContainerNode
: public wxDataViewTreeStoreNode
1227 wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode
*parent
,
1228 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1229 wxClientData
*data
= NULL
);
1230 virtual ~wxDataViewTreeStoreContainerNode();
1232 const wxDataViewTreeStoreNodeList
&GetChildren() const
1233 { return m_children
; }
1234 wxDataViewTreeStoreNodeList
&GetChildren()
1235 { return m_children
; }
1237 void SetExpandedIcon( const wxIcon
&icon
)
1238 { m_iconExpanded
= icon
; }
1239 const wxIcon
&GetExpandedIcon() const
1240 { return m_iconExpanded
; }
1242 void SetExpanded( bool expanded
= true )
1243 { m_isExpanded
= expanded
; }
1244 bool IsExpanded() const
1245 { return m_isExpanded
; }
1247 virtual bool IsContainer()
1251 wxDataViewTreeStoreNodeList m_children
;
1252 wxIcon m_iconExpanded
;
1256 //-----------------------------------------------------------------------------
1258 class WXDLLIMPEXP_ADV wxDataViewTreeStore
: public wxDataViewModel
1261 wxDataViewTreeStore();
1262 ~wxDataViewTreeStore();
1264 wxDataViewItem
AppendItem( const wxDataViewItem
& parent
,
1265 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1266 wxDataViewItem
PrependItem( const wxDataViewItem
& parent
,
1267 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1268 wxDataViewItem
InsertItem( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1269 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1271 wxDataViewItem
PrependContainer( const wxDataViewItem
& parent
,
1272 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1273 wxClientData
*data
= NULL
);
1274 wxDataViewItem
AppendContainer( const wxDataViewItem
& parent
,
1275 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1276 wxClientData
*data
= NULL
);
1277 wxDataViewItem
InsertContainer( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1278 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1279 wxClientData
*data
= NULL
);
1281 wxDataViewItem
GetNthChild( const wxDataViewItem
& parent
, unsigned int pos
) const;
1282 int GetChildCount( const wxDataViewItem
& parent
) const;
1284 void SetItemText( const wxDataViewItem
& item
, const wxString
&text
);
1285 wxString
GetItemText( const wxDataViewItem
& item
) const;
1286 void SetItemIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1287 const wxIcon
&GetItemIcon( const wxDataViewItem
& item
) const;
1288 void SetItemExpandedIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1289 const wxIcon
&GetItemExpandedIcon( const wxDataViewItem
& item
) const;
1290 void SetItemData( const wxDataViewItem
& item
, wxClientData
*data
);
1291 wxClientData
*GetItemData( const wxDataViewItem
& item
) const;
1293 void DeleteItem( const wxDataViewItem
& item
);
1294 void DeleteChildren( const wxDataViewItem
& item
);
1295 void DeleteAllItems();
1297 // implement base methods
1299 virtual void GetValue( wxVariant
&variant
,
1300 const wxDataViewItem
&item
, unsigned int col
) const;
1301 virtual bool SetValue( const wxVariant
&variant
,
1302 const wxDataViewItem
&item
, unsigned int col
);
1303 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const;
1304 virtual bool IsContainer( const wxDataViewItem
&item
) const;
1305 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
1307 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
1308 unsigned int column
, bool ascending
) const;
1310 virtual bool HasDefaultCompare() const
1312 virtual unsigned int GetColumnCount() const
1314 virtual wxString
GetColumnType( unsigned int WXUNUSED(col
) ) const
1315 { return wxT("wxDataViewIconText"); }
1317 wxDataViewTreeStoreNode
*FindNode( const wxDataViewItem
&item
) const;
1318 wxDataViewTreeStoreContainerNode
*FindContainerNode( const wxDataViewItem
&item
) const;
1319 wxDataViewTreeStoreNode
*GetRoot() const { return m_root
; }
1322 wxDataViewTreeStoreNode
*m_root
;
1325 //-----------------------------------------------------------------------------
1327 class WXDLLIMPEXP_ADV wxDataViewTreeCtrl
: public wxDataViewCtrl
1330 wxDataViewTreeCtrl();
1331 wxDataViewTreeCtrl( wxWindow
*parent
, wxWindowID id
,
1332 const wxPoint
& pos
= wxDefaultPosition
,
1333 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
1334 const wxValidator
& validator
= wxDefaultValidator
);
1335 ~wxDataViewTreeCtrl();
1337 bool Create( wxWindow
*parent
, wxWindowID id
,
1338 const wxPoint
& pos
= wxDefaultPosition
,
1339 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
1340 const wxValidator
& validator
= wxDefaultValidator
);
1342 wxDataViewTreeStore
*GetStore()
1343 { return (wxDataViewTreeStore
*) GetModel(); }
1344 const wxDataViewTreeStore
*GetStore() const
1345 { return (const wxDataViewTreeStore
*) GetModel(); }
1347 void SetImageList( wxImageList
*imagelist
);
1348 wxImageList
* GetImageList() { return m_imageList
; }
1350 wxDataViewItem
AppendItem( const wxDataViewItem
& parent
,
1351 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1352 wxDataViewItem
PrependItem( const wxDataViewItem
& parent
,
1353 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1354 wxDataViewItem
InsertItem( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1355 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1357 wxDataViewItem
PrependContainer( const wxDataViewItem
& parent
,
1358 const wxString
&text
, int icon
= -1, int expanded
= -1,
1359 wxClientData
*data
= NULL
);
1360 wxDataViewItem
AppendContainer( const wxDataViewItem
& parent
,
1361 const wxString
&text
, int icon
= -1, int expanded
= -1,
1362 wxClientData
*data
= NULL
);
1363 wxDataViewItem
InsertContainer( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1364 const wxString
&text
, int icon
= -1, int expanded
= -1,
1365 wxClientData
*data
= NULL
);
1367 wxDataViewItem
GetNthChild( const wxDataViewItem
& parent
, unsigned int pos
) const
1368 { return GetStore()->GetNthChild(parent
, pos
); }
1369 int GetChildCount( const wxDataViewItem
& parent
) const
1370 { return GetStore()->GetChildCount(parent
); }
1372 void SetItemText( const wxDataViewItem
& item
, const wxString
&text
);
1373 wxString
GetItemText( const wxDataViewItem
& item
) const
1374 { return GetStore()->GetItemText(item
); }
1375 void SetItemIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1376 const wxIcon
&GetItemIcon( const wxDataViewItem
& item
) const
1377 { return GetStore()->GetItemIcon(item
); }
1378 void SetItemExpandedIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1379 const wxIcon
&GetItemExpandedIcon( const wxDataViewItem
& item
) const
1380 { return GetStore()->GetItemExpandedIcon(item
); }
1381 void SetItemData( const wxDataViewItem
& item
, wxClientData
*data
)
1382 { GetStore()->SetItemData(item
,data
); }
1383 wxClientData
*GetItemData( const wxDataViewItem
& item
) const
1384 { return GetStore()->GetItemData(item
); }
1386 void DeleteItem( const wxDataViewItem
& item
);
1387 void DeleteChildren( const wxDataViewItem
& item
);
1388 void DeleteAllItems();
1390 void OnExpanded( wxDataViewEvent
&event
);
1391 void OnCollapsed( wxDataViewEvent
&event
);
1392 void OnSize( wxSizeEvent
&event
);
1395 wxImageList
*m_imageList
;
1398 DECLARE_EVENT_TABLE()
1399 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl
)
1402 #endif // wxUSE_DATAVIEWCTRL
1405 // _WX_DATAVIEW_H_BASE_