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