#include <stdio.h>
#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 <commctrl.h>
#endif
-#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxImageList, wxObject)
-#endif
wxImageList::wxImageList(void)
{
HBITMAP hBitmap2 = 0;
if ( mask.Ok() )
hBitmap2 = (HBITMAP) mask.GetHBITMAP();
- return ImageList_Add((HIMAGELIST) GetHIMAGELIST(), hBitmap1, hBitmap2);
+ else if (bitmap.GetMask())
+ hBitmap2 = (HBITMAP) bitmap.GetMask()->GetMaskBitmap();
+
+ HBITMAP hBitmapI=0;
+ if(hBitmap2!=0) {
+ // Microsoft imagelist masks are inverted from wxWindows mask standard (white is mask color)
+ BITMAP bm;
+ ::GetObject(hBitmap2,sizeof(BITMAP),(LPVOID)&bm);
+ int w=bm.bmWidth;
+ int h=bm.bmHeight;
+ HDC hdc = ::CreateCompatibleDC(NULL);
+ HDC hdci = ::CreateCompatibleDC(NULL);
+ hBitmapI = ::CreateCompatibleBitmap(hdci, w, h);
+ ::SelectObject(hdc, hBitmap2);
+ ::SelectObject(hdci, hBitmapI);
+ ::BitBlt(hdci, 0, 0, w, h, hdc, 0, 0, NOTSRCCOPY);
+ ::DeleteDC(hdc);
+ ::DeleteDC(hdci);
+ }
+
+ int index = ImageList_Add((HIMAGELIST) GetHIMAGELIST(), hBitmap1, hBitmapI);
+ if ( index == -1 )
+ {
+ wxLogError(_("Couldn't add an image to the image list."));
+ }
+
+ // Clean up inverted mask
+ if(hBitmapI!=0)
+ ::DeleteObject(hBitmapI);
+
+ return index;
}
// Adds a bitmap, using the specified colour to create the mask bitmap
// '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.
// 'bitmap' and '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
// Removes the image at the given 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
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;
return (ImageList_Draw((HIMAGELIST) GetHIMAGELIST(), index, hDC,
x, y, style) != 0);
+#endif
}
#endif