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