]>
Commit | Line | Data |
---|---|---|
239eaa41 RR |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: src/common/datavcmn.cpp | |
3 | // Purpose: wxDataViewCtrl base classes and common parts | |
4 | // Author: Robert Roebling | |
5 | // Created: 2006/02/20 | |
6 | // RCS-ID: $Id$ | |
7 | // Copyright: (c) 2006, Robert Roebling | |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | // For compilers that support precompilation, includes "wx.h". | |
12 | #include "wx/wxprec.h" | |
13 | ||
14 | #ifdef __BORLANDC__ | |
15 | #pragma hdrstop | |
16 | #endif | |
17 | ||
8045736e RR |
18 | #if wxUSE_DATAVIEWCTRL |
19 | ||
e7445ff8 PC |
20 | #include "wx/dataview.h" |
21 | ||
f554a14b | 22 | #ifndef WX_PRECOMP |
f554a14b WS |
23 | #include "wx/log.h" |
24 | #endif | |
25 | ||
4a2e5ee8 | 26 | const wxChar wxDataViewCtrlNameStr[] = wxT("dataviewCtrl"); |
239eaa41 | 27 | |
239eaa41 | 28 | |
f554a14b | 29 | // --------------------------------------------------------- |
239eaa41 | 30 | // wxDataViewListModel |
f554a14b | 31 | // --------------------------------------------------------- |
239eaa41 | 32 | |
239eaa41 RR |
33 | wxDataViewListModel::wxDataViewListModel() |
34 | { | |
b5d777c7 | 35 | m_viewingColumns.DeleteContents( true ); |
8f850e28 | 36 | m_notifiers.DeleteContents( true ); |
239eaa41 RR |
37 | } |
38 | ||
39 | wxDataViewListModel::~wxDataViewListModel() | |
40 | { | |
87f0efe2 RR |
41 | wxList::compatibility_iterator node = m_notifiers.GetFirst(); |
42 | while (node) | |
43 | { | |
44 | wxDataViewListModelNotifier* notifier = (wxDataViewListModelNotifier*) node->GetData(); | |
45 | notifier->Freed(); | |
46 | node = node->GetNext(); | |
47 | } | |
239eaa41 RR |
48 | } |
49 | ||
50 | bool wxDataViewListModel::RowAppended() | |
51 | { | |
8f850e28 RR |
52 | bool ret = true; |
53 | ||
85e5bb6a | 54 | wxList::compatibility_iterator node = m_notifiers.GetFirst(); |
8f850e28 RR |
55 | while (node) |
56 | { | |
57 | wxDataViewListModelNotifier* notifier = (wxDataViewListModelNotifier*) node->GetData(); | |
58 | if (!notifier->RowAppended()) | |
59 | ret = false; | |
60 | node = node->GetNext(); | |
61 | } | |
f554a14b | 62 | |
8f850e28 | 63 | return ret; |
239eaa41 RR |
64 | } |
65 | ||
66 | bool wxDataViewListModel::RowPrepended() | |
67 | { | |
8f850e28 RR |
68 | bool ret = true; |
69 | ||
85e5bb6a | 70 | wxList::compatibility_iterator node = m_notifiers.GetFirst(); |
8f850e28 RR |
71 | while (node) |
72 | { | |
73 | wxDataViewListModelNotifier* notifier = (wxDataViewListModelNotifier*) node->GetData(); | |
74 | if (!notifier->RowPrepended()) | |
75 | ret = false; | |
76 | node = node->GetNext(); | |
77 | } | |
f554a14b | 78 | |
8f850e28 | 79 | return ret; |
239eaa41 RR |
80 | } |
81 | ||
0a71f9e9 | 82 | bool wxDataViewListModel::RowInserted( unsigned int before ) |
239eaa41 | 83 | { |
8f850e28 RR |
84 | bool ret = true; |
85 | ||
85e5bb6a | 86 | wxList::compatibility_iterator node = m_notifiers.GetFirst(); |
8f850e28 RR |
87 | while (node) |
88 | { | |
89 | wxDataViewListModelNotifier* notifier = (wxDataViewListModelNotifier*) node->GetData(); | |
90 | if (!notifier->RowInserted(before)) | |
91 | ret = false; | |
92 | node = node->GetNext(); | |
93 | } | |
f554a14b | 94 | |
8f850e28 | 95 | return ret; |
239eaa41 RR |
96 | } |
97 | ||
0a71f9e9 | 98 | bool wxDataViewListModel::RowDeleted( unsigned int row ) |
239eaa41 | 99 | { |
8f850e28 RR |
100 | bool ret = true; |
101 | ||
85e5bb6a | 102 | wxList::compatibility_iterator node = m_notifiers.GetFirst(); |
8f850e28 RR |
103 | while (node) |
104 | { | |
105 | wxDataViewListModelNotifier* notifier = (wxDataViewListModelNotifier*) node->GetData(); | |
106 | if (!notifier->RowDeleted( row )) | |
107 | ret = false; | |
108 | node = node->GetNext(); | |
109 | } | |
f554a14b | 110 | |
8f850e28 | 111 | return ret; |
239eaa41 RR |
112 | } |
113 | ||
0a71f9e9 | 114 | bool wxDataViewListModel::RowChanged( unsigned int row ) |
239eaa41 | 115 | { |
8f850e28 RR |
116 | bool ret = true; |
117 | ||
85e5bb6a | 118 | wxList::compatibility_iterator node = m_notifiers.GetFirst(); |
8f850e28 RR |
119 | while (node) |
120 | { | |
121 | wxDataViewListModelNotifier* notifier = (wxDataViewListModelNotifier*) node->GetData(); | |
122 | if (!notifier->RowChanged( row )) | |
123 | ret = false; | |
124 | node = node->GetNext(); | |
125 | } | |
f554a14b | 126 | |
8f850e28 | 127 | return ret; |
239eaa41 RR |
128 | } |
129 | ||
0a71f9e9 | 130 | bool wxDataViewListModel::ValueChanged( unsigned int col, unsigned int row ) |
239eaa41 | 131 | { |
8f850e28 | 132 | bool ret = true; |
b5d777c7 | 133 | |
85e5bb6a | 134 | wxList::compatibility_iterator node = m_notifiers.GetFirst(); |
b5d777c7 RR |
135 | while (node) |
136 | { | |
8f850e28 RR |
137 | wxDataViewListModelNotifier* notifier = (wxDataViewListModelNotifier*) node->GetData(); |
138 | if (!notifier->ValueChanged( col, row )) | |
139 | ret = false; | |
b5d777c7 RR |
140 | node = node->GetNext(); |
141 | } | |
f554a14b | 142 | |
b5d777c7 | 143 | return ret; |
239eaa41 RR |
144 | } |
145 | ||
0a71f9e9 | 146 | bool wxDataViewListModel::RowsReordered( unsigned int *new_order ) |
4eccd3a1 RR |
147 | { |
148 | bool ret = true; | |
149 | ||
85e5bb6a | 150 | wxList::compatibility_iterator node = m_notifiers.GetFirst(); |
4eccd3a1 RR |
151 | while (node) |
152 | { | |
153 | wxDataViewListModelNotifier* notifier = (wxDataViewListModelNotifier*) node->GetData(); | |
154 | if (!notifier->RowsReordered( new_order )) | |
155 | ret = false; | |
156 | node = node->GetNext(); | |
157 | } | |
f554a14b | 158 | |
4eccd3a1 RR |
159 | return ret; |
160 | } | |
161 | ||
239eaa41 RR |
162 | bool wxDataViewListModel::Cleared() |
163 | { | |
8f850e28 RR |
164 | bool ret = true; |
165 | ||
85e5bb6a | 166 | wxList::compatibility_iterator node = m_notifiers.GetFirst(); |
8f850e28 RR |
167 | while (node) |
168 | { | |
169 | wxDataViewListModelNotifier* notifier = (wxDataViewListModelNotifier*) node->GetData(); | |
170 | if (!notifier->Cleared()) | |
171 | ret = false; | |
172 | node = node->GetNext(); | |
173 | } | |
f554a14b | 174 | |
8f850e28 | 175 | return ret; |
239eaa41 RR |
176 | } |
177 | ||
0a71f9e9 | 178 | void wxDataViewListModel::AddViewingColumn( wxDataViewColumn *view_column, unsigned int model_column ) |
b5d777c7 RR |
179 | { |
180 | m_viewingColumns.Append( new wxDataViewViewingColumn( view_column, model_column ) ); | |
181 | } | |
182 | ||
183 | void wxDataViewListModel::RemoveViewingColumn( wxDataViewColumn *column ) | |
184 | { | |
85e5bb6a | 185 | wxList::compatibility_iterator node = m_viewingColumns.GetFirst(); |
b5d777c7 RR |
186 | while (node) |
187 | { | |
188 | wxDataViewViewingColumn* tmp = (wxDataViewViewingColumn*) node->GetData(); | |
f554a14b | 189 | |
b5d777c7 RR |
190 | if (tmp->m_viewColumn == column) |
191 | { | |
192 | m_viewingColumns.DeleteObject( tmp ); | |
193 | return; | |
194 | } | |
f554a14b | 195 | |
b5d777c7 RR |
196 | node = node->GetNext(); |
197 | } | |
198 | } | |
199 | ||
8f850e28 | 200 | void wxDataViewListModel::AddNotifier( wxDataViewListModelNotifier *notifier ) |
239eaa41 | 201 | { |
8f850e28 RR |
202 | m_notifiers.Append( notifier ); |
203 | notifier->SetOwner( this ); | |
239eaa41 RR |
204 | } |
205 | ||
8f850e28 | 206 | void wxDataViewListModel::RemoveNotifier( wxDataViewListModelNotifier *notifier ) |
239eaa41 | 207 | { |
8f850e28 | 208 | m_notifiers.DeleteObject( notifier ); |
239eaa41 RR |
209 | } |
210 | ||
f554a14b | 211 | // --------------------------------------------------------- |
4eccd3a1 | 212 | // wxDataViewSortedListModelNotifier |
f554a14b | 213 | // --------------------------------------------------------- |
4eccd3a1 RR |
214 | |
215 | class wxDataViewSortedListModelNotifier: public wxDataViewListModelNotifier | |
216 | { | |
217 | public: | |
218 | wxDataViewSortedListModelNotifier( wxDataViewSortedListModel *model ) | |
4627af27 RR |
219 | { m_model = model; } |
220 | ||
221 | virtual bool RowAppended() | |
222 | { return m_model->ChildRowAppended(); } | |
9969fdfe | 223 | |
4627af27 RR |
224 | virtual bool RowPrepended() |
225 | { return m_model->ChildRowPrepended(); } | |
9969fdfe | 226 | |
0a71f9e9 | 227 | virtual bool RowInserted( unsigned int before ) |
4627af27 | 228 | { return m_model->ChildRowInserted( before ); } |
9969fdfe | 229 | |
0a71f9e9 | 230 | virtual bool RowDeleted( unsigned int row ) |
4627af27 | 231 | { return m_model->ChildRowDeleted( row ); } |
9969fdfe | 232 | |
0a71f9e9 | 233 | virtual bool RowChanged( unsigned int row ) |
4627af27 | 234 | { return m_model->ChildRowChanged( row ); } |
9969fdfe | 235 | |
0a71f9e9 | 236 | virtual bool ValueChanged( unsigned int col, unsigned int row ) |
4627af27 | 237 | { return m_model->ChildValueChanged( col, row); } |
9969fdfe | 238 | |
0a71f9e9 | 239 | virtual bool RowsReordered( unsigned int *new_order ) |
9969fdfe WS |
240 | { return m_model->ChildRowsReordered( new_order ); } |
241 | ||
4627af27 RR |
242 | virtual bool Cleared() |
243 | { return m_model->ChildCleared(); } | |
f554a14b | 244 | |
87f0efe2 RR |
245 | virtual bool Freed() |
246 | { m_model->m_child = NULL; return wxDataViewListModelNotifier::Freed(); } | |
247 | ||
4eccd3a1 RR |
248 | wxDataViewSortedListModel *m_model; |
249 | }; | |
250 | ||
f554a14b | 251 | // --------------------------------------------------------- |
4eccd3a1 | 252 | // wxDataViewSortedListModel compare function |
f554a14b | 253 | // --------------------------------------------------------- |
8981608c RR |
254 | |
255 | int wxCALLBACK wxDataViewListModelSortedDefaultCompare | |
0a71f9e9 | 256 | (unsigned int row1, unsigned int row2, unsigned int col, wxDataViewListModel* model ) |
8981608c | 257 | { |
3f3af7e7 RR |
258 | wxVariant value1,value2; |
259 | model->GetValue( value1, col, row1 ); | |
260 | model->GetValue( value2, col, row2 ); | |
8981608c RR |
261 | if (value1.GetType() == wxT("string")) |
262 | { | |
263 | wxString str1 = value1.GetString(); | |
264 | wxString str2 = value2.GetString(); | |
265 | return str1.Cmp( str2 ); | |
266 | } | |
267 | if (value1.GetType() == wxT("long")) | |
268 | { | |
269 | long l1 = value1.GetLong(); | |
270 | long l2 = value2.GetLong(); | |
271 | return l1-l2; | |
272 | } | |
273 | if (value1.GetType() == wxT("double")) | |
274 | { | |
275 | double d1 = value1.GetDouble(); | |
276 | double d2 = value2.GetDouble(); | |
277 | if (d1 == d2) return 0; | |
278 | if (d1 < d2) return 1; | |
279 | return -1; | |
280 | } | |
281 | if (value1.GetType() == wxT("datetime")) | |
282 | { | |
283 | wxDateTime dt1 = value1.GetDateTime(); | |
284 | wxDateTime dt2 = value2.GetDateTime(); | |
285 | if (dt1.IsEqualTo(dt2)) return 0; | |
286 | if (dt1.IsEarlierThan(dt2)) return 1; | |
287 | return -1; | |
288 | } | |
289 | ||
290 | return 0; | |
291 | } | |
292 | ||
31fb32e1 RR |
293 | int wxCALLBACK wxDataViewListModelSortedDefaultCompareDescending |
294 | (unsigned int row1, unsigned int row2, unsigned int col, wxDataViewListModel* model ) | |
295 | { | |
296 | return wxDataViewListModelSortedDefaultCompare( row2, row1, col, model ); | |
297 | } | |
298 | ||
8981608c RR |
299 | static wxDataViewListModelCompare s_CmpFunc; |
300 | static wxDataViewListModel *s_CmpModel; | |
31fb32e1 | 301 | static unsigned int s_CmpCol; |
8981608c | 302 | |
0a71f9e9 | 303 | int LINKAGEMODE wxDataViewIntermediateCmp( unsigned int row1, unsigned int row2 ) |
8981608c RR |
304 | { |
305 | return s_CmpFunc( row1, row2, s_CmpCol, s_CmpModel ); | |
306 | } | |
307 | ||
f554a14b | 308 | // --------------------------------------------------------- |
4eccd3a1 RR |
309 | // wxDataViewSortedListModel |
310 | // --------------------------------------------------------- | |
8981608c | 311 | |
8981608c RR |
312 | wxDataViewSortedListModel::wxDataViewSortedListModel( wxDataViewListModel *child ) : |
313 | m_array( wxDataViewIntermediateCmp ) | |
314 | { | |
315 | m_child = child; | |
31fb32e1 RR |
316 | |
317 | m_ascending = true; | |
f554a14b | 318 | |
4eccd3a1 RR |
319 | m_notifierOnChild = new wxDataViewSortedListModelNotifier( this ); |
320 | m_child->AddNotifier( m_notifierOnChild ); | |
f554a14b WS |
321 | |
322 | Resort(); | |
8981608c RR |
323 | } |
324 | ||
325 | wxDataViewSortedListModel::~wxDataViewSortedListModel() | |
326 | { | |
87f0efe2 | 327 | if (m_child) |
4eccd3a1 | 328 | m_child->RemoveNotifier( m_notifierOnChild ); |
8981608c RR |
329 | } |
330 | ||
31fb32e1 RR |
331 | // FIXME |
332 | void wxDataViewSortedListModel::InitStatics() | |
333 | { | |
334 | s_CmpCol = 0; | |
335 | s_CmpModel = m_child; | |
336 | if (m_ascending) | |
337 | s_CmpFunc = wxDataViewListModelSortedDefaultCompare; | |
338 | else | |
339 | s_CmpFunc = wxDataViewListModelSortedDefaultCompareDescending; | |
340 | } | |
341 | ||
8f850e28 RR |
342 | void wxDataViewSortedListModel::Resort() |
343 | { | |
31fb32e1 RR |
344 | InitStatics(); |
345 | ||
8f850e28 | 346 | m_array.Clear(); |
9861f022 | 347 | unsigned int n = m_child->GetRowCount(); |
0a71f9e9 | 348 | unsigned int i; |
8f850e28 RR |
349 | for (i = 0; i < n; i++) |
350 | m_array.Add( i ); | |
c3112d56 RR |
351 | |
352 | // do we need the neworder? | |
353 | wxDataViewListModel::RowsReordered( NULL ); | |
8f850e28 RR |
354 | } |
355 | ||
3f3af7e7 | 356 | #if 0 |
0a71f9e9 | 357 | static void Dump( wxDataViewListModel *model, unsigned int col ) |
3f3af7e7 | 358 | { |
9861f022 | 359 | unsigned int n = model->GetRowCount(); |
0a71f9e9 | 360 | unsigned int i; |
3f3af7e7 RR |
361 | for (i = 0; i < n; i++) |
362 | { | |
363 | wxVariant variant; | |
364 | model->GetValue( variant, col, i ); | |
365 | wxString tmp; | |
366 | tmp = variant.GetString(); | |
367 | wxPrintf( wxT("%d: %s\n"), (int) i, tmp.c_str() ); | |
368 | } | |
369 | } | |
370 | #endif | |
371 | ||
4627af27 RR |
372 | bool wxDataViewSortedListModel::ChildRowAppended() |
373 | { | |
374 | // no need to fix up array | |
9969fdfe | 375 | |
0a71f9e9 | 376 | unsigned int len = m_array.GetCount(); |
9969fdfe | 377 | |
0a71f9e9 | 378 | unsigned int pos = m_array.Add( len ); |
9969fdfe | 379 | |
4627af27 RR |
380 | if (pos == 0) |
381 | return wxDataViewListModel::RowPrepended(); | |
9969fdfe | 382 | |
4627af27 RR |
383 | if (pos == len) |
384 | return wxDataViewListModel::RowAppended(); | |
9969fdfe | 385 | |
4627af27 RR |
386 | return wxDataViewListModel::RowInserted( pos ); |
387 | } | |
388 | ||
389 | bool wxDataViewSortedListModel::ChildRowPrepended() | |
390 | { | |
391 | // fix up array | |
0a71f9e9 RR |
392 | unsigned int i; |
393 | unsigned int len = m_array.GetCount(); | |
4627af27 RR |
394 | for (i = 0; i < len; i++) |
395 | { | |
0a71f9e9 | 396 | unsigned int value = m_array[i]; |
4627af27 RR |
397 | m_array[i] = value+1; |
398 | } | |
9969fdfe | 399 | |
0a71f9e9 | 400 | unsigned int pos = m_array.Add( 0 ); |
9969fdfe | 401 | |
4627af27 RR |
402 | if (pos == 0) |
403 | return wxDataViewListModel::RowPrepended(); | |
9969fdfe | 404 | |
4627af27 RR |
405 | if (pos == len) |
406 | return wxDataViewListModel::RowAppended(); | |
9969fdfe | 407 | |
4627af27 RR |
408 | return wxDataViewListModel::RowInserted( pos ); |
409 | } | |
410 | ||
0a71f9e9 | 411 | bool wxDataViewSortedListModel::ChildRowInserted( unsigned int before ) |
4627af27 RR |
412 | { |
413 | // fix up array | |
0a71f9e9 RR |
414 | unsigned int i; |
415 | unsigned int len = m_array.GetCount(); | |
4627af27 RR |
416 | for (i = 0; i < len; i++) |
417 | { | |
0a71f9e9 | 418 | unsigned int value = m_array[i]; |
4627af27 RR |
419 | if (value >= before) |
420 | m_array[i] = value+1; | |
421 | } | |
9969fdfe | 422 | |
0a71f9e9 | 423 | unsigned int pos = m_array.Add( before ); |
9969fdfe | 424 | |
4627af27 RR |
425 | if (pos == 0) |
426 | return wxDataViewListModel::RowPrepended(); | |
9969fdfe | 427 | |
4627af27 RR |
428 | if (pos == len) |
429 | return wxDataViewListModel::RowAppended(); | |
9969fdfe | 430 | |
4627af27 RR |
431 | return wxDataViewListModel::RowInserted( pos ); |
432 | } | |
433 | ||
0a71f9e9 | 434 | bool wxDataViewSortedListModel::ChildRowDeleted( unsigned int row ) |
4627af27 | 435 | { |
0a71f9e9 RR |
436 | unsigned int i; |
437 | unsigned int len = m_array.GetCount(); | |
4627af27 RR |
438 | int pos = -1; |
439 | for (i = 0; i < len; i++) | |
440 | { | |
0a71f9e9 | 441 | unsigned int value = m_array[i]; |
4627af27 RR |
442 | if (value == row) |
443 | { | |
444 | // delete later | |
445 | pos = (int) i; | |
446 | } | |
447 | else | |
448 | { | |
449 | // Fix up array | |
450 | if (value > row) | |
451 | m_array[i] = value-1; | |
452 | } | |
453 | } | |
9969fdfe | 454 | |
4627af27 RR |
455 | if (pos == -1) |
456 | return false; // we should probably assert | |
457 | ||
9969fdfe | 458 | // remove |
0a71f9e9 | 459 | m_array.RemoveAt( (unsigned int) pos ); |
4627af27 | 460 | |
0a71f9e9 | 461 | return wxDataViewListModel::RowDeleted( (unsigned int) pos); |
4627af27 RR |
462 | } |
463 | ||
0a71f9e9 | 464 | bool wxDataViewSortedListModel::ChildRowChanged( unsigned int row ) |
4627af27 | 465 | { |
0a71f9e9 RR |
466 | unsigned int i; |
467 | unsigned int len = m_array.GetCount(); | |
4627af27 RR |
468 | |
469 | // Remove and readd sorted. Find out at which | |
470 | // position it was and where it ended. | |
0a71f9e9 | 471 | unsigned int start_pos = 0,end_pos = 0; |
4627af27 RR |
472 | for (i = 0; i < len; i++) |
473 | if (m_array[i] == row) | |
474 | { | |
475 | start_pos = i; | |
476 | break; | |
477 | } | |
478 | m_array.RemoveAt( start_pos ); | |
479 | m_array.Add( row ); | |
480 | ||
481 | for (i = 0; i < len; i++) | |
482 | if (m_array[i] == row) | |
483 | { | |
484 | end_pos = i; | |
485 | break; | |
486 | } | |
487 | ||
488 | if (end_pos == start_pos) | |
489 | return wxDataViewListModel::RowChanged( start_pos ); | |
490 | ||
491 | // Create an array where order[old] -> new_pos, so that | |
492 | // if nothing changed order[0] -> 0 etc. | |
0a71f9e9 | 493 | unsigned int *order = new unsigned int[ len ]; |
4627af27 RR |
494 | // Fill up initial values. |
495 | for (i = 0; i < len; i++) | |
496 | order[i] = i; | |
497 | ||
498 | if (start_pos < end_pos) | |
499 | { | |
500 | for (i = start_pos; i < end_pos; i++) | |
501 | order[i] = order[i+1]; | |
502 | order[end_pos] = start_pos; | |
503 | } | |
504 | else | |
505 | { | |
506 | for (i = end_pos; i > start_pos; i--) | |
507 | order[i] = order[i-1]; | |
508 | order[start_pos] = end_pos; | |
509 | } | |
510 | ||
511 | wxDataViewListModel::RowsReordered( order ); | |
512 | ||
513 | delete [] order; | |
514 | ||
515 | return true; | |
516 | } | |
517 | ||
0a71f9e9 | 518 | bool wxDataViewSortedListModel::ChildValueChanged( unsigned int col, unsigned int row ) |
4eccd3a1 | 519 | { |
0a71f9e9 RR |
520 | unsigned int i; |
521 | unsigned int len = m_array.GetCount(); | |
f554a14b | 522 | |
4eccd3a1 RR |
523 | // Remove and readd sorted. Find out at which |
524 | // position it was and where it ended. | |
0a71f9e9 | 525 | unsigned int start_pos = 0,end_pos = 0; |
4eccd3a1 RR |
526 | for (i = 0; i < len; i++) |
527 | if (m_array[i] == row) | |
528 | { | |
529 | start_pos = i; | |
530 | break; | |
531 | } | |
3f3af7e7 | 532 | m_array.RemoveAt( start_pos ); |
4eccd3a1 | 533 | m_array.Add( row ); |
f554a14b | 534 | |
4eccd3a1 RR |
535 | for (i = 0; i < len; i++) |
536 | if (m_array[i] == row) | |
537 | { | |
538 | end_pos = i; | |
539 | break; | |
540 | } | |
f554a14b | 541 | |
4eccd3a1 RR |
542 | if (end_pos == start_pos) |
543 | return wxDataViewListModel::ValueChanged( col, start_pos ); | |
f554a14b | 544 | |
4eccd3a1 RR |
545 | // Create an array where order[old] -> new_pos, so that |
546 | // if nothing changed order[0] -> 0 etc. | |
0a71f9e9 | 547 | unsigned int *order = new unsigned int[ len ]; |
4eccd3a1 RR |
548 | // Fill up initial values. |
549 | for (i = 0; i < len; i++) | |
550 | order[i] = i; | |
551 | ||
552 | if (start_pos < end_pos) | |
553 | { | |
554 | for (i = start_pos; i < end_pos; i++) | |
555 | order[i] = order[i+1]; | |
556 | order[end_pos] = start_pos; | |
557 | } | |
558 | else | |
559 | { | |
560 | for (i = end_pos; i > start_pos; i--) | |
561 | order[i] = order[i-1]; | |
562 | order[start_pos] = end_pos; | |
f554a14b WS |
563 | } |
564 | ||
3f3af7e7 | 565 | wxDataViewListModel::RowsReordered( order ); |
f554a14b | 566 | |
4eccd3a1 | 567 | delete [] order; |
f554a14b | 568 | |
4eccd3a1 RR |
569 | return true; |
570 | } | |
571 | ||
0a71f9e9 | 572 | bool wxDataViewSortedListModel::ChildRowsReordered( unsigned int *WXUNUSED(new_order) ) |
4627af27 RR |
573 | { |
574 | // Nothing needs to be done. If the sort criteria | |
575 | // of this list don't change, the order of the | |
576 | // items of the child list isn't relevant. | |
577 | return true; | |
578 | } | |
579 | ||
580 | bool wxDataViewSortedListModel::ChildCleared() | |
581 | { | |
582 | return wxDataViewListModel::Cleared(); | |
583 | } | |
584 | ||
9861f022 | 585 | unsigned int wxDataViewSortedListModel::GetRowCount() const |
8981608c | 586 | { |
3f3af7e7 | 587 | return m_array.GetCount(); |
8981608c RR |
588 | } |
589 | ||
9861f022 | 590 | unsigned int wxDataViewSortedListModel::GetColumnCount() const |
8981608c | 591 | { |
9861f022 | 592 | return m_child->GetColumnCount(); |
8981608c RR |
593 | } |
594 | ||
9861f022 | 595 | wxString wxDataViewSortedListModel::GetColumnType( unsigned int col ) const |
8981608c | 596 | { |
9861f022 | 597 | return m_child->GetColumnType( col ); |
8981608c RR |
598 | } |
599 | ||
9861f022 | 600 | void wxDataViewSortedListModel::GetValue( wxVariant &variant, unsigned int col, unsigned int row ) const |
8981608c | 601 | { |
0a71f9e9 | 602 | unsigned int child_row = m_array[row]; |
3f3af7e7 | 603 | m_child->GetValue( variant, col, child_row ); |
8981608c RR |
604 | } |
605 | ||
2fa73716 | 606 | bool wxDataViewSortedListModel::SetValue( const wxVariant &variant, unsigned int col, unsigned int row ) |
8981608c | 607 | { |
0a71f9e9 | 608 | unsigned int child_row = m_array[row]; |
8981608c | 609 | bool ret = m_child->SetValue( variant, col, child_row ); |
f554a14b | 610 | |
4627af27 RR |
611 | // Do nothing here as the change in the |
612 | // child model will be reported back. | |
f554a14b | 613 | |
8981608c RR |
614 | return ret; |
615 | } | |
616 | ||
617 | bool wxDataViewSortedListModel::RowAppended() | |
618 | { | |
619 | // you can only append | |
620 | bool ret = m_child->RowAppended(); | |
f554a14b | 621 | |
4627af27 RR |
622 | // Do nothing here as the change in the |
623 | // child model will be reported back. | |
f554a14b | 624 | |
8981608c RR |
625 | return ret; |
626 | } | |
627 | ||
628 | bool wxDataViewSortedListModel::RowPrepended() | |
629 | { | |
630 | // you can only append | |
631 | bool ret = m_child->RowAppended(); | |
f554a14b | 632 | |
4627af27 RR |
633 | // Do nothing here as the change in the |
634 | // child model will be reported back. | |
f554a14b | 635 | |
8981608c RR |
636 | return ret; |
637 | } | |
638 | ||
0a71f9e9 | 639 | bool wxDataViewSortedListModel::RowInserted( unsigned int WXUNUSED(before) ) |
8981608c RR |
640 | { |
641 | // you can only append | |
642 | bool ret = m_child->RowAppended(); | |
f554a14b | 643 | |
4627af27 RR |
644 | // Do nothing here as the change in the |
645 | // child model will be reported back. | |
f554a14b | 646 | |
8981608c RR |
647 | return ret; |
648 | } | |
649 | ||
0a71f9e9 | 650 | bool wxDataViewSortedListModel::RowDeleted( unsigned int row ) |
8981608c | 651 | { |
0a71f9e9 | 652 | unsigned int child_row = m_array[row]; |
f554a14b | 653 | |
8981608c | 654 | bool ret = m_child->RowDeleted( child_row ); |
f554a14b | 655 | |
4eccd3a1 RR |
656 | // Do nothing here as the change in the |
657 | // child model will be reported back. | |
f554a14b | 658 | |
8981608c RR |
659 | return ret; |
660 | } | |
661 | ||
0a71f9e9 | 662 | bool wxDataViewSortedListModel::RowChanged( unsigned int row ) |
8981608c | 663 | { |
0a71f9e9 | 664 | unsigned int child_row = m_array[row]; |
8981608c | 665 | bool ret = m_child->RowChanged( child_row ); |
f554a14b | 666 | |
4eccd3a1 RR |
667 | // Do nothing here as the change in the |
668 | // child model will be reported back. | |
f554a14b | 669 | |
8981608c RR |
670 | return ret; |
671 | } | |
672 | ||
0a71f9e9 | 673 | bool wxDataViewSortedListModel::ValueChanged( unsigned int col, unsigned int row ) |
8981608c | 674 | { |
0a71f9e9 | 675 | unsigned int child_row = m_array[row]; |
8981608c | 676 | bool ret = m_child->ValueChanged( col, child_row ); |
f554a14b | 677 | |
4eccd3a1 RR |
678 | // Do nothing here as the change in the |
679 | // child model will be reported back. | |
f554a14b | 680 | |
8981608c RR |
681 | return ret; |
682 | } | |
683 | ||
0a71f9e9 | 684 | bool wxDataViewSortedListModel::RowsReordered( unsigned int *WXUNUSED(new_order) ) |
4eccd3a1 RR |
685 | { |
686 | // We sort them ourselves. | |
687 | ||
688 | return false; | |
689 | } | |
690 | ||
8981608c RR |
691 | bool wxDataViewSortedListModel::Cleared() |
692 | { | |
693 | bool ret = m_child->Cleared(); | |
f554a14b | 694 | |
4627af27 RR |
695 | // Do nothing here as the change in the |
696 | // child model will be reported back. | |
9969fdfe | 697 | |
8981608c RR |
698 | return ret; |
699 | } | |
700 | ||
f554a14b | 701 | // --------------------------------------------------------- |
baa9ebc4 | 702 | // wxDataViewRendererBase |
f554a14b | 703 | // --------------------------------------------------------- |
6842a71a | 704 | |
baa9ebc4 | 705 | IMPLEMENT_ABSTRACT_CLASS(wxDataViewRendererBase, wxObject) |
6842a71a | 706 | |
9861f022 RR |
707 | wxDataViewRendererBase::wxDataViewRendererBase( const wxString &varianttype, |
708 | wxDataViewCellMode WXUNUSED(mode), | |
709 | int WXUNUSED(align) ) | |
6842a71a RR |
710 | { |
711 | m_variantType = varianttype; | |
1e510b1e RR |
712 | m_editorCtrl = NULL; |
713 | m_row = (unsigned int) -1; | |
9861f022 RR |
714 | } |
715 | ||
716 | const wxDataViewCtrl* wxDataViewRendererBase::GetView() const | |
717 | { | |
718 | return wx_const_cast(wxDataViewRendererBase*, this)->GetOwner()->GetOwner(); | |
6842a71a | 719 | } |
f554a14b | 720 | |
1e510b1e RR |
721 | bool wxDataViewRendererBase::StartEditing( unsigned int row, wxRect labelRect ) |
722 | { | |
723 | m_row = row; // remember for later | |
724 | ||
725 | unsigned int col = GetOwner()->GetModelColumn(); | |
726 | wxVariant value; | |
727 | GetOwner()->GetOwner()->GetModel()->GetValue( value, col, row ); | |
728 | ||
729 | m_editorCtrl = CreateEditorCtrl( GetOwner()->GetOwner()->GetMainWindow(), labelRect, value ); | |
730 | ||
30715fa1 RR |
731 | wxDataViewEditorCtrlEvtHandler *handler = |
732 | new wxDataViewEditorCtrlEvtHandler( m_editorCtrl, (wxDataViewRenderer*) this ); | |
733 | ||
734 | m_editorCtrl->PushEventHandler( handler ); | |
1e510b1e | 735 | |
30715fa1 RR |
736 | #if defined(__WXGTK20__) && !defined(wxUSE_GENERICDATAVIEWCTRL) |
737 | handler->SetFocusOnIdle(); | |
738 | #else | |
1e510b1e | 739 | m_editorCtrl->SetFocus(); |
30715fa1 RR |
740 | #endif |
741 | ||
1e510b1e RR |
742 | return true; |
743 | } | |
744 | ||
745 | void wxDataViewRendererBase::CancelEditing() | |
746 | { | |
2fa73716 | 747 | wxPendingDelete.Append( m_editorCtrl ); |
1e510b1e RR |
748 | |
749 | GetOwner()->GetOwner()->GetMainWindow()->SetFocus(); | |
2fa73716 RR |
750 | |
751 | // m_editorCtrl->PopEventHandler( true ); | |
1e510b1e RR |
752 | } |
753 | ||
754 | bool wxDataViewRendererBase::FinishEditing() | |
755 | { | |
1e510b1e RR |
756 | wxVariant value; |
757 | GetValueFromEditorCtrl( m_editorCtrl, value ); | |
758 | ||
2fa73716 | 759 | wxPendingDelete.Append( m_editorCtrl ); |
1e510b1e RR |
760 | |
761 | GetOwner()->GetOwner()->GetMainWindow()->SetFocus(); | |
762 | ||
763 | if (!Validate(value)) | |
764 | return false; | |
765 | ||
766 | unsigned int col = GetOwner()->GetModelColumn(); | |
767 | GetOwner()->GetOwner()->GetModel()->SetValue( value, col, m_row ); | |
768 | GetOwner()->GetOwner()->GetModel()->ValueChanged( col, m_row ); | |
769 | ||
2fa73716 RR |
770 | // m_editorCtrl->PopEventHandler( true ); |
771 | ||
1e510b1e RR |
772 | return true; |
773 | } | |
774 | ||
775 | //----------------------------------------------------------------------------- | |
776 | // wxDataViewEditorCtrlEvtHandler | |
777 | //----------------------------------------------------------------------------- | |
778 | ||
779 | BEGIN_EVENT_TABLE(wxDataViewEditorCtrlEvtHandler, wxEvtHandler) | |
780 | EVT_CHAR (wxDataViewEditorCtrlEvtHandler::OnChar) | |
781 | EVT_KILL_FOCUS (wxDataViewEditorCtrlEvtHandler::OnKillFocus) | |
30715fa1 | 782 | EVT_IDLE (wxDataViewEditorCtrlEvtHandler::OnIdle) |
1e510b1e RR |
783 | END_EVENT_TABLE() |
784 | ||
785 | wxDataViewEditorCtrlEvtHandler::wxDataViewEditorCtrlEvtHandler( | |
786 | wxControl *editorCtrl, | |
787 | wxDataViewRenderer *owner ) | |
788 | { | |
789 | m_owner = owner; | |
790 | m_editorCtrl = editorCtrl; | |
791 | ||
792 | m_finished = false; | |
793 | } | |
794 | ||
30715fa1 RR |
795 | void wxDataViewEditorCtrlEvtHandler::OnIdle( wxIdleEvent &event ) |
796 | { | |
797 | if (m_focusOnIdle) | |
798 | { | |
799 | m_focusOnIdle = false; | |
800 | if (wxWindow::FindFocus() != m_editorCtrl) | |
801 | m_editorCtrl->SetFocus(); | |
802 | } | |
803 | ||
804 | event.Skip(); | |
805 | } | |
806 | ||
1e510b1e RR |
807 | void wxDataViewEditorCtrlEvtHandler::OnChar( wxKeyEvent &event ) |
808 | { | |
809 | switch ( event.m_keyCode ) | |
810 | { | |
811 | case WXK_RETURN: | |
812 | m_finished = true; | |
813 | m_owner->FinishEditing(); | |
814 | break; | |
815 | ||
816 | case WXK_ESCAPE: | |
817 | m_finished = true; | |
818 | m_owner->CancelEditing(); | |
819 | break; | |
820 | ||
821 | default: | |
822 | event.Skip(); | |
823 | } | |
824 | } | |
825 | ||
826 | void wxDataViewEditorCtrlEvtHandler::OnKillFocus( wxFocusEvent &event ) | |
827 | { | |
828 | if (!m_finished) | |
829 | { | |
830 | m_finished = true; | |
831 | m_owner->FinishEditing(); | |
832 | } | |
833 | ||
1e510b1e RR |
834 | event.Skip(); |
835 | } | |
836 | ||
f554a14b | 837 | // --------------------------------------------------------- |
fa28826d | 838 | // wxDataViewColumnBase |
f554a14b | 839 | // --------------------------------------------------------- |
fa28826d RR |
840 | |
841 | IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumnBase, wxObject) | |
842 | ||
9861f022 | 843 | wxDataViewColumnBase::wxDataViewColumnBase(const wxString& WXUNUSED(title), |
baa9ebc4 | 844 | wxDataViewRenderer *renderer, |
0a71f9e9 | 845 | unsigned int model_column, |
008b5a66 | 846 | int WXUNUSED(width), |
87f0efe2 | 847 | wxAlignment WXUNUSED(align), |
9861f022 | 848 | int WXUNUSED(flags)) |
fa28826d | 849 | { |
baa9ebc4 | 850 | m_renderer = renderer; |
6842a71a | 851 | m_model_column = model_column; |
6842a71a | 852 | m_owner = NULL; |
baa9ebc4 | 853 | m_renderer->SetOwner( (wxDataViewColumn*) this ); |
9861f022 RR |
854 | |
855 | // NOTE: the wxDataViewColumn's ctor must store the width, align, flags | |
856 | // parameters inside the native control! | |
6842a71a RR |
857 | } |
858 | ||
07a84e7b RR |
859 | wxDataViewColumnBase::wxDataViewColumnBase(const wxBitmap& bitmap, |
860 | wxDataViewRenderer *renderer, | |
861 | unsigned int model_column, | |
862 | int WXUNUSED(width), | |
87f0efe2 | 863 | wxAlignment WXUNUSED(align), |
9861f022 | 864 | int WXUNUSED(flags) ) |
07a84e7b RR |
865 | { |
866 | m_renderer = renderer; | |
867 | m_model_column = model_column; | |
07a84e7b RR |
868 | m_bitmap = bitmap; |
869 | m_owner = NULL; | |
870 | m_renderer->SetOwner( (wxDataViewColumn*) this ); | |
871 | } | |
872 | ||
6842a71a RR |
873 | wxDataViewColumnBase::~wxDataViewColumnBase() |
874 | { | |
baa9ebc4 RR |
875 | if (m_renderer) |
876 | delete m_renderer; | |
f554a14b | 877 | |
b5d777c7 RR |
878 | if (GetOwner()) |
879 | { | |
880 | GetOwner()->GetModel()->RemoveViewingColumn( (wxDataViewColumn*) this ); | |
881 | } | |
fa28826d RR |
882 | } |
883 | ||
9861f022 | 884 | int wxDataViewColumnBase::GetFlags() const |
fa28826d | 885 | { |
9861f022 | 886 | int ret = 0; |
fa28826d | 887 | |
9861f022 RR |
888 | if (IsSortable()) |
889 | ret |= wxDATAVIEW_COL_SORTABLE; | |
890 | if (IsResizeable()) | |
891 | ret |= wxDATAVIEW_COL_RESIZABLE; | |
892 | if (IsHidden()) | |
893 | ret |= wxDATAVIEW_COL_HIDDEN; | |
fa28826d | 894 | |
9861f022 | 895 | return ret; |
07a84e7b RR |
896 | } |
897 | ||
9861f022 | 898 | void wxDataViewColumnBase::SetFlags(int flags) |
07a84e7b | 899 | { |
9861f022 RR |
900 | SetSortable((flags & wxDATAVIEW_COL_SORTABLE) != 0); |
901 | SetResizeable((flags & wxDATAVIEW_COL_RESIZABLE) != 0); | |
902 | SetHidden((flags & wxDATAVIEW_COL_HIDDEN) != 0); | |
07a84e7b RR |
903 | } |
904 | ||
9861f022 | 905 | |
f554a14b | 906 | // --------------------------------------------------------- |
239eaa41 | 907 | // wxDataViewCtrlBase |
f554a14b | 908 | // --------------------------------------------------------- |
239eaa41 RR |
909 | |
910 | IMPLEMENT_ABSTRACT_CLASS(wxDataViewCtrlBase, wxControl) | |
911 | ||
912 | wxDataViewCtrlBase::wxDataViewCtrlBase() | |
913 | { | |
914 | m_model = NULL; | |
fa28826d | 915 | m_cols.DeleteContents( true ); |
239eaa41 RR |
916 | } |
917 | ||
918 | wxDataViewCtrlBase::~wxDataViewCtrlBase() | |
919 | { | |
87f0efe2 RR |
920 | // IMPORTANT: before calling DecRef() on our model (since it may |
921 | // result in a free() call), erase all columns (since | |
922 | // they hold a pointer to our model) | |
923 | m_cols.Clear(); | |
924 | ||
925 | if (m_model) | |
926 | { | |
927 | m_model->DecRef(); | |
928 | m_model = NULL; | |
929 | } | |
239eaa41 RR |
930 | } |
931 | ||
6e2e590f | 932 | bool wxDataViewCtrlBase::AssociateModel( wxDataViewListModel *model ) |
239eaa41 | 933 | { |
87f0efe2 RR |
934 | if ( m_model ) |
935 | m_model->DecRef(); // discard old model, if any | |
936 | ||
937 | // add our own reference to the new model: | |
239eaa41 | 938 | m_model = model; |
87f0efe2 RR |
939 | if ( m_model ) |
940 | m_model->IncRef(); | |
f554a14b | 941 | |
239eaa41 RR |
942 | return true; |
943 | } | |
944 | ||
6e2e590f | 945 | wxDataViewListModel* wxDataViewCtrlBase::GetModel() |
239eaa41 RR |
946 | { |
947 | return m_model; | |
948 | } | |
949 | ||
1286b7ba | 950 | bool wxDataViewCtrlBase::AppendTextColumn( const wxString &label, unsigned int model_column, |
87f0efe2 | 951 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
fa28826d | 952 | { |
1286b7ba | 953 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
954 | new wxDataViewTextRenderer( wxT("string"), mode, (int)align ), |
955 | model_column, width, align, flags ) ); | |
fa28826d RR |
956 | } |
957 | ||
1286b7ba | 958 | bool wxDataViewCtrlBase::AppendToggleColumn( const wxString &label, unsigned int model_column, |
87f0efe2 | 959 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
605c2c4a | 960 | { |
1286b7ba | 961 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
962 | new wxDataViewToggleRenderer( wxT("bool"), mode, (int)align ), |
963 | model_column, width, align, flags ) ); | |
605c2c4a RR |
964 | } |
965 | ||
1286b7ba | 966 | bool wxDataViewCtrlBase::AppendProgressColumn( const wxString &label, unsigned int model_column, |
87f0efe2 | 967 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
ad63bf41 | 968 | { |
1286b7ba | 969 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
970 | new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode, (int)align ), |
971 | model_column, width, align, flags ) ); | |
ad63bf41 RR |
972 | } |
973 | ||
1286b7ba | 974 | bool wxDataViewCtrlBase::AppendDateColumn( const wxString &label, unsigned int model_column, |
87f0efe2 | 975 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
4d496ecb | 976 | { |
1286b7ba | 977 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
978 | new wxDataViewDateRenderer( wxT("datetime"), mode, (int)align ), |
979 | model_column, width, align, flags ) ); | |
4d496ecb RR |
980 | } |
981 | ||
1286b7ba | 982 | bool wxDataViewCtrlBase::AppendBitmapColumn( const wxString &label, unsigned int model_column, |
87f0efe2 | 983 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
07a84e7b | 984 | { |
1286b7ba | 985 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
986 | new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode, (int)align ), |
987 | model_column, width, align, flags ) ); | |
07a84e7b RR |
988 | } |
989 | ||
1286b7ba | 990 | bool wxDataViewCtrlBase::AppendTextColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 | 991 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
07a84e7b | 992 | { |
1286b7ba | 993 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
994 | new wxDataViewTextRenderer( wxT("string"), mode, (int)align ), |
995 | model_column, width, align, flags ) ); | |
07a84e7b RR |
996 | } |
997 | ||
1286b7ba | 998 | bool wxDataViewCtrlBase::AppendToggleColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 | 999 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
07a84e7b | 1000 | { |
1286b7ba | 1001 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
1002 | new wxDataViewToggleRenderer( wxT("bool"), mode, (int)align ), |
1003 | model_column, width, align, flags ) ); | |
07a84e7b RR |
1004 | } |
1005 | ||
1286b7ba | 1006 | bool wxDataViewCtrlBase::AppendProgressColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 | 1007 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
07a84e7b | 1008 | { |
1286b7ba | 1009 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
1010 | new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode, (int)align ), |
1011 | model_column, width, align, flags ) ); | |
07a84e7b RR |
1012 | } |
1013 | ||
1286b7ba | 1014 | bool wxDataViewCtrlBase::AppendDateColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 | 1015 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
07a84e7b | 1016 | { |
1286b7ba | 1017 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
1018 | new wxDataViewDateRenderer( wxT("datetime"), mode, (int)align ), |
1019 | model_column, width, align, flags ) ); | |
07a84e7b RR |
1020 | } |
1021 | ||
1286b7ba | 1022 | bool wxDataViewCtrlBase::AppendBitmapColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 | 1023 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
07a84e7b | 1024 | { |
1286b7ba | 1025 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
1026 | new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode, (int)align ), |
1027 | model_column, width, align, flags ) ); | |
07a84e7b RR |
1028 | } |
1029 | ||
fa28826d RR |
1030 | bool wxDataViewCtrlBase::AppendColumn( wxDataViewColumn *col ) |
1031 | { | |
1032 | m_cols.Append( (wxObject*) col ); | |
6842a71a | 1033 | col->SetOwner( (wxDataViewCtrl*) this ); |
b5d777c7 | 1034 | m_model->AddViewingColumn( col, col->GetModelColumn() ); |
fa28826d RR |
1035 | return true; |
1036 | } | |
1037 | ||
9861f022 | 1038 | unsigned int wxDataViewCtrlBase::GetColumnCount() const |
fa28826d RR |
1039 | { |
1040 | return m_cols.GetCount(); | |
1041 | } | |
1042 | ||
0a71f9e9 | 1043 | bool wxDataViewCtrlBase::DeleteColumn( unsigned int WXUNUSED(pos) ) |
fa28826d RR |
1044 | { |
1045 | return false; | |
1046 | } | |
1047 | ||
1048 | bool wxDataViewCtrlBase::ClearColumns() | |
1049 | { | |
1050 | return false; | |
1051 | } | |
1052 | ||
0a71f9e9 | 1053 | wxDataViewColumn* wxDataViewCtrlBase::GetColumn( unsigned int pos ) |
fa28826d RR |
1054 | { |
1055 | return (wxDataViewColumn*) m_cols[ pos ]; | |
1056 | } | |
1057 | ||
eb7f97f8 RR |
1058 | // --------------------------------------------------------- |
1059 | // wxDataViewEvent | |
1060 | // --------------------------------------------------------- | |
1061 | ||
1062 | IMPLEMENT_DYNAMIC_CLASS(wxDataViewEvent,wxNotifyEvent) | |
1063 | ||
1064 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ROW_SELECTED) | |
f828871d | 1065 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ROW_ACTIVATED) |
31fb32e1 RR |
1066 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK) |
1067 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK) | |
eb7f97f8 RR |
1068 | |
1069 | ||
8045736e | 1070 | #endif |