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