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