]> git.saurik.com Git - wxWidgets.git/blame - include/wx/dataview.h
Fix crash when editing wxDVC items in place in wxOSX/Cocoa.
[wxWidgets.git] / include / wx / dataview.h
CommitLineData
bcd846ea
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/dataview.h
3// Purpose: wxDataViewCtrl base classes
4// Author: Robert Roebling
b7e9f8b1 5// Modified by: Bo Yang
bcd846ea
RR
6// Created: 08.01.06
7// RCS-ID: $Id$
8// Copyright: (c) Robert Roebling
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_DATAVIEW_H_BASE_
13#define _WX_DATAVIEW_H_BASE_
14
15#include "wx/defs.h"
16
17#if wxUSE_DATAVIEWCTRL
18
239eaa41 19#include "wx/textctrl.h"
56873923 20#include "wx/headercol.h"
64ffb888 21#include "wx/variant.h"
b7e9f8b1 22#include "wx/dynarray.h"
89352653 23#include "wx/icon.h"
c232dfe5 24#include "wx/weakref.h"
8eff6c56 25#include "wx/vector.h"
8c2654ce
PC
26#include "wx/dataobj.h"
27
28class WXDLLIMPEXP_FWD_CORE wxImageList;
4ed7af08 29
e86edab0 30#if !(defined(__WXGTK20__) || defined(__WXOSX__)) || defined(__WXUNIVERSAL__)
0a807957 31// #if !(defined(__WXOSX__)) || defined(__WXUNIVERSAL__)
56873923
VZ
32 #define wxHAS_GENERIC_DATAVIEWCTRL
33#endif
34
239eaa41
RR
35// ----------------------------------------------------------------------------
36// wxDataViewCtrl globals
37// ----------------------------------------------------------------------------
bcd846ea 38
b5dbe15d
VS
39class WXDLLIMPEXP_FWD_ADV wxDataViewItem;
40class WXDLLIMPEXP_FWD_ADV wxDataViewModel;
41class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl;
42class WXDLLIMPEXP_FWD_ADV wxDataViewColumn;
43class WXDLLIMPEXP_FWD_ADV wxDataViewRenderer;
44class WXDLLIMPEXP_FWD_ADV wxDataViewModelNotifier;
fa28826d 45
23318a53 46extern WXDLLIMPEXP_DATA_ADV(const char) wxDataViewCtrlNameStr[];
bcd846ea 47
ce468dc2
FM
48// ----------------------------------------------------------------------------
49// wxDataViewCtrl flags
50// ----------------------------------------------------------------------------
51
52// size of a wxDataViewRenderer without contents:
53#define wxDVC_DEFAULT_RENDERER_SIZE 20
54
87f0efe2
RR
55// the default width of new (text) columns:
56#define wxDVC_DEFAULT_WIDTH 80
57
58// the default width of new toggle columns:
59#define wxDVC_TOGGLE_DEFAULT_WIDTH 30
60
9861f022
RR
61// the default minimal width of the columns:
62#define wxDVC_DEFAULT_MINWIDTH 30
63
f2b7492a
RR
64// The default alignment of wxDataViewRenderers is to take
65// the alignment from the column it owns.
66#define wxDVR_DEFAULT_ALIGNMENT -1
9861f022 67
87f0efe2 68
f554a14b 69// ---------------------------------------------------------
e0062c04 70// wxDataViewItem
f554a14b 71// ---------------------------------------------------------
239eaa41 72
e0062c04 73class WXDLLIMPEXP_ADV wxDataViewItem
239eaa41
RR
74{
75public:
b5ec7dd6 76 wxDataViewItem( void* id = NULL )
9d52aad3 77 { m_id = id; }
e0062c04 78 wxDataViewItem( const wxDataViewItem &item )
9d52aad3
RR
79 { m_id = item.m_id; }
80 bool IsOk() const { return m_id != NULL; }
81 void* GetID() const { return m_id; }
4f1cf94b 82 operator const void* () const { return m_id; }
b5ec7dd6 83
8f850e28 84private:
9d52aad3 85 void* m_id;
64ffb888 86};
239eaa41 87
9aa2e298
VZ
88inline
89bool operator==(const wxDataViewItem& left, const wxDataViewItem& right)
90{
91 return left.GetID() == right.GetID();
92}
93
94inline
95bool operator!=(const wxDataViewItem& left, const wxDataViewItem& right)
96{
97 return !(left == right);
98}
aba9bfd0 99
cd722937
RR
100WX_DEFINE_ARRAY(wxDataViewItem, wxDataViewItemArray);
101
9d8fe14a
RR
102// ---------------------------------------------------------
103// wxDataViewModelNotifier
104// ---------------------------------------------------------
105
106class WXDLLIMPEXP_ADV wxDataViewModelNotifier
107{
108public:
5e6f8927 109 wxDataViewModelNotifier() { m_owner = NULL; }
9d8fe14a
RR
110 virtual ~wxDataViewModelNotifier() { m_owner = NULL; }
111
112 virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ) = 0;
113 virtual bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item ) = 0;
114 virtual bool ItemChanged( const wxDataViewItem &item ) = 0;
854cdb09
RR
115 virtual bool ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items );
116 virtual bool ItemsDeleted( const wxDataViewItem &parent, const wxDataViewItemArray &items );
117 virtual bool ItemsChanged( const wxDataViewItemArray &items );
9d8fe14a
RR
118 virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col ) = 0;
119 virtual bool Cleared() = 0;
b5ec7dd6 120
d3f00f59 121 virtual void Resort() = 0;
9d8fe14a
RR
122
123 void SetOwner( wxDataViewModel *owner ) { m_owner = owner; }
e51bf699 124 wxDataViewModel *GetOwner() const { return m_owner; }
9d8fe14a
RR
125
126private:
127 wxDataViewModel *m_owner;
128};
129
130
4264606e
RR
131
132// ----------------------------------------------------------------------------
133// wxDataViewItemAttr: a structure containing the visual attributes of an item
134// ----------------------------------------------------------------------------
135
136// TODO: this should be renamed to wxItemAttr or something general like this
137
138class WXDLLIMPEXP_ADV wxDataViewItemAttr
139{
140public:
141 // ctors
c058cafa
VZ
142 wxDataViewItemAttr()
143 {
4264606e
RR
144 m_bold = false;
145 m_italic = false;
146 }
147
148 // setters
149 void SetColour(const wxColour& colour) { m_colour = colour; }
150 void SetBold( bool set ) { m_bold = set; }
151 void SetItalic( bool set ) { m_italic = set; }
c058cafa 152
4264606e
RR
153 // accessors
154 bool HasColour() const { return m_colour.Ok(); }
155 const wxColour& GetColour() const { return m_colour; }
c058cafa 156
2d0d7813 157 bool HasFont() const { return m_bold || m_italic; }
4264606e
RR
158 bool GetBold() const { return m_bold; }
159 bool GetItalic() const { return m_italic; }
160
161private:
162 wxColour m_colour;
163 bool m_bold;
164 bool m_italic;
165};
166
167
f554a14b 168// ---------------------------------------------------------
e0062c04 169// wxDataViewModel
f554a14b 170// ---------------------------------------------------------
239eaa41 171
d350fbec
VS
172WX_DECLARE_LIST_WITH_DECL(wxDataViewModelNotifier, wxDataViewModelNotifiers,
173 class WXDLLIMPEXP_ADV);
9d8fe14a 174
e4e83d3a 175class WXDLLIMPEXP_ADV wxDataViewModel: public wxRefCounter
239eaa41
RR
176{
177public:
e0062c04 178 wxDataViewModel();
239eaa41 179
9861f022 180 virtual unsigned int GetColumnCount() const = 0;
87f0efe2 181
a7f61f76 182 // return type as reported by wxVariant
9861f022 183 virtual wxString GetColumnType( unsigned int col ) const = 0;
87f0efe2 184
a7f61f76 185 // get value into a wxVariant
b5ec7dd6 186 virtual void GetValue( wxVariant &variant,
e0062c04 187 const wxDataViewItem &item, unsigned int col ) const = 0;
87f0efe2 188
a7f61f76 189 // set value, call ValueChanged() afterwards!
b5ec7dd6 190 virtual bool SetValue( const wxVariant &variant,
e0062c04 191 const wxDataViewItem &item, unsigned int col ) = 0;
239eaa41 192
4264606e
RR
193 // Get text attribute, return false of default attributes should be used
194 virtual bool GetAttr( const wxDataViewItem &WXUNUSED(item), unsigned int WXUNUSED(col), wxDataViewItemAttr &WXUNUSED(attr) )
195 { return false; }
196
e0062c04 197 // define hierachy
ed903e42
RR
198 virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const = 0;
199 virtual bool IsContainer( const wxDataViewItem &item ) const = 0;
1e40f667 200 // Is the container just a header or an item with all columns
b5ec7dd6
VZ
201 virtual bool HasContainerColumns(const wxDataViewItem& WXUNUSED(item)) const
202 { return false; }
74fe973b 203 virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const = 0;
b9b8b59c 204
239eaa41 205 // delegated notifiers
e0062c04 206 virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item );
854cdb09 207 virtual bool ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items );
469d3e9b 208 virtual bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item );
854cdb09 209 virtual bool ItemsDeleted( const wxDataViewItem &parent, const wxDataViewItemArray &items );
e0062c04 210 virtual bool ItemChanged( const wxDataViewItem &item );
854cdb09 211 virtual bool ItemsChanged( const wxDataViewItemArray &items );
e0062c04 212 virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col );
8981608c 213 virtual bool Cleared();
b5d777c7 214
ef427989
RR
215 // delegatd action
216 virtual void Resort();
217
e0062c04
RR
218 void AddNotifier( wxDataViewModelNotifier *notifier );
219 void RemoveNotifier( wxDataViewModelNotifier *notifier );
b5ec7dd6 220
ef427989 221 // default compare function
b5ec7dd6 222 virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
862de7b3 223 unsigned int column, bool ascending ) const;
09711964 224 virtual bool HasDefaultCompare() const { return false; }
c058cafa 225
2056dede 226 // internal
e39de702 227 virtual bool IsVirtualListModel() const { return false; }
66e09788 228
87f0efe2
RR
229protected:
230 // the user should not delete this class directly: he should use DecRef() instead!
5debbdcf 231 virtual ~wxDataViewModel() { }
87f0efe2 232
9d8fe14a 233 wxDataViewModelNotifiers m_notifiers;
ef427989
RR
234};
235
236// ---------------------------------------------------------
c534e696 237// wxDataViewIndexListModel
ef427989
RR
238// ---------------------------------------------------------
239
d350fbec 240class WXDLLIMPEXP_ADV wxDataViewIndexListModel: public wxDataViewModel
ef427989
RR
241{
242public:
c534e696 243 wxDataViewIndexListModel( unsigned int initial_size = 0 );
ef427989 244 ~wxDataViewIndexListModel();
b5ec7dd6 245
8eff6c56 246 virtual void GetValueByRow( wxVariant &variant,
ef427989
RR
247 unsigned int row, unsigned int col ) const = 0;
248
8eff6c56 249 virtual bool SetValueByRow( const wxVariant &variant,
ef427989 250 unsigned int row, unsigned int col ) = 0;
b5ec7dd6 251
8eff6c56 252 virtual bool GetAttrByRow( unsigned int WXUNUSED(row), unsigned int WXUNUSED(col), wxDataViewItemAttr &WXUNUSED(attr) )
4264606e 253 { return false; }
c058cafa 254
c534e696
RR
255 void RowPrepended();
256 void RowInserted( unsigned int before );
257 void RowAppended();
258 void RowDeleted( unsigned int row );
8b6cf9bf 259 void RowsDeleted( const wxArrayInt &rows );
c534e696
RR
260 void RowChanged( unsigned int row );
261 void RowValueChanged( unsigned int row, unsigned int col );
33ba5a05 262 void Reset( unsigned int new_size );
b5ec7dd6 263
c534e696 264 // convert to/from row/wxDataViewItem
b5ec7dd6 265
c534e696
RR
266 unsigned int GetRow( const wxDataViewItem &item ) const;
267 wxDataViewItem GetItem( unsigned int row ) const;
b5ec7dd6 268
c534e696 269 // compare based on index
b5ec7dd6
VZ
270
271 virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
862de7b3 272 unsigned int column, bool ascending ) const;
517166e6 273 virtual bool HasDefaultCompare() const;
c534e696
RR
274
275 // implement base methods
276
b5ec7dd6 277 virtual void GetValue( wxVariant &variant,
c534e696 278 const wxDataViewItem &item, unsigned int col ) const;
b5ec7dd6 279 virtual bool SetValue( const wxVariant &variant,
c534e696 280 const wxDataViewItem &item, unsigned int col );
4264606e 281 virtual bool GetAttr( const wxDataViewItem &item, unsigned int col, wxDataViewItemAttr &attr );
c534e696
RR
282 virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const;
283 virtual bool IsContainer( const wxDataViewItem &item ) const;
74fe973b 284 virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const;
b5ec7dd6 285
2056dede 286 // internal
e39de702 287 virtual bool IsVirtualListModel() const { return false; }
9330d5af 288 unsigned int GetCount() const { return m_hash.GetCount(); }
c058cafa 289
c534e696 290private:
cd722937 291 wxDataViewItemArray m_hash;
9330d5af 292 unsigned int m_nextFreeID;
517166e6 293 bool m_ordered;
239eaa41
RR
294};
295
e39de702
RR
296// ---------------------------------------------------------
297// wxDataViewVirtualListModel
298// ---------------------------------------------------------
299
300#ifdef __WXMAC__
301// better than nothing
f1399150 302typedef wxDataViewIndexListModel wxDataViewVirtualListModel;
e39de702
RR
303#else
304
305class WXDLLIMPEXP_ADV wxDataViewVirtualListModel: public wxDataViewModel
306{
307public:
308 wxDataViewVirtualListModel( unsigned int initial_size = 0 );
309 ~wxDataViewVirtualListModel();
310
8eff6c56 311 virtual void GetValueByRow( wxVariant &variant,
e39de702
RR
312 unsigned int row, unsigned int col ) const = 0;
313
8eff6c56 314 virtual bool SetValueByRow( const wxVariant &variant,
e39de702
RR
315 unsigned int row, unsigned int col ) = 0;
316
8eff6c56 317 virtual bool GetAttrByRow( unsigned int WXUNUSED(row), unsigned int WXUNUSED(col), wxDataViewItemAttr &WXUNUSED(attr) )
e39de702
RR
318 { return false; }
319
320 void RowPrepended();
321 void RowInserted( unsigned int before );
322 void RowAppended();
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 );
328
329 // convert to/from row/wxDataViewItem
330
331 unsigned int GetRow( const wxDataViewItem &item ) const;
332 wxDataViewItem GetItem( unsigned int row ) const;
333
334 // compare based on index
335
336 virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
862de7b3 337 unsigned int column, bool ascending ) const;
e39de702
RR
338 virtual bool HasDefaultCompare() const;
339
340 // implement base methods
341
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;
350
351 // internal
352 virtual bool IsVirtualListModel() const { return true; }
9330d5af 353 unsigned int GetCount() const { return m_size; }
e39de702
RR
354
355private:
9330d5af 356 unsigned int m_size;
e39de702
RR
357 bool m_ordered;
358};
359#endif
c33edc08 360
1e510b1e
RR
361//-----------------------------------------------------------------------------
362// wxDataViewEditorCtrlEvtHandler
363//-----------------------------------------------------------------------------
364
365class wxDataViewEditorCtrlEvtHandler: public wxEvtHandler
366{
367public:
368 wxDataViewEditorCtrlEvtHandler( wxControl *editor, wxDataViewRenderer *owner );
b5ec7dd6 369
1e510b1e 370 void AcceptChangesAndFinish();
30715fa1 371 void SetFocusOnIdle( bool focus = true ) { m_focusOnIdle = focus; }
1e510b1e
RR
372
373protected:
374 void OnChar( wxKeyEvent &event );
724852da 375 void OnTextEnter( wxCommandEvent &event );
1e510b1e 376 void OnKillFocus( wxFocusEvent &event );
30715fa1 377 void OnIdle( wxIdleEvent &event );
1e510b1e
RR
378
379private:
380 wxDataViewRenderer *m_owner;
381 wxControl *m_editorCtrl;
382 bool m_finished;
30715fa1 383 bool m_focusOnIdle;
1e510b1e
RR
384
385private:
386 DECLARE_EVENT_TABLE()
387};
388
f554a14b 389// ---------------------------------------------------------
baa9ebc4 390// wxDataViewRendererBase
f554a14b 391// ---------------------------------------------------------
fa28826d 392
6842a71a 393enum wxDataViewCellMode
fa28826d 394{
6842a71a
RR
395 wxDATAVIEW_CELL_INERT,
396 wxDATAVIEW_CELL_ACTIVATABLE,
397 wxDATAVIEW_CELL_EDITABLE
fa28826d
RR
398};
399
6842a71a
RR
400enum wxDataViewCellRenderState
401{
402 wxDATAVIEW_CELL_SELECTED = 1,
403 wxDATAVIEW_CELL_PRELIT = 2,
404 wxDATAVIEW_CELL_INSENSITIVE = 4,
405 wxDATAVIEW_CELL_FOCUSED = 8
406};
407
baa9ebc4 408class WXDLLIMPEXP_ADV wxDataViewRendererBase: public wxObject
6842a71a
RR
409{
410public:
b5ec7dd6 411 wxDataViewRendererBase( const wxString &varianttype,
9861f022
RR
412 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
413 int alignment = wxDVR_DEFAULT_ALIGNMENT );
c937bcac 414 virtual ~wxDataViewRendererBase();
6842a71a 415
9861f022
RR
416 virtual bool Validate( wxVariant& WXUNUSED(value) )
417 { return true; }
f554a14b 418
6842a71a 419 void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; }
e51bf699 420 wxDataViewColumn* GetOwner() const { return m_owner; }
f554a14b 421
9861f022
RR
422 // renderer properties:
423
424 virtual bool SetValue( const wxVariant& WXUNUSED(value) ) = 0;
425 virtual bool GetValue( wxVariant& WXUNUSED(value) ) const = 0;
426
427 wxString GetVariantType() const { return m_variantType; }
428
429 virtual void SetMode( wxDataViewCellMode mode ) = 0;
430 virtual wxDataViewCellMode GetMode() const = 0;
431
432 // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but
433 // rather an "int"; that's because for rendering cells it's allowed
434 // to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM)
435 virtual void SetAlignment( int align ) = 0;
436 virtual int GetAlignment() const = 0;
b5ec7dd6 437
c937bcac
VZ
438 // enable or disable (if called with wxELLIPSIZE_NONE) replacing parts of
439 // the item text (hence this only makes sense for renderers showing
440 // text...) with ellipsis in order to make it fit the column width
441 virtual void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE) = 0;
442 void DisableEllipsize() { EnableEllipsize(wxELLIPSIZE_NONE); }
443
444 virtual wxEllipsizeMode GetEllipsizeMode() const = 0;
445
1e510b1e 446 // in-place editing
fca0d8b5 447 virtual bool HasEditorCtrl() const
1e510b1e 448 { return false; }
96c2a0dd
VZ
449 virtual wxControl* CreateEditorCtrl(wxWindow * WXUNUSED(parent),
450 wxRect WXUNUSED(labelRect),
451 const wxVariant& WXUNUSED(value))
1e510b1e 452 { return NULL; }
96c2a0dd
VZ
453 virtual bool GetValueFromEditorCtrl(wxControl * WXUNUSED(editor),
454 wxVariant& WXUNUSED(value))
1e510b1e
RR
455 { return false; }
456
e0062c04 457 virtual bool StartEditing( const wxDataViewItem &item, wxRect labelRect );
1e510b1e
RR
458 virtual void CancelEditing();
459 virtual bool FinishEditing();
b5ec7dd6 460
1e510b1e 461 wxControl *GetEditorCtrl() { return m_editorCtrl; }
b5ec7dd6 462
a7f61f76 463protected:
6842a71a
RR
464 wxString m_variantType;
465 wxDataViewColumn *m_owner;
c232dfe5 466 wxWeakRef<wxControl> m_editorCtrl;
e0062c04 467 wxDataViewItem m_item; // for m_editorCtrl
6842a71a 468
9861f022
RR
469 // internal utility:
470 const wxDataViewCtrl* GetView() const;
471
6842a71a 472protected:
baa9ebc4 473 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase)
6842a71a
RR
474};
475
89352653
RR
476//-----------------------------------------------------------------------------
477// wxDataViewIconText
478//-----------------------------------------------------------------------------
479
d350fbec 480class WXDLLIMPEXP_ADV wxDataViewIconText: public wxObject
89352653
RR
481{
482public:
483 wxDataViewIconText( const wxString &text = wxEmptyString, const wxIcon& icon = wxNullIcon )
5e6f8927
PC
484 : m_text(text), m_icon(icon)
485 { }
89352653 486 wxDataViewIconText( const wxDataViewIconText &other )
4f271814 487 : wxObject()
344ed1f3 488 { m_icon = other.m_icon; m_text = other.m_text; }
89352653
RR
489
490 void SetText( const wxString &text ) { m_text = text; }
491 wxString GetText() const { return m_text; }
492 void SetIcon( const wxIcon &icon ) { m_icon = icon; }
493 const wxIcon &GetIcon() const { return m_icon; }
494
495private:
496 wxString m_text;
497 wxIcon m_icon;
498
499private:
500 DECLARE_DYNAMIC_CLASS(wxDataViewIconText)
501};
502
9aa2e298
VZ
503inline
504bool operator==(const wxDataViewIconText& left, const wxDataViewIconText& right)
505{
506 return left.GetText() == right.GetText() &&
507 left.GetIcon().IsSameAs(right.GetIcon());
508}
509
510inline
511bool operator!=(const wxDataViewIconText& left, const wxDataViewIconText& right)
512{
513 return !(left == right);
514}
89352653 515
d350fbec 516DECLARE_VARIANT_OBJECT_EXPORTED(wxDataViewIconText, WXDLLIMPEXP_ADV)
89352653 517
f554a14b 518// ---------------------------------------------------------
6842a71a 519// wxDataViewColumnBase
f554a14b 520// ---------------------------------------------------------
6842a71a 521
56873923 522// for compatibility only, do not use
fa28826d
RR
523enum wxDataViewColumnFlags
524{
56873923
VZ
525 wxDATAVIEW_COL_RESIZABLE = wxCOL_RESIZABLE,
526 wxDATAVIEW_COL_SORTABLE = wxCOL_SORTABLE,
527 wxDATAVIEW_COL_REORDERABLE = wxCOL_REORDERABLE,
528 wxDATAVIEW_COL_HIDDEN = wxCOL_HIDDEN
fa28826d
RR
529};
530
dcb6cbec 531class WXDLLIMPEXP_ADV wxDataViewColumnBase : public wxSettableHeaderColumn
fa28826d
RR
532{
533public:
e2bfe673
VZ
534 // ctor for the text columns: takes ownership of renderer
535 wxDataViewColumnBase(wxDataViewRenderer *renderer,
536 unsigned int model_column)
537 {
538 Init(renderer, model_column);
539 }
540
541 // ctor for the bitmap columns
542 wxDataViewColumnBase(const wxBitmap& bitmap,
543 wxDataViewRenderer *renderer,
544 unsigned int model_column)
545 : m_bitmap(bitmap)
546 {
547 Init(renderer, model_column);
548 }
549
d3c7fc99 550 virtual ~wxDataViewColumnBase();
fa28826d 551
9861f022 552 // setters:
b5ec7dd6 553 virtual void SetOwner( wxDataViewCtrl *owner )
9861f022 554 { m_owner = owner; }
f554a14b 555
9861f022 556 // getters:
e86edab0 557 unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column); }
594d5596
RR
558 wxDataViewCtrl *GetOwner() const { return m_owner; }
559 wxDataViewRenderer* GetRenderer() const { return m_renderer; }
9861f022 560
56873923
VZ
561 // implement some of base class pure virtuals (the rest is port-dependent
562 // and done differently in generic and native versions)
563 virtual void SetBitmap( const wxBitmap& bitmap ) { m_bitmap = bitmap; }
564 virtual wxBitmap GetBitmap() const { return m_bitmap; }
56873923 565
9861f022 566protected:
baa9ebc4 567 wxDataViewRenderer *m_renderer;
6842a71a 568 int m_model_column;
07a84e7b 569 wxBitmap m_bitmap;
6842a71a 570 wxDataViewCtrl *m_owner;
fa28826d 571
e2bfe673
VZ
572private:
573 // common part of all ctors
574 void Init(wxDataViewRenderer *renderer, unsigned int model_column);
fa28826d
RR
575};
576
f554a14b 577// ---------------------------------------------------------
239eaa41 578// wxDataViewCtrlBase
f554a14b 579// ---------------------------------------------------------
239eaa41 580
c21f7aa1 581#define wxDV_SINGLE 0x0000 // for convenience
9861f022
RR
582#define wxDV_MULTIPLE 0x0001 // can select multiple items
583
584#define wxDV_NO_HEADER 0x0002 // column titles not visible
585#define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows
586#define wxDV_VERT_RULES 0x0008 // light vertical rules between columns
c21f7aa1 587
1a07a730 588#define wxDV_ROW_LINES 0x0010 // alternating colour in rows
344ed1f3 589#define wxDV_VARIABLE_LINE_HEIGHT 0x0020 // variable line height
1a07a730 590
f460c29d 591class WXDLLIMPEXP_ADV wxDataViewCtrlBase: public wxControl
239eaa41
RR
592{
593public:
594 wxDataViewCtrlBase();
d3c7fc99 595 virtual ~wxDataViewCtrlBase();
f554a14b 596
ce468dc2
FM
597 // model
598 // -----
599
e0062c04
RR
600 virtual bool AssociateModel( wxDataViewModel *model );
601 wxDataViewModel* GetModel();
a75124d0 602 const wxDataViewModel* GetModel() const;
f554a14b 603
ce468dc2
FM
604
605 // column management
606 // -----------------
607
b5ec7dd6 608 wxDataViewColumn *PrependTextColumn( const wxString &label, unsigned int model_column,
736fe67c 609 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
56873923 610 wxAlignment align = wxALIGN_NOT,
736fe67c 611 int flags = wxDATAVIEW_COL_RESIZABLE );
b5ec7dd6 612 wxDataViewColumn *PrependIconTextColumn( const wxString &label, unsigned int model_column,
736fe67c 613 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
56873923 614 wxAlignment align = wxALIGN_NOT,
736fe67c
RR
615 int flags = wxDATAVIEW_COL_RESIZABLE );
616 wxDataViewColumn *PrependToggleColumn( const wxString &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 );
b5ec7dd6 620 wxDataViewColumn *PrependProgressColumn( const wxString &label, unsigned int model_column,
736fe67c
RR
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 wxString &label, unsigned int model_column,
625 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
56873923 626 wxAlignment align = wxALIGN_NOT,
736fe67c
RR
627 int flags = wxDATAVIEW_COL_RESIZABLE );
628 wxDataViewColumn *PrependBitmapColumn( const wxString &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 );
632 wxDataViewColumn *PrependTextColumn( const wxBitmap &label, unsigned int model_column,
633 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
56873923 634 wxAlignment align = wxALIGN_NOT,
736fe67c
RR
635 int flags = wxDATAVIEW_COL_RESIZABLE );
636 wxDataViewColumn *PrependIconTextColumn( const wxBitmap &label, unsigned int model_column,
637 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
56873923 638 wxAlignment align = wxALIGN_NOT,
736fe67c
RR
639 int flags = wxDATAVIEW_COL_RESIZABLE );
640 wxDataViewColumn *PrependToggleColumn( const wxBitmap &label, unsigned int model_column,
641 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
642 wxAlignment align = wxALIGN_CENTER,
643 int flags = wxDATAVIEW_COL_RESIZABLE );
644 wxDataViewColumn *PrependProgressColumn( const wxBitmap &label, unsigned int model_column,
645 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
646 wxAlignment align = wxALIGN_CENTER,
647 int flags = wxDATAVIEW_COL_RESIZABLE );
648 wxDataViewColumn *PrependDateColumn( const wxBitmap &label, unsigned int model_column,
649 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
56873923 650 wxAlignment align = wxALIGN_NOT,
736fe67c
RR
651 int flags = wxDATAVIEW_COL_RESIZABLE );
652 wxDataViewColumn *PrependBitmapColumn( const wxBitmap &label, unsigned int model_column,
653 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
654 wxAlignment align = wxALIGN_CENTER,
655 int flags = wxDATAVIEW_COL_RESIZABLE );
b5ec7dd6
VZ
656
657 wxDataViewColumn *AppendTextColumn( const wxString &label, unsigned int model_column,
87f0efe2 658 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
56873923 659 wxAlignment align = wxALIGN_NOT,
87f0efe2 660 int flags = wxDATAVIEW_COL_RESIZABLE );
b5ec7dd6 661 wxDataViewColumn *AppendIconTextColumn( const wxString &label, unsigned int model_column,
b04fcede 662 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
56873923 663 wxAlignment align = wxALIGN_NOT,
b04fcede 664 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 665 wxDataViewColumn *AppendToggleColumn( const wxString &label, unsigned int model_column,
87f0efe2
RR
666 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
667 wxAlignment align = wxALIGN_CENTER,
668 int flags = wxDATAVIEW_COL_RESIZABLE );
b5ec7dd6 669 wxDataViewColumn *AppendProgressColumn( const wxString &label, unsigned int model_column,
87f0efe2
RR
670 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
671 wxAlignment align = wxALIGN_CENTER,
672 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 673 wxDataViewColumn *AppendDateColumn( const wxString &label, unsigned int model_column,
87f0efe2 674 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
56873923 675 wxAlignment align = wxALIGN_NOT,
87f0efe2 676 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 677 wxDataViewColumn *AppendBitmapColumn( const wxString &label, unsigned int model_column,
87f0efe2
RR
678 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
679 wxAlignment align = wxALIGN_CENTER,
680 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 681 wxDataViewColumn *AppendTextColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2 682 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
56873923 683 wxAlignment align = wxALIGN_NOT,
87f0efe2 684 int flags = wxDATAVIEW_COL_RESIZABLE );
b04fcede
RR
685 wxDataViewColumn *AppendIconTextColumn( const wxBitmap &label, unsigned int model_column,
686 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
56873923 687 wxAlignment align = wxALIGN_NOT,
b04fcede 688 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 689 wxDataViewColumn *AppendToggleColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2
RR
690 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
691 wxAlignment align = wxALIGN_CENTER,
692 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 693 wxDataViewColumn *AppendProgressColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2
RR
694 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
695 wxAlignment align = wxALIGN_CENTER,
696 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 697 wxDataViewColumn *AppendDateColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2 698 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
56873923 699 wxAlignment align = wxALIGN_NOT,
87f0efe2 700 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 701 wxDataViewColumn *AppendBitmapColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2
RR
702 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
703 wxAlignment align = wxALIGN_CENTER,
704 int flags = wxDATAVIEW_COL_RESIZABLE );
736fe67c 705
736fe67c 706 virtual bool PrependColumn( wxDataViewColumn *col );
19723525 707 virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col );
f554a14b 708 virtual bool AppendColumn( wxDataViewColumn *col );
9861f022 709
91a6c655
RR
710 virtual unsigned int GetColumnCount() const = 0;
711 virtual wxDataViewColumn* GetColumn( unsigned int pos ) const = 0;
453091c2 712 virtual int GetColumnPosition( const wxDataViewColumn *column ) const = 0;
b5ec7dd6 713
91a6c655
RR
714 virtual bool DeleteColumn( wxDataViewColumn *column ) = 0;
715 virtual bool ClearColumns() = 0;
b5ec7dd6 716
1b27b2bd 717 void SetExpanderColumn( wxDataViewColumn *col )
3b6280be 718 { m_expander_column = col ; DoSetExpanderColumn(); }
b5ec7dd6 719 wxDataViewColumn *GetExpanderColumn() const
3b6280be 720 { return m_expander_column; }
b5ec7dd6 721
21f47fb9 722 virtual wxDataViewColumn *GetSortingColumn() const = 0;
23318a53 723
ce468dc2
FM
724
725 // items management
726 // ----------------
727
3b6280be
RR
728 void SetIndent( int indent )
729 { m_indent = indent ; DoSetIndent(); }
b5ec7dd6
VZ
730 int GetIndent() const
731 { return m_indent; }
3b6280be 732
fbda518c 733 virtual wxDataViewItem GetSelection() const = 0;
b7e9f8b1
RR
734 virtual int GetSelections( wxDataViewItemArray & sel ) const = 0;
735 virtual void SetSelections( const wxDataViewItemArray & sel ) = 0;
736 virtual void Select( const wxDataViewItem & item ) = 0;
737 virtual void Unselect( const wxDataViewItem & item ) = 0;
738 virtual bool IsSelected( const wxDataViewItem & item ) const = 0;
739
b7e9f8b1
RR
740 virtual void SelectAll() = 0;
741 virtual void UnselectAll() = 0;
742
f71d3ba4 743 virtual void Expand( const wxDataViewItem & item ) = 0;
4219d8b0 744 virtual void ExpandAncestors( const wxDataViewItem & item );
f71d3ba4 745 virtual void Collapse( const wxDataViewItem & item ) = 0;
739a8399 746 virtual bool IsExpanded( const wxDataViewItem & item ) const = 0;
f71d3ba4 747
6154212e 748 virtual void EnsureVisible( const wxDataViewItem & item,
4219d8b0 749 const wxDataViewColumn *column = NULL ) = 0;
a87b466d 750 virtual void HitTest( const wxPoint & point, wxDataViewItem &item, wxDataViewColumn* &column ) const = 0;
fbda518c 751 virtual wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ) const = 0;
8c2654ce 752
f54e5c1a
VZ
753#if wxUSE_DRAG_AND_DROP
754 virtual bool EnableDragSource(const wxDataFormat& WXUNUSED(format))
755 { return false; }
756 virtual bool EnableDropTarget(const wxDataFormat& WXUNUSED(format))
757 { return false; }
758#endif // wxUSE_DRAG_AND_DROP
b7e9f8b1 759
2fa90e33
VZ
760 // define control visual attributes
761 // --------------------------------
762
763 virtual wxVisualAttributes GetDefaultAttributes() const
764 {
765 return GetClassDefaultAttributes(GetWindowVariant());
766 }
767
768 static wxVisualAttributes
769 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL)
770 {
771 return wxControl::GetCompositeControlsDefaultAttributes(variant);
772 }
773
3b6280be
RR
774protected:
775 virtual void DoSetExpanderColumn() = 0 ;
776 virtual void DoSetIndent() = 0;
777
239eaa41 778private:
e0062c04 779 wxDataViewModel *m_model;
1b27b2bd 780 wxDataViewColumn *m_expander_column;
3b6280be 781 int m_indent ;
b5ec7dd6 782
239eaa41 783protected:
260b9be7 784 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase)
239eaa41 785};
bcd846ea 786
eb7f97f8
RR
787// ----------------------------------------------------------------------------
788// wxDataViewEvent - the event class for the wxDataViewCtrl notifications
789// ----------------------------------------------------------------------------
790
2f799ae8 791class WXDLLIMPEXP_ADV wxDataViewEvent : public wxNotifyEvent
eb7f97f8
RR
792{
793public:
794 wxDataViewEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
795 : wxNotifyEvent(commandType, winid),
e0062c04 796 m_item(0),
eb7f97f8 797 m_col(-1),
eb7f97f8
RR
798 m_model(NULL),
799 m_value(wxNullVariant),
6af3eec2 800 m_column(NULL),
47a8b1e1
VZ
801 m_pos(-1,-1),
802 m_cacheFrom(0),
803 m_cacheTo(0)
6effcb7c
FM
804#if wxUSE_DRAG_AND_DROP
805 , m_dataObject(NULL),
e4de825e
RR
806 m_dataBuffer(NULL),
807 m_dataSize(0)
6effcb7c 808#endif
eb7f97f8
RR
809 { }
810
811 wxDataViewEvent(const wxDataViewEvent& event)
812 : wxNotifyEvent(event),
e0062c04 813 m_item(event.m_item),
eb7f97f8 814 m_col(event.m_col),
eb7f97f8
RR
815 m_model(event.m_model),
816 m_value(event.m_value),
6af3eec2 817 m_column(event.m_column),
47a8b1e1
VZ
818 m_pos(m_pos),
819 m_cacheFrom(event.m_cacheFrom),
820 m_cacheTo(event.m_cacheTo)
6effcb7c
FM
821#if wxUSE_DRAG_AND_DROP
822 , m_dataObject(event.m_dataObject),
e4de825e
RR
823 m_dataFormat(event.m_dataFormat),
824 m_dataBuffer(event.m_dataBuffer),
825 m_dataSize(event.m_dataSize)
6effcb7c 826#endif
eb7f97f8
RR
827 { }
828
e0062c04
RR
829 wxDataViewItem GetItem() const { return m_item; }
830 void SetItem( const wxDataViewItem &item ) { m_item = item; }
831
eb7f97f8
RR
832 int GetColumn() const { return m_col; }
833 void SetColumn( int col ) { m_col = col; }
9861f022 834
eb7f97f8
RR
835 wxDataViewModel* GetModel() const { return m_model; }
836 void SetModel( wxDataViewModel *model ) { m_model = model; }
9861f022 837
eb7f97f8
RR
838 const wxVariant &GetValue() const { return m_value; }
839 void SetValue( const wxVariant &value ) { m_value = value; }
840
31fb32e1
RR
841 // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only
842 void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; }
9861f022 843 wxDataViewColumn *GetDataViewColumn() const { return m_column; }
c058cafa 844
6af3eec2 845 // for wxEVT_DATAVIEW_CONTEXT_MENU only
5cfb6fee 846 wxPoint GetPosition() const { return m_pos; }
6af3eec2 847 void SetPosition( int x, int y ) { m_pos.x = x; m_pos.y = y; }
31fb32e1 848
47a8b1e1
VZ
849 // For wxEVT_COMMAND_DATAVIEW_CACHE_HINT
850 int GetCacheFrom() const { return m_cacheFrom; }
851 int GetCacheTo() const { return m_cacheTo; }
852 void SetCache(int from, int to) { m_cacheFrom = from; m_cacheTo = to; }
853
854
62c9b3d7 855#if wxUSE_DRAG_AND_DROP
e4de825e 856 // For drag operations
591cc82d 857 void SetDataObject( wxDataObject *obj ) { m_dataObject = obj; }
e4de825e 858 wxDataObject *GetDataObject() const { return m_dataObject; }
8c2654ce 859
e4de825e
RR
860 // For drop operations
861 void SetDataFormat( const wxDataFormat &format ) { m_dataFormat = format; }
862 wxDataFormat GetDataFormat() const { return m_dataFormat; }
863 void SetDataSize( size_t size ) { m_dataSize = size; }
864 size_t GetDataSize() const { return m_dataSize; }
865 void SetDataBuffer( void* buf ) { m_dataBuffer = buf;}
866 void *GetDataBuffer() const { return m_dataBuffer; }
664e1314 867#endif // wxUSE_DRAG_AND_DROP
15cac64f 868
eb7f97f8
RR
869 virtual wxEvent *Clone() const { return new wxDataViewEvent(*this); }
870
871protected:
e0062c04 872 wxDataViewItem m_item;
eb7f97f8 873 int m_col;
eb7f97f8
RR
874 wxDataViewModel *m_model;
875 wxVariant m_value;
31fb32e1 876 wxDataViewColumn *m_column;
6af3eec2 877 wxPoint m_pos;
47a8b1e1
VZ
878 int m_cacheFrom;
879 int m_cacheTo;
8c2654ce 880
5e14f15d 881#if wxUSE_DRAG_AND_DROP
591cc82d 882 wxDataObject *m_dataObject;
8c2654ce 883
e4de825e
RR
884 wxDataFormat m_dataFormat;
885 void* m_dataBuffer;
886 size_t m_dataSize;
5e14f15d 887#endif // wxUSE_DRAG_AND_DROP
eb7f97f8
RR
888
889private:
890 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent)
891};
892
9b11752c
VZ
893wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEvent );
894
895wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEvent );
896wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED, wxDataViewEvent );
897wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED, wxDataViewEvent );
898wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING, wxDataViewEvent );
899wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING, wxDataViewEvent );
3e978cf7 900wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING, wxDataViewEvent );
9b11752c
VZ
901wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED, wxDataViewEvent );
902wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, wxDataViewEvent );
903wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, wxDataViewEvent );
904
905wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, wxDataViewEvent );
906
907wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, wxDataViewEvent );
908wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, wxDataViewEvent );
909wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, wxDataViewEvent );
910wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED, wxDataViewEvent );
911
47a8b1e1
VZ
912wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_CACHE_HINT, wxDataViewEvent );
913
9b11752c
VZ
914wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG, wxDataViewEvent );
915wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE, wxDataViewEvent );
916wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_DROP, wxDataViewEvent );
15cac64f 917
eb7f97f8
RR
918typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&);
919
920#define wxDataViewEventHandler(func) \
3c778901 921 wxEVENT_HANDLER_CAST(wxDataViewEventFunction, func)
eb7f97f8
RR
922
923#define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \
924 wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn))
925
d86c1870
RR
926#define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn)
927
e0062c04 928#define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn)
6977c3bf 929#define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn)
3ecb8a53 930#define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn)
6977c3bf 931#define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn)
3ecb8a53 932#define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn)
3e978cf7 933#define EVT_DATAVIEW_ITEM_START_EDITING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_START_EDITING, id, fn)
e0000f94
RR
934#define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn)
935#define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn)
6608fdab 936#define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn)
e0000f94 937
6af3eec2
RR
938#define EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_CONTEXT_MENU, id, fn)
939
31fb32e1
RR
940#define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn)
941#define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn)
c0a66d92 942#define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn)
e483dfcb 943#define EVT_DATAVIEW_COLUMN_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_REORDERED, id, fn)
47a8b1e1 944#define EVT_DATAVIEW_CACHE_HINT(id, fn) wx__DECLARE_DATAVIEWEVT(CACHE_HINT, id, fn)
eb7f97f8 945
591cc82d 946#define EVT_DATAVIEW_ITEM_BEGIN_DRAG(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_BEGIN_DRAG, id, fn)
e4de825e
RR
947#define EVT_DATAVIEW_ITEM_DROP_POSSIBLE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP_POSSIBLE, id, fn)
948#define EVT_DATAVIEW_ITEM_DROP(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DROP, id, fn)
fe9fb970 949
56873923
VZ
950#ifdef wxHAS_GENERIC_DATAVIEWCTRL
951 // this symbol doesn't follow the convention for wxUSE_XXX symbols which
952 // are normally always defined as either 0 or 1, so its use is deprecated
953 // and it only exists for backwards compatibility, don't use it any more
954 // and use wxHAS_GENERIC_DATAVIEWCTRL instead
955 #define wxUSE_GENERICDATAVIEWCTRL
956
957 #include "wx/generic/dataview.h"
958#elif defined(__WXGTK20__)
bcd846ea 959 #include "wx/gtk/dataview.h"
56873923 960#elif defined(__WXMAC__)
ef0e9220 961 #include "wx/osx/dataview.h"
bcd846ea 962#else
56873923 963 #error "unknown native wxDataViewCtrl implementation"
bcd846ea
RR
964#endif
965
52e750fc
RR
966// -------------------------------------
967// wxDataViewSpinRenderer
968// -------------------------------------
969
4660b556 970class WXDLLIMPEXP_ADV wxDataViewSpinRenderer: public wxDataViewCustomRenderer
52e750fc
RR
971{
972public:
973 wxDataViewSpinRenderer( int min, int max,
974 wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
975 int alignment = wxDVR_DEFAULT_ALIGNMENT );
fca0d8b5 976 virtual bool HasEditorCtrl() const { return true; }
52e750fc
RR
977 virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value );
978 virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value );
979 virtual bool Render( wxRect rect, wxDC *dc, int state );
980 virtual wxSize GetSize() const;
981 virtual bool SetValue( const wxVariant &value );
982 virtual bool GetValue( wxVariant &value ) const;
b5ec7dd6 983
52e750fc
RR
984private:
985 long m_data;
986 long m_min,m_max;
987};
988
e86edab0 989#if defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXOSX_CARBON__)
7448d67c
RR
990
991// -------------------------------------
992// wxDataViewChoiceRenderer
993// -------------------------------------
994
995class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer: public wxDataViewCustomRenderer
996{
997public:
998 wxDataViewChoiceRenderer( const wxArrayString &choices,
999 wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
1000 int alignment = wxDVR_DEFAULT_ALIGNMENT );
fca0d8b5 1001 virtual bool HasEditorCtrl() const { return true; }
7448d67c
RR
1002 virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value );
1003 virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value );
1004 virtual bool Render( wxRect rect, wxDC *dc, int state );
1005 virtual wxSize GetSize() const;
1006 virtual bool SetValue( const wxVariant &value );
1007 virtual bool GetValue( wxVariant &value ) const;
1008
1009private:
1010 wxArrayString m_choices;
1011 wxString m_data;
1012};
1013
1014#endif
1015
2d0d7813
VZ
1016// this class is obsolete, its functionality was merged in
1017// wxDataViewTextRenderer itself now, don't use it any more
1018#define wxDataViewTextRendererAttr wxDataViewTextRenderer
1019
8eff6c56
RR
1020//-----------------------------------------------------------------------------
1021// wxDataViewListStore
1022//-----------------------------------------------------------------------------
1023
1024class WXDLLIMPEXP_ADV wxDataViewListStoreLine
1025{
1026public:
1027 wxDataViewListStoreLine( wxClientData *data = NULL )
1028 {
1029 m_data = data;
1030 }
1031 virtual ~wxDataViewListStoreLine()
1032 {
1033 delete m_data;
1034 }
1035
1036 void SetData( wxClientData *data )
1037 { if (m_data) delete m_data; m_data = data; }
1038 wxClientData *GetData() const
1039 { return m_data; }
8c2654ce 1040
8eff6c56 1041 wxVector<wxVariant> m_values;
8c2654ce 1042
8eff6c56
RR
1043private:
1044 wxClientData *m_data;
1045};
1046
1047
1048class WXDLLIMPEXP_ADV wxDataViewListStore: public wxDataViewIndexListModel
1049{
1050public:
1051 wxDataViewListStore();
1052 ~wxDataViewListStore();
1053
1054 void PrependColumn( const wxString &varianttype );
1055 void InsertColumn( unsigned int pos, const wxString &varianttype );
1056 void AppendColumn( const wxString &varianttype );
8c2654ce 1057
8eff6c56
RR
1058 void AppendItem( const wxVector<wxVariant> &values, wxClientData *data = NULL );
1059 void PrependItem( const wxVector<wxVariant> &values, wxClientData *data = NULL );
1060 void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxClientData *data = NULL );
8af28fab 1061 void DeleteItem( unsigned int pos );
8eff6c56
RR
1062 void DeleteAllItems();
1063
8eff6c56
RR
1064 // override base virtuals
1065
1066 virtual unsigned int GetColumnCount() const;
1067
1068 virtual wxString GetColumnType( unsigned int col ) const;
1069
1070 virtual void GetValueByRow( wxVariant &value,
1071 unsigned int row, unsigned int col ) const;
1072
1073 virtual bool SetValueByRow( const wxVariant &value,
1074 unsigned int row, unsigned int col );
1075
8c2654ce 1076
8eff6c56
RR
1077public:
1078 wxVector<wxDataViewListStoreLine*> m_data;
1079 wxArrayString m_cols;
1080};
1081
dc813e6c
RR
1082//-----------------------------------------------------------------------------
1083
1084class WXDLLIMPEXP_ADV wxDataViewListCtrl: public wxDataViewCtrl
1085{
1086public:
1087 wxDataViewListCtrl();
1088 wxDataViewListCtrl( wxWindow *parent, wxWindowID id,
1089 const wxPoint& pos = wxDefaultPosition,
1090 const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES,
1091 const wxValidator& validator = wxDefaultValidator );
1092 ~wxDataViewListCtrl();
1093
1094 bool Create( wxWindow *parent, wxWindowID id,
1095 const wxPoint& pos = wxDefaultPosition,
1096 const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES,
1097 const wxValidator& validator = wxDefaultValidator );
1098
1099 wxDataViewListStore *GetStore()
1100 { return (wxDataViewListStore*) GetModel(); }
1101 const wxDataViewListStore *GetStore() const
1102 { return (const wxDataViewListStore*) GetModel(); }
1103
95b20f41
RR
1104 bool AppendColumn( wxDataViewColumn *column, const wxString &varianttype );
1105 bool PrependColumn( wxDataViewColumn *column, const wxString &varianttype );
1106 bool InsertColumn( unsigned int pos, wxDataViewColumn *column, const wxString &varianttype );
8c2654ce 1107
95b20f41
RR
1108 // overridden from base class
1109 virtual bool PrependColumn( wxDataViewColumn *col );
1110 virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col );
1111 virtual bool AppendColumn( wxDataViewColumn *col );
1112
f54e5c1a
VZ
1113 wxDataViewColumn *AppendTextColumn( const wxString &label,
1114 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
dc813e6c 1115 int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE );
f54e5c1a
VZ
1116 wxDataViewColumn *AppendToggleColumn( const wxString &label,
1117 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
dc813e6c 1118 int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE );
f54e5c1a
VZ
1119 wxDataViewColumn *AppendProgressColumn( const wxString &label,
1120 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
dc813e6c 1121 int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE );
f54e5c1a
VZ
1122 wxDataViewColumn *AppendIconTextColumn( const wxString &label,
1123 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
dc813e6c
RR
1124 int width = -1, wxAlignment align = wxALIGN_LEFT, int flags = wxDATAVIEW_COL_RESIZABLE );
1125
1126 void AppendItem( const wxVector<wxVariant> &values, wxClientData *data = NULL )
1127 { GetStore()->AppendItem( values, data ); }
1128 void PrependItem( const wxVector<wxVariant> &values, wxClientData *data = NULL )
1129 { GetStore()->PrependItem( values, data ); }
1130 void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxClientData *data = NULL )
1131 { GetStore()->InsertItem( row, values, data ); }
1132 void DeleteItem( unsigned row )
1133 { GetStore()->DeleteItem( row ); }
1134 void DeleteAllItems()
1135 { GetStore()->DeleteAllItems(); }
1136
1137 void SetValue( const wxVariant &value, unsigned int row, unsigned int col )
f54e5c1a 1138 { GetStore()->SetValueByRow( value, row, col );
832df171
RR
1139 GetStore()->RowValueChanged( row, col); }
1140 void GetValue( wxVariant &value, unsigned int row, unsigned int col )
1141 { GetStore()->GetValueByRow( value, row, col ); }
dc813e6c
RR
1142
1143 void SetTextValue( const wxString &value, unsigned int row, unsigned int col )
832df171
RR
1144 { GetStore()->SetValueByRow( value, row, col );
1145 GetStore()->RowValueChanged( row, col); }
dc813e6c
RR
1146 wxString GetTextValue( unsigned int row, unsigned int col ) const
1147 { wxVariant value; GetStore()->GetValueByRow( value, row, col ); return value.GetString(); }
1148
1149 void SetToggleValue( bool value, unsigned int row, unsigned int col )
832df171
RR
1150 { GetStore()->SetValueByRow( value, row, col );
1151 GetStore()->RowValueChanged( row, col); }
dc813e6c
RR
1152 bool GetToggleValue( unsigned int row, unsigned int col ) const
1153 { wxVariant value; GetStore()->GetValueByRow( value, row, col ); return value.GetBool(); }
1154
1155 void OnSize( wxSizeEvent &event );
1156
1157private:
1158 DECLARE_EVENT_TABLE()
1159 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewListCtrl)
1160};
8eff6c56 1161
e94d0c1e
RR
1162//-----------------------------------------------------------------------------
1163// wxDataViewTreeStore
1164//-----------------------------------------------------------------------------
1165
1166class WXDLLIMPEXP_ADV wxDataViewTreeStoreNode
1167{
1168public:
1169 wxDataViewTreeStoreNode( wxDataViewTreeStoreNode *parent,
1170 const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
1171 virtual ~wxDataViewTreeStoreNode();
b5ec7dd6
VZ
1172
1173 void SetText( const wxString &text )
e94d0c1e
RR
1174 { m_text = text; }
1175 wxString GetText() const
1176 { return m_text; }
1177 void SetIcon( const wxIcon &icon )
1178 { m_icon = icon; }
1179 const wxIcon &GetIcon() const
1180 { return m_icon; }
1181 void SetData( wxClientData *data )
1182 { if (m_data) delete m_data; m_data = data; }
1183 wxClientData *GetData() const
1184 { return m_data; }
b5ec7dd6 1185
e94d0c1e
RR
1186 wxDataViewItem GetItem() const
1187 { return wxDataViewItem( (void*) this ); }
b5ec7dd6 1188
e94d0c1e
RR
1189 virtual bool IsContainer()
1190 { return false; }
b5ec7dd6 1191
e94d0c1e
RR
1192 wxDataViewTreeStoreNode *GetParent()
1193 { return m_parent; }
b5ec7dd6 1194
e94d0c1e
RR
1195private:
1196 wxDataViewTreeStoreNode *m_parent;
1197 wxString m_text;
1198 wxIcon m_icon;
1199 wxClientData *m_data;
1200};
1201
1202WX_DECLARE_LIST_WITH_DECL(wxDataViewTreeStoreNode, wxDataViewTreeStoreNodeList,
1203 class WXDLLIMPEXP_ADV);
1204
1205class WXDLLIMPEXP_ADV wxDataViewTreeStoreContainerNode: public wxDataViewTreeStoreNode
1206{
1207public:
b5ec7dd6
VZ
1208 wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode *parent,
1209 const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
e94d0c1e
RR
1210 wxClientData *data = NULL );
1211 virtual ~wxDataViewTreeStoreContainerNode();
1212
b5ec7dd6 1213 const wxDataViewTreeStoreNodeList &GetChildren() const
e94d0c1e 1214 { return m_children; }
b5ec7dd6 1215 wxDataViewTreeStoreNodeList &GetChildren()
e94d0c1e
RR
1216 { return m_children; }
1217
1218 void SetExpandedIcon( const wxIcon &icon )
1219 { m_iconExpanded = icon; }
1220 const wxIcon &GetExpandedIcon() const
1221 { return m_iconExpanded; }
b5ec7dd6 1222
a75124d0
RR
1223 void SetExpanded( bool expanded = true )
1224 { m_isExpanded = expanded; }
1225 bool IsExpanded() const
1226 { return m_isExpanded; }
1227
e94d0c1e
RR
1228 virtual bool IsContainer()
1229 { return true; }
b5ec7dd6 1230
e94d0c1e
RR
1231private:
1232 wxDataViewTreeStoreNodeList m_children;
1233 wxIcon m_iconExpanded;
a75124d0 1234 bool m_isExpanded;
e94d0c1e
RR
1235};
1236
1237//-----------------------------------------------------------------------------
1238
1239class WXDLLIMPEXP_ADV wxDataViewTreeStore: public wxDataViewModel
1240{
1241public:
1242 wxDataViewTreeStore();
1243 ~wxDataViewTreeStore();
1244
b5ec7dd6 1245 wxDataViewItem AppendItem( const wxDataViewItem& parent,
e94d0c1e
RR
1246 const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
1247 wxDataViewItem PrependItem( const wxDataViewItem& parent,
1248 const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
1249 wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous,
1250 const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
b5ec7dd6
VZ
1251
1252 wxDataViewItem PrependContainer( const wxDataViewItem& parent,
1253 const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
e94d0c1e
RR
1254 wxClientData *data = NULL );
1255 wxDataViewItem AppendContainer( const wxDataViewItem& parent,
b5ec7dd6 1256 const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
e94d0c1e
RR
1257 wxClientData *data = NULL );
1258 wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous,
b5ec7dd6 1259 const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
e94d0c1e
RR
1260 wxClientData *data = NULL );
1261
1262 wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const;
1263 int GetChildCount( const wxDataViewItem& parent ) const;
b5ec7dd6 1264
e94d0c1e
RR
1265 void SetItemText( const wxDataViewItem& item, const wxString &text );
1266 wxString GetItemText( const wxDataViewItem& item ) const;
b5ec7dd6 1267 void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon );
e94d0c1e
RR
1268 const wxIcon &GetItemIcon( const wxDataViewItem& item ) const;
1269 void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon );
1270 const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const;
1271 void SetItemData( const wxDataViewItem& item, wxClientData *data );
1272 wxClientData *GetItemData( const wxDataViewItem& item ) const;
1273
1274 void DeleteItem( const wxDataViewItem& item );
1275 void DeleteChildren( const wxDataViewItem& item );
1276 void DeleteAllItems();
b5ec7dd6 1277
e94d0c1e
RR
1278 // implement base methods
1279
b5ec7dd6 1280 virtual void GetValue( wxVariant &variant,
e94d0c1e 1281 const wxDataViewItem &item, unsigned int col ) const;
b5ec7dd6 1282 virtual bool SetValue( const wxVariant &variant,
e94d0c1e
RR
1283 const wxDataViewItem &item, unsigned int col );
1284 virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const;
1285 virtual bool IsContainer( const wxDataViewItem &item ) const;
1286 virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const;
1287
b5ec7dd6 1288 virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
862de7b3 1289 unsigned int column, bool ascending ) const;
b5ec7dd6
VZ
1290
1291 virtual bool HasDefaultCompare() const
e94d0c1e 1292 { return true; }
b5ec7dd6 1293 virtual unsigned int GetColumnCount() const
e94d0c1e 1294 { return 1; };
b5ec7dd6 1295 virtual wxString GetColumnType( unsigned int WXUNUSED(col) ) const
594d5596 1296 { return wxT("wxDataViewIconText"); }
b5ec7dd6 1297
e94d0c1e
RR
1298 wxDataViewTreeStoreNode *FindNode( const wxDataViewItem &item ) const;
1299 wxDataViewTreeStoreContainerNode *FindContainerNode( const wxDataViewItem &item ) const;
1300 wxDataViewTreeStoreNode *GetRoot() const { return m_root; }
b5ec7dd6 1301
e94d0c1e
RR
1302public:
1303 wxDataViewTreeStoreNode *m_root;
1304};
1305
dc813e6c
RR
1306//-----------------------------------------------------------------------------
1307
e94d0c1e
RR
1308class WXDLLIMPEXP_ADV wxDataViewTreeCtrl: public wxDataViewCtrl
1309{
1310public:
a75124d0
RR
1311 wxDataViewTreeCtrl();
1312 wxDataViewTreeCtrl( wxWindow *parent, wxWindowID id,
e94d0c1e 1313 const wxPoint& pos = wxDefaultPosition,
1a07a730 1314 const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
e94d0c1e 1315 const wxValidator& validator = wxDefaultValidator );
a75124d0 1316 ~wxDataViewTreeCtrl();
e94d0c1e
RR
1317
1318 bool Create( wxWindow *parent, wxWindowID id,
1319 const wxPoint& pos = wxDefaultPosition,
1a07a730 1320 const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
e94d0c1e
RR
1321 const wxValidator& validator = wxDefaultValidator );
1322
1323 wxDataViewTreeStore *GetStore()
1324 { return (wxDataViewTreeStore*) GetModel(); }
a75124d0
RR
1325 const wxDataViewTreeStore *GetStore() const
1326 { return (const wxDataViewTreeStore*) GetModel(); }
b5ec7dd6 1327
a75124d0
RR
1328 void SetImageList( wxImageList *imagelist );
1329 wxImageList* GetImageList() { return m_imageList; }
c058cafa 1330
a75124d0
RR
1331 wxDataViewItem AppendItem( const wxDataViewItem& parent,
1332 const wxString &text, int icon = -1, wxClientData *data = NULL );
1333 wxDataViewItem PrependItem( const wxDataViewItem& parent,
1334 const wxString &text, int icon = -1, wxClientData *data = NULL );
1335 wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous,
1336 const wxString &text, int icon = -1, wxClientData *data = NULL );
1337
1338 wxDataViewItem PrependContainer( const wxDataViewItem& parent,
1339 const wxString &text, int icon = -1, int expanded = -1,
1340 wxClientData *data = NULL );
1341 wxDataViewItem AppendContainer( const wxDataViewItem& parent,
1342 const wxString &text, int icon = -1, int expanded = -1,
1343 wxClientData *data = NULL );
1344 wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous,
1345 const wxString &text, int icon = -1, int expanded = -1,
1346 wxClientData *data = NULL );
1347
1348 wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const
1349 { return GetStore()->GetNthChild(parent, pos); }
1350 int GetChildCount( const wxDataViewItem& parent ) const
1351 { return GetStore()->GetChildCount(parent); }
1352
e700e296 1353 void SetItemText( const wxDataViewItem& item, const wxString &text );
a75124d0
RR
1354 wxString GetItemText( const wxDataViewItem& item ) const
1355 { return GetStore()->GetItemText(item); }
e700e296 1356 void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon );
a75124d0
RR
1357 const wxIcon &GetItemIcon( const wxDataViewItem& item ) const
1358 { return GetStore()->GetItemIcon(item); }
e700e296 1359 void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon );
a75124d0
RR
1360 const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const
1361 { return GetStore()->GetItemExpandedIcon(item); }
1362 void SetItemData( const wxDataViewItem& item, wxClientData *data )
1363 { GetStore()->SetItemData(item,data); }
1364 wxClientData *GetItemData( const wxDataViewItem& item ) const
1365 { return GetStore()->GetItemData(item); }
1366
e700e296
RR
1367 void DeleteItem( const wxDataViewItem& item );
1368 void DeleteChildren( const wxDataViewItem& item );
1369 void DeleteAllItems();
a75124d0
RR
1370
1371 void OnExpanded( wxDataViewEvent &event );
1372 void OnCollapsed( wxDataViewEvent &event );
1a07a730 1373 void OnSize( wxSizeEvent &event );
b5ec7dd6 1374
e94d0c1e 1375private:
a75124d0
RR
1376 wxImageList *m_imageList;
1377
1378private:
1379 DECLARE_EVENT_TABLE()
e94d0c1e
RR
1380 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl)
1381};
e94d0c1e 1382
bcd846ea
RR
1383#endif // wxUSE_DATAVIEWCTRL
1384
1385#endif
1386 // _WX_DATAVIEW_H_BASE_