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
; }
88 bool operator == (const wxDataViewItem
&left
, const wxDataViewItem
&right
);
90 WX_DEFINE_ARRAY(wxDataViewItem
, wxDataViewItemArray
);
92 // ---------------------------------------------------------
93 // wxDataViewModelNotifier
94 // ---------------------------------------------------------
96 class WXDLLIMPEXP_ADV wxDataViewModelNotifier
99 wxDataViewModelNotifier() { m_owner
= NULL
; }
100 virtual ~wxDataViewModelNotifier() { m_owner
= NULL
; }
102 virtual bool ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
) = 0;
103 virtual bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
) = 0;
104 virtual bool ItemChanged( const wxDataViewItem
&item
) = 0;
105 virtual bool ItemsAdded( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
106 virtual bool ItemsDeleted( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
107 virtual bool ItemsChanged( const wxDataViewItemArray
&items
);
108 virtual bool ValueChanged( const wxDataViewItem
&item
, unsigned int col
) = 0;
109 virtual bool Cleared() = 0;
111 virtual void Resort() = 0;
113 void SetOwner( wxDataViewModel
*owner
) { m_owner
= owner
; }
114 wxDataViewModel
*GetOwner() const { return m_owner
; }
117 wxDataViewModel
*m_owner
;
122 // ----------------------------------------------------------------------------
123 // wxDataViewItemAttr: a structure containing the visual attributes of an item
124 // ----------------------------------------------------------------------------
126 // TODO: this should be renamed to wxItemAttr or something general like this
128 class WXDLLIMPEXP_ADV wxDataViewItemAttr
139 void SetColour(const wxColour
& colour
) { m_colour
= colour
; }
140 void SetBold( bool set
) { m_bold
= set
; }
141 void SetItalic( bool set
) { m_italic
= set
; }
144 bool HasColour() const { return m_colour
.Ok(); }
145 const wxColour
& GetColour() const { return m_colour
; }
147 bool GetBold() const { return m_bold
; }
148 bool GetItalic() const { return m_italic
; }
157 // ---------------------------------------------------------
159 // ---------------------------------------------------------
161 WX_DECLARE_LIST_WITH_DECL(wxDataViewModelNotifier
, wxDataViewModelNotifiers
,
162 class WXDLLIMPEXP_ADV
);
164 class WXDLLIMPEXP_ADV wxDataViewModel
: public wxRefCounter
169 virtual unsigned int GetColumnCount() const = 0;
171 // return type as reported by wxVariant
172 virtual wxString
GetColumnType( unsigned int col
) const = 0;
174 // get value into a wxVariant
175 virtual void GetValue( wxVariant
&variant
,
176 const wxDataViewItem
&item
, unsigned int col
) const = 0;
178 // set value, call ValueChanged() afterwards!
179 virtual bool SetValue( const wxVariant
&variant
,
180 const wxDataViewItem
&item
, unsigned int col
) = 0;
182 // Get text attribute, return false of default attributes should be used
183 virtual bool GetAttr( const wxDataViewItem
&WXUNUSED(item
), unsigned int WXUNUSED(col
), wxDataViewItemAttr
&WXUNUSED(attr
) )
187 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const = 0;
188 virtual bool IsContainer( const wxDataViewItem
&item
) const = 0;
189 // Is the container just a header or an item with all columns
190 virtual bool HasContainerColumns(const wxDataViewItem
& WXUNUSED(item
)) const
192 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const = 0;
194 // delegated notifiers
195 virtual bool ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
196 virtual bool ItemsAdded( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
197 virtual bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
198 virtual bool ItemsDeleted( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
199 virtual bool ItemChanged( const wxDataViewItem
&item
);
200 virtual bool ItemsChanged( const wxDataViewItemArray
&items
);
201 virtual bool ValueChanged( const wxDataViewItem
&item
, unsigned int col
);
202 virtual bool Cleared();
205 virtual void Resort();
207 void AddNotifier( wxDataViewModelNotifier
*notifier
);
208 void RemoveNotifier( wxDataViewModelNotifier
*notifier
);
210 // default compare function
211 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
212 unsigned int column
, bool ascending
) const;
213 virtual bool HasDefaultCompare() const { return false; }
216 virtual bool IsVirtualListModel() const { return false; }
219 // the user should not delete this class directly: he should use DecRef() instead!
220 virtual ~wxDataViewModel() { }
222 wxDataViewModelNotifiers m_notifiers
;
225 // ---------------------------------------------------------
226 // wxDataViewIndexListModel
227 // ---------------------------------------------------------
229 class WXDLLIMPEXP_ADV wxDataViewIndexListModel
: public wxDataViewModel
232 wxDataViewIndexListModel( unsigned int initial_size
= 0 );
233 ~wxDataViewIndexListModel();
235 virtual void GetValueByRow( wxVariant
&variant
,
236 unsigned int row
, unsigned int col
) const = 0;
238 virtual bool SetValueByRow( const wxVariant
&variant
,
239 unsigned int row
, unsigned int col
) = 0;
241 virtual bool GetAttrByRow( unsigned int WXUNUSED(row
), unsigned int WXUNUSED(col
), wxDataViewItemAttr
&WXUNUSED(attr
) )
245 void RowInserted( unsigned int before
);
247 void RowDeleted( unsigned int row
);
248 void RowsDeleted( const wxArrayInt
&rows
);
249 void RowChanged( unsigned int row
);
250 void RowValueChanged( unsigned int row
, unsigned int col
);
251 void Reset( unsigned int new_size
);
253 // convert to/from row/wxDataViewItem
255 unsigned int GetRow( const wxDataViewItem
&item
) const;
256 wxDataViewItem
GetItem( unsigned int row
) const;
258 // compare based on index
260 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
261 unsigned int column
, bool ascending
) const;
262 virtual bool HasDefaultCompare() const;
264 // implement base methods
266 virtual void GetValue( wxVariant
&variant
,
267 const wxDataViewItem
&item
, unsigned int col
) const;
268 virtual bool SetValue( const wxVariant
&variant
,
269 const wxDataViewItem
&item
, unsigned int col
);
270 virtual bool GetAttr( const wxDataViewItem
&item
, unsigned int col
, wxDataViewItemAttr
&attr
);
271 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const;
272 virtual bool IsContainer( const wxDataViewItem
&item
) const;
273 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
276 virtual bool IsVirtualListModel() const { return false; }
277 unsigned int GetCount() const { return m_hash
.GetCount(); }
280 wxDataViewItemArray m_hash
;
281 unsigned int m_nextFreeID
;
285 // ---------------------------------------------------------
286 // wxDataViewVirtualListModel
287 // ---------------------------------------------------------
290 // better than nothing
291 typedef wxDataViewIndexListModel wxDataViewVirtualListModel
;
294 class WXDLLIMPEXP_ADV wxDataViewVirtualListModel
: public wxDataViewModel
297 wxDataViewVirtualListModel( unsigned int initial_size
= 0 );
298 ~wxDataViewVirtualListModel();
300 virtual void GetValueByRow( wxVariant
&variant
,
301 unsigned int row
, unsigned int col
) const = 0;
303 virtual bool SetValueByRow( const wxVariant
&variant
,
304 unsigned int row
, unsigned int col
) = 0;
306 virtual bool GetAttrByRow( unsigned int WXUNUSED(row
), unsigned int WXUNUSED(col
), wxDataViewItemAttr
&WXUNUSED(attr
) )
310 void RowInserted( unsigned int before
);
312 void RowDeleted( unsigned int row
);
313 void RowsDeleted( const wxArrayInt
&rows
);
314 void RowChanged( unsigned int row
);
315 void RowValueChanged( unsigned int row
, unsigned int col
);
316 void Reset( unsigned int new_size
);
318 // convert to/from row/wxDataViewItem
320 unsigned int GetRow( const wxDataViewItem
&item
) const;
321 wxDataViewItem
GetItem( unsigned int row
) const;
323 // compare based on index
325 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
326 unsigned int column
, bool ascending
) const;
327 virtual bool HasDefaultCompare() const;
329 // implement base methods
331 virtual void GetValue( wxVariant
&variant
,
332 const wxDataViewItem
&item
, unsigned int col
) const;
333 virtual bool SetValue( const wxVariant
&variant
,
334 const wxDataViewItem
&item
, unsigned int col
);
335 virtual bool GetAttr( const wxDataViewItem
&item
, unsigned int col
, wxDataViewItemAttr
&attr
);
336 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const;
337 virtual bool IsContainer( const wxDataViewItem
&item
) const;
338 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
341 virtual bool IsVirtualListModel() const { return true; }
342 unsigned int GetCount() const { return m_size
; }
350 //-----------------------------------------------------------------------------
351 // wxDataViewEditorCtrlEvtHandler
352 //-----------------------------------------------------------------------------
354 class wxDataViewEditorCtrlEvtHandler
: public wxEvtHandler
357 wxDataViewEditorCtrlEvtHandler( wxControl
*editor
, wxDataViewRenderer
*owner
);
359 void AcceptChangesAndFinish();
360 void SetFocusOnIdle( bool focus
= true ) { m_focusOnIdle
= focus
; }
363 void OnChar( wxKeyEvent
&event
);
364 void OnTextEnter( wxCommandEvent
&event
);
365 void OnKillFocus( wxFocusEvent
&event
);
366 void OnIdle( wxIdleEvent
&event
);
369 wxDataViewRenderer
*m_owner
;
370 wxControl
*m_editorCtrl
;
375 DECLARE_EVENT_TABLE()
378 // ---------------------------------------------------------
379 // wxDataViewRendererBase
380 // ---------------------------------------------------------
382 enum wxDataViewCellMode
384 wxDATAVIEW_CELL_INERT
,
385 wxDATAVIEW_CELL_ACTIVATABLE
,
386 wxDATAVIEW_CELL_EDITABLE
389 enum wxDataViewCellRenderState
391 wxDATAVIEW_CELL_SELECTED
= 1,
392 wxDATAVIEW_CELL_PRELIT
= 2,
393 wxDATAVIEW_CELL_INSENSITIVE
= 4,
394 wxDATAVIEW_CELL_FOCUSED
= 8
397 class WXDLLIMPEXP_ADV wxDataViewRendererBase
: public wxObject
400 wxDataViewRendererBase( const wxString
&varianttype
,
401 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
402 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
403 ~wxDataViewRendererBase();
405 virtual bool Validate( wxVariant
& WXUNUSED(value
) )
408 void SetOwner( wxDataViewColumn
*owner
) { m_owner
= owner
; }
409 wxDataViewColumn
* GetOwner() const { return m_owner
; }
411 // renderer properties:
413 virtual bool SetValue( const wxVariant
& WXUNUSED(value
) ) = 0;
414 virtual bool GetValue( wxVariant
& WXUNUSED(value
) ) const = 0;
416 wxString
GetVariantType() const { return m_variantType
; }
418 virtual void SetMode( wxDataViewCellMode mode
) = 0;
419 virtual wxDataViewCellMode
GetMode() const = 0;
421 // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but
422 // rather an "int"; that's because for rendering cells it's allowed
423 // to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM)
424 virtual void SetAlignment( int align
) = 0;
425 virtual int GetAlignment() const = 0;
428 virtual bool HasEditorCtrl() const
430 virtual wxControl
* CreateEditorCtrl(wxWindow
* WXUNUSED(parent
),
431 wxRect
WXUNUSED(labelRect
),
432 const wxVariant
& WXUNUSED(value
))
434 virtual bool GetValueFromEditorCtrl(wxControl
* WXUNUSED(editor
),
435 wxVariant
& WXUNUSED(value
))
438 virtual bool StartEditing( const wxDataViewItem
&item
, wxRect labelRect
);
439 virtual void CancelEditing();
440 virtual bool FinishEditing();
442 wxControl
*GetEditorCtrl() { return m_editorCtrl
; }
445 wxString m_variantType
;
446 wxDataViewColumn
*m_owner
;
447 wxWeakRef
<wxControl
> m_editorCtrl
;
448 wxDataViewItem m_item
; // for m_editorCtrl
451 const wxDataViewCtrl
* GetView() const;
454 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase
)
457 //-----------------------------------------------------------------------------
458 // wxDataViewIconText
459 //-----------------------------------------------------------------------------
461 class WXDLLIMPEXP_ADV wxDataViewIconText
: public wxObject
464 wxDataViewIconText( const wxString
&text
= wxEmptyString
, const wxIcon
& icon
= wxNullIcon
)
465 : m_text(text
), m_icon(icon
)
467 wxDataViewIconText( const wxDataViewIconText
&other
)
469 { m_icon
= other
.m_icon
; m_text
= other
.m_text
; }
471 void SetText( const wxString
&text
) { m_text
= text
; }
472 wxString
GetText() const { return m_text
; }
473 void SetIcon( const wxIcon
&icon
) { m_icon
= icon
; }
474 const wxIcon
&GetIcon() const { return m_icon
; }
481 DECLARE_DYNAMIC_CLASS(wxDataViewIconText
)
484 bool operator == (const wxDataViewIconText
&one
, const wxDataViewIconText
&two
);
486 DECLARE_VARIANT_OBJECT_EXPORTED(wxDataViewIconText
, WXDLLIMPEXP_ADV
)
488 // ---------------------------------------------------------
489 // wxDataViewColumnBase
490 // ---------------------------------------------------------
492 // for compatibility only, do not use
493 enum wxDataViewColumnFlags
495 wxDATAVIEW_COL_RESIZABLE
= wxCOL_RESIZABLE
,
496 wxDATAVIEW_COL_SORTABLE
= wxCOL_SORTABLE
,
497 wxDATAVIEW_COL_REORDERABLE
= wxCOL_REORDERABLE
,
498 wxDATAVIEW_COL_HIDDEN
= wxCOL_HIDDEN
501 class WXDLLIMPEXP_ADV wxDataViewColumnBase
: public wxSettableHeaderColumn
504 // ctor for the text columns: takes ownership of renderer
505 wxDataViewColumnBase(wxDataViewRenderer
*renderer
,
506 unsigned int model_column
)
508 Init(renderer
, model_column
);
511 // ctor for the bitmap columns
512 wxDataViewColumnBase(const wxBitmap
& bitmap
,
513 wxDataViewRenderer
*renderer
,
514 unsigned int model_column
)
517 Init(renderer
, model_column
);
520 virtual ~wxDataViewColumnBase();
523 virtual void SetOwner( wxDataViewCtrl
*owner
)
527 unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column
); }
528 wxDataViewCtrl
*GetOwner() const { return m_owner
; }
529 wxDataViewRenderer
* GetRenderer() const { return m_renderer
; }
531 // implement some of base class pure virtuals (the rest is port-dependent
532 // and done differently in generic and native versions)
533 virtual void SetBitmap( const wxBitmap
& bitmap
) { m_bitmap
= bitmap
; }
534 virtual wxBitmap
GetBitmap() const { return m_bitmap
; }
537 wxDataViewRenderer
*m_renderer
;
540 wxDataViewCtrl
*m_owner
;
543 // common part of all ctors
544 void Init(wxDataViewRenderer
*renderer
, unsigned int model_column
);
547 // ---------------------------------------------------------
548 // wxDataViewCtrlBase
549 // ---------------------------------------------------------
551 #define wxDV_SINGLE 0x0000 // for convenience
552 #define wxDV_MULTIPLE 0x0001 // can select multiple items
554 #define wxDV_NO_HEADER 0x0002 // column titles not visible
555 #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows
556 #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns
558 #define wxDV_ROW_LINES 0x0010 // alternating colour in rows
559 #define wxDV_VARIABLE_LINE_HEIGHT 0x0020 // variable line height
561 class WXDLLIMPEXP_ADV wxDataViewCtrlBase
: public wxControl
564 wxDataViewCtrlBase();
565 virtual ~wxDataViewCtrlBase();
570 virtual bool AssociateModel( wxDataViewModel
*model
);
571 wxDataViewModel
* GetModel();
572 const wxDataViewModel
* GetModel() const;
578 wxDataViewColumn
*PrependTextColumn( const wxString
&label
, unsigned int model_column
,
579 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
580 wxAlignment align
= wxALIGN_NOT
,
581 int flags
= wxDATAVIEW_COL_RESIZABLE
);
582 wxDataViewColumn
*PrependIconTextColumn( const wxString
&label
, unsigned int model_column
,
583 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
584 wxAlignment align
= wxALIGN_NOT
,
585 int flags
= wxDATAVIEW_COL_RESIZABLE
);
586 wxDataViewColumn
*PrependToggleColumn( const wxString
&label
, unsigned int model_column
,
587 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
588 wxAlignment align
= wxALIGN_CENTER
,
589 int flags
= wxDATAVIEW_COL_RESIZABLE
);
590 wxDataViewColumn
*PrependProgressColumn( const wxString
&label
, unsigned int model_column
,
591 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
592 wxAlignment align
= wxALIGN_CENTER
,
593 int flags
= wxDATAVIEW_COL_RESIZABLE
);
594 wxDataViewColumn
*PrependDateColumn( const wxString
&label
, unsigned int model_column
,
595 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
596 wxAlignment align
= wxALIGN_NOT
,
597 int flags
= wxDATAVIEW_COL_RESIZABLE
);
598 wxDataViewColumn
*PrependBitmapColumn( const wxString
&label
, unsigned int model_column
,
599 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
600 wxAlignment align
= wxALIGN_CENTER
,
601 int flags
= wxDATAVIEW_COL_RESIZABLE
);
602 wxDataViewColumn
*PrependTextColumn( const wxBitmap
&label
, unsigned int model_column
,
603 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
604 wxAlignment align
= wxALIGN_NOT
,
605 int flags
= wxDATAVIEW_COL_RESIZABLE
);
606 wxDataViewColumn
*PrependIconTextColumn( const wxBitmap
&label
, unsigned int model_column
,
607 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
608 wxAlignment align
= wxALIGN_NOT
,
609 int flags
= wxDATAVIEW_COL_RESIZABLE
);
610 wxDataViewColumn
*PrependToggleColumn( const wxBitmap
&label
, unsigned int model_column
,
611 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
612 wxAlignment align
= wxALIGN_CENTER
,
613 int flags
= wxDATAVIEW_COL_RESIZABLE
);
614 wxDataViewColumn
*PrependProgressColumn( const wxBitmap
&label
, unsigned int model_column
,
615 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
616 wxAlignment align
= wxALIGN_CENTER
,
617 int flags
= wxDATAVIEW_COL_RESIZABLE
);
618 wxDataViewColumn
*PrependDateColumn( const wxBitmap
&label
, unsigned int model_column
,
619 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
620 wxAlignment align
= wxALIGN_NOT
,
621 int flags
= wxDATAVIEW_COL_RESIZABLE
);
622 wxDataViewColumn
*PrependBitmapColumn( const wxBitmap
&label
, unsigned int model_column
,
623 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
624 wxAlignment align
= wxALIGN_CENTER
,
625 int flags
= wxDATAVIEW_COL_RESIZABLE
);
627 wxDataViewColumn
*AppendTextColumn( 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
*AppendIconTextColumn( 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
*AppendToggleColumn( 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
*AppendProgressColumn( 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
*AppendDateColumn( 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
*AppendBitmapColumn( 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
*AppendTextColumn( 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
*AppendIconTextColumn( 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
*AppendToggleColumn( 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
*AppendProgressColumn( 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
*AppendDateColumn( 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
*AppendBitmapColumn( 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 virtual bool PrependColumn( wxDataViewColumn
*col
);
677 virtual bool InsertColumn( unsigned int pos
, wxDataViewColumn
*col
);
678 virtual bool AppendColumn( wxDataViewColumn
*col
);
680 virtual unsigned int GetColumnCount() const = 0;
681 virtual wxDataViewColumn
* GetColumn( unsigned int pos
) const = 0;
682 virtual int GetColumnPosition( const wxDataViewColumn
*column
) const = 0;
684 virtual bool DeleteColumn( wxDataViewColumn
*column
) = 0;
685 virtual bool ClearColumns() = 0;
687 void SetExpanderColumn( wxDataViewColumn
*col
)
688 { m_expander_column
= col
; DoSetExpanderColumn(); }
689 wxDataViewColumn
*GetExpanderColumn() const
690 { return m_expander_column
; }
692 virtual wxDataViewColumn
*GetSortingColumn() const = 0;
698 void SetIndent( int indent
)
699 { m_indent
= indent
; DoSetIndent(); }
700 int GetIndent() const
703 virtual wxDataViewItem
GetSelection() const = 0;
704 virtual int GetSelections( wxDataViewItemArray
& sel
) const = 0;
705 virtual void SetSelections( const wxDataViewItemArray
& sel
) = 0;
706 virtual void Select( const wxDataViewItem
& item
) = 0;
707 virtual void Unselect( const wxDataViewItem
& item
) = 0;
708 virtual bool IsSelected( const wxDataViewItem
& item
) const = 0;
710 virtual void SelectAll() = 0;
711 virtual void UnselectAll() = 0;
713 virtual void Expand( const wxDataViewItem
& item
) = 0;
714 virtual void ExpandAncestors( const wxDataViewItem
& item
);
715 virtual void Collapse( const wxDataViewItem
& item
) = 0;
716 virtual bool IsExpanded( const wxDataViewItem
& item
) const = 0;
718 virtual void EnsureVisible( const wxDataViewItem
& item
,
719 const wxDataViewColumn
*column
= NULL
) = 0;
720 virtual void HitTest( const wxPoint
& point
, wxDataViewItem
&item
, wxDataViewColumn
* &column
) const = 0;
721 virtual wxRect
GetItemRect( const wxDataViewItem
& item
, const wxDataViewColumn
*column
= NULL
) const = 0;
723 #if wxUSE_DRAG_AND_DROP
724 virtual bool EnableDragSource(const wxDataFormat
& WXUNUSED(format
))
726 virtual bool EnableDropTarget(const wxDataFormat
& WXUNUSED(format
))
728 #endif // wxUSE_DRAG_AND_DROP
731 virtual void DoSetExpanderColumn() = 0 ;
732 virtual void DoSetIndent() = 0;
735 wxDataViewModel
*m_model
;
736 wxDataViewColumn
*m_expander_column
;
740 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase
)
743 // ----------------------------------------------------------------------------
744 // wxDataViewEvent - the event class for the wxDataViewCtrl notifications
745 // ----------------------------------------------------------------------------
747 class WXDLLIMPEXP_ADV wxDataViewEvent
: public wxNotifyEvent
750 wxDataViewEvent(wxEventType commandType
= wxEVT_NULL
, int winid
= 0)
751 : wxNotifyEvent(commandType
, winid
),
755 m_value(wxNullVariant
),
758 #if wxUSE_DRAG_AND_DROP
759 , m_dataObject(NULL
),
765 wxDataViewEvent(const wxDataViewEvent
& event
)
766 : wxNotifyEvent(event
),
767 m_item(event
.m_item
),
769 m_model(event
.m_model
),
770 m_value(event
.m_value
),
771 m_column(event
.m_column
),
773 #if wxUSE_DRAG_AND_DROP
774 , m_dataObject(event
.m_dataObject
),
775 m_dataFormat(event
.m_dataFormat
),
776 m_dataBuffer(event
.m_dataBuffer
),
777 m_dataSize(event
.m_dataSize
)
781 wxDataViewItem
GetItem() const { return m_item
; }
782 void SetItem( const wxDataViewItem
&item
) { m_item
= item
; }
784 int GetColumn() const { return m_col
; }
785 void SetColumn( int col
) { m_col
= col
; }
787 wxDataViewModel
* GetModel() const { return m_model
; }
788 void SetModel( wxDataViewModel
*model
) { m_model
= model
; }
790 const wxVariant
&GetValue() const { return m_value
; }
791 void SetValue( const wxVariant
&value
) { m_value
= value
; }
793 // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only
794 void SetDataViewColumn( wxDataViewColumn
*col
) { m_column
= col
; }
795 wxDataViewColumn
*GetDataViewColumn() const { return m_column
; }
797 // for wxEVT_DATAVIEW_CONTEXT_MENU only
798 wxPoint
GetPosition() const { return m_pos
; }
799 void SetPosition( int x
, int y
) { m_pos
.x
= x
; m_pos
.y
= y
; }
801 #if wxUSE_DRAG_AND_DROP
802 // For drag operations
803 void SetDataObject( wxDataObject
*obj
) { m_dataObject
= obj
; }
804 wxDataObject
*GetDataObject() const { return m_dataObject
; }
806 // For drop operations
807 void SetDataFormat( const wxDataFormat
&format
) { m_dataFormat
= format
; }
808 wxDataFormat
GetDataFormat() const { return m_dataFormat
; }
809 void SetDataSize( size_t size
) { m_dataSize
= size
; }
810 size_t GetDataSize() const { return m_dataSize
; }
811 void SetDataBuffer( void* buf
) { m_dataBuffer
= buf
;}
812 void *GetDataBuffer() const { return m_dataBuffer
; }
813 #endif // wxUSE_DRAG_AND_DROP
815 virtual wxEvent
*Clone() const { return new wxDataViewEvent(*this); }
818 wxDataViewItem m_item
;
820 wxDataViewModel
*m_model
;
822 wxDataViewColumn
*m_column
;
825 #if wxUSE_DRAG_AND_DROP
826 wxDataObject
*m_dataObject
;
828 wxDataFormat m_dataFormat
;
831 #endif // wxUSE_DRAG_AND_DROP
834 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent
)
837 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED
, wxDataViewEvent
);
839 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED
, wxDataViewEvent
);
840 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED
, wxDataViewEvent
);
841 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED
, wxDataViewEvent
);
842 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING
, wxDataViewEvent
);
843 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING
, wxDataViewEvent
);
844 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING
, wxDataViewEvent
);
845 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED
, wxDataViewEvent
);
846 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE
, wxDataViewEvent
);
847 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED
, wxDataViewEvent
);
849 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU
, wxDataViewEvent
);
851 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK
, wxDataViewEvent
);
852 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK
, wxDataViewEvent
);
853 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED
, wxDataViewEvent
);
854 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED
, wxDataViewEvent
);
856 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG
, wxDataViewEvent
);
857 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE
, wxDataViewEvent
);
858 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_DROP
, wxDataViewEvent
);
860 typedef void (wxEvtHandler::*wxDataViewEventFunction
)(wxDataViewEvent
&);
862 #define wxDataViewEventHandler(func) \
863 wxEVENT_HANDLER_CAST(wxDataViewEventFunction, func)
865 #define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \
866 wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn))
868 #define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn)
870 #define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn)
871 #define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn)
872 #define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn)
873 #define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn)
874 #define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn)
875 #define EVT_DATAVIEW_ITEM_START_EDITING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_START_EDITING, id, fn)
876 #define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn)
877 #define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn)
878 #define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn)
880 #define EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_CONTEXT_MENU, id, fn)
882 #define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn)
883 #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn)
884 #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn)
885 #define EVT_DATAVIEW_COLUMN_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_REORDERED, id, fn)
887 #define EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_BEGIN_DRAG, id, fn)
888 #define EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP_POSSIBLE, id, fn)
889 #define EVT_DATAVIEW_ITEM_DROP(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP, id, fn)
891 #ifdef wxHAS_GENERIC_DATAVIEWCTRL
892 // this symbol doesn't follow the convention for wxUSE_XXX symbols which
893 // are normally always defined as either 0 or 1, so its use is deprecated
894 // and it only exists for backwards compatibility, don't use it any more
895 // and use wxHAS_GENERIC_DATAVIEWCTRL instead
896 #define wxUSE_GENERICDATAVIEWCTRL
898 #include "wx/generic/dataview.h"
899 #elif defined(__WXGTK20__)
900 #include "wx/gtk/dataview.h"
901 #elif defined(__WXMAC__)
902 #include "wx/osx/dataview.h"
904 #error "unknown native wxDataViewCtrl implementation"
907 // -------------------------------------
908 // wxDataViewSpinRenderer
909 // -------------------------------------
911 class WXDLLIMPEXP_ADV wxDataViewSpinRenderer
: public wxDataViewCustomRenderer
914 wxDataViewSpinRenderer( int min
, int max
,
915 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
916 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
917 virtual bool HasEditorCtrl() const { return true; }
918 virtual wxControl
* CreateEditorCtrl( wxWindow
*parent
, wxRect labelRect
, const wxVariant
&value
);
919 virtual bool GetValueFromEditorCtrl( wxControl
* editor
, wxVariant
&value
);
920 virtual bool Render( wxRect rect
, wxDC
*dc
, int state
);
921 virtual wxSize
GetSize() const;
922 virtual bool SetValue( const wxVariant
&value
);
923 virtual bool GetValue( wxVariant
&value
) const;
930 #if defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXOSX_CARBON__)
932 // -------------------------------------
933 // wxDataViewChoiceRenderer
934 // -------------------------------------
936 class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer
: public wxDataViewCustomRenderer
939 wxDataViewChoiceRenderer( const wxArrayString
&choices
,
940 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
941 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
942 virtual bool HasEditorCtrl() const { return true; }
943 virtual wxControl
* CreateEditorCtrl( wxWindow
*parent
, wxRect labelRect
, const wxVariant
&value
);
944 virtual bool GetValueFromEditorCtrl( wxControl
* editor
, wxVariant
&value
);
945 virtual bool Render( wxRect rect
, wxDC
*dc
, int state
);
946 virtual wxSize
GetSize() const;
947 virtual bool SetValue( const wxVariant
&value
);
948 virtual bool GetValue( wxVariant
&value
) const;
951 wxArrayString m_choices
;
957 //-----------------------------------------------------------------------------
958 // wxDataViewListStore
959 //-----------------------------------------------------------------------------
961 class WXDLLIMPEXP_ADV wxDataViewListStoreLine
964 wxDataViewListStoreLine( wxClientData
*data
= NULL
)
968 virtual ~wxDataViewListStoreLine()
973 void SetData( wxClientData
*data
)
974 { if (m_data
) delete m_data
; m_data
= data
; }
975 wxClientData
*GetData() const
978 wxVector
<wxVariant
> m_values
;
981 wxClientData
*m_data
;
985 class WXDLLIMPEXP_ADV wxDataViewListStore
: public wxDataViewIndexListModel
988 wxDataViewListStore();
989 ~wxDataViewListStore();
991 void PrependColumn( const wxString
&varianttype
);
992 void InsertColumn( unsigned int pos
, const wxString
&varianttype
);
993 void AppendColumn( const wxString
&varianttype
);
995 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
996 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
997 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
998 void DeleteItem( unsigned int pos
);
999 void DeleteAllItems();
1001 // override base virtuals
1003 virtual unsigned int GetColumnCount() const;
1005 virtual wxString
GetColumnType( unsigned int col
) const;
1007 virtual void GetValueByRow( wxVariant
&value
,
1008 unsigned int row
, unsigned int col
) const;
1010 virtual bool SetValueByRow( const wxVariant
&value
,
1011 unsigned int row
, unsigned int col
);
1015 wxVector
<wxDataViewListStoreLine
*> m_data
;
1016 wxArrayString m_cols
;
1019 //-----------------------------------------------------------------------------
1021 class WXDLLIMPEXP_ADV wxDataViewListCtrl
: public wxDataViewCtrl
1024 wxDataViewListCtrl();
1025 wxDataViewListCtrl( wxWindow
*parent
, wxWindowID id
,
1026 const wxPoint
& pos
= wxDefaultPosition
,
1027 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
1028 const wxValidator
& validator
= wxDefaultValidator
);
1029 ~wxDataViewListCtrl();
1031 bool Create( wxWindow
*parent
, wxWindowID id
,
1032 const wxPoint
& pos
= wxDefaultPosition
,
1033 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
1034 const wxValidator
& validator
= wxDefaultValidator
);
1036 wxDataViewListStore
*GetStore()
1037 { return (wxDataViewListStore
*) GetModel(); }
1038 const wxDataViewListStore
*GetStore() const
1039 { return (const wxDataViewListStore
*) GetModel(); }
1041 bool AppendColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
1042 bool PrependColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
1043 bool InsertColumn( unsigned int pos
, wxDataViewColumn
*column
, const wxString
&varianttype
);
1045 // overridden from base class
1046 virtual bool PrependColumn( wxDataViewColumn
*col
);
1047 virtual bool InsertColumn( unsigned int pos
, wxDataViewColumn
*col
);
1048 virtual bool AppendColumn( wxDataViewColumn
*col
);
1050 wxDataViewColumn
*AppendTextColumn( const wxString
&label
,
1051 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1052 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1053 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
,
1054 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
1055 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1056 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
,
1057 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1058 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1059 wxDataViewColumn
*AppendIconTextColumn( const wxString
&label
,
1060 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1061 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1063 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1064 { GetStore()->AppendItem( values
, data
); }
1065 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1066 { GetStore()->PrependItem( values
, data
); }
1067 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1068 { GetStore()->InsertItem( row
, values
, data
); }
1069 void DeleteItem( unsigned row
)
1070 { GetStore()->DeleteItem( row
); }
1071 void DeleteAllItems()
1072 { GetStore()->DeleteAllItems(); }
1074 void SetValue( const wxVariant
&value
, unsigned int row
, unsigned int col
)
1075 { GetStore()->SetValueByRow( value
, row
, col
);
1076 GetStore()->RowValueChanged( row
, col
); }
1077 void GetValue( wxVariant
&value
, unsigned int row
, unsigned int col
)
1078 { GetStore()->GetValueByRow( value
, row
, col
); }
1080 void SetTextValue( const wxString
&value
, unsigned int row
, unsigned int col
)
1081 { GetStore()->SetValueByRow( value
, row
, col
);
1082 GetStore()->RowValueChanged( row
, col
); }
1083 wxString
GetTextValue( unsigned int row
, unsigned int col
) const
1084 { wxVariant value
; GetStore()->GetValueByRow( value
, row
, col
); return value
.GetString(); }
1086 void SetToggleValue( bool value
, unsigned int row
, unsigned int col
)
1087 { GetStore()->SetValueByRow( value
, row
, col
);
1088 GetStore()->RowValueChanged( row
, col
); }
1089 bool GetToggleValue( unsigned int row
, unsigned int col
) const
1090 { wxVariant value
; GetStore()->GetValueByRow( value
, row
, col
); return value
.GetBool(); }
1092 void OnSize( wxSizeEvent
&event
);
1095 DECLARE_EVENT_TABLE()
1096 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewListCtrl
)
1099 //-----------------------------------------------------------------------------
1100 // wxDataViewTreeStore
1101 //-----------------------------------------------------------------------------
1103 class WXDLLIMPEXP_ADV wxDataViewTreeStoreNode
1106 wxDataViewTreeStoreNode( wxDataViewTreeStoreNode
*parent
,
1107 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1108 virtual ~wxDataViewTreeStoreNode();
1110 void SetText( const wxString
&text
)
1112 wxString
GetText() const
1114 void SetIcon( const wxIcon
&icon
)
1116 const wxIcon
&GetIcon() const
1118 void SetData( wxClientData
*data
)
1119 { if (m_data
) delete m_data
; m_data
= data
; }
1120 wxClientData
*GetData() const
1123 wxDataViewItem
GetItem() const
1124 { return wxDataViewItem( (void*) this ); }
1126 virtual bool IsContainer()
1129 wxDataViewTreeStoreNode
*GetParent()
1130 { return m_parent
; }
1133 wxDataViewTreeStoreNode
*m_parent
;
1136 wxClientData
*m_data
;
1139 WX_DECLARE_LIST_WITH_DECL(wxDataViewTreeStoreNode
, wxDataViewTreeStoreNodeList
,
1140 class WXDLLIMPEXP_ADV
);
1142 class WXDLLIMPEXP_ADV wxDataViewTreeStoreContainerNode
: public wxDataViewTreeStoreNode
1145 wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode
*parent
,
1146 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1147 wxClientData
*data
= NULL
);
1148 virtual ~wxDataViewTreeStoreContainerNode();
1150 const wxDataViewTreeStoreNodeList
&GetChildren() const
1151 { return m_children
; }
1152 wxDataViewTreeStoreNodeList
&GetChildren()
1153 { return m_children
; }
1155 void SetExpandedIcon( const wxIcon
&icon
)
1156 { m_iconExpanded
= icon
; }
1157 const wxIcon
&GetExpandedIcon() const
1158 { return m_iconExpanded
; }
1160 void SetExpanded( bool expanded
= true )
1161 { m_isExpanded
= expanded
; }
1162 bool IsExpanded() const
1163 { return m_isExpanded
; }
1165 virtual bool IsContainer()
1169 wxDataViewTreeStoreNodeList m_children
;
1170 wxIcon m_iconExpanded
;
1174 //-----------------------------------------------------------------------------
1176 class WXDLLIMPEXP_ADV wxDataViewTreeStore
: public wxDataViewModel
1179 wxDataViewTreeStore();
1180 ~wxDataViewTreeStore();
1182 wxDataViewItem
AppendItem( const wxDataViewItem
& parent
,
1183 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1184 wxDataViewItem
PrependItem( const wxDataViewItem
& parent
,
1185 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1186 wxDataViewItem
InsertItem( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1187 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1189 wxDataViewItem
PrependContainer( const wxDataViewItem
& parent
,
1190 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1191 wxClientData
*data
= NULL
);
1192 wxDataViewItem
AppendContainer( const wxDataViewItem
& parent
,
1193 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1194 wxClientData
*data
= NULL
);
1195 wxDataViewItem
InsertContainer( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1196 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1197 wxClientData
*data
= NULL
);
1199 wxDataViewItem
GetNthChild( const wxDataViewItem
& parent
, unsigned int pos
) const;
1200 int GetChildCount( const wxDataViewItem
& parent
) const;
1202 void SetItemText( const wxDataViewItem
& item
, const wxString
&text
);
1203 wxString
GetItemText( const wxDataViewItem
& item
) const;
1204 void SetItemIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1205 const wxIcon
&GetItemIcon( const wxDataViewItem
& item
) const;
1206 void SetItemExpandedIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1207 const wxIcon
&GetItemExpandedIcon( const wxDataViewItem
& item
) const;
1208 void SetItemData( const wxDataViewItem
& item
, wxClientData
*data
);
1209 wxClientData
*GetItemData( const wxDataViewItem
& item
) const;
1211 void DeleteItem( const wxDataViewItem
& item
);
1212 void DeleteChildren( const wxDataViewItem
& item
);
1213 void DeleteAllItems();
1215 // implement base methods
1217 virtual void GetValue( wxVariant
&variant
,
1218 const wxDataViewItem
&item
, unsigned int col
) const;
1219 virtual bool SetValue( const wxVariant
&variant
,
1220 const wxDataViewItem
&item
, unsigned int col
);
1221 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const;
1222 virtual bool IsContainer( const wxDataViewItem
&item
) const;
1223 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
1225 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
1226 unsigned int column
, bool ascending
) const;
1228 virtual bool HasDefaultCompare() const
1230 virtual unsigned int GetColumnCount() const
1232 virtual wxString
GetColumnType( unsigned int WXUNUSED(col
) ) const
1233 { return wxT("wxDataViewIconText"); }
1235 wxDataViewTreeStoreNode
*FindNode( const wxDataViewItem
&item
) const;
1236 wxDataViewTreeStoreContainerNode
*FindContainerNode( const wxDataViewItem
&item
) const;
1237 wxDataViewTreeStoreNode
*GetRoot() const { return m_root
; }
1240 wxDataViewTreeStoreNode
*m_root
;
1243 //-----------------------------------------------------------------------------
1245 class WXDLLIMPEXP_ADV wxDataViewTreeCtrl
: public wxDataViewCtrl
1248 wxDataViewTreeCtrl();
1249 wxDataViewTreeCtrl( wxWindow
*parent
, wxWindowID id
,
1250 const wxPoint
& pos
= wxDefaultPosition
,
1251 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
1252 const wxValidator
& validator
= wxDefaultValidator
);
1253 ~wxDataViewTreeCtrl();
1255 bool Create( wxWindow
*parent
, wxWindowID id
,
1256 const wxPoint
& pos
= wxDefaultPosition
,
1257 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
1258 const wxValidator
& validator
= wxDefaultValidator
);
1260 wxDataViewTreeStore
*GetStore()
1261 { return (wxDataViewTreeStore
*) GetModel(); }
1262 const wxDataViewTreeStore
*GetStore() const
1263 { return (const wxDataViewTreeStore
*) GetModel(); }
1265 void SetImageList( wxImageList
*imagelist
);
1266 wxImageList
* GetImageList() { return m_imageList
; }
1268 wxDataViewItem
AppendItem( const wxDataViewItem
& parent
,
1269 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1270 wxDataViewItem
PrependItem( const wxDataViewItem
& parent
,
1271 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1272 wxDataViewItem
InsertItem( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1273 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1275 wxDataViewItem
PrependContainer( const wxDataViewItem
& parent
,
1276 const wxString
&text
, int icon
= -1, int expanded
= -1,
1277 wxClientData
*data
= NULL
);
1278 wxDataViewItem
AppendContainer( const wxDataViewItem
& parent
,
1279 const wxString
&text
, int icon
= -1, int expanded
= -1,
1280 wxClientData
*data
= NULL
);
1281 wxDataViewItem
InsertContainer( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1282 const wxString
&text
, int icon
= -1, int expanded
= -1,
1283 wxClientData
*data
= NULL
);
1285 wxDataViewItem
GetNthChild( const wxDataViewItem
& parent
, unsigned int pos
) const
1286 { return GetStore()->GetNthChild(parent
, pos
); }
1287 int GetChildCount( const wxDataViewItem
& parent
) const
1288 { return GetStore()->GetChildCount(parent
); }
1290 void SetItemText( const wxDataViewItem
& item
, const wxString
&text
);
1291 wxString
GetItemText( const wxDataViewItem
& item
) const
1292 { return GetStore()->GetItemText(item
); }
1293 void SetItemIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1294 const wxIcon
&GetItemIcon( const wxDataViewItem
& item
) const
1295 { return GetStore()->GetItemIcon(item
); }
1296 void SetItemExpandedIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1297 const wxIcon
&GetItemExpandedIcon( const wxDataViewItem
& item
) const
1298 { return GetStore()->GetItemExpandedIcon(item
); }
1299 void SetItemData( const wxDataViewItem
& item
, wxClientData
*data
)
1300 { GetStore()->SetItemData(item
,data
); }
1301 wxClientData
*GetItemData( const wxDataViewItem
& item
) const
1302 { return GetStore()->GetItemData(item
); }
1304 void DeleteItem( const wxDataViewItem
& item
);
1305 void DeleteChildren( const wxDataViewItem
& item
);
1306 void DeleteAllItems();
1308 void OnExpanded( wxDataViewEvent
&event
);
1309 void OnCollapsed( wxDataViewEvent
&event
);
1310 void OnSize( wxSizeEvent
&event
);
1313 wxImageList
*m_imageList
;
1316 DECLARE_EVENT_TABLE()
1317 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl
)
1320 #endif // wxUSE_DATAVIEWCTRL
1323 // _WX_DATAVIEW_H_BASE_