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