]> git.saurik.com Git - wxWidgets.git/blame - include/wx/dataview.h
Fix wxExecute process end detect behavior for wxCocoa and wxMac. I have no
[wxWidgets.git] / include / wx / dataview.h
CommitLineData
bcd846ea
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/dataview.h
3// Purpose: wxDataViewCtrl base classes
4// Author: Robert Roebling
b7e9f8b1 5// Modified by: Bo Yang
bcd846ea
RR
6// Created: 08.01.06
7// RCS-ID: $Id$
8// Copyright: (c) Robert Roebling
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_DATAVIEW_H_BASE_
13#define _WX_DATAVIEW_H_BASE_
14
15#include "wx/defs.h"
16
17#if wxUSE_DATAVIEWCTRL
18
239eaa41
RR
19#include "wx/control.h"
20#include "wx/textctrl.h"
21#include "wx/bitmap.h"
64ffb888 22#include "wx/variant.h"
b9b8b59c 23#include "wx/listctrl.h"
b7e9f8b1 24#include "wx/dynarray.h"
89352653 25#include "wx/icon.h"
4ed7af08
RR
26
27#if defined(__WXGTK20__)
28 // for testing
b04fcede 29 // #define wxUSE_GENERICDATAVIEWCTRL 1
4ed7af08 30#elif defined(__WXMAC__)
4ed7af08
RR
31#else
32 #define wxUSE_GENERICDATAVIEWCTRL 1
33#endif
34
bcd846ea 35// ----------------------------------------------------------------------------
f554a14b 36// wxDataViewCtrl flags
bcd846ea
RR
37// ----------------------------------------------------------------------------
38
239eaa41
RR
39// ----------------------------------------------------------------------------
40// wxDataViewCtrl globals
41// ----------------------------------------------------------------------------
bcd846ea 42
b5dbe15d
VS
43class WXDLLIMPEXP_FWD_ADV wxDataViewItem;
44class WXDLLIMPEXP_FWD_ADV wxDataViewModel;
45class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl;
46class WXDLLIMPEXP_FWD_ADV wxDataViewColumn;
47class WXDLLIMPEXP_FWD_ADV wxDataViewRenderer;
48class WXDLLIMPEXP_FWD_ADV wxDataViewModelNotifier;
fa28826d 49
f460c29d 50extern WXDLLIMPEXP_DATA_ADV(const wxChar) wxDataViewCtrlNameStr[];
bcd846ea 51
87f0efe2
RR
52// the default width of new (text) columns:
53#define wxDVC_DEFAULT_WIDTH 80
54
55// the default width of new toggle columns:
56#define wxDVC_TOGGLE_DEFAULT_WIDTH 30
57
9861f022
RR
58// the default minimal width of the columns:
59#define wxDVC_DEFAULT_MINWIDTH 30
60
61// the default alignment of wxDataViewRenderers:
62#define wxDVR_DEFAULT_ALIGNMENT (wxALIGN_LEFT|wxALIGN_TOP)
63
87f0efe2 64
f554a14b 65// ---------------------------------------------------------
e0062c04 66// wxDataViewItem
f554a14b 67// ---------------------------------------------------------
239eaa41 68
e0062c04 69class WXDLLIMPEXP_ADV wxDataViewItem
239eaa41
RR
70{
71public:
9d52aad3
RR
72 wxDataViewItem( void* id = NULL )
73 { m_id = id; }
e0062c04 74 wxDataViewItem( const wxDataViewItem &item )
9d52aad3
RR
75 { m_id = item.m_id; }
76 bool IsOk() const { return m_id != NULL; }
77 void* GetID() const { return m_id; }
4f1cf94b 78 operator const void* () const { return m_id; }
e0062c04 79
8f850e28 80private:
9d52aad3 81 void* m_id;
64ffb888 82};
239eaa41 83
d5025dc0 84bool operator == (const wxDataViewItem &left, const wxDataViewItem &right);
aba9bfd0 85
cd722937
RR
86WX_DEFINE_ARRAY(wxDataViewItem, wxDataViewItemArray);
87
9d8fe14a
RR
88// ---------------------------------------------------------
89// wxDataViewModelNotifier
90// ---------------------------------------------------------
91
92class WXDLLIMPEXP_ADV wxDataViewModelNotifier
93{
94public:
95 wxDataViewModelNotifier() { }
96 virtual ~wxDataViewModelNotifier() { m_owner = NULL; }
97
98 virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ) = 0;
99 virtual bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item ) = 0;
100 virtual bool ItemChanged( const wxDataViewItem &item ) = 0;
854cdb09
RR
101 virtual bool ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items );
102 virtual bool ItemsDeleted( const wxDataViewItem &parent, const wxDataViewItemArray &items );
103 virtual bool ItemsChanged( const wxDataViewItemArray &items );
9d8fe14a
RR
104 virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col ) = 0;
105 virtual bool Cleared() = 0;
106
d3f00f59 107 virtual void Resort() = 0;
9d8fe14a
RR
108
109 void SetOwner( wxDataViewModel *owner ) { m_owner = owner; }
110 wxDataViewModel *GetOwner() { return m_owner; }
111
112private:
113 wxDataViewModel *m_owner;
114};
115
116
f554a14b 117// ---------------------------------------------------------
e0062c04 118// wxDataViewModel
f554a14b 119// ---------------------------------------------------------
239eaa41 120
d350fbec
VS
121WX_DECLARE_LIST_WITH_DECL(wxDataViewModelNotifier, wxDataViewModelNotifiers,
122 class WXDLLIMPEXP_ADV);
9d8fe14a 123
e0062c04 124class WXDLLIMPEXP_ADV wxDataViewModel: public wxObjectRefData
239eaa41
RR
125{
126public:
e0062c04 127 wxDataViewModel();
239eaa41 128
9861f022 129 virtual unsigned int GetColumnCount() const = 0;
87f0efe2 130
a7f61f76 131 // return type as reported by wxVariant
9861f022 132 virtual wxString GetColumnType( unsigned int col ) const = 0;
87f0efe2 133
a7f61f76 134 // get value into a wxVariant
e0062c04
RR
135 virtual void GetValue( wxVariant &variant,
136 const wxDataViewItem &item, unsigned int col ) const = 0;
87f0efe2 137
a7f61f76 138 // set value, call ValueChanged() afterwards!
e0062c04
RR
139 virtual bool SetValue( const wxVariant &variant,
140 const wxDataViewItem &item, unsigned int col ) = 0;
239eaa41 141
e0062c04 142 // define hierachy
ed903e42
RR
143 virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const = 0;
144 virtual bool IsContainer( const wxDataViewItem &item ) const = 0;
1e40f667
RR
145 // Is the container just a header or an item with all columns
146 virtual bool HasContainerColumns( const wxDataViewItem &item ) const { return false; }
74fe973b 147 virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const = 0;
b9b8b59c 148
239eaa41 149 // delegated notifiers
e0062c04 150 virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item );
854cdb09 151 virtual bool ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items );
469d3e9b 152 virtual bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item );
854cdb09 153 virtual bool ItemsDeleted( const wxDataViewItem &parent, const wxDataViewItemArray &items );
e0062c04 154 virtual bool ItemChanged( const wxDataViewItem &item );
854cdb09 155 virtual bool ItemsChanged( const wxDataViewItemArray &items );
e0062c04 156 virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col );
8981608c 157 virtual bool Cleared();
b5d777c7 158
ef427989
RR
159 // delegatd action
160 virtual void Resort();
161
e0062c04
RR
162 void AddNotifier( wxDataViewModelNotifier *notifier );
163 void RemoveNotifier( wxDataViewModelNotifier *notifier );
63415a42 164
ef427989 165 // default compare function
7ee7191c
RR
166 virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
167 unsigned int column, bool ascending );
09711964 168 virtual bool HasDefaultCompare() const { return false; }
66e09788 169
87f0efe2
RR
170protected:
171 // the user should not delete this class directly: he should use DecRef() instead!
5debbdcf 172 virtual ~wxDataViewModel() { }
87f0efe2 173
9d8fe14a 174 wxDataViewModelNotifiers m_notifiers;
ef427989
RR
175};
176
177// ---------------------------------------------------------
c534e696 178// wxDataViewIndexListModel
ef427989
RR
179// ---------------------------------------------------------
180
d350fbec 181class WXDLLIMPEXP_ADV wxDataViewIndexListModel: public wxDataViewModel
ef427989
RR
182{
183public:
c534e696 184 wxDataViewIndexListModel( unsigned int initial_size = 0 );
ef427989
RR
185 ~wxDataViewIndexListModel();
186
187 virtual unsigned int GetRowCount() = 0;
188
189 virtual void GetValue( wxVariant &variant,
190 unsigned int row, unsigned int col ) const = 0;
191
192 virtual bool SetValue( const wxVariant &variant,
193 unsigned int row, unsigned int col ) = 0;
194
c534e696
RR
195 void RowPrepended();
196 void RowInserted( unsigned int before );
197 void RowAppended();
198 void RowDeleted( unsigned int row );
199 void RowChanged( unsigned int row );
200 void RowValueChanged( unsigned int row, unsigned int col );
201
202 // convert to/from row/wxDataViewItem
ef427989 203
c534e696
RR
204 unsigned int GetRow( const wxDataViewItem &item ) const;
205 wxDataViewItem GetItem( unsigned int row ) const;
206
207 // compare based on index
ef427989 208
7ee7191c
RR
209 virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
210 unsigned int column, bool ascending );
09711964 211 virtual bool HasDefaultCompare() const { return true; }
c534e696
RR
212
213 // implement base methods
214
215 virtual void GetValue( wxVariant &variant,
216 const wxDataViewItem &item, unsigned int col ) const;
217 virtual bool SetValue( const wxVariant &variant,
218 const wxDataViewItem &item, unsigned int col );
219 virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const;
220 virtual bool IsContainer( const wxDataViewItem &item ) const;
74fe973b 221 virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const;
ef427989 222
c534e696 223private:
cd722937 224 wxDataViewItemArray m_hash;
c534e696 225 unsigned int m_lastIndex;
239eaa41
RR
226};
227
c33edc08
RR
228//-----------------------------------------------------------------------------
229// wxDataViewTreeStore
230//-----------------------------------------------------------------------------
231
232#if 0
233class wxDataViewTreeStore: public wxDataViewModel
234{
235public:
236 wxDataViewTreeStore();
237 ~wxDataViewTreeStore();
238
239 void AddColumn( const wxString &variant_type );
240
241 wxDataViewItem AddItem( const wxDataViewItem& parent, const wxVariant &value );
242 wxDataViewItem AddContainer( const wxDataViewItem& parent, const wxVariant &value );
243
244 // implement base methods
245
246 virtual void GetValue( wxVariant &variant,
247 const wxDataViewItem &item, unsigned int col ) const;
248 virtual bool SetValue( const wxVariant &variant,
249 const wxDataViewItem &item, unsigned int col );
250 virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const;
251 virtual bool IsContainer( const wxDataViewItem &item ) const;
252 virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const;
253};
254#endif
255
1e510b1e
RR
256//-----------------------------------------------------------------------------
257// wxDataViewEditorCtrlEvtHandler
258//-----------------------------------------------------------------------------
259
260class wxDataViewEditorCtrlEvtHandler: public wxEvtHandler
261{
262public:
263 wxDataViewEditorCtrlEvtHandler( wxControl *editor, wxDataViewRenderer *owner );
264
265 void AcceptChangesAndFinish();
30715fa1 266 void SetFocusOnIdle( bool focus = true ) { m_focusOnIdle = focus; }
1e510b1e
RR
267
268protected:
269 void OnChar( wxKeyEvent &event );
270 void OnKillFocus( wxFocusEvent &event );
30715fa1 271 void OnIdle( wxIdleEvent &event );
1e510b1e
RR
272
273private:
274 wxDataViewRenderer *m_owner;
275 wxControl *m_editorCtrl;
276 bool m_finished;
30715fa1 277 bool m_focusOnIdle;
1e510b1e
RR
278
279private:
280 DECLARE_EVENT_TABLE()
281};
282
f554a14b 283// ---------------------------------------------------------
baa9ebc4 284// wxDataViewRendererBase
f554a14b 285// ---------------------------------------------------------
fa28826d 286
6842a71a 287enum wxDataViewCellMode
fa28826d 288{
6842a71a
RR
289 wxDATAVIEW_CELL_INERT,
290 wxDATAVIEW_CELL_ACTIVATABLE,
291 wxDATAVIEW_CELL_EDITABLE
fa28826d
RR
292};
293
6842a71a
RR
294enum wxDataViewCellRenderState
295{
296 wxDATAVIEW_CELL_SELECTED = 1,
297 wxDATAVIEW_CELL_PRELIT = 2,
298 wxDATAVIEW_CELL_INSENSITIVE = 4,
299 wxDATAVIEW_CELL_FOCUSED = 8
300};
301
baa9ebc4 302class WXDLLIMPEXP_ADV wxDataViewRendererBase: public wxObject
6842a71a
RR
303{
304public:
9861f022
RR
305 wxDataViewRendererBase( const wxString &varianttype,
306 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
307 int alignment = wxDVR_DEFAULT_ALIGNMENT );
6842a71a 308
9861f022
RR
309 virtual bool Validate( wxVariant& WXUNUSED(value) )
310 { return true; }
f554a14b 311
6842a71a
RR
312 void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; }
313 wxDataViewColumn* GetOwner() { return m_owner; }
f554a14b 314
9861f022
RR
315 // renderer properties:
316
317 virtual bool SetValue( const wxVariant& WXUNUSED(value) ) = 0;
318 virtual bool GetValue( wxVariant& WXUNUSED(value) ) const = 0;
319
320 wxString GetVariantType() const { return m_variantType; }
321
322 virtual void SetMode( wxDataViewCellMode mode ) = 0;
323 virtual wxDataViewCellMode GetMode() const = 0;
324
325 // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but
326 // rather an "int"; that's because for rendering cells it's allowed
327 // to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM)
328 virtual void SetAlignment( int align ) = 0;
329 virtual int GetAlignment() const = 0;
99d471a5 330
1e510b1e
RR
331 // in-place editing
332 virtual bool HasEditorCtrl()
333 { return false; }
96c2a0dd
VZ
334 virtual wxControl* CreateEditorCtrl(wxWindow * WXUNUSED(parent),
335 wxRect WXUNUSED(labelRect),
336 const wxVariant& WXUNUSED(value))
1e510b1e 337 { return NULL; }
96c2a0dd
VZ
338 virtual bool GetValueFromEditorCtrl(wxControl * WXUNUSED(editor),
339 wxVariant& WXUNUSED(value))
1e510b1e
RR
340 { return false; }
341
e0062c04 342 virtual bool StartEditing( const wxDataViewItem &item, wxRect labelRect );
1e510b1e
RR
343 virtual void CancelEditing();
344 virtual bool FinishEditing();
345
346 wxControl *GetEditorCtrl() { return m_editorCtrl; }
347
a7f61f76 348protected:
6842a71a
RR
349 wxString m_variantType;
350 wxDataViewColumn *m_owner;
1e510b1e 351 wxControl *m_editorCtrl;
e0062c04 352 wxDataViewItem m_item; // for m_editorCtrl
6842a71a 353
9861f022
RR
354 // internal utility:
355 const wxDataViewCtrl* GetView() const;
356
6842a71a 357protected:
baa9ebc4 358 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase)
6842a71a
RR
359};
360
89352653
RR
361//-----------------------------------------------------------------------------
362// wxDataViewIconText
363//-----------------------------------------------------------------------------
364
d350fbec 365class WXDLLIMPEXP_ADV wxDataViewIconText: public wxObject
89352653
RR
366{
367public:
368 wxDataViewIconText( const wxString &text = wxEmptyString, const wxIcon& icon = wxNullIcon )
369 { m_icon = icon; m_text = text; }
370 wxDataViewIconText( const wxDataViewIconText &other )
371 { m_icon = other.m_icon; m_text = other.m_text; }
372
373 void SetText( const wxString &text ) { m_text = text; }
374 wxString GetText() const { return m_text; }
375 void SetIcon( const wxIcon &icon ) { m_icon = icon; }
376 const wxIcon &GetIcon() const { return m_icon; }
377
378private:
379 wxString m_text;
380 wxIcon m_icon;
381
382private:
383 DECLARE_DYNAMIC_CLASS(wxDataViewIconText)
384};
385
386bool operator == (const wxDataViewIconText &one, const wxDataViewIconText &two);
387
d350fbec 388DECLARE_VARIANT_OBJECT_EXPORTED(wxDataViewIconText, WXDLLIMPEXP_ADV)
89352653 389
f554a14b 390// ---------------------------------------------------------
6842a71a 391// wxDataViewColumnBase
f554a14b 392// ---------------------------------------------------------
6842a71a 393
fa28826d
RR
394enum wxDataViewColumnFlags
395{
396 wxDATAVIEW_COL_RESIZABLE = 1,
397 wxDATAVIEW_COL_SORTABLE = 2,
398 wxDATAVIEW_COL_HIDDEN = 4
399};
400
f460c29d 401class WXDLLIMPEXP_ADV wxDataViewColumnBase: public wxObject
fa28826d
RR
402{
403public:
87f0efe2
RR
404 wxDataViewColumnBase( const wxString &title, wxDataViewRenderer *renderer,
405 unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
406 wxAlignment align = wxALIGN_CENTER,
407 int flags = wxDATAVIEW_COL_RESIZABLE );
408 wxDataViewColumnBase( const wxBitmap &bitmap, wxDataViewRenderer *renderer,
409 unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
410 wxAlignment align = wxALIGN_CENTER,
411 int flags = wxDATAVIEW_COL_RESIZABLE );
d3c7fc99 412 virtual ~wxDataViewColumnBase();
fa28826d 413
9861f022 414 // setters:
07b6378f 415
9861f022 416 virtual void SetTitle( const wxString &title ) = 0;
47cef10f 417 virtual void SetAlignment( wxAlignment align ) = 0;
31fb32e1 418 virtual void SetSortable( bool sortable ) = 0;
9861f022
RR
419 virtual void SetResizeable( bool resizeable ) = 0;
420 virtual void SetHidden( bool hidden ) = 0;
47cef10f 421 virtual void SetSortOrder( bool ascending ) = 0;
9861f022
RR
422 virtual void SetFlags( int flags );
423 virtual void SetOwner( wxDataViewCtrl *owner )
424 { m_owner = owner; }
425 virtual void SetBitmap( const wxBitmap &bitmap )
426 { m_bitmap=bitmap; }
07a84e7b 427
9861f022
RR
428 virtual void SetMinWidth( int minWidth ) = 0;
429 virtual void SetWidth( int width ) = 0;
f554a14b 430
f554a14b 431
9861f022 432 // getters:
07b6378f 433
9861f022
RR
434 virtual wxString GetTitle() const = 0;
435 virtual wxAlignment GetAlignment() const = 0;
87f0efe2 436 virtual int GetWidth() const = 0;
9861f022 437 virtual int GetMinWidth() const = 0;
07b6378f 438
9861f022
RR
439 virtual int GetFlags() const;
440
441 virtual bool IsSortable() const = 0;
442 virtual bool IsResizeable() const = 0;
443 virtual bool IsHidden() const = 0;
444 virtual bool IsSortOrderAscending() const = 0;
445
446 const wxBitmap &GetBitmap() const { return m_bitmap; }
6d9ecc87 447 unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column); }
9861f022
RR
448
449 wxDataViewCtrl *GetOwner() { return m_owner; }
450 wxDataViewRenderer* GetRenderer() { return m_renderer; }
451
452protected:
baa9ebc4 453 wxDataViewRenderer *m_renderer;
6842a71a 454 int m_model_column;
07a84e7b 455 wxBitmap m_bitmap;
6842a71a 456 wxDataViewCtrl *m_owner;
fa28826d
RR
457
458protected:
459 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase)
460};
461
f554a14b 462// ---------------------------------------------------------
239eaa41 463// wxDataViewCtrlBase
f554a14b 464// ---------------------------------------------------------
239eaa41 465
c21f7aa1 466#define wxDV_SINGLE 0x0000 // for convenience
9861f022
RR
467#define wxDV_MULTIPLE 0x0001 // can select multiple items
468
469#define wxDV_NO_HEADER 0x0002 // column titles not visible
470#define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows
471#define wxDV_VERT_RULES 0x0008 // light vertical rules between columns
c21f7aa1 472
f460c29d 473class WXDLLIMPEXP_ADV wxDataViewCtrlBase: public wxControl
239eaa41
RR
474{
475public:
476 wxDataViewCtrlBase();
d3c7fc99 477 virtual ~wxDataViewCtrlBase();
f554a14b 478
e0062c04
RR
479 virtual bool AssociateModel( wxDataViewModel *model );
480 wxDataViewModel* GetModel();
f554a14b 481
07a84e7b 482 // short cuts
c7074d44 483 wxDataViewColumn *AppendTextColumn( const wxString &label, unsigned int model_column,
87f0efe2
RR
484 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
485 wxAlignment align = wxALIGN_CENTER,
486 int flags = wxDATAVIEW_COL_RESIZABLE );
b04fcede
RR
487 wxDataViewColumn *AppendIconTextColumn( const wxString &label, unsigned int model_column,
488 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
489 wxAlignment align = wxALIGN_CENTER,
490 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 491 wxDataViewColumn *AppendToggleColumn( const wxString &label, unsigned int model_column,
87f0efe2
RR
492 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
493 wxAlignment align = wxALIGN_CENTER,
494 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 495 wxDataViewColumn *AppendProgressColumn( const wxString &label, unsigned int model_column,
87f0efe2
RR
496 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
497 wxAlignment align = wxALIGN_CENTER,
498 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 499 wxDataViewColumn *AppendDateColumn( const wxString &label, unsigned int model_column,
87f0efe2
RR
500 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
501 wxAlignment align = wxALIGN_CENTER,
502 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 503 wxDataViewColumn *AppendBitmapColumn( const wxString &label, unsigned int model_column,
87f0efe2
RR
504 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
505 wxAlignment align = wxALIGN_CENTER,
506 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 507 wxDataViewColumn *AppendTextColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2
RR
508 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
509 wxAlignment align = wxALIGN_CENTER,
510 int flags = wxDATAVIEW_COL_RESIZABLE );
b04fcede
RR
511 wxDataViewColumn *AppendIconTextColumn( const wxBitmap &label, unsigned int model_column,
512 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
513 wxAlignment align = wxALIGN_CENTER,
514 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 515 wxDataViewColumn *AppendToggleColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2
RR
516 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
517 wxAlignment align = wxALIGN_CENTER,
518 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 519 wxDataViewColumn *AppendProgressColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2
RR
520 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
521 wxAlignment align = wxALIGN_CENTER,
522 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 523 wxDataViewColumn *AppendDateColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2
RR
524 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
525 wxAlignment align = wxALIGN_CENTER,
526 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44
RR
527
528 wxDataViewColumn *AppendBitmapColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2
RR
529 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
530 wxAlignment align = wxALIGN_CENTER,
531 int flags = wxDATAVIEW_COL_RESIZABLE );
07a84e7b 532
f554a14b 533 virtual bool AppendColumn( wxDataViewColumn *col );
9861f022 534
91a6c655
RR
535 virtual unsigned int GetColumnCount() const = 0;
536 virtual wxDataViewColumn* GetColumn( unsigned int pos ) const = 0;
453091c2 537 virtual int GetColumnPosition( const wxDataViewColumn *column ) const = 0;
91a6c655
RR
538
539 virtual bool DeleteColumn( wxDataViewColumn *column ) = 0;
540 virtual bool ClearColumns() = 0;
541
1b27b2bd 542 void SetExpanderColumn( wxDataViewColumn *col )
3b6280be 543 { m_expander_column = col ; DoSetExpanderColumn(); }
1b27b2bd 544 wxDataViewColumn *GetExpanderColumn() const
3b6280be 545 { return m_expander_column; }
21f47fb9
RR
546
547 virtual wxDataViewColumn *GetSortingColumn() const = 0;
3b6280be
RR
548
549 void SetIndent( int indent )
550 { m_indent = indent ; DoSetIndent(); }
551 int GetIndent() const
552 { return m_indent; }
553
fbda518c 554 virtual wxDataViewItem GetSelection() const = 0;
b7e9f8b1
RR
555 virtual int GetSelections( wxDataViewItemArray & sel ) const = 0;
556 virtual void SetSelections( const wxDataViewItemArray & sel ) = 0;
557 virtual void Select( const wxDataViewItem & item ) = 0;
558 virtual void Unselect( const wxDataViewItem & item ) = 0;
559 virtual bool IsSelected( const wxDataViewItem & item ) const = 0;
560
b7e9f8b1
RR
561 virtual void SelectAll() = 0;
562 virtual void UnselectAll() = 0;
563
f71d3ba4
RR
564 virtual void Expand( const wxDataViewItem & item ) = 0;
565 virtual void Collapse( const wxDataViewItem & item ) = 0;
566
6154212e 567 virtual void EnsureVisible( const wxDataViewItem & item,
fbda518c 568 const wxDataViewColumn *column = NULL ) = 0;
a87b466d 569 virtual void HitTest( const wxPoint & point, wxDataViewItem &item, wxDataViewColumn* &column ) const = 0;
fbda518c 570 virtual wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ) const = 0;
b7e9f8b1 571
3b6280be
RR
572protected:
573 virtual void DoSetExpanderColumn() = 0 ;
574 virtual void DoSetIndent() = 0;
575
239eaa41 576private:
e0062c04 577 wxDataViewModel *m_model;
1b27b2bd 578 wxDataViewColumn *m_expander_column;
3b6280be
RR
579 int m_indent ;
580
239eaa41 581protected:
260b9be7 582 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase)
239eaa41 583};
bcd846ea 584
eb7f97f8
RR
585// ----------------------------------------------------------------------------
586// wxDataViewEvent - the event class for the wxDataViewCtrl notifications
587// ----------------------------------------------------------------------------
588
2f799ae8 589class WXDLLIMPEXP_ADV wxDataViewEvent : public wxNotifyEvent
eb7f97f8
RR
590{
591public:
592 wxDataViewEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
593 : wxNotifyEvent(commandType, winid),
e0062c04 594 m_item(0),
eb7f97f8 595 m_col(-1),
eb7f97f8
RR
596 m_model(NULL),
597 m_value(wxNullVariant),
31fb32e1 598 m_column(NULL)
eb7f97f8
RR
599 { }
600
601 wxDataViewEvent(const wxDataViewEvent& event)
602 : wxNotifyEvent(event),
e0062c04 603 m_item(event.m_item),
eb7f97f8 604 m_col(event.m_col),
eb7f97f8
RR
605 m_model(event.m_model),
606 m_value(event.m_value),
31fb32e1 607 m_column(event.m_column)
eb7f97f8
RR
608 { }
609
e0062c04
RR
610 wxDataViewItem GetItem() const { return m_item; }
611 void SetItem( const wxDataViewItem &item ) { m_item = item; }
612
eb7f97f8
RR
613 int GetColumn() const { return m_col; }
614 void SetColumn( int col ) { m_col = col; }
9861f022 615
eb7f97f8
RR
616 wxDataViewModel* GetModel() const { return m_model; }
617 void SetModel( wxDataViewModel *model ) { m_model = model; }
9861f022 618
eb7f97f8
RR
619 const wxVariant &GetValue() const { return m_value; }
620 void SetValue( const wxVariant &value ) { m_value = value; }
621
31fb32e1
RR
622 // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only
623 void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; }
9861f022 624 wxDataViewColumn *GetDataViewColumn() const { return m_column; }
31fb32e1 625
eb7f97f8
RR
626 virtual wxEvent *Clone() const { return new wxDataViewEvent(*this); }
627
628protected:
e0062c04 629 wxDataViewItem m_item;
eb7f97f8 630 int m_col;
eb7f97f8
RR
631 wxDataViewModel *m_model;
632 wxVariant m_value;
31fb32e1 633 wxDataViewColumn *m_column;
eb7f97f8
RR
634
635private:
636 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent)
637};
638
639BEGIN_DECLARE_EVENT_TYPES()
d86c1870
RR
640 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, -1)
641
e0062c04 642 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, -1)
d209a914
RR
643 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED, -1)
644 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED, -1)
6977c3bf
RR
645 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING, -1)
646 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING, -1)
e0000f94
RR
647 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED, -1)
648 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, -1)
6608fdab 649 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, -1)
e0000f94 650
e07c1146
PC
651 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, -1)
652 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, -1)
c0a66d92 653 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, -1)
eb7f97f8
RR
654END_DECLARE_EVENT_TYPES()
655
656typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&);
657
658#define wxDataViewEventHandler(func) \
659 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxDataViewEventFunction, &func)
660
661#define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \
662 wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn))
663
d86c1870
RR
664#define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn)
665
e0062c04 666#define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn)
6977c3bf 667#define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn)
3ecb8a53 668#define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn)
6977c3bf 669#define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn)
3ecb8a53 670#define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn)
e0000f94
RR
671#define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn)
672#define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn)
6608fdab 673#define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn)
e0000f94 674
31fb32e1
RR
675#define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn)
676#define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn)
c0a66d92 677#define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn)
eb7f97f8 678
4ed7af08
RR
679#if defined(wxUSE_GENERICDATAVIEWCTRL)
680 #include "wx/generic/dataview.h"
681#elif defined(__WXGTK20__)
bcd846ea
RR
682 #include "wx/gtk/dataview.h"
683#elif defined(__WXMAC__)
c0a66d92 684 #include "wx/mac/dataview.h"
bcd846ea
RR
685#else
686 #include "wx/generic/dataview.h"
687#endif
688
689#endif // wxUSE_DATAVIEWCTRL
690
691#endif
692 // _WX_DATAVIEW_H_BASE_