* makes GetIcon() and GetBitmap() behave in the same way again (i.e. GetBitmap
falls back to CreateIconBundle too)
* GetIcon() used to call CreateIconBundle() first, before CreateBitmap() - this
doesn't make sense, inverted
* GetIconBundle() falls back to GetIcon() if provider's CreateIconBundle()
doesn't return anything and vice versa: GetIcon()/GetBitmap() falls back to
GetIconBundle() if CreateBitmap() doesn't return anything
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59930
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
// only once per instance's lifetime for each requested wxArtID.
virtual wxBitmap CreateBitmap(const wxArtID& WXUNUSED(id),
const wxArtClient& WXUNUSED(client),
// only once per instance's lifetime for each requested wxArtID.
virtual wxBitmap CreateBitmap(const wxArtID& WXUNUSED(id),
const wxArtClient& WXUNUSED(client),
- const wxSize& WXUNUSED(size)) { return wxNullBitmap; }
+ const wxSize& WXUNUSED(size))
+ {
+ return wxNullBitmap;
+ }
virtual wxIconBundle CreateIconBundle(const wxArtID& WXUNUSED(id),
const wxArtClient& WXUNUSED(client))
virtual wxIconBundle CreateIconBundle(const wxArtID& WXUNUSED(id),
const wxArtClient& WXUNUSED(client))
private:
static void CommonAddingProvider();
private:
static void CommonAddingProvider();
+ static wxIconBundle DoGetIconBundle(const wxArtID& id,
+ const wxArtClient& client);
private:
// list of providers:
private:
// list of providers:
{
bmp = node->GetData()->CreateBitmap(id, client, size);
if ( bmp.Ok() )
{
bmp = node->GetData()->CreateBitmap(id, client, size);
if ( bmp.Ok() )
+ break;
+ }
+
+ if ( !bmp.Ok() )
+ {
+ // no bitmap created -- as a fallback, try if we can find desired
+ // icon in a bundle
+ wxIconBundle iconBundle = DoGetIconBundle(id, client);
+ if ( iconBundle.IsOk() )
+ wxSize sz(size != wxDefaultSize
+ ? size
+ : GetNativeSizeHint(client));
+ wxIcon icon(iconBundle.GetIcon(sz));
+ if ( icon.IsOk() )
+ bmp.CopyFromIcon(icon);
+ }
+ }
+
+ if ( bmp.IsOk() )
+ {
+ // 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) )
- {
- wxImage img = bmp.ConvertToImage();
- img.Rescale(size.x, size.y);
- bmp = wxBitmap(img);
- }
-#endif
- break;
+ if ( size != wxDefaultSize &&
+ (bmp.GetWidth() != size.x || bmp.GetHeight() != size.y) )
+ {
+ wxImage img = bmp.ConvertToImage();
+ img.Rescale(size.x, size.y);
+ bmp = wxBitmap(img);
- // We could try the IconBundles here and convert what we find
- // to a bitmap.
sm_cache->PutBitmap(hashId, bmp);
sm_cache->PutBitmap(hashId, bmp);
-/*static*/ wxIconBundle wxArtProvider::GetIconBundle(const wxArtID& id, const wxArtClient& client)
+/*static*/
+wxIconBundle wxArtProvider::GetIconBundle(const wxArtID& id, const wxArtClient& client)
+{
+ wxIconBundle iconbundle(DoGetIconBundle(id, client));
+
+ if ( iconbundle.IsOk() )
+ {
+ return iconbundle;
+ }
+ else
+ {
+ // fall back to single-icon bundle
+ return wxIconBundle(GetIcon(id, client));
+ }
+}
+
+/*static*/
+wxIconBundle wxArtProvider::DoGetIconBundle(const wxArtID& id, const wxArtClient& client)
{
// safety-check against writing client,id,size instead of id,client,size:
wxASSERT_MSG( client.Last() == _T('C'), _T("invalid 'client' parameter") );
{
// safety-check against writing client,id,size instead of id,client,size:
wxASSERT_MSG( client.Last() == _T('C'), _T("invalid 'client' parameter") );
const wxArtClient& client,
const wxSize& size)
{
const wxArtClient& client,
const wxSize& size)
{
- wxCHECK_MSG( sm_providers, wxNullIcon, _T("no wxArtProvider exists") );
-
- // First look for an appropriate icon bundle - this will give us the best icon
- wxIconBundle iconBundle = GetIconBundle(id, client);
- if ( iconBundle.IsOk() )
- return iconBundle.GetIcon(size);
-
- // If there is no icon bundle then look for a bitmap
wxBitmap bmp = GetBitmap(id, client, size);
wxBitmap bmp = GetBitmap(id, client, size);
return wxNullIcon;
wxIcon icon;
return wxNullIcon;
wxIcon icon;
class wxMacArtProvider : public wxArtProvider
{
protected:
class wxMacArtProvider : public wxArtProvider
{
protected:
- virtual wxBitmap CreateBitmap(const wxArtID& id, const wxArtClient& client,
- const wxSize& size);
virtual wxIconBundle CreateIconBundle(const wxArtID& id,
const wxArtClient& client);
};
virtual wxIconBundle CreateIconBundle(const wxArtID& id,
const wxArtClient& client);
};
return wxMacArtProvider_CreateIconBundle(id);
}
return wxMacArtProvider_CreateIconBundle(id);
}
-// ----------------------------------------------------------------------------
-// CreateBitmap
-// ----------------------------------------------------------------------------
-
-wxBitmap wxMacArtProvider::CreateBitmap(const wxArtID& id,
- const wxArtClient& client,
- const wxSize& reqSize)
-{
- wxIconBundle ic(CreateIconBundle(id, client));
- if (ic.IsOk())
- {
- wxIcon theIcon(ic.GetIcon(reqSize));
- return wxBitmap(theIcon);
- }
-
- return wxNullBitmap;
-}
-
// ----------------------------------------------------------------------------
// wxArtProvider::GetNativeSizeHint()
// ----------------------------------------------------------------------------
// wxArtProvider::GetNativeSizeHint()