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