]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/renderer.cpp
Added automatic dialog scrolling ability
[wxWidgets.git] / src / mac / carbon / renderer.cpp
index e72aa9a7481dcf131d8f9de46d37c85e79b738cd..abcc1d6aa2b655e960921e2b1af05663199ec120 100644 (file)
@@ -121,23 +121,14 @@ int wxRendererMac::DrawHeaderButton( wxWindow *win,
     HIRect headerRect = CGRectMake( x, y, w, h );
     if ( !dc.IsKindOf( CLASSINFO( wxPaintDC ) ) )
     {
-        Rect r =
-        {
-            (short) headerRect.origin.y, (short) headerRect.origin.x,
-            (short) (headerRect.origin.y + headerRect.size.height),
-            (short) (headerRect.origin.x + headerRect.size.width)
-        };
-
-        RgnHandle updateRgn = NewRgn();
-        RectRgn( updateRgn, &r );
-        HIViewSetNeedsDisplayInRegion( (HIViewRef) win->GetHandle(), updateRgn, true );
-        DisposeRgn( updateRgn );
+        win->Refresh( &rect );
     }
     else
     {
         CGContextRef cgContext;
+        wxGCDCImpl *impl = (wxGCDCImpl*) dc.GetImpl();
 
-        cgContext = (CGContextRef) dc.GetGraphicsContext()->GetNativeContext();
+        cgContext = (CGContextRef) impl->GetGraphicsContext()->GetNativeContext();
 
         {
             HIThemeButtonDrawInfo drawInfo;
@@ -213,23 +204,14 @@ void wxRendererMac::DrawTreeItemButton( wxWindow *win,
     HIRect headerRect = CGRectMake( x, y, w, h );
     if ( !dc.IsKindOf( CLASSINFO( wxPaintDC ) ) )
     {
-        Rect r =
-    {
-            (short) headerRect.origin.y, (short) headerRect.origin.x,
-            (short) (headerRect.origin.y + headerRect.size.height),
-            (short) (headerRect.origin.x + headerRect.size.width)
-        };
-
-        RgnHandle updateRgn = NewRgn();
-        RectRgn( updateRgn, &r );
-        HIViewSetNeedsDisplayInRegion( (HIViewRef) win->GetHandle(), updateRgn, true );
-        DisposeRgn( updateRgn );
+        win->Refresh( &rect );
     }
     else
     {
         CGContextRef cgContext;
 
-        cgContext = (CGContextRef) dc.GetGraphicsContext()->GetNativeContext();
+        wxGCDCImpl *impl = (wxGCDCImpl*) dc.GetImpl();
+        cgContext = (CGContextRef) impl->GetGraphicsContext()->GetNativeContext();
 
         HIThemeButtonDrawInfo drawInfo;
         HIRect labelRect;
@@ -268,24 +250,15 @@ void wxRendererMac::DrawSplitterSash( wxWindow *win,
 
     if ( !dc.IsKindOf( CLASSINFO( wxPaintDC ) ) )
     {
-        Rect r =
-        {
-            (short) splitterRect.origin.y,
-            (short) splitterRect.origin.x,
-            (short) (splitterRect.origin.y + splitterRect.size.height),
-            (short) (splitterRect.origin.x + splitterRect.size.width)
-        };
-
-        RgnHandle updateRgn = NewRgn();
-        RectRgn( updateRgn, &r );
-        HIViewSetNeedsDisplayInRegion( (HIViewRef) win->GetHandle(), updateRgn, true );
-        DisposeRgn( updateRgn );
-    }
+        wxRect rect( (int) splitterRect.origin.x, (int) splitterRect.origin.y, (int) splitterRect.size.width,
+                     (int) splitterRect.size.height );
+        win->Refresh( &rect );
+   }
     else
     {
         CGContextRef cgContext;
-
-        cgContext = (CGContextRef) dc.GetGraphicsContext()->GetNativeContext();
+        wxGCDCImpl *impl = (wxGCDCImpl*) dc.GetImpl();
+        cgContext = (CGContextRef) impl->GetGraphicsContext()->GetNativeContext();
 
         HIThemeSplitterDrawInfo drawInfo;
         drawInfo.version = 0;
@@ -296,27 +269,18 @@ void wxRendererMac::DrawSplitterSash( wxWindow *win,
 }
 
 void
-wxRendererMac::DrawItemSelectionRect(wxWindow *win,
+wxRendererMac::DrawItemSelectionRect(wxWindow * WXUNUSED(win),
                                      wxDC& dc,
                                      const wxRect& rect,
-                                     int flags )
+                                     int flags)
 {
     if ( !(flags & wxCONTROL_SELECTED) )
         return;
-        
-    if (flags & wxCONTROL_FOCUSED)
-    {
-        if (!IsControlActive( (ControlRef)win->GetHandle() ))
-            flags = wxCONTROL_SELECTED;
-    }
 
-    RGBColor selColor;
-    GetThemeBrushAsColor(flags & wxCONTROL_FOCUSED
-                            ? kThemeBrushAlternatePrimaryHighlightColor
-                            : kThemeBrushSecondaryHighlightColor,
-                         32, true, &selColor);
-
-    wxBrush selBrush(selColor);
+    wxColour col( wxMacCreateCGColorFromHITheme( (flags & wxCONTROL_FOCUSED) ?
+                                                 kThemeBrushAlternatePrimaryHighlightColor
+                                                                             : kThemeBrushSecondaryHighlightColor ) );
+    wxBrush selBrush( col );
 
     dc.SetPen( *wxTRANSPARENT_PEN );
     dc.SetBrush( selBrush );
@@ -343,22 +307,13 @@ wxRendererMac::DrawMacThemeButton(wxWindow *win,
     HIRect headerRect = CGRectMake( x, y, w, h );
     if ( !dc.IsKindOf( CLASSINFO( wxPaintDC ) ) )
     {
-        Rect r =
-        {
-            (short) headerRect.origin.y, (short) headerRect.origin.x,
-            (short) (headerRect.origin.y + headerRect.size.height),
-            (short) (headerRect.origin.x + headerRect.size.width)
-        };
-
-        RgnHandle updateRgn = NewRgn();
-        RectRgn( updateRgn, &r );
-        HIViewSetNeedsDisplayInRegion( (HIViewRef) win->GetHandle(), updateRgn, true );
-        DisposeRgn( updateRgn );
+        win->Refresh( &rect );
     }
     else
     {
+        wxGCDCImpl *impl = (wxGCDCImpl*) dc.GetImpl();
         CGContextRef cgContext;
-        cgContext = (CGContextRef) dc.GetGraphicsContext()->GetNativeContext();
+        cgContext = (CGContextRef) impl->GetGraphicsContext()->GetNativeContext();
 
         HIThemeButtonDrawInfo drawInfo;
         HIRect labelRect;