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