X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1e510b1e2d0270caf227c3fc0cf34ae2e7dd6794..d3ae69de983f61c1ede821e32c18ae3a8bd8c70c:/src/common/datavcmn.cpp diff --git a/src/common/datavcmn.cpp b/src/common/datavcmn.cpp index 633822e6b5..c3aba3e3d4 100644 --- a/src/common/datavcmn.cpp +++ b/src/common/datavcmn.cpp @@ -38,13 +38,6 @@ wxDataViewListModel::wxDataViewListModel() wxDataViewListModel::~wxDataViewListModel() { - wxList::compatibility_iterator node = m_notifiers.GetFirst(); - while (node) - { - wxDataViewListModelNotifier* notifier = (wxDataViewListModelNotifier*) node->GetData(); - notifier->Freed(); - node = node->GetNext(); - } } bool wxDataViewListModel::RowAppended() @@ -217,6 +210,9 @@ class wxDataViewSortedListModelNotifier: public wxDataViewListModelNotifier public: wxDataViewSortedListModelNotifier( wxDataViewSortedListModel *model ) { m_model = model; } + + ~wxDataViewSortedListModelNotifier() + { m_model->DetachChild(); } virtual bool RowAppended() { return m_model->ChildRowAppended(); } @@ -242,9 +238,6 @@ public: virtual bool Cleared() { return m_model->ChildCleared(); } - virtual bool Freed() - { m_model->m_child = NULL; return wxDataViewListModelNotifier::Freed(); } - wxDataViewSortedListModel *m_model; }; @@ -325,7 +318,12 @@ wxDataViewSortedListModel::wxDataViewSortedListModel( wxDataViewListModel *child wxDataViewSortedListModel::~wxDataViewSortedListModel() { if (m_child) - m_child->RemoveNotifier( m_notifierOnChild ); + m_child->RemoveNotifier( m_notifierOnChild ); +} + +void wxDataViewSortedListModel::DetachChild() +{ + m_child = NULL; } // FIXME @@ -348,6 +346,9 @@ void wxDataViewSortedListModel::Resort() unsigned int i; for (i = 0; i < n; i++) m_array.Add( i ); + + // do we need the neworder? + wxDataViewListModel::RowsReordered( NULL ); } #if 0 @@ -600,7 +601,7 @@ void wxDataViewSortedListModel::GetValue( wxVariant &variant, unsigned int col, m_child->GetValue( variant, col, child_row ); } -bool wxDataViewSortedListModel::SetValue( wxVariant &variant, unsigned int col, unsigned int row ) +bool wxDataViewSortedListModel::SetValue( const wxVariant &variant, unsigned int col, unsigned int row ) { unsigned int child_row = m_array[row]; bool ret = m_child->SetValue( variant, col, child_row ); @@ -725,31 +726,35 @@ bool wxDataViewRendererBase::StartEditing( unsigned int row, wxRect labelRect ) m_editorCtrl = CreateEditorCtrl( GetOwner()->GetOwner()->GetMainWindow(), labelRect, value ); - m_editorCtrl->PushEventHandler( - new wxDataViewEditorCtrlEvtHandler( m_editorCtrl, (wxDataViewRenderer*) this ) ); + wxDataViewEditorCtrlEvtHandler *handler = + new wxDataViewEditorCtrlEvtHandler( m_editorCtrl, (wxDataViewRenderer*) this ); + + m_editorCtrl->PushEventHandler( handler ); +#if defined(__WXGTK20__) && !defined(wxUSE_GENERICDATAVIEWCTRL) + handler->SetFocusOnIdle(); +#else m_editorCtrl->SetFocus(); - +#endif + return true; } void wxDataViewRendererBase::CancelEditing() { - // m_editorCtrl->PopEventHandler( true ); - - delete m_editorCtrl; + wxPendingDelete.Append( m_editorCtrl ); GetOwner()->GetOwner()->GetMainWindow()->SetFocus(); + + // m_editorCtrl->PopEventHandler( true ); } bool wxDataViewRendererBase::FinishEditing() { - // m_editorCtrl->PopEventHandler( true ); - wxVariant value; GetValueFromEditorCtrl( m_editorCtrl, value ); - delete m_editorCtrl; + wxPendingDelete.Append( m_editorCtrl ); GetOwner()->GetOwner()->GetMainWindow()->SetFocus(); @@ -760,6 +765,8 @@ bool wxDataViewRendererBase::FinishEditing() GetOwner()->GetOwner()->GetModel()->SetValue( value, col, m_row ); GetOwner()->GetOwner()->GetModel()->ValueChanged( col, m_row ); + // m_editorCtrl->PopEventHandler( true ); + return true; } @@ -770,6 +777,7 @@ bool wxDataViewRendererBase::FinishEditing() BEGIN_EVENT_TABLE(wxDataViewEditorCtrlEvtHandler, wxEvtHandler) EVT_CHAR (wxDataViewEditorCtrlEvtHandler::OnChar) EVT_KILL_FOCUS (wxDataViewEditorCtrlEvtHandler::OnKillFocus) + EVT_IDLE (wxDataViewEditorCtrlEvtHandler::OnIdle) END_EVENT_TABLE() wxDataViewEditorCtrlEvtHandler::wxDataViewEditorCtrlEvtHandler( @@ -782,6 +790,18 @@ wxDataViewEditorCtrlEvtHandler::wxDataViewEditorCtrlEvtHandler( m_finished = false; } +void wxDataViewEditorCtrlEvtHandler::OnIdle( wxIdleEvent &event ) +{ + if (m_focusOnIdle) + { + m_focusOnIdle = false; + if (wxWindow::FindFocus() != m_editorCtrl) + m_editorCtrl->SetFocus(); + } + + event.Skip(); +} + void wxDataViewEditorCtrlEvtHandler::OnChar( wxKeyEvent &event ) { switch ( event.m_keyCode ) @@ -809,7 +829,6 @@ void wxDataViewEditorCtrlEvtHandler::OnKillFocus( wxFocusEvent &event ) m_owner->FinishEditing(); } - // We must let the native text control handle focus event.Skip(); }