X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3d1a4878f36ba4b5f66c2ccfd2cb27a9dc528b6f..6ac23e25b85468c7885f6ab43ca0a45f6458af2e:/src/mac/carbon/taskbar.cpp diff --git a/src/mac/carbon/taskbar.cpp b/src/mac/carbon/taskbar.cpp index e94ae77d65..a373300546 100644 --- a/src/mac/carbon/taskbar.cpp +++ b/src/mac/carbon/taskbar.cpp @@ -143,6 +143,8 @@ wxTaskBarIcon::wxTaskBarIcon(const wxTaskBarIconType& nType) this, (&(EventHandlerRef&)m_pEventHandlerRef)); wxASSERT(err == noErr); + + Connect(wxEVT_TASKBAR_RIGHT_DOWN, wxTaskBarIconEventHandler(wxTaskBarIcon::OnRightDown)); } wxTaskBarIcon::~wxTaskBarIcon() @@ -176,39 +178,46 @@ wxMenu* wxTaskBarIcon::DoCreatePopupMenu() // Operations: bool wxTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& tooltip) { - wxMask* mask = icon.GetMask(); - if (!mask) + wxBitmap bmp( icon ) ; + OSStatus err = noErr ; + + CGImageRef pImage; + +#if 0 // is always available under OSX now -- crashes on 10.2 in CFRetain() - RN + pImage = (CGImageRef) bmp.CGImageCreate() ; +#else + WXHBITMAP iconport ; + WXHBITMAP maskport ; + iconport = bmp.GetHBITMAP( &maskport ) ; + + if (!maskport) { // Make a mask with no transparent pixels - wxBitmap bmp(icon.GetWidth(), icon.GetHeight()); + wxBitmap mbmp(icon.GetWidth(), icon.GetHeight()); wxMemoryDC dc; - dc.SelectObject(bmp); + dc.SelectObject(mbmp); dc.SetBackground(*wxBLACK_BRUSH); dc.Clear(); dc.SelectObject(wxNullBitmap); - mask = new wxMask(bmp, *wxWHITE); + bmp.SetMask( new wxMask(mbmp, *wxWHITE) ) ; + iconport = bmp.GetHBITMAP( &maskport ) ; } - - CGImageRef pImage; //create the icon from the bitmap and mask bitmap contained within - OSStatus err = CreateCGImageFromPixMaps( - GetGWorldPixMap(MAC_WXHBITMAP(icon.GetHBITMAP())), - GetGWorldPixMap(MAC_WXHBITMAP(mask->GetMaskBitmap())), - &pImage - ); - + err = CreateCGImageFromPixMaps( + GetGWorldPixMap(MAC_WXHBITMAP(iconport)), + GetGWorldPixMap(MAC_WXHBITMAP(maskport)), + &pImage + ); wxASSERT(err == 0); - +#endif + wxASSERT(pImage != NULL ); err = SetApplicationDockTileImage(pImage); - + wxASSERT(err == 0); if (pImage != NULL) CGImageRelease(pImage); - - if (!icon.GetMask()) - delete mask; return m_iconAdded = err == noErr; } @@ -272,7 +281,7 @@ bool wxTaskBarIcon::PopupMenu(wxMenu *menu) theItem->GetId(), //id theItem->GetText(), //text label theItem->GetHelp(), //status bar help string - theItem->GetKind(), //menu flags - checkable, seperator, etc. + theItem->GetKind(), //menu flags - checkable, separator, etc. theItem->GetSubMenu() //submenu )); theNode = theNode->GetNext(); @@ -282,4 +291,10 @@ bool wxTaskBarIcon::PopupMenu(wxMenu *menu) return true; } +//Skip the event so that popupmenu isn't called in parent, avoiding double-creation of the menus +void wxTaskBarIcon::OnRightDown(wxTaskBarIconEvent& evt) +{ + evt.Skip(); +} + #endif //wxHAS_TASK_BAR_ICON