]> git.saurik.com Git - wxWidgets.git/blob - include/wx/dataview.h
define HDS_FLAT not defined in VC6 headers
[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/headercol.h"
22 #include "wx/variant.h"
23 #include "wx/dynarray.h"
24 #include "wx/icon.h"
25 #include "wx/imaglist.h"
26 #include "wx/weakref.h"
27
28 #if !(defined(__WXGTK20__) || defined(__WXMAC__)) || defined(__WXUNIVERSAL__)
29 #define wxHAS_GENERIC_DATAVIEWCTRL
30 #endif
31
32 class WXDLLIMPEXP_FWD_CORE wxDataFormat;
33
34 // ----------------------------------------------------------------------------
35 // wxDataViewCtrl flags
36 // ----------------------------------------------------------------------------
37
38 // ----------------------------------------------------------------------------
39 // wxDataViewCtrl globals
40 // ----------------------------------------------------------------------------
41
42 class WXDLLIMPEXP_FWD_ADV wxDataViewItem;
43 class WXDLLIMPEXP_FWD_ADV wxDataViewModel;
44 class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl;
45 class WXDLLIMPEXP_FWD_ADV wxDataViewColumn;
46 class WXDLLIMPEXP_FWD_ADV wxDataViewRenderer;
47 class WXDLLIMPEXP_FWD_ADV wxDataViewModelNotifier;
48
49 extern WXDLLIMPEXP_DATA_ADV(const char) wxDataViewCtrlNameStr[];
50
51 // the default width of new (text) columns:
52 #define wxDVC_DEFAULT_WIDTH 80
53
54 // the default width of new toggle columns:
55 #define wxDVC_TOGGLE_DEFAULT_WIDTH 30
56
57 // the default minimal width of the columns:
58 #define wxDVC_DEFAULT_MINWIDTH 30
59
60 // The default alignment of wxDataViewRenderers is to take
61 // the alignment from the column it owns.
62 #define wxDVR_DEFAULT_ALIGNMENT -1
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() { m_owner = NULL; }
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() const { 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 IsVirtualListModel() 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 IsVirtualListModel() const { return false; }
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 };
293
294 // ---------------------------------------------------------
295 // wxDataViewVirtualListModel
296 // ---------------------------------------------------------
297
298 #ifdef __WXMAC__
299 // better than nothing
300 typedef wxDataViewIndexListModel wxDataViewVirtualListModel;
301 #else
302
303 class WXDLLIMPEXP_ADV wxDataViewVirtualListModel: public wxDataViewModel
304 {
305 public:
306 wxDataViewVirtualListModel( unsigned int initial_size = 0 );
307 ~wxDataViewVirtualListModel();
308
309 virtual void GetValue( wxVariant &variant,
310 unsigned int row, unsigned int col ) const = 0;
311
312 virtual bool SetValue( const wxVariant &variant,
313 unsigned int row, unsigned int col ) = 0;
314
315 virtual bool GetAttr( unsigned int WXUNUSED(row), unsigned int WXUNUSED(col), wxDataViewItemAttr &WXUNUSED(attr) )
316 { return false; }
317
318 void RowPrepended();
319 void RowInserted( unsigned int before );
320 void RowAppended();
321 void RowDeleted( unsigned int row );
322 void RowsDeleted( const wxArrayInt &rows );
323 void RowChanged( unsigned int row );
324 void RowValueChanged( unsigned int row, unsigned int col );
325 void Reset( unsigned int new_size );
326
327 // convert to/from row/wxDataViewItem
328
329 unsigned int GetRow( const wxDataViewItem &item ) const;
330 wxDataViewItem GetItem( unsigned int row ) const;
331
332 // compare based on index
333
334 virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
335 unsigned int column, bool ascending );
336 virtual bool HasDefaultCompare() const;
337
338 // implement base methods
339
340 virtual void GetValue( wxVariant &variant,
341 const wxDataViewItem &item, unsigned int col ) const;
342 virtual bool SetValue( const wxVariant &variant,
343 const wxDataViewItem &item, unsigned int col );
344 virtual bool GetAttr( const wxDataViewItem &item, unsigned int col, wxDataViewItemAttr &attr );
345 virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const;
346 virtual bool IsContainer( const wxDataViewItem &item ) const;
347 virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const;
348
349 // internal
350 virtual bool IsVirtualListModel() const { return true; }
351 unsigned int GetLastIndex() const { return m_lastIndex; }
352
353 private:
354 wxDataViewItemArray m_hash;
355 unsigned int m_lastIndex;
356 bool m_ordered;
357 };
358 #endif
359
360 //-----------------------------------------------------------------------------
361 // wxDataViewEditorCtrlEvtHandler
362 //-----------------------------------------------------------------------------
363
364 class wxDataViewEditorCtrlEvtHandler: public wxEvtHandler
365 {
366 public:
367 wxDataViewEditorCtrlEvtHandler( wxControl *editor, wxDataViewRenderer *owner );
368
369 void AcceptChangesAndFinish();
370 void SetFocusOnIdle( bool focus = true ) { m_focusOnIdle = focus; }
371
372 protected:
373 void OnChar( wxKeyEvent &event );
374 void OnTextEnter( wxCommandEvent &event );
375 void OnKillFocus( wxFocusEvent &event );
376 void OnIdle( wxIdleEvent &event );
377
378 private:
379 wxDataViewRenderer *m_owner;
380 wxControl *m_editorCtrl;
381 bool m_finished;
382 bool m_focusOnIdle;
383
384 private:
385 DECLARE_EVENT_TABLE()
386 };
387
388 // ---------------------------------------------------------
389 // wxDataViewRendererBase
390 // ---------------------------------------------------------
391
392 enum wxDataViewCellMode
393 {
394 wxDATAVIEW_CELL_INERT,
395 wxDATAVIEW_CELL_ACTIVATABLE,
396 wxDATAVIEW_CELL_EDITABLE
397 };
398
399 enum wxDataViewCellRenderState
400 {
401 wxDATAVIEW_CELL_SELECTED = 1,
402 wxDATAVIEW_CELL_PRELIT = 2,
403 wxDATAVIEW_CELL_INSENSITIVE = 4,
404 wxDATAVIEW_CELL_FOCUSED = 8
405 };
406
407 class WXDLLIMPEXP_ADV wxDataViewRendererBase: public wxObject
408 {
409 public:
410 wxDataViewRendererBase( const wxString &varianttype,
411 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
412 int alignment = wxDVR_DEFAULT_ALIGNMENT );
413 ~wxDataViewRendererBase();
414
415 virtual bool Validate( wxVariant& WXUNUSED(value) )
416 { return true; }
417
418 void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; }
419 wxDataViewColumn* GetOwner() const { return m_owner; }
420
421 // renderer properties:
422
423 virtual bool SetValue( const wxVariant& WXUNUSED(value) ) = 0;
424 virtual bool GetValue( wxVariant& WXUNUSED(value) ) const = 0;
425
426 wxString GetVariantType() const { return m_variantType; }
427
428 virtual void SetMode( wxDataViewCellMode mode ) = 0;
429 virtual wxDataViewCellMode GetMode() const = 0;
430
431 // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but
432 // rather an "int"; that's because for rendering cells it's allowed
433 // to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM)
434 virtual void SetAlignment( int align ) = 0;
435 virtual int GetAlignment() const = 0;
436
437 // in-place editing
438 virtual bool HasEditorCtrl()
439 { return false; }
440 virtual wxControl* CreateEditorCtrl(wxWindow * WXUNUSED(parent),
441 wxRect WXUNUSED(labelRect),
442 const wxVariant& WXUNUSED(value))
443 { return NULL; }
444 virtual bool GetValueFromEditorCtrl(wxControl * WXUNUSED(editor),
445 wxVariant& WXUNUSED(value))
446 { return false; }
447
448 virtual bool StartEditing( const wxDataViewItem &item, wxRect labelRect );
449 virtual void CancelEditing();
450 virtual bool FinishEditing();
451
452 wxControl *GetEditorCtrl() { return m_editorCtrl; }
453
454 protected:
455 wxString m_variantType;
456 wxDataViewColumn *m_owner;
457 wxWeakRef<wxControl> m_editorCtrl;
458 wxDataViewItem m_item; // for m_editorCtrl
459
460 // internal utility:
461 const wxDataViewCtrl* GetView() const;
462
463 protected:
464 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase)
465 };
466
467 //-----------------------------------------------------------------------------
468 // wxDataViewIconText
469 //-----------------------------------------------------------------------------
470
471 class WXDLLIMPEXP_ADV wxDataViewIconText: public wxObject
472 {
473 public:
474 wxDataViewIconText( const wxString &text = wxEmptyString, const wxIcon& icon = wxNullIcon )
475 : m_text(text), m_icon(icon)
476 { }
477 wxDataViewIconText( const wxDataViewIconText &other )
478 : wxObject()
479 { m_icon = other.m_icon; m_text = other.m_text; }
480
481 void SetText( const wxString &text ) { m_text = text; }
482 wxString GetText() const { return m_text; }
483 void SetIcon( const wxIcon &icon ) { m_icon = icon; }
484 const wxIcon &GetIcon() const { return m_icon; }
485
486 private:
487 wxString m_text;
488 wxIcon m_icon;
489
490 private:
491 DECLARE_DYNAMIC_CLASS(wxDataViewIconText)
492 };
493
494 bool operator == (const wxDataViewIconText &one, const wxDataViewIconText &two);
495
496 DECLARE_VARIANT_OBJECT_EXPORTED(wxDataViewIconText, WXDLLIMPEXP_ADV)
497
498 // ---------------------------------------------------------
499 // wxDataViewColumnBase
500 // ---------------------------------------------------------
501
502 // for compatibility only, do not use
503 enum wxDataViewColumnFlags
504 {
505 wxDATAVIEW_COL_RESIZABLE = wxCOL_RESIZABLE,
506 wxDATAVIEW_COL_SORTABLE = wxCOL_SORTABLE,
507 wxDATAVIEW_COL_REORDERABLE = wxCOL_REORDERABLE,
508 wxDATAVIEW_COL_HIDDEN = wxCOL_HIDDEN
509 };
510
511 class WXDLLIMPEXP_ADV wxDataViewColumnBase : public
512 // native implementations of wxDataViewCtrl have their own implementations of
513 // wxDataViewColumnBase and so they need to only inherit from
514 // wxHeaderColumnBase to provide the same interface as the generic port which
515 // uses the platform native (if any) wxHeaderColumn
516 #ifdef wxHAS_GENERIC_DATAVIEWCTRL
517 wxHeaderColumn
518 #else
519 wxHeaderColumnBase
520 #endif
521 {
522 public:
523 wxDataViewColumnBase( const wxString &title, wxDataViewRenderer *renderer,
524 unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
525 wxAlignment align = wxALIGN_CENTER,
526 int flags = wxDATAVIEW_COL_RESIZABLE );
527 wxDataViewColumnBase( const wxBitmap &bitmap, wxDataViewRenderer *renderer,
528 unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
529 wxAlignment align = wxALIGN_CENTER,
530 int flags = wxDATAVIEW_COL_RESIZABLE );
531 virtual ~wxDataViewColumnBase();
532
533 // setters:
534 virtual void SetOwner( wxDataViewCtrl *owner )
535 { m_owner = owner; }
536
537 // getters:
538 unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column); }
539 wxDataViewCtrl *GetOwner() const { return m_owner; }
540 wxDataViewRenderer* GetRenderer() const { return m_renderer; }
541
542 #ifndef wxHAS_GENERIC_DATAVIEWCTRL
543 // implement some of base class pure virtuals (the rest is port-dependent
544 // and done differently in generic and native versions)
545 virtual void SetBitmap( const wxBitmap& bitmap ) { m_bitmap = bitmap; }
546 virtual wxBitmap GetBitmap() const { return m_bitmap; }
547 #endif // !wxHAS_GENERIC_DATAVIEWCTRL
548
549 protected:
550 wxDataViewRenderer *m_renderer;
551 int m_model_column;
552 #ifndef wxHAS_GENERIC_DATAVIEWCTRL
553 wxBitmap m_bitmap;
554 #endif // !wxHAS_GENERIC_DATAVIEWCTRL
555 wxDataViewCtrl *m_owner;
556
557 protected:
558 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase)
559 };
560
561 // ---------------------------------------------------------
562 // wxDataViewCtrlBase
563 // ---------------------------------------------------------
564
565 #define wxDV_SINGLE 0x0000 // for convenience
566 #define wxDV_MULTIPLE 0x0001 // can select multiple items
567
568 #define wxDV_NO_HEADER 0x0002 // column titles not visible
569 #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows
570 #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns
571
572 #define wxDV_ROW_LINES 0x0010 // alternating colour in rows
573 #define wxDV_VARIABLE_LINE_HEIGHT 0x0020 // variable line height
574
575 class WXDLLIMPEXP_ADV wxDataViewCtrlBase: public wxControl
576 {
577 public:
578 wxDataViewCtrlBase();
579 virtual ~wxDataViewCtrlBase();
580
581 virtual bool AssociateModel( wxDataViewModel *model );
582 wxDataViewModel* GetModel();
583 const wxDataViewModel* GetModel() const;
584
585 // short cuts
586 wxDataViewColumn *PrependTextColumn( const wxString &label, unsigned int model_column,
587 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
588 wxAlignment align = wxALIGN_NOT,
589 int flags = wxDATAVIEW_COL_RESIZABLE );
590 wxDataViewColumn *PrependIconTextColumn( const wxString &label, unsigned int model_column,
591 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
592 wxAlignment align = wxALIGN_NOT,
593 int flags = wxDATAVIEW_COL_RESIZABLE );
594 wxDataViewColumn *PrependToggleColumn( const wxString &label, unsigned int model_column,
595 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
596 wxAlignment align = wxALIGN_CENTER,
597 int flags = wxDATAVIEW_COL_RESIZABLE );
598 wxDataViewColumn *PrependProgressColumn( const wxString &label, unsigned int model_column,
599 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
600 wxAlignment align = wxALIGN_CENTER,
601 int flags = wxDATAVIEW_COL_RESIZABLE );
602 wxDataViewColumn *PrependDateColumn( const wxString &label, unsigned int model_column,
603 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
604 wxAlignment align = wxALIGN_NOT,
605 int flags = wxDATAVIEW_COL_RESIZABLE );
606 wxDataViewColumn *PrependBitmapColumn( const wxString &label, unsigned int model_column,
607 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
608 wxAlignment align = wxALIGN_CENTER,
609 int flags = wxDATAVIEW_COL_RESIZABLE );
610 wxDataViewColumn *PrependTextColumn( const wxBitmap &label, unsigned int model_column,
611 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
612 wxAlignment align = wxALIGN_NOT,
613 int flags = wxDATAVIEW_COL_RESIZABLE );
614 wxDataViewColumn *PrependIconTextColumn( const wxBitmap &label, unsigned int model_column,
615 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
616 wxAlignment align = wxALIGN_NOT,
617 int flags = wxDATAVIEW_COL_RESIZABLE );
618 wxDataViewColumn *PrependToggleColumn( const wxBitmap &label, unsigned int model_column,
619 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
620 wxAlignment align = wxALIGN_CENTER,
621 int flags = wxDATAVIEW_COL_RESIZABLE );
622 wxDataViewColumn *PrependProgressColumn( const wxBitmap &label, unsigned int model_column,
623 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
624 wxAlignment align = wxALIGN_CENTER,
625 int flags = wxDATAVIEW_COL_RESIZABLE );
626 wxDataViewColumn *PrependDateColumn( const wxBitmap &label, unsigned int model_column,
627 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
628 wxAlignment align = wxALIGN_NOT,
629 int flags = wxDATAVIEW_COL_RESIZABLE );
630 wxDataViewColumn *PrependBitmapColumn( const wxBitmap &label, unsigned int model_column,
631 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
632 wxAlignment align = wxALIGN_CENTER,
633 int flags = wxDATAVIEW_COL_RESIZABLE );
634
635 wxDataViewColumn *AppendTextColumn( const wxString &label, unsigned int model_column,
636 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
637 wxAlignment align = wxALIGN_NOT,
638 int flags = wxDATAVIEW_COL_RESIZABLE );
639 wxDataViewColumn *AppendIconTextColumn( const wxString &label, unsigned int model_column,
640 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
641 wxAlignment align = wxALIGN_NOT,
642 int flags = wxDATAVIEW_COL_RESIZABLE );
643 wxDataViewColumn *AppendToggleColumn( const wxString &label, unsigned int model_column,
644 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
645 wxAlignment align = wxALIGN_CENTER,
646 int flags = wxDATAVIEW_COL_RESIZABLE );
647 wxDataViewColumn *AppendProgressColumn( const wxString &label, unsigned int model_column,
648 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
649 wxAlignment align = wxALIGN_CENTER,
650 int flags = wxDATAVIEW_COL_RESIZABLE );
651 wxDataViewColumn *AppendDateColumn( const wxString &label, unsigned int model_column,
652 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
653 wxAlignment align = wxALIGN_NOT,
654 int flags = wxDATAVIEW_COL_RESIZABLE );
655 wxDataViewColumn *AppendBitmapColumn( const wxString &label, unsigned int model_column,
656 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
657 wxAlignment align = wxALIGN_CENTER,
658 int flags = wxDATAVIEW_COL_RESIZABLE );
659 wxDataViewColumn *AppendTextColumn( const wxBitmap &label, unsigned int model_column,
660 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
661 wxAlignment align = wxALIGN_NOT,
662 int flags = wxDATAVIEW_COL_RESIZABLE );
663 wxDataViewColumn *AppendIconTextColumn( const wxBitmap &label, unsigned int model_column,
664 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
665 wxAlignment align = wxALIGN_NOT,
666 int flags = wxDATAVIEW_COL_RESIZABLE );
667 wxDataViewColumn *AppendToggleColumn( const wxBitmap &label, unsigned int model_column,
668 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
669 wxAlignment align = wxALIGN_CENTER,
670 int flags = wxDATAVIEW_COL_RESIZABLE );
671 wxDataViewColumn *AppendProgressColumn( const wxBitmap &label, unsigned int model_column,
672 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
673 wxAlignment align = wxALIGN_CENTER,
674 int flags = wxDATAVIEW_COL_RESIZABLE );
675 wxDataViewColumn *AppendDateColumn( const wxBitmap &label, unsigned int model_column,
676 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
677 wxAlignment align = wxALIGN_NOT,
678 int flags = wxDATAVIEW_COL_RESIZABLE );
679 wxDataViewColumn *AppendBitmapColumn( const wxBitmap &label, unsigned int model_column,
680 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
681 wxAlignment align = wxALIGN_CENTER,
682 int flags = wxDATAVIEW_COL_RESIZABLE );
683
684
685 virtual bool PrependColumn( wxDataViewColumn *col );
686 virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col );
687 virtual bool AppendColumn( wxDataViewColumn *col );
688
689 virtual unsigned int GetColumnCount() const = 0;
690 virtual wxDataViewColumn* GetColumn( unsigned int pos ) const = 0;
691 virtual int GetColumnPosition( const wxDataViewColumn *column ) const = 0;
692
693 virtual bool DeleteColumn( wxDataViewColumn *column ) = 0;
694 virtual bool ClearColumns() = 0;
695
696 void SetExpanderColumn( wxDataViewColumn *col )
697 { m_expander_column = col ; DoSetExpanderColumn(); }
698 wxDataViewColumn *GetExpanderColumn() const
699 { return m_expander_column; }
700
701 virtual wxDataViewColumn *GetSortingColumn() const = 0;
702
703 void SetIndent( int indent )
704 { m_indent = indent ; DoSetIndent(); }
705 int GetIndent() const
706 { return m_indent; }
707
708 virtual wxDataViewItem GetSelection() const = 0;
709 virtual int GetSelections( wxDataViewItemArray & sel ) const = 0;
710 virtual void SetSelections( const wxDataViewItemArray & sel ) = 0;
711 virtual void Select( const wxDataViewItem & item ) = 0;
712 virtual void Unselect( const wxDataViewItem & item ) = 0;
713 virtual bool IsSelected( const wxDataViewItem & item ) const = 0;
714
715 virtual void SelectAll() = 0;
716 virtual void UnselectAll() = 0;
717
718 virtual void Expand( const wxDataViewItem & item ) = 0;
719 virtual void Collapse( const wxDataViewItem & item ) = 0;
720
721 virtual void EnsureVisible( const wxDataViewItem & item,
722 const wxDataViewColumn *column = NULL ) = 0;
723 virtual void HitTest( const wxPoint & point, wxDataViewItem &item, wxDataViewColumn* &column ) const = 0;
724 virtual wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ) const = 0;
725
726 protected:
727 virtual void DoSetExpanderColumn() = 0 ;
728 virtual void DoSetIndent() = 0;
729
730 private:
731 wxDataViewModel *m_model;
732 wxDataViewColumn *m_expander_column;
733 int m_indent ;
734
735 protected:
736 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase)
737 };
738
739 // ----------------------------------------------------------------------------
740 // wxDataViewEvent - the event class for the wxDataViewCtrl notifications
741 // ----------------------------------------------------------------------------
742
743 class WXDLLIMPEXP_ADV wxDataViewEvent : public wxNotifyEvent
744 {
745 public:
746 wxDataViewEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
747 : wxNotifyEvent(commandType, winid),
748 m_item(0),
749 m_col(-1),
750 m_model(NULL),
751 m_value(wxNullVariant),
752 m_column(NULL),
753 m_pos(-1,-1)
754 { }
755
756 wxDataViewEvent(const wxDataViewEvent& event)
757 : wxNotifyEvent(event),
758 m_item(event.m_item),
759 m_col(event.m_col),
760 m_model(event.m_model),
761 m_value(event.m_value),
762 m_column(event.m_column),
763 m_pos(m_pos)
764 { }
765
766 wxDataViewItem GetItem() const { return m_item; }
767 void SetItem( const wxDataViewItem &item ) { m_item = item; }
768
769 int GetColumn() const { return m_col; }
770 void SetColumn( int col ) { m_col = col; }
771
772 wxDataViewModel* GetModel() const { return m_model; }
773 void SetModel( wxDataViewModel *model ) { m_model = model; }
774
775 const wxVariant &GetValue() const { return m_value; }
776 void SetValue( const wxVariant &value ) { m_value = value; }
777
778 // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only
779 void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; }
780 wxDataViewColumn *GetDataViewColumn() const { return m_column; }
781
782 // for wxEVT_DATAVIEW_CONTEXT_MENU only
783 wxPoint GetPosition() const { return m_pos; }
784 void SetPosition( int x, int y ) { m_pos.x = x; m_pos.y = y; }
785
786 virtual wxEvent *Clone() const { return new wxDataViewEvent(*this); }
787
788 protected:
789 wxDataViewItem m_item;
790 int m_col;
791 wxDataViewModel *m_model;
792 wxVariant m_value;
793 wxDataViewColumn *m_column;
794 wxPoint m_pos;
795
796 private:
797 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent)
798 };
799
800 extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED;
801
802 extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED;
803 extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED;
804 extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED;
805 extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING;
806 extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING;
807 extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED;
808 extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE;
809 extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED;
810
811 extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU;
812
813 extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK;
814 extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK;
815 extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED;
816 extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED;
817
818 typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&);
819
820 #define wxDataViewEventHandler(func) \
821 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxDataViewEventFunction, &func)
822
823 #define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \
824 wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn))
825
826 #define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn)
827
828 #define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn)
829 #define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn)
830 #define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn)
831 #define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn)
832 #define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn)
833 #define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn)
834 #define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn)
835 #define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn)
836
837 #define EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_CONTEXT_MENU, id, fn)
838
839 #define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn)
840 #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn)
841 #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn)
842 #define EVT_DATAVIEW_COLUMN_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_REORDERED, id, fn)
843
844
845 #ifdef wxHAS_GENERIC_DATAVIEWCTRL
846 // this symbol doesn't follow the convention for wxUSE_XXX symbols which
847 // are normally always defined as either 0 or 1, so its use is deprecated
848 // and it only exists for backwards compatibility, don't use it any more
849 // and use wxHAS_GENERIC_DATAVIEWCTRL instead
850 #define wxUSE_GENERICDATAVIEWCTRL
851
852 #include "wx/generic/dataview.h"
853 #elif defined(__WXGTK20__)
854 #include "wx/gtk/dataview.h"
855 #elif defined(__WXMAC__)
856 #include "wx/osx/dataview.h"
857 #else
858 #error "unknown native wxDataViewCtrl implementation"
859 #endif
860
861 // -------------------------------------
862 // wxDataViewSpinRenderer
863 // -------------------------------------
864
865 class WXDLLIMPEXP_ADV wxDataViewSpinRenderer: public wxDataViewCustomRenderer
866 {
867 public:
868 wxDataViewSpinRenderer( int min, int max,
869 wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
870 int alignment = wxDVR_DEFAULT_ALIGNMENT );
871 virtual bool HasEditorCtrl() { return true; }
872 virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value );
873 virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value );
874 virtual bool Render( wxRect rect, wxDC *dc, int state );
875 virtual wxSize GetSize() const;
876 virtual bool SetValue( const wxVariant &value );
877 virtual bool GetValue( wxVariant &value ) const;
878
879 private:
880 long m_data;
881 long m_min,m_max;
882 };
883
884 #ifndef __WXGTK20__
885
886 // -------------------------------------
887 // wxDataViewChoiceRenderer
888 // -------------------------------------
889
890 class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer: public wxDataViewCustomRenderer
891 {
892 public:
893 wxDataViewChoiceRenderer( const wxArrayString &choices,
894 wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
895 int alignment = wxDVR_DEFAULT_ALIGNMENT );
896 virtual bool HasEditorCtrl() { return true; }
897 virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value );
898 virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value );
899 virtual bool Render( wxRect rect, wxDC *dc, int state );
900 virtual wxSize GetSize() const;
901 virtual bool SetValue( const wxVariant &value );
902 virtual bool GetValue( wxVariant &value ) const;
903
904 private:
905 wxArrayString m_choices;
906 wxString m_data;
907 };
908
909 #endif
910
911 //-----------------------------------------------------------------------------
912 // wxDataViewTreeStore
913 //-----------------------------------------------------------------------------
914
915 class WXDLLIMPEXP_ADV wxDataViewTreeStoreNode
916 {
917 public:
918 wxDataViewTreeStoreNode( wxDataViewTreeStoreNode *parent,
919 const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
920 virtual ~wxDataViewTreeStoreNode();
921
922 void SetText( const wxString &text )
923 { m_text = text; }
924 wxString GetText() const
925 { return m_text; }
926 void SetIcon( const wxIcon &icon )
927 { m_icon = icon; }
928 const wxIcon &GetIcon() const
929 { return m_icon; }
930 void SetData( wxClientData *data )
931 { if (m_data) delete m_data; m_data = data; }
932 wxClientData *GetData() const
933 { return m_data; }
934
935 wxDataViewItem GetItem() const
936 { return wxDataViewItem( (void*) this ); }
937
938 virtual bool IsContainer()
939 { return false; }
940
941 wxDataViewTreeStoreNode *GetParent()
942 { return m_parent; }
943
944 private:
945 wxDataViewTreeStoreNode *m_parent;
946 wxString m_text;
947 wxIcon m_icon;
948 wxClientData *m_data;
949 };
950
951 WX_DECLARE_LIST_WITH_DECL(wxDataViewTreeStoreNode, wxDataViewTreeStoreNodeList,
952 class WXDLLIMPEXP_ADV);
953
954 class WXDLLIMPEXP_ADV wxDataViewTreeStoreContainerNode: public wxDataViewTreeStoreNode
955 {
956 public:
957 wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode *parent,
958 const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
959 wxClientData *data = NULL );
960 virtual ~wxDataViewTreeStoreContainerNode();
961
962 const wxDataViewTreeStoreNodeList &GetChildren() const
963 { return m_children; }
964 wxDataViewTreeStoreNodeList &GetChildren()
965 { return m_children; }
966
967 void SetExpandedIcon( const wxIcon &icon )
968 { m_iconExpanded = icon; }
969 const wxIcon &GetExpandedIcon() const
970 { return m_iconExpanded; }
971
972 void SetExpanded( bool expanded = true )
973 { m_isExpanded = expanded; }
974 bool IsExpanded() const
975 { return m_isExpanded; }
976
977 virtual bool IsContainer()
978 { return true; }
979
980 private:
981 wxDataViewTreeStoreNodeList m_children;
982 wxIcon m_iconExpanded;
983 bool m_isExpanded;
984 };
985
986 //-----------------------------------------------------------------------------
987
988 class WXDLLIMPEXP_ADV wxDataViewTreeStore: public wxDataViewModel
989 {
990 public:
991 wxDataViewTreeStore();
992 ~wxDataViewTreeStore();
993
994 wxDataViewItem AppendItem( const wxDataViewItem& parent,
995 const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
996 wxDataViewItem PrependItem( const wxDataViewItem& parent,
997 const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
998 wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous,
999 const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
1000
1001 wxDataViewItem PrependContainer( const wxDataViewItem& parent,
1002 const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
1003 wxClientData *data = NULL );
1004 wxDataViewItem AppendContainer( const wxDataViewItem& parent,
1005 const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
1006 wxClientData *data = NULL );
1007 wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous,
1008 const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
1009 wxClientData *data = NULL );
1010
1011 wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const;
1012 int GetChildCount( const wxDataViewItem& parent ) const;
1013
1014 void SetItemText( const wxDataViewItem& item, const wxString &text );
1015 wxString GetItemText( const wxDataViewItem& item ) const;
1016 void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon );
1017 const wxIcon &GetItemIcon( const wxDataViewItem& item ) const;
1018 void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon );
1019 const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const;
1020 void SetItemData( const wxDataViewItem& item, wxClientData *data );
1021 wxClientData *GetItemData( const wxDataViewItem& item ) const;
1022
1023 void DeleteItem( const wxDataViewItem& item );
1024 void DeleteChildren( const wxDataViewItem& item );
1025 void DeleteAllItems();
1026
1027 // implement base methods
1028
1029 virtual void GetValue( wxVariant &variant,
1030 const wxDataViewItem &item, unsigned int col ) const;
1031 virtual bool SetValue( const wxVariant &variant,
1032 const wxDataViewItem &item, unsigned int col );
1033 virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const;
1034 virtual bool IsContainer( const wxDataViewItem &item ) const;
1035 virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const;
1036
1037 virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
1038 unsigned int column, bool ascending );
1039
1040 virtual bool HasDefaultCompare() const
1041 { return true; }
1042 virtual unsigned int GetColumnCount() const
1043 { return 1; };
1044 virtual wxString GetColumnType( unsigned int WXUNUSED(col) ) const
1045 { return wxT("wxDataViewIconText"); }
1046
1047 wxDataViewTreeStoreNode *FindNode( const wxDataViewItem &item ) const;
1048 wxDataViewTreeStoreContainerNode *FindContainerNode( const wxDataViewItem &item ) const;
1049 wxDataViewTreeStoreNode *GetRoot() const { return m_root; }
1050
1051 public:
1052 wxDataViewTreeStoreNode *m_root;
1053 };
1054
1055 class WXDLLIMPEXP_ADV wxDataViewTreeCtrl: public wxDataViewCtrl
1056 {
1057 public:
1058 wxDataViewTreeCtrl();
1059 wxDataViewTreeCtrl( wxWindow *parent, wxWindowID id,
1060 const wxPoint& pos = wxDefaultPosition,
1061 const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
1062 const wxValidator& validator = wxDefaultValidator );
1063 ~wxDataViewTreeCtrl();
1064
1065 bool Create( wxWindow *parent, wxWindowID id,
1066 const wxPoint& pos = wxDefaultPosition,
1067 const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
1068 const wxValidator& validator = wxDefaultValidator );
1069
1070 wxDataViewTreeStore *GetStore()
1071 { return (wxDataViewTreeStore*) GetModel(); }
1072 const wxDataViewTreeStore *GetStore() const
1073 { return (const wxDataViewTreeStore*) GetModel(); }
1074
1075 void SetImageList( wxImageList *imagelist );
1076 wxImageList* GetImageList() { return m_imageList; }
1077
1078 wxDataViewItem AppendItem( const wxDataViewItem& parent,
1079 const wxString &text, int icon = -1, wxClientData *data = NULL );
1080 wxDataViewItem PrependItem( const wxDataViewItem& parent,
1081 const wxString &text, int icon = -1, wxClientData *data = NULL );
1082 wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous,
1083 const wxString &text, int icon = -1, wxClientData *data = NULL );
1084
1085 wxDataViewItem PrependContainer( const wxDataViewItem& parent,
1086 const wxString &text, int icon = -1, int expanded = -1,
1087 wxClientData *data = NULL );
1088 wxDataViewItem AppendContainer( const wxDataViewItem& parent,
1089 const wxString &text, int icon = -1, int expanded = -1,
1090 wxClientData *data = NULL );
1091 wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous,
1092 const wxString &text, int icon = -1, int expanded = -1,
1093 wxClientData *data = NULL );
1094
1095 wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const
1096 { return GetStore()->GetNthChild(parent, pos); }
1097 int GetChildCount( const wxDataViewItem& parent ) const
1098 { return GetStore()->GetChildCount(parent); }
1099
1100 void SetItemText( const wxDataViewItem& item, const wxString &text )
1101 { GetStore()->SetItemText(item,text); }
1102 wxString GetItemText( const wxDataViewItem& item ) const
1103 { return GetStore()->GetItemText(item); }
1104 void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon )
1105 { GetStore()->SetItemIcon(item,icon); }
1106 const wxIcon &GetItemIcon( const wxDataViewItem& item ) const
1107 { return GetStore()->GetItemIcon(item); }
1108 void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon )
1109 { GetStore()->SetItemExpandedIcon(item,icon); }
1110 const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const
1111 { return GetStore()->GetItemExpandedIcon(item); }
1112 void SetItemData( const wxDataViewItem& item, wxClientData *data )
1113 { GetStore()->SetItemData(item,data); }
1114 wxClientData *GetItemData( const wxDataViewItem& item ) const
1115 { return GetStore()->GetItemData(item); }
1116
1117 void DeleteItem( const wxDataViewItem& item )
1118 { GetStore()->DeleteItem(item); }
1119 void DeleteChildren( const wxDataViewItem& item )
1120 { GetStore()->DeleteChildren(item); }
1121 void DeleteAllItems()
1122 { GetStore()->DeleteAllItems(); }
1123
1124 void OnExpanded( wxDataViewEvent &event );
1125 void OnCollapsed( wxDataViewEvent &event );
1126 void OnSize( wxSizeEvent &event );
1127
1128 private:
1129 wxImageList *m_imageList;
1130
1131 private:
1132 DECLARE_EVENT_TABLE()
1133 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl)
1134 };
1135
1136 #endif // wxUSE_DATAVIEWCTRL
1137
1138 #endif
1139 // _WX_DATAVIEW_H_BASE_