]> git.saurik.com Git - wxWidgets.git/blame - src/common/datavcmn.cpp
Removed run-time dependency on libpangocairo
[wxWidgets.git] / src / common / datavcmn.cpp
CommitLineData
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 26const wxChar wxDataViewCtrlNameStr[] = wxT("dataviewCtrl");
239eaa41 27
239eaa41 28
d5025dc0
RR
29bool operator == (const wxDataViewItem &left, const wxDataViewItem &right)
30{
31 return (left.GetID() == right.GetID() );
32}
33
34
f554a14b 35// ---------------------------------------------------------
d5025dc0 36// wxDataViewModel
f554a14b 37// ---------------------------------------------------------
239eaa41 38
fbda518c 39#include <wx/listimpl.cpp>
9d8fe14a
RR
40WX_DEFINE_LIST(wxDataViewModelNotifiers);
41
e0062c04 42wxDataViewModel::wxDataViewModel()
239eaa41 43{
8f850e28 44 m_notifiers.DeleteContents( true );
239eaa41
RR
45}
46
e0062c04 47bool wxDataViewModel::ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item )
239eaa41 48{
8f850e28
RR
49 bool ret = true;
50
9d8fe14a
RR
51 wxDataViewModelNotifiers::iterator iter;
52 for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter)
8f850e28 53 {
9d8fe14a 54 wxDataViewModelNotifier* notifier = *iter;
e0062c04 55 if (!notifier->ItemAdded( parent, item ))
8f850e28 56 ret = false;
8f850e28 57 }
f554a14b 58
8f850e28 59 return ret;
239eaa41
RR
60}
61
469d3e9b 62bool wxDataViewModel::ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item )
239eaa41 63{
8f850e28
RR
64 bool ret = true;
65
9d8fe14a
RR
66 wxDataViewModelNotifiers::iterator iter;
67 for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter)
8f850e28 68 {
9d8fe14a 69 wxDataViewModelNotifier* notifier = *iter;
469d3e9b 70 if (!notifier->ItemDeleted( parent, item ))
8f850e28 71 ret = false;
8f850e28 72 }
f554a14b 73
8f850e28 74 return ret;
239eaa41
RR
75}
76
e0062c04 77bool wxDataViewModel::ItemChanged( const wxDataViewItem &item )
239eaa41 78{
8f850e28
RR
79 bool ret = true;
80
9d8fe14a
RR
81 wxDataViewModelNotifiers::iterator iter;
82 for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter)
8f850e28 83 {
9d8fe14a 84 wxDataViewModelNotifier* notifier = *iter;
e0062c04 85 if (!notifier->ItemChanged( item ))
8f850e28 86 ret = false;
8f850e28 87 }
f554a14b 88
8f850e28 89 return ret;
239eaa41
RR
90}
91
e0062c04 92bool wxDataViewModel::ValueChanged( const wxDataViewItem &item, unsigned int col )
239eaa41 93{
8f850e28 94 bool ret = true;
b5d777c7 95
9d8fe14a
RR
96 wxDataViewModelNotifiers::iterator iter;
97 for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter)
b5d777c7 98 {
9d8fe14a 99 wxDataViewModelNotifier* notifier = *iter;
e0062c04 100 if (!notifier->ValueChanged( item, col ))
8f850e28 101 ret = false;
b5d777c7 102 }
f554a14b 103
b5d777c7 104 return ret;
239eaa41
RR
105}
106
e0062c04 107bool wxDataViewModel::Cleared()
4eccd3a1
RR
108{
109 bool ret = true;
110
9d8fe14a
RR
111 wxDataViewModelNotifiers::iterator iter;
112 for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter)
4eccd3a1 113 {
9d8fe14a 114 wxDataViewModelNotifier* notifier = *iter;
8f850e28
RR
115 if (!notifier->Cleared())
116 ret = false;
8f850e28 117 }
f554a14b 118
8f850e28 119 return ret;
239eaa41
RR
120}
121
ef427989
RR
122void wxDataViewModel::Resort()
123{
9d8fe14a
RR
124 wxDataViewModelNotifiers::iterator iter;
125 for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter)
ef427989 126 {
9d8fe14a 127 wxDataViewModelNotifier* notifier = *iter;
ef427989 128 notifier->Resort();
ef427989
RR
129 }
130}
131
e0062c04 132void wxDataViewModel::AddNotifier( wxDataViewModelNotifier *notifier )
239eaa41 133{
9d8fe14a 134 m_notifiers.push_back( notifier );
8f850e28 135 notifier->SetOwner( this );
239eaa41
RR
136}
137
e0062c04 138void wxDataViewModel::RemoveNotifier( wxDataViewModelNotifier *notifier )
239eaa41 139{
8f850e28 140 m_notifiers.DeleteObject( notifier );
239eaa41
RR
141}
142
7ee7191c
RR
143int wxDataViewModel::Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
144 unsigned int column, bool ascending )
ef427989 145{
cf283a47 146 // sort branches before leaves
ed903e42
RR
147 bool item1_is_container = IsContainer(item1);
148 bool item2_is_container = IsContainer(item2);
900af470 149
ed903e42 150 if (item1_is_container && !item2_is_container)
cf283a47 151 return 1;
ed903e42 152 if (item2_is_container && !item1_is_container)
cf283a47 153 return -1;
900af470 154
ef427989 155 wxVariant value1,value2;
7ee7191c
RR
156 GetValue( value1, item1, column );
157 GetValue( value2, item2, column );
158
159 if (!ascending)
160 {
161 wxVariant temp = value1;
162 value1 = value2;
163 value2 = temp;
164 }
cf283a47 165
ef427989
RR
166 if (value1.GetType() == wxT("string"))
167 {
168 wxString str1 = value1.GetString();
169 wxString str2 = value2.GetString();
0be79c8a 170 int res = str1.Cmp( str2 );
cf283a47
RR
171 if (res) return res;
172 } else
ef427989
RR
173 if (value1.GetType() == wxT("long"))
174 {
175 long l1 = value1.GetLong();
176 long l2 = value2.GetLong();
cf283a47
RR
177 long res = l1-l2;
178 if (res) return res;
179 } else
ef427989
RR
180 if (value1.GetType() == wxT("double"))
181 {
182 double d1 = value1.GetDouble();
183 double d2 = value2.GetDouble();
ef427989 184 if (d1 < d2) return 1;
cf283a47
RR
185 if (d1 > d2) return -1;
186 } else
ef427989
RR
187 if (value1.GetType() == wxT("datetime"))
188 {
189 wxDateTime dt1 = value1.GetDateTime();
190 wxDateTime dt2 = value2.GetDateTime();
ef427989 191 if (dt1.IsEarlierThan(dt2)) return 1;
cf283a47 192 if (dt2.IsEarlierThan(dt1)) return -11;
ef427989
RR
193 }
194
cf283a47 195 // items must be different
900af470
JS
196 unsigned long litem1 = (unsigned long) item1.GetID();
197 unsigned long litem2 = (unsigned long) item2.GetID();
7ee7191c
RR
198
199 if (!ascending)
200 return litem2-litem2;
cf283a47 201
cf283a47 202 return litem1-litem2;
ef427989
RR
203}
204
c534e696
RR
205// ---------------------------------------------------------
206// wxDataViewIndexListModel
207// ---------------------------------------------------------
208
209wxDataViewIndexListModel::wxDataViewIndexListModel( unsigned int initial_size )
210{
211 // build initial index
212 unsigned int i;
213 for (i = 1; i < initial_size+1; i++)
214 m_hash.Add( (void*) i );
215 m_lastIndex = initial_size + 1;
216}
217
218wxDataViewIndexListModel::~wxDataViewIndexListModel()
219{
220}
221
222void wxDataViewIndexListModel::RowPrepended()
223{
224 unsigned int id = m_lastIndex++;
225 m_hash.Insert( (void*) id, 0 );
226 wxDataViewItem item( (void*) id );
227 ItemAdded( wxDataViewItem(0), item );
228}
229
230void wxDataViewIndexListModel::RowInserted( unsigned int before )
231{
232 unsigned int id = m_lastIndex++;
233 m_hash.Insert( (void*) id, before );
234 wxDataViewItem item( (void*) id );
235 ItemAdded( wxDataViewItem(0), item );
236}
237
238void wxDataViewIndexListModel::RowAppended()
239{
240 unsigned int id = m_lastIndex++;
241 m_hash.Add( (void*) id );
242 wxDataViewItem item( (void*) id );
243 ItemAdded( wxDataViewItem(0), item );
244}
245
246void wxDataViewIndexListModel::RowDeleted( unsigned int row )
247{
248 wxDataViewItem item( m_hash[row] );
469d3e9b 249 wxDataViewModel::ItemDeleted( wxDataViewItem(0), item );
d3f00f59 250 m_hash.RemoveAt( row );
c534e696
RR
251}
252
253void wxDataViewIndexListModel::RowChanged( unsigned int row )
254{
255 wxDataViewModel::ItemChanged( GetItem(row) );
256}
257
258void wxDataViewIndexListModel::RowValueChanged( unsigned int row, unsigned int col )
259{
260 wxDataViewModel::ValueChanged( GetItem(row), col );
261}
262
263unsigned int wxDataViewIndexListModel::GetRow( const wxDataViewItem &item ) const
264{
265 // assert for not found
266 return (unsigned int) m_hash.Index( item.GetID() );
267}
268
269wxDataViewItem wxDataViewIndexListModel::GetItem( unsigned int row ) const
270{
fbda518c 271 wxASSERT( row < m_hash.GetCount() );
c534e696
RR
272 return wxDataViewItem( m_hash[row] );
273}
274
7ee7191c
RR
275int wxDataViewIndexListModel::Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
276 unsigned int column, bool ascending )
c534e696 277{
7ee7191c
RR
278 if (ascending)
279 return GetRow(item1) - GetRow(item2);
280
281 return GetRow(item2) - GetRow(item1);
c534e696
RR
282}
283
900af470 284void wxDataViewIndexListModel::GetValue( wxVariant &variant,
c534e696
RR
285 const wxDataViewItem &item, unsigned int col ) const
286{
900af470 287 GetValue( variant, GetRow(item), col );
c534e696
RR
288}
289
900af470 290bool wxDataViewIndexListModel::SetValue( const wxVariant &variant,
c534e696
RR
291 const wxDataViewItem &item, unsigned int col )
292{
293 return SetValue( variant, GetRow(item), col );
294}
295
900af470 296wxDataViewItem wxDataViewIndexListModel::GetParent( const wxDataViewItem & WXUNUSED(item) ) const
c534e696
RR
297{
298 return wxDataViewItem(0);
299}
300
301bool wxDataViewIndexListModel::IsContainer( const wxDataViewItem &item ) const
302{
303 // only the invisible root item has children
304 if (!item.IsOk())
305 return true;
900af470 306
c534e696
RR
307 return false;
308}
309
74fe973b 310unsigned int wxDataViewIndexListModel::GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const
c534e696 311{
74fe973b
RR
312 if (item.IsOk())
313 return 0;
c534e696 314
74fe973b
RR
315 children = m_hash;
316
317 return m_hash.GetCount();
c534e696
RR
318}
319
89352653
RR
320//-----------------------------------------------------------------------------
321// wxDataViewIconText
322//-----------------------------------------------------------------------------
323
324IMPLEMENT_DYNAMIC_CLASS(wxDataViewIconText,wxObject)
325
326IMPLEMENT_VARIANT_OBJECT(wxDataViewIconText)
327
328bool operator == (const wxDataViewIconText &one, const wxDataViewIconText &two)
329{
330 if (one.GetText() != two.GetText()) return false;
331 if (one.IsSameAs(two)) return false;
332 return true;
333}
334
f554a14b 335// ---------------------------------------------------------
baa9ebc4 336// wxDataViewRendererBase
f554a14b 337// ---------------------------------------------------------
6842a71a 338
baa9ebc4 339IMPLEMENT_ABSTRACT_CLASS(wxDataViewRendererBase, wxObject)
6842a71a 340
900af470 341wxDataViewRendererBase::wxDataViewRendererBase( const wxString &varianttype,
9861f022
RR
342 wxDataViewCellMode WXUNUSED(mode),
343 int WXUNUSED(align) )
6842a71a
RR
344{
345 m_variantType = varianttype;
1e510b1e 346 m_editorCtrl = NULL;
9861f022
RR
347}
348
349const wxDataViewCtrl* wxDataViewRendererBase::GetView() const
350{
351 return wx_const_cast(wxDataViewRendererBase*, this)->GetOwner()->GetOwner();
6842a71a 352}
f554a14b 353
e0062c04 354bool wxDataViewRendererBase::StartEditing( const wxDataViewItem &item, wxRect labelRect )
1e510b1e 355{
e0062c04 356 m_item = item; // remember for later
900af470 357
1e510b1e
RR
358 unsigned int col = GetOwner()->GetModelColumn();
359 wxVariant value;
e0062c04 360 GetOwner()->GetOwner()->GetModel()->GetValue( value, item, col );
900af470 361
1e510b1e 362 m_editorCtrl = CreateEditorCtrl( GetOwner()->GetOwner()->GetMainWindow(), labelRect, value );
900af470
JS
363
364 wxDataViewEditorCtrlEvtHandler *handler =
30715fa1 365 new wxDataViewEditorCtrlEvtHandler( m_editorCtrl, (wxDataViewRenderer*) this );
900af470 366
30715fa1 367 m_editorCtrl->PushEventHandler( handler );
900af470 368
30715fa1
RR
369#if defined(__WXGTK20__) && !defined(wxUSE_GENERICDATAVIEWCTRL)
370 handler->SetFocusOnIdle();
371#else
1e510b1e 372 m_editorCtrl->SetFocus();
30715fa1
RR
373#endif
374
afebb87b
RR
375 // Now we should send Editing Started event
376 wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED, GetOwner()->GetOwner()->GetId() );
377 event.SetDataViewColumn( GetOwner() );
378 event.SetModel( GetOwner()->GetOwner()->GetModel() );
379 event.SetItem( item );
afebb87b
RR
380 GetOwner()->GetOwner()->GetEventHandler()->ProcessEvent( event );
381
1e510b1e
RR
382 return true;
383}
384
385void wxDataViewRendererBase::CancelEditing()
386{
2fa73716 387 wxPendingDelete.Append( m_editorCtrl );
900af470 388
1e510b1e 389 GetOwner()->GetOwner()->GetMainWindow()->SetFocus();
900af470 390
2fa73716 391 // m_editorCtrl->PopEventHandler( true );
1e510b1e
RR
392}
393
394bool wxDataViewRendererBase::FinishEditing()
395{
1e510b1e
RR
396 wxVariant value;
397 GetValueFromEditorCtrl( m_editorCtrl, value );
398
2fa73716 399 wxPendingDelete.Append( m_editorCtrl );
900af470 400
1e510b1e 401 GetOwner()->GetOwner()->GetMainWindow()->SetFocus();
900af470 402
1e510b1e
RR
403 if (!Validate(value))
404 return false;
900af470 405
1e510b1e 406 unsigned int col = GetOwner()->GetModelColumn();
e0062c04
RR
407 GetOwner()->GetOwner()->GetModel()->SetValue( value, m_item, col );
408 GetOwner()->GetOwner()->GetModel()->ValueChanged( m_item, col );
900af470 409
2fa73716 410 // m_editorCtrl->PopEventHandler( true );
afebb87b
RR
411
412 // Now we should send Editing Done event
413 wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, GetOwner()->GetOwner()->GetId() );
414 event.SetDataViewColumn( GetOwner() );
415 event.SetModel( GetOwner()->GetOwner()->GetModel() );
8fdaf7de 416 event.SetItem( m_item );
afebb87b 417 GetOwner()->GetOwner()->GetEventHandler()->ProcessEvent( event );
900af470 418
1e510b1e
RR
419 return true;
420}
421
422//-----------------------------------------------------------------------------
423// wxDataViewEditorCtrlEvtHandler
424//-----------------------------------------------------------------------------
425
426BEGIN_EVENT_TABLE(wxDataViewEditorCtrlEvtHandler, wxEvtHandler)
427 EVT_CHAR (wxDataViewEditorCtrlEvtHandler::OnChar)
428 EVT_KILL_FOCUS (wxDataViewEditorCtrlEvtHandler::OnKillFocus)
30715fa1 429 EVT_IDLE (wxDataViewEditorCtrlEvtHandler::OnIdle)
1e510b1e
RR
430END_EVENT_TABLE()
431
432wxDataViewEditorCtrlEvtHandler::wxDataViewEditorCtrlEvtHandler(
433 wxControl *editorCtrl,
434 wxDataViewRenderer *owner )
435{
436 m_owner = owner;
437 m_editorCtrl = editorCtrl;
438
439 m_finished = false;
440}
441
30715fa1
RR
442void wxDataViewEditorCtrlEvtHandler::OnIdle( wxIdleEvent &event )
443{
444 if (m_focusOnIdle)
445 {
446 m_focusOnIdle = false;
447 if (wxWindow::FindFocus() != m_editorCtrl)
448 m_editorCtrl->SetFocus();
449 }
900af470 450
30715fa1
RR
451 event.Skip();
452}
453
1e510b1e
RR
454void wxDataViewEditorCtrlEvtHandler::OnChar( wxKeyEvent &event )
455{
456 switch ( event.m_keyCode )
457 {
458 case WXK_RETURN:
459 m_finished = true;
460 m_owner->FinishEditing();
461 break;
462
463 case WXK_ESCAPE:
464 m_finished = true;
465 m_owner->CancelEditing();
466 break;
467
468 default:
469 event.Skip();
470 }
471}
472
473void wxDataViewEditorCtrlEvtHandler::OnKillFocus( wxFocusEvent &event )
474{
475 if (!m_finished)
476 {
477 m_finished = true;
478 m_owner->FinishEditing();
479 }
480
1e510b1e
RR
481 event.Skip();
482}
483
f554a14b 484// ---------------------------------------------------------
fa28826d 485// wxDataViewColumnBase
f554a14b 486// ---------------------------------------------------------
fa28826d
RR
487
488IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumnBase, wxObject)
489
9861f022 490wxDataViewColumnBase::wxDataViewColumnBase(const wxString& WXUNUSED(title),
baa9ebc4 491 wxDataViewRenderer *renderer,
0a71f9e9 492 unsigned int model_column,
008b5a66 493 int WXUNUSED(width),
87f0efe2 494 wxAlignment WXUNUSED(align),
900af470 495 int WXUNUSED(flags))
fa28826d 496{
baa9ebc4 497 m_renderer = renderer;
6842a71a 498 m_model_column = model_column;
6842a71a 499 m_owner = NULL;
baa9ebc4 500 m_renderer->SetOwner( (wxDataViewColumn*) this );
9861f022
RR
501
502 // NOTE: the wxDataViewColumn's ctor must store the width, align, flags
503 // parameters inside the native control!
6842a71a
RR
504}
505
07a84e7b
RR
506wxDataViewColumnBase::wxDataViewColumnBase(const wxBitmap& bitmap,
507 wxDataViewRenderer *renderer,
508 unsigned int model_column,
509 int WXUNUSED(width),
87f0efe2 510 wxAlignment WXUNUSED(align),
900af470 511 int WXUNUSED(flags) )
07a84e7b
RR
512{
513 m_renderer = renderer;
514 m_model_column = model_column;
07a84e7b
RR
515 m_bitmap = bitmap;
516 m_owner = NULL;
517 m_renderer->SetOwner( (wxDataViewColumn*) this );
518}
519
6842a71a
RR
520wxDataViewColumnBase::~wxDataViewColumnBase()
521{
baa9ebc4
RR
522 if (m_renderer)
523 delete m_renderer;
fa28826d
RR
524}
525
9861f022 526int wxDataViewColumnBase::GetFlags() const
fa28826d 527{
9861f022 528 int ret = 0;
fa28826d 529
9861f022
RR
530 if (IsSortable())
531 ret |= wxDATAVIEW_COL_SORTABLE;
532 if (IsResizeable())
533 ret |= wxDATAVIEW_COL_RESIZABLE;
534 if (IsHidden())
535 ret |= wxDATAVIEW_COL_HIDDEN;
fa28826d 536
9861f022 537 return ret;
07a84e7b
RR
538}
539
9861f022 540void wxDataViewColumnBase::SetFlags(int flags)
07a84e7b 541{
9861f022
RR
542 SetSortable((flags & wxDATAVIEW_COL_SORTABLE) != 0);
543 SetResizeable((flags & wxDATAVIEW_COL_RESIZABLE) != 0);
544 SetHidden((flags & wxDATAVIEW_COL_HIDDEN) != 0);
07a84e7b
RR
545}
546
f554a14b 547// ---------------------------------------------------------
239eaa41 548// wxDataViewCtrlBase
f554a14b 549// ---------------------------------------------------------
239eaa41
RR
550
551IMPLEMENT_ABSTRACT_CLASS(wxDataViewCtrlBase, wxControl)
552
553wxDataViewCtrlBase::wxDataViewCtrlBase()
554{
555 m_model = NULL;
3b6280be
RR
556 m_expander_column = 0;
557 m_indent = 8;
239eaa41
RR
558}
559
560wxDataViewCtrlBase::~wxDataViewCtrlBase()
561{
87f0efe2
RR
562 if (m_model)
563 {
564 m_model->DecRef();
565 m_model = NULL;
566 }
239eaa41
RR
567}
568
e0062c04 569bool wxDataViewCtrlBase::AssociateModel( wxDataViewModel *model )
239eaa41 570{
1821abd1
RR
571 if (m_model)
572 {
87f0efe2 573 m_model->DecRef(); // discard old model, if any
1821abd1 574 }
87f0efe2
RR
575
576 // add our own reference to the new model:
239eaa41 577 m_model = model;
1821abd1
RR
578 if (m_model)
579 {
900af470 580 m_model->IncRef();
1821abd1 581 }
f554a14b 582
239eaa41
RR
583 return true;
584}
585
e0062c04 586wxDataViewModel* wxDataViewCtrlBase::GetModel()
239eaa41
RR
587{
588 return m_model;
589}
590
c7074d44
RR
591wxDataViewColumn *
592wxDataViewCtrlBase::AppendTextColumn( const wxString &label, unsigned int model_column,
87f0efe2 593 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
fa28826d 594{
c7074d44 595 wxDataViewColumn *ret = new wxDataViewColumn( label,
900af470 596 new wxDataViewTextRenderer( wxT("string"), mode, (int)align ),
c7074d44
RR
597 model_column, width, align, flags );
598 AppendColumn( ret );
599 return ret;
fa28826d
RR
600}
601
b04fcede
RR
602wxDataViewColumn *
603wxDataViewCtrlBase::AppendIconTextColumn( const wxString &label, unsigned int model_column,
604 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
605{
606 wxDataViewColumn *ret = new wxDataViewColumn( label,
607 new wxDataViewIconTextRenderer( wxT("wxDataViewIconText"), mode, (int)align ),
608 model_column, width, align, flags );
609 AppendColumn( ret );
610 return ret;
611}
612
c7074d44
RR
613wxDataViewColumn *
614wxDataViewCtrlBase::AppendToggleColumn( const wxString &label, unsigned int model_column,
87f0efe2 615 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
605c2c4a 616{
c7074d44
RR
617
618 wxDataViewColumn *ret = new wxDataViewColumn( label,
900af470 619 new wxDataViewToggleRenderer( wxT("bool"), mode, (int)align ),
c7074d44
RR
620 model_column, width, align, flags );
621 AppendColumn( ret );
622 return ret;
605c2c4a
RR
623}
624
c7074d44
RR
625wxDataViewColumn *
626wxDataViewCtrlBase::AppendProgressColumn( const wxString &label, unsigned int model_column,
87f0efe2 627 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
ad63bf41 628{
c7074d44 629 wxDataViewColumn *ret = new wxDataViewColumn( label,
900af470 630 new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode, (int)align ),
c7074d44
RR
631 model_column, width, align, flags );
632 AppendColumn( ret );
633 return ret;
ad63bf41
RR
634}
635
c7074d44
RR
636wxDataViewColumn *
637wxDataViewCtrlBase::AppendDateColumn( const wxString &label, unsigned int model_column,
87f0efe2 638 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
4d496ecb 639{
c7074d44 640 wxDataViewColumn *ret = new wxDataViewColumn( label,
900af470 641 new wxDataViewDateRenderer( wxT("datetime"), mode, (int)align ),
c7074d44
RR
642 model_column, width, align, flags );
643 AppendColumn( ret );
644 return ret;
4d496ecb
RR
645}
646
c7074d44
RR
647wxDataViewColumn *
648wxDataViewCtrlBase::AppendBitmapColumn( const wxString &label, unsigned int model_column,
87f0efe2 649 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
07a84e7b 650{
c7074d44 651 wxDataViewColumn *ret = new wxDataViewColumn( label,
900af470 652 new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode, (int)align ),
c7074d44
RR
653 model_column, width, align, flags );
654 AppendColumn( ret );
655 return ret;
07a84e7b
RR
656}
657
c7074d44
RR
658wxDataViewColumn *
659wxDataViewCtrlBase::AppendTextColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2 660 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
07a84e7b 661{
c7074d44 662 wxDataViewColumn *ret = new wxDataViewColumn( label,
900af470 663 new wxDataViewTextRenderer( wxT("string"), mode, (int)align ),
c7074d44
RR
664 model_column, width, align, flags );
665 AppendColumn( ret );
666 return ret;
b04fcede
RR
667}
668
669wxDataViewColumn *
670wxDataViewCtrlBase::AppendIconTextColumn( const wxBitmap &label, unsigned int model_column,
671 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
672{
673 wxDataViewColumn *ret = new wxDataViewColumn( label,
674 new wxDataViewIconTextRenderer( wxT("wxDataViewIconText"), mode, (int)align ),
675 model_column, width, align, flags );
676 AppendColumn( ret );
677 return ret;
07a84e7b
RR
678}
679
c7074d44
RR
680wxDataViewColumn *
681wxDataViewCtrlBase::AppendToggleColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2 682 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
07a84e7b 683{
c7074d44 684 wxDataViewColumn *ret = new wxDataViewColumn( label,
900af470 685 new wxDataViewToggleRenderer( wxT("bool"), mode, (int)align ),
c7074d44
RR
686 model_column, width, align, flags );
687 AppendColumn( ret );
688 return ret;
07a84e7b
RR
689}
690
c7074d44
RR
691wxDataViewColumn *
692wxDataViewCtrlBase::AppendProgressColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2 693 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
07a84e7b 694{
c7074d44 695 wxDataViewColumn *ret = new wxDataViewColumn( label,
900af470 696 new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode, (int)align ),
c7074d44
RR
697 model_column, width, align, flags );
698 AppendColumn( ret );
699 return ret;
07a84e7b
RR
700}
701
c7074d44
RR
702wxDataViewColumn *
703wxDataViewCtrlBase::AppendDateColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2 704 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
07a84e7b 705{
c7074d44 706 wxDataViewColumn *ret = new wxDataViewColumn( label,
900af470 707 new wxDataViewDateRenderer( wxT("datetime"), mode, (int)align ),
c7074d44
RR
708 model_column, width, align, flags );
709 AppendColumn( ret );
710 return ret;
07a84e7b
RR
711}
712
c7074d44
RR
713wxDataViewColumn *
714wxDataViewCtrlBase::AppendBitmapColumn( const wxBitmap &label, unsigned int model_column,
87f0efe2 715 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
07a84e7b 716{
c7074d44 717 wxDataViewColumn *ret = new wxDataViewColumn( label,
900af470 718 new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode, (int)align ),
c7074d44
RR
719 model_column, width, align, flags );
720 AppendColumn( ret );
721 return ret;
07a84e7b
RR
722}
723
c7074d44
RR
724bool
725wxDataViewCtrlBase::AppendColumn( wxDataViewColumn *col )
fa28826d 726{
6842a71a 727 col->SetOwner( (wxDataViewCtrl*) this );
fa28826d
RR
728 return true;
729}
730
eb7f97f8
RR
731// ---------------------------------------------------------
732// wxDataViewEvent
733// ---------------------------------------------------------
734
735IMPLEMENT_DYNAMIC_CLASS(wxDataViewEvent,wxNotifyEvent)
736
e0062c04 737DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_SELECTED)
e98351ec 738DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_DESELECTED)
e0062c04 739DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED)
6977c3bf 740DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING)
3ecb8a53 741DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED)
6977c3bf 742DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING)
3ecb8a53 743DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED)
e0000f94
RR
744DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED)
745DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE)
746
31fb32e1
RR
747DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK)
748DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK)
c0a66d92 749DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED)
eb7f97f8 750
e0062c04
RR
751DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_ADDED)
752DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_DELETED)
753DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_CHANGED)
1821abd1 754DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_MODEL_VALUE_CHANGED)
1821abd1 755DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_MODEL_CLEARED)
eb7f97f8 756
8045736e 757#endif
e0000f94 758