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