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
+ wxSize sizeNeeded = size;
if ( !bmp.Ok() )
{
// no bitmap created -- as a fallback, try if we can find desired
if ( !bmp.Ok() )
{
// no bitmap created -- as a fallback, try if we can find desired
wxIconBundle iconBundle = DoGetIconBundle(id, client);
if ( iconBundle.IsOk() )
{
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));
+ {
+ // this icon may be not of the correct size, it will be
+ // rescaled below in such case
- 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 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();
{
wxImage img = bmp.ConvertToImage();
- img.Rescale(size.x, size.y);
+ img.Rescale(sizeNeeded.x, sizeNeeded.y);
sm_cache->PutBitmap(hashId, bmp);
}
sm_cache->PutBitmap(hashId, bmp);
}
// "32 x 32 pixels is the recommended size"
return wxSize(32, 32);
}
// "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);
+ }