return static_cast<NSButton *>(m_osxView);
}
-// Set the keyboard accelerator key from the label (e.g. "Click &Me")
-void wxButton::OSXUpdateAfterLabelChange(const wxString& 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;
- }
-
- wxButtonCocoaImpl *impl = static_cast<wxButtonCocoaImpl*>(GetPeer());
- impl->SetAcceleratorFromLabel(label);
-}
-
// Set bezel style depending on the wxBORDER_XXX flags specified by the style
// and also accounting for the label (bezels are different for multiline
// buttons and normal ones) and the ID (special bezel is used for help button).
SetBezelStyleFromBorderFlags(NSButton *v,
long style,
wxWindowID winid,
- const wxString& label = wxString())
+ const wxString& label = wxString(),
+ const wxBitmap& bitmap = wxBitmap())
{
// We can't display a custom label inside a button with help bezel style so
// we only use it if we are using the default label. wxButton itself checks
}
else
{
- // We can't use rounded bezel styles for multiline buttons 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 isSingleLine = label.find_first_of("\n\r") == wxString::npos;
+ // 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 )
break;
case wxBORDER_SUNKEN:
- bezel = isSingleLine ? NSTexturedRoundedBezelStyle
+ bezel = isSimpleText ? NSTexturedRoundedBezelStyle
: NSSmallSquareBezelStyle;
break;
case wxBORDER_STATIC:
case wxBORDER_RAISED:
case wxBORDER_THEME:
- bezel = isSingleLine ? NSRoundedBezelStyle
+ bezel = isSimpleText ? NSRoundedBezelStyle
: NSRegularSquareBezelStyle;
break;
}
}
}
+// 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;
+ }
+
+ impl->SetAcceleratorFromLabel(label);
+}
+
wxWidgetImplType* wxWidgetImpl::CreateButton( wxWindowMac* wxpeer,
wxWindowMac* WXUNUSED(parent),
NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
wxNSButton* v = [[wxNSButton alloc] initWithFrame:r];
- SetBezelStyleFromBorderFlags(v, style, winid);
+ SetBezelStyleFromBorderFlags(v, style, winid, wxString(), bitmap);
if (bitmap.IsOk())
[v setImage:bitmap.GetNSImage() ];