]> git.saurik.com Git - wxWidgets.git/blame - include/wx/dataview.h
factor out a whole bunch of duplicated code
[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
RR
19#include "wx/control.h"
20#include "wx/textctrl.h"
21#include "wx/bitmap.h"
64ffb888 22#include "wx/variant.h"
b7e9f8b1 23#include "wx/dynarray.h"
89352653 24#include "wx/icon.h"
a75124d0 25#include "wx/imaglist.h"
4ed7af08
RR
26
27#if defined(__WXGTK20__)
28 // for testing
001f0f82 29 // #define wxUSE_GENERICDATAVIEWCTRL 1
4ed7af08 30#elif defined(__WXMAC__)
4ed7af08
RR
31#else
32 #define wxUSE_GENERICDATAVIEWCTRL 1
33#endif
34
bcd846ea 35// ----------------------------------------------------------------------------
f554a14b 36// wxDataViewCtrl flags
bcd846ea
RR
37// ----------------------------------------------------------------------------
38
239eaa41
RR
39// ----------------------------------------------------------------------------
40// wxDataViewCtrl globals
41// ----------------------------------------------------------------------------
bcd846ea 42
b5dbe15d
VS
43class WXDLLIMPEXP_FWD_ADV wxDataViewItem;
44class WXDLLIMPEXP_FWD_ADV wxDataViewModel;
45class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl;
46class WXDLLIMPEXP_FWD_ADV wxDataViewColumn;
47class WXDLLIMPEXP_FWD_ADV wxDataViewRenderer;
48class WXDLLIMPEXP_FWD_ADV wxDataViewModelNotifier;
fa28826d 49
f460c29d 50extern WXDLLIMPEXP_DATA_ADV(const wxChar) wxDataViewCtrlNameStr[];
bcd846ea 51
87f0efe2
RR
52// the default width of new (text) columns:
53#define wxDVC_DEFAULT_WIDTH 80
54
55// the default width of new toggle columns:
56#define wxDVC_TOGGLE_DEFAULT_WIDTH 30
57
9861f022
RR
58// the default minimal width of the columns:
59#define wxDVC_DEFAULT_MINWIDTH 30
60
61// the default alignment of wxDataViewRenderers:
69357fa0 62#define wxDVR_DEFAULT_ALIGNMENT (wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL)
9861f022 63
87f0efe2 64
f554a14b 65// ---------------------------------------------------------
e0062c04 66// wxDataViewItem
f554a14b 67// ---------------------------------------------------------
239eaa41 68
e0062c04 69class WXDLLIMPEXP_ADV wxDataViewItem
239eaa41
RR
70{
71public:
b5ec7dd6 72 wxDataViewItem( void* id = NULL )
9d52aad3 73 { m_id = id; }
e0062c04 74 wxDataViewItem( const wxDataViewItem &item )
9d52aad3
RR
75 { m_id = item.m_id; }
76 bool IsOk() const { return m_id != NULL; }
77 void* GetID() const { return m_id; }
4f1cf94b 78 operator const void* () const { return m_id; }
b5ec7dd6 79
e94d0c1e 80#ifdef __WXDEBUG__
c3c62822 81 void Print( const wxString &text ) const;
e94d0c1e 82#endif
b5ec7dd6 83
8f850e28 84private:
9d52aad3 85 void* m_id;
64ffb888 86};
239eaa41 87
d5025dc0 88bool operator == (const wxDataViewItem &left, const wxDataViewItem &right);
aba9bfd0 89
cd722937
RR
90WX_DEFINE_ARRAY(wxDataViewItem, wxDataViewItemArray);
91
9d8fe14a
RR
92// ---------------------------------------------------------
93// wxDataViewModelNotifier
94// ---------------------------------------------------------
95
96class WXDLLIMPEXP_ADV wxDataViewModelNotifier
97{
98public:
99 wxDataViewModelNotifier() { }
100 virtual ~wxDataViewModelNotifier() { m_owner = NULL; }
101
102 virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ) = 0;
103 virtual bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item ) = 0;
104 virtual bool ItemChanged( const wxDataViewItem &item ) = 0;
854cdb09
RR
105 virtual bool ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items );
106 virtual bool ItemsDeleted( const wxDataViewItem &parent, const wxDataViewItemArray &items );
107 virtual bool ItemsChanged( const wxDataViewItemArray &items );
9d8fe14a
RR
108 virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col ) = 0;
109 virtual bool Cleared() = 0;
b5ec7dd6 110
d3f00f59 111 virtual void Resort() = 0;
9d8fe14a
RR
112
113 void SetOwner( wxDataViewModel *owner ) { m_owner = owner; }
114 wxDataViewModel *GetOwner() { return m_owner; }
115
116private:
117 wxDataViewModel *m_owner;
118};
119
120
4264606e
RR
121
122// ----------------------------------------------------------------------------
123// wxDataViewItemAttr: a structure containing the visual attributes of an item
124// ----------------------------------------------------------------------------
125
126// TODO: this should be renamed to wxItemAttr or something general like this
127
128class WXDLLIMPEXP_ADV wxDataViewItemAttr
129{
130public:
131 // ctors
132 wxDataViewItemAttr()
133 {
134 m_bold = false;
135 m_italic = false;
136 }
137
138 // setters
139 void SetColour(const wxColour& colour) { m_colour = colour; }
140 void SetBold( bool set ) { m_bold = set; }
141 void SetItalic( bool set ) { m_italic = set; }
142
143 // accessors
144 bool HasColour() const { return m_colour.Ok(); }
145 const wxColour& GetColour() const { return m_colour; }
146
147 bool GetBold() const { return m_bold; }
148 bool GetItalic() const { return m_italic; }
149
150private:
151 wxColour m_colour;
152 bool m_bold;
153 bool m_italic;
154};
155
156
f554a14b 157// ---------------------------------------------------------
e0062c04 158// wxDataViewModel
f554a14b 159// ---------------------------------------------------------
239eaa41 160
d350fbec
VS
161WX_DECLARE_LIST_WITH_DECL(wxDataViewModelNotifier, wxDataViewModelNotifiers,
162 class WXDLLIMPEXP_ADV);
9d8fe14a 163
e0062c04 164class WXDLLIMPEXP_ADV wxDataViewModel: public wxObjectRefData
239eaa41
RR
165{
166public:
e0062c04 167 wxDataViewModel();
239eaa41 168
9861f022 169 virtual unsigned int GetColumnCount() const = 0;
87f0efe2 170
a7f61f76 171 // return type as reported by wxVariant
9861f022 172 virtual wxString GetColumnType( unsigned int col ) const = 0;
87f0efe2 173
a7f61f76 174 // get value into a wxVariant
b5ec7dd6 175 virtual void GetValue( wxVariant &variant,
e0062c04 176 const wxDataViewItem &item, unsigned int col ) const = 0;
87f0efe2 177
a7f61f76 178 // set value, call ValueChanged() afterwards!
b5ec7dd6 179 virtual bool SetValue( const wxVariant &variant,
e0062c04 180 const wxDataViewItem &item, unsigned int col ) = 0;
239eaa41 181
4264606e
RR
182 // Get text attribute, return false of default attributes should be used
183 virtual bool GetAttr( const wxDataViewItem &WXUNUSED(item), unsigned int WXUNUSED(col), wxDataViewItemAttr &WXUNUSED(attr) )
184 { return false; }
185
e0062c04 186 // define hierachy
ed903e42
RR
187 virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const = 0;
188 virtual bool IsContainer( const wxDataViewItem &item ) const = 0;
1e40f667 189 // Is the container just a header or an item with all columns
b5ec7dd6
VZ
190 virtual bool HasContainerColumns(const wxDataViewItem& WXUNUSED(item)) const
191 { return false; }
74fe973b 192 virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const = 0;
b9b8b59c 193
239eaa41 194 // delegated notifiers
e0062c04 195 virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item );
854cdb09 196 virtual bool ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items );
469d3e9b 197 virtual bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item );
854cdb09 198 virtual bool ItemsDeleted( const wxDataViewItem &parent, const wxDataViewItemArray &items );
e0062c04 199 virtual bool ItemChanged( const wxDataViewItem &item );
854cdb09 200 virtual bool ItemsChanged( const wxDataViewItemArray &items );
e0062c04 201 virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col );
8981608c 202 virtual bool Cleared();
b5d777c7 203
ef427989
RR
204 // delegatd action
205 virtual void Resort();
206
e0062c04
RR
207 void AddNotifier( wxDataViewModelNotifier *notifier );
208 void RemoveNotifier( wxDataViewModelNotifier *notifier );
b5ec7dd6 209
ef427989 210 // default compare function
b5ec7dd6 211 virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
7ee7191c 212 unsigned int column, bool ascending );
09711964 213 virtual bool HasDefaultCompare() const { return false; }
2056dede
RR
214
215 // internal
216 virtual bool IsIndexListModel() const { return false; }
66e09788 217
87f0efe2
RR
218protected:
219 // the user should not delete this class directly: he should use DecRef() instead!
5debbdcf 220 virtual ~wxDataViewModel() { }
87f0efe2 221
9d8fe14a 222 wxDataViewModelNotifiers m_notifiers;
ef427989
RR
223};
224
225// ---------------------------------------------------------
c534e696 226// wxDataViewIndexListModel
ef427989
RR
227// ---------------------------------------------------------
228
d350fbec 229class WXDLLIMPEXP_ADV wxDataViewIndexListModel: public wxDataViewModel
ef427989
RR
230{
231public:
c534e696 232 wxDataViewIndexListModel( unsigned int initial_size = 0 );
ef427989 233 ~wxDataViewIndexListModel();
b5ec7dd6 234
b5ec7dd6 235 virtual void GetValue( wxVariant &variant,
ef427989
RR
236 unsigned int row, unsigned int col ) const = 0;
237
b5ec7dd6 238 virtual bool SetValue( const wxVariant &variant,
ef427989 239 unsigned int row, unsigned int col ) = 0;
b5ec7dd6 240
4264606e
RR
241 virtual bool GetAttr( unsigned int WXUNUSED(row), unsigned int WXUNUSED(col), wxDataViewItemAttr &WXUNUSED(attr) )
242 { return false; }
243
c534e696
RR
244 void RowPrepended();
245 void RowInserted( unsigned int before );
246 void RowAppended();
247 void RowDeleted( unsigned int row );
248 void RowChanged( unsigned int row );
249 void RowValueChanged( unsigned int row, unsigned int col );
b5ec7dd6 250
c534e696 251 // convert to/from row/wxDataViewItem
b5ec7dd6 252
c534e696
RR
253 unsigned int GetRow( const wxDataViewItem &item ) const;
254 wxDataViewItem GetItem( unsigned int row ) const;
b5ec7dd6 255
c534e696 256 // compare based on index
b5ec7dd6
VZ
257
258 virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
7ee7191c 259 unsigned int column, bool ascending );
517166e6 260 virtual bool HasDefaultCompare() const;
c534e696
RR
261
262 // implement base methods
263
b5ec7dd6 264 virtual void GetValue( wxVariant &variant,
c534e696 265 const wxDataViewItem &item, unsigned int col ) const;
b5ec7dd6 266 virtual bool SetValue( const wxVariant &variant,
c534e696 267 const wxDataViewItem &item, unsigned int col );
4264606e 268 virtual bool GetAttr( const wxDataViewItem &item, unsigned int col, wxDataViewItemAttr &attr );
c534e696
RR
269 virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const;
270 virtual bool IsContainer( const wxDataViewItem &item ) const;
74fe973b 271 virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const;
b5ec7dd6 272
2056dede
RR
273 // internal
274 virtual bool IsIndexListModel() const { return true; }
275 unsigned int GetLastIndex() const { return m_lastIndex; }
276
c534e696 277private:
cd722937 278 wxDataViewItemArray m_hash;
c534e696 279 unsigned int m_lastIndex;
517166e6 280 bool m_ordered;
2056dede 281 bool m_useHash;
239eaa41
RR
282};
283
c33edc08 284
1e510b1e
RR
285//-----------------------------------------------------------------------------
286// wxDataViewEditorCtrlEvtHandler
287//-----------------------------------------------------------------------------
288
289class wxDataViewEditorCtrlEvtHandler: public wxEvtHandler
290{
291public:
292 wxDataViewEditorCtrlEvtHandler( wxControl *editor, wxDataViewRenderer *owner );
b5ec7dd6 293
1e510b1e 294 void AcceptChangesAndFinish();
30715fa1 295 void SetFocusOnIdle( bool focus = true ) { m_focusOnIdle = focus; }
1e510b1e
RR
296
297protected:
298 void OnChar( wxKeyEvent &event );
299 void OnKillFocus( wxFocusEvent &event );
30715fa1 300 void OnIdle( wxIdleEvent &event );
1e510b1e
RR
301
302private:
303 wxDataViewRenderer *m_owner;
304 wxControl *m_editorCtrl;
305 bool m_finished;
30715fa1 306 bool m_focusOnIdle;
1e510b1e
RR
307
308private:
309 DECLARE_EVENT_TABLE()
310};
311
f554a14b 312// ---------------------------------------------------------
baa9ebc4 313// wxDataViewRendererBase
f554a14b 314// ---------------------------------------------------------
fa28826d 315
6842a71a 316enum wxDataViewCellMode
fa28826d 317{
6842a71a
RR
318 wxDATAVIEW_CELL_INERT,
319 wxDATAVIEW_CELL_ACTIVATABLE,
320 wxDATAVIEW_CELL_EDITABLE
fa28826d
RR
321};
322
6842a71a
RR
323enum wxDataViewCellRenderState
324{
325 wxDATAVIEW_CELL_SELECTED = 1,
326 wxDATAVIEW_CELL_PRELIT = 2,
327 wxDATAVIEW_CELL_INSENSITIVE = 4,
328 wxDATAVIEW_CELL_FOCUSED = 8
329};
330
baa9ebc4 331class WXDLLIMPEXP_ADV wxDataViewRendererBase: public wxObject
6842a71a
RR
332{
333public:
b5ec7dd6 334 wxDataViewRendererBase( const wxString &varianttype,
9861f022
RR
335 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
336 int alignment = wxDVR_DEFAULT_ALIGNMENT );
6842a71a 337
9861f022
RR
338 virtual bool Validate( wxVariant& WXUNUSED(value) )
339 { return true; }
f554a14b 340
6842a71a
RR
341 void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; }
342 wxDataViewColumn* GetOwner() { return m_owner; }
f554a14b 343
9861f022
RR
344 // renderer properties:
345
346 virtual bool SetValue( const wxVariant& WXUNUSED(value) ) = 0;
347 virtual bool GetValue( wxVariant& WXUNUSED(value) ) const = 0;
348
349 wxString GetVariantType() const { return m_variantType; }
350
351 virtual void SetMode( wxDataViewCellMode mode ) = 0;
352 virtual wxDataViewCellMode GetMode() const = 0;
353
354 // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but
355 // rather an "int"; that's because for rendering cells it's allowed
356 // to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM)
357 virtual void SetAlignment( int align ) = 0;
358 virtual int GetAlignment() const = 0;
b5ec7dd6 359
1e510b1e
RR
360 // in-place editing
361 virtual bool HasEditorCtrl()
362 { return false; }
96c2a0dd
VZ
363 virtual wxControl* CreateEditorCtrl(wxWindow * WXUNUSED(parent),
364 wxRect WXUNUSED(labelRect),
365 const wxVariant& WXUNUSED(value))
1e510b1e 366 { return NULL; }
96c2a0dd
VZ
367 virtual bool GetValueFromEditorCtrl(wxControl * WXUNUSED(editor),
368 wxVariant& WXUNUSED(value))
1e510b1e
RR
369 { return false; }
370
e0062c04 371 virtual bool StartEditing( const wxDataViewItem &item, wxRect labelRect );
1e510b1e
RR
372 virtual void CancelEditing();
373 virtual bool FinishEditing();
b5ec7dd6 374
1e510b1e 375 wxControl *GetEditorCtrl() { return m_editorCtrl; }
b5ec7dd6 376
a7f61f76 377protected:
6842a71a
RR
378 wxString m_variantType;
379 wxDataViewColumn *m_owner;
1e510b1e 380 wxControl *m_editorCtrl;
e0062c04 381 wxDataViewItem m_item; // for m_editorCtrl
6842a71a 382
9861f022
RR
383 // internal utility:
384 const wxDataViewCtrl* GetView() const;
385
6842a71a 386protected:
baa9ebc4 387 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase)
6842a71a
RR
388};
389
89352653
RR
390//-----------------------------------------------------------------------------
391// wxDataViewIconText
392//-----------------------------------------------------------------------------
393
d350fbec 394class WXDLLIMPEXP_ADV wxDataViewIconText: public wxObject
89352653
RR
395{
396public:
397 wxDataViewIconText( const wxString &text = wxEmptyString, const wxIcon& icon = wxNullIcon )
398 { m_icon = icon; m_text = text; }
399 wxDataViewIconText( const wxDataViewIconText &other )
400 { m_icon = other.m_icon; m_text = other.m_text; }
401
402 void SetText( const wxString &text ) { m_text = text; }
403 wxString GetText() const { return m_text; }
404 void SetIcon( const wxIcon &icon ) { m_icon = icon; }
405 const wxIcon &GetIcon() const { return m_icon; }
406
407private:
408 wxString m_text;
409 wxIcon m_icon;
410
411private:
412 DECLARE_DYNAMIC_CLASS(wxDataViewIconText)
413};
414
415bool operator == (const wxDataViewIconText &one, const wxDataViewIconText &two);
416
d350fbec 417DECLARE_VARIANT_OBJECT_EXPORTED(wxDataViewIconText, WXDLLIMPEXP_ADV)
89352653 418
f554a14b 419// ---------------------------------------------------------
6842a71a 420// wxDataViewColumnBase
f554a14b 421// ---------------------------------------------------------
6842a71a 422
fa28826d
RR
423enum wxDataViewColumnFlags
424{
425 wxDATAVIEW_COL_RESIZABLE = 1,
426 wxDATAVIEW_COL_SORTABLE = 2,
427 wxDATAVIEW_COL_HIDDEN = 4
428};
429
f460c29d 430class WXDLLIMPEXP_ADV wxDataViewColumnBase: public wxObject
fa28826d
RR
431{
432public:
b5ec7dd6
VZ
433 wxDataViewColumnBase( const wxString &title, wxDataViewRenderer *renderer,
434 unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
87f0efe2
RR
435 wxAlignment align = wxALIGN_CENTER,
436 int flags = wxDATAVIEW_COL_RESIZABLE );
b5ec7dd6
VZ
437 wxDataViewColumnBase( const wxBitmap &bitmap, wxDataViewRenderer *renderer,
438 unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
87f0efe2
RR
439 wxAlignment align = wxALIGN_CENTER,
440 int flags = wxDATAVIEW_COL_RESIZABLE );
d3c7fc99 441 virtual ~wxDataViewColumnBase();
fa28826d 442
9861f022 443 // setters:
07b6378f 444
9861f022 445 virtual void SetTitle( const wxString &title ) = 0;
47cef10f 446 virtual void SetAlignment( wxAlignment align ) = 0;
31fb32e1 447 virtual void SetSortable( bool sortable ) = 0;
9861f022
RR
448 virtual void SetResizeable( bool resizeable ) = 0;
449 virtual void SetHidden( bool hidden ) = 0;
47cef10f 450 virtual void SetSortOrder( bool ascending ) = 0;
9861f022 451 virtual void SetFlags( int flags );
b5ec7dd6 452 virtual void SetOwner( wxDataViewCtrl *owner )
9861f022
RR
453 { m_owner = owner; }
454 virtual void SetBitmap( const wxBitmap &bitmap )
455 { m_bitmap=bitmap; }
07a84e7b 456
9861f022
RR
457 virtual void SetMinWidth( int minWidth ) = 0;
458 virtual void SetWidth( int width ) = 0;
f554a14b 459
f554a14b 460
9861f022 461 // getters:
07b6378f 462
9861f022
RR
463 virtual wxString GetTitle() const = 0;
464 virtual wxAlignment GetAlignment() const = 0;
87f0efe2 465 virtual int GetWidth() const = 0;
9861f022 466 virtual int GetMinWidth() const = 0;
07b6378f 467
9861f022
RR
468 virtual int GetFlags() const;
469
470 virtual bool IsSortable() const = 0;
471 virtual bool IsResizeable() const = 0;
472 virtual bool IsHidden() const = 0;
473 virtual bool IsSortOrderAscending() const = 0;
474
475 const wxBitmap &GetBitmap() const { return m_bitmap; }
6d9ecc87 476 unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column); }
9861f022 477
594d5596
RR
478 wxDataViewCtrl *GetOwner() const { return m_owner; }
479 wxDataViewRenderer* GetRenderer() const { return m_renderer; }
9861f022
RR
480
481protected:
baa9ebc4 482 wxDataViewRenderer *m_renderer;
6842a71a 483 int m_model_column;
07a84e7b 484 wxBitmap m_bitmap;
6842a71a 485 wxDataViewCtrl *m_owner;
fa28826d
RR
486
487protected:
488 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase)
489};
490
f554a14b 491// ---------------------------------------------------------
239eaa41 492// wxDataViewCtrlBase
f554a14b 493// ---------------------------------------------------------
239eaa41 494
c21f7aa1 495#define wxDV_SINGLE 0x0000 // for convenience
9861f022
RR
496#define wxDV_MULTIPLE 0x0001 // can select multiple items
497
498#define wxDV_NO_HEADER 0x0002 // column titles not visible
499#define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows
500#define wxDV_VERT_RULES 0x0008 // light vertical rules between columns
c21f7aa1 501
1a07a730
RR
502#define wxDV_ROW_LINES 0x0010 // alternating colour in rows
503
f460c29d 504class WXDLLIMPEXP_ADV wxDataViewCtrlBase: public wxControl
239eaa41
RR
505{
506public:
507 wxDataViewCtrlBase();
d3c7fc99 508 virtual ~wxDataViewCtrlBase();
f554a14b 509
e0062c04
RR
510 virtual bool AssociateModel( wxDataViewModel *model );
511 wxDataViewModel* GetModel();
a75124d0 512 const wxDataViewModel* GetModel() const;
f554a14b 513
07a84e7b 514 // short cuts
b5ec7dd6 515 wxDataViewColumn *PrependTextColumn( const wxString &label, unsigned int model_column,
736fe67c
RR
516 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
517 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
518 int flags = wxDATAVIEW_COL_RESIZABLE );
b5ec7dd6 519 wxDataViewColumn *PrependIconTextColumn( const wxString &label, unsigned int model_column,
736fe67c
RR
520 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
521 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
522 int flags = wxDATAVIEW_COL_RESIZABLE );
523 wxDataViewColumn *PrependToggleColumn( const wxString &label, unsigned int model_column,
524 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
525 wxAlignment align = wxALIGN_CENTER,
526 int flags = wxDATAVIEW_COL_RESIZABLE );
b5ec7dd6 527 wxDataViewColumn *PrependProgressColumn( const wxString &label, unsigned int model_column,
736fe67c
RR
528 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
529 wxAlignment align = wxALIGN_CENTER,
530 int flags = wxDATAVIEW_COL_RESIZABLE );
531 wxDataViewColumn *PrependDateColumn( const wxString &label, unsigned int model_column,
532 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
533 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
534 int flags = wxDATAVIEW_COL_RESIZABLE );
535 wxDataViewColumn *PrependBitmapColumn( const wxString &label, unsigned int model_column,
536 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
537 wxAlignment align = wxALIGN_CENTER,
538 int flags = wxDATAVIEW_COL_RESIZABLE );
539 wxDataViewColumn *PrependTextColumn( const wxBitmap &label, unsigned int model_column,
540 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
541 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
542 int flags = wxDATAVIEW_COL_RESIZABLE );
543 wxDataViewColumn *PrependIconTextColumn( const wxBitmap &label, unsigned int model_column,
544 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
545 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
546 int flags = wxDATAVIEW_COL_RESIZABLE );
547 wxDataViewColumn *PrependToggleColumn( const wxBitmap &label, unsigned int model_column,
548 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
549 wxAlignment align = wxALIGN_CENTER,
550 int flags = wxDATAVIEW_COL_RESIZABLE );
551 wxDataViewColumn *PrependProgressColumn( const wxBitmap &label, unsigned int model_column,
552 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
553 wxAlignment align = wxALIGN_CENTER,
554 int flags = wxDATAVIEW_COL_RESIZABLE );
555 wxDataViewColumn *PrependDateColumn( const wxBitmap &label, unsigned int model_column,
556 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
557 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
558 int flags = wxDATAVIEW_COL_RESIZABLE );
559 wxDataViewColumn *PrependBitmapColumn( const wxBitmap &label, unsigned int model_column,
560 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
561 wxAlignment align = wxALIGN_CENTER,
562 int flags = wxDATAVIEW_COL_RESIZABLE );
b5ec7dd6
VZ
563
564 wxDataViewColumn *AppendTextColumn( const wxString &label, unsigned int model_column,
87f0efe2 565 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
e2da67f6 566 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
87f0efe2 567 int flags = wxDATAVIEW_COL_RESIZABLE );
b5ec7dd6 568 wxDataViewColumn *AppendIconTextColumn( const wxString &label, unsigned int model_column,
b04fcede 569 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
e2da67f6 570 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
b04fcede 571 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 572 wxDataViewColumn *AppendToggleColumn( const wxString &label, unsigned int model_column,
87f0efe2
RR
573 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
574 wxAlignment align = wxALIGN_CENTER,
575 int flags = wxDATAVIEW_COL_RESIZABLE );
b5ec7dd6 576 wxDataViewColumn *AppendProgressColumn( const wxString &label, unsigned int model_column,
87f0efe2
RR
577 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
578 wxAlignment align = wxALIGN_CENTER,
579 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 580 wxDataViewColumn *AppendDateColumn( const wxString &label, unsigned int model_column,
87f0efe2 581 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
e2da67f6 582 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
87f0efe2 583 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 584 wxDataViewColumn *AppendBitmapColumn( const wxString &label, unsigned int model_column,
87f0efe2
RR
585 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
586 wxAlignment align = wxALIGN_CENTER,
587 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 588 wxDataViewColumn *AppendTextColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2 589 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
e2da67f6 590 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
87f0efe2 591 int flags = wxDATAVIEW_COL_RESIZABLE );
b04fcede
RR
592 wxDataViewColumn *AppendIconTextColumn( const wxBitmap &label, unsigned int model_column,
593 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
e2da67f6 594 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
b04fcede 595 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 596 wxDataViewColumn *AppendToggleColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2
RR
597 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
598 wxAlignment align = wxALIGN_CENTER,
599 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 600 wxDataViewColumn *AppendProgressColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2
RR
601 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
602 wxAlignment align = wxALIGN_CENTER,
603 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 604 wxDataViewColumn *AppendDateColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2 605 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
e2da67f6 606 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
87f0efe2 607 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 608 wxDataViewColumn *AppendBitmapColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2
RR
609 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
610 wxAlignment align = wxALIGN_CENTER,
611 int flags = wxDATAVIEW_COL_RESIZABLE );
736fe67c
RR
612
613
614 virtual bool PrependColumn( wxDataViewColumn *col );
f554a14b 615 virtual bool AppendColumn( wxDataViewColumn *col );
9861f022 616
91a6c655
RR
617 virtual unsigned int GetColumnCount() const = 0;
618 virtual wxDataViewColumn* GetColumn( unsigned int pos ) const = 0;
453091c2 619 virtual int GetColumnPosition( const wxDataViewColumn *column ) const = 0;
b5ec7dd6 620
91a6c655
RR
621 virtual bool DeleteColumn( wxDataViewColumn *column ) = 0;
622 virtual bool ClearColumns() = 0;
b5ec7dd6 623
1b27b2bd 624 void SetExpanderColumn( wxDataViewColumn *col )
3b6280be 625 { m_expander_column = col ; DoSetExpanderColumn(); }
b5ec7dd6 626 wxDataViewColumn *GetExpanderColumn() const
3b6280be 627 { return m_expander_column; }
b5ec7dd6 628
21f47fb9 629 virtual wxDataViewColumn *GetSortingColumn() const = 0;
3b6280be
RR
630
631 void SetIndent( int indent )
632 { m_indent = indent ; DoSetIndent(); }
b5ec7dd6
VZ
633 int GetIndent() const
634 { return m_indent; }
3b6280be 635
fbda518c 636 virtual wxDataViewItem GetSelection() const = 0;
b7e9f8b1
RR
637 virtual int GetSelections( wxDataViewItemArray & sel ) const = 0;
638 virtual void SetSelections( const wxDataViewItemArray & sel ) = 0;
639 virtual void Select( const wxDataViewItem & item ) = 0;
640 virtual void Unselect( const wxDataViewItem & item ) = 0;
641 virtual bool IsSelected( const wxDataViewItem & item ) const = 0;
642
b7e9f8b1
RR
643 virtual void SelectAll() = 0;
644 virtual void UnselectAll() = 0;
645
f71d3ba4
RR
646 virtual void Expand( const wxDataViewItem & item ) = 0;
647 virtual void Collapse( const wxDataViewItem & item ) = 0;
648
6154212e 649 virtual void EnsureVisible( const wxDataViewItem & item,
fbda518c 650 const wxDataViewColumn *column = NULL ) = 0;
a87b466d 651 virtual void HitTest( const wxPoint & point, wxDataViewItem &item, wxDataViewColumn* &column ) const = 0;
fbda518c 652 virtual wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ) const = 0;
b7e9f8b1 653
3b6280be
RR
654protected:
655 virtual void DoSetExpanderColumn() = 0 ;
656 virtual void DoSetIndent() = 0;
657
239eaa41 658private:
e0062c04 659 wxDataViewModel *m_model;
1b27b2bd 660 wxDataViewColumn *m_expander_column;
3b6280be 661 int m_indent ;
b5ec7dd6 662
239eaa41 663protected:
260b9be7 664 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase)
239eaa41 665};
bcd846ea 666
eb7f97f8
RR
667// ----------------------------------------------------------------------------
668// wxDataViewEvent - the event class for the wxDataViewCtrl notifications
669// ----------------------------------------------------------------------------
670
2f799ae8 671class WXDLLIMPEXP_ADV wxDataViewEvent : public wxNotifyEvent
eb7f97f8
RR
672{
673public:
674 wxDataViewEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
675 : wxNotifyEvent(commandType, winid),
e0062c04 676 m_item(0),
eb7f97f8 677 m_col(-1),
eb7f97f8
RR
678 m_model(NULL),
679 m_value(wxNullVariant),
6af3eec2
RR
680 m_column(NULL),
681 m_pos(-1,-1)
eb7f97f8
RR
682 { }
683
684 wxDataViewEvent(const wxDataViewEvent& event)
685 : wxNotifyEvent(event),
e0062c04 686 m_item(event.m_item),
eb7f97f8 687 m_col(event.m_col),
eb7f97f8
RR
688 m_model(event.m_model),
689 m_value(event.m_value),
6af3eec2
RR
690 m_column(event.m_column),
691 m_pos(m_pos)
eb7f97f8
RR
692 { }
693
e0062c04
RR
694 wxDataViewItem GetItem() const { return m_item; }
695 void SetItem( const wxDataViewItem &item ) { m_item = item; }
696
eb7f97f8
RR
697 int GetColumn() const { return m_col; }
698 void SetColumn( int col ) { m_col = col; }
9861f022 699
eb7f97f8
RR
700 wxDataViewModel* GetModel() const { return m_model; }
701 void SetModel( wxDataViewModel *model ) { m_model = model; }
9861f022 702
eb7f97f8
RR
703 const wxVariant &GetValue() const { return m_value; }
704 void SetValue( const wxVariant &value ) { m_value = value; }
705
31fb32e1
RR
706 // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only
707 void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; }
9861f022 708 wxDataViewColumn *GetDataViewColumn() const { return m_column; }
6af3eec2
RR
709
710 // for wxEVT_DATAVIEW_CONTEXT_MENU only
711 wxPoint GetPosition() const;
712 void SetPosition( int x, int y ) { m_pos.x = x; m_pos.y = y; }
31fb32e1 713
eb7f97f8
RR
714 virtual wxEvent *Clone() const { return new wxDataViewEvent(*this); }
715
716protected:
e0062c04 717 wxDataViewItem m_item;
eb7f97f8 718 int m_col;
eb7f97f8
RR
719 wxDataViewModel *m_model;
720 wxVariant m_value;
31fb32e1 721 wxDataViewColumn *m_column;
6af3eec2 722 wxPoint m_pos;
eb7f97f8
RR
723
724private:
725 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent)
726};
727
728BEGIN_DECLARE_EVENT_TYPES()
d86c1870 729 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, -1)
b5ec7dd6 730
e0062c04 731 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, -1)
d209a914
RR
732 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED, -1)
733 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED, -1)
6977c3bf
RR
734 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING, -1)
735 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING, -1)
e0000f94
RR
736 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED, -1)
737 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, -1)
6608fdab 738 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, -1)
6af3eec2
RR
739
740 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, -1)
b5ec7dd6 741
e07c1146
PC
742 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, -1)
743 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, -1)
c0a66d92 744 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, -1)
eb7f97f8
RR
745END_DECLARE_EVENT_TYPES()
746
747typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&);
748
749#define wxDataViewEventHandler(func) \
750 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxDataViewEventFunction, &func)
751
752#define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \
753 wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn))
754
d86c1870
RR
755#define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn)
756
e0062c04 757#define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn)
6977c3bf 758#define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn)
3ecb8a53 759#define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn)
6977c3bf 760#define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn)
3ecb8a53 761#define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn)
e0000f94
RR
762#define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn)
763#define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn)
6608fdab 764#define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn)
e0000f94 765
6af3eec2
RR
766#define EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_CONTEXT_MENU, id, fn)
767
31fb32e1
RR
768#define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn)
769#define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn)
c0a66d92 770#define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn)
eb7f97f8 771
4ed7af08
RR
772#if defined(wxUSE_GENERICDATAVIEWCTRL)
773 #include "wx/generic/dataview.h"
774#elif defined(__WXGTK20__)
bcd846ea
RR
775 #include "wx/gtk/dataview.h"
776#elif defined(__WXMAC__)
c0a66d92 777 #include "wx/mac/dataview.h"
bcd846ea
RR
778#else
779 #include "wx/generic/dataview.h"
780#endif
781
52e750fc
RR
782// -------------------------------------
783// wxDataViewSpinRenderer
784// -------------------------------------
785
4660b556 786class WXDLLIMPEXP_ADV wxDataViewSpinRenderer: public wxDataViewCustomRenderer
52e750fc
RR
787{
788public:
789 wxDataViewSpinRenderer( int min, int max,
790 wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
791 int alignment = wxDVR_DEFAULT_ALIGNMENT );
792 virtual bool HasEditorCtrl() { return true; }
793 virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value );
794 virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value );
795 virtual bool Render( wxRect rect, wxDC *dc, int state );
796 virtual wxSize GetSize() const;
797 virtual bool SetValue( const wxVariant &value );
798 virtual bool GetValue( wxVariant &value ) const;
b5ec7dd6 799
52e750fc
RR
800private:
801 long m_data;
802 long m_min,m_max;
803};
804
e94d0c1e
RR
805//-----------------------------------------------------------------------------
806// wxDataViewTreeStore
807//-----------------------------------------------------------------------------
808
809class WXDLLIMPEXP_ADV wxDataViewTreeStoreNode
810{
811public:
812 wxDataViewTreeStoreNode( wxDataViewTreeStoreNode *parent,
813 const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
814 virtual ~wxDataViewTreeStoreNode();
b5ec7dd6
VZ
815
816 void SetText( const wxString &text )
e94d0c1e
RR
817 { m_text = text; }
818 wxString GetText() const
819 { return m_text; }
820 void SetIcon( const wxIcon &icon )
821 { m_icon = icon; }
822 const wxIcon &GetIcon() const
823 { return m_icon; }
824 void SetData( wxClientData *data )
825 { if (m_data) delete m_data; m_data = data; }
826 wxClientData *GetData() const
827 { return m_data; }
b5ec7dd6 828
e94d0c1e
RR
829 wxDataViewItem GetItem() const
830 { return wxDataViewItem( (void*) this ); }
b5ec7dd6 831
e94d0c1e
RR
832 virtual bool IsContainer()
833 { return false; }
b5ec7dd6 834
e94d0c1e
RR
835 wxDataViewTreeStoreNode *GetParent()
836 { return m_parent; }
b5ec7dd6 837
e94d0c1e
RR
838private:
839 wxDataViewTreeStoreNode *m_parent;
840 wxString m_text;
841 wxIcon m_icon;
842 wxClientData *m_data;
843};
844
845WX_DECLARE_LIST_WITH_DECL(wxDataViewTreeStoreNode, wxDataViewTreeStoreNodeList,
846 class WXDLLIMPEXP_ADV);
847
848class WXDLLIMPEXP_ADV wxDataViewTreeStoreContainerNode: public wxDataViewTreeStoreNode
849{
850public:
b5ec7dd6
VZ
851 wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode *parent,
852 const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
e94d0c1e
RR
853 wxClientData *data = NULL );
854 virtual ~wxDataViewTreeStoreContainerNode();
855
b5ec7dd6 856 const wxDataViewTreeStoreNodeList &GetChildren() const
e94d0c1e 857 { return m_children; }
b5ec7dd6 858 wxDataViewTreeStoreNodeList &GetChildren()
e94d0c1e
RR
859 { return m_children; }
860
861 void SetExpandedIcon( const wxIcon &icon )
862 { m_iconExpanded = icon; }
863 const wxIcon &GetExpandedIcon() const
864 { return m_iconExpanded; }
b5ec7dd6 865
a75124d0
RR
866 void SetExpanded( bool expanded = true )
867 { m_isExpanded = expanded; }
868 bool IsExpanded() const
869 { return m_isExpanded; }
870
e94d0c1e
RR
871 virtual bool IsContainer()
872 { return true; }
b5ec7dd6 873
e94d0c1e
RR
874private:
875 wxDataViewTreeStoreNodeList m_children;
876 wxIcon m_iconExpanded;
a75124d0 877 bool m_isExpanded;
e94d0c1e
RR
878};
879
880//-----------------------------------------------------------------------------
881
882class WXDLLIMPEXP_ADV wxDataViewTreeStore: public wxDataViewModel
883{
884public:
885 wxDataViewTreeStore();
886 ~wxDataViewTreeStore();
887
b5ec7dd6 888 wxDataViewItem AppendItem( const wxDataViewItem& parent,
e94d0c1e
RR
889 const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
890 wxDataViewItem PrependItem( const wxDataViewItem& parent,
891 const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
892 wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous,
893 const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
b5ec7dd6
VZ
894
895 wxDataViewItem PrependContainer( const wxDataViewItem& parent,
896 const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
e94d0c1e
RR
897 wxClientData *data = NULL );
898 wxDataViewItem AppendContainer( const wxDataViewItem& parent,
b5ec7dd6 899 const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
e94d0c1e
RR
900 wxClientData *data = NULL );
901 wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous,
b5ec7dd6 902 const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
e94d0c1e
RR
903 wxClientData *data = NULL );
904
905 wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const;
906 int GetChildCount( const wxDataViewItem& parent ) const;
b5ec7dd6 907
e94d0c1e
RR
908 void SetItemText( const wxDataViewItem& item, const wxString &text );
909 wxString GetItemText( const wxDataViewItem& item ) const;
b5ec7dd6 910 void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon );
e94d0c1e
RR
911 const wxIcon &GetItemIcon( const wxDataViewItem& item ) const;
912 void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon );
913 const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const;
914 void SetItemData( const wxDataViewItem& item, wxClientData *data );
915 wxClientData *GetItemData( const wxDataViewItem& item ) const;
916
917 void DeleteItem( const wxDataViewItem& item );
918 void DeleteChildren( const wxDataViewItem& item );
919 void DeleteAllItems();
b5ec7dd6 920
e94d0c1e
RR
921 // implement base methods
922
b5ec7dd6 923 virtual void GetValue( wxVariant &variant,
e94d0c1e 924 const wxDataViewItem &item, unsigned int col ) const;
b5ec7dd6 925 virtual bool SetValue( const wxVariant &variant,
e94d0c1e
RR
926 const wxDataViewItem &item, unsigned int col );
927 virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const;
928 virtual bool IsContainer( const wxDataViewItem &item ) const;
929 virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const;
930
b5ec7dd6 931 virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
e94d0c1e 932 unsigned int column, bool ascending );
b5ec7dd6
VZ
933
934 virtual bool HasDefaultCompare() const
e94d0c1e 935 { return true; }
b5ec7dd6 936 virtual unsigned int GetColumnCount() const
e94d0c1e 937 { return 1; };
b5ec7dd6 938 virtual wxString GetColumnType( unsigned int WXUNUSED(col) ) const
594d5596 939 { return wxT("wxDataViewIconText"); }
b5ec7dd6 940
e94d0c1e
RR
941 wxDataViewTreeStoreNode *FindNode( const wxDataViewItem &item ) const;
942 wxDataViewTreeStoreContainerNode *FindContainerNode( const wxDataViewItem &item ) const;
943 wxDataViewTreeStoreNode *GetRoot() const { return m_root; }
b5ec7dd6 944
e94d0c1e
RR
945public:
946 wxDataViewTreeStoreNode *m_root;
947};
948
e94d0c1e
RR
949class WXDLLIMPEXP_ADV wxDataViewTreeCtrl: public wxDataViewCtrl
950{
951public:
a75124d0
RR
952 wxDataViewTreeCtrl();
953 wxDataViewTreeCtrl( wxWindow *parent, wxWindowID id,
e94d0c1e 954 const wxPoint& pos = wxDefaultPosition,
1a07a730 955 const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
e94d0c1e 956 const wxValidator& validator = wxDefaultValidator );
a75124d0 957 ~wxDataViewTreeCtrl();
e94d0c1e
RR
958
959 bool Create( wxWindow *parent, wxWindowID id,
960 const wxPoint& pos = wxDefaultPosition,
1a07a730 961 const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
e94d0c1e
RR
962 const wxValidator& validator = wxDefaultValidator );
963
964 wxDataViewTreeStore *GetStore()
965 { return (wxDataViewTreeStore*) GetModel(); }
a75124d0
RR
966 const wxDataViewTreeStore *GetStore() const
967 { return (const wxDataViewTreeStore*) GetModel(); }
b5ec7dd6 968
a75124d0
RR
969 void SetImageList( wxImageList *imagelist );
970 wxImageList* GetImageList() { return m_imageList; }
971
972 wxDataViewItem AppendItem( const wxDataViewItem& parent,
973 const wxString &text, int icon = -1, wxClientData *data = NULL );
974 wxDataViewItem PrependItem( const wxDataViewItem& parent,
975 const wxString &text, int icon = -1, wxClientData *data = NULL );
976 wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous,
977 const wxString &text, int icon = -1, wxClientData *data = NULL );
978
979 wxDataViewItem PrependContainer( const wxDataViewItem& parent,
980 const wxString &text, int icon = -1, int expanded = -1,
981 wxClientData *data = NULL );
982 wxDataViewItem AppendContainer( const wxDataViewItem& parent,
983 const wxString &text, int icon = -1, int expanded = -1,
984 wxClientData *data = NULL );
985 wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous,
986 const wxString &text, int icon = -1, int expanded = -1,
987 wxClientData *data = NULL );
988
989 wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const
990 { return GetStore()->GetNthChild(parent, pos); }
991 int GetChildCount( const wxDataViewItem& parent ) const
992 { return GetStore()->GetChildCount(parent); }
993
994 void SetItemText( const wxDataViewItem& item, const wxString &text )
995 { GetStore()->SetItemText(item,text); }
996 wxString GetItemText( const wxDataViewItem& item ) const
997 { return GetStore()->GetItemText(item); }
998 void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon )
999 { GetStore()->SetItemIcon(item,icon); }
1000 const wxIcon &GetItemIcon( const wxDataViewItem& item ) const
1001 { return GetStore()->GetItemIcon(item); }
1002 void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon )
1003 { GetStore()->SetItemExpandedIcon(item,icon); }
1004 const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const
1005 { return GetStore()->GetItemExpandedIcon(item); }
1006 void SetItemData( const wxDataViewItem& item, wxClientData *data )
1007 { GetStore()->SetItemData(item,data); }
1008 wxClientData *GetItemData( const wxDataViewItem& item ) const
1009 { return GetStore()->GetItemData(item); }
1010
1011 void DeleteItem( const wxDataViewItem& item )
1012 { GetStore()->DeleteItem(item); }
1013 void DeleteChildren( const wxDataViewItem& item )
1014 { GetStore()->DeleteChildren(item); }
1015 void DeleteAllItems()
1016 { GetStore()->DeleteAllItems(); }
1017
1018 void OnExpanded( wxDataViewEvent &event );
1019 void OnCollapsed( wxDataViewEvent &event );
1a07a730 1020 void OnSize( wxSizeEvent &event );
b5ec7dd6 1021
e94d0c1e 1022private:
a75124d0
RR
1023 wxImageList *m_imageList;
1024
1025private:
1026 DECLARE_EVENT_TABLE()
e94d0c1e
RR
1027 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl)
1028};
e94d0c1e 1029
bcd846ea
RR
1030#endif // wxUSE_DATAVIEWCTRL
1031
1032#endif
1033 // _WX_DATAVIEW_H_BASE_