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_CARBON__)) || defined(__WXUNIVERSAL__)
31 // #if !(defined(__WXMAC__)) || 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
; }
85 void Print( const wxString
&text
) const;
92 bool operator == (const wxDataViewItem
&left
, const wxDataViewItem
&right
);
94 WX_DEFINE_ARRAY(wxDataViewItem
, wxDataViewItemArray
);
96 // ---------------------------------------------------------
97 // wxDataViewModelNotifier
98 // ---------------------------------------------------------
100 class WXDLLIMPEXP_ADV wxDataViewModelNotifier
103 wxDataViewModelNotifier() { m_owner
= NULL
; }
104 virtual ~wxDataViewModelNotifier() { m_owner
= NULL
; }
106 virtual bool ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
) = 0;
107 virtual bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
) = 0;
108 virtual bool ItemChanged( const wxDataViewItem
&item
) = 0;
109 virtual bool ItemsAdded( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
110 virtual bool ItemsDeleted( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
111 virtual bool ItemsChanged( const wxDataViewItemArray
&items
);
112 virtual bool ValueChanged( const wxDataViewItem
&item
, unsigned int col
) = 0;
113 virtual bool Cleared() = 0;
115 virtual void Resort() = 0;
117 void SetOwner( wxDataViewModel
*owner
) { m_owner
= owner
; }
118 wxDataViewModel
*GetOwner() const { return m_owner
; }
121 wxDataViewModel
*m_owner
;
126 // ----------------------------------------------------------------------------
127 // wxDataViewItemAttr: a structure containing the visual attributes of an item
128 // ----------------------------------------------------------------------------
130 // TODO: this should be renamed to wxItemAttr or something general like this
132 class WXDLLIMPEXP_ADV wxDataViewItemAttr
143 void SetColour(const wxColour
& colour
) { m_colour
= colour
; }
144 void SetBold( bool set
) { m_bold
= set
; }
145 void SetItalic( bool set
) { m_italic
= set
; }
148 bool HasColour() const { return m_colour
.Ok(); }
149 const wxColour
& GetColour() const { return m_colour
; }
151 bool GetBold() const { return m_bold
; }
152 bool GetItalic() const { return m_italic
; }
161 // ---------------------------------------------------------
163 // ---------------------------------------------------------
165 WX_DECLARE_LIST_WITH_DECL(wxDataViewModelNotifier
, wxDataViewModelNotifiers
,
166 class WXDLLIMPEXP_ADV
);
168 class WXDLLIMPEXP_ADV wxDataViewModel
: public wxObjectRefData
173 virtual unsigned int GetColumnCount() const = 0;
175 // return type as reported by wxVariant
176 virtual wxString
GetColumnType( unsigned int col
) const = 0;
178 // get value into a wxVariant
179 virtual void GetValue( wxVariant
&variant
,
180 const wxDataViewItem
&item
, unsigned int col
) const = 0;
182 // set value, call ValueChanged() afterwards!
183 virtual bool SetValue( const wxVariant
&variant
,
184 const wxDataViewItem
&item
, unsigned int col
) = 0;
186 // Get text attribute, return false of default attributes should be used
187 virtual bool GetAttr( const wxDataViewItem
&WXUNUSED(item
), unsigned int WXUNUSED(col
), wxDataViewItemAttr
&WXUNUSED(attr
) )
191 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const = 0;
192 virtual bool IsContainer( const wxDataViewItem
&item
) const = 0;
193 // Is the container just a header or an item with all columns
194 virtual bool HasContainerColumns(const wxDataViewItem
& WXUNUSED(item
)) const
196 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const = 0;
198 // delegated notifiers
199 virtual bool ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
200 virtual bool ItemsAdded( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
201 virtual bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
202 virtual bool ItemsDeleted( const wxDataViewItem
&parent
, const wxDataViewItemArray
&items
);
203 virtual bool ItemChanged( const wxDataViewItem
&item
);
204 virtual bool ItemsChanged( const wxDataViewItemArray
&items
);
205 virtual bool ValueChanged( const wxDataViewItem
&item
, unsigned int col
);
206 virtual bool Cleared();
209 virtual void Resort();
211 void AddNotifier( wxDataViewModelNotifier
*notifier
);
212 void RemoveNotifier( wxDataViewModelNotifier
*notifier
);
214 // default compare function
215 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
216 unsigned int column
, bool ascending
) const;
217 virtual bool HasDefaultCompare() const { return false; }
220 virtual bool IsVirtualListModel() const { return false; }
223 // the user should not delete this class directly: he should use DecRef() instead!
224 virtual ~wxDataViewModel() { }
226 wxDataViewModelNotifiers m_notifiers
;
229 // ---------------------------------------------------------
230 // wxDataViewIndexListModel
231 // ---------------------------------------------------------
233 class WXDLLIMPEXP_ADV wxDataViewIndexListModel
: public wxDataViewModel
236 wxDataViewIndexListModel( unsigned int initial_size
= 0 );
237 ~wxDataViewIndexListModel();
239 virtual void GetValueByRow( wxVariant
&variant
,
240 unsigned int row
, unsigned int col
) const = 0;
242 virtual bool SetValueByRow( const wxVariant
&variant
,
243 unsigned int row
, unsigned int col
) = 0;
245 virtual bool GetAttrByRow( unsigned int WXUNUSED(row
), unsigned int WXUNUSED(col
), wxDataViewItemAttr
&WXUNUSED(attr
) )
249 void RowInserted( unsigned int before
);
251 void RowDeleted( unsigned int row
);
252 void RowsDeleted( const wxArrayInt
&rows
);
253 void RowChanged( unsigned int row
);
254 void RowValueChanged( unsigned int row
, unsigned int col
);
255 void Reset( unsigned int new_size
);
257 // convert to/from row/wxDataViewItem
259 unsigned int GetRow( const wxDataViewItem
&item
) const;
260 wxDataViewItem
GetItem( unsigned int row
) const;
262 // compare based on index
264 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
265 unsigned int column
, bool ascending
) const;
266 virtual bool HasDefaultCompare() const;
268 // implement base methods
270 virtual void GetValue( wxVariant
&variant
,
271 const wxDataViewItem
&item
, unsigned int col
) const;
272 virtual bool SetValue( const wxVariant
&variant
,
273 const wxDataViewItem
&item
, unsigned int col
);
274 virtual bool GetAttr( const wxDataViewItem
&item
, unsigned int col
, wxDataViewItemAttr
&attr
);
275 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const;
276 virtual bool IsContainer( const wxDataViewItem
&item
) const;
277 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
280 virtual bool IsVirtualListModel() const { return false; }
281 unsigned int GetLastIndex() const { return m_lastIndex
; }
284 wxDataViewItemArray m_hash
;
285 unsigned int m_lastIndex
;
289 // ---------------------------------------------------------
290 // wxDataViewVirtualListModel
291 // ---------------------------------------------------------
294 // better than nothing
295 typedef wxDataViewIndexListModel wxDataViewVirtualListModel
;
298 class WXDLLIMPEXP_ADV wxDataViewVirtualListModel
: public wxDataViewModel
301 wxDataViewVirtualListModel( unsigned int initial_size
= 0 );
302 ~wxDataViewVirtualListModel();
304 virtual void GetValueByRow( wxVariant
&variant
,
305 unsigned int row
, unsigned int col
) const = 0;
307 virtual bool SetValueByRow( const wxVariant
&variant
,
308 unsigned int row
, unsigned int col
) = 0;
310 virtual bool GetAttrByRow( unsigned int WXUNUSED(row
), unsigned int WXUNUSED(col
), wxDataViewItemAttr
&WXUNUSED(attr
) )
314 void RowInserted( unsigned int before
);
316 void RowDeleted( unsigned int row
);
317 void RowsDeleted( const wxArrayInt
&rows
);
318 void RowChanged( unsigned int row
);
319 void RowValueChanged( unsigned int row
, unsigned int col
);
320 void Reset( unsigned int new_size
);
322 // convert to/from row/wxDataViewItem
324 unsigned int GetRow( const wxDataViewItem
&item
) const;
325 wxDataViewItem
GetItem( unsigned int row
) const;
327 // compare based on index
329 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
330 unsigned int column
, bool ascending
) const;
331 virtual bool HasDefaultCompare() const;
333 // implement base methods
335 virtual void GetValue( wxVariant
&variant
,
336 const wxDataViewItem
&item
, unsigned int col
) const;
337 virtual bool SetValue( const wxVariant
&variant
,
338 const wxDataViewItem
&item
, unsigned int col
);
339 virtual bool GetAttr( const wxDataViewItem
&item
, unsigned int col
, wxDataViewItemAttr
&attr
);
340 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const;
341 virtual bool IsContainer( const wxDataViewItem
&item
) const;
342 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
345 virtual bool IsVirtualListModel() const { return true; }
346 unsigned int GetLastIndex() const { return m_lastIndex
; }
349 wxDataViewItemArray m_hash
;
350 unsigned int m_lastIndex
;
355 //-----------------------------------------------------------------------------
356 // wxDataViewEditorCtrlEvtHandler
357 //-----------------------------------------------------------------------------
359 class wxDataViewEditorCtrlEvtHandler
: public wxEvtHandler
362 wxDataViewEditorCtrlEvtHandler( wxControl
*editor
, wxDataViewRenderer
*owner
);
364 void AcceptChangesAndFinish();
365 void SetFocusOnIdle( bool focus
= true ) { m_focusOnIdle
= focus
; }
368 void OnChar( wxKeyEvent
&event
);
369 void OnTextEnter( wxCommandEvent
&event
);
370 void OnKillFocus( wxFocusEvent
&event
);
371 void OnIdle( wxIdleEvent
&event
);
374 wxDataViewRenderer
*m_owner
;
375 wxControl
*m_editorCtrl
;
380 DECLARE_EVENT_TABLE()
383 // ---------------------------------------------------------
384 // wxDataViewRendererBase
385 // ---------------------------------------------------------
387 enum wxDataViewCellMode
389 wxDATAVIEW_CELL_INERT
,
390 wxDATAVIEW_CELL_ACTIVATABLE
,
391 wxDATAVIEW_CELL_EDITABLE
394 enum wxDataViewCellRenderState
396 wxDATAVIEW_CELL_SELECTED
= 1,
397 wxDATAVIEW_CELL_PRELIT
= 2,
398 wxDATAVIEW_CELL_INSENSITIVE
= 4,
399 wxDATAVIEW_CELL_FOCUSED
= 8
402 class WXDLLIMPEXP_ADV wxDataViewRendererBase
: public wxObject
405 wxDataViewRendererBase( const wxString
&varianttype
,
406 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
407 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
408 ~wxDataViewRendererBase();
410 virtual bool Validate( wxVariant
& WXUNUSED(value
) )
413 void SetOwner( wxDataViewColumn
*owner
) { m_owner
= owner
; }
414 wxDataViewColumn
* GetOwner() const { return m_owner
; }
416 // renderer properties:
418 virtual bool SetValue( const wxVariant
& WXUNUSED(value
) ) = 0;
419 virtual bool GetValue( wxVariant
& WXUNUSED(value
) ) const = 0;
421 wxString
GetVariantType() const { return m_variantType
; }
423 virtual void SetMode( wxDataViewCellMode mode
) = 0;
424 virtual wxDataViewCellMode
GetMode() const = 0;
426 // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but
427 // rather an "int"; that's because for rendering cells it's allowed
428 // to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM)
429 virtual void SetAlignment( int align
) = 0;
430 virtual int GetAlignment() const = 0;
433 virtual bool HasEditorCtrl() const
435 virtual wxControl
* CreateEditorCtrl(wxWindow
* WXUNUSED(parent
),
436 wxRect
WXUNUSED(labelRect
),
437 const wxVariant
& WXUNUSED(value
))
439 virtual bool GetValueFromEditorCtrl(wxControl
* WXUNUSED(editor
),
440 wxVariant
& WXUNUSED(value
))
443 virtual bool StartEditing( const wxDataViewItem
&item
, wxRect labelRect
);
444 virtual void CancelEditing();
445 virtual bool FinishEditing();
447 wxControl
*GetEditorCtrl() { return m_editorCtrl
; }
450 wxString m_variantType
;
451 wxDataViewColumn
*m_owner
;
452 wxWeakRef
<wxControl
> m_editorCtrl
;
453 wxDataViewItem m_item
; // for m_editorCtrl
456 const wxDataViewCtrl
* GetView() const;
459 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase
)
462 //-----------------------------------------------------------------------------
463 // wxDataViewIconText
464 //-----------------------------------------------------------------------------
466 class WXDLLIMPEXP_ADV wxDataViewIconText
: public wxObject
469 wxDataViewIconText( const wxString
&text
= wxEmptyString
, const wxIcon
& icon
= wxNullIcon
)
470 : m_text(text
), m_icon(icon
)
472 wxDataViewIconText( const wxDataViewIconText
&other
)
474 { m_icon
= other
.m_icon
; m_text
= other
.m_text
; }
476 void SetText( const wxString
&text
) { m_text
= text
; }
477 wxString
GetText() const { return m_text
; }
478 void SetIcon( const wxIcon
&icon
) { m_icon
= icon
; }
479 const wxIcon
&GetIcon() const { return m_icon
; }
486 DECLARE_DYNAMIC_CLASS(wxDataViewIconText
)
489 bool operator == (const wxDataViewIconText
&one
, const wxDataViewIconText
&two
);
491 DECLARE_VARIANT_OBJECT_EXPORTED(wxDataViewIconText
, WXDLLIMPEXP_ADV
)
493 // ---------------------------------------------------------
494 // wxDataViewColumnBase
495 // ---------------------------------------------------------
497 // for compatibility only, do not use
498 enum wxDataViewColumnFlags
500 wxDATAVIEW_COL_RESIZABLE
= wxCOL_RESIZABLE
,
501 wxDATAVIEW_COL_SORTABLE
= wxCOL_SORTABLE
,
502 wxDATAVIEW_COL_REORDERABLE
= wxCOL_REORDERABLE
,
503 wxDATAVIEW_COL_HIDDEN
= wxCOL_HIDDEN
506 class WXDLLIMPEXP_ADV wxDataViewColumnBase
: public wxSettableHeaderColumn
509 // ctor for the text columns: takes ownership of renderer
510 wxDataViewColumnBase(wxDataViewRenderer
*renderer
,
511 unsigned int model_column
)
513 Init(renderer
, model_column
);
516 // ctor for the bitmap columns
517 wxDataViewColumnBase(const wxBitmap
& bitmap
,
518 wxDataViewRenderer
*renderer
,
519 unsigned int model_column
)
522 Init(renderer
, model_column
);
525 virtual ~wxDataViewColumnBase();
528 virtual void SetOwner( wxDataViewCtrl
*owner
)
532 unsigned int GetModelColumn() const
533 { return static_cast<unsigned int>(m_model_column
); }
534 wxDataViewCtrl
*GetOwner() const { return m_owner
; }
535 wxDataViewRenderer
* GetRenderer() const { return m_renderer
; }
537 // implement some of base class pure virtuals (the rest is port-dependent
538 // and done differently in generic and native versions)
539 virtual void SetBitmap( const wxBitmap
& bitmap
) { m_bitmap
= bitmap
; }
540 virtual wxBitmap
GetBitmap() const { return m_bitmap
; }
543 wxDataViewRenderer
*m_renderer
;
546 wxDataViewCtrl
*m_owner
;
549 // common part of all ctors
550 void Init(wxDataViewRenderer
*renderer
, unsigned int model_column
);
553 // ---------------------------------------------------------
554 // wxDataViewCtrlBase
555 // ---------------------------------------------------------
557 #define wxDV_SINGLE 0x0000 // for convenience
558 #define wxDV_MULTIPLE 0x0001 // can select multiple items
560 #define wxDV_NO_HEADER 0x0002 // column titles not visible
561 #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows
562 #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns
564 #define wxDV_ROW_LINES 0x0010 // alternating colour in rows
565 #define wxDV_VARIABLE_LINE_HEIGHT 0x0020 // variable line height
567 class WXDLLIMPEXP_ADV wxDataViewCtrlBase
: public wxControl
570 wxDataViewCtrlBase();
571 virtual ~wxDataViewCtrlBase();
576 virtual bool AssociateModel( wxDataViewModel
*model
);
577 wxDataViewModel
* GetModel();
578 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
);
682 virtual bool PrependColumn( wxDataViewColumn
*col
);
683 virtual bool InsertColumn( unsigned int pos
, wxDataViewColumn
*col
);
684 virtual bool AppendColumn( wxDataViewColumn
*col
);
686 virtual unsigned int GetColumnCount() const = 0;
687 virtual wxDataViewColumn
* GetColumn( unsigned int pos
) const = 0;
688 virtual int GetColumnPosition( const wxDataViewColumn
*column
) const = 0;
690 virtual bool DeleteColumn( wxDataViewColumn
*column
) = 0;
691 virtual bool ClearColumns() = 0;
693 void SetExpanderColumn( wxDataViewColumn
*col
)
694 { m_expander_column
= col
; DoSetExpanderColumn(); }
695 wxDataViewColumn
*GetExpanderColumn() const
696 { return m_expander_column
; }
698 virtual wxDataViewColumn
*GetSortingColumn() const = 0;
704 void SetIndent( int indent
)
705 { m_indent
= indent
; DoSetIndent(); }
706 int GetIndent() const
709 virtual wxDataViewItem
GetSelection() const = 0;
710 virtual int GetSelections( wxDataViewItemArray
& sel
) const = 0;
711 virtual void SetSelections( const wxDataViewItemArray
& sel
) = 0;
712 virtual void Select( const wxDataViewItem
& item
) = 0;
713 virtual void Unselect( const wxDataViewItem
& item
) = 0;
714 virtual bool IsSelected( const wxDataViewItem
& item
) const = 0;
716 virtual void SelectAll() = 0;
717 virtual void UnselectAll() = 0;
719 virtual void Expand( const wxDataViewItem
& item
) = 0;
720 virtual void ExpandAncestors( const wxDataViewItem
& item
);
721 virtual void Collapse( const wxDataViewItem
& item
) = 0;
722 virtual bool IsExpanded( const wxDataViewItem
& item
) const = 0;
724 virtual void EnsureVisible( const wxDataViewItem
& item
,
725 const wxDataViewColumn
*column
= NULL
) = 0;
726 virtual void HitTest( const wxPoint
& point
, wxDataViewItem
&item
, wxDataViewColumn
* &column
) const = 0;
727 virtual wxRect
GetItemRect( const wxDataViewItem
& item
, const wxDataViewColumn
*column
= NULL
) const = 0;
729 #if wxUSE_DRAG_AND_DROP
730 virtual bool EnableDragSource(const wxDataFormat
& WXUNUSED(format
))
732 virtual bool EnableDropTarget(const wxDataFormat
& WXUNUSED(format
))
734 #endif // wxUSE_DRAG_AND_DROP
737 virtual void DoSetExpanderColumn() = 0 ;
738 virtual void DoSetIndent() = 0;
741 wxDataViewModel
*m_model
;
742 wxDataViewColumn
*m_expander_column
;
746 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase
)
749 // ----------------------------------------------------------------------------
750 // wxDataViewEvent - the event class for the wxDataViewCtrl notifications
751 // ----------------------------------------------------------------------------
753 class WXDLLIMPEXP_ADV wxDataViewEvent
: public wxNotifyEvent
756 wxDataViewEvent(wxEventType commandType
= wxEVT_NULL
, int winid
= 0)
757 : wxNotifyEvent(commandType
, winid
),
761 m_value(wxNullVariant
),
764 #if wxUSE_DRAG_AND_DROP
765 , m_dataObject(NULL
),
771 wxDataViewEvent(const wxDataViewEvent
& event
)
772 : wxNotifyEvent(event
),
773 m_item(event
.m_item
),
775 m_model(event
.m_model
),
776 m_value(event
.m_value
),
777 m_column(event
.m_column
),
779 #if wxUSE_DRAG_AND_DROP
780 , m_dataObject(event
.m_dataObject
),
781 m_dataFormat(event
.m_dataFormat
),
782 m_dataBuffer(event
.m_dataBuffer
),
783 m_dataSize(event
.m_dataSize
)
787 wxDataViewItem
GetItem() const { return m_item
; }
788 void SetItem( const wxDataViewItem
&item
) { m_item
= item
; }
790 int GetColumn() const { return m_col
; }
791 void SetColumn( int col
) { m_col
= col
; }
793 wxDataViewModel
* GetModel() const { return m_model
; }
794 void SetModel( wxDataViewModel
*model
) { m_model
= model
; }
796 const wxVariant
&GetValue() const { return m_value
; }
797 void SetValue( const wxVariant
&value
) { m_value
= value
; }
799 // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only
800 void SetDataViewColumn( wxDataViewColumn
*col
) { m_column
= col
; }
801 wxDataViewColumn
*GetDataViewColumn() const { return m_column
; }
803 // for wxEVT_DATAVIEW_CONTEXT_MENU only
804 wxPoint
GetPosition() const { return m_pos
; }
805 void SetPosition( int x
, int y
) { m_pos
.x
= x
; m_pos
.y
= y
; }
807 #if wxUSE_DRAG_AND_DROP
808 // For drag operations
809 void SetDataObject( wxDataObject
*obj
) { m_dataObject
= obj
; }
810 wxDataObject
*GetDataObject() const { return m_dataObject
; }
812 // For drop operations
813 void SetDataFormat( const wxDataFormat
&format
) { m_dataFormat
= format
; }
814 wxDataFormat
GetDataFormat() const { return m_dataFormat
; }
815 void SetDataSize( size_t size
) { m_dataSize
= size
; }
816 size_t GetDataSize() const { return m_dataSize
; }
817 void SetDataBuffer( void* buf
) { m_dataBuffer
= buf
;}
818 void *GetDataBuffer() const { return m_dataBuffer
; }
819 #endif // wxUSE_DRAG_AND_DROP
821 virtual wxEvent
*Clone() const { return new wxDataViewEvent(*this); }
824 wxDataViewItem m_item
;
826 wxDataViewModel
*m_model
;
828 wxDataViewColumn
*m_column
;
831 #if wxUSE_DRAG_AND_DROP
832 wxDataObject
*m_dataObject
;
834 wxDataFormat m_dataFormat
;
837 #endif // wxUSE_DRAG_AND_DROP
840 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent
)
843 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED
, wxDataViewEvent
);
845 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED
, wxDataViewEvent
);
846 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED
, wxDataViewEvent
);
847 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED
, wxDataViewEvent
);
848 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING
, wxDataViewEvent
);
849 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING
, wxDataViewEvent
);
850 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING
, wxDataViewEvent
);
851 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED
, wxDataViewEvent
);
852 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE
, wxDataViewEvent
);
853 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED
, wxDataViewEvent
);
855 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU
, wxDataViewEvent
);
857 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK
, wxDataViewEvent
);
858 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK
, wxDataViewEvent
);
859 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED
, wxDataViewEvent
);
860 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED
, wxDataViewEvent
);
862 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG
, wxDataViewEvent
);
863 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE
, wxDataViewEvent
);
864 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV
, wxEVT_COMMAND_DATAVIEW_ITEM_DROP
, wxDataViewEvent
);
866 typedef void (wxEvtHandler::*wxDataViewEventFunction
)(wxDataViewEvent
&);
868 #define wxDataViewEventHandler(func) \
869 wxEVENT_HANDLER_CAST(wxDataViewEventFunction, func)
871 #define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \
872 wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn))
874 #define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn)
876 #define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn)
877 #define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn)
878 #define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn)
879 #define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn)
880 #define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn)
881 #define EVT_DATAVIEW_ITEM_START_EDITING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_START_EDITING, id, fn)
882 #define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn)
883 #define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn)
884 #define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn)
886 #define EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_CONTEXT_MENU, id, fn)
888 #define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn)
889 #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn)
890 #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn)
891 #define EVT_DATAVIEW_COLUMN_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_REORDERED, id, fn)
893 #define EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_BEGIN_DRAG, id, fn)
894 #define EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP_POSSIBLE, id, fn)
895 #define EVT_DATAVIEW_ITEM_DROP(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP, id, fn)
897 #ifdef wxHAS_GENERIC_DATAVIEWCTRL
898 // this symbol doesn't follow the convention for wxUSE_XXX symbols which
899 // are normally always defined as either 0 or 1, so its use is deprecated
900 // and it only exists for backwards compatibility, don't use it any more
901 // and use wxHAS_GENERIC_DATAVIEWCTRL instead
902 #define wxUSE_GENERICDATAVIEWCTRL
904 #include "wx/generic/dataview.h"
905 #elif defined(__WXGTK20__)
906 #include "wx/gtk/dataview.h"
907 #elif defined(__WXMAC__)
908 #include "wx/osx/dataview.h"
910 #error "unknown native wxDataViewCtrl implementation"
913 // -------------------------------------
914 // wxDataViewSpinRenderer
915 // -------------------------------------
917 class WXDLLIMPEXP_ADV wxDataViewSpinRenderer
: public wxDataViewCustomRenderer
920 wxDataViewSpinRenderer( int min
, int max
,
921 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
922 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
923 virtual bool HasEditorCtrl() const { return true; }
924 virtual wxControl
* CreateEditorCtrl( wxWindow
*parent
, wxRect labelRect
, const wxVariant
&value
);
925 virtual bool GetValueFromEditorCtrl( wxControl
* editor
, wxVariant
&value
);
926 virtual bool Render( wxRect rect
, wxDC
*dc
, int state
);
927 virtual wxSize
GetSize() const;
928 virtual bool SetValue( const wxVariant
&value
);
929 virtual bool GetValue( wxVariant
&value
) const;
936 #if defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXMAC__)
938 // -------------------------------------
939 // wxDataViewChoiceRenderer
940 // -------------------------------------
942 class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer
: public wxDataViewCustomRenderer
945 wxDataViewChoiceRenderer( const wxArrayString
&choices
,
946 wxDataViewCellMode mode
= wxDATAVIEW_CELL_EDITABLE
,
947 int alignment
= wxDVR_DEFAULT_ALIGNMENT
);
948 virtual bool HasEditorCtrl() const { return true; }
949 virtual wxControl
* CreateEditorCtrl( wxWindow
*parent
, wxRect labelRect
, const wxVariant
&value
);
950 virtual bool GetValueFromEditorCtrl( wxControl
* editor
, wxVariant
&value
);
951 virtual bool Render( wxRect rect
, wxDC
*dc
, int state
);
952 virtual wxSize
GetSize() const;
953 virtual bool SetValue( const wxVariant
&value
);
954 virtual bool GetValue( wxVariant
&value
) const;
957 wxArrayString m_choices
;
963 //-----------------------------------------------------------------------------
964 // wxDataViewListStore
965 //-----------------------------------------------------------------------------
967 class WXDLLIMPEXP_ADV wxDataViewListStoreLine
970 wxDataViewListStoreLine( wxClientData
*data
= NULL
)
974 virtual ~wxDataViewListStoreLine()
979 void SetData( wxClientData
*data
)
980 { if (m_data
) delete m_data
; m_data
= data
; }
981 wxClientData
*GetData() const
984 wxVector
<wxVariant
> m_values
;
987 wxClientData
*m_data
;
991 class WXDLLIMPEXP_ADV wxDataViewListStore
: public wxDataViewIndexListModel
994 wxDataViewListStore();
995 ~wxDataViewListStore();
997 void PrependColumn( const wxString
&varianttype
);
998 void InsertColumn( unsigned int pos
, const wxString
&varianttype
);
999 void AppendColumn( const wxString
&varianttype
);
1001 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1002 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1003 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
);
1004 void DeleteItem( unsigned int pos
);
1005 void DeleteAllItems();
1007 // override base virtuals
1009 virtual unsigned int GetColumnCount() const;
1011 virtual wxString
GetColumnType( unsigned int col
) const;
1013 virtual void GetValueByRow( wxVariant
&value
,
1014 unsigned int row
, unsigned int col
) const;
1016 virtual bool SetValueByRow( const wxVariant
&value
,
1017 unsigned int row
, unsigned int col
);
1021 wxVector
<wxDataViewListStoreLine
*> m_data
;
1022 wxArrayString m_cols
;
1025 //-----------------------------------------------------------------------------
1027 class WXDLLIMPEXP_ADV wxDataViewListCtrl
: public wxDataViewCtrl
1030 wxDataViewListCtrl();
1031 wxDataViewListCtrl( wxWindow
*parent
, wxWindowID id
,
1032 const wxPoint
& pos
= wxDefaultPosition
,
1033 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
1034 const wxValidator
& validator
= wxDefaultValidator
);
1035 ~wxDataViewListCtrl();
1037 bool Create( wxWindow
*parent
, wxWindowID id
,
1038 const wxPoint
& pos
= wxDefaultPosition
,
1039 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_ROW_LINES
,
1040 const wxValidator
& validator
= wxDefaultValidator
);
1042 wxDataViewListStore
*GetStore()
1043 { return (wxDataViewListStore
*) GetModel(); }
1044 const wxDataViewListStore
*GetStore() const
1045 { return (const wxDataViewListStore
*) GetModel(); }
1047 bool AppendColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
1048 bool PrependColumn( wxDataViewColumn
*column
, const wxString
&varianttype
);
1049 bool InsertColumn( unsigned int pos
, wxDataViewColumn
*column
, const wxString
&varianttype
);
1051 // overridden from base class
1052 virtual bool PrependColumn( wxDataViewColumn
*col
);
1053 virtual bool InsertColumn( unsigned int pos
, wxDataViewColumn
*col
);
1054 virtual bool AppendColumn( wxDataViewColumn
*col
);
1056 wxDataViewColumn
*AppendTextColumn( const wxString
&label
,
1057 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1058 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1059 wxDataViewColumn
*AppendToggleColumn( const wxString
&label
,
1060 wxDataViewCellMode mode
= wxDATAVIEW_CELL_ACTIVATABLE
,
1061 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1062 wxDataViewColumn
*AppendProgressColumn( const wxString
&label
,
1063 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1064 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1065 wxDataViewColumn
*AppendIconTextColumn( const wxString
&label
,
1066 wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
,
1067 int width
= -1, wxAlignment align
= wxALIGN_LEFT
, int flags
= wxDATAVIEW_COL_RESIZABLE
);
1069 void AppendItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1070 { GetStore()->AppendItem( values
, data
); }
1071 void PrependItem( const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1072 { GetStore()->PrependItem( values
, data
); }
1073 void InsertItem( unsigned int row
, const wxVector
<wxVariant
> &values
, wxClientData
*data
= NULL
)
1074 { GetStore()->InsertItem( row
, values
, data
); }
1075 void DeleteItem( unsigned row
)
1076 { GetStore()->DeleteItem( row
); }
1077 void DeleteAllItems()
1078 { GetStore()->DeleteAllItems(); }
1080 void SetValue( const wxVariant
&value
, unsigned int row
, unsigned int col
)
1081 { GetStore()->SetValueByRow( value
, row
, col
);
1082 GetStore()->RowValueChanged( row
, col
); }
1083 void GetValue( wxVariant
&value
, unsigned int row
, unsigned int col
)
1084 { GetStore()->GetValueByRow( value
, row
, col
); }
1086 void SetTextValue( const wxString
&value
, unsigned int row
, unsigned int col
)
1087 { GetStore()->SetValueByRow( value
, row
, col
);
1088 GetStore()->RowValueChanged( row
, col
); }
1089 wxString
GetTextValue( unsigned int row
, unsigned int col
) const
1090 { wxVariant value
; GetStore()->GetValueByRow( value
, row
, col
); return value
.GetString(); }
1092 void SetToggleValue( bool value
, unsigned int row
, unsigned int col
)
1093 { GetStore()->SetValueByRow( value
, row
, col
);
1094 GetStore()->RowValueChanged( row
, col
); }
1095 bool GetToggleValue( unsigned int row
, unsigned int col
) const
1096 { wxVariant value
; GetStore()->GetValueByRow( value
, row
, col
); return value
.GetBool(); }
1098 void OnSize( wxSizeEvent
&event
);
1101 DECLARE_EVENT_TABLE()
1102 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewListCtrl
)
1105 //-----------------------------------------------------------------------------
1106 // wxDataViewTreeStore
1107 //-----------------------------------------------------------------------------
1109 class WXDLLIMPEXP_ADV wxDataViewTreeStoreNode
1112 wxDataViewTreeStoreNode( wxDataViewTreeStoreNode
*parent
,
1113 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1114 virtual ~wxDataViewTreeStoreNode();
1116 void SetText( const wxString
&text
)
1118 wxString
GetText() const
1120 void SetIcon( const wxIcon
&icon
)
1122 const wxIcon
&GetIcon() const
1124 void SetData( wxClientData
*data
)
1125 { if (m_data
) delete m_data
; m_data
= data
; }
1126 wxClientData
*GetData() const
1129 wxDataViewItem
GetItem() const
1130 { return wxDataViewItem( (void*) this ); }
1132 virtual bool IsContainer()
1135 wxDataViewTreeStoreNode
*GetParent()
1136 { return m_parent
; }
1139 wxDataViewTreeStoreNode
*m_parent
;
1142 wxClientData
*m_data
;
1145 WX_DECLARE_LIST_WITH_DECL(wxDataViewTreeStoreNode
, wxDataViewTreeStoreNodeList
,
1146 class WXDLLIMPEXP_ADV
);
1148 class WXDLLIMPEXP_ADV wxDataViewTreeStoreContainerNode
: public wxDataViewTreeStoreNode
1151 wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode
*parent
,
1152 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1153 wxClientData
*data
= NULL
);
1154 virtual ~wxDataViewTreeStoreContainerNode();
1156 const wxDataViewTreeStoreNodeList
&GetChildren() const
1157 { return m_children
; }
1158 wxDataViewTreeStoreNodeList
&GetChildren()
1159 { return m_children
; }
1161 void SetExpandedIcon( const wxIcon
&icon
)
1162 { m_iconExpanded
= icon
; }
1163 const wxIcon
&GetExpandedIcon() const
1164 { return m_iconExpanded
; }
1166 void SetExpanded( bool expanded
= true )
1167 { m_isExpanded
= expanded
; }
1168 bool IsExpanded() const
1169 { return m_isExpanded
; }
1171 virtual bool IsContainer()
1175 wxDataViewTreeStoreNodeList m_children
;
1176 wxIcon m_iconExpanded
;
1180 //-----------------------------------------------------------------------------
1182 class WXDLLIMPEXP_ADV wxDataViewTreeStore
: public wxDataViewModel
1185 wxDataViewTreeStore();
1186 ~wxDataViewTreeStore();
1188 wxDataViewItem
AppendItem( const wxDataViewItem
& parent
,
1189 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1190 wxDataViewItem
PrependItem( const wxDataViewItem
& parent
,
1191 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1192 wxDataViewItem
InsertItem( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1193 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, wxClientData
*data
= NULL
);
1195 wxDataViewItem
PrependContainer( const wxDataViewItem
& parent
,
1196 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1197 wxClientData
*data
= NULL
);
1198 wxDataViewItem
AppendContainer( const wxDataViewItem
& parent
,
1199 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1200 wxClientData
*data
= NULL
);
1201 wxDataViewItem
InsertContainer( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1202 const wxString
&text
, const wxIcon
&icon
= wxNullIcon
, const wxIcon
&expanded
= wxNullIcon
,
1203 wxClientData
*data
= NULL
);
1205 wxDataViewItem
GetNthChild( const wxDataViewItem
& parent
, unsigned int pos
) const;
1206 int GetChildCount( const wxDataViewItem
& parent
) const;
1208 void SetItemText( const wxDataViewItem
& item
, const wxString
&text
);
1209 wxString
GetItemText( const wxDataViewItem
& item
) const;
1210 void SetItemIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1211 const wxIcon
&GetItemIcon( const wxDataViewItem
& item
) const;
1212 void SetItemExpandedIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1213 const wxIcon
&GetItemExpandedIcon( const wxDataViewItem
& item
) const;
1214 void SetItemData( const wxDataViewItem
& item
, wxClientData
*data
);
1215 wxClientData
*GetItemData( const wxDataViewItem
& item
) const;
1217 void DeleteItem( const wxDataViewItem
& item
);
1218 void DeleteChildren( const wxDataViewItem
& item
);
1219 void DeleteAllItems();
1221 // implement base methods
1223 virtual void GetValue( wxVariant
&variant
,
1224 const wxDataViewItem
&item
, unsigned int col
) const;
1225 virtual bool SetValue( const wxVariant
&variant
,
1226 const wxDataViewItem
&item
, unsigned int col
);
1227 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const;
1228 virtual bool IsContainer( const wxDataViewItem
&item
) const;
1229 virtual unsigned int GetChildren( const wxDataViewItem
&item
, wxDataViewItemArray
&children
) const;
1231 virtual int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
1232 unsigned int column
, bool ascending
) const;
1234 virtual bool HasDefaultCompare() const
1236 virtual unsigned int GetColumnCount() const
1238 virtual wxString
GetColumnType( unsigned int WXUNUSED(col
) ) const
1239 { return wxT("wxDataViewIconText"); }
1241 wxDataViewTreeStoreNode
*FindNode( const wxDataViewItem
&item
) const;
1242 wxDataViewTreeStoreContainerNode
*FindContainerNode( const wxDataViewItem
&item
) const;
1243 wxDataViewTreeStoreNode
*GetRoot() const { return m_root
; }
1246 wxDataViewTreeStoreNode
*m_root
;
1249 //-----------------------------------------------------------------------------
1251 class WXDLLIMPEXP_ADV wxDataViewTreeCtrl
: public wxDataViewCtrl
1254 wxDataViewTreeCtrl();
1255 wxDataViewTreeCtrl( 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
);
1259 ~wxDataViewTreeCtrl();
1261 bool Create( wxWindow
*parent
, wxWindowID id
,
1262 const wxPoint
& pos
= wxDefaultPosition
,
1263 const wxSize
& size
= wxDefaultSize
, long style
= wxDV_NO_HEADER
| wxDV_ROW_LINES
,
1264 const wxValidator
& validator
= wxDefaultValidator
);
1266 wxDataViewTreeStore
*GetStore()
1267 { return (wxDataViewTreeStore
*) GetModel(); }
1268 const wxDataViewTreeStore
*GetStore() const
1269 { return (const wxDataViewTreeStore
*) GetModel(); }
1271 void SetImageList( wxImageList
*imagelist
);
1272 wxImageList
* GetImageList() { return m_imageList
; }
1274 wxDataViewItem
AppendItem( const wxDataViewItem
& parent
,
1275 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1276 wxDataViewItem
PrependItem( const wxDataViewItem
& parent
,
1277 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1278 wxDataViewItem
InsertItem( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1279 const wxString
&text
, int icon
= -1, wxClientData
*data
= NULL
);
1281 wxDataViewItem
PrependContainer( const wxDataViewItem
& parent
,
1282 const wxString
&text
, int icon
= -1, int expanded
= -1,
1283 wxClientData
*data
= NULL
);
1284 wxDataViewItem
AppendContainer( const wxDataViewItem
& parent
,
1285 const wxString
&text
, int icon
= -1, int expanded
= -1,
1286 wxClientData
*data
= NULL
);
1287 wxDataViewItem
InsertContainer( const wxDataViewItem
& parent
, const wxDataViewItem
& previous
,
1288 const wxString
&text
, int icon
= -1, int expanded
= -1,
1289 wxClientData
*data
= NULL
);
1291 wxDataViewItem
GetNthChild( const wxDataViewItem
& parent
, unsigned int pos
) const
1292 { return GetStore()->GetNthChild(parent
, pos
); }
1293 int GetChildCount( const wxDataViewItem
& parent
) const
1294 { return GetStore()->GetChildCount(parent
); }
1296 void SetItemText( const wxDataViewItem
& item
, const wxString
&text
);
1297 wxString
GetItemText( const wxDataViewItem
& item
) const
1298 { return GetStore()->GetItemText(item
); }
1299 void SetItemIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1300 const wxIcon
&GetItemIcon( const wxDataViewItem
& item
) const
1301 { return GetStore()->GetItemIcon(item
); }
1302 void SetItemExpandedIcon( const wxDataViewItem
& item
, const wxIcon
&icon
);
1303 const wxIcon
&GetItemExpandedIcon( const wxDataViewItem
& item
) const
1304 { return GetStore()->GetItemExpandedIcon(item
); }
1305 void SetItemData( const wxDataViewItem
& item
, wxClientData
*data
)
1306 { GetStore()->SetItemData(item
,data
); }
1307 wxClientData
*GetItemData( const wxDataViewItem
& item
) const
1308 { return GetStore()->GetItemData(item
); }
1310 void DeleteItem( const wxDataViewItem
& item
);
1311 void DeleteChildren( const wxDataViewItem
& item
);
1312 void DeleteAllItems();
1314 void OnExpanded( wxDataViewEvent
&event
);
1315 void OnCollapsed( wxDataViewEvent
&event
);
1316 void OnSize( wxSizeEvent
&event
);
1319 wxImageList
*m_imageList
;
1322 DECLARE_EVENT_TABLE()
1323 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl
)
1326 #endif // wxUSE_DATAVIEWCTRL
1329 // _WX_DATAVIEW_H_BASE_