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