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