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