On Mar 29, 2:27 pm, David Phillip Oster <os...@[EMAIL PROTECTED]
> wrote:
> In article
> <79d3e4eb-b1f1-4fc9-ac43-d1da8b39c...@[EMAIL PROTECTED]
>,
>
>
>
> flopbucket <flopbuc...@[EMAIL PROTECTED]
> wrote:
> > I'm an experienced C++ developer but new to Mac OS X. I am familiar
> > with basic Cocoa development, Objective-C, etc.
>
> > 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?
>
> > If anyone has any ideas on how to go about this it'd be greatly
> > appreciated. I don't mind reading and doing the hard work of course,
> > I'm just not sure what way you would do this in Cocoa.
>
> Text is complicated. There are Unicode and kerning rules that will have
> you tearing your hair. Better just to re-use the existing Cocoa cl*****
> for drawing scrolling text.
>
> For you, I've built a simple working model of the ticker tape view you
> asked for here:http://www.TurboZen.com/sourcecode/Ticker.zip
>
> It is built out of an NSTextView, with the following tricks:
> The animation is driven by a timer, that fires 60 times a second,
> executing this:
>
> - (void)step:(NSTimer *)timer {
> mOffset -= 2; // pixels per tick
> [self setTextContainerInset:NSMakeSize(mOffset, 0)];
> [self setNeedsDisplay:YES];
>
> }
>
> Limitations:
>
> * the timer is created scheduled, on the runloop in the default mode. To
> get the ticker to work while the user is tracking a menu or a control,
> you need to add the timer to the other runloop modes.
>
> * I didn't add any API to set the font attributes, such as color of the
> appended text.
>
> * A real program would use the NSTextContainer owned by the NSTextView
> to measure the pixels in the string prefix, delete the prefix, and reset
> the container offset, so you wouldn't waste storage storing dead history
> in the prefix of the string of the NSTextStorage.
>
> (If you are new to Cocoa, you may miss that much of the creation and
> wiring up of the objects in a program is specified in Interface Builder,
> in the .nib file. That is how the AppDelegate and gets created and how
> it gets a pointer to the TickerView.)
>
> See
>
file:///Developer/ADC%20Reference%20Library/do***entation/Cocoa/Conceptua
> l/TextArchitecture/index.html for more information.
>
> --
> David Phillip Oster
Hi David,
Thank you very much, much appreciated. I'm going to download it now
and take a look, I'm sure it will get me started on the right track.
Do you know any good books covering Cocoa? I've seen "Cocoa
Development" mentioned, but the reviews said it was out of date at
this time.
Thanks again


|