Fix bezel used for bitmap buttons in wxOSX/Cocoa.
Don't use NSRoundedBezelStyle for bitmap buttons as this bezel has fixed height. Instead, use NSRegularSquareBezelStyle which can used with buttons of any size and is the correct bezel to use for the buttons mostly identified by their icon according to Apple docs. Notice that we still use the standard bezel for the "small" (where "small" is arbitrarily defined by the hard coded 20 pixels height) icons as those are usually used in addition to the text and not replacing it and so it makes more sense to use the same bezel as for the normal buttons for them. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73056 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
6ceeeafd56
commit
0c2e6e8b36
@ -208,7 +208,8 @@ void
|
||||
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
|
||||
@ -220,10 +221,13 @@ SetBezelStyleFromBorderFlags(NSButton *v,
|
||||
}
|
||||
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 )
|
||||
@ -238,7 +242,7 @@ SetBezelStyleFromBorderFlags(NSButton *v,
|
||||
break;
|
||||
|
||||
case wxBORDER_SUNKEN:
|
||||
bezel = isSingleLine ? NSTexturedRoundedBezelStyle
|
||||
bezel = isSimpleText ? NSTexturedRoundedBezelStyle
|
||||
: NSSmallSquareBezelStyle;
|
||||
break;
|
||||
|
||||
@ -250,7 +254,7 @@ SetBezelStyleFromBorderFlags(NSButton *v,
|
||||
case wxBORDER_STATIC:
|
||||
case wxBORDER_RAISED:
|
||||
case wxBORDER_THEME:
|
||||
bezel = isSingleLine ? NSRoundedBezelStyle
|
||||
bezel = isSimpleText ? NSRoundedBezelStyle
|
||||
: NSRegularSquareBezelStyle;
|
||||
break;
|
||||
}
|
||||
@ -340,7 +344,7 @@ wxWidgetImplType* wxWidgetImpl::CreateBitmapButton( wxWindowMac* wxpeer,
|
||||
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() ];
|
||||
|
@ -30,7 +30,8 @@
|
||||
extern "C" void SetBezelStyleFromBorderFlags(NSButton *v,
|
||||
long style,
|
||||
wxWindowID winid = wxID_ANY,
|
||||
const wxString& label = wxString());
|
||||
const wxString& label = wxString(),
|
||||
const wxBitmap& bitmap = wxBitmap());
|
||||
|
||||
wxWidgetImplType* wxWidgetImpl::CreateToggleButton( wxWindowMac* wxpeer,
|
||||
wxWindowMac* WXUNUSED(parent),
|
||||
@ -63,7 +64,7 @@ wxWidgetImplType* wxWidgetImpl::CreateBitmapToggleButton( wxWindowMac* wxpeer,
|
||||
NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
|
||||
wxNSButton* v = [[wxNSButton alloc] initWithFrame:r];
|
||||
|
||||
SetBezelStyleFromBorderFlags(v, style, winid);
|
||||
SetBezelStyleFromBorderFlags(v, style, winid, wxString(), label);
|
||||
|
||||
if (label.IsOk())
|
||||
[v setImage:label.GetNSImage() ];
|
||||
|
Loading…
Reference in New Issue
Block a user