]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/button.mm
under cocoa a too-small static box leads to erroneous layout information, therefore...
[wxWidgets.git] / src / osx / cocoa / button.mm
index b44ef3cd92a2d2a4c86da3e86ad70c6b9c89161a..2eb0889fe250f7d0d224471f34246173550f4187 100644 (file)
 
 #include "wx/osx/private.h"
 
+#if wxUSE_MARKUP
+    #include "wx/osx/cocoa/private/markuptoattr.h"
+#endif // wxUSE_MARKUP
+
+
 wxSize wxButton::DoGetBestSize() const
 {
     // We only use help button bezel if we don't have any (non standard) label
@@ -125,6 +130,25 @@ public:
         wxWidgetCocoaImpl::SetBitmap(bitmap);
     }
 
+#if wxUSE_MARKUP
+    virtual void SetLabelMarkup(const wxString& markup)
+    {
+        wxMarkupToAttrString toAttr(GetWXPeer(), markup);
+        NSMutableAttributedString *attrString = toAttr.GetNSAttributedString();
+
+        // Button text is always centered.
+        NSMutableParagraphStyle *
+            paragraphStyle = [[NSMutableParagraphStyle alloc] init];
+        [paragraphStyle setAlignment: NSCenterTextAlignment];
+        [attrString addAttribute:NSParagraphStyleAttributeName
+                    value:paragraphStyle
+                    range:NSMakeRange(0, [attrString length])];
+        [paragraphStyle release];
+
+        [GetNSButton() setAttributedTitle:attrString];
+    }
+#endif // wxUSE_MARKUP
+
     void SetPressedBitmap( const wxBitmap& bitmap )
     {
         NSButton* button = GetNSButton();
@@ -178,6 +202,8 @@ private:
     }
 };
 
+} // anonymous namespace
+
 extern "C" void SetBezelStyleFromBorderFlags(NSButton *v, long style);
     
 // set bezel style depending on the wxBORDER_XXX flags specified by the style
@@ -200,7 +226,6 @@ void SetBezelStyleFromBorderFlags(NSButton *v, long style)
     }
 }
 
-} // anonymous namespace
 
 wxWidgetImplType* wxWidgetImpl::CreateButton( wxWindowMac* wxpeer,
                                     wxWindowMac* WXUNUSED(parent),