]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix item selection/focus drawing in generic wxListCtrl.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 11 Jul 2010 10:43:43 +0000 (10:43 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 11 Jul 2010 10:43:43 +0000 (10:43 +0000)
Item focus rectangle was not drawn at all under wxGTK as the code doing it was
disabled with a comment saying that it was drawn elsewhere -- but this wasn't
the case.

So remove #ifdefs for wxGTK/Mac from generic wxListCtrl code and do use
wxRendererNative methods for all platforms. This fixes the appearance of the
control under GTK and if it introduces any problems under Mac, they should be
fixed in its wxRendererNative implementation and not by adding #ifdefs here.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64879 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/generic/listctrl.cpp

index 0a6da82812d92dbe93d837acdbb69033167c7e01..ef666f76e52c05fe4e9fc9dd518be761c9ab000f 100644 (file)
@@ -737,30 +737,19 @@ void wxListLineData::Draw( wxDC *dc )
     wxListItemAttr *attr = GetAttr();
 
     if ( SetAttributes(dc, attr, highlighted) )
-#if ( !defined(__WXGTK20__) && !defined(__WXMAC__) )
-    {
-        dc->DrawRectangle( m_gi->m_rectHighlight );
-    }
-#else
     {
+        int flags = 0;
         if (highlighted)
-        {
-            int flags = wxCONTROL_SELECTED;
-            if (m_owner->HasFocus()
+            flags |= wxCONTROL_SELECTED;
+        if (m_owner->HasFocus()
 #if defined( __WXMAC__ ) && !defined(__WXUNIVERSAL__) && wxOSX_USE_CARBON
-                && IsControlActive( (ControlRef)m_owner->GetHandle() )
+            && IsControlActive( (ControlRef)m_owner->GetHandle() )
 #endif
-            )
-                flags |= wxCONTROL_FOCUSED;
-            wxRendererNative::Get().DrawItemSelectionRect( m_owner, *dc, m_gi->m_rectHighlight, flags );
-
-        }
-        else
-        {
-            dc->DrawRectangle( m_gi->m_rectHighlight );
-        }
+        )
+            flags |= wxCONTROL_FOCUSED;
+        wxRendererNative::Get().
+            DrawItemSelectionRect( m_owner, *dc, m_gi->m_rectHighlight, flags );
     }
-#endif
 
     // just for debugging to better see where the items are
 #if 0
@@ -801,29 +790,16 @@ void wxListLineData::DrawInReportMode( wxDC *dc,
     //       GetAttr() and move these lines into the loop below
     wxListItemAttr *attr = GetAttr();
     if ( SetAttributes(dc, attr, highlighted) )
-#if ( !defined(__WXGTK20__) && !defined(__WXMAC__) )
-    {
-        dc->DrawRectangle( rectHL );
-
-        wxUnusedVar(current);
-    }
-#else
     {
+        int flags = 0;
         if (highlighted)
-        {
-            int flags = wxCONTROL_SELECTED;
-            if (m_owner->HasFocus())
-                flags |= wxCONTROL_FOCUSED;
-            if (current)
-               flags |= wxCONTROL_CURRENT;
-            wxRendererNative::Get().DrawItemSelectionRect( m_owner, *dc, rectHL, flags );
-        }
-        else
-        {
-            dc->DrawRectangle( rectHL );
-        }
+            flags |= wxCONTROL_SELECTED;
+        if (m_owner->HasFocus())
+            flags |= wxCONTROL_FOCUSED;
+        if (current)
+           flags |= wxCONTROL_CURRENT;
+        wxRendererNative::Get().DrawItemSelectionRect( m_owner, *dc, rectHL, flags );
     }
-#endif
 
     wxCoord x = rect.x + HEADER_OFFSET_X,
             yMid = rect.y + rect.height/2;
@@ -2138,20 +2114,15 @@ void wxListMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
         }
     }
 
-#if !defined( __WXMAC__) && !defined(__WXGTK20__)
-    // Don't draw rect outline under Mac at all.
-    // Draw it elsewhere under GTK.
     if ( HasCurrent() )
     {
-        if ( m_hasFocus )
-        {
-            wxRect rect( GetLineHighlightRect( m_current ) );
-            dc.SetPen( *wxBLACK_PEN );
-            dc.SetBrush( *wxTRANSPARENT_BRUSH );
-            dc.DrawRectangle( rect );
-        }
+        int flags = 0;
+        if ( IsHighlighted(m_current) )
+            flags |= wxCONTROL_SELECTED;
+
+        wxRendererNative::Get().
+            DrawFocusRect(this, dc, GetLineHighlightRect(m_current), flags);
     }
-#endif
 }
 
 void wxListMainWindow::HighlightAll( bool on )