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