]>
Commit | Line | Data |
---|---|---|
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 | ||
43 | class WXDLLIMPEXP_FWD_ADV wxDataViewItem; | |
44 | class WXDLLIMPEXP_FWD_ADV wxDataViewModel; | |
45 | class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl; | |
46 | class WXDLLIMPEXP_FWD_ADV wxDataViewColumn; | |
47 | class WXDLLIMPEXP_FWD_ADV wxDataViewRenderer; | |
48 | class WXDLLIMPEXP_FWD_ADV wxDataViewModelNotifier; | |
49 | ||
50 | extern 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_CENTRE_VERTICAL) | |
63 | ||
64 | ||
65 | // --------------------------------------------------------- | |
66 | // wxDataViewItem | |
67 | // --------------------------------------------------------- | |
68 | ||
69 | class WXDLLIMPEXP_ADV wxDataViewItem | |
70 | { | |
71 | public: | |
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 | ||
80 | #ifdef __WXDEBUG__ | |
81 | void Print( const wxString &text ) const { wxPrintf( "item %s: %d\n", text, (int) m_id ); } | |
82 | #endif | |
83 | ||
84 | private: | |
85 | void* m_id; | |
86 | }; | |
87 | ||
88 | bool operator == (const wxDataViewItem &left, const wxDataViewItem &right); | |
89 | ||
90 | WX_DEFINE_ARRAY(wxDataViewItem, wxDataViewItemArray); | |
91 | ||
92 | // --------------------------------------------------------- | |
93 | // wxDataViewModelNotifier | |
94 | // --------------------------------------------------------- | |
95 | ||
96 | class WXDLLIMPEXP_ADV wxDataViewModelNotifier | |
97 | { | |
98 | public: | |
99 | wxDataViewModelNotifier() { } | |
100 | virtual ~wxDataViewModelNotifier() { m_owner = NULL; } | |
101 | ||
102 | virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ) = 0; | |
103 | virtual bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item ) = 0; | |
104 | virtual bool ItemChanged( const wxDataViewItem &item ) = 0; | |
105 | virtual bool ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items ); | |
106 | virtual bool ItemsDeleted( const wxDataViewItem &parent, const wxDataViewItemArray &items ); | |
107 | virtual bool ItemsChanged( const wxDataViewItemArray &items ); | |
108 | virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col ) = 0; | |
109 | virtual bool Cleared() = 0; | |
110 | ||
111 | virtual void Resort() = 0; | |
112 | ||
113 | void SetOwner( wxDataViewModel *owner ) { m_owner = owner; } | |
114 | wxDataViewModel *GetOwner() { return m_owner; } | |
115 | ||
116 | private: | |
117 | wxDataViewModel *m_owner; | |
118 | }; | |
119 | ||
120 | ||
121 | // --------------------------------------------------------- | |
122 | // wxDataViewModel | |
123 | // --------------------------------------------------------- | |
124 | ||
125 | WX_DECLARE_LIST_WITH_DECL(wxDataViewModelNotifier, wxDataViewModelNotifiers, | |
126 | class WXDLLIMPEXP_ADV); | |
127 | ||
128 | class WXDLLIMPEXP_ADV wxDataViewModel: public wxObjectRefData | |
129 | { | |
130 | public: | |
131 | wxDataViewModel(); | |
132 | ||
133 | virtual unsigned int GetColumnCount() const = 0; | |
134 | ||
135 | // return type as reported by wxVariant | |
136 | virtual wxString GetColumnType( unsigned int col ) const = 0; | |
137 | ||
138 | // get value into a wxVariant | |
139 | virtual void GetValue( wxVariant &variant, | |
140 | const wxDataViewItem &item, unsigned int col ) const = 0; | |
141 | ||
142 | // set value, call ValueChanged() afterwards! | |
143 | virtual bool SetValue( const wxVariant &variant, | |
144 | const wxDataViewItem &item, unsigned int col ) = 0; | |
145 | ||
146 | // define hierachy | |
147 | virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const = 0; | |
148 | virtual bool IsContainer( const wxDataViewItem &item ) const = 0; | |
149 | // Is the container just a header or an item with all columns | |
150 | virtual bool HasContainerColumns(const wxDataViewItem& WXUNUSED(item)) const | |
151 | { return false; } | |
152 | virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const = 0; | |
153 | ||
154 | // delegated notifiers | |
155 | virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ); | |
156 | virtual bool ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items ); | |
157 | virtual bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item ); | |
158 | virtual bool ItemsDeleted( const wxDataViewItem &parent, const wxDataViewItemArray &items ); | |
159 | virtual bool ItemChanged( const wxDataViewItem &item ); | |
160 | virtual bool ItemsChanged( const wxDataViewItemArray &items ); | |
161 | virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col ); | |
162 | virtual bool Cleared(); | |
163 | ||
164 | // delegatd action | |
165 | virtual void Resort(); | |
166 | ||
167 | void AddNotifier( wxDataViewModelNotifier *notifier ); | |
168 | void RemoveNotifier( wxDataViewModelNotifier *notifier ); | |
169 | ||
170 | // default compare function | |
171 | virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, | |
172 | unsigned int column, bool ascending ); | |
173 | virtual bool HasDefaultCompare() const { return false; } | |
174 | ||
175 | protected: | |
176 | // the user should not delete this class directly: he should use DecRef() instead! | |
177 | virtual ~wxDataViewModel() { } | |
178 | ||
179 | wxDataViewModelNotifiers m_notifiers; | |
180 | }; | |
181 | ||
182 | // --------------------------------------------------------- | |
183 | // wxDataViewIndexListModel | |
184 | // --------------------------------------------------------- | |
185 | ||
186 | class WXDLLIMPEXP_ADV wxDataViewIndexListModel: public wxDataViewModel | |
187 | { | |
188 | public: | |
189 | wxDataViewIndexListModel( unsigned int initial_size = 0 ); | |
190 | ~wxDataViewIndexListModel(); | |
191 | ||
192 | virtual unsigned int GetRowCount() = 0; | |
193 | ||
194 | virtual void GetValue( wxVariant &variant, | |
195 | unsigned int row, unsigned int col ) const = 0; | |
196 | ||
197 | virtual bool SetValue( const wxVariant &variant, | |
198 | unsigned int row, unsigned int col ) = 0; | |
199 | ||
200 | void RowPrepended(); | |
201 | void RowInserted( unsigned int before ); | |
202 | void RowAppended(); | |
203 | void RowDeleted( unsigned int row ); | |
204 | void RowChanged( unsigned int row ); | |
205 | void RowValueChanged( unsigned int row, unsigned int col ); | |
206 | ||
207 | // convert to/from row/wxDataViewItem | |
208 | ||
209 | unsigned int GetRow( const wxDataViewItem &item ) const; | |
210 | wxDataViewItem GetItem( unsigned int row ) const; | |
211 | ||
212 | // compare based on index | |
213 | ||
214 | virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, | |
215 | unsigned int column, bool ascending ); | |
216 | virtual bool HasDefaultCompare() const { return true; } | |
217 | ||
218 | // implement base methods | |
219 | ||
220 | virtual void GetValue( wxVariant &variant, | |
221 | const wxDataViewItem &item, unsigned int col ) const; | |
222 | virtual bool SetValue( const wxVariant &variant, | |
223 | const wxDataViewItem &item, unsigned int col ); | |
224 | virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const; | |
225 | virtual bool IsContainer( const wxDataViewItem &item ) const; | |
226 | virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const; | |
227 | ||
228 | private: | |
229 | wxDataViewItemArray m_hash; | |
230 | unsigned int m_lastIndex; | |
231 | }; | |
232 | ||
233 | ||
234 | //----------------------------------------------------------------------------- | |
235 | // wxDataViewEditorCtrlEvtHandler | |
236 | //----------------------------------------------------------------------------- | |
237 | ||
238 | class wxDataViewEditorCtrlEvtHandler: public wxEvtHandler | |
239 | { | |
240 | public: | |
241 | wxDataViewEditorCtrlEvtHandler( wxControl *editor, wxDataViewRenderer *owner ); | |
242 | ||
243 | void AcceptChangesAndFinish(); | |
244 | void SetFocusOnIdle( bool focus = true ) { m_focusOnIdle = focus; } | |
245 | ||
246 | protected: | |
247 | void OnChar( wxKeyEvent &event ); | |
248 | void OnKillFocus( wxFocusEvent &event ); | |
249 | void OnIdle( wxIdleEvent &event ); | |
250 | ||
251 | private: | |
252 | wxDataViewRenderer *m_owner; | |
253 | wxControl *m_editorCtrl; | |
254 | bool m_finished; | |
255 | bool m_focusOnIdle; | |
256 | ||
257 | private: | |
258 | DECLARE_EVENT_TABLE() | |
259 | }; | |
260 | ||
261 | // --------------------------------------------------------- | |
262 | // wxDataViewRendererBase | |
263 | // --------------------------------------------------------- | |
264 | ||
265 | enum wxDataViewCellMode | |
266 | { | |
267 | wxDATAVIEW_CELL_INERT, | |
268 | wxDATAVIEW_CELL_ACTIVATABLE, | |
269 | wxDATAVIEW_CELL_EDITABLE | |
270 | }; | |
271 | ||
272 | enum wxDataViewCellRenderState | |
273 | { | |
274 | wxDATAVIEW_CELL_SELECTED = 1, | |
275 | wxDATAVIEW_CELL_PRELIT = 2, | |
276 | wxDATAVIEW_CELL_INSENSITIVE = 4, | |
277 | wxDATAVIEW_CELL_FOCUSED = 8 | |
278 | }; | |
279 | ||
280 | class WXDLLIMPEXP_ADV wxDataViewRendererBase: public wxObject | |
281 | { | |
282 | public: | |
283 | wxDataViewRendererBase( const wxString &varianttype, | |
284 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
285 | int alignment = wxDVR_DEFAULT_ALIGNMENT ); | |
286 | ||
287 | virtual bool Validate( wxVariant& WXUNUSED(value) ) | |
288 | { return true; } | |
289 | ||
290 | void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; } | |
291 | wxDataViewColumn* GetOwner() { return m_owner; } | |
292 | ||
293 | // renderer properties: | |
294 | ||
295 | virtual bool SetValue( const wxVariant& WXUNUSED(value) ) = 0; | |
296 | virtual bool GetValue( wxVariant& WXUNUSED(value) ) const = 0; | |
297 | ||
298 | wxString GetVariantType() const { return m_variantType; } | |
299 | ||
300 | virtual void SetMode( wxDataViewCellMode mode ) = 0; | |
301 | virtual wxDataViewCellMode GetMode() const = 0; | |
302 | ||
303 | // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but | |
304 | // rather an "int"; that's because for rendering cells it's allowed | |
305 | // to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM) | |
306 | virtual void SetAlignment( int align ) = 0; | |
307 | virtual int GetAlignment() const = 0; | |
308 | ||
309 | // in-place editing | |
310 | virtual bool HasEditorCtrl() | |
311 | { return false; } | |
312 | virtual wxControl* CreateEditorCtrl(wxWindow * WXUNUSED(parent), | |
313 | wxRect WXUNUSED(labelRect), | |
314 | const wxVariant& WXUNUSED(value)) | |
315 | { return NULL; } | |
316 | virtual bool GetValueFromEditorCtrl(wxControl * WXUNUSED(editor), | |
317 | wxVariant& WXUNUSED(value)) | |
318 | { return false; } | |
319 | ||
320 | virtual bool StartEditing( const wxDataViewItem &item, wxRect labelRect ); | |
321 | virtual void CancelEditing(); | |
322 | virtual bool FinishEditing(); | |
323 | ||
324 | wxControl *GetEditorCtrl() { return m_editorCtrl; } | |
325 | ||
326 | protected: | |
327 | wxString m_variantType; | |
328 | wxDataViewColumn *m_owner; | |
329 | wxControl *m_editorCtrl; | |
330 | wxDataViewItem m_item; // for m_editorCtrl | |
331 | ||
332 | // internal utility: | |
333 | const wxDataViewCtrl* GetView() const; | |
334 | ||
335 | protected: | |
336 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase) | |
337 | }; | |
338 | ||
339 | //----------------------------------------------------------------------------- | |
340 | // wxDataViewIconText | |
341 | //----------------------------------------------------------------------------- | |
342 | ||
343 | class WXDLLIMPEXP_ADV wxDataViewIconText: public wxObject | |
344 | { | |
345 | public: | |
346 | wxDataViewIconText( const wxString &text = wxEmptyString, const wxIcon& icon = wxNullIcon ) | |
347 | { m_icon = icon; m_text = text; } | |
348 | wxDataViewIconText( const wxDataViewIconText &other ) | |
349 | { m_icon = other.m_icon; m_text = other.m_text; } | |
350 | ||
351 | void SetText( const wxString &text ) { m_text = text; } | |
352 | wxString GetText() const { return m_text; } | |
353 | void SetIcon( const wxIcon &icon ) { m_icon = icon; } | |
354 | const wxIcon &GetIcon() const { return m_icon; } | |
355 | ||
356 | private: | |
357 | wxString m_text; | |
358 | wxIcon m_icon; | |
359 | ||
360 | private: | |
361 | DECLARE_DYNAMIC_CLASS(wxDataViewIconText) | |
362 | }; | |
363 | ||
364 | bool operator == (const wxDataViewIconText &one, const wxDataViewIconText &two); | |
365 | ||
366 | DECLARE_VARIANT_OBJECT_EXPORTED(wxDataViewIconText, WXDLLIMPEXP_ADV) | |
367 | ||
368 | // --------------------------------------------------------- | |
369 | // wxDataViewColumnBase | |
370 | // --------------------------------------------------------- | |
371 | ||
372 | enum wxDataViewColumnFlags | |
373 | { | |
374 | wxDATAVIEW_COL_RESIZABLE = 1, | |
375 | wxDATAVIEW_COL_SORTABLE = 2, | |
376 | wxDATAVIEW_COL_HIDDEN = 4 | |
377 | }; | |
378 | ||
379 | class WXDLLIMPEXP_ADV wxDataViewColumnBase: public wxObject | |
380 | { | |
381 | public: | |
382 | wxDataViewColumnBase( const wxString &title, wxDataViewRenderer *renderer, | |
383 | unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH, | |
384 | wxAlignment align = wxALIGN_CENTER, | |
385 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
386 | wxDataViewColumnBase( const wxBitmap &bitmap, wxDataViewRenderer *renderer, | |
387 | unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH, | |
388 | wxAlignment align = wxALIGN_CENTER, | |
389 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
390 | virtual ~wxDataViewColumnBase(); | |
391 | ||
392 | // setters: | |
393 | ||
394 | virtual void SetTitle( const wxString &title ) = 0; | |
395 | virtual void SetAlignment( wxAlignment align ) = 0; | |
396 | virtual void SetSortable( bool sortable ) = 0; | |
397 | virtual void SetResizeable( bool resizeable ) = 0; | |
398 | virtual void SetHidden( bool hidden ) = 0; | |
399 | virtual void SetSortOrder( bool ascending ) = 0; | |
400 | virtual void SetFlags( int flags ); | |
401 | virtual void SetOwner( wxDataViewCtrl *owner ) | |
402 | { m_owner = owner; } | |
403 | virtual void SetBitmap( const wxBitmap &bitmap ) | |
404 | { m_bitmap=bitmap; } | |
405 | ||
406 | virtual void SetMinWidth( int minWidth ) = 0; | |
407 | virtual void SetWidth( int width ) = 0; | |
408 | ||
409 | ||
410 | // getters: | |
411 | ||
412 | virtual wxString GetTitle() const = 0; | |
413 | virtual wxAlignment GetAlignment() const = 0; | |
414 | virtual int GetWidth() const = 0; | |
415 | virtual int GetMinWidth() const = 0; | |
416 | ||
417 | virtual int GetFlags() const; | |
418 | ||
419 | virtual bool IsSortable() const = 0; | |
420 | virtual bool IsResizeable() const = 0; | |
421 | virtual bool IsHidden() const = 0; | |
422 | virtual bool IsSortOrderAscending() const = 0; | |
423 | ||
424 | const wxBitmap &GetBitmap() const { return m_bitmap; } | |
425 | unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column); } | |
426 | ||
427 | wxDataViewCtrl *GetOwner() { return m_owner; } | |
428 | wxDataViewRenderer* GetRenderer() { return m_renderer; } | |
429 | ||
430 | protected: | |
431 | wxDataViewRenderer *m_renderer; | |
432 | int m_model_column; | |
433 | wxBitmap m_bitmap; | |
434 | wxDataViewCtrl *m_owner; | |
435 | ||
436 | protected: | |
437 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase) | |
438 | }; | |
439 | ||
440 | // --------------------------------------------------------- | |
441 | // wxDataViewCtrlBase | |
442 | // --------------------------------------------------------- | |
443 | ||
444 | #define wxDV_SINGLE 0x0000 // for convenience | |
445 | #define wxDV_MULTIPLE 0x0001 // can select multiple items | |
446 | ||
447 | #define wxDV_NO_HEADER 0x0002 // column titles not visible | |
448 | #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows | |
449 | #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns | |
450 | ||
451 | class WXDLLIMPEXP_ADV wxDataViewCtrlBase: public wxControl | |
452 | { | |
453 | public: | |
454 | wxDataViewCtrlBase(); | |
455 | virtual ~wxDataViewCtrlBase(); | |
456 | ||
457 | virtual bool AssociateModel( wxDataViewModel *model ); | |
458 | wxDataViewModel* GetModel(); | |
459 | ||
460 | // short cuts | |
461 | wxDataViewColumn *PrependTextColumn( const wxString &label, unsigned int model_column, | |
462 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
463 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), | |
464 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
465 | wxDataViewColumn *PrependIconTextColumn( const wxString &label, unsigned int model_column, | |
466 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
467 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), | |
468 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
469 | wxDataViewColumn *PrependToggleColumn( const wxString &label, unsigned int model_column, | |
470 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, | |
471 | wxAlignment align = wxALIGN_CENTER, | |
472 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
473 | wxDataViewColumn *PrependProgressColumn( const wxString &label, unsigned int model_column, | |
474 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, | |
475 | wxAlignment align = wxALIGN_CENTER, | |
476 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
477 | wxDataViewColumn *PrependDateColumn( const wxString &label, unsigned int model_column, | |
478 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, | |
479 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), | |
480 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
481 | wxDataViewColumn *PrependBitmapColumn( const wxString &label, unsigned int model_column, | |
482 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
483 | wxAlignment align = wxALIGN_CENTER, | |
484 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
485 | wxDataViewColumn *PrependTextColumn( const wxBitmap &label, unsigned int model_column, | |
486 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
487 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), | |
488 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
489 | wxDataViewColumn *PrependIconTextColumn( const wxBitmap &label, unsigned int model_column, | |
490 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
491 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), | |
492 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
493 | wxDataViewColumn *PrependToggleColumn( const wxBitmap &label, unsigned int model_column, | |
494 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, | |
495 | wxAlignment align = wxALIGN_CENTER, | |
496 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
497 | wxDataViewColumn *PrependProgressColumn( const wxBitmap &label, unsigned int model_column, | |
498 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, | |
499 | wxAlignment align = wxALIGN_CENTER, | |
500 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
501 | wxDataViewColumn *PrependDateColumn( const wxBitmap &label, unsigned int model_column, | |
502 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, | |
503 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), | |
504 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
505 | wxDataViewColumn *PrependBitmapColumn( const wxBitmap &label, unsigned int model_column, | |
506 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
507 | wxAlignment align = wxALIGN_CENTER, | |
508 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
509 | ||
510 | wxDataViewColumn *AppendTextColumn( const wxString &label, unsigned int model_column, | |
511 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
512 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), | |
513 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
514 | wxDataViewColumn *AppendIconTextColumn( const wxString &label, unsigned int model_column, | |
515 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
516 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), | |
517 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
518 | wxDataViewColumn *AppendToggleColumn( const wxString &label, unsigned int model_column, | |
519 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, | |
520 | wxAlignment align = wxALIGN_CENTER, | |
521 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
522 | wxDataViewColumn *AppendProgressColumn( const wxString &label, unsigned int model_column, | |
523 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, | |
524 | wxAlignment align = wxALIGN_CENTER, | |
525 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
526 | wxDataViewColumn *AppendDateColumn( const wxString &label, unsigned int model_column, | |
527 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, | |
528 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), | |
529 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
530 | wxDataViewColumn *AppendBitmapColumn( const wxString &label, unsigned int model_column, | |
531 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
532 | wxAlignment align = wxALIGN_CENTER, | |
533 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
534 | wxDataViewColumn *AppendTextColumn( const wxBitmap &label, unsigned int model_column, | |
535 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
536 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), | |
537 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
538 | wxDataViewColumn *AppendIconTextColumn( const wxBitmap &label, unsigned int model_column, | |
539 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
540 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), | |
541 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
542 | wxDataViewColumn *AppendToggleColumn( const wxBitmap &label, unsigned int model_column, | |
543 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, | |
544 | wxAlignment align = wxALIGN_CENTER, | |
545 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
546 | wxDataViewColumn *AppendProgressColumn( const wxBitmap &label, unsigned int model_column, | |
547 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, | |
548 | wxAlignment align = wxALIGN_CENTER, | |
549 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
550 | wxDataViewColumn *AppendDateColumn( const wxBitmap &label, unsigned int model_column, | |
551 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, | |
552 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), | |
553 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
554 | wxDataViewColumn *AppendBitmapColumn( const wxBitmap &label, unsigned int model_column, | |
555 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
556 | wxAlignment align = wxALIGN_CENTER, | |
557 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
558 | ||
559 | ||
560 | virtual bool PrependColumn( wxDataViewColumn *col ); | |
561 | virtual bool AppendColumn( wxDataViewColumn *col ); | |
562 | ||
563 | virtual unsigned int GetColumnCount() const = 0; | |
564 | virtual wxDataViewColumn* GetColumn( unsigned int pos ) const = 0; | |
565 | virtual int GetColumnPosition( const wxDataViewColumn *column ) const = 0; | |
566 | ||
567 | virtual bool DeleteColumn( wxDataViewColumn *column ) = 0; | |
568 | virtual bool ClearColumns() = 0; | |
569 | ||
570 | void SetExpanderColumn( wxDataViewColumn *col ) | |
571 | { m_expander_column = col ; DoSetExpanderColumn(); } | |
572 | wxDataViewColumn *GetExpanderColumn() const | |
573 | { return m_expander_column; } | |
574 | ||
575 | virtual wxDataViewColumn *GetSortingColumn() const = 0; | |
576 | ||
577 | void SetIndent( int indent ) | |
578 | { m_indent = indent ; DoSetIndent(); } | |
579 | int GetIndent() const | |
580 | { return m_indent; } | |
581 | ||
582 | virtual wxDataViewItem GetSelection() const = 0; | |
583 | virtual int GetSelections( wxDataViewItemArray & sel ) const = 0; | |
584 | virtual void SetSelections( const wxDataViewItemArray & sel ) = 0; | |
585 | virtual void Select( const wxDataViewItem & item ) = 0; | |
586 | virtual void Unselect( const wxDataViewItem & item ) = 0; | |
587 | virtual bool IsSelected( const wxDataViewItem & item ) const = 0; | |
588 | ||
589 | virtual void SelectAll() = 0; | |
590 | virtual void UnselectAll() = 0; | |
591 | ||
592 | virtual void Expand( const wxDataViewItem & item ) = 0; | |
593 | virtual void Collapse( const wxDataViewItem & item ) = 0; | |
594 | ||
595 | virtual void EnsureVisible( const wxDataViewItem & item, | |
596 | const wxDataViewColumn *column = NULL ) = 0; | |
597 | virtual void HitTest( const wxPoint & point, wxDataViewItem &item, wxDataViewColumn* &column ) const = 0; | |
598 | virtual wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ) const = 0; | |
599 | ||
600 | protected: | |
601 | virtual void DoSetExpanderColumn() = 0 ; | |
602 | virtual void DoSetIndent() = 0; | |
603 | ||
604 | private: | |
605 | wxDataViewModel *m_model; | |
606 | wxDataViewColumn *m_expander_column; | |
607 | int m_indent ; | |
608 | ||
609 | protected: | |
610 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase) | |
611 | }; | |
612 | ||
613 | // ---------------------------------------------------------------------------- | |
614 | // wxDataViewEvent - the event class for the wxDataViewCtrl notifications | |
615 | // ---------------------------------------------------------------------------- | |
616 | ||
617 | class WXDLLIMPEXP_ADV wxDataViewEvent : public wxNotifyEvent | |
618 | { | |
619 | public: | |
620 | wxDataViewEvent(wxEventType commandType = wxEVT_NULL, int winid = 0) | |
621 | : wxNotifyEvent(commandType, winid), | |
622 | m_item(0), | |
623 | m_col(-1), | |
624 | m_model(NULL), | |
625 | m_value(wxNullVariant), | |
626 | m_column(NULL) | |
627 | { } | |
628 | ||
629 | wxDataViewEvent(const wxDataViewEvent& event) | |
630 | : wxNotifyEvent(event), | |
631 | m_item(event.m_item), | |
632 | m_col(event.m_col), | |
633 | m_model(event.m_model), | |
634 | m_value(event.m_value), | |
635 | m_column(event.m_column) | |
636 | { } | |
637 | ||
638 | wxDataViewItem GetItem() const { return m_item; } | |
639 | void SetItem( const wxDataViewItem &item ) { m_item = item; } | |
640 | ||
641 | int GetColumn() const { return m_col; } | |
642 | void SetColumn( int col ) { m_col = col; } | |
643 | ||
644 | wxDataViewModel* GetModel() const { return m_model; } | |
645 | void SetModel( wxDataViewModel *model ) { m_model = model; } | |
646 | ||
647 | const wxVariant &GetValue() const { return m_value; } | |
648 | void SetValue( const wxVariant &value ) { m_value = value; } | |
649 | ||
650 | // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only | |
651 | void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; } | |
652 | wxDataViewColumn *GetDataViewColumn() const { return m_column; } | |
653 | ||
654 | virtual wxEvent *Clone() const { return new wxDataViewEvent(*this); } | |
655 | ||
656 | protected: | |
657 | wxDataViewItem m_item; | |
658 | int m_col; | |
659 | wxDataViewModel *m_model; | |
660 | wxVariant m_value; | |
661 | wxDataViewColumn *m_column; | |
662 | ||
663 | private: | |
664 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent) | |
665 | }; | |
666 | ||
667 | BEGIN_DECLARE_EVENT_TYPES() | |
668 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, -1) | |
669 | ||
670 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, -1) | |
671 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED, -1) | |
672 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED, -1) | |
673 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING, -1) | |
674 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING, -1) | |
675 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED, -1) | |
676 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, -1) | |
677 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, -1) | |
678 | ||
679 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, -1) | |
680 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, -1) | |
681 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, -1) | |
682 | END_DECLARE_EVENT_TYPES() | |
683 | ||
684 | typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&); | |
685 | ||
686 | #define wxDataViewEventHandler(func) \ | |
687 | (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxDataViewEventFunction, &func) | |
688 | ||
689 | #define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \ | |
690 | wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn)) | |
691 | ||
692 | #define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn) | |
693 | ||
694 | #define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn) | |
695 | #define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn) | |
696 | #define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn) | |
697 | #define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn) | |
698 | #define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn) | |
699 | #define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn) | |
700 | #define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn) | |
701 | #define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn) | |
702 | ||
703 | #define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn) | |
704 | #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn) | |
705 | #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn) | |
706 | ||
707 | #if defined(wxUSE_GENERICDATAVIEWCTRL) | |
708 | #include "wx/generic/dataview.h" | |
709 | #elif defined(__WXGTK20__) | |
710 | #include "wx/gtk/dataview.h" | |
711 | #elif defined(__WXMAC__) | |
712 | #include "wx/mac/dataview.h" | |
713 | #else | |
714 | #include "wx/generic/dataview.h" | |
715 | #endif | |
716 | ||
717 | // ------------------------------------- | |
718 | // wxDataViewSpinRenderer | |
719 | // ------------------------------------- | |
720 | ||
721 | class wxDataViewSpinRenderer: public wxDataViewCustomRenderer | |
722 | { | |
723 | public: | |
724 | wxDataViewSpinRenderer( int min, int max, | |
725 | wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE, | |
726 | int alignment = wxDVR_DEFAULT_ALIGNMENT ); | |
727 | virtual bool HasEditorCtrl() { return true; } | |
728 | virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value ); | |
729 | virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value ); | |
730 | virtual bool Render( wxRect rect, wxDC *dc, int state ); | |
731 | virtual wxSize GetSize() const; | |
732 | virtual bool SetValue( const wxVariant &value ); | |
733 | virtual bool GetValue( wxVariant &value ) const; | |
734 | ||
735 | private: | |
736 | long m_data; | |
737 | long m_min,m_max; | |
738 | }; | |
739 | ||
740 | //----------------------------------------------------------------------------- | |
741 | // wxDataViewTreeStore | |
742 | //----------------------------------------------------------------------------- | |
743 | ||
744 | class WXDLLIMPEXP_ADV wxDataViewTreeStoreNode | |
745 | { | |
746 | public: | |
747 | wxDataViewTreeStoreNode( wxDataViewTreeStoreNode *parent, | |
748 | const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); | |
749 | virtual ~wxDataViewTreeStoreNode(); | |
750 | ||
751 | void SetText( const wxString &text ) | |
752 | { m_text = text; } | |
753 | wxString GetText() const | |
754 | { return m_text; } | |
755 | void SetIcon( const wxIcon &icon ) | |
756 | { m_icon = icon; } | |
757 | const wxIcon &GetIcon() const | |
758 | { return m_icon; } | |
759 | void SetData( wxClientData *data ) | |
760 | { if (m_data) delete m_data; m_data = data; } | |
761 | wxClientData *GetData() const | |
762 | { return m_data; } | |
763 | ||
764 | wxDataViewItem GetItem() const | |
765 | { return wxDataViewItem( (void*) this ); } | |
766 | ||
767 | virtual bool IsContainer() | |
768 | { return false; } | |
769 | ||
770 | wxDataViewTreeStoreNode *GetParent() | |
771 | { return m_parent; } | |
772 | ||
773 | private: | |
774 | wxDataViewTreeStoreNode *m_parent; | |
775 | wxString m_text; | |
776 | wxIcon m_icon; | |
777 | wxClientData *m_data; | |
778 | }; | |
779 | ||
780 | WX_DECLARE_LIST_WITH_DECL(wxDataViewTreeStoreNode, wxDataViewTreeStoreNodeList, | |
781 | class WXDLLIMPEXP_ADV); | |
782 | ||
783 | class WXDLLIMPEXP_ADV wxDataViewTreeStoreContainerNode: public wxDataViewTreeStoreNode | |
784 | { | |
785 | public: | |
786 | wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode *parent, | |
787 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, | |
788 | wxClientData *data = NULL ); | |
789 | virtual ~wxDataViewTreeStoreContainerNode(); | |
790 | ||
791 | const wxDataViewTreeStoreNodeList &GetChildren() const | |
792 | { return m_children; } | |
793 | wxDataViewTreeStoreNodeList &GetChildren() | |
794 | { return m_children; } | |
795 | ||
796 | void SetExpandedIcon( const wxIcon &icon ) | |
797 | { m_iconExpanded = icon; } | |
798 | const wxIcon &GetExpandedIcon() const | |
799 | { return m_iconExpanded; } | |
800 | ||
801 | virtual bool IsContainer() | |
802 | { return true; } | |
803 | ||
804 | private: | |
805 | wxDataViewTreeStoreNodeList m_children; | |
806 | wxIcon m_iconExpanded; | |
807 | }; | |
808 | ||
809 | //----------------------------------------------------------------------------- | |
810 | ||
811 | class WXDLLIMPEXP_ADV wxDataViewTreeStore: public wxDataViewModel | |
812 | { | |
813 | public: | |
814 | wxDataViewTreeStore(); | |
815 | ~wxDataViewTreeStore(); | |
816 | ||
817 | wxDataViewItem AppendItem( const wxDataViewItem& parent, | |
818 | const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); | |
819 | wxDataViewItem PrependItem( const wxDataViewItem& parent, | |
820 | const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); | |
821 | wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous, | |
822 | const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); | |
823 | ||
824 | wxDataViewItem PrependContainer( const wxDataViewItem& parent, | |
825 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, | |
826 | wxClientData *data = NULL ); | |
827 | wxDataViewItem AppendContainer( const wxDataViewItem& parent, | |
828 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, | |
829 | wxClientData *data = NULL ); | |
830 | wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous, | |
831 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, | |
832 | wxClientData *data = NULL ); | |
833 | ||
834 | wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const; | |
835 | int GetChildCount( const wxDataViewItem& parent ) const; | |
836 | ||
837 | void SetItemText( const wxDataViewItem& item, const wxString &text ); | |
838 | wxString GetItemText( const wxDataViewItem& item ) const; | |
839 | void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon ); | |
840 | const wxIcon &GetItemIcon( const wxDataViewItem& item ) const; | |
841 | void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon ); | |
842 | const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const; | |
843 | void SetItemData( const wxDataViewItem& item, wxClientData *data ); | |
844 | wxClientData *GetItemData( const wxDataViewItem& item ) const; | |
845 | ||
846 | void DeleteItem( const wxDataViewItem& item ); | |
847 | void DeleteChildren( const wxDataViewItem& item ); | |
848 | void DeleteAllItems(); | |
849 | ||
850 | // implement base methods | |
851 | ||
852 | virtual void GetValue( wxVariant &variant, | |
853 | const wxDataViewItem &item, unsigned int col ) const; | |
854 | virtual bool SetValue( const wxVariant &variant, | |
855 | const wxDataViewItem &item, unsigned int col ); | |
856 | virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const; | |
857 | virtual bool IsContainer( const wxDataViewItem &item ) const; | |
858 | virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const; | |
859 | ||
860 | virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, | |
861 | unsigned int column, bool ascending ); | |
862 | ||
863 | virtual bool HasDefaultCompare() const | |
864 | { return true; } | |
865 | virtual unsigned int GetColumnCount() const | |
866 | { return 1; }; | |
867 | virtual wxString GetColumnType( unsigned int WXUNUSED(col) ) const | |
868 | { return "wxDataViewIconText"; } | |
869 | ||
870 | wxDataViewTreeStoreNode *FindNode( const wxDataViewItem &item ) const; | |
871 | wxDataViewTreeStoreContainerNode *FindContainerNode( const wxDataViewItem &item ) const; | |
872 | wxDataViewTreeStoreNode *GetRoot() const { return m_root; } | |
873 | ||
874 | public: | |
875 | wxDataViewTreeStoreNode *m_root; | |
876 | }; | |
877 | ||
878 | #if 0 | |
879 | class WXDLLIMPEXP_ADV wxDataViewTreeCtrl: public wxDataViewCtrl | |
880 | { | |
881 | public: | |
882 | wxDataViewCtrl( wxWindow *parent, wxWindowID id, | |
883 | const wxPoint& pos = wxDefaultPosition, | |
884 | const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER, | |
885 | const wxValidator& validator = wxDefaultValidator ); | |
886 | ||
887 | bool Create( wxWindow *parent, wxWindowID id, | |
888 | const wxPoint& pos = wxDefaultPosition, | |
889 | const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER, | |
890 | const wxValidator& validator = wxDefaultValidator ); | |
891 | ||
892 | wxDataViewTreeStore *GetStore() | |
893 | { return (wxDataViewTreeStore*) GetModel(); } | |
894 | ||
895 | void OnExpand( wxDataViewCtrl &event ); | |
896 | void OnCollapse( wxDataViewCtrl &event ); | |
897 | ||
898 | private: | |
899 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl) | |
900 | }; | |
901 | #endif | |
902 | ||
903 | #endif // wxUSE_DATAVIEWCTRL | |
904 | ||
905 | #endif | |
906 | // _WX_DATAVIEW_H_BASE_ |