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