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