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