nsMessengerOSXIntegration::~nsMessengerOSXIntegration()
{
  if (mBiffIconVisible) 
  {
    RestoreApplicationDockTileImage();
    mBiffIconVisible = PR_FALSE;
  }
}
Пример #2
0
void MacDock::overlay(const QString& text)
{
	if (text.isEmpty()) {
		overlayed = false;
		RestoreApplicationDockTileImage();
		return;
	}

	// Create the context
	CGContextRef context = BeginCGContextForApplicationDockTile();

	if (!overlayed) {
		overlayed = true;

		// Add some subtle drop down shadow
		// FIXME: Disabled because 10.2 doesn't support it
		//CGSize s = { 2.0, -4.0 };
		//CGContextSetShadow(context,s,5.0);
	}

	// Draw a circle
	CGContextBeginPath(context);
	CGContextAddArc(context, 95.0, 95.0, 25.0, 0.0, 2 * M_PI, true);
	CGContextClosePath(context);
	CGContextSetRGBFillColor(context, 1, 0.0, 0.0, 1);
	CGContextFillPath(context);

	// Set the clipping path to the same circle
	CGContextBeginPath(context);
	CGContextAddArc(context, 95.0, 95.0, 25.0, 0.0, 2 * M_PI, true);
	CGContextClip(context);

	// Remove drop shadow
	// FIXME: Disabled because 10.2 doesn't support it
	//CGSize s = { 0.0, -0.0 };
	//CGContextSetShadowWithColor(context, s, 0, NULL);

	// Select the appropriate font
	CGContextSelectFont(context,DOCK_FONT_NAME, DOCK_FONT_SIZE, kCGEncodingMacRoman);
	CGContextSetRGBFillColor(context, 1, 1, 1, 1);

	// Draw the text invisible
	CGPoint begin = CGContextGetTextPosition(context);
	CGContextSetTextDrawingMode(context, kCGTextInvisible);	
	CGContextShowTextAtPoint(context, begin.x, begin.y, text.toStdString().c_str(), text.length());
	CGPoint end = CGContextGetTextPosition(context);

	// Draw the text
	CGContextSetTextDrawingMode(context, kCGTextFill);	
	CGContextShowTextAtPoint(context, 95 - (end.x - begin.x)/2, 95 - 8, text.toStdString().c_str(), text.length());
	
	// Cleanup
	CGContextFlush(context);
	EndCGContextForApplicationDockTile(context);
}
Пример #3
0
//-----------------------------------------------------------------------------
// wxDockTaskBarIcon::RemoveIcon
//
// Restores the old image for the dock via RestoreApplicationDockTileImage
//-----------------------------------------------------------------------------
bool wxDockTaskBarIcon::RemoveIcon()
{
    wxDELETE(m_pMenu);

    // restore old icon to the dock
    OSStatus err = RestoreApplicationDockTileImage();
    verify_noerr( err );

    // restore the old menu to the dock
    SetApplicationDockTileMenu( m_theLastMenu );

    bool success = (err == noErr);
    m_iconAdded = !success;

    return success;
}
Пример #4
0
bool wxTaskBarIcon::RemoveIcon()
{
    if(m_pMenu)
    {
        delete m_pMenu;
        m_pMenu = NULL;
    }
    
    //restore old icon to the dock
	OSStatus err = RestoreApplicationDockTileImage();
	wxASSERT(err == 0);
    
    //restore the old menu to the dock
    SetApplicationDockTileMenu(MAC_WXHMENU(m_theLastMenu));

    return !(m_iconAdded = !(err == noErr));
}
Пример #5
0
/*******************************************************************************
**	TileBadge
*******************************************************************************/
void TileBadge( Boolean inRestoreTileBeforeBadging )
{
	OSStatus	theErr;
	PicHandle	theBadge;
	PicHandle	theBadgeMask;
	GWorldPtr	theBadgeWorld;
	GWorldPtr	theBadgeMaskWorld;
	Rect		theRect = { 0, 0, 128, 128 };
	CGImageRef	theBadgeImage;
	GDHandle	theSavedDevice;
	GrafPtr		theSavedPort;

	// ***
	//
	// PITFALL!
	//
	// Rebadging the tile will composite over the old one!
	// You might want to restore the tile before badging.
	//
	// ***
	if ( inRestoreTileBeforeBadging )
		RestoreApplicationDockTileImage();

	// Load the pictures
	theBadge = GetPicture( kBadge );
	require( theBadge != NULL, CantLoadBadge );
	theBadgeMask = GetPicture( kBadgeMask );
	require( theBadgeMask != NULL, CantLoadBadgeMask );

	// Make some GWorlds
	theErr = NewGWorld( &theBadgeWorld, 32, &theRect, NULL, NULL, 0 );
	require_noerr( theErr, CantMakeBadgeWorld );
	theErr = NewGWorld( &theBadgeMaskWorld, 32, &theRect, NULL, NULL, 0 );
	require_noerr( theErr, CantMakeBadgeMaskWorld );

	// Draw the pictures into the GWorlds
	GetGWorld( &theSavedPort, &theSavedDevice );
	SetGWorld( theBadgeWorld, NULL );
	DrawPicture( theBadge, &theRect );
	SetGWorld( theBadgeMaskWorld, NULL );
	DrawPicture( theBadgeMask, &theRect );
	SetGWorld( theSavedPort, theSavedDevice );

	// ***
	//
	// Make a CGImage from the GWorlds' pixmaps
	//
	// ***
	theErr = CreateCGImageFromPixMaps( GetGWorldPixMap( theBadgeWorld ),
		GetGWorldPixMap( theBadgeMaskWorld ), &theBadgeImage );
	if ( theErr != noErr )
		SysBeep( 0 );
	require_noerr( theErr, CantMakeBadgeImage );

	// ***
	//
	// Badge the tile
	//
	// ***
	theErr = OverlayApplicationDockTileImage( theBadgeImage );

	if ( theBadgeImage != NULL )
		CGImageRelease( theBadgeImage );

CantMakeBadgeImage:
	DisposeGWorld( theBadgeMaskWorld );

CantMakeBadgeMaskWorld:
	DisposeGWorld( theBadgeWorld );

CantMakeBadgeWorld:
	ReleaseResource( (Handle) theBadgeMask );

CantLoadBadgeMask:
	ReleaseResource( (Handle) theBadge );

CantLoadBadge:
	;
}
NS_IMETHODIMP
nsMessengerOSXIntegration::OnItemIntPropertyChanged(nsIRDFResource *aItem, nsIAtom *aProperty, PRInt32 aOldValue, PRInt32 aNewValue)
{
  nsresult rv;
  // if we got new mail bounce the Dock icon and/or apply badge to Dock icon
  if (mBiffStateAtom == aProperty && mFoldersWithNewMail)
  {
    nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(aItem);
    NS_ENSURE_TRUE(folder, NS_OK);

    if (aNewValue == nsIMsgFolder::nsMsgBiffState_NewMail) 
    {
      // if the icon is not already visible, only show a system tray icon iff 
      // we are performing biff (as opposed to the user getting new mail)
      if (!mBiffIconVisible)
      {
        PRBool performingBiff = PR_FALSE;
        nsCOMPtr<nsIMsgIncomingServer> server;
		folder->GetServer(getter_AddRefs(server));
        if (server)
		  server->GetPerformingBiff(&performingBiff);
        if (!performingBiff) 
          return NS_OK; // kick out right now...
      }

      nsCOMPtr<nsIWeakReference> weakFolder = do_GetWeakReference(folder); 
      // remove the element if it is already in the array....
      PRUint32 count = 0;
      PRUint32 index = 0; 
      mFoldersWithNewMail->Count(&count);
      nsCOMPtr<nsIMsgFolder> oldFolder;
      nsCOMPtr<nsIWeakReference> weakReference;
      for (index = 0; index < count; index++)
      {
        weakReference = do_QueryElementAt(mFoldersWithNewMail, index);
        oldFolder = do_QueryReferent(weakReference);
        if (oldFolder == folder) // if they point to the same folder
          break;
        oldFolder = nsnull;
      }

	 if (oldFolder)
       mFoldersWithNewMail->ReplaceElementAt(weakFolder, index);
	 else
       mFoldersWithNewMail->AppendElement(weakFolder);
      // now regenerate the tooltip
      OnAlertFinished(nsnull);  
    }
    else if (aNewValue == nsIMsgFolder::nsMsgBiffState_NoMail)
	{
      // we are always going to remove the icon whenever we get our first no mail
      // notification. 
      mFoldersWithNewMail->Clear(); 
      if (mBiffIconVisible) 
      {
        RestoreApplicationDockTileImage();
        mBiffIconVisible = PR_FALSE;
      }
    }
  } // if the biff property changed
  
  return NS_OK;
}