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