]> git.saurik.com Git - wxWidgets.git/commitdiff
Implement wxRendererMac::DrawItemSelectionRect and move the generic wxTreeCtrl to...
authorKevin Ollivier <kevino@theolliviers.com>
Sun, 19 Nov 2006 06:28:47 +0000 (06:28 +0000)
committerKevin Ollivier <kevino@theolliviers.com>
Sun, 19 Nov 2006 06:28:47 +0000 (06:28 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43506 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/generic/treectlg.cpp
src/mac/carbon/renderer.cpp

index bfd43b7dc8b2f912b2da184c75713767b562ad67..a20a4fabe201d02a0d6b7ba6de20c42a0ebce284 100644 (file)
@@ -754,13 +754,6 @@ void wxGenericTreeCtrl::Init()
     m_indent = 15;
     m_spacing = 18;
 
-#ifdef __WXMAC__
-    // OS X sel item highlight color differs from text highlight color, which is
-    // what wxSYS_COLOUR_HIGHLIGHT returns. 
-    RGBColor hilight;
-    GetThemeBrushAsColor(kThemeBrushAlternatePrimaryHighlightColor, 32, true, &hilight);
-    m_hilightBrush = new wxBrush( wxColour(hilight.red, hilight.green, hilight.blue ), wxSOLID );
-#else
     m_hilightBrush = new wxBrush
                          (
                             wxSystemSettings::GetColour
@@ -769,14 +762,7 @@ void wxGenericTreeCtrl::Init()
                             ),
                             wxSOLID
                          );
-#endif
 
-#ifdef __WXMAC__
-    // on Mac, this color also differs from the wxSYS_COLOUR_BTNSHADOW, enough to be noticable.
-    // I don't know if BTNSHADOW is appropriate in other contexts, so I'm just changing it here.
-    GetThemeBrushAsColor(kThemeBrushSecondaryHighlightColor, 32, true, &hilight);
-    m_hilightUnfocusedBrush = new wxBrush( wxColour(hilight.red, hilight.green, hilight.blue ), wxSOLID );
-#else
     m_hilightUnfocusedBrush = new wxBrush
                               (
                                  wxSystemSettings::GetColour
@@ -785,7 +771,7 @@ void wxGenericTreeCtrl::Init()
                                  ),
                                  wxSOLID
                               );
-#endif
+
     m_imageListButtons = NULL;
     m_ownsImageListButtons = false;
 
@@ -2236,7 +2222,7 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
         x=0;
         GetVirtualSize(&w, &h);
         wxRect rect( x, item->GetY()+offset, w, total_h-offset);
-#ifndef __WXGTK20__
+#if !defined(__WXGTK20__) && !defined(__WXMAC__)
         dc.DrawRectangle(rect);
 #else
         if (!item->IsSelected())
@@ -2263,7 +2249,7 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
             // background colour.
             wxRect rect( item->GetX() + image_w - 2, item->GetY()+offset,
                          item->GetWidth() - image_w + 2, total_h-offset );
-#ifndef __WXGTK20__
+#if !defined(__WXGTK20__) && !defined(__WXMAC__)
             dc.DrawRectangle( rect );
 #else
             rect.x -= 1;
@@ -2284,7 +2270,7 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
         {
             wxRect rect( item->GetX()-2, item->GetY()+offset,
                          item->GetWidth()+2, total_h-offset );
-#ifndef __WXGTK20__
+#if !defined(__WXGTK20__) && !defined(__WXMAC__)
             dc.DrawRectangle( rect );
 #else
             if ( attr && attr->HasBackgroundColour() )
index 8cc6fae7ddc8d8d74ff6823d7767dfdf539b8d38..71bb87221e37279299d2e4c22329ac2ee327d929 100644 (file)
@@ -56,6 +56,11 @@ public:
         wxCoord position,
         wxOrientation orient,
         int flags = 0 );
+        
+    virtual void DrawItemSelectionRect(wxWindow *win,
+                                       wxDC& dc,
+                                       const wxRect& rect,
+                                       int flags = 0);
 
 private:
     // the tree buttons
@@ -341,3 +346,25 @@ void wxRendererMac::DrawSplitterSash( wxWindow *win,
 #endif
     }
 }
+
+void
+wxRendererMac::DrawItemSelectionRect(wxWindow *win,
+                                     wxDC& dc,
+                                     const wxRect& rect,
+                                     int flags )
+{
+    RGBColor selColor; 
+    if (flags & wxCONTROL_SELECTED)
+    {
+        if (flags & wxCONTROL_FOCUSED)
+            GetThemeBrushAsColor(kThemeBrushAlternatePrimaryHighlightColor, 32, true, &selColor);
+        else
+            GetThemeBrushAsColor(kThemeBrushSecondaryHighlightColor, 32, true, &selColor);
+    }
+    
+    wxBrush selBrush = wxBrush( wxColour( selColor.red, selColor.green, selColor.blue ), wxSOLID );
+
+    dc.SetPen( *wxTRANSPARENT_PEN );
+    dc.SetBrush( selBrush );
+    dc.DrawRectangle( rect );
+}