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 // define DnD capabilities
197 virtual bool IsDraggable( const wxDataViewItem
&WXUNUSED(item
) )
199 virtual size_t GetDragDataSize( const wxDataViewItem
&WXUNUSED(item
), const wxDataFormat
&WXUNUSED(format
) )
201 virtual bool GetDragData( const wxDataViewItem
&WXUNUSED(item
), const wxDataFormat
&WXUNUSED(format
),
202 void* WXUNUSED(data
), size_t WXUNUSED(size
) )
205 // delegated notifiers
206 virtual bool ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
207 virtual bool ItemsAdded( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
208 virtual bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
209 virtual bool ItemsDeleted( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
210 virtual bool ItemChanged( const wxDataViewItem
&item
);
211 virtual bool ItemsChanged( const wxDataViewItemArray
&items
);
212 virtual bool ValueChanged( const wxDataViewItem
&item
, unsigned int col
);
213 virtual bool Cleared();
216 virtual void Resort();
218 void AddNotifier( wxDataViewModelNotifier
*notifier
);
219 void RemoveNotifier( wxDataViewModelNotifier
*notifier
);
221 // default compare function
222 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
223 unsigned int column
, bool ascending
);
224 virtual bool HasDefaultCompare() const { return false; }
227 virtual bool IsVirtualListModel() const { return false; }
230 // the user should not delete this class directly: he should use DecRef() instead!
231 virtual ~wxDataViewModel() { }
233 wxDataViewModelNotifiers m_notifiers
;
236 // ---------------------------------------------------------
237 // wxDataViewIndexListModel
238 // ---------------------------------------------------------
240 class WXDLLIMPEXP_ADV wxDataViewIndexListModel
: public wxDataViewModel
243 wxDataViewIndexListModel( unsigned int initial_size
= 0 );
244 ~wxDataViewIndexListModel();
246 virtual void GetValueByRow( wxVariant
&variant
,
247 unsigned int row
, unsigned int col
) const = 0;
249 virtual bool SetValueByRow( const wxVariant
&variant
,
250 unsigned int row
, unsigned int col
) = 0;
252 virtual bool GetAttrByRow( unsigned int WXUNUSED(row
), unsigned int WXUNUSED(col
), wxDataViewItemAttr
&WXUNUSED(attr
) )
256 void RowInserted( unsigned int before
);
258 void RowDeleted( unsigned int row
);
259 void RowsDeleted( const wxArrayInt
&rows
);
260 void RowChanged( unsigned int row
);
261 void RowValueChanged( unsigned int row
, unsigned int col
);
262 void Reset( unsigned int new_size
);
264 // convert to/from row/wxDataViewItem
266 unsigned int GetRow( const wxDataViewItem
&item
) const;
267 wxDataViewItem
GetItem( unsigned int row
) const;
269 // compare based on index
271 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
272 unsigned int column
, bool ascending
);
273 virtual bool HasDefaultCompare() const;
275 // implement base methods
277 virtual void GetValue( wxVariant
&variant
,
278 const wxDataViewItem
&item
, unsigned int col
) const;
279 virtual bool SetValue( const wxVariant
&variant
,
280 const wxDataViewItem
&item
, unsigned int col
);
281 virtual bool GetAttr( const wxDataViewItem
&item
, unsigned int col
, wxDataViewItemAttr
&attr
);
282 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const;
283 virtual bool IsContainer( const wxDataViewItem
&item
) const;
284 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
287 virtual bool IsVirtualListModel() const { return false; }
288 unsigned int GetLastIndex() const { return m_lastIndex
; }
291 wxDataViewItemArray m_hash
;
292 unsigned int m_lastIndex
;
296 // ---------------------------------------------------------
297 // wxDataViewVirtualListModel
298 // ---------------------------------------------------------
301 // better than nothing
302 typedef wxDataViewIndexListModel wxDataViewVirtualListModel
;
305 class WXDLLIMPEXP_ADV wxDataViewVirtualListModel
: public wxDataViewModel
308 wxDataViewVirtualListModel( unsigned int initial_size
= 0 );
309 ~wxDataViewVirtualListModel();
311 virtual void GetValueByRow( wxVariant
&variant
,
312 unsigned int row
, unsigned int col
) const = 0;
314 virtual bool SetValueByRow( const wxVariant
&variant
,
315 unsigned int row
, unsigned int col
) = 0;
317 virtual bool GetAttrByRow( unsigned int WXUNUSED(row
), unsigned int WXUNUSED(col
), wxDataViewItemAttr
&WXUNUSED(attr
) )
321 void RowInserted( unsigned int before
);
323 void RowDeleted( unsigned int row
);
324 void RowsDeleted( const wxArrayInt
&rows
);
325 void RowChanged( unsigned int row
);
326 void RowValueChanged( unsigned int row
, unsigned int col
);
327 void Reset( unsigned int new_size
);
329 // convert to/from row/wxDataViewItem
331 unsigned int GetRow( const wxDataViewItem
&item
) const;
332 wxDataViewItem
GetItem( unsigned int row
) const;
334 // compare based on index
336 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
337 unsigned int column
, bool ascending
);
338 virtual bool HasDefaultCompare() const;
340 // implement base methods
342 virtual void GetValue( wxVariant
&variant
,
343 const wxDataViewItem
&item
, unsigned int col
) const;
344 virtual bool SetValue( const wxVariant
&variant
,
345 const wxDataViewItem
&item
, unsigned int col
);
346 virtual bool GetAttr( const wxDataViewItem
&item
, unsigned int col
, wxDataViewItemAttr
&attr
);
347 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const;
348 virtual bool IsContainer( const wxDataViewItem
&item
) const;
349 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
352 virtual bool IsVirtualListModel() const { return true; }
353 unsigned int GetLastIndex() const { return m_lastIndex
; }
356 wxDataViewItemArray m_hash
;
357 unsigned int m_lastIndex
;
362 //-----------------------------------------------------------------------------
363 // wxDataViewEditorCtrlEvtHandler
364 //-----------------------------------------------------------------------------
366 class wxDataViewEditorCtrlEvtHandler
: public wxEvtHandler
369 wxDataViewEditorCtrlEvtHandler( wxControl
*editor
, wxDataViewRenderer
*owner
);
371 void AcceptChangesAndFinish();
372 void SetFocusOnIdle( bool focus
= true ) { m_focusOnIdle
= focus
; }
375 void OnChar( wxKeyEvent
&event
);
376 void OnTextEnter( wxCommandEvent
&event
);
377 void OnKillFocus( wxFocusEvent
&event
);
378 void OnIdle( wxIdleEvent
&event
);
381 wxDataViewRenderer
*m_owner
;
382 wxControl
*m_editorCtrl
;
387 DECLARE_EVENT_TABLE()
390 // ---------------------------------------------------------
391 // wxDataViewRendererBase
392 // ---------------------------------------------------------
394 enum wxDataViewCellMode
396 wxDATAVIEW_CELL_INERT
,
397 wxDATAVIEW_CELL_ACTIVATABLE
,
398 wxDATAVIEW_CELL_EDITABLE
401 enum wxDataViewCellRenderState
403 wxDATAVIEW_CELL_SELECTED
= 1,
404 wxDATAVIEW_CELL_PRELIT
= 2,
405 wxDATAVIEW_CELL_INSENSITIVE
= 4,
406 wxDATAVIEW_CELL_FOCUSED
= 8
409 class WXDLLIMPEXP_ADV wxDataViewRendererBase
: public wxObject
412 wxDataViewRendererBase( const wxString
&varianttype
,
413 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
414 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
415 ~wxDataViewRendererBase();
417 virtual bool Validate( wxVariant
& WXUNUSED(value
) )
420 void SetOwner( wxDataViewColumn
*owner
) { m_owner
= owner
; }
421 wxDataViewColumn
* GetOwner() const { return m_owner
; }
423 // renderer properties:
425 virtual bool SetValue( const wxVariant
& WXUNUSED(value
) ) = 0;
426 virtual bool GetValue( wxVariant
& WXUNUSED(value
) ) const = 0;
428 wxString
GetVariantType() const { return m_variantType
; }
430 virtual void SetMode( wxDataViewCellMode mode
) = 0;
431 virtual wxDataViewCellMode
GetMode() const = 0;
433 // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but
434 // rather an "int"; that's because for rendering cells it's allowed
435 // to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM)
436 virtual void SetAlignment( int align
) = 0;
437 virtual int GetAlignment() const = 0;
440 virtual bool HasEditorCtrl()
442 virtual wxControl
* CreateEditorCtrl(wxWindow
* WXUNUSED(parent
),
443 wxRect
WXUNUSED(labelRect
),
444 const wxVariant
& WXUNUSED(value
))
446 virtual bool GetValueFromEditorCtrl(wxControl
* WXUNUSED(editor
),
447 wxVariant
& WXUNUSED(value
))
450 virtual bool StartEditing( const wxDataViewItem
&item
, wxRect labelRect
);
451 virtual void CancelEditing();
452 virtual bool FinishEditing();
454 wxControl
*GetEditorCtrl() { return m_editorCtrl
; }
457 wxString m_variantType
;
458 wxDataViewColumn
*m_owner
;
459 wxWeakRef
<wxControl
> m_editorCtrl
;
460 wxDataViewItem m_item
; // for m_editorCtrl
463 const wxDataViewCtrl
* GetView() const;
466 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase
)
469 //-----------------------------------------------------------------------------
470 // wxDataViewIconText
471 //-----------------------------------------------------------------------------
473 class WXDLLIMPEXP_ADV wxDataViewIconText
: public wxObject
476 wxDataViewIconText( const wxString
&text
= wxEmptyString
, const wxIcon
& icon
= wxNullIcon
)
477 : m_text(text
), m_icon(icon
)
479 wxDataViewIconText( const wxDataViewIconText
&other
)
481 { m_icon
= other
.m_icon
; m_text
= other
.m_text
; }
483 void SetText( const wxString
&text
) { m_text
= text
; }
484 wxString
GetText() const { return m_text
; }
485 void SetIcon( const wxIcon
&icon
) { m_icon
= icon
; }
486 const wxIcon
&GetIcon() const { return m_icon
; }
493 DECLARE_DYNAMIC_CLASS(wxDataViewIconText
)
496 bool operator == (const wxDataViewIconText
&one
, const wxDataViewIconText
&two
);
498 DECLARE_VARIANT_OBJECT_EXPORTED(wxDataViewIconText
, WXDLLIMPEXP_ADV
)
500 // ---------------------------------------------------------
501 // wxDataViewColumnBase
502 // ---------------------------------------------------------
504 // for compatibility only, do not use
505 enum wxDataViewColumnFlags
507 wxDATAVIEW_COL_RESIZABLE
= wxCOL_RESIZABLE
,
508 wxDATAVIEW_COL_SORTABLE
= wxCOL_SORTABLE
,
509 wxDATAVIEW_COL_REORDERABLE
= wxCOL_REORDERABLE
,
510 wxDATAVIEW_COL_HIDDEN
= wxCOL_HIDDEN
513 class WXDLLIMPEXP_ADV wxDataViewColumnBase
: public wxSettableHeaderColumn
516 // ctor for the text columns: takes ownership of renderer
517 wxDataViewColumnBase(wxDataViewRenderer
*renderer
,
518 unsigned int model_column
)
520 Init(renderer
, model_column
);
523 // ctor for the bitmap columns
524 wxDataViewColumnBase(const wxBitmap
& bitmap
,
525 wxDataViewRenderer
*renderer
,
526 unsigned int model_column
)
529 Init(renderer
, model_column
);
532 virtual ~wxDataViewColumnBase();
535 virtual void SetOwner( wxDataViewCtrl
*owner
)
539 unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column
); }
540 wxDataViewCtrl
*GetOwner() const { return m_owner
; }
541 wxDataViewRenderer
* GetRenderer() const { return m_renderer
; }
543 // implement some of base class pure virtuals (the rest is port-dependent
544 // and done differently in generic and native versions)
545 virtual void SetBitmap( const wxBitmap
& bitmap
) { m_bitmap
= bitmap
; }
546 virtual wxBitmap
GetBitmap() const { return m_bitmap
; }
549 wxDataViewRenderer
*m_renderer
;
552 wxDataViewCtrl
*m_owner
;
555 // common part of all ctors
556 void Init(wxDataViewRenderer
*renderer
, unsigned int model_column
);
559 // ---------------------------------------------------------
560 // wxDataViewCtrlBase
561 // ---------------------------------------------------------
563 #define wxDV_SINGLE 0x0000 // for convenience
564 #define wxDV_MULTIPLE 0x0001 // can select multiple items
566 #define wxDV_NO_HEADER 0x0002 // column titles not visible
567 #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows
568 #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns
570 #define wxDV_ROW_LINES 0x0010 // alternating colour in rows
571 #define wxDV_VARIABLE_LINE_HEIGHT 0x0020 // variable line height
573 class WXDLLIMPEXP_ADV wxDataViewCtrlBase
: public wxControl
576 wxDataViewCtrlBase();
577 virtual ~wxDataViewCtrlBase();
579 virtual bool AssociateModel( wxDataViewModel
*model
);
580 wxDataViewModel
* GetModel();
581 const wxDataViewModel
* GetModel() const;
584 wxDataViewColumn
*PrependTextColumn( const wxString
&label
, unsigned int model_column
,
585 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
586 wxAlignment align
= wxALIGN_NOT
,
587 int flags
= wxDATAVIEW_COL_RESIZABLE
);
588 wxDataViewColumn
*PrependIconTextColumn( const wxString
&label
, unsigned int model_column
,
589 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
590 wxAlignment align
= wxALIGN_NOT
,
591 int flags
= wxDATAVIEW_COL_RESIZABLE
);
592 wxDataViewColumn
*PrependToggleColumn( const wxString
&label
, unsigned int model_column
,
593 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
594 wxAlignment align
= wxALIGN_CENTER
,
595 int flags
= wxDATAVIEW_COL_RESIZABLE
);
596 wxDataViewColumn
*PrependProgressColumn( const wxString
&label
, unsigned int model_column
,
597 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
598 wxAlignment align
= wxALIGN_CENTER
,
599 int flags
= wxDATAVIEW_COL_RESIZABLE
);
600 wxDataViewColumn
*PrependDateColumn( const wxString
&label
, unsigned int model_column
,
601 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
602 wxAlignment align
= wxALIGN_NOT
,
603 int flags
= wxDATAVIEW_COL_RESIZABLE
);
604 wxDataViewColumn
*PrependBitmapColumn( const wxString
&label
, unsigned int model_column
,
605 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
606 wxAlignment align
= wxALIGN_CENTER
,
607 int flags
= wxDATAVIEW_COL_RESIZABLE
);
608 wxDataViewColumn
*PrependTextColumn( const wxBitmap
&label
, unsigned int model_column
,
609 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
610 wxAlignment align
= wxALIGN_NOT
,
611 int flags
= wxDATAVIEW_COL_RESIZABLE
);
612 wxDataViewColumn
*PrependIconTextColumn( const wxBitmap
&label
, unsigned int model_column
,
613 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
614 wxAlignment align
= wxALIGN_NOT
,
615 int flags
= wxDATAVIEW_COL_RESIZABLE
);
616 wxDataViewColumn
*PrependToggleColumn( const wxBitmap
&label
, unsigned int model_column
,
617 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
618 wxAlignment align
= wxALIGN_CENTER
,
619 int flags
= wxDATAVIEW_COL_RESIZABLE
);
620 wxDataViewColumn
*PrependProgressColumn( const wxBitmap
&label
, unsigned int model_column
,
621 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
622 wxAlignment align
= wxALIGN_CENTER
,
623 int flags
= wxDATAVIEW_COL_RESIZABLE
);
624 wxDataViewColumn
*PrependDateColumn( const wxBitmap
&label
, unsigned int model_column
,
625 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
626 wxAlignment align
= wxALIGN_NOT
,
627 int flags
= wxDATAVIEW_COL_RESIZABLE
);
628 wxDataViewColumn
*PrependBitmapColumn( const wxBitmap
&label
, unsigned int model_column
,
629 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
630 wxAlignment align
= wxALIGN_CENTER
,
631 int flags
= wxDATAVIEW_COL_RESIZABLE
);
633 wxDataViewColumn
*AppendTextColumn( const wxString
&label
, unsigned int model_column
,
634 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
635 wxAlignment align
= wxALIGN_NOT
,
636 int flags
= wxDATAVIEW_COL_RESIZABLE
);
637 wxDataViewColumn
*AppendIconTextColumn( const wxString
&label
, unsigned int model_column
,
638 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
639 wxAlignment align
= wxALIGN_NOT
,
640 int flags
= wxDATAVIEW_COL_RESIZABLE
);
641 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
, unsigned int model_column
,
642 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
643 wxAlignment align
= wxALIGN_CENTER
,
644 int flags
= wxDATAVIEW_COL_RESIZABLE
);
645 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
, unsigned int model_column
,
646 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
647 wxAlignment align
= wxALIGN_CENTER
,
648 int flags
= wxDATAVIEW_COL_RESIZABLE
);
649 wxDataViewColumn
*AppendDateColumn( const wxString
&label
, unsigned int model_column
,
650 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
651 wxAlignment align
= wxALIGN_NOT
,
652 int flags
= wxDATAVIEW_COL_RESIZABLE
);
653 wxDataViewColumn
*AppendBitmapColumn( const wxString
&label
, unsigned int model_column
,
654 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
655 wxAlignment align
= wxALIGN_CENTER
,
656 int flags
= wxDATAVIEW_COL_RESIZABLE
);
657 wxDataViewColumn
*AppendTextColumn( const wxBitmap
&label
, unsigned int model_column
,
658 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
659 wxAlignment align
= wxALIGN_NOT
,
660 int flags
= wxDATAVIEW_COL_RESIZABLE
);
661 wxDataViewColumn
*AppendIconTextColumn( const wxBitmap
&label
, unsigned int model_column
,
662 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
663 wxAlignment align
= wxALIGN_NOT
,
664 int flags
= wxDATAVIEW_COL_RESIZABLE
);
665 wxDataViewColumn
*AppendToggleColumn( const wxBitmap
&label
, unsigned int model_column
,
666 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_TOGGLE_DEFAULT_WIDTH
,
667 wxAlignment align
= wxALIGN_CENTER
,
668 int flags
= wxDATAVIEW_COL_RESIZABLE
);
669 wxDataViewColumn
*AppendProgressColumn( const wxBitmap
&label
, unsigned int model_column
,
670 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= wxDVC_DEFAULT_WIDTH
,
671 wxAlignment align
= wxALIGN_CENTER
,
672 int flags
= wxDATAVIEW_COL_RESIZABLE
);
673 wxDataViewColumn
*AppendDateColumn( const wxBitmap
&label
, unsigned int model_column
,
674 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
, int width
= -1,
675 wxAlignment align
= wxALIGN_NOT
,
676 int flags
= wxDATAVIEW_COL_RESIZABLE
);
677 wxDataViewColumn
*AppendBitmapColumn( const wxBitmap
&label
, unsigned int model_column
,
678 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
, int width
= -1,
679 wxAlignment align
= wxALIGN_CENTER
,
680 int flags
= wxDATAVIEW_COL_RESIZABLE
);
683 virtual bool PrependColumn( wxDataViewColumn
*col
);
684 virtual bool InsertColumn( unsigned int pos
, wxDataViewColumn
*col
);
685 virtual bool AppendColumn( wxDataViewColumn
*col
);
687 virtual unsigned int GetColumnCount() const = 0;
688 virtual wxDataViewColumn
* GetColumn( unsigned int pos
) const = 0;
689 virtual int GetColumnPosition( const wxDataViewColumn
*column
) const = 0;
691 virtual bool DeleteColumn( wxDataViewColumn
*column
) = 0;
692 virtual bool ClearColumns() = 0;
694 void SetExpanderColumn( wxDataViewColumn
*col
)
695 { m_expander_column
= col
; DoSetExpanderColumn(); }
696 wxDataViewColumn
*GetExpanderColumn() const
697 { return m_expander_column
; }
699 virtual wxDataViewColumn
*GetSortingColumn() const = 0;
701 void SetIndent( int indent
)
702 { m_indent
= indent
; DoSetIndent(); }
703 int GetIndent() const
706 virtual wxDataViewItem
GetSelection() const = 0;
707 virtual int GetSelections( wxDataViewItemArray
& sel
) const = 0;
708 virtual void SetSelections( const wxDataViewItemArray
& sel
) = 0;
709 virtual void Select( const wxDataViewItem
& item
) = 0;
710 virtual void Unselect( const wxDataViewItem
& item
) = 0;
711 virtual bool IsSelected( const wxDataViewItem
& item
) const = 0;
713 virtual void SelectAll() = 0;
714 virtual void UnselectAll() = 0;
716 virtual void Expand( const wxDataViewItem
& item
) = 0;
717 virtual void ExpandAncestors( const wxDataViewItem
& item
);
718 virtual void Collapse( const wxDataViewItem
& item
) = 0;
719 virtual bool IsExpanded( const wxDataViewItem
& item
) const = 0;
721 virtual void EnsureVisible( const wxDataViewItem
& item
,
722 const wxDataViewColumn
*column
= NULL
) = 0;
723 virtual void HitTest( const wxPoint
& point
, wxDataViewItem
&item
, wxDataViewColumn
* &column
) const = 0;
724 virtual wxRect
GetItemRect( const wxDataViewItem
& item
, const wxDataViewColumn
*column
= NULL
) const = 0;
727 virtual void DoSetExpanderColumn() = 0 ;
728 virtual void DoSetIndent() = 0;
731 wxDataViewModel
*m_model
;
732 wxDataViewColumn
*m_expander_column
;
736 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase
)
739 // ----------------------------------------------------------------------------
740 // wxDataViewEvent - the event class for the wxDataViewCtrl notifications
741 // ----------------------------------------------------------------------------
743 class WXDLLIMPEXP_ADV wxDataViewEvent
: public wxNotifyEvent
746 wxDataViewEvent(wxEventType commandType
= wxEVT_NULL
, int winid
= 0)
747 : wxNotifyEvent(commandType
, winid
),
751 m_value(wxNullVariant
),
756 wxDataViewEvent(const wxDataViewEvent
& event
)
757 : wxNotifyEvent(event
),
758 m_item(event
.m_item
),
760 m_model(event
.m_model
),
761 m_value(event
.m_value
),
762 m_column(event
.m_column
),
766 wxDataViewItem
GetItem() const { return m_item
; }
767 void SetItem( const wxDataViewItem
&item
) { m_item
= item
; }
769 int GetColumn() const { return m_col
; }
770 void SetColumn( int col
) { m_col
= col
; }
772 wxDataViewModel
* GetModel() const { return m_model
; }
773 void SetModel( wxDataViewModel
*model
) { m_model
= model
; }
775 const wxVariant
&GetValue() const { return m_value
; }
776 void SetValue( const wxVariant
&value
) { m_value
= value
; }
778 // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only
779 void SetDataViewColumn( wxDataViewColumn
*col
) { m_column
= col
; }
780 wxDataViewColumn
*GetDataViewColumn() const { return m_column
; }
782 // for wxEVT_DATAVIEW_CONTEXT_MENU only
783 wxPoint
GetPosition() const { return m_pos
; }
784 void SetPosition( int x
, int y
) { m_pos
.x
= x
; m_pos
.y
= y
; }
786 virtual wxEvent
*Clone() const { return new wxDataViewEvent(*this); }
789 wxDataViewItem m_item
;
791 wxDataViewModel
*m_model
;
793 wxDataViewColumn
*m_column
;
797 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent
)
800 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED
, wxDataViewEvent
)
802 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED
, wxDataViewEvent
)
803 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED
, wxDataViewEvent
)
804 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED
, wxDataViewEvent
)
805 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING
, wxDataViewEvent
)
806 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING
, wxDataViewEvent
)
807 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED
, wxDataViewEvent
)
808 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE
, wxDataViewEvent
)
809 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED
, wxDataViewEvent
)
811 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU
, wxDataViewEvent
)
813 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK
, wxDataViewEvent
)
814 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK
, wxDataViewEvent
)
815 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED
, wxDataViewEvent
)
816 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED
, wxDataViewEvent
)
818 typedef void (wxEvtHandler::*wxDataViewEventFunction
)(wxDataViewEvent
&);
820 #define wxDataViewEventHandler(func) \
821 wxEVENT_HANDLER_CAST(wxDataViewEventFunction, func)
823 #define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \
824 wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn))
826 #define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn)
828 #define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn)
829 #define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn)
830 #define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn)
831 #define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn)
832 #define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn)
833 #define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn)
834 #define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn)
835 #define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn)
837 #define EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_CONTEXT_MENU, id, fn)
839 #define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn)
840 #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn)
841 #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn)
842 #define EVT_DATAVIEW_COLUMN_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_REORDERED, id, fn)
845 #ifdef wxHAS_GENERIC_DATAVIEWCTRL
846 // this symbol doesn't follow the convention for wxUSE_XXX symbols which
847 // are normally always defined as either 0 or 1, so its use is deprecated
848 // and it only exists for backwards compatibility, don't use it any more
849 // and use wxHAS_GENERIC_DATAVIEWCTRL instead
850 #define wxUSE_GENERICDATAVIEWCTRL
852 #include "wx/generic/dataview.h"
853 #elif defined(__WXGTK20__)
854 #include "wx/gtk/dataview.h"
855 #elif defined(__WXMAC__)
856 #include "wx/osx/dataview.h"
858 #error "unknown native wxDataViewCtrl implementation"
861 // -------------------------------------
862 // wxDataViewSpinRenderer
863 // -------------------------------------
865 class WXDLLIMPEXP_ADV wxDataViewSpinRenderer
: public wxDataViewCustomRenderer
868 wxDataViewSpinRenderer( int min
, int max
,
869 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
870 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
871 virtual bool HasEditorCtrl() { return true; }
872 virtual wxControl
* CreateEditorCtrl( wxWindow
*parent
, wxRect labelRect
, const wxVariant
&value
);
873 virtual bool GetValueFromEditorCtrl( wxControl
* editor
, wxVariant
&value
);
874 virtual bool Render( wxRect rect
, wxDC
*dc
, int state
);
875 virtual wxSize
GetSize() const;
876 virtual bool SetValue( const wxVariant
&value
);
877 virtual bool GetValue( wxVariant
&value
) const;
884 #if defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXMAC__)
886 // -------------------------------------
887 // wxDataViewChoiceRenderer
888 // -------------------------------------
890 class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer
: public wxDataViewCustomRenderer
893 wxDataViewChoiceRenderer( const wxArrayString
&choices
,
894 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
895 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
896 virtual bool HasEditorCtrl() { return true; }
897 virtual wxControl
* CreateEditorCtrl( wxWindow
*parent
, wxRect labelRect
, const wxVariant
&value
);
898 virtual bool GetValueFromEditorCtrl( wxControl
* editor
, wxVariant
&value
);
899 virtual bool Render( wxRect rect
, wxDC
*dc
, int state
);
900 virtual wxSize
GetSize() const;
901 virtual bool SetValue( const wxVariant
&value
);
902 virtual bool GetValue( wxVariant
&value
) const;
905 wxArrayString m_choices
;
911 //-----------------------------------------------------------------------------
912 // wxDataViewListStore
913 //-----------------------------------------------------------------------------
915 class WXDLLIMPEXP_ADV wxDataViewListStoreLine
918 wxDataViewListStoreLine( wxClientData
*data
= NULL
)
922 virtual ~wxDataViewListStoreLine()
927 void SetData( wxClientData
*data
)
928 { if (m_data
) delete m_data
; m_data
= data
; }
929 wxClientData
*GetData() const
932 wxVector
<wxVariant
> m_values
;
935 wxClientData
*m_data
;
939 class WXDLLIMPEXP_ADV wxDataViewListStore
: public wxDataViewIndexListModel
942 wxDataViewListStore();
943 ~wxDataViewListStore();
945 void PrependColumn( const wxString
&varianttype
);
946 void InsertColumn( unsigned int pos
, const wxString
&varianttype
);
947 void AppendColumn( const wxString
&varianttype
);
949 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
950 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
951 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
952 void DeleteItem( unsigned pos
);
953 void DeleteAllItems();
955 // override base virtuals
957 virtual unsigned int GetColumnCount() const;
959 virtual wxString
GetColumnType( unsigned int col
) const;
961 virtual void GetValueByRow( wxVariant
&value
,
962 unsigned int row
, unsigned int col
) const;
964 virtual bool SetValueByRow( const wxVariant
&value
,
965 unsigned int row
, unsigned int col
);
969 wxVector
<wxDataViewListStoreLine
*> m_data
;
970 wxArrayString m_cols
;
973 //-----------------------------------------------------------------------------
975 class WXDLLIMPEXP_ADV wxDataViewListCtrl
: public wxDataViewCtrl
978 wxDataViewListCtrl();
979 wxDataViewListCtrl( wxWindow
*parent
, wxWindowID id
,
980 const wxPoint
& pos
= wxDefaultPosition
,
981 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
982 const wxValidator
& validator
= wxDefaultValidator
);
983 ~wxDataViewListCtrl();
985 bool Create( wxWindow
*parent
, wxWindowID id
,
986 const wxPoint
& pos
= wxDefaultPosition
,
987 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
988 const wxValidator
& validator
= wxDefaultValidator
);
990 wxDataViewListStore
*GetStore()
991 { return (wxDataViewListStore
*) GetModel(); }
992 const wxDataViewListStore
*GetStore() const
993 { return (const wxDataViewListStore
*) GetModel(); }
995 void AppendCol( wxDataViewColumn
*column
, const wxString
&varianttype
);
996 void PrependCol( wxDataViewColumn
*column
, const wxString
&varianttype
);
997 void InsertCol( unsigned int pos
, wxDataViewColumn
*column
, const wxString
&varianttype
);
999 wxDataViewColumn
*AppendTextCol( const wxString
&label
,
1000 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1001 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1002 wxDataViewColumn
*AppendToggleCol( const wxString
&label
,
1003 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
1004 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1005 wxDataViewColumn
*AppendProgressCol( const wxString
&label
,
1006 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1007 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1008 wxDataViewColumn
*AppendIconTextCol( const wxString
&label
,
1009 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1010 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1012 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1013 { GetStore()->AppendItem( values
, data
); }
1014 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1015 { GetStore()->PrependItem( values
, data
); }
1016 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1017 { GetStore()->InsertItem( row
, values
, data
); }
1018 void DeleteItem( unsigned row
)
1019 { GetStore()->DeleteItem( row
); }
1020 void DeleteAllItems()
1021 { GetStore()->DeleteAllItems(); }
1023 void SetValue( const wxVariant
&value
, unsigned int row
, unsigned int col
)
1024 { GetStore()->SetValueByRow( value
, row
, col
);
1025 GetStore()->RowValueChanged( row
, col
); }
1026 void GetValue( wxVariant
&value
, unsigned int row
, unsigned int col
)
1027 { GetStore()->GetValueByRow( value
, row
, col
); }
1029 void SetTextValue( const wxString
&value
, unsigned int row
, unsigned int col
)
1030 { GetStore()->SetValueByRow( value
, row
, col
);
1031 GetStore()->RowValueChanged( row
, col
); }
1032 wxString
GetTextValue( unsigned int row
, unsigned int col
) const
1033 { wxVariant value
; GetStore()->GetValueByRow( value
, row
, col
); return value
.GetString(); }
1035 void SetToggleValue( bool value
, unsigned int row
, unsigned int col
)
1036 { GetStore()->SetValueByRow( value
, row
, col
);
1037 GetStore()->RowValueChanged( row
, col
); }
1038 bool GetToggleValue( unsigned int row
, unsigned int col
) const
1039 { wxVariant value
; GetStore()->GetValueByRow( value
, row
, col
); return value
.GetBool(); }
1041 void OnSize( wxSizeEvent
&event
);
1044 DECLARE_EVENT_TABLE()
1045 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewListCtrl
)
1048 //-----------------------------------------------------------------------------
1049 // wxDataViewTreeStore
1050 //-----------------------------------------------------------------------------
1052 class WXDLLIMPEXP_ADV wxDataViewTreeStoreNode
1055 wxDataViewTreeStoreNode( wxDataViewTreeStoreNode
*parent
,
1056 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1057 virtual ~wxDataViewTreeStoreNode();
1059 void SetText( const wxString
&text
)
1061 wxString
GetText() const
1063 void SetIcon( const wxIcon
&icon
)
1065 const wxIcon
&GetIcon() const
1067 void SetData( wxClientData
*data
)
1068 { if (m_data
) delete m_data
; m_data
= data
; }
1069 wxClientData
*GetData() const
1072 wxDataViewItem
GetItem() const
1073 { return wxDataViewItem( (void*) this ); }
1075 virtual bool IsContainer()
1078 wxDataViewTreeStoreNode
*GetParent()
1079 { return m_parent
; }
1082 wxDataViewTreeStoreNode
*m_parent
;
1085 wxClientData
*m_data
;
1088 WX_DECLARE_LIST_WITH_DECL(wxDataViewTreeStoreNode
, wxDataViewTreeStoreNodeList
,
1089 class WXDLLIMPEXP_ADV
);
1091 class WXDLLIMPEXP_ADV wxDataViewTreeStoreContainerNode
: public wxDataViewTreeStoreNode
1094 wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode
*parent
,
1095 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1096 wxClientData
*data
= NULL
);
1097 virtual ~wxDataViewTreeStoreContainerNode();
1099 const wxDataViewTreeStoreNodeList
&GetChildren() const
1100 { return m_children
; }
1101 wxDataViewTreeStoreNodeList
&GetChildren()
1102 { return m_children
; }
1104 void SetExpandedIcon( const wxIcon
&icon
)
1105 { m_iconExpanded
= icon
; }
1106 const wxIcon
&GetExpandedIcon() const
1107 { return m_iconExpanded
; }
1109 void SetExpanded( bool expanded
= true )
1110 { m_isExpanded
= expanded
; }
1111 bool IsExpanded() const
1112 { return m_isExpanded
; }
1114 virtual bool IsContainer()
1118 wxDataViewTreeStoreNodeList m_children
;
1119 wxIcon m_iconExpanded
;
1123 //-----------------------------------------------------------------------------
1125 class WXDLLIMPEXP_ADV wxDataViewTreeStore
: public wxDataViewModel
1128 wxDataViewTreeStore();
1129 ~wxDataViewTreeStore();
1131 wxDataViewItem
AppendItem( const wxDataViewItem
& parent
,
1132 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1133 wxDataViewItem
PrependItem( const wxDataViewItem
& parent
,
1134 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1135 wxDataViewItem
InsertItem( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1136 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1138 wxDataViewItem
PrependContainer( const wxDataViewItem
& parent
,
1139 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1140 wxClientData
*data
= NULL
);
1141 wxDataViewItem
AppendContainer( const wxDataViewItem
& parent
,
1142 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1143 wxClientData
*data
= NULL
);
1144 wxDataViewItem
InsertContainer( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1145 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1146 wxClientData
*data
= NULL
);
1148 wxDataViewItem
GetNthChild( const wxDataViewItem
& parent
, unsigned int pos
) const;
1149 int GetChildCount( const wxDataViewItem
& parent
) const;
1151 void SetItemText( const wxDataViewItem
& item
, const wxString
&text
);
1152 wxString
GetItemText( const wxDataViewItem
& item
) const;
1153 void SetItemIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1154 const wxIcon
&GetItemIcon( const wxDataViewItem
& item
) const;
1155 void SetItemExpandedIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1156 const wxIcon
&GetItemExpandedIcon( const wxDataViewItem
& item
) const;
1157 void SetItemData( const wxDataViewItem
& item
, wxClientData
*data
);
1158 wxClientData
*GetItemData( const wxDataViewItem
& item
) const;
1160 void DeleteItem( const wxDataViewItem
& item
);
1161 void DeleteChildren( const wxDataViewItem
& item
);
1162 void DeleteAllItems();
1164 // implement base methods
1166 virtual void GetValue( wxVariant
&variant
,
1167 const wxDataViewItem
&item
, unsigned int col
) const;
1168 virtual bool SetValue( const wxVariant
&variant
,
1169 const wxDataViewItem
&item
, unsigned int col
);
1170 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const;
1171 virtual bool IsContainer( const wxDataViewItem
&item
) const;
1172 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
1174 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
1175 unsigned int column
, bool ascending
);
1177 virtual bool HasDefaultCompare() const
1179 virtual unsigned int GetColumnCount() const
1181 virtual wxString
GetColumnType( unsigned int WXUNUSED(col
) ) const
1182 { return wxT("wxDataViewIconText"); }
1184 wxDataViewTreeStoreNode
*FindNode( const wxDataViewItem
&item
) const;
1185 wxDataViewTreeStoreContainerNode
*FindContainerNode( const wxDataViewItem
&item
) const;
1186 wxDataViewTreeStoreNode
*GetRoot() const { return m_root
; }
1189 wxDataViewTreeStoreNode
*m_root
;
1192 //-----------------------------------------------------------------------------
1194 class WXDLLIMPEXP_ADV wxDataViewTreeCtrl
: public wxDataViewCtrl
1197 wxDataViewTreeCtrl();
1198 wxDataViewTreeCtrl( wxWindow
*parent
, wxWindowID id
,
1199 const wxPoint
& pos
= wxDefaultPosition
,
1200 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
1201 const wxValidator
& validator
= wxDefaultValidator
);
1202 ~wxDataViewTreeCtrl();
1204 bool Create( wxWindow
*parent
, wxWindowID id
,
1205 const wxPoint
& pos
= wxDefaultPosition
,
1206 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
1207 const wxValidator
& validator
= wxDefaultValidator
);
1209 wxDataViewTreeStore
*GetStore()
1210 { return (wxDataViewTreeStore
*) GetModel(); }
1211 const wxDataViewTreeStore
*GetStore() const
1212 { return (const wxDataViewTreeStore
*) GetModel(); }
1214 void SetImageList( wxImageList
*imagelist
);
1215 wxImageList
* GetImageList() { return m_imageList
; }
1217 wxDataViewItem
AppendItem( const wxDataViewItem
& parent
,
1218 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1219 wxDataViewItem
PrependItem( const wxDataViewItem
& parent
,
1220 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1221 wxDataViewItem
InsertItem( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1222 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1224 wxDataViewItem
PrependContainer( const wxDataViewItem
& parent
,
1225 const wxString
&text
, int icon
= -1, int expanded
= -1,
1226 wxClientData
*data
= NULL
);
1227 wxDataViewItem
AppendContainer( const wxDataViewItem
& parent
,
1228 const wxString
&text
, int icon
= -1, int expanded
= -1,
1229 wxClientData
*data
= NULL
);
1230 wxDataViewItem
InsertContainer( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1231 const wxString
&text
, int icon
= -1, int expanded
= -1,
1232 wxClientData
*data
= NULL
);
1234 wxDataViewItem
GetNthChild( const wxDataViewItem
& parent
, unsigned int pos
) const
1235 { return GetStore()->GetNthChild(parent
, pos
); }
1236 int GetChildCount( const wxDataViewItem
& parent
) const
1237 { return GetStore()->GetChildCount(parent
); }
1239 void SetItemText( const wxDataViewItem
& item
, const wxString
&text
)
1240 { GetStore()->SetItemText(item
,text
); }
1241 wxString
GetItemText( const wxDataViewItem
& item
) const
1242 { return GetStore()->GetItemText(item
); }
1243 void SetItemIcon( const wxDataViewItem
& item
, const wxIcon
&icon
)
1244 { GetStore()->SetItemIcon(item
,icon
); }
1245 const wxIcon
&GetItemIcon( const wxDataViewItem
& item
) const
1246 { return GetStore()->GetItemIcon(item
); }
1247 void SetItemExpandedIcon( const wxDataViewItem
& item
, const wxIcon
&icon
)
1248 { GetStore()->SetItemExpandedIcon(item
,icon
); }
1249 const wxIcon
&GetItemExpandedIcon( const wxDataViewItem
& item
) const
1250 { return GetStore()->GetItemExpandedIcon(item
); }
1251 void SetItemData( const wxDataViewItem
& item
, wxClientData
*data
)
1252 { GetStore()->SetItemData(item
,data
); }
1253 wxClientData
*GetItemData( const wxDataViewItem
& item
) const
1254 { return GetStore()->GetItemData(item
); }
1256 void DeleteItem( const wxDataViewItem
& item
)
1257 { GetStore()->DeleteItem(item
); }
1258 void DeleteChildren( const wxDataViewItem
& item
)
1259 { GetStore()->DeleteChildren(item
); }
1260 void DeleteAllItems()
1261 { GetStore()->DeleteAllItems(); }
1263 void OnExpanded( wxDataViewEvent
&event
);
1264 void OnCollapsed( wxDataViewEvent
&event
);
1265 void OnSize( wxSizeEvent
&event
);
1268 wxImageList
*m_imageList
;
1271 DECLARE_EVENT_TABLE()
1272 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl
)
1275 #endif // wxUSE_DATAVIEWCTRL
1278 // _WX_DATAVIEW_H_BASE_