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