]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/taskbar.cpp
wxUSE_TOOLTIPS fix (good grief I think I just did this a couple days ago...)
[wxWidgets.git] / src / mac / carbon / taskbar.cpp
index 395f5f5e30fc1723250731a41c8f43a59e83f86a..74490f125cccc129b2da9e8091fb1510ecd6b8a0 100644 (file)
@@ -11,8 +11,6 @@
 
 #include "wx/wxprec.h"
 
-#include "wx/defs.h"
-
 #ifdef wxHAS_TASK_BAR_ICON
 
 #include "wx/mac/private.h"
@@ -36,7 +34,12 @@ pascal OSStatus wxDockEventHandler( EventHandlerCallRef inHandlerCallRef,
     {
         //TODO:        This is a complete copy of 
         //static pascal OSStatus wxMacAppCommandEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
-       
+
+        if (! pTB->GetCurrentMenu() )
+        {
+            return eventNotHandledErr;
+        }
+                
         MenuRef hMenu = MAC_WXHMENU(pTB->GetCurrentMenu()->GetHMenu());
         OSStatus result = eventNotHandledErr ;
 
@@ -173,39 +176,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 1 // is always available under OSX now       
+    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;
 }