- // see trac #11128 for a thorough discussion
- if ( (style & wxBORDER_MASK) == wxBORDER_RAISED )
- [v setBezelStyle:NSRegularSquareBezelStyle];
- else if ( (style & wxBORDER_MASK) == wxBORDER_SUNKEN )
- [v setBezelStyle:NSSmallSquareBezelStyle];
- else
- [v setBezelStyle:NSShadowlessSquareBezelStyle];
+ // We can't use rounded bezel styles neither for multiline buttons nor
+ // for buttons containing (big) icons as they are only meant to be used
+ // at certain sizes, so the style used depends on whether the label is
+ // single or multi line.
+ const bool
+ isSimpleText = (label.find_first_of("\n\r") == wxString::npos)
+ && (!bitmap.IsOk() || bitmap.GetHeight() < 20);
+
+ NSBezelStyle bezel;
+ switch ( style & wxBORDER_MASK )
+ {
+ case wxBORDER_NONE:
+ bezel = NSShadowlessSquareBezelStyle;
+ [v setBordered:NO];
+ break;
+
+ case wxBORDER_SIMPLE:
+ bezel = NSShadowlessSquareBezelStyle;
+ break;
+
+ case wxBORDER_SUNKEN:
+ bezel = isSimpleText ? NSTexturedRoundedBezelStyle
+ : NSSmallSquareBezelStyle;
+ break;
+
+ default:
+ wxFAIL_MSG( "Unknown border style" );
+ // fall through
+
+ case 0:
+ case wxBORDER_STATIC:
+ case wxBORDER_RAISED:
+ case wxBORDER_THEME:
+ bezel = isSimpleText ? NSRoundedBezelStyle
+ : NSRegularSquareBezelStyle;
+ break;
+ }
+
+ [v setBezelStyle:bezel];
+ }
+}
+
+// Set the keyboard accelerator key from the label (e.g. "Click &Me")
+void wxButton::OSXUpdateAfterLabelChange(const wxString& label)
+{
+ wxButtonCocoaImpl *impl = static_cast<wxButtonCocoaImpl*>(GetPeer());
+
+ // Update the bezel style as may be necessary if our new label is multi
+ // line while the old one wasn't (or vice versa).
+ SetBezelStyleFromBorderFlags(impl->GetNSButton(),
+ GetWindowStyle(),
+ GetId(),
+ label);
+
+
+ // Skip setting the accelerator for the default buttons as this would
+ // overwrite the default "Enter" which should be preserved.
+ wxTopLevelWindow * const
+ tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
+ if ( tlw )
+ {
+ if ( tlw->GetDefaultItem() == this )
+ return;