]>
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 | |
b04fcede | 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: | |
62 | #define wxDVR_DEFAULT_ALIGNMENT (wxALIGN_LEFT|wxALIGN_TOP) | |
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 | |
8f850e28 | 80 | private: |
9d52aad3 | 81 | void* m_id; |
64ffb888 | 82 | }; |
239eaa41 | 83 | |
d5025dc0 | 84 | bool operator == (const wxDataViewItem &left, const wxDataViewItem &right); |
aba9bfd0 | 85 | |
cd722937 RR |
86 | WX_DEFINE_ARRAY(wxDataViewItem, wxDataViewItemArray); |
87 | ||
9d8fe14a RR |
88 | // --------------------------------------------------------- |
89 | // wxDataViewModelNotifier | |
90 | // --------------------------------------------------------- | |
91 | ||
92 | class WXDLLIMPEXP_ADV wxDataViewModelNotifier | |
93 | { | |
94 | public: | |
95 | wxDataViewModelNotifier() { } | |
96 | virtual ~wxDataViewModelNotifier() { m_owner = NULL; } | |
97 | ||
98 | virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ) = 0; | |
99 | virtual bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item ) = 0; | |
100 | virtual bool ItemChanged( const wxDataViewItem &item ) = 0; | |
101 | virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col ) = 0; | |
102 | virtual bool Cleared() = 0; | |
103 | ||
d3f00f59 | 104 | virtual void Resort() = 0; |
9d8fe14a RR |
105 | |
106 | void SetOwner( wxDataViewModel *owner ) { m_owner = owner; } | |
107 | wxDataViewModel *GetOwner() { return m_owner; } | |
108 | ||
109 | private: | |
110 | wxDataViewModel *m_owner; | |
111 | }; | |
112 | ||
113 | ||
f554a14b | 114 | // --------------------------------------------------------- |
e0062c04 | 115 | // wxDataViewModel |
f554a14b | 116 | // --------------------------------------------------------- |
239eaa41 | 117 | |
9d8fe14a RR |
118 | WX_DECLARE_LIST(wxDataViewModelNotifier, wxDataViewModelNotifiers ); |
119 | ||
e0062c04 | 120 | class WXDLLIMPEXP_ADV wxDataViewModel: public wxObjectRefData |
239eaa41 RR |
121 | { |
122 | public: | |
e0062c04 | 123 | wxDataViewModel(); |
239eaa41 | 124 | |
9861f022 | 125 | virtual unsigned int GetColumnCount() const = 0; |
87f0efe2 | 126 | |
a7f61f76 | 127 | // return type as reported by wxVariant |
9861f022 | 128 | virtual wxString GetColumnType( unsigned int col ) const = 0; |
87f0efe2 | 129 | |
a7f61f76 | 130 | // get value into a wxVariant |
e0062c04 RR |
131 | virtual void GetValue( wxVariant &variant, |
132 | const wxDataViewItem &item, unsigned int col ) const = 0; | |
87f0efe2 | 133 | |
a7f61f76 | 134 | // set value, call ValueChanged() afterwards! |
e0062c04 RR |
135 | virtual bool SetValue( const wxVariant &variant, |
136 | const wxDataViewItem &item, unsigned int col ) = 0; | |
239eaa41 | 137 | |
e0062c04 | 138 | // define hierachy |
ed903e42 RR |
139 | virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const = 0; |
140 | virtual bool IsContainer( const wxDataViewItem &item ) const = 0; | |
74fe973b | 141 | virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const = 0; |
b9b8b59c | 142 | |
239eaa41 | 143 | // delegated notifiers |
e0062c04 | 144 | virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ); |
469d3e9b | 145 | virtual bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item ); |
e0062c04 RR |
146 | virtual bool ItemChanged( const wxDataViewItem &item ); |
147 | virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col ); | |
8981608c | 148 | virtual bool Cleared(); |
b5d777c7 | 149 | |
ef427989 RR |
150 | // delegatd action |
151 | virtual void Resort(); | |
152 | ||
e0062c04 RR |
153 | void AddNotifier( wxDataViewModelNotifier *notifier ); |
154 | void RemoveNotifier( wxDataViewModelNotifier *notifier ); | |
63415a42 | 155 | |
ef427989 | 156 | // default compare function |
7ee7191c RR |
157 | virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, |
158 | unsigned int column, bool ascending ); | |
09711964 | 159 | virtual bool HasDefaultCompare() const { return false; } |
66e09788 | 160 | |
87f0efe2 RR |
161 | protected: |
162 | // the user should not delete this class directly: he should use DecRef() instead! | |
5debbdcf | 163 | virtual ~wxDataViewModel() { } |
87f0efe2 | 164 | |
9d8fe14a | 165 | wxDataViewModelNotifiers m_notifiers; |
ef427989 RR |
166 | }; |
167 | ||
168 | // --------------------------------------------------------- | |
c534e696 | 169 | // wxDataViewIndexListModel |
ef427989 RR |
170 | // --------------------------------------------------------- |
171 | ||
172 | class wxDataViewIndexListModel: public wxDataViewModel | |
173 | { | |
174 | public: | |
c534e696 | 175 | wxDataViewIndexListModel( unsigned int initial_size = 0 ); |
ef427989 RR |
176 | ~wxDataViewIndexListModel(); |
177 | ||
178 | virtual unsigned int GetRowCount() = 0; | |
179 | ||
180 | virtual void GetValue( wxVariant &variant, | |
181 | unsigned int row, unsigned int col ) const = 0; | |
182 | ||
183 | virtual bool SetValue( const wxVariant &variant, | |
184 | unsigned int row, unsigned int col ) = 0; | |
185 | ||
c534e696 RR |
186 | void RowPrepended(); |
187 | void RowInserted( unsigned int before ); | |
188 | void RowAppended(); | |
189 | void RowDeleted( unsigned int row ); | |
190 | void RowChanged( unsigned int row ); | |
191 | void RowValueChanged( unsigned int row, unsigned int col ); | |
192 | ||
193 | // convert to/from row/wxDataViewItem | |
ef427989 | 194 | |
c534e696 RR |
195 | unsigned int GetRow( const wxDataViewItem &item ) const; |
196 | wxDataViewItem GetItem( unsigned int row ) const; | |
197 | ||
198 | // compare based on index | |
ef427989 | 199 | |
7ee7191c RR |
200 | virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, |
201 | unsigned int column, bool ascending ); | |
09711964 | 202 | virtual bool HasDefaultCompare() const { return true; } |
c534e696 RR |
203 | |
204 | // implement base methods | |
205 | ||
206 | virtual void GetValue( wxVariant &variant, | |
207 | const wxDataViewItem &item, unsigned int col ) const; | |
208 | virtual bool SetValue( const wxVariant &variant, | |
209 | const wxDataViewItem &item, unsigned int col ); | |
210 | virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const; | |
211 | virtual bool IsContainer( const wxDataViewItem &item ) const; | |
74fe973b | 212 | virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const; |
ef427989 | 213 | |
c534e696 | 214 | private: |
cd722937 | 215 | wxDataViewItemArray m_hash; |
c534e696 | 216 | unsigned int m_lastIndex; |
239eaa41 RR |
217 | }; |
218 | ||
1e510b1e RR |
219 | //----------------------------------------------------------------------------- |
220 | // wxDataViewEditorCtrlEvtHandler | |
221 | //----------------------------------------------------------------------------- | |
222 | ||
223 | class wxDataViewEditorCtrlEvtHandler: public wxEvtHandler | |
224 | { | |
225 | public: | |
226 | wxDataViewEditorCtrlEvtHandler( wxControl *editor, wxDataViewRenderer *owner ); | |
227 | ||
228 | void AcceptChangesAndFinish(); | |
30715fa1 | 229 | void SetFocusOnIdle( bool focus = true ) { m_focusOnIdle = focus; } |
1e510b1e RR |
230 | |
231 | protected: | |
232 | void OnChar( wxKeyEvent &event ); | |
233 | void OnKillFocus( wxFocusEvent &event ); | |
30715fa1 | 234 | void OnIdle( wxIdleEvent &event ); |
1e510b1e RR |
235 | |
236 | private: | |
237 | wxDataViewRenderer *m_owner; | |
238 | wxControl *m_editorCtrl; | |
239 | bool m_finished; | |
30715fa1 | 240 | bool m_focusOnIdle; |
1e510b1e RR |
241 | |
242 | private: | |
243 | DECLARE_EVENT_TABLE() | |
244 | }; | |
245 | ||
f554a14b | 246 | // --------------------------------------------------------- |
baa9ebc4 | 247 | // wxDataViewRendererBase |
f554a14b | 248 | // --------------------------------------------------------- |
fa28826d | 249 | |
6842a71a | 250 | enum wxDataViewCellMode |
fa28826d | 251 | { |
6842a71a RR |
252 | wxDATAVIEW_CELL_INERT, |
253 | wxDATAVIEW_CELL_ACTIVATABLE, | |
254 | wxDATAVIEW_CELL_EDITABLE | |
fa28826d RR |
255 | }; |
256 | ||
6842a71a RR |
257 | enum wxDataViewCellRenderState |
258 | { | |
259 | wxDATAVIEW_CELL_SELECTED = 1, | |
260 | wxDATAVIEW_CELL_PRELIT = 2, | |
261 | wxDATAVIEW_CELL_INSENSITIVE = 4, | |
262 | wxDATAVIEW_CELL_FOCUSED = 8 | |
263 | }; | |
264 | ||
baa9ebc4 | 265 | class WXDLLIMPEXP_ADV wxDataViewRendererBase: public wxObject |
6842a71a RR |
266 | { |
267 | public: | |
9861f022 RR |
268 | wxDataViewRendererBase( const wxString &varianttype, |
269 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, | |
270 | int alignment = wxDVR_DEFAULT_ALIGNMENT ); | |
6842a71a | 271 | |
9861f022 RR |
272 | virtual bool Validate( wxVariant& WXUNUSED(value) ) |
273 | { return true; } | |
f554a14b | 274 | |
6842a71a RR |
275 | void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; } |
276 | wxDataViewColumn* GetOwner() { return m_owner; } | |
f554a14b | 277 | |
9861f022 RR |
278 | // renderer properties: |
279 | ||
280 | virtual bool SetValue( const wxVariant& WXUNUSED(value) ) = 0; | |
281 | virtual bool GetValue( wxVariant& WXUNUSED(value) ) const = 0; | |
282 | ||
283 | wxString GetVariantType() const { return m_variantType; } | |
284 | ||
285 | virtual void SetMode( wxDataViewCellMode mode ) = 0; | |
286 | virtual wxDataViewCellMode GetMode() const = 0; | |
287 | ||
288 | // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but | |
289 | // rather an "int"; that's because for rendering cells it's allowed | |
290 | // to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM) | |
291 | virtual void SetAlignment( int align ) = 0; | |
292 | virtual int GetAlignment() const = 0; | |
99d471a5 | 293 | |
1e510b1e RR |
294 | // in-place editing |
295 | virtual bool HasEditorCtrl() | |
296 | { return false; } | |
96c2a0dd VZ |
297 | virtual wxControl* CreateEditorCtrl(wxWindow * WXUNUSED(parent), |
298 | wxRect WXUNUSED(labelRect), | |
299 | const wxVariant& WXUNUSED(value)) | |
1e510b1e | 300 | { return NULL; } |
96c2a0dd VZ |
301 | virtual bool GetValueFromEditorCtrl(wxControl * WXUNUSED(editor), |
302 | wxVariant& WXUNUSED(value)) | |
1e510b1e RR |
303 | { return false; } |
304 | ||
e0062c04 | 305 | virtual bool StartEditing( const wxDataViewItem &item, wxRect labelRect ); |
1e510b1e RR |
306 | virtual void CancelEditing(); |
307 | virtual bool FinishEditing(); | |
308 | ||
309 | wxControl *GetEditorCtrl() { return m_editorCtrl; } | |
310 | ||
a7f61f76 | 311 | protected: |
6842a71a RR |
312 | wxString m_variantType; |
313 | wxDataViewColumn *m_owner; | |
1e510b1e | 314 | wxControl *m_editorCtrl; |
e0062c04 | 315 | wxDataViewItem m_item; // for m_editorCtrl |
6842a71a | 316 | |
9861f022 RR |
317 | // internal utility: |
318 | const wxDataViewCtrl* GetView() const; | |
319 | ||
6842a71a | 320 | protected: |
baa9ebc4 | 321 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase) |
6842a71a RR |
322 | }; |
323 | ||
89352653 RR |
324 | //----------------------------------------------------------------------------- |
325 | // wxDataViewIconText | |
326 | //----------------------------------------------------------------------------- | |
327 | ||
328 | class wxDataViewIconText: public wxObject | |
329 | { | |
330 | public: | |
331 | wxDataViewIconText( const wxString &text = wxEmptyString, const wxIcon& icon = wxNullIcon ) | |
332 | { m_icon = icon; m_text = text; } | |
333 | wxDataViewIconText( const wxDataViewIconText &other ) | |
334 | { m_icon = other.m_icon; m_text = other.m_text; } | |
335 | ||
336 | void SetText( const wxString &text ) { m_text = text; } | |
337 | wxString GetText() const { return m_text; } | |
338 | void SetIcon( const wxIcon &icon ) { m_icon = icon; } | |
339 | const wxIcon &GetIcon() const { return m_icon; } | |
340 | ||
341 | private: | |
342 | wxString m_text; | |
343 | wxIcon m_icon; | |
344 | ||
345 | private: | |
346 | DECLARE_DYNAMIC_CLASS(wxDataViewIconText) | |
347 | }; | |
348 | ||
349 | bool operator == (const wxDataViewIconText &one, const wxDataViewIconText &two); | |
350 | ||
351 | DECLARE_VARIANT_OBJECT(wxDataViewIconText) | |
352 | ||
f554a14b | 353 | // --------------------------------------------------------- |
6842a71a | 354 | // wxDataViewColumnBase |
f554a14b | 355 | // --------------------------------------------------------- |
6842a71a | 356 | |
fa28826d RR |
357 | enum wxDataViewColumnFlags |
358 | { | |
359 | wxDATAVIEW_COL_RESIZABLE = 1, | |
360 | wxDATAVIEW_COL_SORTABLE = 2, | |
361 | wxDATAVIEW_COL_HIDDEN = 4 | |
362 | }; | |
363 | ||
f460c29d | 364 | class WXDLLIMPEXP_ADV wxDataViewColumnBase: public wxObject |
fa28826d RR |
365 | { |
366 | public: | |
87f0efe2 RR |
367 | wxDataViewColumnBase( const wxString &title, wxDataViewRenderer *renderer, |
368 | unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH, | |
369 | wxAlignment align = wxALIGN_CENTER, | |
370 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
371 | wxDataViewColumnBase( const wxBitmap &bitmap, wxDataViewRenderer *renderer, | |
372 | unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH, | |
373 | wxAlignment align = wxALIGN_CENTER, | |
374 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
d3c7fc99 | 375 | virtual ~wxDataViewColumnBase(); |
fa28826d | 376 | |
9861f022 | 377 | // setters: |
07b6378f | 378 | |
9861f022 | 379 | virtual void SetTitle( const wxString &title ) = 0; |
47cef10f | 380 | virtual void SetAlignment( wxAlignment align ) = 0; |
31fb32e1 | 381 | virtual void SetSortable( bool sortable ) = 0; |
9861f022 RR |
382 | virtual void SetResizeable( bool resizeable ) = 0; |
383 | virtual void SetHidden( bool hidden ) = 0; | |
47cef10f | 384 | virtual void SetSortOrder( bool ascending ) = 0; |
9861f022 RR |
385 | virtual void SetFlags( int flags ); |
386 | virtual void SetOwner( wxDataViewCtrl *owner ) | |
387 | { m_owner = owner; } | |
388 | virtual void SetBitmap( const wxBitmap &bitmap ) | |
389 | { m_bitmap=bitmap; } | |
07a84e7b | 390 | |
9861f022 RR |
391 | virtual void SetMinWidth( int minWidth ) = 0; |
392 | virtual void SetWidth( int width ) = 0; | |
f554a14b | 393 | |
f554a14b | 394 | |
9861f022 | 395 | // getters: |
07b6378f | 396 | |
9861f022 RR |
397 | virtual wxString GetTitle() const = 0; |
398 | virtual wxAlignment GetAlignment() const = 0; | |
87f0efe2 | 399 | virtual int GetWidth() const = 0; |
9861f022 | 400 | virtual int GetMinWidth() const = 0; |
07b6378f | 401 | |
9861f022 RR |
402 | virtual int GetFlags() const; |
403 | ||
404 | virtual bool IsSortable() const = 0; | |
405 | virtual bool IsResizeable() const = 0; | |
406 | virtual bool IsHidden() const = 0; | |
407 | virtual bool IsSortOrderAscending() const = 0; | |
408 | ||
409 | const wxBitmap &GetBitmap() const { return m_bitmap; } | |
410 | unsigned int GetModelColumn() const { return m_model_column; } | |
411 | ||
412 | wxDataViewCtrl *GetOwner() { return m_owner; } | |
413 | wxDataViewRenderer* GetRenderer() { return m_renderer; } | |
414 | ||
415 | protected: | |
baa9ebc4 | 416 | wxDataViewRenderer *m_renderer; |
6842a71a | 417 | int m_model_column; |
07a84e7b | 418 | wxBitmap m_bitmap; |
6842a71a | 419 | wxDataViewCtrl *m_owner; |
fa28826d RR |
420 | |
421 | protected: | |
422 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase) | |
423 | }; | |
424 | ||
f554a14b | 425 | // --------------------------------------------------------- |
239eaa41 | 426 | // wxDataViewCtrlBase |
f554a14b | 427 | // --------------------------------------------------------- |
239eaa41 | 428 | |
c21f7aa1 | 429 | #define wxDV_SINGLE 0x0000 // for convenience |
9861f022 RR |
430 | #define wxDV_MULTIPLE 0x0001 // can select multiple items |
431 | ||
432 | #define wxDV_NO_HEADER 0x0002 // column titles not visible | |
433 | #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows | |
434 | #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns | |
c21f7aa1 | 435 | |
f460c29d | 436 | class WXDLLIMPEXP_ADV wxDataViewCtrlBase: public wxControl |
239eaa41 RR |
437 | { |
438 | public: | |
439 | wxDataViewCtrlBase(); | |
d3c7fc99 | 440 | virtual ~wxDataViewCtrlBase(); |
f554a14b | 441 | |
e0062c04 RR |
442 | virtual bool AssociateModel( wxDataViewModel *model ); |
443 | wxDataViewModel* GetModel(); | |
f554a14b | 444 | |
07a84e7b | 445 | // short cuts |
c7074d44 | 446 | wxDataViewColumn *AppendTextColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
447 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
448 | wxAlignment align = wxALIGN_CENTER, | |
449 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
b04fcede RR |
450 | wxDataViewColumn *AppendIconTextColumn( const wxString &label, unsigned int model_column, |
451 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
452 | wxAlignment align = wxALIGN_CENTER, | |
453 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 454 | wxDataViewColumn *AppendToggleColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
455 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, |
456 | wxAlignment align = wxALIGN_CENTER, | |
457 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 458 | wxDataViewColumn *AppendProgressColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
459 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, |
460 | wxAlignment align = wxALIGN_CENTER, | |
461 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 462 | wxDataViewColumn *AppendDateColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
463 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, |
464 | wxAlignment align = wxALIGN_CENTER, | |
465 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 466 | wxDataViewColumn *AppendBitmapColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
467 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
468 | wxAlignment align = wxALIGN_CENTER, | |
469 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 470 | wxDataViewColumn *AppendTextColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
471 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
472 | wxAlignment align = wxALIGN_CENTER, | |
473 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
b04fcede RR |
474 | wxDataViewColumn *AppendIconTextColumn( const wxBitmap &label, unsigned int model_column, |
475 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
476 | wxAlignment align = wxALIGN_CENTER, | |
477 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 478 | wxDataViewColumn *AppendToggleColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
479 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, |
480 | wxAlignment align = wxALIGN_CENTER, | |
481 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 482 | wxDataViewColumn *AppendProgressColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
483 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, |
484 | wxAlignment align = wxALIGN_CENTER, | |
485 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 486 | wxDataViewColumn *AppendDateColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
487 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, |
488 | wxAlignment align = wxALIGN_CENTER, | |
489 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 RR |
490 | |
491 | wxDataViewColumn *AppendBitmapColumn( const wxBitmap &label, unsigned int model_column, | |
87f0efe2 RR |
492 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
493 | wxAlignment align = wxALIGN_CENTER, | |
494 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
07a84e7b | 495 | |
f554a14b | 496 | virtual bool AppendColumn( wxDataViewColumn *col ); |
9861f022 | 497 | |
91a6c655 RR |
498 | virtual unsigned int GetColumnCount() const = 0; |
499 | virtual wxDataViewColumn* GetColumn( unsigned int pos ) const = 0; | |
500 | ||
501 | virtual bool DeleteColumn( wxDataViewColumn *column ) = 0; | |
502 | virtual bool ClearColumns() = 0; | |
503 | ||
1b27b2bd | 504 | void SetExpanderColumn( wxDataViewColumn *col ) |
3b6280be | 505 | { m_expander_column = col ; DoSetExpanderColumn(); } |
1b27b2bd | 506 | wxDataViewColumn *GetExpanderColumn() const |
3b6280be RR |
507 | { return m_expander_column; } |
508 | ||
509 | void SetIndent( int indent ) | |
510 | { m_indent = indent ; DoSetIndent(); } | |
511 | int GetIndent() const | |
512 | { return m_indent; } | |
513 | ||
fbda518c | 514 | virtual wxDataViewItem GetSelection() const = 0; |
b7e9f8b1 RR |
515 | virtual int GetSelections( wxDataViewItemArray & sel ) const = 0; |
516 | virtual void SetSelections( const wxDataViewItemArray & sel ) = 0; | |
517 | virtual void Select( const wxDataViewItem & item ) = 0; | |
518 | virtual void Unselect( const wxDataViewItem & item ) = 0; | |
519 | virtual bool IsSelected( const wxDataViewItem & item ) const = 0; | |
520 | ||
b7e9f8b1 RR |
521 | virtual void SelectAll() = 0; |
522 | virtual void UnselectAll() = 0; | |
523 | ||
f71d3ba4 RR |
524 | virtual void Expand( const wxDataViewItem & item ) = 0; |
525 | virtual void Collapse( const wxDataViewItem & item ) = 0; | |
526 | ||
6154212e | 527 | virtual void EnsureVisible( const wxDataViewItem & item, |
fbda518c | 528 | const wxDataViewColumn *column = NULL ) = 0; |
a87b466d | 529 | virtual void HitTest( const wxPoint & point, wxDataViewItem &item, wxDataViewColumn* &column ) const = 0; |
fbda518c | 530 | virtual wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ) const = 0; |
b7e9f8b1 | 531 | |
3b6280be RR |
532 | protected: |
533 | virtual void DoSetExpanderColumn() = 0 ; | |
534 | virtual void DoSetIndent() = 0; | |
535 | ||
239eaa41 | 536 | private: |
e0062c04 | 537 | wxDataViewModel *m_model; |
1b27b2bd | 538 | wxDataViewColumn *m_expander_column; |
3b6280be RR |
539 | int m_indent ; |
540 | ||
239eaa41 | 541 | protected: |
260b9be7 | 542 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase) |
239eaa41 | 543 | }; |
bcd846ea | 544 | |
eb7f97f8 RR |
545 | // ---------------------------------------------------------------------------- |
546 | // wxDataViewEvent - the event class for the wxDataViewCtrl notifications | |
547 | // ---------------------------------------------------------------------------- | |
548 | ||
2f799ae8 | 549 | class WXDLLIMPEXP_ADV wxDataViewEvent : public wxNotifyEvent |
eb7f97f8 RR |
550 | { |
551 | public: | |
552 | wxDataViewEvent(wxEventType commandType = wxEVT_NULL, int winid = 0) | |
553 | : wxNotifyEvent(commandType, winid), | |
e0062c04 | 554 | m_item(0), |
eb7f97f8 | 555 | m_col(-1), |
eb7f97f8 RR |
556 | m_model(NULL), |
557 | m_value(wxNullVariant), | |
31fb32e1 | 558 | m_column(NULL) |
eb7f97f8 RR |
559 | { } |
560 | ||
561 | wxDataViewEvent(const wxDataViewEvent& event) | |
562 | : wxNotifyEvent(event), | |
e0062c04 | 563 | m_item(event.m_item), |
eb7f97f8 | 564 | m_col(event.m_col), |
eb7f97f8 RR |
565 | m_model(event.m_model), |
566 | m_value(event.m_value), | |
31fb32e1 | 567 | m_column(event.m_column) |
eb7f97f8 RR |
568 | { } |
569 | ||
e0062c04 RR |
570 | wxDataViewItem GetItem() const { return m_item; } |
571 | void SetItem( const wxDataViewItem &item ) { m_item = item; } | |
572 | ||
eb7f97f8 RR |
573 | int GetColumn() const { return m_col; } |
574 | void SetColumn( int col ) { m_col = col; } | |
9861f022 | 575 | |
eb7f97f8 RR |
576 | wxDataViewModel* GetModel() const { return m_model; } |
577 | void SetModel( wxDataViewModel *model ) { m_model = model; } | |
9861f022 | 578 | |
eb7f97f8 RR |
579 | const wxVariant &GetValue() const { return m_value; } |
580 | void SetValue( const wxVariant &value ) { m_value = value; } | |
581 | ||
31fb32e1 RR |
582 | // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only |
583 | void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; } | |
9861f022 | 584 | wxDataViewColumn *GetDataViewColumn() const { return m_column; } |
31fb32e1 | 585 | |
eb7f97f8 RR |
586 | virtual wxEvent *Clone() const { return new wxDataViewEvent(*this); } |
587 | ||
588 | protected: | |
e0062c04 | 589 | wxDataViewItem m_item; |
eb7f97f8 | 590 | int m_col; |
eb7f97f8 RR |
591 | wxDataViewModel *m_model; |
592 | wxVariant m_value; | |
31fb32e1 | 593 | wxDataViewColumn *m_column; |
eb7f97f8 RR |
594 | |
595 | private: | |
596 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent) | |
597 | }; | |
598 | ||
599 | BEGIN_DECLARE_EVENT_TYPES() | |
e0062c04 | 600 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_SELECTED, -1) |
e98351ec | 601 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_DESELECTED, -1) |
e0062c04 | 602 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, -1) |
d209a914 RR |
603 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED, -1) |
604 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED, -1) | |
6977c3bf RR |
605 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING, -1) |
606 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING, -1) | |
e0000f94 RR |
607 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED, -1) |
608 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, -1) | |
609 | ||
e07c1146 PC |
610 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, -1) |
611 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, -1) | |
c0a66d92 | 612 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, -1) |
e0000f94 | 613 | |
1821abd1 | 614 | // notifications from the model to the control |
e0062c04 RR |
615 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_ADDED, -1) |
616 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_DELETED, -1) | |
617 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_CHANGED, -1) | |
1821abd1 | 618 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_VALUE_CHANGED, -1) |
1821abd1 | 619 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_MODEL_CLEARED, -1) |
eb7f97f8 RR |
620 | END_DECLARE_EVENT_TYPES() |
621 | ||
622 | typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&); | |
623 | ||
624 | #define wxDataViewEventHandler(func) \ | |
625 | (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxDataViewEventFunction, &func) | |
626 | ||
627 | #define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \ | |
628 | wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn)) | |
629 | ||
e0062c04 | 630 | #define EVT_DATAVIEW_ITEM_SELECTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_SELECTED, id, fn) |
e98351ec | 631 | #define EVT_DATAVIEW_ITEM_DESELECTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_DESELECTED, id, fn) |
e0062c04 | 632 | #define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn) |
6977c3bf | 633 | #define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn) |
3ecb8a53 | 634 | #define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn) |
6977c3bf | 635 | #define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn) |
3ecb8a53 | 636 | #define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn) |
e0000f94 RR |
637 | #define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn) |
638 | #define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn) | |
639 | ||
31fb32e1 RR |
640 | #define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn) |
641 | #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn) | |
c0a66d92 | 642 | #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn) |
eb7f97f8 | 643 | |
d8331a01 | 644 | #define EVT_DATAVIEW_MODEL_ITEM_ADDED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_ITEM_ADDED, id, fn) |
e0062c04 RR |
645 | #define EVT_DATAVIEW_MODEL_ITEM_DELETED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_ITEM_DELETED, id, fn) |
646 | #define EVT_DATAVIEW_MODEL_ITEM_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_ITEM_CHANGED, id, fn) | |
1821abd1 | 647 | #define EVT_DATAVIEW_MODEL_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_VALUE_CHANGED, id, fn) |
1821abd1 RR |
648 | #define EVT_DATAVIEW_MODEL_CLEARED(id, fn) wx__DECLARE_DATAVIEWEVT(MODEL_CLEARED, id, fn) |
649 | ||
eb7f97f8 | 650 | |
4ed7af08 RR |
651 | #if defined(wxUSE_GENERICDATAVIEWCTRL) |
652 | #include "wx/generic/dataview.h" | |
653 | #elif defined(__WXGTK20__) | |
bcd846ea RR |
654 | #include "wx/gtk/dataview.h" |
655 | #elif defined(__WXMAC__) | |
c0a66d92 | 656 | #include "wx/mac/dataview.h" |
bcd846ea RR |
657 | #else |
658 | #include "wx/generic/dataview.h" | |
659 | #endif | |
660 | ||
661 | #endif // wxUSE_DATAVIEWCTRL | |
662 | ||
663 | #endif | |
664 | // _WX_DATAVIEW_H_BASE_ |