On 28/03/2008, flopbucket wrote in message <79d3e4eb-b1f1-4fc9-ac43-
d1da8b39c4ea@[EMAIL PROTECTED]
>:
> I want to write a small app that open a window and at the bottom has a
> scrolling text area, like a stock ticker. As new data arrives, I want
> it to smoothly scroll in from the right, causing text at the extreme
> left to scroll out of the window. Normal "ticker" type stuff.
>
> Being new to Mac OS, I'm not exactly sure how best to go about this.
> Especially about getting the letters to smoothly scroll in (i.e. not
> whole letter at a time). Do I draw to an offscreen bitmap and copy
> part of it to the window for display?
That's very oldschool. There are better ways now.
In Cocoa, you will be writing your text to an NSTextView.
NSTextView inherits from NSView.
NSViews have two properties called 'frame' and 'bounds'. Once controls
where the view appears in the view that contains it. The other controls
where the contents of the view are drawn in relation to its boundaries.
Normally they're the same but a good way to scroll content is to mess with
one, while leaving the other static.
I think one way to scroll your content (the text in an NSTextView) would
be to use setBounds continually. Take a look at the do***entation for
NSView, and the conceptual doc here:
<http://developer.apple.com/do***entation/Cocoa/Conceptual/CocoaViewsGuide/
Coordinates/chapter_3_section_3.html>
Since you're relatively new to Cocoa I would suggest you handle your own
scrolling, because it will give you a good idea how Cocoa objects behave.
But once you understand what's happening you might like to know that Cocoa
has an animation class especially designed for animating views:
<http://developer.apple.com/do***entation/Cocoa/Conceptual/AnimationGuide/A
rticles/ViewAnimations.html>
Simon.
--
http://www.hearsay.demon.co.uk


|