• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Fwd: I need a milder application badge (solution)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: I need a milder application badge (solution)


  • Subject: Fwd: I need a milder application badge (solution)
  • From: Jay Reynolds Freeman <email@hidden>
  • Date: Sat, 25 Jul 2009 11:33:41 -0700

What Sherm suggests is exactly what I described as my solution,
and it does work, with one serious problem:  Capturing the image
that gets drawn in the manner described *also* captures whatever
background lies beyond the transparent portions of the image, and
that is not what I want.  That is why I have to hack the bitmap
after capturing it.

If I set a particular background color for the view where I am drawing
the image, then the newly-captured image shows that color where the
original image was transparent.  If I tell that view not to draw its
background, or set its background color to transparent, then I get the
background color of the window at the base of the view hierarchy.
And if tell that window not to draw its background, or to use a
transparent background color, then the transparent portions of
the original image come out dead black in the copy.  (I suspect that
dead black is the "color" of off-screen portions of the Mac console.)

--  Jay Reynolds Freeman
---------------------
email@hidden
http://web.mac.com/jay_reynolds_freeman (personal web site)


On Jul 25, 2009, at 11:25 AM, Sherm Pendley wrote:

On Sat, Jul 25, 2009 at 1:54 PM, Jay Reynolds
Freeman<email@hidden> wrote:
What I want to do is modify the dock icon while the application running.
The only interface I can find to do this is
NSApp.setApplicationIconImage: , which requires an NSImage. I have no way
to get at the actual view being used to draw the dock icon, in order to
subclass it; I have to create a new NSImage somehow, and pass that to
setApplicationIconImage.

You don't need to subclass anything just to draw into an NSImage. You can call an NSImage's -lockFocus method to direct all the usual drawing functions and methods to draw into that image, instead of into an onscreen view. Don't forget to call -unlockFocus when you're done!

So, what you want to do is, get the default image, -copy it and
-autorelease the copy, send the copy a -lockFocus, draw whatever
content you want to add to the icon, using all the usual functions &
methods you'd have used in a subclass' -drawRect: method, send the
copy a -unlockFocus, send the copy to -setApplicationIconImage:.

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: I need a milder application badge (solution)
      • From: Scott Ribe <email@hidden>
  • Prev by Date: Re: Unit testing question
  • Next by Date: Re: I need a milder application badge (solution)
  • Previous by thread: Re: NSDictionary crash
  • Next by thread: Re: I need a milder application badge (solution)
  • Index(es):
    • Date
    • Thread