]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/datavcmn.cpp
compilation fix: use DeviceToLogical[XY]() instead of [XY]LOG2DEV()
[wxWidgets.git] / src / common / datavcmn.cpp
index 5e5e4e8fd035a22ff76e8d0ffed73b7034da171e..c3aba3e3d4c6752677692ac7a582d596b3525d37 100644 (file)
@@ -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
@@ -603,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 );
@@ -728,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();
     
@@ -763,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;
 }
 
@@ -773,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(
@@ -785,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 )
@@ -812,7 +829,6 @@ void wxDataViewEditorCtrlEvtHandler::OnKillFocus( wxFocusEvent &event )
         m_owner->FinishEditing();
     }
 
-    // We must let the native text control handle focus
     event.Skip();
 }