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