]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/treectlg.cpp
Fixed a bug so wxLC_VRULES works by itself.
[wxWidgets.git] / src / generic / treectlg.cpp
index 2650eac81d69d983d4f94be744644f1b4768e1b9..ed745c827f1f28c55daf7d37f6d383ace3dc6997 100644 (file)
@@ -1490,12 +1490,12 @@ void wxGenericTreeCtrl::SelectItem(const wxTreeItemId& itemId,
     {
         if (!IsExpanded(parent))
             Expand( parent );
     {
         if (!IsExpanded(parent))
             Expand( parent );
-            
+
         parent = GetParent( parent );
     }
         parent = GetParent( parent );
     }
-    
+
     EnsureVisible( itemId );
     EnsureVisible( itemId );
-    
+
     // ctrl press
     if (unselect_others)
     {
     // ctrl press
     if (unselect_others)
     {
@@ -1787,8 +1787,11 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
 
     int total_h = GetLineHeight(item);
 
 
     int total_h = GetLineHeight(item);
 
-    if (item->IsSelected())
+    bool paintBg = item->IsSelected() && m_hasFocus;
+    if ( paintBg )
+    {
         dc.SetBrush(*m_hilightBrush);
         dc.SetBrush(*m_hilightBrush);
+    }
     else
     {
         wxColour colBg;
     else
     {
         wxColour colBg;
@@ -1799,21 +1802,20 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
         dc.SetBrush(wxBrush(colBg, wxSOLID));
     }
 
         dc.SetBrush(wxBrush(colBg, wxSOLID));
     }
 
-    int offset = 0;
-    if (HasFlag(wxTR_ROW_LINES)) offset = 1;
+    int offset = HasFlag(wxTR_ROW_LINES) ? 1 : 0;
 
 
-    if (item->IsSelected() && image != NO_IMAGE)
+    if ( item->IsSelected() && image != NO_IMAGE)
     {
         // If it's selected, and there's an image, then we should
         // take care to leave the area under the image painted in the
         // background colour.
     {
         // If it's selected, and there's an image, then we should
         // take care to leave the area under the image painted in the
         // background colour.
-        dc.DrawRectangle( item->GetX() + image_w - 2, item->GetY()+offset, 
-                                         item->GetWidth() - image_w + 2, total_h-offset );
+        dc.DrawRectangle( item->GetX() + image_w - 2, item->GetY()+offset,
+                          item->GetWidth() - image_w + 2, total_h-offset );
     }
     else
     {
     }
     else
     {
-        dc.DrawRectangle( item->GetX()-2, item->GetY()+offset, 
-                                         item->GetWidth()+2, total_h-offset );
+        dc.DrawRectangle( item->GetX()-2, item->GetY()+offset,
+                          item->GetWidth()+2, total_h-offset );
     }
 
     if ( image != NO_IMAGE )
     }
 
     if ( image != NO_IMAGE )
@@ -1860,16 +1862,16 @@ void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level
         int endX = x-5;
 
         if (!item->HasChildren()) endX += 20;
         int endX = x-5;
 
         if (!item->HasChildren()) endX += 20;
-        
+
         if (HasFlag( wxTR_MAC_BUTTONS ))
         if (HasFlag( wxTR_MAC_BUTTONS ))
-        {              
+        {
             if (item->HasPlus())
             {
                 dc.SetPen( *wxBLACK_PEN );
                 dc.SetBrush( *m_hilightBrush );
             if (item->HasPlus())
             {
                 dc.SetPen( *wxBLACK_PEN );
                 dc.SetBrush( *m_hilightBrush );
-                
+
                 wxPoint button[3];
                 wxPoint button[3];
-                
+
                 if (item->IsExpanded())
                 {
                     button[0].x = x-5;
                 if (item->IsExpanded())
                 {
                     button[0].x = x-5;
@@ -1889,7 +1891,7 @@ void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level
                     button[2].x = x+3;
                 }
                 dc.DrawPolygon( 3, button );
                     button[2].x = x+3;
                 }
                 dc.DrawPolygon( 3, button );
-                
+
                 dc.SetPen( m_dottedPen );
             }
         }
                 dc.SetPen( m_dottedPen );
             }
         }
@@ -1914,21 +1916,20 @@ void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level
             }
         }
 
             }
         }
 
-        wxPen *pen = wxTRANSPARENT_PEN;
-        wxColour colText;
-
+        wxPen *pen;
+#ifndef __WXMAC__
+        // don't draw rect outline if we already have the background color
+        // under Max
         if ( item->IsSelected() )
         if ( item->IsSelected() )
-        {
-            colText = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_HIGHLIGHTTEXT );
-
-#ifdef __WXMAC__
-               // no rect outline, we already have the background color
+            pen = wxBLACK_PEN;
+        else
+#endif // !__WXMAC__
             pen = wxTRANSPARENT_PEN;
             pen = wxTRANSPARENT_PEN;
-#else
-            if ( m_hasFocus )
-               pen = wxBLACK_PEN;
-#endif
 
 
+        wxColour colText;
+        if ( item->IsSelected() && m_hasFocus )
+        {
+            colText = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_HIGHLIGHTTEXT );
         }
         else
         {
         }
         else
         {
@@ -1948,11 +1949,11 @@ void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level
 
         if (HasFlag( wxTR_ROW_LINES ))
         {
 
         if (HasFlag( wxTR_ROW_LINES ))
         {
-               dc.SetPen( *wxWHITE_PEN );
-               dc.DrawLine( 0, oldY, 10000, oldY );
-               dc.DrawLine( 0, oldY + GetLineHeight(item), 10000, oldY + GetLineHeight(item) );
+            dc.SetPen( *wxWHITE_PEN );
+            dc.DrawLine( 0, oldY, 10000, oldY );
+            dc.DrawLine( 0, oldY + GetLineHeight(item), 10000, oldY + GetLineHeight(item) );
         }
         }
-        
+
         // restore DC objects
         dc.SetBrush( *wxWHITE_BRUSH );
         dc.SetPen( m_dottedPen );
         // restore DC objects
         dc.SetBrush( *wxWHITE_BRUSH );
         dc.SetPen( m_dottedPen );
@@ -2075,14 +2076,16 @@ void wxGenericTreeCtrl::OnSetFocus( wxFocusEvent &WXUNUSED(event) )
 {
     m_hasFocus = TRUE;
 
 {
     m_hasFocus = TRUE;
 
-    if (m_current) RefreshLine( m_current );
+    if (m_current)
+        RefreshLine( m_current );
 }
 
 void wxGenericTreeCtrl::OnKillFocus( wxFocusEvent &WXUNUSED(event) )
 {
     m_hasFocus = FALSE;
 
 }
 
 void wxGenericTreeCtrl::OnKillFocus( wxFocusEvent &WXUNUSED(event) )
 {
     m_hasFocus = FALSE;
 
-    if (m_current) RefreshLine( m_current );
+    if (m_current)
+        RefreshLine( m_current );
 }
 
 void wxGenericTreeCtrl::OnChar( wxKeyEvent &event )
 }
 
 void wxGenericTreeCtrl::OnChar( wxKeyEvent &event )
@@ -2510,6 +2513,13 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event )
         // erase the highlighting
         DrawDropEffect(m_dropTarget);
 
         // erase the highlighting
         DrawDropEffect(m_dropTarget);
 
+        if ( m_oldSelection )
+        {
+            m_oldSelection->SetHilight(TRUE);
+            RefreshLine(m_oldSelection);
+            m_oldSelection = (wxGenericTreeItem *)NULL;
+        }
+
         // generate the drag end event
         wxTreeEvent event(wxEVT_COMMAND_TREE_END_DRAG, GetId());
 
         // generate the drag end event
         wxTreeEvent event(wxEVT_COMMAND_TREE_END_DRAG, GetId());
 
@@ -2522,13 +2532,6 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event )
         m_isDragging = FALSE;
         m_dropTarget = (wxGenericTreeItem *)NULL;
 
         m_isDragging = FALSE;
         m_dropTarget = (wxGenericTreeItem *)NULL;
 
-        if ( m_oldSelection )
-        {
-            m_oldSelection->SetHilight(TRUE);
-            RefreshLine(m_oldSelection);
-            m_oldSelection = (wxGenericTreeItem *)NULL;
-        }
-
         ReleaseMouse();
 
         SetCursor(m_oldCursor);
         ReleaseMouse();
 
         SetCursor(m_oldCursor);