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