wxDataViewListModel::~wxDataViewListModel()
{
- wxList::compatibility_iterator node = m_notifiers.GetFirst();
- while (node)
- {
- wxDataViewListModelNotifier* notifier = (wxDataViewListModelNotifier*) node->GetData();
- notifier->Freed();
- node = node->GetNext();
- }
}
bool wxDataViewListModel::RowAppended()
public:
wxDataViewSortedListModelNotifier( wxDataViewSortedListModel *model )
{ m_model = model; }
+
+ ~wxDataViewSortedListModelNotifier()
+ { m_model->DetachChild(); }
virtual bool RowAppended()
{ return m_model->ChildRowAppended(); }
virtual bool Cleared()
{ return m_model->ChildCleared(); }
- virtual bool Freed()
- { m_model->m_child = NULL; return wxDataViewListModelNotifier::Freed(); }
-
wxDataViewSortedListModel *m_model;
};
wxDataViewSortedListModel::~wxDataViewSortedListModel()
{
if (m_child)
- m_child->RemoveNotifier( m_notifierOnChild );
+ m_child->RemoveNotifier( m_notifierOnChild );
+}
+
+void wxDataViewSortedListModel::DetachChild()
+{
+ m_child = NULL;
}
// FIXME
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 );
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();
GetOwner()->GetOwner()->GetModel()->SetValue( value, col, m_row );
GetOwner()->GetOwner()->GetModel()->ValueChanged( col, m_row );
+ // m_editorCtrl->PopEventHandler( true );
+
return true;
}
BEGIN_EVENT_TABLE(wxDataViewEditorCtrlEvtHandler, wxEvtHandler)
EVT_CHAR (wxDataViewEditorCtrlEvtHandler::OnChar)
EVT_KILL_FOCUS (wxDataViewEditorCtrlEvtHandler::OnKillFocus)
+ EVT_IDLE (wxDataViewEditorCtrlEvtHandler::OnIdle)
END_EVENT_TABLE()
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 )
m_owner->FinishEditing();
}
- // We must let the native text control handle focus
event.Skip();
}