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