How an I get an NSAttributedString into an NSView?

  • I have a NSStatusItem that displays the weather forecast. I use an
    image of the current conditions (sunny, partly cloudy, etc) and an
    NSAttributedString to display the current temperature in the status
    bar using NSStatusItem's setImage and setAttributedTitle methods. Now
    I would like to animate the status item when the forecast changes. I
    need to animate a view, so now I have to use setView to create a
    view. Using the image by itself in the view is easy enough, but how
    do get the attr. string in a view? I'm looking at the CircleView
    example and that looks promising as a model, but is there a better
    way that I might accomplish this?
    Thanks

    "Beware of all enterprises that require new clothes."
      -- Henry David Thoreau

    Lorenzo Thurman
    <lorenzo...>
  • --- Lorenzo Thurman <lorenzo...> wrote:

    > I have a NSStatusItem that displays the weather
    > forecast. I use an
    > image of the current conditions (sunny, partly
    > cloudy, etc) and an
    > NSAttributedString to display the current
    > temperature in the status
    > bar using NSStatusItem's setImage and
    > setAttributedTitle methods. Now
    > I would like to animate the status item when the
    > forecast changes. I
    > need to animate a view, so now I have to use setView
    > to create a
    > view. Using the image by itself in the view is easy
    > enough, but how
    > do get the attr. string in a view? I'm looking at
    > the CircleView
    > example and that looks promising as a model, but is
    > there a better
    > way that I might accomplish this?
    > Thanks

    Easiest solution: AppKit's NSAttributedString category
    includes methods for drawing an attributed string in a
    given rect.

    http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Cla
    sses/NSAttributedString_AppKitAdditions/Reference/Reference.html


    Cheers,
    Chuck

          ____________________________________________________________________________________
    Don't let your dream ride pass you by. Make it a reality with Yahoo! Autos.
    http://autos.yahoo.com/index.html
  • On Oct 10, 2007, at 7:08 p, Charles Steinman wrote:

    > --- Lorenzo Thurman <lorenzo...> wrote:
    >
    >> I have a NSStatusItem that displays the weather
    >> forecast. I use an
    >> image of the current conditions (sunny, partly
    >> cloudy, etc) and an
    >> NSAttributedString to display the current
    >> temperature in the status
    >> bar using NSStatusItem's setImage and
    >> setAttributedTitle methods. Now
    >> I would like to animate the status item when the
    >> forecast changes. I
    >> need to animate a view, so now I have to use setView
    >> to create a
    >> view. Using the image by itself in the view is easy
    >> enough, but how
    >> do get the attr. string in a view? I'm looking at
    >> the CircleView
    >> example and that looks promising as a model, but is
    >> there a better
    >> way that I might accomplish this?
    >> Thanks
    >
    > Easiest solution: AppKit's NSAttributedString category
    > includes methods for drawing an attributed string in a
    > given rect.
    >
    > http://developer.apple.com/documentation/Cocoa/Reference/
    > ApplicationKit/Classes/NSAttributedString_AppKitAdditions/Reference/
    > Reference.html
    >
    > Cheers,
    > Chuck
    >
    >
    >
    > ______________________________________________________________________
    > ______________
    > Don't let your dream ride pass you by. Make it a reality with
    > Yahoo! Autos.
    > http://autos.yahoo.com/index.html
    >
    >
    >
    Thanks, this looks even better.

    "A good friend will help you move. A really good friend will help you
    move a body"
    --Unknown

    Lorenzo Thurman
    <lorenzo...>
previous month october 2007 next month
MTWTFSS
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today