]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/dataview.h | |
3 | // Purpose: wxDataViewCtrl base classes | |
4 | // Author: Robert Roebling | |
5 | // Modified by: | |
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 | ||
25 | #if defined(__WXGTK20__) | |
26 | // for testing | |
27 | // #define wxUSE_GENERICDATAVIEWCTRL 1 | |
28 | #elif defined(__WXMAC__) | |
29 | #else | |
30 | #define wxUSE_GENERICDATAVIEWCTRL 1 | |
31 | #endif | |
32 | ||
33 | // ---------------------------------------------------------------------------- | |
34 | // wxDataViewCtrl flags | |
35 | // ---------------------------------------------------------------------------- | |
36 | ||
37 | // ---------------------------------------------------------------------------- | |
38 | // wxDataViewCtrl globals | |
39 | // ---------------------------------------------------------------------------- | |
40 | ||
41 | class WXDLLIMPEXP_FWD_ADV wxDataViewItem; | |
42 | class WXDLLIMPEXP_FWD_ADV wxDataViewModel; | |
43 | class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl; | |
44 | class WXDLLIMPEXP_FWD_ADV wxDataViewColumn; | |
45 | class WXDLLIMPEXP_FWD_ADV wxDataViewRenderer; | |
46 | class WXDLLIMPEXP_FWD_ADV wxDataViewModelNotifier; | |
47 | class wxDataViewEventModelNotifier; | |
48 | ||
49 | extern WXDLLIMPEXP_DATA_ADV(const wxChar) wxDataViewCtrlNameStr[]; | |
50 | ||
51 | // the default width of new (text) columns: | |
52 | #define wxDVC_DEFAULT_WIDTH 80 | |
53 | ||
54 | // the default width of new toggle columns: | |
55 | #define wxDVC_TOGGLE_DEFAULT_WIDTH 30 | |
56 | ||
57 | // the default minimal width of the columns: | |
58 | #define wxDVC_DEFAULT_MINWIDTH 30 | |
59 | ||
60 | // the default alignment of wxDataViewRenderers: | |
61 | #define wxDVR_DEFAULT_ALIGNMENT (wxALIGN_LEFT|wxALIGN_TOP) | |
62 | ||
63 | ||
64 | // --------------------------------------------------------- | |
65 | // wxDataViewItem | |
66 | // --------------------------------------------------------- | |
67 | ||
68 | class WXDLLIMPEXP_ADV wxDataViewItem | |
69 | { | |
70 | public: | |
71 | wxDataViewItem( wxUint32 id = 0 ) | |
72 | { m_id = id; m_reserved1 = 0; m_reserved2 = NULL; } | |
73 | wxDataViewItem( const wxDataViewItem &item ) | |
74 | { m_id = item.m_id; m_reserved1 = item.m_reserved1; m_reserved2 = item.m_reserved2; } | |
75 | bool IsOk() const { return m_id != 0; } | |
76 | wxUint32 GetID() const { return m_id; } | |
77 | ||
78 | public: | |
79 | wxUint32 m_reserved1; | |
80 | void* m_reserved2; | |
81 | ||
82 | private: | |
83 | wxUint32 m_id; | |
84 | }; | |
85 | ||
86 | bool operator == ( const wxDataViewItem& left, const wxDataViewItem& right ); | |
87 | ||
88 | // --------------------------------------------------------- | |
89 | // wxDataViewModel | |
90 | // --------------------------------------------------------- | |
91 | ||
92 | typedef int (wxCALLBACK *wxDataViewModelCompare) | |
93 | (const wxDataViewItem& item1, const wxDataViewItem& item2, unsigned int col, unsigned int option ); | |
94 | ||
95 | class WXDLLIMPEXP_ADV wxDataViewModel: public wxObjectRefData | |
96 | { | |
97 | public: | |
98 | wxDataViewModel(); | |
99 | ||
100 | virtual unsigned int GetColumnCount() const = 0; | |
101 | ||
102 | // return type as reported by wxVariant | |
103 | virtual wxString GetColumnType( unsigned int col ) const = 0; | |
104 | ||
105 | // get value into a wxVariant | |
106 | virtual void GetValue( wxVariant &variant, | |
107 | const wxDataViewItem &item, unsigned int col ) const = 0; | |
108 | ||
109 | // set value, call ValueChanged() afterwards! | |
110 | virtual bool SetValue( const wxVariant &variant, | |
111 | const wxDataViewItem &item, unsigned int col ) = 0; | |
112 | ||
113 | // define hierachy | |
114 | virtual bool HasChildren( const wxDataViewItem &item ) const = 0; | |
115 | virtual int GetChildCount( const wxDataViewItem &item ) const = 0; | |
116 | virtual wxDataViewItem GetParent( const wxDataViewItem &child ) const = 0; | |
117 | virtual wxDataViewItem GetFirstChild( const wxDataViewItem &parent ) const = 0; | |
118 | virtual wxDataViewItem GetNextSibling( const wxDataViewItem &item ) const = 0; | |
119 | virtual wxDataViewItem GetNthChild( const wxDataViewItem &parent, unsigned int n ) const = 0; | |
120 | ||
121 | // delegated notifiers | |
122 | virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ); | |
123 | virtual bool ItemDeleted( const wxDataViewItem &item ); | |
124 | virtual bool ItemChanged( const wxDataViewItem &item ); | |
125 | virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col ); | |
126 | virtual bool Cleared(); | |
127 | ||
128 | void AddNotifier( wxDataViewModelNotifier *notifier ); | |
129 | void RemoveNotifier( wxDataViewModelNotifier *notifier ); | |
130 | ||
131 | void SetCompareFunction( wxDataViewModelCompare func ) { m_cmpFunc = func; } | |
132 | wxDataViewModelCompare GetCompareFunction() { return m_cmpFunc; } | |
133 | ||
134 | protected: | |
135 | // the user should not delete this class directly: he should use DecRef() instead! | |
136 | virtual ~wxDataViewModel() { } | |
137 | ||
138 | wxList m_notifiers; | |
139 | wxDataViewModelCompare m_cmpFunc; | |
140 | }; | |
141 | ||
142 | // --------------------------------------------------------- | |
143 | // wxDataViewModelNotifier | |
144 | // --------------------------------------------------------- | |
145 | ||
146 | class WXDLLIMPEXP_ADV wxDataViewModelNotifier: public wxObject | |
147 | { | |
148 | public: | |
149 | wxDataViewModelNotifier() { } | |
150 | virtual ~wxDataViewModelNotifier() { m_owner = NULL; } | |
151 | ||
152 | virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ) = 0; | |
153 | virtual bool ItemDeleted( const wxDataViewItem &item ) = 0; | |
154 | virtual bool ItemChanged( const wxDataViewItem &item ) = 0; | |
155 | virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col ) = 0; | |
156 | virtual bool Cleared() = 0; | |
157 | ||
158 | void SetOwner( wxDataViewModel *owner ) { m_owner = owner; } | |
159 | wxDataViewModel *GetOwner() { return m_owner; } | |
160 | ||
161 | private: | |
162 | wxDataViewModel *m_owner; | |
163 | }; | |
164 | ||
165 | ||
166 | //----------------------------------------------------------------------------- | |
167 | // wxDataViewEditorCtrlEvtHandler | |
168 | //----------------------------------------------------------------------------- | |
169 | ||
170 | class wxDataViewEditorCtrlEvtHandler: public wxEvtHandler | |
171 | { | |
172 | public: | |
173 | wxDataViewEditorCtrlEvtHandler( wxControl *editor, wxDataViewRenderer *owner ); | |
174 | ||
175 | void AcceptChangesAndFinish(); | |
176 | void SetFocusOnIdle( bool focus = true ) { m_focusOnIdle = focus; } | |
177 | ||
178 | protected: | |
179 | void OnChar( wxKeyEvent &event ); | |
180 | void OnKillFocus( wxFocusEvent &event ); | |
181 | void OnIdle( wxIdleEvent &event ); | |
182 | ||
183 | private: | |
184 | wxDataViewRenderer *m_owner; | |
185 | wxControl *m_editorCtrl; | |
186 | bool m_finished; | |
187 | bool m_focusOnIdle; | |
188 | ||
189 | private: | |
190 | DECLARE_EVENT_TABLE() | |
191 | }; | |
192 | ||
193 | // --------------------------------------------------------- | |
194 | // wxDataViewRendererBase | |
195 | // --------------------------------------------------------- | |
196 | ||
197 | enum wxDataViewCellMode | |
198 | { | |
199 | wxDATAVIEW_CELL_INERT, | |
200 | wxDATAVIEW_CELL_ACTIVATABLE, | |
201 | wxDATAVIEW_CELL_EDITABLE | |
202 | }; | |
203 | ||
204 | enum wxDataViewCellRenderState | |
205 | { | |
206 | wxDATAVIEW_CELL_SELECTED = 1, | |
207 | wxDATAVIEW_CELL_PRELIT = 2, | |
208 | wxDATAVIEW_CELL_INSENSITIVE = 4, | |
209 | wxDATAVIEW_CELL_FOCUSED = 8 | |
210 | }; | |
211 | ||
212 | class WXDLLIMPEXP_ADV wxDataViewRendererBase: public wxObject | |
213 | { | |
214 | public: | |
215 | wxDataViewRendererBase( const wxString &varianttype, | |
216 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
217 | int alignment = wxDVR_DEFAULT_ALIGNMENT ); | |
218 | ||
219 | virtual bool Validate( wxVariant& WXUNUSED(value) ) | |
220 | { return true; } | |
221 | ||
222 | void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; } | |
223 | wxDataViewColumn* GetOwner() { return m_owner; } | |
224 | ||
225 | // renderer properties: | |
226 | ||
227 | virtual bool SetValue( const wxVariant& WXUNUSED(value) ) = 0; | |
228 | virtual bool GetValue( wxVariant& WXUNUSED(value) ) const = 0; | |
229 | ||
230 | wxString GetVariantType() const { return m_variantType; } | |
231 | ||
232 | virtual void SetMode( wxDataViewCellMode mode ) = 0; | |
233 | virtual wxDataViewCellMode GetMode() const = 0; | |
234 | ||
235 | // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but | |
236 | // rather an "int"; that's because for rendering cells it's allowed | |
237 | // to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM) | |
238 | virtual void SetAlignment( int align ) = 0; | |
239 | virtual int GetAlignment() const = 0; | |
240 | ||
241 | // in-place editing | |
242 | virtual bool HasEditorCtrl() | |
243 | { return false; } | |
244 | virtual wxControl* CreateEditorCtrl(wxWindow * WXUNUSED(parent), | |
245 | wxRect WXUNUSED(labelRect), | |
246 | const wxVariant& WXUNUSED(value)) | |
247 | { return NULL; } | |
248 | virtual bool GetValueFromEditorCtrl(wxControl * WXUNUSED(editor), | |
249 | wxVariant& WXUNUSED(value)) | |
250 | { return false; } | |
251 | ||
252 | virtual bool StartEditing( const wxDataViewItem &item, wxRect labelRect ); | |
253 | virtual void CancelEditing(); | |
254 | virtual bool FinishEditing(); | |
255 | ||
256 | wxControl *GetEditorCtrl() { return m_editorCtrl; } | |
257 | ||
258 | protected: | |
259 | wxString m_variantType; | |
260 | wxDataViewColumn *m_owner; | |
261 | wxControl *m_editorCtrl; | |
262 | wxDataViewItem m_item; // for m_editorCtrl | |
263 | ||
264 | // internal utility: | |
265 | const wxDataViewCtrl* GetView() const; | |
266 | ||
267 | protected: | |
268 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase) | |
269 | }; | |
270 | ||
271 | // --------------------------------------------------------- | |
272 | // wxDataViewColumnBase | |
273 | // --------------------------------------------------------- | |
274 | ||
275 | enum wxDataViewColumnFlags | |
276 | { | |
277 | wxDATAVIEW_COL_RESIZABLE = 1, | |
278 | wxDATAVIEW_COL_SORTABLE = 2, | |
279 | wxDATAVIEW_COL_HIDDEN = 4 | |
280 | }; | |
281 | ||
282 | class WXDLLIMPEXP_ADV wxDataViewColumnBase: public wxObject | |
283 | { | |
284 | public: | |
285 | wxDataViewColumnBase( const wxString &title, wxDataViewRenderer *renderer, | |
286 | unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH, | |
287 | wxAlignment align = wxALIGN_CENTER, | |
288 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
289 | wxDataViewColumnBase( const wxBitmap &bitmap, wxDataViewRenderer *renderer, | |
290 | unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH, | |
291 | wxAlignment align = wxALIGN_CENTER, | |
292 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
293 | virtual ~wxDataViewColumnBase(); | |
294 | ||
295 | // setters: | |
296 | ||
297 | virtual void SetTitle( const wxString &title ) = 0; | |
298 | virtual void SetAlignment( wxAlignment align ) = 0; | |
299 | virtual void SetSortable( bool sortable ) = 0; | |
300 | virtual void SetResizeable( bool resizeable ) = 0; | |
301 | virtual void SetHidden( bool hidden ) = 0; | |
302 | virtual void SetSortOrder( bool ascending ) = 0; | |
303 | virtual void SetFlags( int flags ); | |
304 | virtual void SetOwner( wxDataViewCtrl *owner ) | |
305 | { m_owner = owner; } | |
306 | virtual void SetBitmap( const wxBitmap &bitmap ) | |
307 | { m_bitmap=bitmap; } | |
308 | ||
309 | virtual void SetMinWidth( int minWidth ) = 0; | |
310 | virtual void SetWidth( int width ) = 0; | |
311 | ||
312 | ||
313 | // getters: | |
314 | ||
315 | virtual wxString GetTitle() const = 0; | |
316 | virtual wxAlignment GetAlignment() const = 0; | |
317 | virtual int GetWidth() const = 0; | |
318 | virtual int GetMinWidth() const = 0; | |
319 | ||
320 | virtual int GetFlags() const; | |
321 | ||
322 | virtual bool IsSortable() const = 0; | |
323 | virtual bool IsResizeable() const = 0; | |
324 | virtual bool IsHidden() const = 0; | |
325 | virtual bool IsSortOrderAscending() const = 0; | |
326 | ||
327 | const wxBitmap &GetBitmap() const { return m_bitmap; } | |
328 | unsigned int GetModelColumn() const { return m_model_column; } | |
329 | ||
330 | wxDataViewCtrl *GetOwner() { return m_owner; } | |
331 | wxDataViewRenderer* GetRenderer() { return m_renderer; } | |
332 | ||
333 | protected: | |
334 | wxDataViewRenderer *m_renderer; | |
335 | int m_model_column; | |
336 | wxBitmap m_bitmap; | |
337 | wxDataViewCtrl *m_owner; | |
338 | ||
339 | protected: | |
340 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase) | |
341 | }; | |
342 | ||
343 | // --------------------------------------------------------- | |
344 | // wxDataViewCtrlBase | |
345 | // --------------------------------------------------------- | |
346 | ||
347 | #define wxDV_SINGLE 0x0000 // for convenience | |
348 | #define wxDV_MULTIPLE 0x0001 // can select multiple items | |
349 | ||
350 | #define wxDV_NO_HEADER 0x0002 // column titles not visible | |
351 | #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows | |
352 | #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns | |
353 | ||
354 | class WXDLLIMPEXP_ADV wxDataViewCtrlBase: public wxControl | |
355 | { | |
356 | public: | |
357 | wxDataViewCtrlBase(); | |
358 | virtual ~wxDataViewCtrlBase(); | |
359 | ||
360 | virtual bool AssociateModel( wxDataViewModel *model ); | |
361 | wxDataViewModel* GetModel(); | |
362 | ||
363 | // short cuts | |
364 | bool AppendTextColumn( const wxString &label, unsigned int model_column, | |
365 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
366 | wxAlignment align = wxALIGN_CENTER, | |
367 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
368 | bool AppendToggleColumn( const wxString &label, unsigned int model_column, | |
369 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, | |
370 | wxAlignment align = wxALIGN_CENTER, | |
371 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
372 | bool AppendProgressColumn( const wxString &label, unsigned int model_column, | |
373 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, | |
374 | wxAlignment align = wxALIGN_CENTER, | |
375 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
376 | bool AppendDateColumn( const wxString &label, unsigned int model_column, | |
377 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, | |
378 | wxAlignment align = wxALIGN_CENTER, | |
379 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
380 | bool AppendBitmapColumn( const wxString &label, unsigned int model_column, | |
381 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
382 | wxAlignment align = wxALIGN_CENTER, | |
383 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
384 | bool AppendTextColumn( const wxBitmap &label, unsigned int model_column, | |
385 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
386 | wxAlignment align = wxALIGN_CENTER, | |
387 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
388 | bool AppendToggleColumn( const wxBitmap &label, unsigned int model_column, | |
389 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, | |
390 | wxAlignment align = wxALIGN_CENTER, | |
391 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
392 | bool AppendProgressColumn( const wxBitmap &label, unsigned int model_column, | |
393 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, | |
394 | wxAlignment align = wxALIGN_CENTER, | |
395 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
396 | bool AppendDateColumn( const wxBitmap &label, unsigned int model_column, | |
397 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, | |
398 | wxAlignment align = wxALIGN_CENTER, | |
399 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
400 | bool AppendBitmapColumn( const wxBitmap &label, unsigned int model_column, | |
401 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
402 | wxAlignment align = wxALIGN_CENTER, | |
403 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
404 | ||
405 | virtual bool AppendColumn( wxDataViewColumn *col ); | |
406 | ||
407 | virtual unsigned int GetColumnCount() const; | |
408 | ||
409 | virtual bool DeleteColumn( unsigned int pos ); | |
410 | virtual bool ClearColumns(); | |
411 | virtual wxDataViewColumn* GetColumn( unsigned int pos ); | |
412 | ||
413 | // TODO selection code | |
414 | ||
415 | private: | |
416 | wxDataViewModel *m_model; | |
417 | wxList m_cols; | |
418 | wxDataViewEventModelNotifier *m_eventNotifier; | |
419 | ||
420 | protected: | |
421 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase) | |
422 | }; | |
423 | ||
424 | // ---------------------------------------------------------------------------- | |
425 | // wxDataViewEvent - the event class for the wxDataViewCtrl notifications | |
426 | // ---------------------------------------------------------------------------- | |
427 | ||
428 | class WXDLLIMPEXP_ADV wxDataViewEvent : public wxNotifyEvent | |
429 | { | |
430 | public: | |
431 | wxDataViewEvent(wxEventType commandType = wxEVT_NULL, int winid = 0) | |
432 | : wxNotifyEvent(commandType, winid), | |
433 | m_item(0), | |
434 | m_col(-1), | |
435 | m_model(NULL), | |
436 | m_value(wxNullVariant), | |
437 | m_column(NULL) | |
438 | { } | |
439 | ||
440 | wxDataViewEvent(const wxDataViewEvent& event) | |
441 | : wxNotifyEvent(event), | |
442 | m_item(event.m_item), | |
443 | m_col(event.m_col), | |
444 | m_model(event.m_model), | |
445 | m_value(event.m_value), | |
446 | m_column(event.m_column) | |
447 | { } | |
448 | ||
449 | wxDataViewItem GetItem() const { return m_item; } | |
450 | void SetItem( const wxDataViewItem &item ) { m_item = item; } | |
451 | ||
452 | int GetColumn() const { return m_col; } | |
453 | void SetColumn( int col ) { m_col = col; } | |
454 | ||
455 | wxDataViewModel* GetModel() const { return m_model; } | |
456 | void SetModel( wxDataViewModel *model ) { m_model = model; } | |
457 | ||
458 | const wxVariant &GetValue() const { return m_value; } | |
459 | void SetValue( const wxVariant &value ) { m_value = value; } | |
460 | ||
461 | // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only | |
462 | void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; } | |
463 | wxDataViewColumn *GetDataViewColumn() const { return m_column; } | |
464 | ||
465 | virtual wxEvent *Clone() const { return new wxDataViewEvent(*this); } | |
466 | ||
467 | protected: | |
468 | wxDataViewItem m_item; | |
469 | int m_col; | |
470 | wxDataViewModel *m_model; | |
471 | wxVariant m_value; | |
472 | wxDataViewColumn *m_column; | |
473 | ||
474 | private: | |
475 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent) | |
476 | }; | |
477 | ||
478 | BEGIN_DECLARE_EVENT_TYPES() | |
479 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_SELECTED, -1) | |
480 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, -1) | |
481 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, -1) | |
482 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, -1) | |
483 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, -1) | |
484 | // notifications from the model to the control | |
485 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_ADDED, -1) | |
486 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_DELETED, -1) | |
487 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_CHANGED, -1) | |
488 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_VALUE_CHANGED, -1) | |
489 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_CLEARED, -1) | |
490 | END_DECLARE_EVENT_TYPES() | |
491 | ||
492 | typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&); | |
493 | ||
494 | #define wxDataViewEventHandler(func) \ | |
495 | (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxDataViewEventFunction, &func) | |
496 | ||
497 | #define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \ | |
498 | wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn)) | |
499 | ||
500 | #define EVT_DATAVIEW_ITEM_SELECTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_SELECTED, id, fn) | |
501 | #define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn) | |
502 | #define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn) | |
503 | #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn) | |
504 | #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn) | |
505 | ||
506 | #define EVT_DATAVIEW_MODEL_ITEM_ADDED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_ITEM_APPENDED, id, fn) | |
507 | #define EVT_DATAVIEW_MODEL_ITEM_DELETED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_ITEM_DELETED, id, fn) | |
508 | #define EVT_DATAVIEW_MODEL_ITEM_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_ITEM_CHANGED, id, fn) | |
509 | #define EVT_DATAVIEW_MODEL_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_VALUE_CHANGED, id, fn) | |
510 | #define EVT_DATAVIEW_MODEL_CLEARED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_CLEARED, id, fn) | |
511 | ||
512 | ||
513 | #if defined(wxUSE_GENERICDATAVIEWCTRL) | |
514 | #include "wx/generic/dataview.h" | |
515 | #elif defined(__WXGTK20__) | |
516 | #include "wx/gtk/dataview.h" | |
517 | #elif defined(__WXMAC__) | |
518 | #include "wx/mac/dataview.h" | |
519 | #else | |
520 | #include "wx/generic/dataview.h" | |
521 | #endif | |
522 | ||
523 | #endif // wxUSE_DATAVIEWCTRL | |
524 | ||
525 | #endif | |
526 | // _WX_DATAVIEW_H_BASE_ |