]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/datavcmn.cpp
Improve wxCheckListBox appearance under Vista/Win7.
[wxWidgets.git] / src / common / datavcmn.cpp
index bd62828c65908afc0a5bda4228bfe404183a44bb..99449244bb5bdc2f3c89e9c8f465a8c3a7fc0c87 100644 (file)
@@ -792,13 +792,22 @@ wxDataViewCustomRendererBase::RenderText(const wxString& text,
                                         text,
                                         *dc,
                                         GetEllipsizeMode(),
                                         text,
                                         *dc,
                                         GetEllipsizeMode(),
-                                        rect.width,
+                                        rectText.width,
                                         wxELLIPSIZE_FLAGS_NONE
                                     );
     }
 
                                         wxELLIPSIZE_FLAGS_NONE
                                     );
     }
 
+    // get the alignment to use
+    int align = GetAlignment();
+    if ( align == wxDVR_DEFAULT_ALIGNMENT )
+    {
+        // if we don't have an explicit alignment ourselves, use that of the
+        // column in horizontal direction and default vertical alignment
+        align = GetOwner()->GetAlignment() | wxALIGN_CENTRE_VERTICAL;
+    }
+
     dc->DrawLabel(ellipsizedText.empty() ? text : ellipsizedText,
     dc->DrawLabel(ellipsizedText.empty() ? text : ellipsizedText,
-                  rectText, GetAlignment());
+                  rectText, align);
 }
 
 //-----------------------------------------------------------------------------
 }
 
 //-----------------------------------------------------------------------------
@@ -1790,6 +1799,14 @@ wxDataViewTreeStore::InsertContainer(const wxDataViewItem& parent,
     return node->GetItem();
 }
 
     return node->GetItem();
 }
 
+bool wxDataViewTreeStore::IsContainer( const wxDataViewItem& item ) const
+{
+    wxDataViewTreeStoreNode *node = FindNode( item );
+    if (!node) return false;
+
+    return node->IsContainer();
+}
+
 wxDataViewItem wxDataViewTreeStore::GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const
 {
     wxDataViewTreeStoreContainerNode *parent_node = FindContainerNode( parent );
 wxDataViewItem wxDataViewTreeStore::GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const
 {
     wxDataViewTreeStoreContainerNode *parent_node = FindContainerNode( parent );
@@ -1963,14 +1980,6 @@ wxDataViewItem wxDataViewTreeStore::GetParent( const wxDataViewItem &item ) cons
     return parent->GetItem();
 }
 
     return parent->GetItem();
 }
 
-bool wxDataViewTreeStore::IsContainer( const wxDataViewItem &item ) const
-{
-    wxDataViewTreeStoreNode *node = FindNode( item );
-    if (!node) return false;
-
-    return node->IsContainer();
-}
-
 unsigned int wxDataViewTreeStore::GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const
 {
     wxDataViewTreeStoreContainerNode *node = FindContainerNode( item );
 unsigned int wxDataViewTreeStore::GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const
 {
     wxDataViewTreeStoreContainerNode *node = FindContainerNode( item );
@@ -2006,13 +2015,13 @@ int wxDataViewTreeStore::Compare( const wxDataViewItem &item1, const wxDataViewI
         return 0;
     }
 
         return 0;
     }
 
-    if (node1->IsContainer() && !!node2->IsContainer())
-        return 1;
-
-    if (node2->IsContainer() && !!node1->IsContainer())
+    if (node1->IsContainer() && !node2->IsContainer())
         return -1;
 
         return -1;
 
-    return parent1->GetChildren().IndexOf( node1 ) - parent1->GetChildren().IndexOf( node2 );
+    if (node2->IsContainer() && !node1->IsContainer())
+        return 1;
+
+    return parent1->GetChildren().IndexOf( node1 ) - parent2->GetChildren().IndexOf( node2 );
 }
 
 wxDataViewTreeStoreNode *wxDataViewTreeStore::FindNode( const wxDataViewItem &item ) const
 }
 
 wxDataViewTreeStoreNode *wxDataViewTreeStore::FindNode( const wxDataViewItem &item ) const
@@ -2064,7 +2073,15 @@ bool wxDataViewTreeCtrl::Create( wxWindow *parent, wxWindowID id,
     AssociateModel( store );
     store->DecRef();
 
     AssociateModel( store );
     store->DecRef();
 
-    AppendIconTextColumn(wxString(),0,wxDATAVIEW_CELL_EDITABLE,-1);
+    AppendIconTextColumn
+    (
+        wxString(),                 // no label (header is not shown anyhow)
+        0,                          // the only model column
+        wxDATAVIEW_CELL_EDITABLE,
+        -1,                         // default width
+        wxALIGN_NOT,                //  and alignment
+        0                           // not resizeable
+    );
 
     return true;
 }
 
     return true;
 }