Beispiel #1
0
wxBitmap wxWindowsArtProvider::CreateBitmap(const wxArtID& id,
                                            const wxArtClient& WXUNUSED(client),
                                            const wxSize& WXUNUSED(size))
{
    // handle message box icons specially (wxIcon ctor treat these names
    // as special cases via wxICOResourceHandler::LoadIcon):
    if ( id == wxART_ERROR )
        return CreateFromStdIcon("wxICON_ERROR");
    else if ( id == wxART_INFORMATION )
        return CreateFromStdIcon("wxICON_INFORMATION");
    else if ( id == wxART_WARNING )
        return CreateFromStdIcon("wxICON_WARNING");
    else if ( id == wxART_QUESTION )
        return CreateFromStdIcon("wxICON_QUESTION");

    // for anything else, fall back to generic provider:
    return wxNullBitmap;
}
Beispiel #2
0
wxBitmap wxWindowsArtProvider::CreateBitmap(const wxArtID& id,
                                            const wxArtClient& client,
                                            const wxSize& size)
{
    wxBitmap bitmap;

#ifdef wxHAS_SHGetStockIconInfo
    // first try to use SHGetStockIconInfo, available only on Vista and higher
    SHSTOCKICONID stockIconId = MSWGetStockIconIdForArtProviderId( id );
    if ( stockIconId != SIID_INVALID )
    {
        WinStruct<SHSTOCKICONINFO> sii;

        UINT uFlags = SHGSI_ICON;
        if ( size != wxDefaultSize )
        {
            if ( size.x <= 16 )
                uFlags |= SHGSI_SMALLICON;
            else if ( size.x >= 64 )
                uFlags |= SHGSI_LARGEICON;
        }

        HRESULT res = MSW_SHGetStockIconInfo(stockIconId, uFlags, &sii);
        if ( res == S_OK )
        {
            wxIcon icon;
            icon.CreateFromHICON( (WXHICON)sii.hIcon );

            wxBitmap bitmap( icon );
            ::DestroyIcon(sii.hIcon);

            if ( bitmap.IsOk() )
                return bitmap;
        }
    }
#endif // wxHAS_SHGetStockIconInfo


#if wxUSE_FSVOLUME
    // now try SHGetFileInfo
    wxFSVolumeKind volKind = wxFS_VOL_OTHER;
    if ( id == wxART_HARDDISK )
        volKind = wxFS_VOL_DISK;
    else if ( id == wxART_FLOPPY )
        volKind = wxFS_VOL_FLOPPY;
    else if ( id == wxART_CDROM )
        volKind = wxFS_VOL_CDROM;

    if ( volKind != wxFS_VOL_OTHER )
    {
        bitmap = GetDriveBitmapForVolumeType(volKind, size);
        if ( bitmap.IsOk() )
            return bitmap;
    }
#endif // wxUSE_FSVOLUME

    // notice that the directory used here doesn't need to exist
    if ( id == wxART_FOLDER )
        bitmap = MSWGetBitmapForPath("C:\\wxdummydir\\", size );
    else if ( id == wxART_FOLDER_OPEN )
        bitmap = MSWGetBitmapForPath("C:\\wxdummydir\\", size, SHGFI_OPENICON );

    if ( !bitmap.IsOk() )
    {
        // handle message box icons specially (wxIcon ctor treat these names
        // as special cases via wxICOResourceHandler::LoadIcon):
        const char *name = NULL;
        if ( id == wxART_ERROR )
            name = "wxICON_ERROR";
        else if ( id == wxART_INFORMATION )
            name = "wxICON_INFORMATION";
        else if ( id == wxART_WARNING )
            name = "wxICON_WARNING";
        else if ( id == wxART_QUESTION )
            name = "wxICON_QUESTION";

        if ( name )
            return CreateFromStdIcon(name, client);
    }

    // for anything else, fall back to generic provider:
    return bitmap;
}