]> git.saurik.com Git - wxWidgets.git/blame - include/wx/dataview.h
added wxUSE_REGKEY option
[wxWidgets.git] / include / wx / dataview.h
CommitLineData
bcd846ea
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/dataview.h
3// Purpose: wxDataViewCtrl base classes
4// Author: Robert Roebling
5// Modified by:
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"
4ed7af08
RR
24
25#if defined(__WXGTK20__)
26 // for testing
1e08ad10 27 // #define wxUSE_GENERICDATAVIEWCTRL 1
4ed7af08 28#elif defined(__WXMAC__)
4ed7af08
RR
29#else
30 #define wxUSE_GENERICDATAVIEWCTRL 1
31#endif
32
bcd846ea 33// ----------------------------------------------------------------------------
f554a14b 34// wxDataViewCtrl flags
bcd846ea
RR
35// ----------------------------------------------------------------------------
36
239eaa41
RR
37// ----------------------------------------------------------------------------
38// wxDataViewCtrl globals
39// ----------------------------------------------------------------------------
bcd846ea 40
b5dbe15d
VS
41class WXDLLIMPEXP_FWD_ADV wxDataViewItem;
42class WXDLLIMPEXP_FWD_ADV wxDataViewModel;
43class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl;
44class WXDLLIMPEXP_FWD_ADV wxDataViewColumn;
45class WXDLLIMPEXP_FWD_ADV wxDataViewRenderer;
46class WXDLLIMPEXP_FWD_ADV wxDataViewModelNotifier;
e0062c04 47class wxDataViewEventModelNotifier;
fa28826d 48
f460c29d 49extern WXDLLIMPEXP_DATA_ADV(const wxChar) wxDataViewCtrlNameStr[];
bcd846ea 50
87f0efe2
RR
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
9861f022
RR
57// the default minimal width of the columns:
58#define wxDVC_DEFAULT_MINWIDTH 30
59
60// the default alignment of wxDataViewRenderers:
61#define wxDVR_DEFAULT_ALIGNMENT (wxALIGN_LEFT|wxALIGN_TOP)
62
87f0efe2 63
f554a14b 64// ---------------------------------------------------------
e0062c04 65// wxDataViewItem
f554a14b 66// ---------------------------------------------------------
239eaa41 67
e0062c04 68class WXDLLIMPEXP_ADV wxDataViewItem
239eaa41
RR
69{
70public:
9d52aad3
RR
71 wxDataViewItem( void* id = NULL )
72 { m_id = id; }
e0062c04 73 wxDataViewItem( const wxDataViewItem &item )
9d52aad3
RR
74 { m_id = item.m_id; }
75 bool IsOk() const { return m_id != NULL; }
76 void* GetID() const { return m_id; }
e0062c04 77
8f850e28 78private:
9d52aad3 79 void* m_id;
64ffb888 80};
239eaa41 81
d5025dc0 82bool operator == (const wxDataViewItem &left, const wxDataViewItem &right);
aba9bfd0 83
f554a14b 84// ---------------------------------------------------------
e0062c04 85// wxDataViewModel
f554a14b 86// ---------------------------------------------------------
239eaa41 87
e0062c04 88class WXDLLIMPEXP_ADV wxDataViewModel: public wxObjectRefData
239eaa41
RR
89{
90public:
e0062c04 91 wxDataViewModel();
239eaa41 92
9861f022 93 virtual unsigned int GetColumnCount() const = 0;
87f0efe2 94
a7f61f76 95 // return type as reported by wxVariant
9861f022 96 virtual wxString GetColumnType( unsigned int col ) const = 0;
87f0efe2 97
a7f61f76 98 // get value into a wxVariant
e0062c04
RR
99 virtual void GetValue( wxVariant &variant,
100 const wxDataViewItem &item, unsigned int col ) const = 0;
87f0efe2 101
a7f61f76 102 // set value, call ValueChanged() afterwards!
e0062c04
RR
103 virtual bool SetValue( const wxVariant &variant,
104 const wxDataViewItem &item, unsigned int col ) = 0;
239eaa41 105
e0062c04 106 // define hierachy
ed903e42
RR
107 virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const = 0;
108 virtual bool IsContainer( const wxDataViewItem &item ) const = 0;
e0062c04
RR
109 virtual wxDataViewItem GetFirstChild( const wxDataViewItem &parent ) const = 0;
110 virtual wxDataViewItem GetNextSibling( const wxDataViewItem &item ) const = 0;
b9b8b59c 111
239eaa41 112 // delegated notifiers
e0062c04
RR
113 virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item );
114 virtual bool ItemDeleted( const wxDataViewItem &item );
115 virtual bool ItemChanged( const wxDataViewItem &item );
116 virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col );
8981608c 117 virtual bool Cleared();
b5d777c7 118
ef427989
RR
119 // delegatd action
120 virtual void Resort();
121
e0062c04
RR
122 void AddNotifier( wxDataViewModelNotifier *notifier );
123 void RemoveNotifier( wxDataViewModelNotifier *notifier );
63415a42 124
ef427989
RR
125 // default compare function
126 virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2 );
127
128 void SetSortingColumn( unsigned int col ) { m_sortingColumn = col; }
129 unsigned int GetSortingColumn() { return m_sortingColumn; }
4508fcd2 130 void SetSortOrderAscending( bool ascending ) { m_ascending = ascending; }
ef427989
RR
131 bool GetSortOrderAscending() { return m_ascending; }
132
5732efaa 133
87f0efe2
RR
134protected:
135 // the user should not delete this class directly: he should use DecRef() instead!
5debbdcf 136 virtual ~wxDataViewModel() { }
87f0efe2 137
5732efaa 138 wxList m_notifiers;
ef427989
RR
139 unsigned int m_sortingColumn;
140 bool m_ascending;
141};
142
143// ---------------------------------------------------------
144// wxDataViewVirtualListModel
145// ---------------------------------------------------------
146
147class wxDataViewIndexListModel: public wxDataViewModel
148{
149public:
150 wxDataViewIndexListModel();
151 ~wxDataViewIndexListModel();
152
153 virtual unsigned int GetRowCount() = 0;
154
155 virtual void GetValue( wxVariant &variant,
156 unsigned int row, unsigned int col ) const = 0;
157
158 virtual bool SetValue( const wxVariant &variant,
159 unsigned int row, unsigned int col ) = 0;
160
161 void ItemPrepended();
162 void ItemInserted( unsigned int before );
163 void ItemAppended();
164 void ItemChanged( unsigned int row );
165 void ValueChanged( unsigned int row, unsigned int col );
166
167 wxDataViewItem GetItem( unsigned int row );
168
169 virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2 );
170
239eaa41
RR
171};
172
f554a14b 173// ---------------------------------------------------------
e0062c04 174// wxDataViewModelNotifier
f554a14b 175// ---------------------------------------------------------
8981608c 176
e0062c04 177class WXDLLIMPEXP_ADV wxDataViewModelNotifier: public wxObject
8981608c
RR
178{
179public:
e0062c04
RR
180 wxDataViewModelNotifier() { }
181 virtual ~wxDataViewModelNotifier() { m_owner = NULL; }
9861f022 182
e0062c04
RR
183 virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ) = 0;
184 virtual bool ItemDeleted( const wxDataViewItem &item ) = 0;
185 virtual bool ItemChanged( const wxDataViewItem &item ) = 0;
186 virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col ) = 0;
187 virtual bool Cleared() = 0;
ef427989
RR
188
189 virtual void Resort() { };
8981608c 190
e0062c04
RR
191 void SetOwner( wxDataViewModel *owner ) { m_owner = owner; }
192 wxDataViewModel *GetOwner() { return m_owner; }
8f850e28 193
8981608c 194private:
e0062c04 195 wxDataViewModel *m_owner;
8981608c
RR
196};
197
e0062c04 198
1e510b1e
RR
199//-----------------------------------------------------------------------------
200// wxDataViewEditorCtrlEvtHandler
201//-----------------------------------------------------------------------------
202
203class wxDataViewEditorCtrlEvtHandler: public wxEvtHandler
204{
205public:
206 wxDataViewEditorCtrlEvtHandler( wxControl *editor, wxDataViewRenderer *owner );
207
208 void AcceptChangesAndFinish();
30715fa1 209 void SetFocusOnIdle( bool focus = true ) { m_focusOnIdle = focus; }
1e510b1e
RR
210
211protected:
212 void OnChar( wxKeyEvent &event );
213 void OnKillFocus( wxFocusEvent &event );
30715fa1 214 void OnIdle( wxIdleEvent &event );
1e510b1e
RR
215
216private:
217 wxDataViewRenderer *m_owner;
218 wxControl *m_editorCtrl;
219 bool m_finished;
30715fa1 220 bool m_focusOnIdle;
1e510b1e
RR
221
222private:
223 DECLARE_EVENT_TABLE()
224};
225
f554a14b 226// ---------------------------------------------------------
baa9ebc4 227// wxDataViewRendererBase
f554a14b 228// ---------------------------------------------------------
fa28826d 229
6842a71a 230enum wxDataViewCellMode
fa28826d 231{
6842a71a
RR
232 wxDATAVIEW_CELL_INERT,
233 wxDATAVIEW_CELL_ACTIVATABLE,
234 wxDATAVIEW_CELL_EDITABLE
fa28826d
RR
235};
236
6842a71a
RR
237enum wxDataViewCellRenderState
238{
239 wxDATAVIEW_CELL_SELECTED = 1,
240 wxDATAVIEW_CELL_PRELIT = 2,
241 wxDATAVIEW_CELL_INSENSITIVE = 4,
242 wxDATAVIEW_CELL_FOCUSED = 8
243};
244
baa9ebc4 245class WXDLLIMPEXP_ADV wxDataViewRendererBase: public wxObject
6842a71a
RR
246{
247public:
9861f022
RR
248 wxDataViewRendererBase( const wxString &varianttype,
249 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
250 int alignment = wxDVR_DEFAULT_ALIGNMENT );
6842a71a 251
9861f022
RR
252 virtual bool Validate( wxVariant& WXUNUSED(value) )
253 { return true; }
f554a14b 254
6842a71a
RR
255 void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; }
256 wxDataViewColumn* GetOwner() { return m_owner; }
f554a14b 257
9861f022
RR
258 // renderer properties:
259
260 virtual bool SetValue( const wxVariant& WXUNUSED(value) ) = 0;
261 virtual bool GetValue( wxVariant& WXUNUSED(value) ) const = 0;
262
263 wxString GetVariantType() const { return m_variantType; }
264
265 virtual void SetMode( wxDataViewCellMode mode ) = 0;
266 virtual wxDataViewCellMode GetMode() const = 0;
267
268 // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but
269 // rather an "int"; that's because for rendering cells it's allowed
270 // to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM)
271 virtual void SetAlignment( int align ) = 0;
272 virtual int GetAlignment() const = 0;
99d471a5 273
1e510b1e
RR
274 // in-place editing
275 virtual bool HasEditorCtrl()
276 { return false; }
96c2a0dd
VZ
277 virtual wxControl* CreateEditorCtrl(wxWindow * WXUNUSED(parent),
278 wxRect WXUNUSED(labelRect),
279 const wxVariant& WXUNUSED(value))
1e510b1e 280 { return NULL; }
96c2a0dd
VZ
281 virtual bool GetValueFromEditorCtrl(wxControl * WXUNUSED(editor),
282 wxVariant& WXUNUSED(value))
1e510b1e
RR
283 { return false; }
284
e0062c04 285 virtual bool StartEditing( const wxDataViewItem &item, wxRect labelRect );
1e510b1e
RR
286 virtual void CancelEditing();
287 virtual bool FinishEditing();
288
289 wxControl *GetEditorCtrl() { return m_editorCtrl; }
290
a7f61f76 291protected:
6842a71a
RR
292 wxString m_variantType;
293 wxDataViewColumn *m_owner;
1e510b1e 294 wxControl *m_editorCtrl;
e0062c04 295 wxDataViewItem m_item; // for m_editorCtrl
6842a71a 296
9861f022
RR
297 // internal utility:
298 const wxDataViewCtrl* GetView() const;
299
6842a71a 300protected:
baa9ebc4 301 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase)
6842a71a
RR
302};
303
f554a14b 304// ---------------------------------------------------------
6842a71a 305// wxDataViewColumnBase
f554a14b 306// ---------------------------------------------------------
6842a71a 307
fa28826d
RR
308enum wxDataViewColumnFlags
309{
310 wxDATAVIEW_COL_RESIZABLE = 1,
311 wxDATAVIEW_COL_SORTABLE = 2,
312 wxDATAVIEW_COL_HIDDEN = 4
313};
314
f460c29d 315class WXDLLIMPEXP_ADV wxDataViewColumnBase: public wxObject
fa28826d
RR
316{
317public:
87f0efe2
RR
318 wxDataViewColumnBase( const wxString &title, wxDataViewRenderer *renderer,
319 unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
320 wxAlignment align = wxALIGN_CENTER,
321 int flags = wxDATAVIEW_COL_RESIZABLE );
322 wxDataViewColumnBase( const wxBitmap &bitmap, wxDataViewRenderer *renderer,
323 unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
324 wxAlignment align = wxALIGN_CENTER,
325 int flags = wxDATAVIEW_COL_RESIZABLE );
d3c7fc99 326 virtual ~wxDataViewColumnBase();
fa28826d 327
9861f022 328 // setters:
07b6378f 329
9861f022 330 virtual void SetTitle( const wxString &title ) = 0;
47cef10f 331 virtual void SetAlignment( wxAlignment align ) = 0;
31fb32e1 332 virtual void SetSortable( bool sortable ) = 0;
9861f022
RR
333 virtual void SetResizeable( bool resizeable ) = 0;
334 virtual void SetHidden( bool hidden ) = 0;
47cef10f 335 virtual void SetSortOrder( bool ascending ) = 0;
9861f022
RR
336 virtual void SetFlags( int flags );
337 virtual void SetOwner( wxDataViewCtrl *owner )
338 { m_owner = owner; }
339 virtual void SetBitmap( const wxBitmap &bitmap )
340 { m_bitmap=bitmap; }
07a84e7b 341
9861f022
RR
342 virtual void SetMinWidth( int minWidth ) = 0;
343 virtual void SetWidth( int width ) = 0;
f554a14b 344
f554a14b 345
9861f022 346 // getters:
07b6378f 347
9861f022
RR
348 virtual wxString GetTitle() const = 0;
349 virtual wxAlignment GetAlignment() const = 0;
87f0efe2 350 virtual int GetWidth() const = 0;
9861f022 351 virtual int GetMinWidth() const = 0;
07b6378f 352
9861f022
RR
353 virtual int GetFlags() const;
354
355 virtual bool IsSortable() const = 0;
356 virtual bool IsResizeable() const = 0;
357 virtual bool IsHidden() const = 0;
358 virtual bool IsSortOrderAscending() const = 0;
359
360 const wxBitmap &GetBitmap() const { return m_bitmap; }
361 unsigned int GetModelColumn() const { return m_model_column; }
362
363 wxDataViewCtrl *GetOwner() { return m_owner; }
364 wxDataViewRenderer* GetRenderer() { return m_renderer; }
365
366protected:
baa9ebc4 367 wxDataViewRenderer *m_renderer;
6842a71a 368 int m_model_column;
07a84e7b 369 wxBitmap m_bitmap;
6842a71a 370 wxDataViewCtrl *m_owner;
fa28826d
RR
371
372protected:
373 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase)
374};
375
f554a14b 376// ---------------------------------------------------------
239eaa41 377// wxDataViewCtrlBase
f554a14b 378// ---------------------------------------------------------
239eaa41 379
c21f7aa1 380#define wxDV_SINGLE 0x0000 // for convenience
9861f022
RR
381#define wxDV_MULTIPLE 0x0001 // can select multiple items
382
383#define wxDV_NO_HEADER 0x0002 // column titles not visible
384#define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows
385#define wxDV_VERT_RULES 0x0008 // light vertical rules between columns
c21f7aa1 386
f460c29d 387class WXDLLIMPEXP_ADV wxDataViewCtrlBase: public wxControl
239eaa41
RR
388{
389public:
390 wxDataViewCtrlBase();
d3c7fc99 391 virtual ~wxDataViewCtrlBase();
f554a14b 392
e0062c04
RR
393 virtual bool AssociateModel( wxDataViewModel *model );
394 wxDataViewModel* GetModel();
f554a14b 395
07a84e7b 396 // short cuts
1286b7ba 397 bool AppendTextColumn( const wxString &label, unsigned int model_column,
87f0efe2
RR
398 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
399 wxAlignment align = wxALIGN_CENTER,
400 int flags = wxDATAVIEW_COL_RESIZABLE );
1286b7ba 401 bool AppendToggleColumn( const wxString &label, unsigned int model_column,
87f0efe2
RR
402 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
403 wxAlignment align = wxALIGN_CENTER,
404 int flags = wxDATAVIEW_COL_RESIZABLE );
1286b7ba 405 bool AppendProgressColumn( const wxString &label, unsigned int model_column,
87f0efe2
RR
406 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
407 wxAlignment align = wxALIGN_CENTER,
408 int flags = wxDATAVIEW_COL_RESIZABLE );
1286b7ba 409 bool AppendDateColumn( const wxString &label, unsigned int model_column,
87f0efe2
RR
410 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
411 wxAlignment align = wxALIGN_CENTER,
412 int flags = wxDATAVIEW_COL_RESIZABLE );
1286b7ba 413 bool AppendBitmapColumn( const wxString &label, unsigned int model_column,
87f0efe2
RR
414 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
415 wxAlignment align = wxALIGN_CENTER,
416 int flags = wxDATAVIEW_COL_RESIZABLE );
1286b7ba 417 bool AppendTextColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2
RR
418 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
419 wxAlignment align = wxALIGN_CENTER,
420 int flags = wxDATAVIEW_COL_RESIZABLE );
1286b7ba 421 bool AppendToggleColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2
RR
422 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
423 wxAlignment align = wxALIGN_CENTER,
424 int flags = wxDATAVIEW_COL_RESIZABLE );
1286b7ba 425 bool AppendProgressColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2
RR
426 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
427 wxAlignment align = wxALIGN_CENTER,
428 int flags = wxDATAVIEW_COL_RESIZABLE );
1286b7ba 429 bool AppendDateColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2
RR
430 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
431 wxAlignment align = wxALIGN_CENTER,
432 int flags = wxDATAVIEW_COL_RESIZABLE );
1286b7ba 433 bool AppendBitmapColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2
RR
434 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
435 wxAlignment align = wxALIGN_CENTER,
436 int flags = wxDATAVIEW_COL_RESIZABLE );
07a84e7b 437
f554a14b 438 virtual bool AppendColumn( wxDataViewColumn *col );
9861f022
RR
439
440 virtual unsigned int GetColumnCount() const;
441
0a71f9e9 442 virtual bool DeleteColumn( unsigned int pos );
fa28826d 443 virtual bool ClearColumns();
0a71f9e9 444 virtual wxDataViewColumn* GetColumn( unsigned int pos );
f554a14b 445
3b6280be
RR
446 void SetExpanderColumn( unsigned int col )
447 { m_expander_column = col ; DoSetExpanderColumn(); }
448 unsigned int GetExpanderColumn() const
449 { return m_expander_column; }
450
451 void SetIndent( int indent )
452 { m_indent = indent ; DoSetIndent(); }
453 int GetIndent() const
454 { return m_indent; }
455
e0062c04 456 // TODO selection code
1e08ad10 457 virtual wxDataViewItem GetSelection() = 0;
6ff7eee7 458
3b6280be
RR
459protected:
460 virtual void DoSetExpanderColumn() = 0 ;
461 virtual void DoSetIndent() = 0;
462
239eaa41 463private:
e0062c04 464 wxDataViewModel *m_model;
fa28826d 465 wxList m_cols;
e0062c04 466 wxDataViewEventModelNotifier *m_eventNotifier;
3b6280be
RR
467 unsigned int m_expander_column;
468 int m_indent ;
469
239eaa41 470protected:
260b9be7 471 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase)
239eaa41 472};
bcd846ea 473
eb7f97f8
RR
474// ----------------------------------------------------------------------------
475// wxDataViewEvent - the event class for the wxDataViewCtrl notifications
476// ----------------------------------------------------------------------------
477
2f799ae8 478class WXDLLIMPEXP_ADV wxDataViewEvent : public wxNotifyEvent
eb7f97f8
RR
479{
480public:
481 wxDataViewEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
482 : wxNotifyEvent(commandType, winid),
e0062c04 483 m_item(0),
eb7f97f8 484 m_col(-1),
eb7f97f8
RR
485 m_model(NULL),
486 m_value(wxNullVariant),
31fb32e1 487 m_column(NULL)
eb7f97f8
RR
488 { }
489
490 wxDataViewEvent(const wxDataViewEvent& event)
491 : wxNotifyEvent(event),
e0062c04 492 m_item(event.m_item),
eb7f97f8 493 m_col(event.m_col),
eb7f97f8
RR
494 m_model(event.m_model),
495 m_value(event.m_value),
31fb32e1 496 m_column(event.m_column)
eb7f97f8
RR
497 { }
498
e0062c04
RR
499 wxDataViewItem GetItem() const { return m_item; }
500 void SetItem( const wxDataViewItem &item ) { m_item = item; }
501
eb7f97f8
RR
502 int GetColumn() const { return m_col; }
503 void SetColumn( int col ) { m_col = col; }
9861f022 504
eb7f97f8
RR
505 wxDataViewModel* GetModel() const { return m_model; }
506 void SetModel( wxDataViewModel *model ) { m_model = model; }
9861f022 507
eb7f97f8
RR
508 const wxVariant &GetValue() const { return m_value; }
509 void SetValue( const wxVariant &value ) { m_value = value; }
510
31fb32e1
RR
511 // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only
512 void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; }
9861f022 513 wxDataViewColumn *GetDataViewColumn() const { return m_column; }
31fb32e1 514
eb7f97f8
RR
515 virtual wxEvent *Clone() const { return new wxDataViewEvent(*this); }
516
517protected:
e0062c04 518 wxDataViewItem m_item;
eb7f97f8 519 int m_col;
eb7f97f8
RR
520 wxDataViewModel *m_model;
521 wxVariant m_value;
31fb32e1 522 wxDataViewColumn *m_column;
eb7f97f8
RR
523
524private:
525 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent)
526};
527
528BEGIN_DECLARE_EVENT_TYPES()
e0062c04
RR
529 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_SELECTED, -1)
530 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, -1)
e07c1146
PC
531 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, -1)
532 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, -1)
c0a66d92 533 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, -1)
1821abd1 534 // notifications from the model to the control
e0062c04
RR
535 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_ADDED, -1)
536 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_DELETED, -1)
537 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_CHANGED, -1)
1821abd1 538 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_VALUE_CHANGED, -1)
1821abd1 539 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_CLEARED, -1)
eb7f97f8
RR
540END_DECLARE_EVENT_TYPES()
541
542typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&);
543
544#define wxDataViewEventHandler(func) \
545 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxDataViewEventFunction, &func)
546
547#define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \
548 wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn))
549
e0062c04
RR
550#define EVT_DATAVIEW_ITEM_SELECTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_SELECTED, id, fn)
551#define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn)
31fb32e1
RR
552#define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn)
553#define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn)
c0a66d92 554#define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn)
eb7f97f8 555
e0062c04
RR
556#define EVT_DATAVIEW_MODEL_ITEM_ADDED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_ITEM_APPENDED, id, fn)
557#define EVT_DATAVIEW_MODEL_ITEM_DELETED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_ITEM_DELETED, id, fn)
558#define EVT_DATAVIEW_MODEL_ITEM_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_ITEM_CHANGED, id, fn)
1821abd1 559#define EVT_DATAVIEW_MODEL_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_VALUE_CHANGED, id, fn)
1821abd1
RR
560#define EVT_DATAVIEW_MODEL_CLEARED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_CLEARED, id, fn)
561
eb7f97f8 562
4ed7af08
RR
563#if defined(wxUSE_GENERICDATAVIEWCTRL)
564 #include "wx/generic/dataview.h"
565#elif defined(__WXGTK20__)
bcd846ea
RR
566 #include "wx/gtk/dataview.h"
567#elif defined(__WXMAC__)
c0a66d92 568 #include "wx/mac/dataview.h"
bcd846ea
RR
569#else
570 #include "wx/generic/dataview.h"
571#endif
572
573#endif // wxUSE_DATAVIEWCTRL
574
575#endif
576 // _WX_DATAVIEW_H_BASE_