]> git.saurik.com Git - wxWidgets.git/blame - include/wx/dataview.h
removed not implemented anyhow SetIcons()
[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
b5ec7dd6 231 virtual void GetValue( wxVariant &variant,
ef427989
RR
232 unsigned int row, unsigned int col ) const = 0;
233
b5ec7dd6 234 virtual bool SetValue( const wxVariant &variant,
ef427989 235 unsigned int row, unsigned int col ) = 0;
b5ec7dd6 236
4264606e
RR
237 virtual bool GetAttr( unsigned int WXUNUSED(row), unsigned int WXUNUSED(col), wxDataViewItemAttr &WXUNUSED(attr) )
238 { return false; }
239
c534e696
RR
240 void RowPrepended();
241 void RowInserted( unsigned int before );
242 void RowAppended();
243 void RowDeleted( unsigned int row );
244 void RowChanged( unsigned int row );
245 void RowValueChanged( unsigned int row, unsigned int col );
b5ec7dd6 246
c534e696 247 // convert to/from row/wxDataViewItem
b5ec7dd6 248
c534e696
RR
249 unsigned int GetRow( const wxDataViewItem &item ) const;
250 wxDataViewItem GetItem( unsigned int row ) const;
b5ec7dd6 251
c534e696 252 // compare based on index
b5ec7dd6
VZ
253
254 virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
7ee7191c 255 unsigned int column, bool ascending );
517166e6 256 virtual bool HasDefaultCompare() const;
c534e696
RR
257
258 // implement base methods
259
b5ec7dd6 260 virtual void GetValue( wxVariant &variant,
c534e696 261 const wxDataViewItem &item, unsigned int col ) const;
b5ec7dd6 262 virtual bool SetValue( const wxVariant &variant,
c534e696 263 const wxDataViewItem &item, unsigned int col );
4264606e 264 virtual bool GetAttr( const wxDataViewItem &item, unsigned int col, wxDataViewItemAttr &attr );
c534e696
RR
265 virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const;
266 virtual bool IsContainer( const wxDataViewItem &item ) const;
74fe973b 267 virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const;
b5ec7dd6 268
c534e696 269private:
cd722937 270 wxDataViewItemArray m_hash;
c534e696 271 unsigned int m_lastIndex;
517166e6 272 bool m_ordered;
239eaa41
RR
273};
274
c33edc08 275
1e510b1e
RR
276//-----------------------------------------------------------------------------
277// wxDataViewEditorCtrlEvtHandler
278//-----------------------------------------------------------------------------
279
280class wxDataViewEditorCtrlEvtHandler: public wxEvtHandler
281{
282public:
283 wxDataViewEditorCtrlEvtHandler( wxControl *editor, wxDataViewRenderer *owner );
b5ec7dd6 284
1e510b1e 285 void AcceptChangesAndFinish();
30715fa1 286 void SetFocusOnIdle( bool focus = true ) { m_focusOnIdle = focus; }
1e510b1e
RR
287
288protected:
289 void OnChar( wxKeyEvent &event );
290 void OnKillFocus( wxFocusEvent &event );
30715fa1 291 void OnIdle( wxIdleEvent &event );
1e510b1e
RR
292
293private:
294 wxDataViewRenderer *m_owner;
295 wxControl *m_editorCtrl;
296 bool m_finished;
30715fa1 297 bool m_focusOnIdle;
1e510b1e
RR
298
299private:
300 DECLARE_EVENT_TABLE()
301};
302
f554a14b 303// ---------------------------------------------------------
baa9ebc4 304// wxDataViewRendererBase
f554a14b 305// ---------------------------------------------------------
fa28826d 306
6842a71a 307enum wxDataViewCellMode
fa28826d 308{
6842a71a
RR
309 wxDATAVIEW_CELL_INERT,
310 wxDATAVIEW_CELL_ACTIVATABLE,
311 wxDATAVIEW_CELL_EDITABLE
fa28826d
RR
312};
313
6842a71a
RR
314enum wxDataViewCellRenderState
315{
316 wxDATAVIEW_CELL_SELECTED = 1,
317 wxDATAVIEW_CELL_PRELIT = 2,
318 wxDATAVIEW_CELL_INSENSITIVE = 4,
319 wxDATAVIEW_CELL_FOCUSED = 8
320};
321
baa9ebc4 322class WXDLLIMPEXP_ADV wxDataViewRendererBase: public wxObject
6842a71a
RR
323{
324public:
b5ec7dd6 325 wxDataViewRendererBase( const wxString &varianttype,
9861f022
RR
326 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
327 int alignment = wxDVR_DEFAULT_ALIGNMENT );
6842a71a 328
9861f022
RR
329 virtual bool Validate( wxVariant& WXUNUSED(value) )
330 { return true; }
f554a14b 331
6842a71a
RR
332 void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; }
333 wxDataViewColumn* GetOwner() { return m_owner; }
f554a14b 334
9861f022
RR
335 // renderer properties:
336
337 virtual bool SetValue( const wxVariant& WXUNUSED(value) ) = 0;
338 virtual bool GetValue( wxVariant& WXUNUSED(value) ) const = 0;
339
340 wxString GetVariantType() const { return m_variantType; }
341
342 virtual void SetMode( wxDataViewCellMode mode ) = 0;
343 virtual wxDataViewCellMode GetMode() const = 0;
344
345 // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but
346 // rather an "int"; that's because for rendering cells it's allowed
347 // to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM)
348 virtual void SetAlignment( int align ) = 0;
349 virtual int GetAlignment() const = 0;
b5ec7dd6 350
1e510b1e
RR
351 // in-place editing
352 virtual bool HasEditorCtrl()
353 { return false; }
96c2a0dd
VZ
354 virtual wxControl* CreateEditorCtrl(wxWindow * WXUNUSED(parent),
355 wxRect WXUNUSED(labelRect),
356 const wxVariant& WXUNUSED(value))
1e510b1e 357 { return NULL; }
96c2a0dd
VZ
358 virtual bool GetValueFromEditorCtrl(wxControl * WXUNUSED(editor),
359 wxVariant& WXUNUSED(value))
1e510b1e
RR
360 { return false; }
361
e0062c04 362 virtual bool StartEditing( const wxDataViewItem &item, wxRect labelRect );
1e510b1e
RR
363 virtual void CancelEditing();
364 virtual bool FinishEditing();
b5ec7dd6 365
1e510b1e 366 wxControl *GetEditorCtrl() { return m_editorCtrl; }
b5ec7dd6 367
a7f61f76 368protected:
6842a71a
RR
369 wxString m_variantType;
370 wxDataViewColumn *m_owner;
1e510b1e 371 wxControl *m_editorCtrl;
e0062c04 372 wxDataViewItem m_item; // for m_editorCtrl
6842a71a 373
9861f022
RR
374 // internal utility:
375 const wxDataViewCtrl* GetView() const;
376
6842a71a 377protected:
baa9ebc4 378 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase)
6842a71a
RR
379};
380
89352653
RR
381//-----------------------------------------------------------------------------
382// wxDataViewIconText
383//-----------------------------------------------------------------------------
384
d350fbec 385class WXDLLIMPEXP_ADV wxDataViewIconText: public wxObject
89352653
RR
386{
387public:
388 wxDataViewIconText( const wxString &text = wxEmptyString, const wxIcon& icon = wxNullIcon )
389 { m_icon = icon; m_text = text; }
390 wxDataViewIconText( const wxDataViewIconText &other )
391 { m_icon = other.m_icon; m_text = other.m_text; }
392
393 void SetText( const wxString &text ) { m_text = text; }
394 wxString GetText() const { return m_text; }
395 void SetIcon( const wxIcon &icon ) { m_icon = icon; }
396 const wxIcon &GetIcon() const { return m_icon; }
397
398private:
399 wxString m_text;
400 wxIcon m_icon;
401
402private:
403 DECLARE_DYNAMIC_CLASS(wxDataViewIconText)
404};
405
406bool operator == (const wxDataViewIconText &one, const wxDataViewIconText &two);
407
d350fbec 408DECLARE_VARIANT_OBJECT_EXPORTED(wxDataViewIconText, WXDLLIMPEXP_ADV)
89352653 409
f554a14b 410// ---------------------------------------------------------
6842a71a 411// wxDataViewColumnBase
f554a14b 412// ---------------------------------------------------------
6842a71a 413
fa28826d
RR
414enum wxDataViewColumnFlags
415{
416 wxDATAVIEW_COL_RESIZABLE = 1,
417 wxDATAVIEW_COL_SORTABLE = 2,
418 wxDATAVIEW_COL_HIDDEN = 4
419};
420
f460c29d 421class WXDLLIMPEXP_ADV wxDataViewColumnBase: public wxObject
fa28826d
RR
422{
423public:
b5ec7dd6
VZ
424 wxDataViewColumnBase( const wxString &title, wxDataViewRenderer *renderer,
425 unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
87f0efe2
RR
426 wxAlignment align = wxALIGN_CENTER,
427 int flags = wxDATAVIEW_COL_RESIZABLE );
b5ec7dd6
VZ
428 wxDataViewColumnBase( const wxBitmap &bitmap, wxDataViewRenderer *renderer,
429 unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
87f0efe2
RR
430 wxAlignment align = wxALIGN_CENTER,
431 int flags = wxDATAVIEW_COL_RESIZABLE );
d3c7fc99 432 virtual ~wxDataViewColumnBase();
fa28826d 433
9861f022 434 // setters:
07b6378f 435
9861f022 436 virtual void SetTitle( const wxString &title ) = 0;
47cef10f 437 virtual void SetAlignment( wxAlignment align ) = 0;
31fb32e1 438 virtual void SetSortable( bool sortable ) = 0;
9861f022
RR
439 virtual void SetResizeable( bool resizeable ) = 0;
440 virtual void SetHidden( bool hidden ) = 0;
47cef10f 441 virtual void SetSortOrder( bool ascending ) = 0;
9861f022 442 virtual void SetFlags( int flags );
b5ec7dd6 443 virtual void SetOwner( wxDataViewCtrl *owner )
9861f022
RR
444 { m_owner = owner; }
445 virtual void SetBitmap( const wxBitmap &bitmap )
446 { m_bitmap=bitmap; }
07a84e7b 447
9861f022
RR
448 virtual void SetMinWidth( int minWidth ) = 0;
449 virtual void SetWidth( int width ) = 0;
f554a14b 450
f554a14b 451
9861f022 452 // getters:
07b6378f 453
9861f022
RR
454 virtual wxString GetTitle() const = 0;
455 virtual wxAlignment GetAlignment() const = 0;
87f0efe2 456 virtual int GetWidth() const = 0;
9861f022 457 virtual int GetMinWidth() const = 0;
07b6378f 458
9861f022
RR
459 virtual int GetFlags() const;
460
461 virtual bool IsSortable() const = 0;
462 virtual bool IsResizeable() const = 0;
463 virtual bool IsHidden() const = 0;
464 virtual bool IsSortOrderAscending() const = 0;
465
466 const wxBitmap &GetBitmap() const { return m_bitmap; }
6d9ecc87 467 unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column); }
9861f022 468
594d5596
RR
469 wxDataViewCtrl *GetOwner() const { return m_owner; }
470 wxDataViewRenderer* GetRenderer() const { return m_renderer; }
9861f022
RR
471
472protected:
baa9ebc4 473 wxDataViewRenderer *m_renderer;
6842a71a 474 int m_model_column;
07a84e7b 475 wxBitmap m_bitmap;
6842a71a 476 wxDataViewCtrl *m_owner;
fa28826d
RR
477
478protected:
479 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase)
480};
481
f554a14b 482// ---------------------------------------------------------
239eaa41 483// wxDataViewCtrlBase
f554a14b 484// ---------------------------------------------------------
239eaa41 485
c21f7aa1 486#define wxDV_SINGLE 0x0000 // for convenience
9861f022
RR
487#define wxDV_MULTIPLE 0x0001 // can select multiple items
488
489#define wxDV_NO_HEADER 0x0002 // column titles not visible
490#define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows
491#define wxDV_VERT_RULES 0x0008 // light vertical rules between columns
c21f7aa1 492
f460c29d 493class WXDLLIMPEXP_ADV wxDataViewCtrlBase: public wxControl
239eaa41
RR
494{
495public:
496 wxDataViewCtrlBase();
d3c7fc99 497 virtual ~wxDataViewCtrlBase();
f554a14b 498
e0062c04
RR
499 virtual bool AssociateModel( wxDataViewModel *model );
500 wxDataViewModel* GetModel();
f554a14b 501
07a84e7b 502 // short cuts
b5ec7dd6 503 wxDataViewColumn *PrependTextColumn( const wxString &label, unsigned int model_column,
736fe67c
RR
504 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
505 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
506 int flags = wxDATAVIEW_COL_RESIZABLE );
b5ec7dd6 507 wxDataViewColumn *PrependIconTextColumn( const wxString &label, unsigned int model_column,
736fe67c
RR
508 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
509 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
510 int flags = wxDATAVIEW_COL_RESIZABLE );
511 wxDataViewColumn *PrependToggleColumn( const wxString &label, unsigned int model_column,
512 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
513 wxAlignment align = wxALIGN_CENTER,
514 int flags = wxDATAVIEW_COL_RESIZABLE );
b5ec7dd6 515 wxDataViewColumn *PrependProgressColumn( const wxString &label, unsigned int model_column,
736fe67c
RR
516 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
517 wxAlignment align = wxALIGN_CENTER,
518 int flags = wxDATAVIEW_COL_RESIZABLE );
519 wxDataViewColumn *PrependDateColumn( const wxString &label, unsigned int model_column,
520 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
521 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
522 int flags = wxDATAVIEW_COL_RESIZABLE );
523 wxDataViewColumn *PrependBitmapColumn( const wxString &label, unsigned int model_column,
524 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
525 wxAlignment align = wxALIGN_CENTER,
526 int flags = wxDATAVIEW_COL_RESIZABLE );
527 wxDataViewColumn *PrependTextColumn( const wxBitmap &label, unsigned int model_column,
528 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
529 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
530 int flags = wxDATAVIEW_COL_RESIZABLE );
531 wxDataViewColumn *PrependIconTextColumn( const wxBitmap &label, unsigned int model_column,
532 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
533 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
534 int flags = wxDATAVIEW_COL_RESIZABLE );
535 wxDataViewColumn *PrependToggleColumn( const wxBitmap &label, unsigned int model_column,
536 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
537 wxAlignment align = wxALIGN_CENTER,
538 int flags = wxDATAVIEW_COL_RESIZABLE );
539 wxDataViewColumn *PrependProgressColumn( const wxBitmap &label, unsigned int model_column,
540 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
541 wxAlignment align = wxALIGN_CENTER,
542 int flags = wxDATAVIEW_COL_RESIZABLE );
543 wxDataViewColumn *PrependDateColumn( const wxBitmap &label, unsigned int model_column,
544 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
545 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
546 int flags = wxDATAVIEW_COL_RESIZABLE );
547 wxDataViewColumn *PrependBitmapColumn( const wxBitmap &label, unsigned int model_column,
548 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
549 wxAlignment align = wxALIGN_CENTER,
550 int flags = wxDATAVIEW_COL_RESIZABLE );
b5ec7dd6
VZ
551
552 wxDataViewColumn *AppendTextColumn( const wxString &label, unsigned int model_column,
87f0efe2 553 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
e2da67f6 554 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
87f0efe2 555 int flags = wxDATAVIEW_COL_RESIZABLE );
b5ec7dd6 556 wxDataViewColumn *AppendIconTextColumn( const wxString &label, unsigned int model_column,
b04fcede 557 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
e2da67f6 558 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
b04fcede 559 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 560 wxDataViewColumn *AppendToggleColumn( const wxString &label, unsigned int model_column,
87f0efe2
RR
561 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
562 wxAlignment align = wxALIGN_CENTER,
563 int flags = wxDATAVIEW_COL_RESIZABLE );
b5ec7dd6 564 wxDataViewColumn *AppendProgressColumn( const wxString &label, unsigned int model_column,
87f0efe2
RR
565 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
566 wxAlignment align = wxALIGN_CENTER,
567 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 568 wxDataViewColumn *AppendDateColumn( const wxString &label, unsigned int model_column,
87f0efe2 569 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
e2da67f6 570 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
87f0efe2 571 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 572 wxDataViewColumn *AppendBitmapColumn( const wxString &label, unsigned int model_column,
87f0efe2
RR
573 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
574 wxAlignment align = wxALIGN_CENTER,
575 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 576 wxDataViewColumn *AppendTextColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2 577 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
e2da67f6 578 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
87f0efe2 579 int flags = wxDATAVIEW_COL_RESIZABLE );
b04fcede
RR
580 wxDataViewColumn *AppendIconTextColumn( const wxBitmap &label, unsigned int model_column,
581 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
e2da67f6 582 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
b04fcede 583 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 584 wxDataViewColumn *AppendToggleColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2
RR
585 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
586 wxAlignment align = wxALIGN_CENTER,
587 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 588 wxDataViewColumn *AppendProgressColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2
RR
589 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
590 wxAlignment align = wxALIGN_CENTER,
591 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 592 wxDataViewColumn *AppendDateColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2 593 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
e2da67f6 594 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
87f0efe2 595 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 596 wxDataViewColumn *AppendBitmapColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2
RR
597 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
598 wxAlignment align = wxALIGN_CENTER,
599 int flags = wxDATAVIEW_COL_RESIZABLE );
736fe67c
RR
600
601
602 virtual bool PrependColumn( wxDataViewColumn *col );
f554a14b 603 virtual bool AppendColumn( wxDataViewColumn *col );
9861f022 604
91a6c655
RR
605 virtual unsigned int GetColumnCount() const = 0;
606 virtual wxDataViewColumn* GetColumn( unsigned int pos ) const = 0;
453091c2 607 virtual int GetColumnPosition( const wxDataViewColumn *column ) const = 0;
b5ec7dd6 608
91a6c655
RR
609 virtual bool DeleteColumn( wxDataViewColumn *column ) = 0;
610 virtual bool ClearColumns() = 0;
b5ec7dd6 611
1b27b2bd 612 void SetExpanderColumn( wxDataViewColumn *col )
3b6280be 613 { m_expander_column = col ; DoSetExpanderColumn(); }
b5ec7dd6 614 wxDataViewColumn *GetExpanderColumn() const
3b6280be 615 { return m_expander_column; }
b5ec7dd6 616
21f47fb9 617 virtual wxDataViewColumn *GetSortingColumn() const = 0;
3b6280be
RR
618
619 void SetIndent( int indent )
620 { m_indent = indent ; DoSetIndent(); }
b5ec7dd6
VZ
621 int GetIndent() const
622 { return m_indent; }
3b6280be 623
fbda518c 624 virtual wxDataViewItem GetSelection() const = 0;
b7e9f8b1
RR
625 virtual int GetSelections( wxDataViewItemArray & sel ) const = 0;
626 virtual void SetSelections( const wxDataViewItemArray & sel ) = 0;
627 virtual void Select( const wxDataViewItem & item ) = 0;
628 virtual void Unselect( const wxDataViewItem & item ) = 0;
629 virtual bool IsSelected( const wxDataViewItem & item ) const = 0;
630
b7e9f8b1
RR
631 virtual void SelectAll() = 0;
632 virtual void UnselectAll() = 0;
633
f71d3ba4
RR
634 virtual void Expand( const wxDataViewItem & item ) = 0;
635 virtual void Collapse( const wxDataViewItem & item ) = 0;
636
6154212e 637 virtual void EnsureVisible( const wxDataViewItem & item,
fbda518c 638 const wxDataViewColumn *column = NULL ) = 0;
a87b466d 639 virtual void HitTest( const wxPoint & point, wxDataViewItem &item, wxDataViewColumn* &column ) const = 0;
fbda518c 640 virtual wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ) const = 0;
b7e9f8b1 641
3b6280be
RR
642protected:
643 virtual void DoSetExpanderColumn() = 0 ;
644 virtual void DoSetIndent() = 0;
645
239eaa41 646private:
e0062c04 647 wxDataViewModel *m_model;
1b27b2bd 648 wxDataViewColumn *m_expander_column;
3b6280be 649 int m_indent ;
b5ec7dd6 650
239eaa41 651protected:
260b9be7 652 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase)
239eaa41 653};
bcd846ea 654
eb7f97f8
RR
655// ----------------------------------------------------------------------------
656// wxDataViewEvent - the event class for the wxDataViewCtrl notifications
657// ----------------------------------------------------------------------------
658
2f799ae8 659class WXDLLIMPEXP_ADV wxDataViewEvent : public wxNotifyEvent
eb7f97f8
RR
660{
661public:
662 wxDataViewEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
663 : wxNotifyEvent(commandType, winid),
e0062c04 664 m_item(0),
eb7f97f8 665 m_col(-1),
eb7f97f8
RR
666 m_model(NULL),
667 m_value(wxNullVariant),
31fb32e1 668 m_column(NULL)
eb7f97f8
RR
669 { }
670
671 wxDataViewEvent(const wxDataViewEvent& event)
672 : wxNotifyEvent(event),
e0062c04 673 m_item(event.m_item),
eb7f97f8 674 m_col(event.m_col),
eb7f97f8
RR
675 m_model(event.m_model),
676 m_value(event.m_value),
31fb32e1 677 m_column(event.m_column)
eb7f97f8
RR
678 { }
679
e0062c04
RR
680 wxDataViewItem GetItem() const { return m_item; }
681 void SetItem( const wxDataViewItem &item ) { m_item = item; }
682
eb7f97f8
RR
683 int GetColumn() const { return m_col; }
684 void SetColumn( int col ) { m_col = col; }
9861f022 685
eb7f97f8
RR
686 wxDataViewModel* GetModel() const { return m_model; }
687 void SetModel( wxDataViewModel *model ) { m_model = model; }
9861f022 688
eb7f97f8
RR
689 const wxVariant &GetValue() const { return m_value; }
690 void SetValue( const wxVariant &value ) { m_value = value; }
691
31fb32e1
RR
692 // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only
693 void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; }
9861f022 694 wxDataViewColumn *GetDataViewColumn() const { return m_column; }
31fb32e1 695
eb7f97f8
RR
696 virtual wxEvent *Clone() const { return new wxDataViewEvent(*this); }
697
698protected:
e0062c04 699 wxDataViewItem m_item;
eb7f97f8 700 int m_col;
eb7f97f8
RR
701 wxDataViewModel *m_model;
702 wxVariant m_value;
31fb32e1 703 wxDataViewColumn *m_column;
eb7f97f8
RR
704
705private:
706 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent)
707};
708
709BEGIN_DECLARE_EVENT_TYPES()
d86c1870 710 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, -1)
b5ec7dd6 711
e0062c04 712 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, -1)
d209a914
RR
713 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED, -1)
714 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED, -1)
6977c3bf
RR
715 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING, -1)
716 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING, -1)
e0000f94
RR
717 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED, -1)
718 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, -1)
6608fdab 719 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, -1)
b5ec7dd6 720
e07c1146
PC
721 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, -1)
722 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, -1)
c0a66d92 723 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, -1)
eb7f97f8
RR
724END_DECLARE_EVENT_TYPES()
725
726typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&);
727
728#define wxDataViewEventHandler(func) \
729 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxDataViewEventFunction, &func)
730
731#define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \
732 wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn))
733
d86c1870
RR
734#define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn)
735
e0062c04 736#define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn)
6977c3bf 737#define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn)
3ecb8a53 738#define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn)
6977c3bf 739#define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn)
3ecb8a53 740#define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn)
e0000f94
RR
741#define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn)
742#define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn)
6608fdab 743#define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn)
e0000f94 744
31fb32e1
RR
745#define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn)
746#define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn)
c0a66d92 747#define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn)
eb7f97f8 748
4ed7af08
RR
749#if defined(wxUSE_GENERICDATAVIEWCTRL)
750 #include "wx/generic/dataview.h"
751#elif defined(__WXGTK20__)
bcd846ea
RR
752 #include "wx/gtk/dataview.h"
753#elif defined(__WXMAC__)
c0a66d92 754 #include "wx/mac/dataview.h"
bcd846ea
RR
755#else
756 #include "wx/generic/dataview.h"
757#endif
758
52e750fc
RR
759// -------------------------------------
760// wxDataViewSpinRenderer
761// -------------------------------------
762
4660b556 763class WXDLLIMPEXP_ADV wxDataViewSpinRenderer: public wxDataViewCustomRenderer
52e750fc
RR
764{
765public:
766 wxDataViewSpinRenderer( int min, int max,
767 wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
768 int alignment = wxDVR_DEFAULT_ALIGNMENT );
769 virtual bool HasEditorCtrl() { return true; }
770 virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value );
771 virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value );
772 virtual bool Render( wxRect rect, wxDC *dc, int state );
773 virtual wxSize GetSize() const;
774 virtual bool SetValue( const wxVariant &value );
775 virtual bool GetValue( wxVariant &value ) const;
b5ec7dd6 776
52e750fc
RR
777private:
778 long m_data;
779 long m_min,m_max;
780};
781
e94d0c1e
RR
782//-----------------------------------------------------------------------------
783// wxDataViewTreeStore
784//-----------------------------------------------------------------------------
785
786class WXDLLIMPEXP_ADV wxDataViewTreeStoreNode
787{
788public:
789 wxDataViewTreeStoreNode( wxDataViewTreeStoreNode *parent,
790 const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
791 virtual ~wxDataViewTreeStoreNode();
b5ec7dd6
VZ
792
793 void SetText( const wxString &text )
e94d0c1e
RR
794 { m_text = text; }
795 wxString GetText() const
796 { return m_text; }
797 void SetIcon( const wxIcon &icon )
798 { m_icon = icon; }
799 const wxIcon &GetIcon() const
800 { return m_icon; }
801 void SetData( wxClientData *data )
802 { if (m_data) delete m_data; m_data = data; }
803 wxClientData *GetData() const
804 { return m_data; }
b5ec7dd6 805
e94d0c1e
RR
806 wxDataViewItem GetItem() const
807 { return wxDataViewItem( (void*) this ); }
b5ec7dd6 808
e94d0c1e
RR
809 virtual bool IsContainer()
810 { return false; }
b5ec7dd6 811
e94d0c1e
RR
812 wxDataViewTreeStoreNode *GetParent()
813 { return m_parent; }
b5ec7dd6 814
e94d0c1e
RR
815private:
816 wxDataViewTreeStoreNode *m_parent;
817 wxString m_text;
818 wxIcon m_icon;
819 wxClientData *m_data;
820};
821
822WX_DECLARE_LIST_WITH_DECL(wxDataViewTreeStoreNode, wxDataViewTreeStoreNodeList,
823 class WXDLLIMPEXP_ADV);
824
825class WXDLLIMPEXP_ADV wxDataViewTreeStoreContainerNode: public wxDataViewTreeStoreNode
826{
827public:
b5ec7dd6
VZ
828 wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode *parent,
829 const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
e94d0c1e
RR
830 wxClientData *data = NULL );
831 virtual ~wxDataViewTreeStoreContainerNode();
832
b5ec7dd6 833 const wxDataViewTreeStoreNodeList &GetChildren() const
e94d0c1e 834 { return m_children; }
b5ec7dd6 835 wxDataViewTreeStoreNodeList &GetChildren()
e94d0c1e
RR
836 { return m_children; }
837
838 void SetExpandedIcon( const wxIcon &icon )
839 { m_iconExpanded = icon; }
840 const wxIcon &GetExpandedIcon() const
841 { return m_iconExpanded; }
b5ec7dd6 842
e94d0c1e
RR
843 virtual bool IsContainer()
844 { return true; }
b5ec7dd6 845
e94d0c1e
RR
846private:
847 wxDataViewTreeStoreNodeList m_children;
848 wxIcon m_iconExpanded;
849};
850
851//-----------------------------------------------------------------------------
852
853class WXDLLIMPEXP_ADV wxDataViewTreeStore: public wxDataViewModel
854{
855public:
856 wxDataViewTreeStore();
857 ~wxDataViewTreeStore();
858
b5ec7dd6 859 wxDataViewItem AppendItem( const wxDataViewItem& parent,
e94d0c1e
RR
860 const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
861 wxDataViewItem PrependItem( const wxDataViewItem& parent,
862 const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
863 wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous,
864 const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
b5ec7dd6
VZ
865
866 wxDataViewItem PrependContainer( const wxDataViewItem& parent,
867 const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
e94d0c1e
RR
868 wxClientData *data = NULL );
869 wxDataViewItem AppendContainer( const wxDataViewItem& parent,
b5ec7dd6 870 const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
e94d0c1e
RR
871 wxClientData *data = NULL );
872 wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous,
b5ec7dd6 873 const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
e94d0c1e
RR
874 wxClientData *data = NULL );
875
876 wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const;
877 int GetChildCount( const wxDataViewItem& parent ) const;
b5ec7dd6 878
e94d0c1e
RR
879 void SetItemText( const wxDataViewItem& item, const wxString &text );
880 wxString GetItemText( const wxDataViewItem& item ) const;
b5ec7dd6 881 void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon );
e94d0c1e
RR
882 const wxIcon &GetItemIcon( const wxDataViewItem& item ) const;
883 void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon );
884 const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const;
885 void SetItemData( const wxDataViewItem& item, wxClientData *data );
886 wxClientData *GetItemData( const wxDataViewItem& item ) const;
887
888 void DeleteItem( const wxDataViewItem& item );
889 void DeleteChildren( const wxDataViewItem& item );
890 void DeleteAllItems();
b5ec7dd6 891
e94d0c1e
RR
892 // implement base methods
893
b5ec7dd6 894 virtual void GetValue( wxVariant &variant,
e94d0c1e 895 const wxDataViewItem &item, unsigned int col ) const;
b5ec7dd6 896 virtual bool SetValue( const wxVariant &variant,
e94d0c1e
RR
897 const wxDataViewItem &item, unsigned int col );
898 virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const;
899 virtual bool IsContainer( const wxDataViewItem &item ) const;
900 virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const;
901
b5ec7dd6 902 virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
e94d0c1e 903 unsigned int column, bool ascending );
b5ec7dd6
VZ
904
905 virtual bool HasDefaultCompare() const
e94d0c1e 906 { return true; }
b5ec7dd6 907 virtual unsigned int GetColumnCount() const
e94d0c1e 908 { return 1; };
b5ec7dd6 909 virtual wxString GetColumnType( unsigned int WXUNUSED(col) ) const
594d5596 910 { return wxT("wxDataViewIconText"); }
b5ec7dd6 911
e94d0c1e
RR
912 wxDataViewTreeStoreNode *FindNode( const wxDataViewItem &item ) const;
913 wxDataViewTreeStoreContainerNode *FindContainerNode( const wxDataViewItem &item ) const;
914 wxDataViewTreeStoreNode *GetRoot() const { return m_root; }
b5ec7dd6 915
e94d0c1e
RR
916public:
917 wxDataViewTreeStoreNode *m_root;
918};
919
920#if 0
921class WXDLLIMPEXP_ADV wxDataViewTreeCtrl: public wxDataViewCtrl
922{
923public:
924 wxDataViewCtrl( wxWindow *parent, wxWindowID id,
925 const wxPoint& pos = wxDefaultPosition,
926 const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER,
927 const wxValidator& validator = wxDefaultValidator );
928
929 bool Create( wxWindow *parent, wxWindowID id,
930 const wxPoint& pos = wxDefaultPosition,
931 const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER,
932 const wxValidator& validator = wxDefaultValidator );
933
934 wxDataViewTreeStore *GetStore()
935 { return (wxDataViewTreeStore*) GetModel(); }
b5ec7dd6 936
e94d0c1e 937 void OnExpand( wxDataViewCtrl &event );
b5ec7dd6
VZ
938 void OnCollapse( wxDataViewCtrl &event );
939
e94d0c1e
RR
940private:
941 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl)
942};
943#endif
944
bcd846ea
RR
945#endif // wxUSE_DATAVIEWCTRL
946
947#endif
948 // _WX_DATAVIEW_H_BASE_