]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/dataview.h
added wxDataViewIconTextRenderer
[wxWidgets.git] / include / wx / dataview.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/dataview.h
3// Purpose: wxDataViewCtrl base classes
4// Author: Robert Roebling
5// Modified by: Bo Yang
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
19#include "wx/control.h"
20#include "wx/textctrl.h"
21#include "wx/bitmap.h"
22#include "wx/variant.h"
23#include "wx/listctrl.h"
24#include "wx/dynarray.h"
25#include "wx/icon.h"
26
27#if defined(__WXGTK20__)
28 // for testing
29 #define wxUSE_GENERICDATAVIEWCTRL 1
30#elif defined(__WXMAC__)
31#else
32 #define wxUSE_GENERICDATAVIEWCTRL 1
33#endif
34
35// ----------------------------------------------------------------------------
36// wxDataViewCtrl flags
37// ----------------------------------------------------------------------------
38
39// ----------------------------------------------------------------------------
40// wxDataViewCtrl globals
41// ----------------------------------------------------------------------------
42
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;
49
50extern WXDLLIMPEXP_DATA_ADV(const wxChar) wxDataViewCtrlNameStr[];
51
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
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
64
65// ---------------------------------------------------------
66// wxDataViewItem
67// ---------------------------------------------------------
68
69class WXDLLIMPEXP_ADV wxDataViewItem
70{
71public:
72 wxDataViewItem( void* id = NULL )
73 { m_id = id; }
74 wxDataViewItem( const wxDataViewItem &item )
75 { m_id = item.m_id; }
76 bool IsOk() const { return m_id != NULL; }
77 void* GetID() const { return m_id; }
78 operator const void* () const { return m_id; }
79
80private:
81 void* m_id;
82};
83
84bool operator == (const wxDataViewItem &left, const wxDataViewItem &right);
85
86WX_DEFINE_ARRAY(wxDataViewItem, wxDataViewItemArray);
87
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
104 virtual void Resort() = 0;
105
106 void SetOwner( wxDataViewModel *owner ) { m_owner = owner; }
107 wxDataViewModel *GetOwner() { return m_owner; }
108
109private:
110 wxDataViewModel *m_owner;
111};
112
113
114// ---------------------------------------------------------
115// wxDataViewModel
116// ---------------------------------------------------------
117
118WX_DECLARE_LIST(wxDataViewModelNotifier, wxDataViewModelNotifiers );
119
120class WXDLLIMPEXP_ADV wxDataViewModel: public wxObjectRefData
121{
122public:
123 wxDataViewModel();
124
125 virtual unsigned int GetColumnCount() const = 0;
126
127 // return type as reported by wxVariant
128 virtual wxString GetColumnType( unsigned int col ) const = 0;
129
130 // get value into a wxVariant
131 virtual void GetValue( wxVariant &variant,
132 const wxDataViewItem &item, unsigned int col ) const = 0;
133
134 // set value, call ValueChanged() afterwards!
135 virtual bool SetValue( const wxVariant &variant,
136 const wxDataViewItem &item, unsigned int col ) = 0;
137
138 // define hierachy
139 virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const = 0;
140 virtual bool IsContainer( const wxDataViewItem &item ) const = 0;
141 virtual wxDataViewItem GetFirstChild( const wxDataViewItem &parent ) const = 0;
142 virtual wxDataViewItem GetNextSibling( const wxDataViewItem &item ) const = 0;
143
144 // delegated notifiers
145 virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item );
146 virtual bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item );
147 virtual bool ItemChanged( const wxDataViewItem &item );
148 virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col );
149 virtual bool Cleared();
150
151 // delegatd action
152 virtual void Resort();
153
154 void AddNotifier( wxDataViewModelNotifier *notifier );
155 void RemoveNotifier( wxDataViewModelNotifier *notifier );
156
157 // default compare function
158 virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
159 unsigned int column, bool ascending );
160 virtual bool HasDefaultCompare() { return false; }
161
162protected:
163 // the user should not delete this class directly: he should use DecRef() instead!
164 virtual ~wxDataViewModel() { }
165
166 wxDataViewModelNotifiers m_notifiers;
167};
168
169// ---------------------------------------------------------
170// wxDataViewIndexListModel
171// ---------------------------------------------------------
172
173class wxDataViewIndexListModel: public wxDataViewModel
174{
175public:
176 wxDataViewIndexListModel( unsigned int initial_size = 0 );
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
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
195
196 unsigned int GetRow( const wxDataViewItem &item ) const;
197 wxDataViewItem GetItem( unsigned int row ) const;
198
199 // compare based on index
200
201 virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
202 unsigned int column, bool ascending );
203 virtual bool HasDefaultCompare() { return true; }
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;
215
216private:
217 wxDataViewItemArray m_hash;
218 unsigned int m_lastIndex;
219};
220
221//-----------------------------------------------------------------------------
222// wxDataViewEditorCtrlEvtHandler
223//-----------------------------------------------------------------------------
224
225class wxDataViewEditorCtrlEvtHandler: public wxEvtHandler
226{
227public:
228 wxDataViewEditorCtrlEvtHandler( wxControl *editor, wxDataViewRenderer *owner );
229
230 void AcceptChangesAndFinish();
231 void SetFocusOnIdle( bool focus = true ) { m_focusOnIdle = focus; }
232
233protected:
234 void OnChar( wxKeyEvent &event );
235 void OnKillFocus( wxFocusEvent &event );
236 void OnIdle( wxIdleEvent &event );
237
238private:
239 wxDataViewRenderer *m_owner;
240 wxControl *m_editorCtrl;
241 bool m_finished;
242 bool m_focusOnIdle;
243
244private:
245 DECLARE_EVENT_TABLE()
246};
247
248// ---------------------------------------------------------
249// wxDataViewRendererBase
250// ---------------------------------------------------------
251
252enum wxDataViewCellMode
253{
254 wxDATAVIEW_CELL_INERT,
255 wxDATAVIEW_CELL_ACTIVATABLE,
256 wxDATAVIEW_CELL_EDITABLE
257};
258
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
267class WXDLLIMPEXP_ADV wxDataViewRendererBase: public wxObject
268{
269public:
270 wxDataViewRendererBase( const wxString &varianttype,
271 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
272 int alignment = wxDVR_DEFAULT_ALIGNMENT );
273
274 virtual bool Validate( wxVariant& WXUNUSED(value) )
275 { return true; }
276
277 void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; }
278 wxDataViewColumn* GetOwner() { return m_owner; }
279
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;
295
296 // in-place editing
297 virtual bool HasEditorCtrl()
298 { return false; }
299 virtual wxControl* CreateEditorCtrl(wxWindow * WXUNUSED(parent),
300 wxRect WXUNUSED(labelRect),
301 const wxVariant& WXUNUSED(value))
302 { return NULL; }
303 virtual bool GetValueFromEditorCtrl(wxControl * WXUNUSED(editor),
304 wxVariant& WXUNUSED(value))
305 { return false; }
306
307 virtual bool StartEditing( const wxDataViewItem &item, wxRect labelRect );
308 virtual void CancelEditing();
309 virtual bool FinishEditing();
310
311 wxControl *GetEditorCtrl() { return m_editorCtrl; }
312
313protected:
314 wxString m_variantType;
315 wxDataViewColumn *m_owner;
316 wxControl *m_editorCtrl;
317 wxDataViewItem m_item; // for m_editorCtrl
318
319 // internal utility:
320 const wxDataViewCtrl* GetView() const;
321
322protected:
323 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase)
324};
325
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
355// ---------------------------------------------------------
356// wxDataViewColumnBase
357// ---------------------------------------------------------
358
359enum wxDataViewColumnFlags
360{
361 wxDATAVIEW_COL_RESIZABLE = 1,
362 wxDATAVIEW_COL_SORTABLE = 2,
363 wxDATAVIEW_COL_HIDDEN = 4
364};
365
366class WXDLLIMPEXP_ADV wxDataViewColumnBase: public wxObject
367{
368public:
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 );
377 virtual ~wxDataViewColumnBase();
378
379 // setters:
380
381 virtual void SetTitle( const wxString &title ) = 0;
382 virtual void SetAlignment( wxAlignment align ) = 0;
383 virtual void SetSortable( bool sortable ) = 0;
384 virtual void SetResizeable( bool resizeable ) = 0;
385 virtual void SetHidden( bool hidden ) = 0;
386 virtual void SetSortOrder( bool ascending ) = 0;
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; }
392
393 virtual void SetMinWidth( int minWidth ) = 0;
394 virtual void SetWidth( int width ) = 0;
395
396
397 // getters:
398
399 virtual wxString GetTitle() const = 0;
400 virtual wxAlignment GetAlignment() const = 0;
401 virtual int GetWidth() const = 0;
402 virtual int GetMinWidth() const = 0;
403
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:
418 wxDataViewRenderer *m_renderer;
419 int m_model_column;
420 wxBitmap m_bitmap;
421 wxDataViewCtrl *m_owner;
422
423protected:
424 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase)
425};
426
427// ---------------------------------------------------------
428// wxDataViewCtrlBase
429// ---------------------------------------------------------
430
431#define wxDV_SINGLE 0x0000 // for convenience
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
437
438class WXDLLIMPEXP_ADV wxDataViewCtrlBase: public wxControl
439{
440public:
441 wxDataViewCtrlBase();
442 virtual ~wxDataViewCtrlBase();
443
444 virtual bool AssociateModel( wxDataViewModel *model );
445 wxDataViewModel* GetModel();
446
447 // short cuts
448 wxDataViewColumn *AppendTextColumn( const wxString &label, unsigned int model_column,
449 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
450 wxAlignment align = wxALIGN_CENTER,
451 int flags = wxDATAVIEW_COL_RESIZABLE );
452 wxDataViewColumn *AppendToggleColumn( const wxString &label, unsigned int model_column,
453 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
454 wxAlignment align = wxALIGN_CENTER,
455 int flags = wxDATAVIEW_COL_RESIZABLE );
456 wxDataViewColumn *AppendProgressColumn( const wxString &label, unsigned int model_column,
457 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
458 wxAlignment align = wxALIGN_CENTER,
459 int flags = wxDATAVIEW_COL_RESIZABLE );
460 wxDataViewColumn *AppendDateColumn( const wxString &label, unsigned int model_column,
461 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
462 wxAlignment align = wxALIGN_CENTER,
463 int flags = wxDATAVIEW_COL_RESIZABLE );
464 wxDataViewColumn *AppendBitmapColumn( const wxString &label, unsigned int model_column,
465 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
466 wxAlignment align = wxALIGN_CENTER,
467 int flags = wxDATAVIEW_COL_RESIZABLE );
468 wxDataViewColumn *AppendTextColumn( const wxBitmap &label, unsigned int model_column,
469 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
470 wxAlignment align = wxALIGN_CENTER,
471 int flags = wxDATAVIEW_COL_RESIZABLE );
472 wxDataViewColumn *AppendToggleColumn( const wxBitmap &label, unsigned int model_column,
473 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH,
474 wxAlignment align = wxALIGN_CENTER,
475 int flags = wxDATAVIEW_COL_RESIZABLE );
476 wxDataViewColumn *AppendProgressColumn( const wxBitmap &label, unsigned int model_column,
477 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH,
478 wxAlignment align = wxALIGN_CENTER,
479 int flags = wxDATAVIEW_COL_RESIZABLE );
480 wxDataViewColumn *AppendDateColumn( const wxBitmap &label, unsigned int model_column,
481 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1,
482 wxAlignment align = wxALIGN_CENTER,
483 int flags = wxDATAVIEW_COL_RESIZABLE );
484
485 wxDataViewColumn *AppendBitmapColumn( const wxBitmap &label, unsigned int model_column,
486 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1,
487 wxAlignment align = wxALIGN_CENTER,
488 int flags = wxDATAVIEW_COL_RESIZABLE );
489
490 virtual bool AppendColumn( wxDataViewColumn *col );
491
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
498 void SetExpanderColumn( wxDataViewColumn *col )
499 { m_expander_column = col ; DoSetExpanderColumn(); }
500 wxDataViewColumn *GetExpanderColumn() const
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
508 virtual wxDataViewItem GetSelection() const = 0;
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
515 virtual void SelectAll() = 0;
516 virtual void UnselectAll() = 0;
517
518 virtual void Expand( const wxDataViewItem & item ) = 0;
519 virtual void Collapse( const wxDataViewItem & item ) = 0;
520
521 virtual void EnsureVisible( const wxDataViewItem & item,
522 const wxDataViewColumn *column = NULL ) = 0;
523 virtual void HitTest( const wxPoint & point, wxDataViewItem &item, wxDataViewColumn* &column ) const = 0;
524 virtual wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ) const = 0;
525
526protected:
527 virtual void DoSetExpanderColumn() = 0 ;
528 virtual void DoSetIndent() = 0;
529
530private:
531 wxDataViewModel *m_model;
532 wxDataViewColumn *m_expander_column;
533 int m_indent ;
534
535protected:
536 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase)
537};
538
539// ----------------------------------------------------------------------------
540// wxDataViewEvent - the event class for the wxDataViewCtrl notifications
541// ----------------------------------------------------------------------------
542
543class WXDLLIMPEXP_ADV wxDataViewEvent : public wxNotifyEvent
544{
545public:
546 wxDataViewEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
547 : wxNotifyEvent(commandType, winid),
548 m_item(0),
549 m_col(-1),
550 m_model(NULL),
551 m_value(wxNullVariant),
552 m_column(NULL)
553 { }
554
555 wxDataViewEvent(const wxDataViewEvent& event)
556 : wxNotifyEvent(event),
557 m_item(event.m_item),
558 m_col(event.m_col),
559 m_model(event.m_model),
560 m_value(event.m_value),
561 m_column(event.m_column)
562 { }
563
564 wxDataViewItem GetItem() const { return m_item; }
565 void SetItem( const wxDataViewItem &item ) { m_item = item; }
566
567 int GetColumn() const { return m_col; }
568 void SetColumn( int col ) { m_col = col; }
569
570 wxDataViewModel* GetModel() const { return m_model; }
571 void SetModel( wxDataViewModel *model ) { m_model = model; }
572
573 const wxVariant &GetValue() const { return m_value; }
574 void SetValue( const wxVariant &value ) { m_value = value; }
575
576 // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only
577 void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; }
578 wxDataViewColumn *GetDataViewColumn() const { return m_column; }
579
580 virtual wxEvent *Clone() const { return new wxDataViewEvent(*this); }
581
582protected:
583 wxDataViewItem m_item;
584 int m_col;
585 wxDataViewModel *m_model;
586 wxVariant m_value;
587 wxDataViewColumn *m_column;
588
589private:
590 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent)
591};
592
593BEGIN_DECLARE_EVENT_TYPES()
594 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_SELECTED, -1)
595 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_DESELECTED, -1)
596 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, -1)
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)
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)
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
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)
606 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, -1)
607
608 // notifications from the model to the control
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)
612 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_VALUE_CHANGED, -1)
613 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_CLEARED, -1)
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
624#define EVT_DATAVIEW_ITEM_SELECTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_SELECTED, id, fn)
625#define EVT_DATAVIEW_ITEM_DESELECTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DESELECTED, id, fn)
626#define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn)
627#define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn)
628#define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn)
629#define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn)
630#define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn)
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
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)
636#define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn)
637
638#define EVT_DATAVIEW_MODEL_ITEM_ADDED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_ITEM_ADDED, id, fn)
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)
641#define EVT_DATAVIEW_MODEL_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_VALUE_CHANGED, id, fn)
642#define EVT_DATAVIEW_MODEL_CLEARED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_CLEARED, id, fn)
643
644
645#if defined(wxUSE_GENERICDATAVIEWCTRL)
646 #include "wx/generic/dataview.h"
647#elif defined(__WXGTK20__)
648 #include "wx/gtk/dataview.h"
649#elif defined(__WXMAC__)
650 #include "wx/mac/dataview.h"
651#else
652 #include "wx/generic/dataview.h"
653#endif
654
655#endif // wxUSE_DATAVIEWCTRL
656
657#endif
658 // _WX_DATAVIEW_H_BASE_