Return smaller images for wxART_MENU/BUTTON under OS X.
Requesting images with client id of wxART_MENU/BUTTON used to return the large 32*32 icons because GetNativeSizeHint() wasn't implemented for these client ids. Moreover, under Mac some icons (notably message box ones) are created from the corresponding icon bundle and the code in wxArtProvider::GetBitmap() didn't resize them correctly in this case, fix this. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62299 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -238,6 +238,7 @@ wxArtProvider::~wxArtProvider()
|
||||
break;
|
||||
}
|
||||
|
||||
wxSize sizeNeeded = size;
|
||||
if ( !bmp.Ok() )
|
||||
{
|
||||
// no bitmap created -- as a fallback, try if we can find desired
|
||||
@@ -245,28 +246,31 @@ wxArtProvider::~wxArtProvider()
|
||||
wxIconBundle iconBundle = DoGetIconBundle(id, client);
|
||||
if ( iconBundle.IsOk() )
|
||||
{
|
||||
wxSize sz(size != wxDefaultSize
|
||||
? size
|
||||
: GetNativeSizeHint(client));
|
||||
wxIcon icon(iconBundle.GetIcon(sz));
|
||||
if ( sizeNeeded == wxDefaultSize )
|
||||
sizeNeeded = GetNativeSizeHint(client);
|
||||
|
||||
wxIcon icon(iconBundle.GetIcon(sizeNeeded));
|
||||
if ( icon.IsOk() )
|
||||
{
|
||||
// this icon may be not of the correct size, it will be
|
||||
// rescaled below in such case
|
||||
bmp.CopyFromIcon(icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( bmp.IsOk() )
|
||||
{
|
||||
// if we didn't get the correct size, resize the bitmap
|
||||
// if we didn't get the correct size, resize the bitmap
|
||||
#if wxUSE_IMAGE && (!defined(__WXMSW__) || wxUSE_WXDIB)
|
||||
if ( size != wxDefaultSize &&
|
||||
(bmp.GetWidth() != size.x || bmp.GetHeight() != size.y) )
|
||||
if ( bmp.IsOk() && sizeNeeded != wxDefaultSize )
|
||||
{
|
||||
if ( bmp.GetSize() != sizeNeeded )
|
||||
{
|
||||
wxImage img = bmp.ConvertToImage();
|
||||
img.Rescale(size.x, size.y);
|
||||
img.Rescale(sizeNeeded.x, sizeNeeded.y);
|
||||
bmp = wxBitmap(img);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif // wxUSE_IMAGE
|
||||
|
||||
sm_cache->PutBitmap(hashId, bmp);
|
||||
}
|
||||
|
@@ -117,6 +117,14 @@ wxSize wxArtProvider::GetNativeSizeHint(const wxArtClient& client)
|
||||
// "32 x 32 pixels is the recommended size"
|
||||
return wxSize(32, 32);
|
||||
}
|
||||
else if ( client == wxART_BUTTON || client == wxART_MENU )
|
||||
{
|
||||
// Mac UI doesn't use any images in neither buttons nor menus in
|
||||
// general but the code using wxArtProvider can use wxART_BUTTON to
|
||||
// find the icons of a roughly appropriate size for the buttons and
|
||||
// 16x16 seems to be the best choice for this kind of use
|
||||
return wxSize(16, 16);
|
||||
}
|
||||
|
||||
return wxDefaultSize;
|
||||
}
|
||||
|
Reference in New Issue
Block a user