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/control.h"
20 #include "wx/textctrl.h"
21 #include "wx/headercol.h"
22 #include "wx/variant.h"
23 #include "wx/dynarray.h"
25 #include "wx/imaglist.h"
26 #include "wx/weakref.h"
27 #include "wx/vector.h"
29 #if !(defined(__WXGTK20__) || defined(__WXMAC__)) || defined(__WXUNIVERSAL__)
30 // #if !(defined(__WXMAC__)) || defined(__WXUNIVERSAL__)
31 #define wxHAS_GENERIC_DATAVIEWCTRL
34 class WXDLLIMPEXP_FWD_CORE wxDataFormat
;
36 // ----------------------------------------------------------------------------
37 // wxDataViewCtrl flags
38 // ----------------------------------------------------------------------------
40 // ----------------------------------------------------------------------------
41 // wxDataViewCtrl globals
42 // ----------------------------------------------------------------------------
44 class WXDLLIMPEXP_FWD_ADV wxDataViewItem
;
45 class WXDLLIMPEXP_FWD_ADV wxDataViewModel
;
46 class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl
;
47 class WXDLLIMPEXP_FWD_ADV wxDataViewColumn
;
48 class WXDLLIMPEXP_FWD_ADV wxDataViewRenderer
;
49 class WXDLLIMPEXP_FWD_ADV wxDataViewModelNotifier
;
51 extern WXDLLIMPEXP_DATA_ADV(const char) wxDataViewCtrlNameStr
[];
53 // the default width of new (text) columns:
54 #define wxDVC_DEFAULT_WIDTH 80
56 // the default width of new toggle columns:
57 #define wxDVC_TOGGLE_DEFAULT_WIDTH 30
59 // the default minimal width of the columns:
60 #define wxDVC_DEFAULT_MINWIDTH 30
62 // The default alignment of wxDataViewRenderers is to take
63 // the alignment from the column it owns.
64 #define wxDVR_DEFAULT_ALIGNMENT -1
67 // ---------------------------------------------------------
69 // ---------------------------------------------------------
71 class WXDLLIMPEXP_ADV wxDataViewItem
74 wxDataViewItem( void* id
= NULL
)
76 wxDataViewItem( const wxDataViewItem
&item
)
78 bool IsOk() const { return m_id
!= NULL
; }
79 void* GetID() const { return m_id
; }
80 operator const void* () const { return m_id
; }
83 void Print( const wxString
&text
) const;
90 bool operator == (const wxDataViewItem
&left
, const wxDataViewItem
&right
);
92 WX_DEFINE_ARRAY(wxDataViewItem
, wxDataViewItemArray
);
94 // ---------------------------------------------------------
95 // wxDataViewModelNotifier
96 // ---------------------------------------------------------
98 class WXDLLIMPEXP_ADV wxDataViewModelNotifier
101 wxDataViewModelNotifier() { m_owner
= NULL
; }
102 virtual ~wxDataViewModelNotifier() { m_owner
= NULL
; }
104 virtual bool ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
) = 0;
105 virtual bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
) = 0;
106 virtual bool ItemChanged( const wxDataViewItem
&item
) = 0;
107 virtual bool ItemsAdded( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
108 virtual bool ItemsDeleted( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
109 virtual bool ItemsChanged( const wxDataViewItemArray
&items
);
110 virtual bool ValueChanged( const wxDataViewItem
&item
, unsigned int col
) = 0;
111 virtual bool Cleared() = 0;
113 virtual void Resort() = 0;
115 void SetOwner( wxDataViewModel
*owner
) { m_owner
= owner
; }
116 wxDataViewModel
*GetOwner() const { return m_owner
; }
119 wxDataViewModel
*m_owner
;
124 // ----------------------------------------------------------------------------
125 // wxDataViewItemAttr: a structure containing the visual attributes of an item
126 // ----------------------------------------------------------------------------
128 // TODO: this should be renamed to wxItemAttr or something general like this
130 class WXDLLIMPEXP_ADV wxDataViewItemAttr
141 void SetColour(const wxColour
& colour
) { m_colour
= colour
; }
142 void SetBold( bool set
) { m_bold
= set
; }
143 void SetItalic( bool set
) { m_italic
= set
; }
146 bool HasColour() const { return m_colour
.Ok(); }
147 const wxColour
& GetColour() const { return m_colour
; }
149 bool GetBold() const { return m_bold
; }
150 bool GetItalic() const { return m_italic
; }
159 // ---------------------------------------------------------
161 // ---------------------------------------------------------
163 WX_DECLARE_LIST_WITH_DECL(wxDataViewModelNotifier
, wxDataViewModelNotifiers
,
164 class WXDLLIMPEXP_ADV
);
166 class WXDLLIMPEXP_ADV wxDataViewModel
: public wxObjectRefData
171 virtual unsigned int GetColumnCount() const = 0;
173 // return type as reported by wxVariant
174 virtual wxString
GetColumnType( unsigned int col
) const = 0;
176 // get value into a wxVariant
177 virtual void GetValue( wxVariant
&variant
,
178 const wxDataViewItem
&item
, unsigned int col
) const = 0;
180 // set value, call ValueChanged() afterwards!
181 virtual bool SetValue( const wxVariant
&variant
,
182 const wxDataViewItem
&item
, unsigned int col
) = 0;
184 // Get text attribute, return false of default attributes should be used
185 virtual bool GetAttr( const wxDataViewItem
&WXUNUSED(item
), unsigned int WXUNUSED(col
), wxDataViewItemAttr
&WXUNUSED(attr
) )
189 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const = 0;
190 virtual bool IsContainer( const wxDataViewItem
&item
) const = 0;
191 // Is the container just a header or an item with all columns
192 virtual bool HasContainerColumns(const wxDataViewItem
& WXUNUSED(item
)) const
194 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const = 0;
196 // delegated notifiers
197 virtual bool ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
198 virtual bool ItemsAdded( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
199 virtual bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
200 virtual bool ItemsDeleted( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
201 virtual bool ItemChanged( const wxDataViewItem
&item
);
202 virtual bool ItemsChanged( const wxDataViewItemArray
&items
);
203 virtual bool ValueChanged( const wxDataViewItem
&item
, unsigned int col
);
204 virtual bool Cleared();
207 virtual void Resort();
209 void AddNotifier( wxDataViewModelNotifier
*notifier
);
210 void RemoveNotifier( wxDataViewModelNotifier
*notifier
);
212 // default compare function
213 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
214 unsigned int column
, bool ascending
);
215 virtual bool HasDefaultCompare() const { return false; }
218 virtual bool IsVirtualListModel() const { return false; }
221 // the user should not delete this class directly: he should use DecRef() instead!
222 virtual ~wxDataViewModel() { }
224 wxDataViewModelNotifiers m_notifiers
;
227 // ---------------------------------------------------------
228 // wxDataViewIndexListModel
229 // ---------------------------------------------------------
231 class WXDLLIMPEXP_ADV wxDataViewIndexListModel
: public wxDataViewModel
234 wxDataViewIndexListModel( unsigned int initial_size
= 0 );
235 ~wxDataViewIndexListModel();
237 virtual void GetValueByRow( wxVariant
&variant
,
238 unsigned int row
, unsigned int col
) const = 0;
240 virtual bool SetValueByRow( const wxVariant
&variant
,
241 unsigned int row
, unsigned int col
) = 0;
243 virtual bool GetAttrByRow( unsigned int WXUNUSED(row
), unsigned int WXUNUSED(col
), wxDataViewItemAttr
&WXUNUSED(attr
) )
247 void RowInserted( unsigned int before
);
249 void RowDeleted( unsigned int row
);
250 void RowsDeleted( const wxArrayInt
&rows
);
251 void RowChanged( unsigned int row
);
252 void RowValueChanged( unsigned int row
, unsigned int col
);
253 void Reset( unsigned int new_size
);
255 // convert to/from row/wxDataViewItem
257 unsigned int GetRow( const wxDataViewItem
&item
) const;
258 wxDataViewItem
GetItem( unsigned int row
) const;
260 // compare based on index
262 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
263 unsigned int column
, bool ascending
);
264 virtual bool HasDefaultCompare() const;
266 // implement base methods
268 virtual void GetValue( wxVariant
&variant
,
269 const wxDataViewItem
&item
, unsigned int col
) const;
270 virtual bool SetValue( const wxVariant
&variant
,
271 const wxDataViewItem
&item
, unsigned int col
);
272 virtual bool GetAttr( const wxDataViewItem
&item
, unsigned int col
, wxDataViewItemAttr
&attr
);
273 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const;
274 virtual bool IsContainer( const wxDataViewItem
&item
) const;
275 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
278 virtual bool IsVirtualListModel() const { return false; }
279 unsigned int GetLastIndex() const { return m_lastIndex
; }
282 wxDataViewItemArray m_hash
;
283 unsigned int m_lastIndex
;
287 // ---------------------------------------------------------
288 // wxDataViewVirtualListModel
289 // ---------------------------------------------------------
292 // better than nothing
293 typedef wxDataViewIndexListModel wxDataViewVirtualListModel
;
296 class WXDLLIMPEXP_ADV wxDataViewVirtualListModel
: public wxDataViewModel
299 wxDataViewVirtualListModel( unsigned int initial_size
= 0 );
300 ~wxDataViewVirtualListModel();
302 virtual void GetValueByRow( wxVariant
&variant
,
303 unsigned int row
, unsigned int col
) const = 0;
305 virtual bool SetValueByRow( const wxVariant
&variant
,
306 unsigned int row
, unsigned int col
) = 0;
308 virtual bool GetAttrByRow( unsigned int WXUNUSED(row
), unsigned int WXUNUSED(col
), wxDataViewItemAttr
&WXUNUSED(attr
) )
312 void RowInserted( unsigned int before
);
314 void RowDeleted( unsigned int row
);
315 void RowsDeleted( const wxArrayInt
&rows
);
316 void RowChanged( unsigned int row
);
317 void RowValueChanged( unsigned int row
, unsigned int col
);
318 void Reset( unsigned int new_size
);
320 // convert to/from row/wxDataViewItem
322 unsigned int GetRow( const wxDataViewItem
&item
) const;
323 wxDataViewItem
GetItem( unsigned int row
) const;
325 // compare based on index
327 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
328 unsigned int column
, bool ascending
);
329 virtual bool HasDefaultCompare() const;
331 // implement base methods
333 virtual void GetValue( wxVariant
&variant
,
334 const wxDataViewItem
&item
, unsigned int col
) const;
335 virtual bool SetValue( const wxVariant
&variant
,
336 const wxDataViewItem
&item
, unsigned int col
);
337 virtual bool GetAttr( const wxDataViewItem
&item
, unsigned int col
, wxDataViewItemAttr
&attr
);
338 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const;
339 virtual bool IsContainer( const wxDataViewItem
&item
) const;
340 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
343 virtual bool IsVirtualListModel() const { return true; }
344 unsigned int GetLastIndex() const { return m_lastIndex
; }
347 wxDataViewItemArray m_hash
;
348 unsigned int m_lastIndex
;
353 //-----------------------------------------------------------------------------
354 // wxDataViewEditorCtrlEvtHandler
355 //-----------------------------------------------------------------------------
357 class wxDataViewEditorCtrlEvtHandler
: public wxEvtHandler
360 wxDataViewEditorCtrlEvtHandler( wxControl
*editor
, wxDataViewRenderer
*owner
);
362 void AcceptChangesAndFinish();
363 void SetFocusOnIdle( bool focus
= true ) { m_focusOnIdle
= focus
; }
366 void OnChar( wxKeyEvent
&event
);
367 void OnTextEnter( wxCommandEvent
&event
);
368 void OnKillFocus( wxFocusEvent
&event
);
369 void OnIdle( wxIdleEvent
&event
);
372 wxDataViewRenderer
*m_owner
;
373 wxControl
*m_editorCtrl
;
378 DECLARE_EVENT_TABLE()
381 // ---------------------------------------------------------
382 // wxDataViewRendererBase
383 // ---------------------------------------------------------
385 enum wxDataViewCellMode
387 wxDATAVIEW_CELL_INERT
,
388 wxDATAVIEW_CELL_ACTIVATABLE
,
389 wxDATAVIEW_CELL_EDITABLE
392 enum wxDataViewCellRenderState
394 wxDATAVIEW_CELL_SELECTED
= 1,
395 wxDATAVIEW_CELL_PRELIT
= 2,
396 wxDATAVIEW_CELL_INSENSITIVE
= 4,
397 wxDATAVIEW_CELL_FOCUSED
= 8
400 class WXDLLIMPEXP_ADV wxDataViewRendererBase
: public wxObject
403 wxDataViewRendererBase( const wxString
&varianttype
,
404 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
405 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
406 ~wxDataViewRendererBase();
408 virtual bool Validate( wxVariant
& WXUNUSED(value
) )
411 void SetOwner( wxDataViewColumn
*owner
) { m_owner
= owner
; }
412 wxDataViewColumn
* GetOwner() const { return m_owner
; }
414 // renderer properties:
416 virtual bool SetValue( const wxVariant
& WXUNUSED(value
) ) = 0;
417 virtual bool GetValue( wxVariant
& WXUNUSED(value
) ) const = 0;
419 wxString
GetVariantType() const { return m_variantType
; }
421 virtual void SetMode( wxDataViewCellMode mode
) = 0;
422 virtual wxDataViewCellMode
GetMode() const = 0;
424 // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but
425 // rather an "int"; that's because for rendering cells it's allowed
426 // to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM)
427 virtual void SetAlignment( int align
) = 0;
428 virtual int GetAlignment() const = 0;
431 virtual bool HasEditorCtrl()
433 virtual wxControl
* CreateEditorCtrl(wxWindow
* WXUNUSED(parent
),
434 wxRect
WXUNUSED(labelRect
),
435 const wxVariant
& WXUNUSED(value
))
437 virtual bool GetValueFromEditorCtrl(wxControl
* WXUNUSED(editor
),
438 wxVariant
& WXUNUSED(value
))
441 virtual bool StartEditing( const wxDataViewItem
&item
, wxRect labelRect
);
442 virtual void CancelEditing();
443 virtual bool FinishEditing();
445 wxControl
*GetEditorCtrl() { return m_editorCtrl
; }
448 wxString m_variantType
;
449 wxDataViewColumn
*m_owner
;
450 wxWeakRef
<wxControl
> m_editorCtrl
;
451 wxDataViewItem m_item
; // for m_editorCtrl
454 const wxDataViewCtrl
* GetView() const;
457 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase
)
460 //-----------------------------------------------------------------------------
461 // wxDataViewIconText
462 //-----------------------------------------------------------------------------
464 class WXDLLIMPEXP_ADV wxDataViewIconText
: public wxObject
467 wxDataViewIconText( const wxString
&text
= wxEmptyString
, const wxIcon
& icon
= wxNullIcon
)
468 : m_text(text
), m_icon(icon
)
470 wxDataViewIconText( const wxDataViewIconText
&other
)
472 { m_icon
= other
.m_icon
; m_text
= other
.m_text
; }
474 void SetText( const wxString
&text
) { m_text
= text
; }
475 wxString
GetText() const { return m_text
; }
476 void SetIcon( const wxIcon
&icon
) { m_icon
= icon
; }
477 const wxIcon
&GetIcon() const { return m_icon
; }
484 DECLARE_DYNAMIC_CLASS(wxDataViewIconText
)
487 bool operator == (const wxDataViewIconText
&one
, const wxDataViewIconText
&two
);
489 DECLARE_VARIANT_OBJECT_EXPORTED(wxDataViewIconText
, WXDLLIMPEXP_ADV
)
491 // ---------------------------------------------------------
492 // wxDataViewColumnBase
493 // ---------------------------------------------------------
495 // for compatibility only, do not use
496 enum wxDataViewColumnFlags
498 wxDATAVIEW_COL_RESIZABLE
= wxCOL_RESIZABLE
,
499 wxDATAVIEW_COL_SORTABLE
= wxCOL_SORTABLE
,
500 wxDATAVIEW_COL_REORDERABLE
= wxCOL_REORDERABLE
,
501 wxDATAVIEW_COL_HIDDEN
= wxCOL_HIDDEN
504 class WXDLLIMPEXP_ADV wxDataViewColumnBase
: public wxSettableHeaderColumn
507 // ctor for the text columns: takes ownership of renderer
508 wxDataViewColumnBase(wxDataViewRenderer
*renderer
,
509 unsigned int model_column
)
511 Init(renderer
, model_column
);
514 // ctor for the bitmap columns
515 wxDataViewColumnBase(const wxBitmap
& bitmap
,
516 wxDataViewRenderer
*renderer
,
517 unsigned int model_column
)
520 Init(renderer
, model_column
);
523 virtual ~wxDataViewColumnBase();
526 virtual void SetOwner( wxDataViewCtrl
*owner
)
530 unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column
); }
531 wxDataViewCtrl
*GetOwner() const { return m_owner
; }
532 wxDataViewRenderer
* GetRenderer() const { return m_renderer
; }
534 // implement some of base class pure virtuals (the rest is port-dependent
535 // and done differently in generic and native versions)
536 virtual void SetBitmap( const wxBitmap
& bitmap
) { m_bitmap
= bitmap
; }
537 virtual wxBitmap
GetBitmap() const { return m_bitmap
; }
540 wxDataViewRenderer
*m_renderer
;
543 wxDataViewCtrl
*m_owner
;
546 // common part of all ctors
547 void Init(wxDataViewRenderer
*renderer
, unsigned int model_column
);
550 // ---------------------------------------------------------
551 // wxDataViewCtrlBase
552 // ---------------------------------------------------------
554 #define wxDV_SINGLE 0x0000 // for convenience
555 #define wxDV_MULTIPLE 0x0001 // can select multiple items
557 #define wxDV_NO_HEADER 0x0002 // column titles not visible
558 #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows
559 #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns
561 #define wxDV_ROW_LINES 0x0010 // alternating colour in rows
562 #define wxDV_VARIABLE_LINE_HEIGHT 0x0020 // variable line height
564 class WXDLLIMPEXP_ADV wxDataViewCtrlBase
: public wxControl
567 wxDataViewCtrlBase();
568 virtual ~wxDataViewCtrlBase();
570 virtual bool AssociateModel( wxDataViewModel
*model
);
571 wxDataViewModel
* GetModel();
572 const wxDataViewModel
* GetModel() const;
575 wxDataViewColumn
*PrependTextColumn( const wxString
&label
, unsigned int model_column
,
576 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
577 wxAlignment align
= wxALIGN_NOT
,
578 int flags
= wxDATAVIEW_COL_RESIZABLE
);
579 wxDataViewColumn
*PrependIconTextColumn( const wxString
&label
, unsigned int model_column
,
580 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
581 wxAlignment align
= wxALIGN_NOT
,
582 int flags
= wxDATAVIEW_COL_RESIZABLE
);
583 wxDataViewColumn
*PrependToggleColumn( const wxString
&label
, unsigned int model_column
,
584 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
585 wxAlignment align
= wxALIGN_CENTER
,
586 int flags
= wxDATAVIEW_COL_RESIZABLE
);
587 wxDataViewColumn
*PrependProgressColumn( const wxString
&label
, unsigned int model_column
,
588 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
589 wxAlignment align
= wxALIGN_CENTER
,
590 int flags
= wxDATAVIEW_COL_RESIZABLE
);
591 wxDataViewColumn
*PrependDateColumn( const wxString
&label
, unsigned int model_column
,
592 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
593 wxAlignment align
= wxALIGN_NOT
,
594 int flags
= wxDATAVIEW_COL_RESIZABLE
);
595 wxDataViewColumn
*PrependBitmapColumn( const wxString
&label
, unsigned int model_column
,
596 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
597 wxAlignment align
= wxALIGN_CENTER
,
598 int flags
= wxDATAVIEW_COL_RESIZABLE
);
599 wxDataViewColumn
*PrependTextColumn( const wxBitmap
&label
, unsigned int model_column
,
600 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
601 wxAlignment align
= wxALIGN_NOT
,
602 int flags
= wxDATAVIEW_COL_RESIZABLE
);
603 wxDataViewColumn
*PrependIconTextColumn( const wxBitmap
&label
, unsigned int model_column
,
604 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
605 wxAlignment align
= wxALIGN_NOT
,
606 int flags
= wxDATAVIEW_COL_RESIZABLE
);
607 wxDataViewColumn
*PrependToggleColumn( const wxBitmap
&label
, unsigned int model_column
,
608 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
609 wxAlignment align
= wxALIGN_CENTER
,
610 int flags
= wxDATAVIEW_COL_RESIZABLE
);
611 wxDataViewColumn
*PrependProgressColumn( const wxBitmap
&label
, unsigned int model_column
,
612 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
613 wxAlignment align
= wxALIGN_CENTER
,
614 int flags
= wxDATAVIEW_COL_RESIZABLE
);
615 wxDataViewColumn
*PrependDateColumn( const wxBitmap
&label
, unsigned int model_column
,
616 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
617 wxAlignment align
= wxALIGN_NOT
,
618 int flags
= wxDATAVIEW_COL_RESIZABLE
);
619 wxDataViewColumn
*PrependBitmapColumn( const wxBitmap
&label
, unsigned int model_column
,
620 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
621 wxAlignment align
= wxALIGN_CENTER
,
622 int flags
= wxDATAVIEW_COL_RESIZABLE
);
624 wxDataViewColumn
*AppendTextColumn( const wxString
&label
, unsigned int model_column
,
625 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
626 wxAlignment align
= wxALIGN_NOT
,
627 int flags
= wxDATAVIEW_COL_RESIZABLE
);
628 wxDataViewColumn
*AppendIconTextColumn( const wxString
&label
, unsigned int model_column
,
629 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
630 wxAlignment align
= wxALIGN_NOT
,
631 int flags
= wxDATAVIEW_COL_RESIZABLE
);
632 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
, unsigned int model_column
,
633 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
634 wxAlignment align
= wxALIGN_CENTER
,
635 int flags
= wxDATAVIEW_COL_RESIZABLE
);
636 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
, unsigned int model_column
,
637 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
638 wxAlignment align
= wxALIGN_CENTER
,
639 int flags
= wxDATAVIEW_COL_RESIZABLE
);
640 wxDataViewColumn
*AppendDateColumn( const wxString
&label
, unsigned int model_column
,
641 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
642 wxAlignment align
= wxALIGN_NOT
,
643 int flags
= wxDATAVIEW_COL_RESIZABLE
);
644 wxDataViewColumn
*AppendBitmapColumn( const wxString
&label
, unsigned int model_column
,
645 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
646 wxAlignment align
= wxALIGN_CENTER
,
647 int flags
= wxDATAVIEW_COL_RESIZABLE
);
648 wxDataViewColumn
*AppendTextColumn( const wxBitmap
&label
, unsigned int model_column
,
649 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
650 wxAlignment align
= wxALIGN_NOT
,
651 int flags
= wxDATAVIEW_COL_RESIZABLE
);
652 wxDataViewColumn
*AppendIconTextColumn( const wxBitmap
&label
, unsigned int model_column
,
653 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
654 wxAlignment align
= wxALIGN_NOT
,
655 int flags
= wxDATAVIEW_COL_RESIZABLE
);
656 wxDataViewColumn
*AppendToggleColumn( const wxBitmap
&label
, unsigned int model_column
,
657 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
658 wxAlignment align
= wxALIGN_CENTER
,
659 int flags
= wxDATAVIEW_COL_RESIZABLE
);
660 wxDataViewColumn
*AppendProgressColumn( const wxBitmap
&label
, unsigned int model_column
,
661 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
662 wxAlignment align
= wxALIGN_CENTER
,
663 int flags
= wxDATAVIEW_COL_RESIZABLE
);
664 wxDataViewColumn
*AppendDateColumn( const wxBitmap
&label
, unsigned int model_column
,
665 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
666 wxAlignment align
= wxALIGN_NOT
,
667 int flags
= wxDATAVIEW_COL_RESIZABLE
);
668 wxDataViewColumn
*AppendBitmapColumn( const wxBitmap
&label
, unsigned int model_column
,
669 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
670 wxAlignment align
= wxALIGN_CENTER
,
671 int flags
= wxDATAVIEW_COL_RESIZABLE
);
674 virtual bool PrependColumn( wxDataViewColumn
*col
);
675 virtual bool InsertColumn( unsigned int pos
, wxDataViewColumn
*col
);
676 virtual bool AppendColumn( wxDataViewColumn
*col
);
678 virtual unsigned int GetColumnCount() const = 0;
679 virtual wxDataViewColumn
* GetColumn( unsigned int pos
) const = 0;
680 virtual int GetColumnPosition( const wxDataViewColumn
*column
) const = 0;
682 virtual bool DeleteColumn( wxDataViewColumn
*column
) = 0;
683 virtual bool ClearColumns() = 0;
685 void SetExpanderColumn( wxDataViewColumn
*col
)
686 { m_expander_column
= col
; DoSetExpanderColumn(); }
687 wxDataViewColumn
*GetExpanderColumn() const
688 { return m_expander_column
; }
690 virtual wxDataViewColumn
*GetSortingColumn() const = 0;
692 void SetIndent( int indent
)
693 { m_indent
= indent
; DoSetIndent(); }
694 int GetIndent() const
697 virtual wxDataViewItem
GetSelection() const = 0;
698 virtual int GetSelections( wxDataViewItemArray
& sel
) const = 0;
699 virtual void SetSelections( const wxDataViewItemArray
& sel
) = 0;
700 virtual void Select( const wxDataViewItem
& item
) = 0;
701 virtual void Unselect( const wxDataViewItem
& item
) = 0;
702 virtual bool IsSelected( const wxDataViewItem
& item
) const = 0;
704 virtual void SelectAll() = 0;
705 virtual void UnselectAll() = 0;
707 virtual void Expand( const wxDataViewItem
& item
) = 0;
708 virtual void ExpandAncestors( const wxDataViewItem
& item
);
709 virtual void Collapse( const wxDataViewItem
& item
) = 0;
710 virtual bool IsExpanded( const wxDataViewItem
& item
) const = 0;
712 virtual void EnsureVisible( const wxDataViewItem
& item
,
713 const wxDataViewColumn
*column
= NULL
) = 0;
714 virtual void HitTest( const wxPoint
& point
, wxDataViewItem
&item
, wxDataViewColumn
* &column
) const = 0;
715 virtual wxRect
GetItemRect( const wxDataViewItem
& item
, const wxDataViewColumn
*column
= NULL
) const = 0;
717 virtual bool EnableDragSource( const wxDataFormat
&format
);
718 virtual bool EnableDropTarget( const wxDataFormat
&format
);
721 virtual void DoSetExpanderColumn() = 0 ;
722 virtual void DoSetIndent() = 0;
725 wxDataViewModel
*m_model
;
726 wxDataViewColumn
*m_expander_column
;
730 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase
)
733 // ----------------------------------------------------------------------------
734 // wxDataViewEvent - the event class for the wxDataViewCtrl notifications
735 // ----------------------------------------------------------------------------
737 class WXDLLIMPEXP_ADV wxDataViewEvent
: public wxNotifyEvent
740 wxDataViewEvent(wxEventType commandType
= wxEVT_NULL
, int winid
= 0)
741 : wxNotifyEvent(commandType
, winid
),
745 m_value(wxNullVariant
),
753 wxDataViewEvent(const wxDataViewEvent
& event
)
754 : wxNotifyEvent(event
),
755 m_item(event
.m_item
),
757 m_model(event
.m_model
),
758 m_value(event
.m_value
),
759 m_column(event
.m_column
),
761 m_dataObject(event
.m_dataObject
),
762 m_dataFormat(event
.m_dataFormat
),
763 m_dataBuffer(event
.m_dataBuffer
),
764 m_dataSize(event
.m_dataSize
)
767 wxDataViewItem
GetItem() const { return m_item
; }
768 void SetItem( const wxDataViewItem
&item
) { m_item
= item
; }
770 int GetColumn() const { return m_col
; }
771 void SetColumn( int col
) { m_col
= col
; }
773 wxDataViewModel
* GetModel() const { return m_model
; }
774 void SetModel( wxDataViewModel
*model
) { m_model
= model
; }
776 const wxVariant
&GetValue() const { return m_value
; }
777 void SetValue( const wxVariant
&value
) { m_value
= value
; }
779 // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only
780 void SetDataViewColumn( wxDataViewColumn
*col
) { m_column
= col
; }
781 wxDataViewColumn
*GetDataViewColumn() const { return m_column
; }
783 // for wxEVT_DATAVIEW_CONTEXT_MENU only
784 wxPoint
GetPosition() const { return m_pos
; }
785 void SetPosition( int x
, int y
) { m_pos
.x
= x
; m_pos
.y
= y
; }
787 // For drag operations
788 void SetDataObject( wxDataObject
*obj
) { m_dataObject
= obj
; }
789 wxDataObject
*GetDataObject() const { return m_dataObject
; }
791 // For drop operations
792 void SetDataFormat( const wxDataFormat
&format
) { m_dataFormat
= format
; }
793 wxDataFormat
GetDataFormat() const { return m_dataFormat
; }
794 void SetDataSize( size_t size
) { m_dataSize
= size
; }
795 size_t GetDataSize() const { return m_dataSize
; }
796 void SetDataBuffer( void* buf
) { m_dataBuffer
= buf
;}
797 void *GetDataBuffer() const { return m_dataBuffer
; }
799 virtual wxEvent
*Clone() const { return new wxDataViewEvent(*this); }
802 wxDataViewItem m_item
;
804 wxDataViewModel
*m_model
;
806 wxDataViewColumn
*m_column
;
809 wxDataObject
*m_dataObject
;
811 wxDataFormat m_dataFormat
;
816 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent
)
819 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED
, wxDataViewEvent
)
821 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED
, wxDataViewEvent
)
822 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED
, wxDataViewEvent
)
823 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED
, wxDataViewEvent
)
824 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING
, wxDataViewEvent
)
825 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING
, wxDataViewEvent
)
826 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED
, wxDataViewEvent
)
827 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE
, wxDataViewEvent
)
828 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED
, wxDataViewEvent
)
830 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU
, wxDataViewEvent
)
832 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK
, wxDataViewEvent
)
833 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK
, wxDataViewEvent
)
834 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED
, wxDataViewEvent
)
835 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED
, wxDataViewEvent
)
837 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG
, wxDataViewEvent
)
838 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE
, wxDataViewEvent
)
839 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_DROP
, wxDataViewEvent
)
841 typedef void (wxEvtHandler
::*wxDataViewEventFunction
)(wxDataViewEvent
&);
843 #define wxDataViewEventHandler(func) \
844 wxEVENT_HANDLER_CAST(wxDataViewEventFunction, func)
846 #define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \
847 wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn))
849 #define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn)
851 #define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn)
852 #define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn)
853 #define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn)
854 #define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn)
855 #define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn)
856 #define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn)
857 #define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn)
858 #define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn)
860 #define EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_CONTEXT_MENU, id, fn)
862 #define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn)
863 #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn)
864 #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn)
865 #define EVT_DATAVIEW_COLUMN_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_REORDERED, id, fn)
867 #define EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_BEGIN_DRAG, id, fn)
868 #define EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP_POSSIBLE, id, fn)
869 #define EVT_DATAVIEW_ITEM_DROP(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP, id, fn)
871 #ifdef wxHAS_GENERIC_DATAVIEWCTRL
872 // this symbol doesn't follow the convention for wxUSE_XXX symbols which
873 // are normally always defined as either 0 or 1, so its use is deprecated
874 // and it only exists for backwards compatibility, don't use it any more
875 // and use wxHAS_GENERIC_DATAVIEWCTRL instead
876 #define wxUSE_GENERICDATAVIEWCTRL
878 #include "wx/generic/dataview.h"
879 #elif defined(__WXGTK20__)
880 #include "wx/gtk/dataview.h"
881 #elif defined(__WXMAC__)
882 #include "wx/osx/dataview.h"
884 #error "unknown native wxDataViewCtrl implementation"
887 // -------------------------------------
888 // wxDataViewSpinRenderer
889 // -------------------------------------
891 class WXDLLIMPEXP_ADV wxDataViewSpinRenderer
: public wxDataViewCustomRenderer
894 wxDataViewSpinRenderer( int min
, int max
,
895 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
896 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
897 virtual bool HasEditorCtrl() { return true; }
898 virtual wxControl
* CreateEditorCtrl( wxWindow
*parent
, wxRect labelRect
, const wxVariant
&value
);
899 virtual bool GetValueFromEditorCtrl( wxControl
* editor
, wxVariant
&value
);
900 virtual bool Render( wxRect rect
, wxDC
*dc
, int state
);
901 virtual wxSize
GetSize() const;
902 virtual bool SetValue( const wxVariant
&value
);
903 virtual bool GetValue( wxVariant
&value
) const;
910 #if defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXMAC__)
912 // -------------------------------------
913 // wxDataViewChoiceRenderer
914 // -------------------------------------
916 class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer
: public wxDataViewCustomRenderer
919 wxDataViewChoiceRenderer( const wxArrayString
&choices
,
920 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
921 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
922 virtual bool HasEditorCtrl() { return true; }
923 virtual wxControl
* CreateEditorCtrl( wxWindow
*parent
, wxRect labelRect
, const wxVariant
&value
);
924 virtual bool GetValueFromEditorCtrl( wxControl
* editor
, wxVariant
&value
);
925 virtual bool Render( wxRect rect
, wxDC
*dc
, int state
);
926 virtual wxSize
GetSize() const;
927 virtual bool SetValue( const wxVariant
&value
);
928 virtual bool GetValue( wxVariant
&value
) const;
931 wxArrayString m_choices
;
937 //-----------------------------------------------------------------------------
938 // wxDataViewListStore
939 //-----------------------------------------------------------------------------
941 class WXDLLIMPEXP_ADV wxDataViewListStoreLine
944 wxDataViewListStoreLine( wxClientData
*data
= NULL
)
948 virtual ~wxDataViewListStoreLine()
953 void SetData( wxClientData
*data
)
954 { if (m_data
) delete m_data
; m_data
= data
; }
955 wxClientData
*GetData() const
958 wxVector
<wxVariant
> m_values
;
961 wxClientData
*m_data
;
965 class WXDLLIMPEXP_ADV wxDataViewListStore
: public wxDataViewIndexListModel
968 wxDataViewListStore();
969 ~wxDataViewListStore();
971 void PrependColumn( const wxString
&varianttype
);
972 void InsertColumn( unsigned int pos
, const wxString
&varianttype
);
973 void AppendColumn( const wxString
&varianttype
);
975 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
976 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
977 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
978 void DeleteItem( unsigned pos
);
979 void DeleteAllItems();
981 // override base virtuals
983 virtual unsigned int GetColumnCount() const;
985 virtual wxString
GetColumnType( unsigned int col
) const;
987 virtual void GetValueByRow( wxVariant
&value
,
988 unsigned int row
, unsigned int col
) const;
990 virtual bool SetValueByRow( const wxVariant
&value
,
991 unsigned int row
, unsigned int col
);
995 wxVector
<wxDataViewListStoreLine
*> m_data
;
996 wxArrayString m_cols
;
999 //-----------------------------------------------------------------------------
1001 class WXDLLIMPEXP_ADV wxDataViewListCtrl
: public wxDataViewCtrl
1004 wxDataViewListCtrl();
1005 wxDataViewListCtrl( wxWindow
*parent
, wxWindowID id
,
1006 const wxPoint
& pos
= wxDefaultPosition
,
1007 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
1008 const wxValidator
& validator
= wxDefaultValidator
);
1009 ~wxDataViewListCtrl();
1011 bool Create( wxWindow
*parent
, wxWindowID id
,
1012 const wxPoint
& pos
= wxDefaultPosition
,
1013 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
1014 const wxValidator
& validator
= wxDefaultValidator
);
1016 wxDataViewListStore
*GetStore()
1017 { return (wxDataViewListStore
*) GetModel(); }
1018 const wxDataViewListStore
*GetStore() const
1019 { return (const wxDataViewListStore
*) GetModel(); }
1021 bool AppendColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
1022 bool PrependColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
1023 bool InsertColumn( unsigned int pos
, wxDataViewColumn
*column
, const wxString
&varianttype
);
1025 // overridden from base class
1026 virtual bool PrependColumn( wxDataViewColumn
*col
);
1027 virtual bool InsertColumn( unsigned int pos
, wxDataViewColumn
*col
);
1028 virtual bool AppendColumn( wxDataViewColumn
*col
);
1030 wxDataViewColumn
*AppendTextColumn( const wxString
&label
,
1031 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1032 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1033 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
,
1034 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
1035 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1036 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
,
1037 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1038 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1039 wxDataViewColumn
*AppendIconTextColumn( const wxString
&label
,
1040 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1041 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1043 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1044 { GetStore()->AppendItem( values
, data
); }
1045 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1046 { GetStore()->PrependItem( values
, data
); }
1047 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1048 { GetStore()->InsertItem( row
, values
, data
); }
1049 void DeleteItem( unsigned row
)
1050 { GetStore()->DeleteItem( row
); }
1051 void DeleteAllItems()
1052 { GetStore()->DeleteAllItems(); }
1054 void SetValue( const wxVariant
&value
, unsigned int row
, unsigned int col
)
1055 { GetStore()->SetValueByRow( value
, row
, col
);
1056 GetStore()->RowValueChanged( row
, col
); }
1057 void GetValue( wxVariant
&value
, unsigned int row
, unsigned int col
)
1058 { GetStore()->GetValueByRow( value
, row
, col
); }
1060 void SetTextValue( const wxString
&value
, unsigned int row
, unsigned int col
)
1061 { GetStore()->SetValueByRow( value
, row
, col
);
1062 GetStore()->RowValueChanged( row
, col
); }
1063 wxString
GetTextValue( unsigned int row
, unsigned int col
) const
1064 { wxVariant value
; GetStore()->GetValueByRow( value
, row
, col
); return value
.GetString(); }
1066 void SetToggleValue( bool value
, unsigned int row
, unsigned int col
)
1067 { GetStore()->SetValueByRow( value
, row
, col
);
1068 GetStore()->RowValueChanged( row
, col
); }
1069 bool GetToggleValue( unsigned int row
, unsigned int col
) const
1070 { wxVariant value
; GetStore()->GetValueByRow( value
, row
, col
); return value
.GetBool(); }
1072 void OnSize( wxSizeEvent
&event
);
1075 DECLARE_EVENT_TABLE()
1076 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewListCtrl
)
1079 //-----------------------------------------------------------------------------
1080 // wxDataViewTreeStore
1081 //-----------------------------------------------------------------------------
1083 class WXDLLIMPEXP_ADV wxDataViewTreeStoreNode
1086 wxDataViewTreeStoreNode( wxDataViewTreeStoreNode
*parent
,
1087 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1088 virtual ~wxDataViewTreeStoreNode();
1090 void SetText( const wxString
&text
)
1092 wxString
GetText() const
1094 void SetIcon( const wxIcon
&icon
)
1096 const wxIcon
&GetIcon() const
1098 void SetData( wxClientData
*data
)
1099 { if (m_data
) delete m_data
; m_data
= data
; }
1100 wxClientData
*GetData() const
1103 wxDataViewItem
GetItem() const
1104 { return wxDataViewItem( (void*) this ); }
1106 virtual bool IsContainer()
1109 wxDataViewTreeStoreNode
*GetParent()
1110 { return m_parent
; }
1113 wxDataViewTreeStoreNode
*m_parent
;
1116 wxClientData
*m_data
;
1119 WX_DECLARE_LIST_WITH_DECL(wxDataViewTreeStoreNode
, wxDataViewTreeStoreNodeList
,
1120 class WXDLLIMPEXP_ADV
);
1122 class WXDLLIMPEXP_ADV wxDataViewTreeStoreContainerNode
: public wxDataViewTreeStoreNode
1125 wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode
*parent
,
1126 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1127 wxClientData
*data
= NULL
);
1128 virtual ~wxDataViewTreeStoreContainerNode();
1130 const wxDataViewTreeStoreNodeList
&GetChildren() const
1131 { return m_children
; }
1132 wxDataViewTreeStoreNodeList
&GetChildren()
1133 { return m_children
; }
1135 void SetExpandedIcon( const wxIcon
&icon
)
1136 { m_iconExpanded
= icon
; }
1137 const wxIcon
&GetExpandedIcon() const
1138 { return m_iconExpanded
; }
1140 void SetExpanded( bool expanded
= true )
1141 { m_isExpanded
= expanded
; }
1142 bool IsExpanded() const
1143 { return m_isExpanded
; }
1145 virtual bool IsContainer()
1149 wxDataViewTreeStoreNodeList m_children
;
1150 wxIcon m_iconExpanded
;
1154 //-----------------------------------------------------------------------------
1156 class WXDLLIMPEXP_ADV wxDataViewTreeStore
: public wxDataViewModel
1159 wxDataViewTreeStore();
1160 ~wxDataViewTreeStore();
1162 wxDataViewItem
AppendItem( const wxDataViewItem
& parent
,
1163 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1164 wxDataViewItem
PrependItem( const wxDataViewItem
& parent
,
1165 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1166 wxDataViewItem
InsertItem( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1167 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1169 wxDataViewItem
PrependContainer( const wxDataViewItem
& parent
,
1170 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1171 wxClientData
*data
= NULL
);
1172 wxDataViewItem
AppendContainer( const wxDataViewItem
& parent
,
1173 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1174 wxClientData
*data
= NULL
);
1175 wxDataViewItem
InsertContainer( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1176 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1177 wxClientData
*data
= NULL
);
1179 wxDataViewItem
GetNthChild( const wxDataViewItem
& parent
, unsigned int pos
) const;
1180 int GetChildCount( const wxDataViewItem
& parent
) const;
1182 void SetItemText( const wxDataViewItem
& item
, const wxString
&text
);
1183 wxString
GetItemText( const wxDataViewItem
& item
) const;
1184 void SetItemIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1185 const wxIcon
&GetItemIcon( const wxDataViewItem
& item
) const;
1186 void SetItemExpandedIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1187 const wxIcon
&GetItemExpandedIcon( const wxDataViewItem
& item
) const;
1188 void SetItemData( const wxDataViewItem
& item
, wxClientData
*data
);
1189 wxClientData
*GetItemData( const wxDataViewItem
& item
) const;
1191 void DeleteItem( const wxDataViewItem
& item
);
1192 void DeleteChildren( const wxDataViewItem
& item
);
1193 void DeleteAllItems();
1195 // implement base methods
1197 virtual void GetValue( wxVariant
&variant
,
1198 const wxDataViewItem
&item
, unsigned int col
) const;
1199 virtual bool SetValue( const wxVariant
&variant
,
1200 const wxDataViewItem
&item
, unsigned int col
);
1201 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const;
1202 virtual bool IsContainer( const wxDataViewItem
&item
) const;
1203 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
1205 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
1206 unsigned int column
, bool ascending
);
1208 virtual bool HasDefaultCompare() const
1210 virtual unsigned int GetColumnCount() const
1212 virtual wxString
GetColumnType( unsigned int WXUNUSED(col
) ) const
1213 { return wxT("wxDataViewIconText"); }
1215 wxDataViewTreeStoreNode
*FindNode( const wxDataViewItem
&item
) const;
1216 wxDataViewTreeStoreContainerNode
*FindContainerNode( const wxDataViewItem
&item
) const;
1217 wxDataViewTreeStoreNode
*GetRoot() const { return m_root
; }
1220 wxDataViewTreeStoreNode
*m_root
;
1223 //-----------------------------------------------------------------------------
1225 class WXDLLIMPEXP_ADV wxDataViewTreeCtrl
: public wxDataViewCtrl
1228 wxDataViewTreeCtrl();
1229 wxDataViewTreeCtrl( wxWindow
*parent
, wxWindowID id
,
1230 const wxPoint
& pos
= wxDefaultPosition
,
1231 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
1232 const wxValidator
& validator
= wxDefaultValidator
);
1233 ~wxDataViewTreeCtrl();
1235 bool Create( wxWindow
*parent
, wxWindowID id
,
1236 const wxPoint
& pos
= wxDefaultPosition
,
1237 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
1238 const wxValidator
& validator
= wxDefaultValidator
);
1240 wxDataViewTreeStore
*GetStore()
1241 { return (wxDataViewTreeStore
*) GetModel(); }
1242 const wxDataViewTreeStore
*GetStore() const
1243 { return (const wxDataViewTreeStore
*) GetModel(); }
1245 void SetImageList( wxImageList
*imagelist
);
1246 wxImageList
* GetImageList() { return m_imageList
; }
1248 wxDataViewItem
AppendItem( const wxDataViewItem
& parent
,
1249 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1250 wxDataViewItem
PrependItem( const wxDataViewItem
& parent
,
1251 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1252 wxDataViewItem
InsertItem( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1253 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1255 wxDataViewItem
PrependContainer( const wxDataViewItem
& parent
,
1256 const wxString
&text
, int icon
= -1, int expanded
= -1,
1257 wxClientData
*data
= NULL
);
1258 wxDataViewItem
AppendContainer( const wxDataViewItem
& parent
,
1259 const wxString
&text
, int icon
= -1, int expanded
= -1,
1260 wxClientData
*data
= NULL
);
1261 wxDataViewItem
InsertContainer( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1262 const wxString
&text
, int icon
= -1, int expanded
= -1,
1263 wxClientData
*data
= NULL
);
1265 wxDataViewItem
GetNthChild( const wxDataViewItem
& parent
, unsigned int pos
) const
1266 { return GetStore()->GetNthChild(parent
, pos
); }
1267 int GetChildCount( const wxDataViewItem
& parent
) const
1268 { return GetStore()->GetChildCount(parent
); }
1270 void SetItemText( const wxDataViewItem
& item
, const wxString
&text
);
1271 wxString
GetItemText( const wxDataViewItem
& item
) const
1272 { return GetStore()->GetItemText(item
); }
1273 void SetItemIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1274 const wxIcon
&GetItemIcon( const wxDataViewItem
& item
) const
1275 { return GetStore()->GetItemIcon(item
); }
1276 void SetItemExpandedIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1277 const wxIcon
&GetItemExpandedIcon( const wxDataViewItem
& item
) const
1278 { return GetStore()->GetItemExpandedIcon(item
); }
1279 void SetItemData( const wxDataViewItem
& item
, wxClientData
*data
)
1280 { GetStore()->SetItemData(item
,data
); }
1281 wxClientData
*GetItemData( const wxDataViewItem
& item
) const
1282 { return GetStore()->GetItemData(item
); }
1284 void DeleteItem( const wxDataViewItem
& item
);
1285 void DeleteChildren( const wxDataViewItem
& item
);
1286 void DeleteAllItems();
1288 void OnExpanded( wxDataViewEvent
&event
);
1289 void OnCollapsed( wxDataViewEvent
&event
);
1290 void OnSize( wxSizeEvent
&event
);
1293 wxImageList
*m_imageList
;
1296 DECLARE_EVENT_TABLE()
1297 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl
)
1300 #endif // wxUSE_DATAVIEWCTRL
1303 // _WX_DATAVIEW_H_BASE_