]> git.saurik.com Git - wxWidgets.git/commitdiff
Use Cocoa methods instead of wx ones in wxDVC font setting code.
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 12 Oct 2009 17:30:35 +0000 (17:30 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 12 Oct 2009 17:30:35 +0000 (17:30 +0000)
Use NSFontManager to create bold or italic version of the font instead of
using wxFont. This works better for the bold attribute, but setting the italic
one still doesn't do anything.

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

src/osx/cocoa/dataview.mm

index 224c89c53f825e7fdbd869db86a417af1033c674..46930000675ad716b843635d6e57c7f488a4232d 100644 (file)
@@ -1525,12 +1525,19 @@ wxWidgetImplType* CreateDataView(wxWindowMac* wxpeer, wxWindowMac* WXUNUSED(pare
     {
         if ( attr.HasFont() )
         {
-            wxFont font(dvc->GetFont());
-            if ( attr.GetBold() )
-                font.MakeBold();
-            if ( attr.GetItalic() )
-                font.MakeItalic();
-            [cell setFont:font.OSXGetNSFont()];
+            // FIXME: using wxFont methods here doesn't work for some reason
+            NSFontManager * const fm = [NSFontManager sharedFontManager];
+            NSFont *font = [cell font];
+            if ( font )
+            {
+                if ( attr.GetBold() )
+                    font = [fm convertFont:font toHaveTrait:NSBoldFontMask];
+                if ( attr.GetItalic() )
+                    font = [fm convertFont:font toHaveTrait:NSItalicFontMask];
+
+                [cell setFont:font];
+            }
+            //else: can't change font if the cell doesn't have any
         }
 
         // we can set font for any cell but only NSTextFieldCell provides a