]> git.saurik.com Git - wxWidgets.git/blame - include/wx/dataview.h
allow specifying the initial modifier keys values in the ctor
[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"
b7e9f8b1 23#include "wx/dynarray.h"
89352653 24#include "wx/icon.h"
a75124d0 25#include "wx/imaglist.h"
c232dfe5 26#include "wx/weakref.h"
4ed7af08 27
5e6f8927
PC
28class WXDLLIMPEXP_FWD_CORE wxDataFormat;
29
bcd846ea 30// ----------------------------------------------------------------------------
f554a14b 31// wxDataViewCtrl flags
bcd846ea
RR
32// ----------------------------------------------------------------------------
33
239eaa41
RR
34// ----------------------------------------------------------------------------
35// wxDataViewCtrl globals
36// ----------------------------------------------------------------------------
bcd846ea 37
b5dbe15d
VS
38class WXDLLIMPEXP_FWD_ADV wxDataViewItem;
39class WXDLLIMPEXP_FWD_ADV wxDataViewModel;
40class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl;
41class WXDLLIMPEXP_FWD_ADV wxDataViewColumn;
42class WXDLLIMPEXP_FWD_ADV wxDataViewRenderer;
43class WXDLLIMPEXP_FWD_ADV wxDataViewModelNotifier;
fa28826d 44
f460c29d 45extern WXDLLIMPEXP_DATA_ADV(const wxChar) wxDataViewCtrlNameStr[];
bcd846ea 46
87f0efe2
RR
47// the default width of new (text) columns:
48#define wxDVC_DEFAULT_WIDTH 80
49
50// the default width of new toggle columns:
51#define wxDVC_TOGGLE_DEFAULT_WIDTH 30
52
9861f022
RR
53// the default minimal width of the columns:
54#define wxDVC_DEFAULT_MINWIDTH 30
55
f2b7492a
RR
56// The default alignment of wxDataViewRenderers is to take
57// the alignment from the column it owns.
58#define wxDVR_DEFAULT_ALIGNMENT -1
9861f022 59
87f0efe2 60
f554a14b 61// ---------------------------------------------------------
e0062c04 62// wxDataViewItem
f554a14b 63// ---------------------------------------------------------
239eaa41 64
e0062c04 65class WXDLLIMPEXP_ADV wxDataViewItem
239eaa41
RR
66{
67public:
b5ec7dd6 68 wxDataViewItem( void* id = NULL )
9d52aad3 69 { m_id = id; }
e0062c04 70 wxDataViewItem( const wxDataViewItem &item )
9d52aad3
RR
71 { m_id = item.m_id; }
72 bool IsOk() const { return m_id != NULL; }
73 void* GetID() const { return m_id; }
4f1cf94b 74 operator const void* () const { return m_id; }
b5ec7dd6 75
e94d0c1e 76#ifdef __WXDEBUG__
c3c62822 77 void Print( const wxString &text ) const;
e94d0c1e 78#endif
b5ec7dd6 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:
5e6f8927 95 wxDataViewModelNotifier() { m_owner = NULL; }
9d8fe14a
RR
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;
b5ec7dd6 106
d3f00f59 107 virtual void Resort() = 0;
9d8fe14a
RR
108
109 void SetOwner( wxDataViewModel *owner ) { m_owner = owner; }
e51bf699 110 wxDataViewModel *GetOwner() const { return m_owner; }
9d8fe14a
RR
111
112private:
113 wxDataViewModel *m_owner;
114};
115
116
4264606e
RR
117
118// ----------------------------------------------------------------------------
119// wxDataViewItemAttr: a structure containing the visual attributes of an item
120// ----------------------------------------------------------------------------
121
122// TODO: this should be renamed to wxItemAttr or something general like this
123
124class WXDLLIMPEXP_ADV wxDataViewItemAttr
125{
126public:
127 // ctors
c058cafa
VZ
128 wxDataViewItemAttr()
129 {
4264606e
RR
130 m_bold = false;
131 m_italic = false;
132 }
133
134 // setters
135 void SetColour(const wxColour& colour) { m_colour = colour; }
136 void SetBold( bool set ) { m_bold = set; }
137 void SetItalic( bool set ) { m_italic = set; }
c058cafa 138
4264606e
RR
139 // accessors
140 bool HasColour() const { return m_colour.Ok(); }
141 const wxColour& GetColour() const { return m_colour; }
c058cafa 142
4264606e
RR
143 bool GetBold() const { return m_bold; }
144 bool GetItalic() const { return m_italic; }
145
146private:
147 wxColour m_colour;
148 bool m_bold;
149 bool m_italic;
150};
151
152
f554a14b 153// ---------------------------------------------------------
e0062c04 154// wxDataViewModel
f554a14b 155// ---------------------------------------------------------
239eaa41 156
d350fbec
VS
157WX_DECLARE_LIST_WITH_DECL(wxDataViewModelNotifier, wxDataViewModelNotifiers,
158 class WXDLLIMPEXP_ADV);
9d8fe14a 159
e0062c04 160class WXDLLIMPEXP_ADV wxDataViewModel: public wxObjectRefData
239eaa41
RR
161{
162public:
e0062c04 163 wxDataViewModel();
239eaa41 164
9861f022 165 virtual unsigned int GetColumnCount() const = 0;
87f0efe2 166
a7f61f76 167 // return type as reported by wxVariant
9861f022 168 virtual wxString GetColumnType( unsigned int col ) const = 0;
87f0efe2 169
a7f61f76 170 // get value into a wxVariant
b5ec7dd6 171 virtual void GetValue( wxVariant &variant,
e0062c04 172 const wxDataViewItem &item, unsigned int col ) const = 0;
87f0efe2 173
a7f61f76 174 // set value, call ValueChanged() afterwards!
b5ec7dd6 175 virtual bool SetValue( const wxVariant &variant,
e0062c04 176 const wxDataViewItem &item, unsigned int col ) = 0;
239eaa41 177
4264606e
RR
178 // Get text attribute, return false of default attributes should be used
179 virtual bool GetAttr( const wxDataViewItem &WXUNUSED(item), unsigned int WXUNUSED(col), wxDataViewItemAttr &WXUNUSED(attr) )
180 { return false; }
181
e0062c04 182 // define hierachy
ed903e42
RR
183 virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const = 0;
184 virtual bool IsContainer( const wxDataViewItem &item ) const = 0;
1e40f667 185 // Is the container just a header or an item with all columns
b5ec7dd6
VZ
186 virtual bool HasContainerColumns(const wxDataViewItem& WXUNUSED(item)) const
187 { return false; }
74fe973b 188 virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const = 0;
b9b8b59c 189
f6f0ef85
RR
190 // define DnD capabilities
191 virtual bool IsDraggable( const wxDataViewItem &WXUNUSED(item) )
192 { return false; }
193 virtual size_t GetDragDataSize( const wxDataViewItem &WXUNUSED(item), const wxDataFormat &WXUNUSED(format) )
194 { return 0; }
c058cafa 195 virtual bool GetDragData( const wxDataViewItem &WXUNUSED(item), const wxDataFormat &WXUNUSED(format),
f6f0ef85
RR
196 void* WXUNUSED(data), size_t WXUNUSED(size) )
197 { return FALSE; }
198
239eaa41 199 // delegated notifiers
e0062c04 200 virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item );
854cdb09 201 virtual bool ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items );
469d3e9b 202 virtual bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item );
854cdb09 203 virtual bool ItemsDeleted( const wxDataViewItem &parent, const wxDataViewItemArray &items );
e0062c04 204 virtual bool ItemChanged( const wxDataViewItem &item );
854cdb09 205 virtual bool ItemsChanged( const wxDataViewItemArray &items );
e0062c04 206 virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col );
8981608c 207 virtual bool Cleared();
b5d777c7 208
ef427989
RR
209 // delegatd action
210 virtual void Resort();
211
e0062c04
RR
212 void AddNotifier( wxDataViewModelNotifier *notifier );
213 void RemoveNotifier( wxDataViewModelNotifier *notifier );
b5ec7dd6 214
ef427989 215 // default compare function
b5ec7dd6 216 virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
7ee7191c 217 unsigned int column, bool ascending );
09711964 218 virtual bool HasDefaultCompare() const { return false; }
c058cafa 219
2056dede 220 // internal
e39de702 221 virtual bool IsVirtualListModel() const { return false; }
66e09788 222
87f0efe2
RR
223protected:
224 // the user should not delete this class directly: he should use DecRef() instead!
5debbdcf 225 virtual ~wxDataViewModel() { }
87f0efe2 226
9d8fe14a 227 wxDataViewModelNotifiers m_notifiers;
ef427989
RR
228};
229
230// ---------------------------------------------------------
c534e696 231// wxDataViewIndexListModel
ef427989
RR
232// ---------------------------------------------------------
233
d350fbec 234class WXDLLIMPEXP_ADV wxDataViewIndexListModel: public wxDataViewModel
ef427989
RR
235{
236public:
c534e696 237 wxDataViewIndexListModel( unsigned int initial_size = 0 );
ef427989 238 ~wxDataViewIndexListModel();
b5ec7dd6 239
b5ec7dd6 240 virtual void GetValue( wxVariant &variant,
ef427989
RR
241 unsigned int row, unsigned int col ) const = 0;
242
b5ec7dd6 243 virtual bool SetValue( const wxVariant &variant,
ef427989 244 unsigned int row, unsigned int col ) = 0;
b5ec7dd6 245
4264606e
RR
246 virtual bool GetAttr( unsigned int WXUNUSED(row), unsigned int WXUNUSED(col), wxDataViewItemAttr &WXUNUSED(attr) )
247 { return false; }
c058cafa 248
c534e696
RR
249 void RowPrepended();
250 void RowInserted( unsigned int before );
251 void RowAppended();
252 void RowDeleted( unsigned int row );
8b6cf9bf 253 void RowsDeleted( const wxArrayInt &rows );
c534e696
RR
254 void RowChanged( unsigned int row );
255 void RowValueChanged( unsigned int row, unsigned int col );
33ba5a05 256 void Reset( unsigned int new_size );
b5ec7dd6 257
c534e696 258 // convert to/from row/wxDataViewItem
b5ec7dd6 259
c534e696
RR
260 unsigned int GetRow( const wxDataViewItem &item ) const;
261 wxDataViewItem GetItem( unsigned int row ) const;
b5ec7dd6 262
c534e696 263 // compare based on index
b5ec7dd6
VZ
264
265 virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
7ee7191c 266 unsigned int column, bool ascending );
517166e6 267 virtual bool HasDefaultCompare() const;
c534e696
RR
268
269 // implement base methods
270
b5ec7dd6 271 virtual void GetValue( wxVariant &variant,
c534e696 272 const wxDataViewItem &item, unsigned int col ) const;
b5ec7dd6 273 virtual bool SetValue( const wxVariant &variant,
c534e696 274 const wxDataViewItem &item, unsigned int col );
4264606e 275 virtual bool GetAttr( const wxDataViewItem &item, unsigned int col, wxDataViewItemAttr &attr );
c534e696
RR
276 virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const;
277 virtual bool IsContainer( const wxDataViewItem &item ) const;
74fe973b 278 virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const;
b5ec7dd6 279
2056dede 280 // internal
e39de702 281 virtual bool IsVirtualListModel() const { return false; }
2056dede 282 unsigned int GetLastIndex() const { return m_lastIndex; }
c058cafa 283
c534e696 284private:
cd722937 285 wxDataViewItemArray m_hash;
c534e696 286 unsigned int m_lastIndex;
517166e6 287 bool m_ordered;
239eaa41
RR
288};
289
e39de702
RR
290// ---------------------------------------------------------
291// wxDataViewVirtualListModel
292// ---------------------------------------------------------
293
294#ifdef __WXMAC__
295// better than nothing
f1399150 296typedef wxDataViewIndexListModel wxDataViewVirtualListModel;
e39de702
RR
297#else
298
299class WXDLLIMPEXP_ADV wxDataViewVirtualListModel: public wxDataViewModel
300{
301public:
302 wxDataViewVirtualListModel( unsigned int initial_size = 0 );
303 ~wxDataViewVirtualListModel();
304
305 virtual void GetValue( wxVariant &variant,
306 unsigned int row, unsigned int col ) const = 0;
307
308 virtual bool SetValue( const wxVariant &variant,
309 unsigned int row, unsigned int col ) = 0;
310
311 virtual bool GetAttr( unsigned int WXUNUSED(row), unsigned int WXUNUSED(col), wxDataViewItemAttr &WXUNUSED(attr) )
312 { return false; }
313
314 void RowPrepended();
315 void RowInserted( unsigned int before );
316 void RowAppended();
317 void RowDeleted( unsigned int row );
318 void RowsDeleted( const wxArrayInt &rows );
319 void RowChanged( unsigned int row );
320 void RowValueChanged( unsigned int row, unsigned int col );
321 void Reset( unsigned int new_size );
322
323 // convert to/from row/wxDataViewItem
324
325 unsigned int GetRow( const wxDataViewItem &item ) const;
326 wxDataViewItem GetItem( unsigned int row ) const;
327
328 // compare based on index
329
330 virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
331 unsigned int column, bool ascending );
332 virtual bool HasDefaultCompare() const;
333
334 // implement base methods
335
336 virtual void GetValue( wxVariant &variant,
337 const wxDataViewItem &item, unsigned int col ) const;
338 virtual bool SetValue( const wxVariant &variant,
339 const wxDataViewItem &item, unsigned int col );
340 virtual bool GetAttr( const wxDataViewItem &item, unsigned int col, wxDataViewItemAttr &attr );
341 virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const;
342 virtual bool IsContainer( const wxDataViewItem &item ) const;
343 virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const;
344
345 // internal
346 virtual bool IsVirtualListModel() const { return true; }
347 unsigned int GetLastIndex() const { return m_lastIndex; }
348
349private:
350 wxDataViewItemArray m_hash;
351 unsigned int m_lastIndex;
352 bool m_ordered;
353};
354#endif
c33edc08 355
1e510b1e
RR
356//-----------------------------------------------------------------------------
357// wxDataViewEditorCtrlEvtHandler
358//-----------------------------------------------------------------------------
359
360class wxDataViewEditorCtrlEvtHandler: public wxEvtHandler
361{
362public:
363 wxDataViewEditorCtrlEvtHandler( wxControl *editor, wxDataViewRenderer *owner );
b5ec7dd6 364
1e510b1e 365 void AcceptChangesAndFinish();
30715fa1 366 void SetFocusOnIdle( bool focus = true ) { m_focusOnIdle = focus; }
1e510b1e
RR
367
368protected:
369 void OnChar( wxKeyEvent &event );
370 void OnKillFocus( wxFocusEvent &event );
30715fa1 371 void OnIdle( wxIdleEvent &event );
1e510b1e
RR
372
373private:
374 wxDataViewRenderer *m_owner;
375 wxControl *m_editorCtrl;
376 bool m_finished;
30715fa1 377 bool m_focusOnIdle;
1e510b1e
RR
378
379private:
380 DECLARE_EVENT_TABLE()
381};
382
f554a14b 383// ---------------------------------------------------------
baa9ebc4 384// wxDataViewRendererBase
f554a14b 385// ---------------------------------------------------------
fa28826d 386
6842a71a 387enum wxDataViewCellMode
fa28826d 388{
6842a71a
RR
389 wxDATAVIEW_CELL_INERT,
390 wxDATAVIEW_CELL_ACTIVATABLE,
391 wxDATAVIEW_CELL_EDITABLE
fa28826d
RR
392};
393
6842a71a
RR
394enum wxDataViewCellRenderState
395{
396 wxDATAVIEW_CELL_SELECTED = 1,
397 wxDATAVIEW_CELL_PRELIT = 2,
398 wxDATAVIEW_CELL_INSENSITIVE = 4,
399 wxDATAVIEW_CELL_FOCUSED = 8
400};
401
baa9ebc4 402class WXDLLIMPEXP_ADV wxDataViewRendererBase: public wxObject
6842a71a
RR
403{
404public:
b5ec7dd6 405 wxDataViewRendererBase( const wxString &varianttype,
9861f022
RR
406 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
407 int alignment = wxDVR_DEFAULT_ALIGNMENT );
c232dfe5 408 ~wxDataViewRendererBase();
6842a71a 409
9861f022
RR
410 virtual bool Validate( wxVariant& WXUNUSED(value) )
411 { return true; }
f554a14b 412
6842a71a 413 void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; }
e51bf699 414 wxDataViewColumn* GetOwner() const { return m_owner; }
f554a14b 415
9861f022
RR
416 // renderer properties:
417
418 virtual bool SetValue( const wxVariant& WXUNUSED(value) ) = 0;
419 virtual bool GetValue( wxVariant& WXUNUSED(value) ) const = 0;
420
421 wxString GetVariantType() const { return m_variantType; }
422
423 virtual void SetMode( wxDataViewCellMode mode ) = 0;
424 virtual wxDataViewCellMode GetMode() const = 0;
425
426 // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but
427 // rather an "int"; that's because for rendering cells it's allowed
428 // to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM)
429 virtual void SetAlignment( int align ) = 0;
430 virtual int GetAlignment() const = 0;
b5ec7dd6 431
1e510b1e
RR
432 // in-place editing
433 virtual bool HasEditorCtrl()
434 { return false; }
96c2a0dd
VZ
435 virtual wxControl* CreateEditorCtrl(wxWindow * WXUNUSED(parent),
436 wxRect WXUNUSED(labelRect),
437 const wxVariant& WXUNUSED(value))
1e510b1e 438 { return NULL; }
96c2a0dd
VZ
439 virtual bool GetValueFromEditorCtrl(wxControl * WXUNUSED(editor),
440 wxVariant& WXUNUSED(value))
1e510b1e
RR
441 { return false; }
442
e0062c04 443 virtual bool StartEditing( const wxDataViewItem &item, wxRect labelRect );
1e510b1e
RR
444 virtual void CancelEditing();
445 virtual bool FinishEditing();
b5ec7dd6 446
1e510b1e 447 wxControl *GetEditorCtrl() { return m_editorCtrl; }
b5ec7dd6 448
a7f61f76 449protected:
6842a71a
RR
450 wxString m_variantType;
451 wxDataViewColumn *m_owner;
c232dfe5 452 wxWeakRef<wxControl> m_editorCtrl;
e0062c04 453 wxDataViewItem m_item; // for m_editorCtrl
6842a71a 454
9861f022
RR
455 // internal utility:
456 const wxDataViewCtrl* GetView() const;
457
6842a71a 458protected:
baa9ebc4 459 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase)
6842a71a
RR
460};
461
89352653
RR
462//-----------------------------------------------------------------------------
463// wxDataViewIconText
464//-----------------------------------------------------------------------------
465
d350fbec 466class WXDLLIMPEXP_ADV wxDataViewIconText: public wxObject
89352653
RR
467{
468public:
469 wxDataViewIconText( const wxString &text = wxEmptyString, const wxIcon& icon = wxNullIcon )
5e6f8927
PC
470 : m_text(text), m_icon(icon)
471 { }
89352653 472 wxDataViewIconText( const wxDataViewIconText &other )
4f271814 473 : wxObject()
344ed1f3 474 { m_icon = other.m_icon; m_text = other.m_text; }
89352653
RR
475
476 void SetText( const wxString &text ) { m_text = text; }
477 wxString GetText() const { return m_text; }
478 void SetIcon( const wxIcon &icon ) { m_icon = icon; }
479 const wxIcon &GetIcon() const { return m_icon; }
480
481private:
482 wxString m_text;
483 wxIcon m_icon;
484
485private:
486 DECLARE_DYNAMIC_CLASS(wxDataViewIconText)
487};
488
489bool operator == (const wxDataViewIconText &one, const wxDataViewIconText &two);
490
d350fbec 491DECLARE_VARIANT_OBJECT_EXPORTED(wxDataViewIconText, WXDLLIMPEXP_ADV)
89352653 492
f554a14b 493// ---------------------------------------------------------
6842a71a 494// wxDataViewColumnBase
f554a14b 495// ---------------------------------------------------------
6842a71a 496
fa28826d
RR
497enum wxDataViewColumnFlags
498{
e483dfcb
RR
499 wxDATAVIEW_COL_RESIZABLE = 1,
500 wxDATAVIEW_COL_SORTABLE = 2,
501 wxDATAVIEW_COL_REORDERABLE = 4,
502 wxDATAVIEW_COL_HIDDEN = 8
fa28826d
RR
503};
504
f460c29d 505class WXDLLIMPEXP_ADV wxDataViewColumnBase: public wxObject
fa28826d
RR
506{
507public:
b5ec7dd6
VZ
508 wxDataViewColumnBase( const wxString &title, wxDataViewRenderer *renderer,
509 unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
87f0efe2
RR
510 wxAlignment align = wxALIGN_CENTER,
511 int flags = wxDATAVIEW_COL_RESIZABLE );
b5ec7dd6
VZ
512 wxDataViewColumnBase( const wxBitmap &bitmap, wxDataViewRenderer *renderer,
513 unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH,
87f0efe2
RR
514 wxAlignment align = wxALIGN_CENTER,
515 int flags = wxDATAVIEW_COL_RESIZABLE );
d3c7fc99 516 virtual ~wxDataViewColumnBase();
fa28826d 517
9861f022 518 // setters:
07b6378f 519
9861f022 520 virtual void SetTitle( const wxString &title ) = 0;
47cef10f 521 virtual void SetAlignment( wxAlignment align ) = 0;
31fb32e1 522 virtual void SetSortable( bool sortable ) = 0;
99c75ebc 523 virtual void SetReorderable(bool reorderable) = 0;
9861f022
RR
524 virtual void SetResizeable( bool resizeable ) = 0;
525 virtual void SetHidden( bool hidden ) = 0;
47cef10f 526 virtual void SetSortOrder( bool ascending ) = 0;
9861f022 527 virtual void SetFlags( int flags );
b5ec7dd6 528 virtual void SetOwner( wxDataViewCtrl *owner )
9861f022
RR
529 { m_owner = owner; }
530 virtual void SetBitmap( const wxBitmap &bitmap )
531 { m_bitmap=bitmap; }
07a84e7b 532
9861f022
RR
533 virtual void SetMinWidth( int minWidth ) = 0;
534 virtual void SetWidth( int width ) = 0;
f554a14b 535
f554a14b 536
9861f022 537 // getters:
07b6378f 538
9861f022
RR
539 virtual wxString GetTitle() const = 0;
540 virtual wxAlignment GetAlignment() const = 0;
87f0efe2 541 virtual int GetWidth() const = 0;
9861f022 542 virtual int GetMinWidth() const = 0;
07b6378f 543
9861f022
RR
544 virtual int GetFlags() const;
545
9861f022 546 virtual bool IsHidden() const = 0;
99c75ebc
RR
547 virtual bool IsReorderable() const = 0;
548 virtual bool IsResizeable() const = 0;
549 virtual bool IsSortable() const = 0;
9861f022
RR
550 virtual bool IsSortOrderAscending() const = 0;
551
552 const wxBitmap &GetBitmap() const { return m_bitmap; }
6d9ecc87 553 unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column); }
9861f022 554
594d5596
RR
555 wxDataViewCtrl *GetOwner() const { return m_owner; }
556 wxDataViewRenderer* GetRenderer() const { return m_renderer; }
9861f022
RR
557
558protected:
baa9ebc4 559 wxDataViewRenderer *m_renderer;
6842a71a 560 int m_model_column;
07a84e7b 561 wxBitmap m_bitmap;
6842a71a 562 wxDataViewCtrl *m_owner;
fa28826d
RR
563
564protected:
565 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase)
566};
567
f554a14b 568// ---------------------------------------------------------
239eaa41 569// wxDataViewCtrlBase
f554a14b 570// ---------------------------------------------------------
239eaa41 571
c21f7aa1 572#define wxDV_SINGLE 0x0000 // for convenience
9861f022
RR
573#define wxDV_MULTIPLE 0x0001 // can select multiple items
574
575#define wxDV_NO_HEADER 0x0002 // column titles not visible
576#define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows
577#define wxDV_VERT_RULES 0x0008 // light vertical rules between columns
c21f7aa1 578
1a07a730 579#define wxDV_ROW_LINES 0x0010 // alternating colour in rows
344ed1f3 580#define wxDV_VARIABLE_LINE_HEIGHT 0x0020 // variable line height
1a07a730 581
f460c29d 582class WXDLLIMPEXP_ADV wxDataViewCtrlBase: public wxControl
239eaa41
RR
583{
584public:
585 wxDataViewCtrlBase();
d3c7fc99 586 virtual ~wxDataViewCtrlBase();
f554a14b 587
e0062c04
RR
588 virtual bool AssociateModel( wxDataViewModel *model );
589 wxDataViewModel* GetModel();
a75124d0 590 const wxDataViewModel* GetModel() const;
f554a14b 591
07a84e7b 592 // short cuts
b5ec7dd6 593 wxDataViewColumn *PrependTextColumn( const wxString &label, unsigned int model_column,
736fe67c
RR
594 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
595 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
596 int flags = wxDATAVIEW_COL_RESIZABLE );
b5ec7dd6 597 wxDataViewColumn *PrependIconTextColumn( const wxString &label, unsigned int model_column,
736fe67c
RR
598 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
599 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
600 int flags = wxDATAVIEW_COL_RESIZABLE );
601 wxDataViewColumn *PrependToggleColumn( const wxString &label, unsigned int model_column,
602 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
603 wxAlignment align = wxALIGN_CENTER,
604 int flags = wxDATAVIEW_COL_RESIZABLE );
b5ec7dd6 605 wxDataViewColumn *PrependProgressColumn( const wxString &label, unsigned int model_column,
736fe67c
RR
606 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
607 wxAlignment align = wxALIGN_CENTER,
608 int flags = wxDATAVIEW_COL_RESIZABLE );
609 wxDataViewColumn *PrependDateColumn( const wxString &label, unsigned int model_column,
610 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
611 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
612 int flags = wxDATAVIEW_COL_RESIZABLE );
613 wxDataViewColumn *PrependBitmapColumn( const wxString &label, unsigned int model_column,
614 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
615 wxAlignment align = wxALIGN_CENTER,
616 int flags = wxDATAVIEW_COL_RESIZABLE );
617 wxDataViewColumn *PrependTextColumn( const wxBitmap &label, unsigned int model_column,
618 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
619 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
620 int flags = wxDATAVIEW_COL_RESIZABLE );
621 wxDataViewColumn *PrependIconTextColumn( const wxBitmap &label, unsigned int model_column,
622 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
623 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
624 int flags = wxDATAVIEW_COL_RESIZABLE );
625 wxDataViewColumn *PrependToggleColumn( const wxBitmap &label, unsigned int model_column,
626 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
627 wxAlignment align = wxALIGN_CENTER,
628 int flags = wxDATAVIEW_COL_RESIZABLE );
629 wxDataViewColumn *PrependProgressColumn( const wxBitmap &label, unsigned int model_column,
630 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
631 wxAlignment align = wxALIGN_CENTER,
632 int flags = wxDATAVIEW_COL_RESIZABLE );
633 wxDataViewColumn *PrependDateColumn( const wxBitmap &label, unsigned int model_column,
634 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
635 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
636 int flags = wxDATAVIEW_COL_RESIZABLE );
637 wxDataViewColumn *PrependBitmapColumn( const wxBitmap &label, unsigned int model_column,
638 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
639 wxAlignment align = wxALIGN_CENTER,
640 int flags = wxDATAVIEW_COL_RESIZABLE );
b5ec7dd6
VZ
641
642 wxDataViewColumn *AppendTextColumn( const wxString &label, unsigned int model_column,
87f0efe2 643 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
e2da67f6 644 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
87f0efe2 645 int flags = wxDATAVIEW_COL_RESIZABLE );
b5ec7dd6 646 wxDataViewColumn *AppendIconTextColumn( const wxString &label, unsigned int model_column,
b04fcede 647 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
e2da67f6 648 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
b04fcede 649 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 650 wxDataViewColumn *AppendToggleColumn( const wxString &label, unsigned int model_column,
87f0efe2
RR
651 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
652 wxAlignment align = wxALIGN_CENTER,
653 int flags = wxDATAVIEW_COL_RESIZABLE );
b5ec7dd6 654 wxDataViewColumn *AppendProgressColumn( const wxString &label, unsigned int model_column,
87f0efe2
RR
655 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
656 wxAlignment align = wxALIGN_CENTER,
657 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 658 wxDataViewColumn *AppendDateColumn( const wxString &label, unsigned int model_column,
87f0efe2 659 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
e2da67f6 660 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
87f0efe2 661 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 662 wxDataViewColumn *AppendBitmapColumn( const wxString &label, unsigned int model_column,
87f0efe2
RR
663 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
664 wxAlignment align = wxALIGN_CENTER,
665 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 666 wxDataViewColumn *AppendTextColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2 667 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
e2da67f6 668 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
87f0efe2 669 int flags = wxDATAVIEW_COL_RESIZABLE );
b04fcede
RR
670 wxDataViewColumn *AppendIconTextColumn( const wxBitmap &label, unsigned int model_column,
671 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
e2da67f6 672 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
b04fcede 673 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 674 wxDataViewColumn *AppendToggleColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2
RR
675 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
676 wxAlignment align = wxALIGN_CENTER,
677 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 678 wxDataViewColumn *AppendProgressColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2
RR
679 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
680 wxAlignment align = wxALIGN_CENTER,
681 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 682 wxDataViewColumn *AppendDateColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2 683 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
e2da67f6 684 wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL),
87f0efe2 685 int flags = wxDATAVIEW_COL_RESIZABLE );
c7074d44 686 wxDataViewColumn *AppendBitmapColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2
RR
687 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
688 wxAlignment align = wxALIGN_CENTER,
689 int flags = wxDATAVIEW_COL_RESIZABLE );
736fe67c
RR
690
691
692 virtual bool PrependColumn( wxDataViewColumn *col );
19723525 693 virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col );
f554a14b 694 virtual bool AppendColumn( wxDataViewColumn *col );
9861f022 695
91a6c655
RR
696 virtual unsigned int GetColumnCount() const = 0;
697 virtual wxDataViewColumn* GetColumn( unsigned int pos ) const = 0;
453091c2 698 virtual int GetColumnPosition( const wxDataViewColumn *column ) const = 0;
b5ec7dd6 699
91a6c655
RR
700 virtual bool DeleteColumn( wxDataViewColumn *column ) = 0;
701 virtual bool ClearColumns() = 0;
b5ec7dd6 702
1b27b2bd 703 void SetExpanderColumn( wxDataViewColumn *col )
3b6280be 704 { m_expander_column = col ; DoSetExpanderColumn(); }
b5ec7dd6 705 wxDataViewColumn *GetExpanderColumn() const
3b6280be 706 { return m_expander_column; }
b5ec7dd6 707
21f47fb9 708 virtual wxDataViewColumn *GetSortingColumn() const = 0;
344ed1f3 709
3b6280be
RR
710 void SetIndent( int indent )
711 { m_indent = indent ; DoSetIndent(); }
b5ec7dd6
VZ
712 int GetIndent() const
713 { return m_indent; }
3b6280be 714
fbda518c 715 virtual wxDataViewItem GetSelection() const = 0;
b7e9f8b1
RR
716 virtual int GetSelections( wxDataViewItemArray & sel ) const = 0;
717 virtual void SetSelections( const wxDataViewItemArray & sel ) = 0;
718 virtual void Select( const wxDataViewItem & item ) = 0;
719 virtual void Unselect( const wxDataViewItem & item ) = 0;
720 virtual bool IsSelected( const wxDataViewItem & item ) const = 0;
721
b7e9f8b1
RR
722 virtual void SelectAll() = 0;
723 virtual void UnselectAll() = 0;
724
f71d3ba4
RR
725 virtual void Expand( const wxDataViewItem & item ) = 0;
726 virtual void Collapse( const wxDataViewItem & item ) = 0;
727
6154212e 728 virtual void EnsureVisible( const wxDataViewItem & item,
fbda518c 729 const wxDataViewColumn *column = NULL ) = 0;
a87b466d 730 virtual void HitTest( const wxPoint & point, wxDataViewItem &item, wxDataViewColumn* &column ) const = 0;
fbda518c 731 virtual wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ) const = 0;
b7e9f8b1 732
3b6280be
RR
733protected:
734 virtual void DoSetExpanderColumn() = 0 ;
735 virtual void DoSetIndent() = 0;
736
239eaa41 737private:
e0062c04 738 wxDataViewModel *m_model;
1b27b2bd 739 wxDataViewColumn *m_expander_column;
3b6280be 740 int m_indent ;
b5ec7dd6 741
239eaa41 742protected:
260b9be7 743 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase)
239eaa41 744};
bcd846ea 745
eb7f97f8
RR
746// ----------------------------------------------------------------------------
747// wxDataViewEvent - the event class for the wxDataViewCtrl notifications
748// ----------------------------------------------------------------------------
749
2f799ae8 750class WXDLLIMPEXP_ADV wxDataViewEvent : public wxNotifyEvent
eb7f97f8
RR
751{
752public:
753 wxDataViewEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
754 : wxNotifyEvent(commandType, winid),
e0062c04 755 m_item(0),
eb7f97f8 756 m_col(-1),
eb7f97f8
RR
757 m_model(NULL),
758 m_value(wxNullVariant),
6af3eec2
RR
759 m_column(NULL),
760 m_pos(-1,-1)
eb7f97f8
RR
761 { }
762
763 wxDataViewEvent(const wxDataViewEvent& event)
764 : wxNotifyEvent(event),
e0062c04 765 m_item(event.m_item),
eb7f97f8 766 m_col(event.m_col),
eb7f97f8
RR
767 m_model(event.m_model),
768 m_value(event.m_value),
6af3eec2
RR
769 m_column(event.m_column),
770 m_pos(m_pos)
eb7f97f8
RR
771 { }
772
e0062c04
RR
773 wxDataViewItem GetItem() const { return m_item; }
774 void SetItem( const wxDataViewItem &item ) { m_item = item; }
775
eb7f97f8
RR
776 int GetColumn() const { return m_col; }
777 void SetColumn( int col ) { m_col = col; }
9861f022 778
eb7f97f8
RR
779 wxDataViewModel* GetModel() const { return m_model; }
780 void SetModel( wxDataViewModel *model ) { m_model = model; }
9861f022 781
eb7f97f8
RR
782 const wxVariant &GetValue() const { return m_value; }
783 void SetValue( const wxVariant &value ) { m_value = value; }
784
31fb32e1
RR
785 // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only
786 void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; }
9861f022 787 wxDataViewColumn *GetDataViewColumn() const { return m_column; }
c058cafa 788
6af3eec2 789 // for wxEVT_DATAVIEW_CONTEXT_MENU only
5cfb6fee 790 wxPoint GetPosition() const { return m_pos; }
6af3eec2 791 void SetPosition( int x, int y ) { m_pos.x = x; m_pos.y = y; }
31fb32e1 792
eb7f97f8
RR
793 virtual wxEvent *Clone() const { return new wxDataViewEvent(*this); }
794
795protected:
e0062c04 796 wxDataViewItem m_item;
eb7f97f8 797 int m_col;
eb7f97f8
RR
798 wxDataViewModel *m_model;
799 wxVariant m_value;
31fb32e1 800 wxDataViewColumn *m_column;
6af3eec2 801 wxPoint m_pos;
eb7f97f8
RR
802
803private:
804 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent)
805};
806
c058cafa
VZ
807extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED;
808
809extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED;
810extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED;
811extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED;
812extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING;
813extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING;
814extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED;
815extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE;
816extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED;
817
818extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU;
819
820extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK;
821extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK;
822extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED;
823extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED;
eb7f97f8
RR
824
825typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&);
826
827#define wxDataViewEventHandler(func) \
828 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxDataViewEventFunction, &func)
829
830#define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \
831 wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn))
832
d86c1870
RR
833#define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn)
834
e0062c04 835#define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn)
6977c3bf 836#define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn)
3ecb8a53 837#define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn)
6977c3bf 838#define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn)
3ecb8a53 839#define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn)
e0000f94
RR
840#define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn)
841#define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn)
6608fdab 842#define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn)
e0000f94 843
6af3eec2
RR
844#define EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_CONTEXT_MENU, id, fn)
845
31fb32e1
RR
846#define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn)
847#define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn)
c0a66d92 848#define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn)
e483dfcb 849#define EVT_DATAVIEW_COLUMN_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_REORDERED, id, fn)
eb7f97f8 850
fe9fb970
VZ
851
852#if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__)
bcd846ea 853 #include "wx/gtk/dataview.h"
fe9fb970 854#elif defined(__WXMAC__) && !defined(__WXUNIVERSAL__)
ef0e9220 855 #include "wx/osx/dataview.h"
bcd846ea 856#else
fe9fb970 857 #define wxUSE_GENERICDATAVIEWCTRL
bcd846ea
RR
858 #include "wx/generic/dataview.h"
859#endif
860
52e750fc
RR
861// -------------------------------------
862// wxDataViewSpinRenderer
863// -------------------------------------
864
4660b556 865class WXDLLIMPEXP_ADV wxDataViewSpinRenderer: public wxDataViewCustomRenderer
52e750fc
RR
866{
867public:
868 wxDataViewSpinRenderer( int min, int max,
869 wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
870 int alignment = wxDVR_DEFAULT_ALIGNMENT );
871 virtual bool HasEditorCtrl() { return true; }
872 virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value );
873 virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value );
874 virtual bool Render( wxRect rect, wxDC *dc, int state );
875 virtual wxSize GetSize() const;
876 virtual bool SetValue( const wxVariant &value );
877 virtual bool GetValue( wxVariant &value ) const;
b5ec7dd6 878
52e750fc
RR
879private:
880 long m_data;
881 long m_min,m_max;
882};
883
e94d0c1e
RR
884//-----------------------------------------------------------------------------
885// wxDataViewTreeStore
886//-----------------------------------------------------------------------------
887
888class WXDLLIMPEXP_ADV wxDataViewTreeStoreNode
889{
890public:
891 wxDataViewTreeStoreNode( wxDataViewTreeStoreNode *parent,
892 const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
893 virtual ~wxDataViewTreeStoreNode();
b5ec7dd6
VZ
894
895 void SetText( const wxString &text )
e94d0c1e
RR
896 { m_text = text; }
897 wxString GetText() const
898 { return m_text; }
899 void SetIcon( const wxIcon &icon )
900 { m_icon = icon; }
901 const wxIcon &GetIcon() const
902 { return m_icon; }
903 void SetData( wxClientData *data )
904 { if (m_data) delete m_data; m_data = data; }
905 wxClientData *GetData() const
906 { return m_data; }
b5ec7dd6 907
e94d0c1e
RR
908 wxDataViewItem GetItem() const
909 { return wxDataViewItem( (void*) this ); }
b5ec7dd6 910
e94d0c1e
RR
911 virtual bool IsContainer()
912 { return false; }
b5ec7dd6 913
e94d0c1e
RR
914 wxDataViewTreeStoreNode *GetParent()
915 { return m_parent; }
b5ec7dd6 916
e94d0c1e
RR
917private:
918 wxDataViewTreeStoreNode *m_parent;
919 wxString m_text;
920 wxIcon m_icon;
921 wxClientData *m_data;
922};
923
924WX_DECLARE_LIST_WITH_DECL(wxDataViewTreeStoreNode, wxDataViewTreeStoreNodeList,
925 class WXDLLIMPEXP_ADV);
926
927class WXDLLIMPEXP_ADV wxDataViewTreeStoreContainerNode: public wxDataViewTreeStoreNode
928{
929public:
b5ec7dd6
VZ
930 wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode *parent,
931 const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
e94d0c1e
RR
932 wxClientData *data = NULL );
933 virtual ~wxDataViewTreeStoreContainerNode();
934
b5ec7dd6 935 const wxDataViewTreeStoreNodeList &GetChildren() const
e94d0c1e 936 { return m_children; }
b5ec7dd6 937 wxDataViewTreeStoreNodeList &GetChildren()
e94d0c1e
RR
938 { return m_children; }
939
940 void SetExpandedIcon( const wxIcon &icon )
941 { m_iconExpanded = icon; }
942 const wxIcon &GetExpandedIcon() const
943 { return m_iconExpanded; }
b5ec7dd6 944
a75124d0
RR
945 void SetExpanded( bool expanded = true )
946 { m_isExpanded = expanded; }
947 bool IsExpanded() const
948 { return m_isExpanded; }
949
e94d0c1e
RR
950 virtual bool IsContainer()
951 { return true; }
b5ec7dd6 952
e94d0c1e
RR
953private:
954 wxDataViewTreeStoreNodeList m_children;
955 wxIcon m_iconExpanded;
a75124d0 956 bool m_isExpanded;
e94d0c1e
RR
957};
958
959//-----------------------------------------------------------------------------
960
961class WXDLLIMPEXP_ADV wxDataViewTreeStore: public wxDataViewModel
962{
963public:
964 wxDataViewTreeStore();
965 ~wxDataViewTreeStore();
966
b5ec7dd6 967 wxDataViewItem AppendItem( const wxDataViewItem& parent,
e94d0c1e
RR
968 const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
969 wxDataViewItem PrependItem( const wxDataViewItem& parent,
970 const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
971 wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous,
972 const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
b5ec7dd6
VZ
973
974 wxDataViewItem PrependContainer( const wxDataViewItem& parent,
975 const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
e94d0c1e
RR
976 wxClientData *data = NULL );
977 wxDataViewItem AppendContainer( const wxDataViewItem& parent,
b5ec7dd6 978 const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
e94d0c1e
RR
979 wxClientData *data = NULL );
980 wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous,
b5ec7dd6 981 const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
e94d0c1e
RR
982 wxClientData *data = NULL );
983
984 wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const;
985 int GetChildCount( const wxDataViewItem& parent ) const;
b5ec7dd6 986
e94d0c1e
RR
987 void SetItemText( const wxDataViewItem& item, const wxString &text );
988 wxString GetItemText( const wxDataViewItem& item ) const;
b5ec7dd6 989 void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon );
e94d0c1e
RR
990 const wxIcon &GetItemIcon( const wxDataViewItem& item ) const;
991 void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon );
992 const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const;
993 void SetItemData( const wxDataViewItem& item, wxClientData *data );
994 wxClientData *GetItemData( const wxDataViewItem& item ) const;
995
996 void DeleteItem( const wxDataViewItem& item );
997 void DeleteChildren( const wxDataViewItem& item );
998 void DeleteAllItems();
b5ec7dd6 999
e94d0c1e
RR
1000 // implement base methods
1001
b5ec7dd6 1002 virtual void GetValue( wxVariant &variant,
e94d0c1e 1003 const wxDataViewItem &item, unsigned int col ) const;
b5ec7dd6 1004 virtual bool SetValue( const wxVariant &variant,
e94d0c1e
RR
1005 const wxDataViewItem &item, unsigned int col );
1006 virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const;
1007 virtual bool IsContainer( const wxDataViewItem &item ) const;
1008 virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const;
1009
b5ec7dd6 1010 virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
e94d0c1e 1011 unsigned int column, bool ascending );
b5ec7dd6
VZ
1012
1013 virtual bool HasDefaultCompare() const
e94d0c1e 1014 { return true; }
b5ec7dd6 1015 virtual unsigned int GetColumnCount() const
e94d0c1e 1016 { return 1; };
b5ec7dd6 1017 virtual wxString GetColumnType( unsigned int WXUNUSED(col) ) const
594d5596 1018 { return wxT("wxDataViewIconText"); }
b5ec7dd6 1019
e94d0c1e
RR
1020 wxDataViewTreeStoreNode *FindNode( const wxDataViewItem &item ) const;
1021 wxDataViewTreeStoreContainerNode *FindContainerNode( const wxDataViewItem &item ) const;
1022 wxDataViewTreeStoreNode *GetRoot() const { return m_root; }
b5ec7dd6 1023
e94d0c1e
RR
1024public:
1025 wxDataViewTreeStoreNode *m_root;
1026};
1027
e94d0c1e
RR
1028class WXDLLIMPEXP_ADV wxDataViewTreeCtrl: public wxDataViewCtrl
1029{
1030public:
a75124d0
RR
1031 wxDataViewTreeCtrl();
1032 wxDataViewTreeCtrl( wxWindow *parent, wxWindowID id,
e94d0c1e 1033 const wxPoint& pos = wxDefaultPosition,
1a07a730 1034 const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
e94d0c1e 1035 const wxValidator& validator = wxDefaultValidator );
a75124d0 1036 ~wxDataViewTreeCtrl();
e94d0c1e
RR
1037
1038 bool Create( wxWindow *parent, wxWindowID id,
1039 const wxPoint& pos = wxDefaultPosition,
1a07a730 1040 const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
e94d0c1e
RR
1041 const wxValidator& validator = wxDefaultValidator );
1042
1043 wxDataViewTreeStore *GetStore()
1044 { return (wxDataViewTreeStore*) GetModel(); }
a75124d0
RR
1045 const wxDataViewTreeStore *GetStore() const
1046 { return (const wxDataViewTreeStore*) GetModel(); }
b5ec7dd6 1047
a75124d0
RR
1048 void SetImageList( wxImageList *imagelist );
1049 wxImageList* GetImageList() { return m_imageList; }
c058cafa 1050
a75124d0
RR
1051 wxDataViewItem AppendItem( const wxDataViewItem& parent,
1052 const wxString &text, int icon = -1, wxClientData *data = NULL );
1053 wxDataViewItem PrependItem( const wxDataViewItem& parent,
1054 const wxString &text, int icon = -1, wxClientData *data = NULL );
1055 wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous,
1056 const wxString &text, int icon = -1, wxClientData *data = NULL );
1057
1058 wxDataViewItem PrependContainer( const wxDataViewItem& parent,
1059 const wxString &text, int icon = -1, int expanded = -1,
1060 wxClientData *data = NULL );
1061 wxDataViewItem AppendContainer( const wxDataViewItem& parent,
1062 const wxString &text, int icon = -1, int expanded = -1,
1063 wxClientData *data = NULL );
1064 wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous,
1065 const wxString &text, int icon = -1, int expanded = -1,
1066 wxClientData *data = NULL );
1067
1068 wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const
1069 { return GetStore()->GetNthChild(parent, pos); }
1070 int GetChildCount( const wxDataViewItem& parent ) const
1071 { return GetStore()->GetChildCount(parent); }
1072
1073 void SetItemText( const wxDataViewItem& item, const wxString &text )
1074 { GetStore()->SetItemText(item,text); }
1075 wxString GetItemText( const wxDataViewItem& item ) const
1076 { return GetStore()->GetItemText(item); }
1077 void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon )
1078 { GetStore()->SetItemIcon(item,icon); }
1079 const wxIcon &GetItemIcon( const wxDataViewItem& item ) const
1080 { return GetStore()->GetItemIcon(item); }
1081 void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon )
1082 { GetStore()->SetItemExpandedIcon(item,icon); }
1083 const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const
1084 { return GetStore()->GetItemExpandedIcon(item); }
1085 void SetItemData( const wxDataViewItem& item, wxClientData *data )
1086 { GetStore()->SetItemData(item,data); }
1087 wxClientData *GetItemData( const wxDataViewItem& item ) const
1088 { return GetStore()->GetItemData(item); }
1089
1090 void DeleteItem( const wxDataViewItem& item )
1091 { GetStore()->DeleteItem(item); }
1092 void DeleteChildren( const wxDataViewItem& item )
1093 { GetStore()->DeleteChildren(item); }
1094 void DeleteAllItems()
1095 { GetStore()->DeleteAllItems(); }
1096
1097 void OnExpanded( wxDataViewEvent &event );
1098 void OnCollapsed( wxDataViewEvent &event );
1a07a730 1099 void OnSize( wxSizeEvent &event );
b5ec7dd6 1100
e94d0c1e 1101private:
a75124d0
RR
1102 wxImageList *m_imageList;
1103
1104private:
1105 DECLARE_EVENT_TABLE()
e94d0c1e
RR
1106 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl)
1107};
e94d0c1e 1108
bcd846ea
RR
1109#endif // wxUSE_DATAVIEWCTRL
1110
1111#endif
1112 // _WX_DATAVIEW_H_BASE_