Re: How can I implement labels without the overhead of an NSTextField?
Re: How can I implement labels without the overhead of an NSTextField?
- Subject: Re: How can I implement labels without the overhead of an NSTextField?
- From: email@hidden
- Date: Sun, 12 Dec 2004 20:35:30 +0000
> Presumably you are simply using [string drawAtPoint:withAttributes:] or
> [string drawInRect:withAttributes:] or the equivalent methods in
> NSAttributedString. The AppKit string drawing methods are not intended
> for drawing and redrawing lots of strings. They are fine for a few
> static labels, but not for a huge number of labels that have to be
> redrawn a lot.
What are you talking about? I was just dragging NSTextViews from the palette. The ones that looks like labels. Hence my complaint that all of the labels were NSTextViews.
> You should get much better performance out of the "glyph" methods in
> NSBezierPath. If you want to understand how they work, I strongly
> recommend getting a copy of "Cocoa Programming" by Anguish, Buck &
> Yacktman and go straight to chapter 14.
>
> Jonathan
I am not interested in how they work, I just want to get them going as soon as possible. Also, I forgot to mention that I will need to change the text of the individual labels. Once I have drawn one with NSBezierPath (or NSAttributedString), how can I erase or change it? Not necessarily through the prescribed methods, a hack would be fine, as long as it looks okay and is faster than the 300 labels in the NSScrollView.
Thanks for your help.
>
>
> On Dec 12, 2004, at 4:23 AM, email@hidden wrote:
>
> > Summary:
> >
> > I put an NSImageView inside an NSScrollView. It scrolls smoothly. I
> > put a large number (300) of labels inside an NSScrollView. It scrolls
> > slowly. Why is this happening, and what can I do to change it?
> >
> > Details:
> >
> > I have an application that needs to display a large number of labels
> > on screen at once. These labels must be scrolled, so I decided to use
> > an NSScrollView. I first tested the NSScrollView out with an image,
> > out of curiousity. It worked fine; the scrolling was smooth and
> > responsive. Then I tested it out with a large number of labels. The
> > scrolling slowed down considerably. This suprised me, as I thought a
> > large number of labels would scroll as fast as an image. After all, I
> > could display an image with the text of the 300 labels, and it would
> > look exactly the same to the user. Then I discovered that labels in
> > Cocoa are actually non-editable NSTextViews. Could this be the cause
> > of the problem? Either way, how would I go about speeding up the
> > scrolling?
> > Making each label into an NSImageView wouldn't work. I tried putting
> > 300 NSImageViews onto the window in place of 300 labels, and it was
> > even slower. I suspect that generating a new transparent image
> > (containing the text of each label) to cover the entire window, upon
> > each movement of the scrollbar, would be just as slow. Perhaps I would
> > be able to override the NSTextField (or NSImageView) class to create a
> > "lite" version that incurred less overhead? Any pointers on how to do
> > this would be appreciated, as I am new to both Cocoa and Object
> > Oriented Programming.
> > One last thing - the 300 labels are scattered about the screen, and
> > are not in orderly rows and columns.
> > _______________________________________________
> > Do not post admin requests to the list. They will be ignored.
> > Cocoa-dev mailing list (email@hidden)
> > Help/Unsubscribe/Update your Subscription:
> >
> > This email sent to email@hidden
> >
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden