]>
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" |
b7e9f8b1 | 23 | #include "wx/dynarray.h" |
89352653 | 24 | #include "wx/icon.h" |
a75124d0 | 25 | #include "wx/imaglist.h" |
4ed7af08 RR |
26 | |
27 | #if defined(__WXGTK20__) | |
28 | // for testing | |
001f0f82 | 29 | // #define wxUSE_GENERICDATAVIEWCTRL 1 |
4ed7af08 | 30 | #elif defined(__WXMAC__) |
4ed7af08 RR |
31 | #else |
32 | #define wxUSE_GENERICDATAVIEWCTRL 1 | |
33 | #endif | |
34 | ||
bcd846ea | 35 | // ---------------------------------------------------------------------------- |
f554a14b | 36 | // wxDataViewCtrl flags |
bcd846ea RR |
37 | // ---------------------------------------------------------------------------- |
38 | ||
239eaa41 RR |
39 | // ---------------------------------------------------------------------------- |
40 | // wxDataViewCtrl globals | |
41 | // ---------------------------------------------------------------------------- | |
bcd846ea | 42 | |
b5dbe15d VS |
43 | class WXDLLIMPEXP_FWD_ADV wxDataViewItem; |
44 | class WXDLLIMPEXP_FWD_ADV wxDataViewModel; | |
45 | class WXDLLIMPEXP_FWD_ADV wxDataViewCtrl; | |
46 | class WXDLLIMPEXP_FWD_ADV wxDataViewColumn; | |
47 | class WXDLLIMPEXP_FWD_ADV wxDataViewRenderer; | |
48 | class WXDLLIMPEXP_FWD_ADV wxDataViewModelNotifier; | |
fa28826d | 49 | |
f460c29d | 50 | extern WXDLLIMPEXP_DATA_ADV(const wxChar) wxDataViewCtrlNameStr[]; |
bcd846ea | 51 | |
87f0efe2 RR |
52 | // the default width of new (text) columns: |
53 | #define wxDVC_DEFAULT_WIDTH 80 | |
54 | ||
55 | // the default width of new toggle columns: | |
56 | #define wxDVC_TOGGLE_DEFAULT_WIDTH 30 | |
57 | ||
9861f022 RR |
58 | // the default minimal width of the columns: |
59 | #define wxDVC_DEFAULT_MINWIDTH 30 | |
60 | ||
61 | // the default alignment of wxDataViewRenderers: | |
69357fa0 | 62 | #define wxDVR_DEFAULT_ALIGNMENT (wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL) |
9861f022 | 63 | |
87f0efe2 | 64 | |
f554a14b | 65 | // --------------------------------------------------------- |
e0062c04 | 66 | // wxDataViewItem |
f554a14b | 67 | // --------------------------------------------------------- |
239eaa41 | 68 | |
e0062c04 | 69 | class WXDLLIMPEXP_ADV wxDataViewItem |
239eaa41 RR |
70 | { |
71 | public: | |
b5ec7dd6 | 72 | wxDataViewItem( void* id = NULL ) |
9d52aad3 | 73 | { m_id = id; } |
e0062c04 | 74 | wxDataViewItem( const wxDataViewItem &item ) |
9d52aad3 RR |
75 | { m_id = item.m_id; } |
76 | bool IsOk() const { return m_id != NULL; } | |
77 | void* GetID() const { return m_id; } | |
4f1cf94b | 78 | operator const void* () const { return m_id; } |
b5ec7dd6 | 79 | |
e94d0c1e | 80 | #ifdef __WXDEBUG__ |
c3c62822 | 81 | void Print( const wxString &text ) const; |
e94d0c1e | 82 | #endif |
b5ec7dd6 | 83 | |
8f850e28 | 84 | private: |
9d52aad3 | 85 | void* m_id; |
64ffb888 | 86 | }; |
239eaa41 | 87 | |
d5025dc0 | 88 | bool operator == (const wxDataViewItem &left, const wxDataViewItem &right); |
aba9bfd0 | 89 | |
cd722937 RR |
90 | WX_DEFINE_ARRAY(wxDataViewItem, wxDataViewItemArray); |
91 | ||
9d8fe14a RR |
92 | // --------------------------------------------------------- |
93 | // wxDataViewModelNotifier | |
94 | // --------------------------------------------------------- | |
95 | ||
96 | class WXDLLIMPEXP_ADV wxDataViewModelNotifier | |
97 | { | |
98 | public: | |
99 | wxDataViewModelNotifier() { } | |
100 | virtual ~wxDataViewModelNotifier() { m_owner = NULL; } | |
101 | ||
102 | virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ) = 0; | |
103 | virtual bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item ) = 0; | |
104 | virtual bool ItemChanged( const wxDataViewItem &item ) = 0; | |
854cdb09 RR |
105 | virtual bool ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items ); |
106 | virtual bool ItemsDeleted( const wxDataViewItem &parent, const wxDataViewItemArray &items ); | |
107 | virtual bool ItemsChanged( const wxDataViewItemArray &items ); | |
9d8fe14a RR |
108 | virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col ) = 0; |
109 | virtual bool Cleared() = 0; | |
b5ec7dd6 | 110 | |
d3f00f59 | 111 | virtual void Resort() = 0; |
9d8fe14a RR |
112 | |
113 | void SetOwner( wxDataViewModel *owner ) { m_owner = owner; } | |
114 | wxDataViewModel *GetOwner() { return m_owner; } | |
115 | ||
116 | private: | |
117 | wxDataViewModel *m_owner; | |
118 | }; | |
119 | ||
120 | ||
4264606e RR |
121 | |
122 | // ---------------------------------------------------------------------------- | |
123 | // wxDataViewItemAttr: a structure containing the visual attributes of an item | |
124 | // ---------------------------------------------------------------------------- | |
125 | ||
126 | // TODO: this should be renamed to wxItemAttr or something general like this | |
127 | ||
128 | class WXDLLIMPEXP_ADV wxDataViewItemAttr | |
129 | { | |
130 | public: | |
131 | // ctors | |
132 | wxDataViewItemAttr() | |
133 | { | |
134 | m_bold = false; | |
135 | m_italic = false; | |
136 | } | |
137 | ||
138 | // setters | |
139 | void SetColour(const wxColour& colour) { m_colour = colour; } | |
140 | void SetBold( bool set ) { m_bold = set; } | |
141 | void SetItalic( bool set ) { m_italic = set; } | |
142 | ||
143 | // accessors | |
144 | bool HasColour() const { return m_colour.Ok(); } | |
145 | const wxColour& GetColour() const { return m_colour; } | |
146 | ||
147 | bool GetBold() const { return m_bold; } | |
148 | bool GetItalic() const { return m_italic; } | |
149 | ||
150 | private: | |
151 | wxColour m_colour; | |
152 | bool m_bold; | |
153 | bool m_italic; | |
154 | }; | |
155 | ||
156 | ||
f554a14b | 157 | // --------------------------------------------------------- |
e0062c04 | 158 | // wxDataViewModel |
f554a14b | 159 | // --------------------------------------------------------- |
239eaa41 | 160 | |
d350fbec VS |
161 | WX_DECLARE_LIST_WITH_DECL(wxDataViewModelNotifier, wxDataViewModelNotifiers, |
162 | class WXDLLIMPEXP_ADV); | |
9d8fe14a | 163 | |
e0062c04 | 164 | class WXDLLIMPEXP_ADV wxDataViewModel: public wxObjectRefData |
239eaa41 RR |
165 | { |
166 | public: | |
e0062c04 | 167 | wxDataViewModel(); |
239eaa41 | 168 | |
9861f022 | 169 | virtual unsigned int GetColumnCount() const = 0; |
87f0efe2 | 170 | |
a7f61f76 | 171 | // return type as reported by wxVariant |
9861f022 | 172 | virtual wxString GetColumnType( unsigned int col ) const = 0; |
87f0efe2 | 173 | |
a7f61f76 | 174 | // get value into a wxVariant |
b5ec7dd6 | 175 | virtual void GetValue( wxVariant &variant, |
e0062c04 | 176 | const wxDataViewItem &item, unsigned int col ) const = 0; |
87f0efe2 | 177 | |
a7f61f76 | 178 | // set value, call ValueChanged() afterwards! |
b5ec7dd6 | 179 | virtual bool SetValue( const wxVariant &variant, |
e0062c04 | 180 | const wxDataViewItem &item, unsigned int col ) = 0; |
239eaa41 | 181 | |
4264606e RR |
182 | // Get text attribute, return false of default attributes should be used |
183 | virtual bool GetAttr( const wxDataViewItem &WXUNUSED(item), unsigned int WXUNUSED(col), wxDataViewItemAttr &WXUNUSED(attr) ) | |
184 | { return false; } | |
185 | ||
e0062c04 | 186 | // define hierachy |
ed903e42 RR |
187 | virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const = 0; |
188 | virtual bool IsContainer( const wxDataViewItem &item ) const = 0; | |
1e40f667 | 189 | // Is the container just a header or an item with all columns |
b5ec7dd6 VZ |
190 | virtual bool HasContainerColumns(const wxDataViewItem& WXUNUSED(item)) const |
191 | { return false; } | |
74fe973b | 192 | virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const = 0; |
b9b8b59c | 193 | |
239eaa41 | 194 | // delegated notifiers |
e0062c04 | 195 | virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ); |
854cdb09 | 196 | virtual bool ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items ); |
469d3e9b | 197 | virtual bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item ); |
854cdb09 | 198 | virtual bool ItemsDeleted( const wxDataViewItem &parent, const wxDataViewItemArray &items ); |
e0062c04 | 199 | virtual bool ItemChanged( const wxDataViewItem &item ); |
854cdb09 | 200 | virtual bool ItemsChanged( const wxDataViewItemArray &items ); |
e0062c04 | 201 | virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col ); |
8981608c | 202 | virtual bool Cleared(); |
b5d777c7 | 203 | |
ef427989 RR |
204 | // delegatd action |
205 | virtual void Resort(); | |
206 | ||
e0062c04 RR |
207 | void AddNotifier( wxDataViewModelNotifier *notifier ); |
208 | void RemoveNotifier( wxDataViewModelNotifier *notifier ); | |
b5ec7dd6 | 209 | |
ef427989 | 210 | // default compare function |
b5ec7dd6 | 211 | virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, |
7ee7191c | 212 | unsigned int column, bool ascending ); |
09711964 | 213 | virtual bool HasDefaultCompare() const { return false; } |
2056dede RR |
214 | |
215 | // internal | |
216 | virtual bool IsIndexListModel() const { return false; } | |
66e09788 | 217 | |
87f0efe2 RR |
218 | protected: |
219 | // the user should not delete this class directly: he should use DecRef() instead! | |
5debbdcf | 220 | virtual ~wxDataViewModel() { } |
87f0efe2 | 221 | |
9d8fe14a | 222 | wxDataViewModelNotifiers m_notifiers; |
ef427989 RR |
223 | }; |
224 | ||
225 | // --------------------------------------------------------- | |
c534e696 | 226 | // wxDataViewIndexListModel |
ef427989 RR |
227 | // --------------------------------------------------------- |
228 | ||
d350fbec | 229 | class WXDLLIMPEXP_ADV wxDataViewIndexListModel: public wxDataViewModel |
ef427989 RR |
230 | { |
231 | public: | |
c534e696 | 232 | wxDataViewIndexListModel( unsigned int initial_size = 0 ); |
ef427989 | 233 | ~wxDataViewIndexListModel(); |
b5ec7dd6 | 234 | |
b5ec7dd6 | 235 | virtual void GetValue( wxVariant &variant, |
ef427989 RR |
236 | unsigned int row, unsigned int col ) const = 0; |
237 | ||
b5ec7dd6 | 238 | virtual bool SetValue( const wxVariant &variant, |
ef427989 | 239 | unsigned int row, unsigned int col ) = 0; |
b5ec7dd6 | 240 | |
4264606e RR |
241 | virtual bool GetAttr( unsigned int WXUNUSED(row), unsigned int WXUNUSED(col), wxDataViewItemAttr &WXUNUSED(attr) ) |
242 | { return false; } | |
243 | ||
c534e696 RR |
244 | void RowPrepended(); |
245 | void RowInserted( unsigned int before ); | |
246 | void RowAppended(); | |
247 | void RowDeleted( unsigned int row ); | |
8b6cf9bf | 248 | void RowsDeleted( const wxArrayInt &rows ); |
c534e696 RR |
249 | void RowChanged( unsigned int row ); |
250 | void RowValueChanged( unsigned int row, unsigned int col ); | |
33ba5a05 | 251 | void Reset( unsigned int new_size ); |
b5ec7dd6 | 252 | |
c534e696 | 253 | // convert to/from row/wxDataViewItem |
b5ec7dd6 | 254 | |
c534e696 RR |
255 | unsigned int GetRow( const wxDataViewItem &item ) const; |
256 | wxDataViewItem GetItem( unsigned int row ) const; | |
b5ec7dd6 | 257 | |
c534e696 | 258 | // compare based on index |
b5ec7dd6 VZ |
259 | |
260 | virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, | |
7ee7191c | 261 | unsigned int column, bool ascending ); |
517166e6 | 262 | virtual bool HasDefaultCompare() const; |
c534e696 RR |
263 | |
264 | // implement base methods | |
265 | ||
b5ec7dd6 | 266 | virtual void GetValue( wxVariant &variant, |
c534e696 | 267 | const wxDataViewItem &item, unsigned int col ) const; |
b5ec7dd6 | 268 | virtual bool SetValue( const wxVariant &variant, |
c534e696 | 269 | const wxDataViewItem &item, unsigned int col ); |
4264606e | 270 | virtual bool GetAttr( const wxDataViewItem &item, unsigned int col, wxDataViewItemAttr &attr ); |
c534e696 RR |
271 | virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const; |
272 | virtual bool IsContainer( const wxDataViewItem &item ) const; | |
74fe973b | 273 | virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const; |
b5ec7dd6 | 274 | |
2056dede RR |
275 | // internal |
276 | virtual bool IsIndexListModel() const { return true; } | |
277 | unsigned int GetLastIndex() const { return m_lastIndex; } | |
278 | ||
c534e696 | 279 | private: |
cd722937 | 280 | wxDataViewItemArray m_hash; |
c534e696 | 281 | unsigned int m_lastIndex; |
517166e6 | 282 | bool m_ordered; |
2056dede | 283 | bool m_useHash; |
239eaa41 RR |
284 | }; |
285 | ||
c33edc08 | 286 | |
1e510b1e RR |
287 | //----------------------------------------------------------------------------- |
288 | // wxDataViewEditorCtrlEvtHandler | |
289 | //----------------------------------------------------------------------------- | |
290 | ||
291 | class wxDataViewEditorCtrlEvtHandler: public wxEvtHandler | |
292 | { | |
293 | public: | |
294 | wxDataViewEditorCtrlEvtHandler( wxControl *editor, wxDataViewRenderer *owner ); | |
b5ec7dd6 | 295 | |
1e510b1e | 296 | void AcceptChangesAndFinish(); |
30715fa1 | 297 | void SetFocusOnIdle( bool focus = true ) { m_focusOnIdle = focus; } |
1e510b1e RR |
298 | |
299 | protected: | |
300 | void OnChar( wxKeyEvent &event ); | |
301 | void OnKillFocus( wxFocusEvent &event ); | |
30715fa1 | 302 | void OnIdle( wxIdleEvent &event ); |
1e510b1e RR |
303 | |
304 | private: | |
305 | wxDataViewRenderer *m_owner; | |
306 | wxControl *m_editorCtrl; | |
307 | bool m_finished; | |
30715fa1 | 308 | bool m_focusOnIdle; |
1e510b1e RR |
309 | |
310 | private: | |
311 | DECLARE_EVENT_TABLE() | |
312 | }; | |
313 | ||
f554a14b | 314 | // --------------------------------------------------------- |
baa9ebc4 | 315 | // wxDataViewRendererBase |
f554a14b | 316 | // --------------------------------------------------------- |
fa28826d | 317 | |
6842a71a | 318 | enum wxDataViewCellMode |
fa28826d | 319 | { |
6842a71a RR |
320 | wxDATAVIEW_CELL_INERT, |
321 | wxDATAVIEW_CELL_ACTIVATABLE, | |
322 | wxDATAVIEW_CELL_EDITABLE | |
fa28826d RR |
323 | }; |
324 | ||
6842a71a RR |
325 | enum wxDataViewCellRenderState |
326 | { | |
327 | wxDATAVIEW_CELL_SELECTED = 1, | |
328 | wxDATAVIEW_CELL_PRELIT = 2, | |
329 | wxDATAVIEW_CELL_INSENSITIVE = 4, | |
330 | wxDATAVIEW_CELL_FOCUSED = 8 | |
331 | }; | |
332 | ||
baa9ebc4 | 333 | class WXDLLIMPEXP_ADV wxDataViewRendererBase: public wxObject |
6842a71a RR |
334 | { |
335 | public: | |
b5ec7dd6 | 336 | wxDataViewRendererBase( const wxString &varianttype, |
9861f022 RR |
337 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, |
338 | int alignment = wxDVR_DEFAULT_ALIGNMENT ); | |
6842a71a | 339 | |
9861f022 RR |
340 | virtual bool Validate( wxVariant& WXUNUSED(value) ) |
341 | { return true; } | |
f554a14b | 342 | |
6842a71a RR |
343 | void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; } |
344 | wxDataViewColumn* GetOwner() { return m_owner; } | |
f554a14b | 345 | |
9861f022 RR |
346 | // renderer properties: |
347 | ||
348 | virtual bool SetValue( const wxVariant& WXUNUSED(value) ) = 0; | |
349 | virtual bool GetValue( wxVariant& WXUNUSED(value) ) const = 0; | |
350 | ||
351 | wxString GetVariantType() const { return m_variantType; } | |
352 | ||
353 | virtual void SetMode( wxDataViewCellMode mode ) = 0; | |
354 | virtual wxDataViewCellMode GetMode() const = 0; | |
355 | ||
356 | // NOTE: Set/GetAlignment do not take/return a wxAlignment enum but | |
357 | // rather an "int"; that's because for rendering cells it's allowed | |
358 | // to combine alignment flags (e.g. wxALIGN_LEFT|wxALIGN_BOTTOM) | |
359 | virtual void SetAlignment( int align ) = 0; | |
360 | virtual int GetAlignment() const = 0; | |
b5ec7dd6 | 361 | |
1e510b1e RR |
362 | // in-place editing |
363 | virtual bool HasEditorCtrl() | |
364 | { return false; } | |
96c2a0dd VZ |
365 | virtual wxControl* CreateEditorCtrl(wxWindow * WXUNUSED(parent), |
366 | wxRect WXUNUSED(labelRect), | |
367 | const wxVariant& WXUNUSED(value)) | |
1e510b1e | 368 | { return NULL; } |
96c2a0dd VZ |
369 | virtual bool GetValueFromEditorCtrl(wxControl * WXUNUSED(editor), |
370 | wxVariant& WXUNUSED(value)) | |
1e510b1e RR |
371 | { return false; } |
372 | ||
e0062c04 | 373 | virtual bool StartEditing( const wxDataViewItem &item, wxRect labelRect ); |
1e510b1e RR |
374 | virtual void CancelEditing(); |
375 | virtual bool FinishEditing(); | |
b5ec7dd6 | 376 | |
1e510b1e | 377 | wxControl *GetEditorCtrl() { return m_editorCtrl; } |
b5ec7dd6 | 378 | |
a7f61f76 | 379 | protected: |
6842a71a RR |
380 | wxString m_variantType; |
381 | wxDataViewColumn *m_owner; | |
1e510b1e | 382 | wxControl *m_editorCtrl; |
e0062c04 | 383 | wxDataViewItem m_item; // for m_editorCtrl |
6842a71a | 384 | |
9861f022 RR |
385 | // internal utility: |
386 | const wxDataViewCtrl* GetView() const; | |
387 | ||
6842a71a | 388 | protected: |
baa9ebc4 | 389 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRendererBase) |
6842a71a RR |
390 | }; |
391 | ||
89352653 RR |
392 | //----------------------------------------------------------------------------- |
393 | // wxDataViewIconText | |
394 | //----------------------------------------------------------------------------- | |
395 | ||
d350fbec | 396 | class WXDLLIMPEXP_ADV wxDataViewIconText: public wxObject |
89352653 RR |
397 | { |
398 | public: | |
399 | wxDataViewIconText( const wxString &text = wxEmptyString, const wxIcon& icon = wxNullIcon ) | |
400 | { m_icon = icon; m_text = text; } | |
401 | wxDataViewIconText( const wxDataViewIconText &other ) | |
402 | { m_icon = other.m_icon; m_text = other.m_text; } | |
403 | ||
404 | void SetText( const wxString &text ) { m_text = text; } | |
405 | wxString GetText() const { return m_text; } | |
406 | void SetIcon( const wxIcon &icon ) { m_icon = icon; } | |
407 | const wxIcon &GetIcon() const { return m_icon; } | |
408 | ||
409 | private: | |
410 | wxString m_text; | |
411 | wxIcon m_icon; | |
412 | ||
413 | private: | |
414 | DECLARE_DYNAMIC_CLASS(wxDataViewIconText) | |
415 | }; | |
416 | ||
417 | bool operator == (const wxDataViewIconText &one, const wxDataViewIconText &two); | |
418 | ||
d350fbec | 419 | DECLARE_VARIANT_OBJECT_EXPORTED(wxDataViewIconText, WXDLLIMPEXP_ADV) |
89352653 | 420 | |
f554a14b | 421 | // --------------------------------------------------------- |
6842a71a | 422 | // wxDataViewColumnBase |
f554a14b | 423 | // --------------------------------------------------------- |
6842a71a | 424 | |
fa28826d RR |
425 | enum wxDataViewColumnFlags |
426 | { | |
427 | wxDATAVIEW_COL_RESIZABLE = 1, | |
428 | wxDATAVIEW_COL_SORTABLE = 2, | |
429 | wxDATAVIEW_COL_HIDDEN = 4 | |
430 | }; | |
431 | ||
f460c29d | 432 | class WXDLLIMPEXP_ADV wxDataViewColumnBase: public wxObject |
fa28826d RR |
433 | { |
434 | public: | |
b5ec7dd6 VZ |
435 | wxDataViewColumnBase( const wxString &title, wxDataViewRenderer *renderer, |
436 | unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH, | |
87f0efe2 RR |
437 | wxAlignment align = wxALIGN_CENTER, |
438 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
b5ec7dd6 VZ |
439 | wxDataViewColumnBase( const wxBitmap &bitmap, wxDataViewRenderer *renderer, |
440 | unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH, | |
87f0efe2 RR |
441 | wxAlignment align = wxALIGN_CENTER, |
442 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
d3c7fc99 | 443 | virtual ~wxDataViewColumnBase(); |
fa28826d | 444 | |
9861f022 | 445 | // setters: |
07b6378f | 446 | |
9861f022 | 447 | virtual void SetTitle( const wxString &title ) = 0; |
47cef10f | 448 | virtual void SetAlignment( wxAlignment align ) = 0; |
31fb32e1 | 449 | virtual void SetSortable( bool sortable ) = 0; |
9861f022 RR |
450 | virtual void SetResizeable( bool resizeable ) = 0; |
451 | virtual void SetHidden( bool hidden ) = 0; | |
47cef10f | 452 | virtual void SetSortOrder( bool ascending ) = 0; |
9861f022 | 453 | virtual void SetFlags( int flags ); |
b5ec7dd6 | 454 | virtual void SetOwner( wxDataViewCtrl *owner ) |
9861f022 RR |
455 | { m_owner = owner; } |
456 | virtual void SetBitmap( const wxBitmap &bitmap ) | |
457 | { m_bitmap=bitmap; } | |
07a84e7b | 458 | |
9861f022 RR |
459 | virtual void SetMinWidth( int minWidth ) = 0; |
460 | virtual void SetWidth( int width ) = 0; | |
f554a14b | 461 | |
f554a14b | 462 | |
9861f022 | 463 | // getters: |
07b6378f | 464 | |
9861f022 RR |
465 | virtual wxString GetTitle() const = 0; |
466 | virtual wxAlignment GetAlignment() const = 0; | |
87f0efe2 | 467 | virtual int GetWidth() const = 0; |
9861f022 | 468 | virtual int GetMinWidth() const = 0; |
07b6378f | 469 | |
9861f022 RR |
470 | virtual int GetFlags() const; |
471 | ||
472 | virtual bool IsSortable() const = 0; | |
473 | virtual bool IsResizeable() const = 0; | |
474 | virtual bool IsHidden() const = 0; | |
475 | virtual bool IsSortOrderAscending() const = 0; | |
476 | ||
477 | const wxBitmap &GetBitmap() const { return m_bitmap; } | |
6d9ecc87 | 478 | unsigned int GetModelColumn() const { return static_cast<unsigned int>(m_model_column); } |
9861f022 | 479 | |
594d5596 RR |
480 | wxDataViewCtrl *GetOwner() const { return m_owner; } |
481 | wxDataViewRenderer* GetRenderer() const { return m_renderer; } | |
9861f022 RR |
482 | |
483 | protected: | |
baa9ebc4 | 484 | wxDataViewRenderer *m_renderer; |
6842a71a | 485 | int m_model_column; |
07a84e7b | 486 | wxBitmap m_bitmap; |
6842a71a | 487 | wxDataViewCtrl *m_owner; |
fa28826d RR |
488 | |
489 | protected: | |
490 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase) | |
491 | }; | |
492 | ||
f554a14b | 493 | // --------------------------------------------------------- |
239eaa41 | 494 | // wxDataViewCtrlBase |
f554a14b | 495 | // --------------------------------------------------------- |
239eaa41 | 496 | |
c21f7aa1 | 497 | #define wxDV_SINGLE 0x0000 // for convenience |
9861f022 RR |
498 | #define wxDV_MULTIPLE 0x0001 // can select multiple items |
499 | ||
500 | #define wxDV_NO_HEADER 0x0002 // column titles not visible | |
501 | #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows | |
502 | #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns | |
c21f7aa1 | 503 | |
1a07a730 RR |
504 | #define wxDV_ROW_LINES 0x0010 // alternating colour in rows |
505 | ||
f460c29d | 506 | class WXDLLIMPEXP_ADV wxDataViewCtrlBase: public wxControl |
239eaa41 RR |
507 | { |
508 | public: | |
509 | wxDataViewCtrlBase(); | |
d3c7fc99 | 510 | virtual ~wxDataViewCtrlBase(); |
f554a14b | 511 | |
e0062c04 RR |
512 | virtual bool AssociateModel( wxDataViewModel *model ); |
513 | wxDataViewModel* GetModel(); | |
a75124d0 | 514 | const wxDataViewModel* GetModel() const; |
f554a14b | 515 | |
07a84e7b | 516 | // short cuts |
b5ec7dd6 | 517 | wxDataViewColumn *PrependTextColumn( const wxString &label, unsigned int model_column, |
736fe67c RR |
518 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
519 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), | |
520 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
b5ec7dd6 | 521 | wxDataViewColumn *PrependIconTextColumn( const wxString &label, unsigned int model_column, |
736fe67c RR |
522 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
523 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), | |
524 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
525 | wxDataViewColumn *PrependToggleColumn( const wxString &label, unsigned int model_column, | |
526 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, | |
527 | wxAlignment align = wxALIGN_CENTER, | |
528 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
b5ec7dd6 | 529 | wxDataViewColumn *PrependProgressColumn( const wxString &label, unsigned int model_column, |
736fe67c RR |
530 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, |
531 | wxAlignment align = wxALIGN_CENTER, | |
532 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
533 | wxDataViewColumn *PrependDateColumn( const wxString &label, unsigned int model_column, | |
534 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, | |
535 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), | |
536 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
537 | wxDataViewColumn *PrependBitmapColumn( const wxString &label, unsigned int model_column, | |
538 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
539 | wxAlignment align = wxALIGN_CENTER, | |
540 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
541 | wxDataViewColumn *PrependTextColumn( const wxBitmap &label, unsigned int model_column, | |
542 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
543 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), | |
544 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
545 | wxDataViewColumn *PrependIconTextColumn( const wxBitmap &label, unsigned int model_column, | |
546 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
547 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), | |
548 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
549 | wxDataViewColumn *PrependToggleColumn( const wxBitmap &label, unsigned int model_column, | |
550 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, | |
551 | wxAlignment align = wxALIGN_CENTER, | |
552 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
553 | wxDataViewColumn *PrependProgressColumn( const wxBitmap &label, unsigned int model_column, | |
554 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, | |
555 | wxAlignment align = wxALIGN_CENTER, | |
556 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
557 | wxDataViewColumn *PrependDateColumn( const wxBitmap &label, unsigned int model_column, | |
558 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, | |
559 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), | |
560 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
561 | wxDataViewColumn *PrependBitmapColumn( const wxBitmap &label, unsigned int model_column, | |
562 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
563 | wxAlignment align = wxALIGN_CENTER, | |
564 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
b5ec7dd6 VZ |
565 | |
566 | wxDataViewColumn *AppendTextColumn( const wxString &label, unsigned int model_column, | |
87f0efe2 | 567 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
e2da67f6 | 568 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), |
87f0efe2 | 569 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
b5ec7dd6 | 570 | wxDataViewColumn *AppendIconTextColumn( const wxString &label, unsigned int model_column, |
b04fcede | 571 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
e2da67f6 | 572 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), |
b04fcede | 573 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
c7074d44 | 574 | wxDataViewColumn *AppendToggleColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
575 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, |
576 | wxAlignment align = wxALIGN_CENTER, | |
577 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
b5ec7dd6 | 578 | wxDataViewColumn *AppendProgressColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
579 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, |
580 | wxAlignment align = wxALIGN_CENTER, | |
581 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 582 | wxDataViewColumn *AppendDateColumn( const wxString &label, unsigned int model_column, |
87f0efe2 | 583 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, |
e2da67f6 | 584 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), |
87f0efe2 | 585 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
c7074d44 | 586 | wxDataViewColumn *AppendBitmapColumn( const wxString &label, unsigned int model_column, |
87f0efe2 RR |
587 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
588 | wxAlignment align = wxALIGN_CENTER, | |
589 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 590 | wxDataViewColumn *AppendTextColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 | 591 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
e2da67f6 | 592 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), |
87f0efe2 | 593 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
b04fcede RR |
594 | wxDataViewColumn *AppendIconTextColumn( const wxBitmap &label, unsigned int model_column, |
595 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, | |
e2da67f6 | 596 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), |
b04fcede | 597 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
c7074d44 | 598 | wxDataViewColumn *AppendToggleColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
599 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, |
600 | wxAlignment align = wxALIGN_CENTER, | |
601 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 602 | wxDataViewColumn *AppendProgressColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
603 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, |
604 | wxAlignment align = wxALIGN_CENTER, | |
605 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
c7074d44 | 606 | wxDataViewColumn *AppendDateColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 | 607 | wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, |
e2da67f6 | 608 | wxAlignment align = (wxAlignment)(wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL), |
87f0efe2 | 609 | int flags = wxDATAVIEW_COL_RESIZABLE ); |
c7074d44 | 610 | wxDataViewColumn *AppendBitmapColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 RR |
611 | wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, |
612 | wxAlignment align = wxALIGN_CENTER, | |
613 | int flags = wxDATAVIEW_COL_RESIZABLE ); | |
736fe67c RR |
614 | |
615 | ||
616 | virtual bool PrependColumn( wxDataViewColumn *col ); | |
f554a14b | 617 | virtual bool AppendColumn( wxDataViewColumn *col ); |
9861f022 | 618 | |
91a6c655 RR |
619 | virtual unsigned int GetColumnCount() const = 0; |
620 | virtual wxDataViewColumn* GetColumn( unsigned int pos ) const = 0; | |
453091c2 | 621 | virtual int GetColumnPosition( const wxDataViewColumn *column ) const = 0; |
b5ec7dd6 | 622 | |
91a6c655 RR |
623 | virtual bool DeleteColumn( wxDataViewColumn *column ) = 0; |
624 | virtual bool ClearColumns() = 0; | |
b5ec7dd6 | 625 | |
1b27b2bd | 626 | void SetExpanderColumn( wxDataViewColumn *col ) |
3b6280be | 627 | { m_expander_column = col ; DoSetExpanderColumn(); } |
b5ec7dd6 | 628 | wxDataViewColumn *GetExpanderColumn() const |
3b6280be | 629 | { return m_expander_column; } |
b5ec7dd6 | 630 | |
21f47fb9 | 631 | virtual wxDataViewColumn *GetSortingColumn() const = 0; |
3b6280be RR |
632 | |
633 | void SetIndent( int indent ) | |
634 | { m_indent = indent ; DoSetIndent(); } | |
b5ec7dd6 VZ |
635 | int GetIndent() const |
636 | { return m_indent; } | |
3b6280be | 637 | |
fbda518c | 638 | virtual wxDataViewItem GetSelection() const = 0; |
b7e9f8b1 RR |
639 | virtual int GetSelections( wxDataViewItemArray & sel ) const = 0; |
640 | virtual void SetSelections( const wxDataViewItemArray & sel ) = 0; | |
641 | virtual void Select( const wxDataViewItem & item ) = 0; | |
642 | virtual void Unselect( const wxDataViewItem & item ) = 0; | |
643 | virtual bool IsSelected( const wxDataViewItem & item ) const = 0; | |
644 | ||
b7e9f8b1 RR |
645 | virtual void SelectAll() = 0; |
646 | virtual void UnselectAll() = 0; | |
647 | ||
f71d3ba4 RR |
648 | virtual void Expand( const wxDataViewItem & item ) = 0; |
649 | virtual void Collapse( const wxDataViewItem & item ) = 0; | |
650 | ||
6154212e | 651 | virtual void EnsureVisible( const wxDataViewItem & item, |
fbda518c | 652 | const wxDataViewColumn *column = NULL ) = 0; |
a87b466d | 653 | virtual void HitTest( const wxPoint & point, wxDataViewItem &item, wxDataViewColumn* &column ) const = 0; |
fbda518c | 654 | virtual wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ) const = 0; |
b7e9f8b1 | 655 | |
3b6280be RR |
656 | protected: |
657 | virtual void DoSetExpanderColumn() = 0 ; | |
658 | virtual void DoSetIndent() = 0; | |
659 | ||
239eaa41 | 660 | private: |
e0062c04 | 661 | wxDataViewModel *m_model; |
1b27b2bd | 662 | wxDataViewColumn *m_expander_column; |
3b6280be | 663 | int m_indent ; |
b5ec7dd6 | 664 | |
239eaa41 | 665 | protected: |
260b9be7 | 666 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase) |
239eaa41 | 667 | }; |
bcd846ea | 668 | |
eb7f97f8 RR |
669 | // ---------------------------------------------------------------------------- |
670 | // wxDataViewEvent - the event class for the wxDataViewCtrl notifications | |
671 | // ---------------------------------------------------------------------------- | |
672 | ||
2f799ae8 | 673 | class WXDLLIMPEXP_ADV wxDataViewEvent : public wxNotifyEvent |
eb7f97f8 RR |
674 | { |
675 | public: | |
676 | wxDataViewEvent(wxEventType commandType = wxEVT_NULL, int winid = 0) | |
677 | : wxNotifyEvent(commandType, winid), | |
e0062c04 | 678 | m_item(0), |
eb7f97f8 | 679 | m_col(-1), |
eb7f97f8 RR |
680 | m_model(NULL), |
681 | m_value(wxNullVariant), | |
6af3eec2 RR |
682 | m_column(NULL), |
683 | m_pos(-1,-1) | |
eb7f97f8 RR |
684 | { } |
685 | ||
686 | wxDataViewEvent(const wxDataViewEvent& event) | |
687 | : wxNotifyEvent(event), | |
e0062c04 | 688 | m_item(event.m_item), |
eb7f97f8 | 689 | m_col(event.m_col), |
eb7f97f8 RR |
690 | m_model(event.m_model), |
691 | m_value(event.m_value), | |
6af3eec2 RR |
692 | m_column(event.m_column), |
693 | m_pos(m_pos) | |
eb7f97f8 RR |
694 | { } |
695 | ||
e0062c04 RR |
696 | wxDataViewItem GetItem() const { return m_item; } |
697 | void SetItem( const wxDataViewItem &item ) { m_item = item; } | |
698 | ||
eb7f97f8 RR |
699 | int GetColumn() const { return m_col; } |
700 | void SetColumn( int col ) { m_col = col; } | |
9861f022 | 701 | |
eb7f97f8 RR |
702 | wxDataViewModel* GetModel() const { return m_model; } |
703 | void SetModel( wxDataViewModel *model ) { m_model = model; } | |
9861f022 | 704 | |
eb7f97f8 RR |
705 | const wxVariant &GetValue() const { return m_value; } |
706 | void SetValue( const wxVariant &value ) { m_value = value; } | |
707 | ||
31fb32e1 RR |
708 | // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only |
709 | void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; } | |
9861f022 | 710 | wxDataViewColumn *GetDataViewColumn() const { return m_column; } |
6af3eec2 RR |
711 | |
712 | // for wxEVT_DATAVIEW_CONTEXT_MENU only | |
713 | wxPoint GetPosition() const; | |
714 | void SetPosition( int x, int y ) { m_pos.x = x; m_pos.y = y; } | |
31fb32e1 | 715 | |
eb7f97f8 RR |
716 | virtual wxEvent *Clone() const { return new wxDataViewEvent(*this); } |
717 | ||
718 | protected: | |
e0062c04 | 719 | wxDataViewItem m_item; |
eb7f97f8 | 720 | int m_col; |
eb7f97f8 RR |
721 | wxDataViewModel *m_model; |
722 | wxVariant m_value; | |
31fb32e1 | 723 | wxDataViewColumn *m_column; |
6af3eec2 | 724 | wxPoint m_pos; |
eb7f97f8 RR |
725 | |
726 | private: | |
727 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent) | |
728 | }; | |
729 | ||
730 | BEGIN_DECLARE_EVENT_TYPES() | |
d86c1870 | 731 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, -1) |
b5ec7dd6 | 732 | |
e0062c04 | 733 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, -1) |
d209a914 RR |
734 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED, -1) |
735 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED, -1) | |
6977c3bf RR |
736 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING, -1) |
737 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING, -1) | |
e0000f94 RR |
738 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED, -1) |
739 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, -1) | |
6608fdab | 740 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, -1) |
6af3eec2 RR |
741 | |
742 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, -1) | |
b5ec7dd6 | 743 | |
e07c1146 PC |
744 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, -1) |
745 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, -1) | |
c0a66d92 | 746 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, -1) |
eb7f97f8 RR |
747 | END_DECLARE_EVENT_TYPES() |
748 | ||
749 | typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&); | |
750 | ||
751 | #define wxDataViewEventHandler(func) \ | |
752 | (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxDataViewEventFunction, &func) | |
753 | ||
754 | #define wx__DECLARE_DATAVIEWEVT(evt, id, fn) \ | |
755 | wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn)) | |
756 | ||
d86c1870 RR |
757 | #define EVT_DATAVIEW_SELECTION_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(SELECTION_CHANGED, id, fn) |
758 | ||
e0062c04 | 759 | #define EVT_DATAVIEW_ITEM_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_ACTIVATED, id, fn) |
6977c3bf | 760 | #define EVT_DATAVIEW_ITEM_COLLAPSING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSING, id, fn) |
3ecb8a53 | 761 | #define EVT_DATAVIEW_ITEM_COLLAPSED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_COLLAPSED, id, fn) |
6977c3bf | 762 | #define EVT_DATAVIEW_ITEM_EXPANDING(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDING, id, fn) |
3ecb8a53 | 763 | #define EVT_DATAVIEW_ITEM_EXPANDED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EXPANDED, id, fn) |
e0000f94 RR |
764 | #define EVT_DATAVIEW_ITEM_EDITING_STARTED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_STARTED, id, fn) |
765 | #define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn) | |
6608fdab | 766 | #define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn) |
e0000f94 | 767 | |
6af3eec2 RR |
768 | #define EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_CONTEXT_MENU, id, fn) |
769 | ||
31fb32e1 RR |
770 | #define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn) |
771 | #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn) | |
c0a66d92 | 772 | #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn) |
eb7f97f8 | 773 | |
4ed7af08 RR |
774 | #if defined(wxUSE_GENERICDATAVIEWCTRL) |
775 | #include "wx/generic/dataview.h" | |
776 | #elif defined(__WXGTK20__) | |
bcd846ea RR |
777 | #include "wx/gtk/dataview.h" |
778 | #elif defined(__WXMAC__) | |
c0a66d92 | 779 | #include "wx/mac/dataview.h" |
bcd846ea RR |
780 | #else |
781 | #include "wx/generic/dataview.h" | |
782 | #endif | |
783 | ||
52e750fc RR |
784 | // ------------------------------------- |
785 | // wxDataViewSpinRenderer | |
786 | // ------------------------------------- | |
787 | ||
4660b556 | 788 | class WXDLLIMPEXP_ADV wxDataViewSpinRenderer: public wxDataViewCustomRenderer |
52e750fc RR |
789 | { |
790 | public: | |
791 | wxDataViewSpinRenderer( int min, int max, | |
792 | wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE, | |
793 | int alignment = wxDVR_DEFAULT_ALIGNMENT ); | |
794 | virtual bool HasEditorCtrl() { return true; } | |
795 | virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value ); | |
796 | virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value ); | |
797 | virtual bool Render( wxRect rect, wxDC *dc, int state ); | |
798 | virtual wxSize GetSize() const; | |
799 | virtual bool SetValue( const wxVariant &value ); | |
800 | virtual bool GetValue( wxVariant &value ) const; | |
b5ec7dd6 | 801 | |
52e750fc RR |
802 | private: |
803 | long m_data; | |
804 | long m_min,m_max; | |
805 | }; | |
806 | ||
e94d0c1e RR |
807 | //----------------------------------------------------------------------------- |
808 | // wxDataViewTreeStore | |
809 | //----------------------------------------------------------------------------- | |
810 | ||
811 | class WXDLLIMPEXP_ADV wxDataViewTreeStoreNode | |
812 | { | |
813 | public: | |
814 | wxDataViewTreeStoreNode( wxDataViewTreeStoreNode *parent, | |
815 | const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); | |
816 | virtual ~wxDataViewTreeStoreNode(); | |
b5ec7dd6 VZ |
817 | |
818 | void SetText( const wxString &text ) | |
e94d0c1e RR |
819 | { m_text = text; } |
820 | wxString GetText() const | |
821 | { return m_text; } | |
822 | void SetIcon( const wxIcon &icon ) | |
823 | { m_icon = icon; } | |
824 | const wxIcon &GetIcon() const | |
825 | { return m_icon; } | |
826 | void SetData( wxClientData *data ) | |
827 | { if (m_data) delete m_data; m_data = data; } | |
828 | wxClientData *GetData() const | |
829 | { return m_data; } | |
b5ec7dd6 | 830 | |
e94d0c1e RR |
831 | wxDataViewItem GetItem() const |
832 | { return wxDataViewItem( (void*) this ); } | |
b5ec7dd6 | 833 | |
e94d0c1e RR |
834 | virtual bool IsContainer() |
835 | { return false; } | |
b5ec7dd6 | 836 | |
e94d0c1e RR |
837 | wxDataViewTreeStoreNode *GetParent() |
838 | { return m_parent; } | |
b5ec7dd6 | 839 | |
e94d0c1e RR |
840 | private: |
841 | wxDataViewTreeStoreNode *m_parent; | |
842 | wxString m_text; | |
843 | wxIcon m_icon; | |
844 | wxClientData *m_data; | |
845 | }; | |
846 | ||
847 | WX_DECLARE_LIST_WITH_DECL(wxDataViewTreeStoreNode, wxDataViewTreeStoreNodeList, | |
848 | class WXDLLIMPEXP_ADV); | |
849 | ||
850 | class WXDLLIMPEXP_ADV wxDataViewTreeStoreContainerNode: public wxDataViewTreeStoreNode | |
851 | { | |
852 | public: | |
b5ec7dd6 VZ |
853 | wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode *parent, |
854 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, | |
e94d0c1e RR |
855 | wxClientData *data = NULL ); |
856 | virtual ~wxDataViewTreeStoreContainerNode(); | |
857 | ||
b5ec7dd6 | 858 | const wxDataViewTreeStoreNodeList &GetChildren() const |
e94d0c1e | 859 | { return m_children; } |
b5ec7dd6 | 860 | wxDataViewTreeStoreNodeList &GetChildren() |
e94d0c1e RR |
861 | { return m_children; } |
862 | ||
863 | void SetExpandedIcon( const wxIcon &icon ) | |
864 | { m_iconExpanded = icon; } | |
865 | const wxIcon &GetExpandedIcon() const | |
866 | { return m_iconExpanded; } | |
b5ec7dd6 | 867 | |
a75124d0 RR |
868 | void SetExpanded( bool expanded = true ) |
869 | { m_isExpanded = expanded; } | |
870 | bool IsExpanded() const | |
871 | { return m_isExpanded; } | |
872 | ||
e94d0c1e RR |
873 | virtual bool IsContainer() |
874 | { return true; } | |
b5ec7dd6 | 875 | |
e94d0c1e RR |
876 | private: |
877 | wxDataViewTreeStoreNodeList m_children; | |
878 | wxIcon m_iconExpanded; | |
a75124d0 | 879 | bool m_isExpanded; |
e94d0c1e RR |
880 | }; |
881 | ||
882 | //----------------------------------------------------------------------------- | |
883 | ||
884 | class WXDLLIMPEXP_ADV wxDataViewTreeStore: public wxDataViewModel | |
885 | { | |
886 | public: | |
887 | wxDataViewTreeStore(); | |
888 | ~wxDataViewTreeStore(); | |
889 | ||
b5ec7dd6 | 890 | wxDataViewItem AppendItem( const wxDataViewItem& parent, |
e94d0c1e RR |
891 | const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); |
892 | wxDataViewItem PrependItem( const wxDataViewItem& parent, | |
893 | const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); | |
894 | wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous, | |
895 | const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); | |
b5ec7dd6 VZ |
896 | |
897 | wxDataViewItem PrependContainer( const wxDataViewItem& parent, | |
898 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, | |
e94d0c1e RR |
899 | wxClientData *data = NULL ); |
900 | wxDataViewItem AppendContainer( const wxDataViewItem& parent, | |
b5ec7dd6 | 901 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, |
e94d0c1e RR |
902 | wxClientData *data = NULL ); |
903 | wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous, | |
b5ec7dd6 | 904 | const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, |
e94d0c1e RR |
905 | wxClientData *data = NULL ); |
906 | ||
907 | wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const; | |
908 | int GetChildCount( const wxDataViewItem& parent ) const; | |
b5ec7dd6 | 909 | |
e94d0c1e RR |
910 | void SetItemText( const wxDataViewItem& item, const wxString &text ); |
911 | wxString GetItemText( const wxDataViewItem& item ) const; | |
b5ec7dd6 | 912 | void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon ); |
e94d0c1e RR |
913 | const wxIcon &GetItemIcon( const wxDataViewItem& item ) const; |
914 | void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon ); | |
915 | const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const; | |
916 | void SetItemData( const wxDataViewItem& item, wxClientData *data ); | |
917 | wxClientData *GetItemData( const wxDataViewItem& item ) const; | |
918 | ||
919 | void DeleteItem( const wxDataViewItem& item ); | |
920 | void DeleteChildren( const wxDataViewItem& item ); | |
921 | void DeleteAllItems(); | |
b5ec7dd6 | 922 | |
e94d0c1e RR |
923 | // implement base methods |
924 | ||
b5ec7dd6 | 925 | virtual void GetValue( wxVariant &variant, |
e94d0c1e | 926 | const wxDataViewItem &item, unsigned int col ) const; |
b5ec7dd6 | 927 | virtual bool SetValue( const wxVariant &variant, |
e94d0c1e RR |
928 | const wxDataViewItem &item, unsigned int col ); |
929 | virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const; | |
930 | virtual bool IsContainer( const wxDataViewItem &item ) const; | |
931 | virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const; | |
932 | ||
b5ec7dd6 | 933 | virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, |
e94d0c1e | 934 | unsigned int column, bool ascending ); |
b5ec7dd6 VZ |
935 | |
936 | virtual bool HasDefaultCompare() const | |
e94d0c1e | 937 | { return true; } |
b5ec7dd6 | 938 | virtual unsigned int GetColumnCount() const |
e94d0c1e | 939 | { return 1; }; |
b5ec7dd6 | 940 | virtual wxString GetColumnType( unsigned int WXUNUSED(col) ) const |
594d5596 | 941 | { return wxT("wxDataViewIconText"); } |
b5ec7dd6 | 942 | |
e94d0c1e RR |
943 | wxDataViewTreeStoreNode *FindNode( const wxDataViewItem &item ) const; |
944 | wxDataViewTreeStoreContainerNode *FindContainerNode( const wxDataViewItem &item ) const; | |
945 | wxDataViewTreeStoreNode *GetRoot() const { return m_root; } | |
b5ec7dd6 | 946 | |
e94d0c1e RR |
947 | public: |
948 | wxDataViewTreeStoreNode *m_root; | |
949 | }; | |
950 | ||
e94d0c1e RR |
951 | class WXDLLIMPEXP_ADV wxDataViewTreeCtrl: public wxDataViewCtrl |
952 | { | |
953 | public: | |
a75124d0 RR |
954 | wxDataViewTreeCtrl(); |
955 | wxDataViewTreeCtrl( wxWindow *parent, wxWindowID id, | |
e94d0c1e | 956 | const wxPoint& pos = wxDefaultPosition, |
1a07a730 | 957 | const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER | wxDV_ROW_LINES, |
e94d0c1e | 958 | const wxValidator& validator = wxDefaultValidator ); |
a75124d0 | 959 | ~wxDataViewTreeCtrl(); |
e94d0c1e RR |
960 | |
961 | bool Create( wxWindow *parent, wxWindowID id, | |
962 | const wxPoint& pos = wxDefaultPosition, | |
1a07a730 | 963 | const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER | wxDV_ROW_LINES, |
e94d0c1e RR |
964 | const wxValidator& validator = wxDefaultValidator ); |
965 | ||
966 | wxDataViewTreeStore *GetStore() | |
967 | { return (wxDataViewTreeStore*) GetModel(); } | |
a75124d0 RR |
968 | const wxDataViewTreeStore *GetStore() const |
969 | { return (const wxDataViewTreeStore*) GetModel(); } | |
b5ec7dd6 | 970 | |
a75124d0 RR |
971 | void SetImageList( wxImageList *imagelist ); |
972 | wxImageList* GetImageList() { return m_imageList; } | |
973 | ||
974 | wxDataViewItem AppendItem( const wxDataViewItem& parent, | |
975 | const wxString &text, int icon = -1, wxClientData *data = NULL ); | |
976 | wxDataViewItem PrependItem( const wxDataViewItem& parent, | |
977 | const wxString &text, int icon = -1, wxClientData *data = NULL ); | |
978 | wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous, | |
979 | const wxString &text, int icon = -1, wxClientData *data = NULL ); | |
980 | ||
981 | wxDataViewItem PrependContainer( const wxDataViewItem& parent, | |
982 | const wxString &text, int icon = -1, int expanded = -1, | |
983 | wxClientData *data = NULL ); | |
984 | wxDataViewItem AppendContainer( const wxDataViewItem& parent, | |
985 | const wxString &text, int icon = -1, int expanded = -1, | |
986 | wxClientData *data = NULL ); | |
987 | wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous, | |
988 | const wxString &text, int icon = -1, int expanded = -1, | |
989 | wxClientData *data = NULL ); | |
990 | ||
991 | wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const | |
992 | { return GetStore()->GetNthChild(parent, pos); } | |
993 | int GetChildCount( const wxDataViewItem& parent ) const | |
994 | { return GetStore()->GetChildCount(parent); } | |
995 | ||
996 | void SetItemText( const wxDataViewItem& item, const wxString &text ) | |
997 | { GetStore()->SetItemText(item,text); } | |
998 | wxString GetItemText( const wxDataViewItem& item ) const | |
999 | { return GetStore()->GetItemText(item); } | |
1000 | void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon ) | |
1001 | { GetStore()->SetItemIcon(item,icon); } | |
1002 | const wxIcon &GetItemIcon( const wxDataViewItem& item ) const | |
1003 | { return GetStore()->GetItemIcon(item); } | |
1004 | void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon ) | |
1005 | { GetStore()->SetItemExpandedIcon(item,icon); } | |
1006 | const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const | |
1007 | { return GetStore()->GetItemExpandedIcon(item); } | |
1008 | void SetItemData( const wxDataViewItem& item, wxClientData *data ) | |
1009 | { GetStore()->SetItemData(item,data); } | |
1010 | wxClientData *GetItemData( const wxDataViewItem& item ) const | |
1011 | { return GetStore()->GetItemData(item); } | |
1012 | ||
1013 | void DeleteItem( const wxDataViewItem& item ) | |
1014 | { GetStore()->DeleteItem(item); } | |
1015 | void DeleteChildren( const wxDataViewItem& item ) | |
1016 | { GetStore()->DeleteChildren(item); } | |
1017 | void DeleteAllItems() | |
1018 | { GetStore()->DeleteAllItems(); } | |
1019 | ||
1020 | void OnExpanded( wxDataViewEvent &event ); | |
1021 | void OnCollapsed( wxDataViewEvent &event ); | |
1a07a730 | 1022 | void OnSize( wxSizeEvent &event ); |
b5ec7dd6 | 1023 | |
e94d0c1e | 1024 | private: |
a75124d0 RR |
1025 | wxImageList *m_imageList; |
1026 | ||
1027 | private: | |
1028 | DECLARE_EVENT_TABLE() | |
e94d0c1e RR |
1029 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl) |
1030 | }; | |
e94d0c1e | 1031 | |
bcd846ea RR |
1032 | #endif // wxUSE_DATAVIEWCTRL |
1033 | ||
1034 | #endif | |
1035 | // _WX_DATAVIEW_H_BASE_ |