1. fixed (to test) the bug with bitmaps without masks in wxImageList
2. reorganized wxImageList a bit, created a new wxInvertMask() function 3. an incredibly ugly fix (?) for "unsatisfied constraints" warnings 4. added wxIcon and wxBitmap ctors from XPM 5. XPM handler now creates bitmaps with mask 6. added wxPrinterDC::BitBlt() and DrawBitmap(), cleared the horrible mess in the wxDC methods with the same names git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5571 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -47,7 +47,7 @@
|
||||
// wxWin macros
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxIconBase)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxIconBase)
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
@@ -71,14 +71,10 @@ void wxIconRefData::Free()
|
||||
// wxIcon
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxIcon::wxIcon()
|
||||
{
|
||||
}
|
||||
|
||||
wxIcon::wxIcon(const char WXUNUSED(bits)[],
|
||||
int WXUNUSED(width),
|
||||
int WXUNUSED(height))
|
||||
wxIcon::wxIcon(const char bits[], int width, int height)
|
||||
{
|
||||
wxBitmap bmp(bits, width, height);
|
||||
CopyFromBitmap(bmp);
|
||||
}
|
||||
|
||||
wxIcon::wxIcon(const wxString& iconfile,
|
||||
@@ -94,6 +90,51 @@ wxIcon::~wxIcon()
|
||||
{
|
||||
}
|
||||
|
||||
void wxIcon::CopyFromBitmap(const wxBitmap& bmp)
|
||||
{
|
||||
#ifdef __WIN32__
|
||||
wxMask *mask = bmp.GetMask();
|
||||
if ( !mask )
|
||||
{
|
||||
// we must have a mask for an icon, so even if it's probably incorrect,
|
||||
// do create it (grey is the "standard" transparent colour)
|
||||
mask = new wxMask(bmp, *wxLIGHT_GREY);
|
||||
}
|
||||
|
||||
ICONINFO iconInfo;
|
||||
iconInfo.fIcon = TRUE; // we want an icon, not a cursor
|
||||
iconInfo.hbmMask = wxInvertMask((HBITMAP)mask->GetMaskBitmap());
|
||||
iconInfo.hbmColor = GetHbitmapOf(bmp);
|
||||
|
||||
HICON hicon = ::CreateIconIndirect(&iconInfo);
|
||||
if ( !hicon )
|
||||
{
|
||||
wxLogLastError("CreateIconIndirect");
|
||||
}
|
||||
else
|
||||
{
|
||||
SetHICON((WXHICON)hicon);
|
||||
SetSize(bmp.GetWidth(), bmp.GetHeight());
|
||||
}
|
||||
|
||||
if ( !bmp.GetMask() )
|
||||
{
|
||||
// we created the mask, now delete it
|
||||
delete mask;
|
||||
}
|
||||
#else // Win16
|
||||
// there are some functions in curico.cpp which probably could be used
|
||||
// here...
|
||||
wxFAIL_MSG("not implemented");
|
||||
#endif // Win32/16
|
||||
}
|
||||
|
||||
void wxIcon::CreateIconFromXpm(const char **data)
|
||||
{
|
||||
wxBitmap bmp(data);
|
||||
CopyFromBitmap(bmp);
|
||||
}
|
||||
|
||||
bool wxIcon::LoadFile(const wxString& filename,
|
||||
long type,
|
||||
int desiredWidth, int desiredHeight)
|
||||
|
Reference in New Issue
Block a user