]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/datavgen.cpp
More proof-reading in wxImage
[wxWidgets.git] / src / generic / datavgen.cpp
index 95231257c6d1d3cd543bb29011a969cf7e59c1a3..db167505f141573730eef7bf0756446ccfceb525 100644 (file)
@@ -641,6 +641,29 @@ wxDC *wxDataViewRenderer::GetDC()
     return m_dc;
 }
 
+void wxDataViewRenderer::SetAlignment( int align )
+{ 
+    m_align=align;
+}
+
+int wxDataViewRenderer::GetAlignment() const
+{
+    return m_align;
+}
+
+int wxDataViewRenderer::CalculateAlignment() const
+{ 
+    if (m_align == wxDVR_DEFAULT_ALIGNMENT)
+    {
+        if (GetOwner() == NULL)
+           return wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL;
+           
+        return GetOwner()->GetAlignment() | wxALIGN_CENTRE_VERTICAL;
+    }
+    
+    return m_align;
+}
+
 // ---------------------------------------------------------
 // wxDataViewCustomRenderer
 // ---------------------------------------------------------
@@ -2214,7 +2237,7 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
             size.y = cell_rect.height;
 
             wxRect item_rect(cell_rect.GetTopLeft(), size);
-            int align = cell->GetAlignment();
+            int align = cell->CalculateAlignment();
 
             // horizontal alignment:
             item_rect.x = cell_rect.x;
@@ -2458,11 +2481,6 @@ bool wxDataViewMainWindow::ItemDeleted(const wxDataViewItem& parent,
     //Make the row number invalid and get a new valid one when user call GetRowCount
     m_count = -1;
     node->ChangeSubTreeCount(sub);
-    if( node->GetChildrenNumber() == 0)
-    {
-        node->GetParent()->GetNodes().Remove( node );
-        delete node;
-    }
 
     //Change the current row to the last row if the current exceed the max row number
     if( m_currentRow > GetRowCount() )
@@ -3157,22 +3175,28 @@ wxDataViewTreeNode * wxDataViewMainWindow::FindNode( const wxDataViewItem & item
             }
 
             wxDataViewTreeNodes nodes = node->GetNodes();
-            unsigned int i = 0;
-            for (; i < nodes.GetCount(); i ++)
+            unsigned int i;
+            bool found = false;
+            
+            for (i = 0; i < nodes.GetCount(); i ++)
             {
                 if (nodes[i]->GetItem() == (**iter))
                 {
+                    if (nodes[i]->GetItem() == item)
+                       return nodes[i];
+                       
                     node = nodes[i];
+                    found = true;
                     break;
                 }
             }
-            if (i == nodes.GetCount())
+            if (!found)
                 return NULL;
         }
         else
             return NULL;
     }
-    return node;
+    return NULL;
 }
 
 void wxDataViewMainWindow::HitTest( const wxPoint & point, wxDataViewItem & item, wxDataViewColumn* &column )
@@ -3350,7 +3374,7 @@ void wxDataViewMainWindow::BuildTree(wxDataViewModel * model)
 {
     DestroyTree();
 
-    if (GetOwner()->GetModel()->IsIndexListModel())
+    if (GetOwner()->GetModel()->IsVirtualListModel())
     {
         m_count = -1 ;
         return;