]>
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: | |
b5ec7dd6 | 72 | wxDataViewItem( void* id = NULL ) |
9d52aad3 | 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; } |
b5ec7dd6 | 79 | |
e94d0c1e | 80 | #ifdef __WXDEBUG__ |
c3c62822 | 81 | void Print( const wxString &text ) const; |
e94d0c1e | 82 | #endif |
b5ec7dd6 | 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; | |
b5ec7dd6 | 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 |
b5ec7dd6 | 139 | virtual void GetValue( wxVariant &variant, |
e0062c04 | 140 | const wxDataViewItem &item, unsigned int col ) const = 0; |
87f0efe2 | 141 | |
a7f61f76 | 142 | // set value, call ValueChanged() afterwards! |
b5ec7dd6 | 143 | virtual bool SetValue( const wxVariant &variant, |
e0062c04 | 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 | 149 | // Is the container just a header or an item with all columns |
b5ec7dd6 VZ |
150 | virtual bool HasContainerColumns(const wxDataViewItem& WXUNUSED(item)) const |
151 | { return false; } | |
74fe973b | 152 | virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const = 0; |
b9b8b59c | 153 | |
239eaa41 | 154 | // delegated notifiers |
e0062c04 | 155 | virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ); |
854cdb09 | 156 | virtual bool ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items ); |
469d3e9b | 157 | virtual bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item ); |
854cdb09 | 158 | virtual bool ItemsDeleted( const wxDataViewItem &parent, const wxDataViewItemArray &items ); |
e0062c04 | 159 | virtual bool ItemChanged( const wxDataViewItem &item ); |
854cdb09 | 160 | virtual bool ItemsChanged( const wxDataViewItemArray &items ); |
e0062c04 | 161 | virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col ); |
8981608c | 162 | virtual bool Cleared(); |
b5d777c7 | 163 | |
ef427989 RR |
164 | // delegatd action |
165 | virtual void Resort(); | |
166 | ||
e0062c04 RR |
167 | void AddNotifier( wxDataViewModelNotifier *notifier ); |
168 | void RemoveNotifier( wxDataViewModelNotifier *notifier ); | |
b5ec7dd6 | 169 | |
ef427989 | 170 | // default compare function |
b5ec7dd6 | 171 | virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, |
7ee7191c | 172 | unsigned int column, bool ascending ); |
09711964 | 173 | virtual bool HasDefaultCompare() const { return false; } |
66e09788 | 174 | |
87f0efe2 RR |
175 | protected: |
176 | // the user should not delete this class directly: he should use DecRef() instead! | |
5debbdcf | 177 | virtual ~wxDataViewModel() { } |
87f0efe2 | 178 | |
9d8fe14a | 179 | wxDataViewModelNotifiers m_notifiers; |
ef427989 RR |
180 | }; |
181 | ||
182 | // --------------------------------------------------------- | |
c534e696 | 183 | // wxDataViewIndexListModel |
ef427989 RR |
184 | // --------------------------------------------------------- |
185 | ||
d350fbec | 186 | class WXDLLIMPEXP_ADV wxDataViewIndexListModel: public wxDataViewModel |
ef427989 RR |
187 | { |
188 | public: | |
c534e696 | 189 | wxDataViewIndexListModel( unsigned int initial_size = 0 ); |
ef427989 | 190 | ~wxDataViewIndexListModel(); |
b5ec7dd6 | 191 | |
ef427989 | 192 | virtual unsigned int GetRowCount() = 0; |
b5ec7dd6 VZ |
193 | |
194 | virtual void GetValue( wxVariant &variant, | |
ef427989 RR |
195 | unsigned int row, unsigned int col ) const = 0; |
196 | ||
b5ec7dd6 | 197 | virtual bool SetValue( const wxVariant &variant, |
ef427989 | 198 | unsigned int row, unsigned int col ) = 0; |
b5ec7dd6 | 199 | |
c534e696 RR |
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 ); | |
b5ec7dd6 | 206 | |
c534e696 | 207 | // convert to/from row/wxDataViewItem |
b5ec7dd6 | 208 | |
c534e696 RR |
209 | unsigned int GetRow( const wxDataViewItem &item ) const; |
210 | wxDataViewItem GetItem( unsigned int row ) const; | |
b5ec7dd6 | 211 | |
c534e696 | 212 | // compare based on index |
b5ec7dd6 VZ |
213 | |
214 | virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, | |
7ee7191c | 215 | unsigned int column, bool ascending ); |
09711964 | 216 | virtual bool HasDefaultCompare() const { return true; } |
c534e696 RR |
217 | |
218 | // implement base methods | |
219 | ||
b5ec7dd6 | 220 | virtual void GetValue( wxVariant &variant, |
c534e696 | 221 | const wxDataViewItem &item, unsigned int col ) const; |
b5ec7dd6 | 222 | virtual bool SetValue( const wxVariant &variant, |
c534e696 RR |
223 | const wxDataViewItem &item, unsigned int col ); |
224 | virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const; | |
225 | virtual bool IsContainer( const wxDataViewItem &item ) const; | |
74fe973b | 226 | virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const; |
b5ec7dd6 | 227 | |
c534e696 | 228 | private: |
cd722937 | 229 | wxDataViewItemArray m_hash; |
c534e696 | 230 | unsigned int m_lastIndex; |
239eaa41 RR |
231 | }; |
232 | ||
c33edc08 | 233 | |
1e510b1e RR |
234 | //----------------------------------------------------------------------------- |
235 | // wxDataViewEditorCtrlEvtHandler | |
236 | //----------------------------------------------------------------------------- | |
237 | ||
238 | class wxDataViewEditorCtrlEvtHandler: public wxEvtHandler | |
239 | { | |
240 | public: | |
241 | wxDataViewEditorCtrlEvtHandler( wxControl *editor, wxDataViewRenderer *owner ); | |
b5ec7dd6 | 242 | |
1e510b1e | 243 | void AcceptChangesAndFinish(); |
30715fa1 | 244 | void SetFocusOnIdle( bool focus = true ) { m_focusOnIdle = focus; } |
1e510b1e RR |
245 | |
246 | protected: | |
247 | void OnChar( wxKeyEvent &event ); | |
248 | void OnKillFocus( wxFocusEvent &event ); | |
30715fa1 | 249 | void OnIdle( wxIdleEvent &event ); |
1e510b1e RR |
250 | |
251 | private: | |
252 | wxDataViewRenderer *m_owner; | |
253 | wxControl *m_editorCtrl; | |
254 | bool m_finished; | |
30715fa1 | 255 | bool m_focusOnIdle; |
1e510b1e RR |
256 | |
257 | private: | |
258 | DECLARE_EVENT_TABLE() | |
259 | }; | |
260 | ||
f554a14b | 261 | // --------------------------------------------------------- |
baa9ebc4 | 262 | // wxDataViewRendererBase |
f554a14b | 263 | // --------------------------------------------------------- |
fa28826d | 264 | |
6842a71a | 265 | enum wxDataViewCellMode |
fa28826d | 266 | { |
6842a71a RR |
267 | wxDATAVIEW_CELL_INERT, |
268 | wxDATAVIEW_CELL_ACTIVATABLE, | |
269 | wxDATAVIEW_CELL_EDITABLE | |
fa28826d RR |
270 | }; |
271 | ||
6842a71a RR |
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 | ||
baa9ebc4 | 280 | class WXDLLIMPEXP_ADV wxDataViewRendererBase: public wxObject |
6842a71a RR |
281 | { |
282 | public: | |
b5ec7dd6 | 283 | wxDataViewRendererBase( const wxString &varianttype, |
9861f022 RR |
284 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
285 | int alignment = wxDVR_DEFAULT_ALIGNMENT ); | |
6842a71a | 286 | |
9861f022 RR |
287 | virtual bool Validate( wxVariant& WXUNUSED(value) ) |
288 | { return true; } | |
f554a14b | 289 | |
6842a71a RR |
290 | void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; } |
291 | wxDataViewColumn* GetOwner() { return m_owner; } | |
f554a14b | 292 | |
9861f022 RR |
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; | |
b5ec7dd6 | 308 | |
1e510b1e RR |
309 | // in-place editing |
310 | virtual bool HasEditorCtrl() | |
311 | { return false; } | |
96c2a0dd VZ |
312 | virtual wxControl* CreateEditorCtrl(wxWindow * WXUNUSED(parent), |
313 | wxRect WXUNUSED(labelRect), | |
314 | const wxVariant& WXUNUSED(value)) | |
1e510b1e | 315 | { return NULL; } |
96c2a0dd VZ |
316 | virtual bool GetValueFromEditorCtrl(wxControl * WXUNUSED(editor), |
317 | wxVariant& WXUNUSED(value)) | |
1e510b1e RR |
318 | { return false; } |
319 | ||
e0062c04 | 320 | virtual bool StartEditing( const wxDataViewItem &item, wxRect labelRect ); |
1e510b1e RR |
321 | virtual void CancelEditing(); |
322 | virtual bool FinishEditing(); | |
b5ec7dd6 | 323 | |
1e510b1e | 324 | wxControl *GetEditorCtrl() { return m_editorCtrl; } |
b5ec7dd6 | 325 | |
a7f61f76 | 326 | protected: |
6842a71a RR |
327 | wxString m_variantType; |
328 | wxDataViewColumn *m_owner; | |
1e510b1e | 329 | wxControl *m_editorCtrl; |
e0062c04 | 330 | wxDataViewItem m_item; // for m_editorCtrl |
6842a71a | 331 | |
9861f022 RR |
332 | // internal utility: |
333 | const wxDataViewCtrl* GetView() const; | |
334 | ||
6842a71a | 335 | protected: |
baa9ebc4 | 336 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase) |
6842a71a RR |
337 | }; |
338 | ||
89352653 RR |
339 | //----------------------------------------------------------------------------- |
340 | // wxDataViewIconText | |
341 | //----------------------------------------------------------------------------- | |
342 | ||
d350fbec | 343 | class WXDLLIMPEXP_ADV wxDataViewIconText: public wxObject |
89352653 RR |
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 | ||
d350fbec | 366 | DECLARE_VARIANT_OBJECT_EXPORTED(wxDataViewIconText, WXDLLIMPEXP_ADV) |
89352653 | 367 | |
f554a14b | 368 | // --------------------------------------------------------- |
6842a71a | 369 | // wxDataViewColumnBase |
f554a14b | 370 | // --------------------------------------------------------- |
6842a71a | 371 | |
fa28826d RR |
372 | enum wxDataViewColumnFlags |
373 | { | |
374 | wxDATAVIEW_COL_RESIZABLE = 1, | |
375 | wxDATAVIEW_COL_SORTABLE = 2, | |
376 | wxDATAVIEW_COL_HIDDEN = 4 | |
377 | }; | |
378 | ||
f460c29d | 379 | class WXDLLIMPEXP_ADV wxDataViewColumnBase: public wxObject |
fa28826d RR |
380 | { |
381 | public: | |
b5ec7dd6 VZ |
382 | wxDataViewColumnBase( const wxString &title, wxDataViewRenderer *renderer, |
383 | unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH, | |
87f0efe2 RR |
384 | wxAlignment align = wxALIGN_CENTER, |
385 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
b5ec7dd6 VZ |
386 | wxDataViewColumnBase( const wxBitmap &bitmap, wxDataViewRenderer *renderer, |
387 | unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH, | |
87f0efe2 RR |
388 | wxAlignment align = wxALIGN_CENTER, |
389 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
d3c7fc99 | 390 | virtual ~wxDataViewColumnBase(); |
fa28826d | 391 | |
9861f022 | 392 | // setters: |
07b6378f | 393 | |
9861f022 | 394 | virtual void SetTitle( const wxString &title ) = 0; |
47cef10f | 395 | virtual void SetAlignment( wxAlignment align ) = 0; |
31fb32e1 | 396 | virtual void SetSortable( bool sortable ) = 0; |
9861f022 RR |
397 | virtual void SetResizeable( bool resizeable ) = 0; |
398 | virtual void SetHidden( bool hidden ) = 0; | |
47cef10f | 399 | virtual void SetSortOrder( bool ascending ) = 0; |
9861f022 | 400 | virtual void SetFlags( int flags ); |
b5ec7dd6 | 401 | virtual void SetOwner( wxDataViewCtrl *owner ) |
9861f022 RR |
402 | { m_owner = owner; } |
403 | virtual void SetBitmap( const wxBitmap &bitmap ) | |
404 | { m_bitmap=bitmap; } | |
07a84e7b | 405 | |
9861f022 RR |
406 | virtual void SetMinWidth( int minWidth ) = 0; |
407 | virtual void SetWidth( int width ) = 0; | |
f554a14b | 408 | |
f554a14b | 409 | |
9861f022 | 410 | // getters: |
07b6378f | 411 | |
9861f022 RR |
412 | virtual wxString GetTitle() const = 0; |
413 | virtual wxAlignment GetAlignment() const = 0; | |
87f0efe2 | 414 | virtual int GetWidth() const = 0; |
9861f022 | 415 | virtual int GetMinWidth() const = 0; |
07b6378f | 416 | |
9861f022 RR |
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; } | |
6d9ecc87 | 425 | unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column); } |
9861f022 RR |
426 | |
427 | wxDataViewCtrl *GetOwner() { return m_owner; } | |
428 | wxDataViewRenderer* GetRenderer() { return m_renderer; } | |
429 | ||
430 | protected: | |
baa9ebc4 | 431 | wxDataViewRenderer *m_renderer; |
6842a71a | 432 | int m_model_column; |
07a84e7b | 433 | wxBitmap m_bitmap; |
6842a71a | 434 | wxDataViewCtrl *m_owner; |
fa28826d RR |
435 | |
436 | protected: | |
437 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase) | |
438 | }; | |
439 | ||
f554a14b | 440 | // --------------------------------------------------------- |
239eaa41 | 441 | // wxDataViewCtrlBase |
f554a14b | 442 | // --------------------------------------------------------- |
239eaa41 | 443 | |
c21f7aa1 | 444 | #define wxDV_SINGLE 0x0000 // for convenience |
9861f022 RR |
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 | |
c21f7aa1 | 450 | |
f460c29d | 451 | class WXDLLIMPEXP_ADV wxDataViewCtrlBase: public wxControl |
239eaa41 RR |
452 | { |
453 | public: | |
454 | wxDataViewCtrlBase(); | |
d3c7fc99 | 455 | virtual ~wxDataViewCtrlBase(); |
f554a14b | 456 | |
e0062c04 RR |
457 | virtual bool AssociateModel( wxDataViewModel *model ); |
458 | wxDataViewModel* GetModel(); | |
f554a14b | 459 | |
07a84e7b | 460 | // short cuts |
b5ec7dd6 | 461 | wxDataViewColumn *PrependTextColumn( const wxString &label, unsigned int model_column, |
736fe67c RR |
462 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
463 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), | |
464 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
b5ec7dd6 | 465 | wxDataViewColumn *PrependIconTextColumn( const wxString &label, unsigned int model_column, |
736fe67c RR |
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 ); | |
b5ec7dd6 | 473 | wxDataViewColumn *PrependProgressColumn( const wxString &label, unsigned int model_column, |
736fe67c RR |
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 ); | |
b5ec7dd6 VZ |
509 | |
510 | wxDataViewColumn *AppendTextColumn( const wxString &label, unsigned int model_column, | |
87f0efe2 | 511 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
e2da67f6 | 512 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), |
87f0efe2 | 513 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
b5ec7dd6 | 514 | wxDataViewColumn *AppendIconTextColumn( const wxString &label, unsigned int model_column, |
b04fcede | 515 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
e2da67f6 | 516 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), |
b04fcede | 517 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
c7074d44 | 518 | wxDataViewColumn *AppendToggleColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
519 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, |
520 | wxAlignment align = wxALIGN_CENTER, | |
521 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
b5ec7dd6 | 522 | wxDataViewColumn *AppendProgressColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
523 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, |
524 | wxAlignment align = wxALIGN_CENTER, | |
525 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 526 | wxDataViewColumn *AppendDateColumn( const wxString &label, unsigned int model_column, |
87f0efe2 | 527 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, |
e2da67f6 | 528 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), |
87f0efe2 | 529 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
c7074d44 | 530 | wxDataViewColumn *AppendBitmapColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
531 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
532 | wxAlignment align = wxALIGN_CENTER, | |
533 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 534 | wxDataViewColumn *AppendTextColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 | 535 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
e2da67f6 | 536 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), |
87f0efe2 | 537 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
b04fcede RR |
538 | wxDataViewColumn *AppendIconTextColumn( const wxBitmap &label, unsigned int model_column, |
539 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
e2da67f6 | 540 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), |
b04fcede | 541 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
c7074d44 | 542 | wxDataViewColumn *AppendToggleColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
543 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, |
544 | wxAlignment align = wxALIGN_CENTER, | |
545 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 546 | wxDataViewColumn *AppendProgressColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
547 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, |
548 | wxAlignment align = wxALIGN_CENTER, | |
549 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 550 | wxDataViewColumn *AppendDateColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 | 551 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, |
e2da67f6 | 552 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), |
87f0efe2 | 553 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
c7074d44 | 554 | wxDataViewColumn *AppendBitmapColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
555 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
556 | wxAlignment align = wxALIGN_CENTER, | |
557 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
736fe67c RR |
558 | |
559 | ||
560 | virtual bool PrependColumn( wxDataViewColumn *col ); | |
f554a14b | 561 | virtual bool AppendColumn( wxDataViewColumn *col ); |
9861f022 | 562 | |
91a6c655 RR |
563 | virtual unsigned int GetColumnCount() const = 0; |
564 | virtual wxDataViewColumn* GetColumn( unsigned int pos ) const = 0; | |
453091c2 | 565 | virtual int GetColumnPosition( const wxDataViewColumn *column ) const = 0; |
b5ec7dd6 | 566 | |
91a6c655 RR |
567 | virtual bool DeleteColumn( wxDataViewColumn *column ) = 0; |
568 | virtual bool ClearColumns() = 0; | |
b5ec7dd6 | 569 | |
1b27b2bd | 570 | void SetExpanderColumn( wxDataViewColumn *col ) |
3b6280be | 571 | { m_expander_column = col ; DoSetExpanderColumn(); } |
b5ec7dd6 | 572 | wxDataViewColumn *GetExpanderColumn() const |
3b6280be | 573 | { return m_expander_column; } |
b5ec7dd6 | 574 | |
21f47fb9 | 575 | virtual wxDataViewColumn *GetSortingColumn() const = 0; |
3b6280be RR |
576 | |
577 | void SetIndent( int indent ) | |
578 | { m_indent = indent ; DoSetIndent(); } | |
b5ec7dd6 VZ |
579 | int GetIndent() const |
580 | { return m_indent; } | |
3b6280be | 581 | |
fbda518c | 582 | virtual wxDataViewItem GetSelection() const = 0; |
b7e9f8b1 RR |
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 | ||
b7e9f8b1 RR |
589 | virtual void SelectAll() = 0; |
590 | virtual void UnselectAll() = 0; | |
591 | ||
f71d3ba4 RR |
592 | virtual void Expand( const wxDataViewItem & item ) = 0; |
593 | virtual void Collapse( const wxDataViewItem & item ) = 0; | |
594 | ||
6154212e | 595 | virtual void EnsureVisible( const wxDataViewItem & item, |
fbda518c | 596 | const wxDataViewColumn *column = NULL ) = 0; |
a87b466d | 597 | virtual void HitTest( const wxPoint & point, wxDataViewItem &item, wxDataViewColumn* &column ) const = 0; |
fbda518c | 598 | virtual wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ) const = 0; |
b7e9f8b1 | 599 | |
3b6280be RR |
600 | protected: |
601 | virtual void DoSetExpanderColumn() = 0 ; | |
602 | virtual void DoSetIndent() = 0; | |
603 | ||
239eaa41 | 604 | private: |
e0062c04 | 605 | wxDataViewModel *m_model; |
1b27b2bd | 606 | wxDataViewColumn *m_expander_column; |
3b6280be | 607 | int m_indent ; |
b5ec7dd6 | 608 | |
239eaa41 | 609 | protected: |
260b9be7 | 610 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase) |
239eaa41 | 611 | }; |
bcd846ea | 612 | |
eb7f97f8 RR |
613 | // ---------------------------------------------------------------------------- |
614 | // wxDataViewEvent - the event class for the wxDataViewCtrl notifications | |
615 | // ---------------------------------------------------------------------------- | |
616 | ||
2f799ae8 | 617 | class WXDLLIMPEXP_ADV wxDataViewEvent : public wxNotifyEvent |
eb7f97f8 RR |
618 | { |
619 | public: | |
620 | wxDataViewEvent(wxEventType commandType = wxEVT_NULL, int winid = 0) | |
621 | : wxNotifyEvent(commandType, winid), | |
e0062c04 | 622 | m_item(0), |
eb7f97f8 | 623 | m_col(-1), |
eb7f97f8 RR |
624 | m_model(NULL), |
625 | m_value(wxNullVariant), | |
31fb32e1 | 626 | m_column(NULL) |
eb7f97f8 RR |
627 | { } |
628 | ||
629 | wxDataViewEvent(const wxDataViewEvent& event) | |
630 | : wxNotifyEvent(event), | |
e0062c04 | 631 | m_item(event.m_item), |
eb7f97f8 | 632 | m_col(event.m_col), |
eb7f97f8 RR |
633 | m_model(event.m_model), |
634 | m_value(event.m_value), | |
31fb32e1 | 635 | m_column(event.m_column) |
eb7f97f8 RR |
636 | { } |
637 | ||
e0062c04 RR |
638 | wxDataViewItem GetItem() const { return m_item; } |
639 | void SetItem( const wxDataViewItem &item ) { m_item = item; } | |
640 | ||
eb7f97f8 RR |
641 | int GetColumn() const { return m_col; } |
642 | void SetColumn( int col ) { m_col = col; } | |
9861f022 | 643 | |
eb7f97f8 RR |
644 | wxDataViewModel* GetModel() const { return m_model; } |
645 | void SetModel( wxDataViewModel *model ) { m_model = model; } | |
9861f022 | 646 | |
eb7f97f8 RR |
647 | const wxVariant &GetValue() const { return m_value; } |
648 | void SetValue( const wxVariant &value ) { m_value = value; } | |
649 | ||
31fb32e1 RR |
650 | // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only |
651 | void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; } | |
9861f022 | 652 | wxDataViewColumn *GetDataViewColumn() const { return m_column; } |
31fb32e1 | 653 | |
eb7f97f8 RR |
654 | virtual wxEvent *Clone() const { return new wxDataViewEvent(*this); } |
655 | ||
656 | protected: | |
e0062c04 | 657 | wxDataViewItem m_item; |
eb7f97f8 | 658 | int m_col; |
eb7f97f8 RR |
659 | wxDataViewModel *m_model; |
660 | wxVariant m_value; | |
31fb32e1 | 661 | wxDataViewColumn *m_column; |
eb7f97f8 RR |
662 | |
663 | private: | |
664 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent) | |
665 | }; | |
666 | ||
667 | BEGIN_DECLARE_EVENT_TYPES() | |
d86c1870 | 668 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, -1) |
b5ec7dd6 | 669 | |
e0062c04 | 670 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, -1) |
d209a914 RR |
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) | |
6977c3bf RR |
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) | |
e0000f94 RR |
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) | |
6608fdab | 677 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, -1) |
b5ec7dd6 | 678 | |
e07c1146 PC |
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) | |
c0a66d92 | 681 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, -1) |
eb7f97f8 RR |
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 | ||
d86c1870 RR |
692 | #define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn) |
693 | ||
e0062c04 | 694 | #define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn) |
6977c3bf | 695 | #define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn) |
3ecb8a53 | 696 | #define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn) |
6977c3bf | 697 | #define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn) |
3ecb8a53 | 698 | #define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn) |
e0000f94 RR |
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) | |
6608fdab | 701 | #define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn) |
e0000f94 | 702 | |
31fb32e1 RR |
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) | |
c0a66d92 | 705 | #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn) |
eb7f97f8 | 706 | |
4ed7af08 RR |
707 | #if defined(wxUSE_GENERICDATAVIEWCTRL) |
708 | #include "wx/generic/dataview.h" | |
709 | #elif defined(__WXGTK20__) | |
bcd846ea RR |
710 | #include "wx/gtk/dataview.h" |
711 | #elif defined(__WXMAC__) | |
c0a66d92 | 712 | #include "wx/mac/dataview.h" |
bcd846ea RR |
713 | #else |
714 | #include "wx/generic/dataview.h" | |
715 | #endif | |
716 | ||
52e750fc RR |
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; | |
b5ec7dd6 | 734 | |
52e750fc RR |
735 | private: |
736 | long m_data; | |
737 | long m_min,m_max; | |
738 | }; | |
739 | ||
e94d0c1e RR |
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(); | |
b5ec7dd6 VZ |
750 | |
751 | void SetText( const wxString &text ) | |
e94d0c1e RR |
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; } | |
b5ec7dd6 | 763 | |
e94d0c1e RR |
764 | wxDataViewItem GetItem() const |
765 | { return wxDataViewItem( (void*) this ); } | |
b5ec7dd6 | 766 | |
e94d0c1e RR |
767 | virtual bool IsContainer() |
768 | { return false; } | |
b5ec7dd6 | 769 | |
e94d0c1e RR |
770 | wxDataViewTreeStoreNode *GetParent() |
771 | { return m_parent; } | |
b5ec7dd6 | 772 | |
e94d0c1e RR |
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: | |
b5ec7dd6 VZ |
786 | wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode *parent, |
787 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, | |
e94d0c1e RR |
788 | wxClientData *data = NULL ); |
789 | virtual ~wxDataViewTreeStoreContainerNode(); | |
790 | ||
b5ec7dd6 | 791 | const wxDataViewTreeStoreNodeList &GetChildren() const |
e94d0c1e | 792 | { return m_children; } |
b5ec7dd6 | 793 | wxDataViewTreeStoreNodeList &GetChildren() |
e94d0c1e RR |
794 | { return m_children; } |
795 | ||
796 | void SetExpandedIcon( const wxIcon &icon ) | |
797 | { m_iconExpanded = icon; } | |
798 | const wxIcon &GetExpandedIcon() const | |
799 | { return m_iconExpanded; } | |
b5ec7dd6 | 800 | |
e94d0c1e RR |
801 | virtual bool IsContainer() |
802 | { return true; } | |
b5ec7dd6 | 803 | |
e94d0c1e RR |
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 | ||
b5ec7dd6 | 817 | wxDataViewItem AppendItem( const wxDataViewItem& parent, |
e94d0c1e RR |
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 ); | |
b5ec7dd6 VZ |
823 | |
824 | wxDataViewItem PrependContainer( const wxDataViewItem& parent, | |
825 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, | |
e94d0c1e RR |
826 | wxClientData *data = NULL ); |
827 | wxDataViewItem AppendContainer( const wxDataViewItem& parent, | |
b5ec7dd6 | 828 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, |
e94d0c1e RR |
829 | wxClientData *data = NULL ); |
830 | wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous, | |
b5ec7dd6 | 831 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, |
e94d0c1e RR |
832 | wxClientData *data = NULL ); |
833 | ||
834 | wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const; | |
835 | int GetChildCount( const wxDataViewItem& parent ) const; | |
b5ec7dd6 | 836 | |
e94d0c1e RR |
837 | void SetItemText( const wxDataViewItem& item, const wxString &text ); |
838 | wxString GetItemText( const wxDataViewItem& item ) const; | |
b5ec7dd6 | 839 | void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon ); |
e94d0c1e RR |
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(); | |
b5ec7dd6 | 849 | |
e94d0c1e RR |
850 | // implement base methods |
851 | ||
b5ec7dd6 | 852 | virtual void GetValue( wxVariant &variant, |
e94d0c1e | 853 | const wxDataViewItem &item, unsigned int col ) const; |
b5ec7dd6 | 854 | virtual bool SetValue( const wxVariant &variant, |
e94d0c1e RR |
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 | ||
b5ec7dd6 | 860 | virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, |
e94d0c1e | 861 | unsigned int column, bool ascending ); |
b5ec7dd6 VZ |
862 | |
863 | virtual bool HasDefaultCompare() const | |
e94d0c1e | 864 | { return true; } |
b5ec7dd6 | 865 | virtual unsigned int GetColumnCount() const |
e94d0c1e | 866 | { return 1; }; |
b5ec7dd6 | 867 | virtual wxString GetColumnType( unsigned int WXUNUSED(col) ) const |
e94d0c1e | 868 | { return "wxDataViewIconText"; } |
b5ec7dd6 | 869 | |
e94d0c1e RR |
870 | wxDataViewTreeStoreNode *FindNode( const wxDataViewItem &item ) const; |
871 | wxDataViewTreeStoreContainerNode *FindContainerNode( const wxDataViewItem &item ) const; | |
872 | wxDataViewTreeStoreNode *GetRoot() const { return m_root; } | |
b5ec7dd6 | 873 | |
e94d0c1e RR |
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(); } | |
b5ec7dd6 | 894 | |
e94d0c1e | 895 | void OnExpand( wxDataViewCtrl &event ); |
b5ec7dd6 VZ |
896 | void OnCollapse( wxDataViewCtrl &event ); |
897 | ||
e94d0c1e RR |
898 | private: |
899 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl) | |
900 | }; | |
901 | #endif | |
902 | ||
bcd846ea RR |
903 | #endif // wxUSE_DATAVIEWCTRL |
904 | ||
905 | #endif | |
906 | // _WX_DATAVIEW_H_BASE_ |