X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7abd9a0331124b50f17d64faec77b7917c9990b5..4e15d1caa03346c126015019c1fdf093033ef40b:/src/msw/artmsw.cpp diff --git a/src/msw/artmsw.cpp b/src/msw/artmsw.cpp index 695fad7d28..22314f1e25 100644 --- a/src/msw/artmsw.cpp +++ b/src/msw/artmsw.cpp @@ -21,6 +21,7 @@ #endif #include "wx/artprov.h" +#include "wx/image.h" #include "wx/msw/wrapwin.h" @@ -35,28 +36,50 @@ protected: const wxSize& size); }; -static wxBitmap CreateFromStdIcon(const char *iconName) +static wxBitmap CreateFromStdIcon(const char *iconName, + const wxArtClient& client) { wxIcon icon(iconName); wxBitmap bmp; bmp.CopyFromIcon(icon); + +#if wxUSE_IMAGE + // The standard native message box icons are in message box size (32x32). + // If they are requested in any size other than the default or message + // box size, they must be rescaled first. + if ( client != wxART_MESSAGE_BOX && client != wxART_OTHER ) + { + const wxSize size = wxArtProvider::GetNativeSizeHint(client); + if ( size != wxDefaultSize ) + { + wxImage img = bmp.ConvertToImage(); + img.Rescale(size.x, size.y); + bmp = wxBitmap(img); + } + } +#endif // wxUSE_IMAGE + return bmp; } wxBitmap wxWindowsArtProvider::CreateBitmap(const wxArtID& id, - const wxArtClient& WXUNUSED(client), + const wxArtClient& client, const wxSize& WXUNUSED(size)) { // handle message box icons specially (wxIcon ctor treat these names // as special cases via wxICOResourceHandler::LoadIcon): + const char *name = NULL; if ( id == wxART_ERROR ) - return CreateFromStdIcon("wxICON_ERROR"); + name = "wxICON_ERROR"; else if ( id == wxART_INFORMATION ) - return CreateFromStdIcon("wxICON_INFORMATION"); + name = "wxICON_INFORMATION"; else if ( id == wxART_WARNING ) - return CreateFromStdIcon("wxICON_WARNING"); + name = "wxICON_WARNING"; else if ( id == wxART_QUESTION ) - return CreateFromStdIcon("wxICON_QUESTION"); + name = "wxICON_QUESTION"; + + if ( name ) + return CreateFromStdIcon(name, client); // for anything else, fall back to generic provider: return wxNullBitmap; @@ -68,7 +91,7 @@ wxBitmap wxWindowsArtProvider::CreateBitmap(const wxArtID& id, /*static*/ void wxArtProvider::InitNativeProvider() { - Push(new wxWindowsArtProvider); + PushBack(new wxWindowsArtProvider); } // ---------------------------------------------------------------------------- @@ -101,6 +124,10 @@ wxSize wxArtProvider::GetNativeSizeHint(const wxArtClient& client) { return wxSize(16, 16); } + else if (client == wxART_LIST) + { + return wxSize(16, 16); + } return wxDefaultSize; }