]> git.saurik.com Git - wxWidgets.git/commitdiff
Added native focus rectangle drawing for wxMac (CG only at present)
authorJulian Smart <julian@anthemion.co.uk>
Fri, 31 Aug 2007 14:56:18 +0000 (14:56 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Fri, 31 Aug 2007 14:56:18 +0000 (14:56 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48514 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/mac/carbon/renderer.cpp

index abac02650a74843c33d285c41f62961969841814..e0f9bc23e2f4734b4eb8e1cac2bf0d7226c5f01e 100644 (file)
@@ -72,6 +72,8 @@ public:
                                        const wxRect& rect,
                                        int flags = 0);
 
+    virtual void DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, int flags = 0);
+
 private:
     void DrawMacThemeButton(wxWindow *win,
                             wxDC& dc,
@@ -206,8 +208,8 @@ int wxRendererMac::DrawHeaderButton( wxWindow *win,
 
 int wxRendererMac::GetHeaderButtonHeight(wxWindow* WXUNUSED(win))
 {
-    SInt32             standardHeight;
-    OSStatus           errStatus;
+    SInt32      standardHeight;
+    OSStatus        errStatus;
 
     errStatus = GetThemeMetric( kThemeMetricListHeaderHeight, &standardHeight );
     if (errStatus == noErr)
@@ -504,3 +506,47 @@ wxRendererMac::DrawPushButton(wxWindow *win,
                        kind, kThemeAdornmentNone);
 }
 
+void
+wxRendererMac::DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, int flags)
+{
+    if (!win)
+    {
+        wxDelegateRendererNative::DrawFocusRect(win, dc, rect, flags);
+        return;
+    }
+
+#if wxMAC_USE_CORE_GRAPHICS
+    {
+        CGRect cgrect = CGRectMake( rect.x , rect.y , rect.width, rect.height ) ;
+
+        HIThemeFrameDrawInfo info ;
+        memset( &info, 0 , sizeof(info) ) ;
+
+        info.version = 0 ;
+        info.kind = 0 ;
+        info.state = kThemeStateActive;
+        info.isFocused = true ;
+
+        CGContextRef cgContext = (CGContextRef) win->MacGetCGContextRef() ;
+        wxASSERT( cgContext ) ;
+
+        HIThemeDrawFocusRect( &cgrect , true , cgContext , kHIThemeOrientationNormal ) ;
+    }
+#else
+    // FIXME: not yet working for !wxMAC_USE_CORE_GRAPHICS
+    {
+        Rect r;
+        r.left = rect.x; r.top = rect.y; r.right = rect.GetRight(); r.bottom = rect.GetBottom();
+        wxTopLevelWindowMac* top = win->MacGetTopLevelWindow();
+        if ( top )
+        {
+            wxPoint pt(0, 0) ;
+            wxMacControl::Convert( &pt , win->GetPeer() , top->GetPeer() ) ;
+            OffsetRect( &r , pt.x , pt.y ) ;
+        }
+
+        DrawThemeFocusRect( &r , true ) ;
+    }
+#endif
+}
+