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