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