Create a mask for the icon if it doesn't already have one
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29548 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -166,15 +166,25 @@ wxMenu* wxTaskBarIcon::DoCreatePopupMenu()
|
|||||||
// Operations:
|
// Operations:
|
||||||
bool wxTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& tooltip)
|
bool wxTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& tooltip)
|
||||||
{
|
{
|
||||||
//TODO: (IT WORKS!) Make work without mask - mayby by using a wxDC?
|
wxMask* mask = icon.GetMask();
|
||||||
|
if (!mask)
|
||||||
wxASSERT(icon.GetMask() != NULL);
|
{
|
||||||
|
// Make a mask with no transparent pixels
|
||||||
|
wxBitmap bmp(icon.GetWidth(), icon.GetHeight());
|
||||||
|
wxMemoryDC dc;
|
||||||
|
dc.SelectObject(bmp);
|
||||||
|
dc.SetBackground(*wxBLACK_BRUSH);
|
||||||
|
dc.Clear();
|
||||||
|
dc.SelectObject(wxNullBitmap);
|
||||||
|
mask = new wxMask(bmp, *wxWHITE);
|
||||||
|
}
|
||||||
|
|
||||||
CGImageRef pImage;
|
CGImageRef pImage;
|
||||||
|
|
||||||
//create the icon from the bitmap and mask bitmap contained within
|
//create the icon from the bitmap and mask bitmap contained within
|
||||||
OSStatus err = CreateCGImageFromPixMaps(
|
OSStatus err = CreateCGImageFromPixMaps(
|
||||||
GetGWorldPixMap(MAC_WXHBITMAP(icon.GetHBITMAP())),
|
GetGWorldPixMap(MAC_WXHBITMAP(icon.GetHBITMAP())),
|
||||||
GetGWorldPixMap(MAC_WXHBITMAP(icon.GetMask()->GetMaskBitmap())),
|
GetGWorldPixMap(MAC_WXHBITMAP(mask->GetMaskBitmap())),
|
||||||
&pImage
|
&pImage
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -187,6 +197,9 @@ bool wxTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& tooltip)
|
|||||||
if (pImage != NULL)
|
if (pImage != NULL)
|
||||||
CGImageRelease(pImage);
|
CGImageRelease(pImage);
|
||||||
|
|
||||||
|
if (!icon.GetMask())
|
||||||
|
delete mask;
|
||||||
|
|
||||||
return m_iconAdded = err == noErr;
|
return m_iconAdded = err == noErr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user