X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2bda0e173844e8e0f8acf4e8ad8b5c26e5c6fe5d..9fea1a5d6282d0925c15fc21e33c6236febcdecf:/src/msw/imaglist.cpp diff --git a/src/msw/imaglist.cpp b/src/msw/imaglist.cpp index 49ce321f41..540c176058 100644 --- a/src/msw/imaglist.cpp +++ b/src/msw/imaglist.cpp @@ -26,13 +26,18 @@ #include #include "wx/setup.h" #include "wx/window.h" -#include "wx/dcclient.h" +#include "wx/icon.h" +#include "wx/dc.h" +#include "wx/string.h" #endif +#include "wx/log.h" +#include "wx/intl.h" + #include "wx/msw/imaglist.h" #include "wx/msw/private.h" -#ifndef __GNUWIN32__ +#if (defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__) || defined(wxUSE_NORLANDER_HEADERS) #include #endif @@ -66,7 +71,7 @@ int wxImageList::GetImageCount(void) const //////////////////////////////////////////////////////////////////////////// // Creates an image list -bool wxImageList::Create(const int width, const int height, const bool mask, const int initial) +bool wxImageList::Create(int width, int height, bool mask, int initial) { UINT flags = 0; if ( mask ) @@ -86,7 +91,14 @@ int wxImageList::Add(const wxBitmap& bitmap, const wxBitmap& mask) HBITMAP hBitmap2 = 0; if ( mask.Ok() ) hBitmap2 = (HBITMAP) mask.GetHBITMAP(); - return ImageList_Add((HIMAGELIST) GetHIMAGELIST(), hBitmap1, hBitmap2); + + int index = ImageList_Add((HIMAGELIST) GetHIMAGELIST(), hBitmap1, hBitmap2); + if ( index == -1 ) + { + wxLogError(_("Couldn't add an image to the image list.")); + } + + return index; } // Adds a bitmap, using the specified colour to create the mask bitmap @@ -94,9 +106,14 @@ int wxImageList::Add(const wxBitmap& bitmap, const wxBitmap& mask) // 'bitmap'. int wxImageList::Add(const wxBitmap& bitmap, const wxColour& maskColour) { +#ifdef __TWIN32__ + wxFAIL_MSG("ImageList_AddMasked not implemented in TWIN32"); + return -1; +#else HBITMAP hBitmap1 = (HBITMAP) bitmap.GetHBITMAP(); COLORREF colorRef = PALETTERGB(maskColour.Red(), maskColour.Green(), maskColour.Blue()); return ImageList_AddMasked((HIMAGELIST) GetHIMAGELIST(), hBitmap1, colorRef); +#endif } // Adds a bitmap and mask from an icon. @@ -109,20 +126,25 @@ int wxImageList::Add(const wxIcon& icon) // Replaces a bitmap, optionally passing a mask bitmap. // Note that wxImageList creates new bitmaps, so you may delete // 'bitmap' and 'mask'. -bool wxImageList::Replace(const int index, const wxBitmap& bitmap, const wxBitmap& mask) +bool wxImageList::Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask) { +#ifdef __TWIN32__ + wxFAIL_MSG("ImageList_Replace not implemented in TWIN32"); + return FALSE; +#else HBITMAP hBitmap1 = (HBITMAP) bitmap.GetHBITMAP(); HBITMAP hBitmap2 = 0; if ( mask.Ok() ) hBitmap2 = (HBITMAP) mask.GetHBITMAP(); return (ImageList_Replace((HIMAGELIST) GetHIMAGELIST(), index, hBitmap1, hBitmap2) != 0); +#endif } /* Not supported by Win95 // Replacing a bitmap, using the specified colour to create the mask bitmap // Note that wxImageList creates new bitmaps, so you may delete // 'bitmap'. -bool wxImageList::Replace(const int index, const wxBitmap& bitmap, const wxColour& maskColour) +bool wxImageList::Replace(int index, const wxBitmap& bitmap, const wxColour& maskColour) { HBITMAP hBitmap1 = (HBITMAP) bitmap.GetHBITMAP(); COLORREF colorRef = PALETTERGB(maskColour.Red(), maskColour.Green(), maskColour.Blue()); @@ -131,16 +153,21 @@ bool wxImageList::Replace(const int index, const wxBitmap& bitmap, const wxColou */ // Replaces a bitmap and mask from an icon. -bool wxImageList::Replace(const int index, const wxIcon& icon) +bool wxImageList::Replace(int index, const wxIcon& icon) { HICON hIcon = (HICON) icon.GetHICON(); return (ImageList_ReplaceIcon((HIMAGELIST) GetHIMAGELIST(), index, hIcon) != 0); } // Removes the image at the given index. -bool wxImageList::Remove(const int index) +bool wxImageList::Remove(int index) { +#ifdef __TWIN32__ + wxFAIL_MSG("ImageList_Replace not implemented in TWIN32"); + return FALSE; +#else return (ImageList_Remove((HIMAGELIST) GetHIMAGELIST(), index) != 0); +#endif } // Remove all images @@ -158,16 +185,20 @@ bool wxImageList::RemoveAll(void) // If 'solidBackground' is TRUE, Draw sets the image list background // colour to the background colour of the wxDC, to speed up // drawing by eliminating masked drawing where possible. -bool wxImageList::Draw(const int index, wxDC& dc, const int x, const int y, - const int flags, const bool solidBackground) +bool wxImageList::Draw(int index, wxDC& dc, int x, int y, + int flags, bool solidBackground) { +#ifdef __TWIN32__ + wxFAIL_MSG("ImageList_Replace not implemented in TWIN32"); + return FALSE; +#else HDC hDC = (HDC) dc.GetHDC(); if ( !hDC ) return FALSE; if ( solidBackground ) { - wxBrush *brush = dc.GetBackground(); + wxBrush *brush = & dc.GetBackground(); if ( brush && brush->Ok()) { wxColour col(brush->GetColour()); @@ -194,6 +225,7 @@ bool wxImageList::Draw(const int index, wxDC& dc, const int x, const int y, return (ImageList_Draw((HIMAGELIST) GetHIMAGELIST(), index, hDC, x, y, style) != 0); +#endif } #endif