• 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
SetFrame in drawPageBorderWithSize
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SetFrame in drawPageBorderWithSize


  • Subject: SetFrame in drawPageBorderWithSize
  • From: Andrei K <email@hidden>
  • Date: Thu, 28 Apr 2005 05:49:58 +0400

Hi all,
I read the archive and I know that question was asked many times in the past, but this time it's a bit different. I print a subclass of NSView using this routine:

-(void)drawPageBorderWithSize:(NSSize)borderSize
{
NSRect oldFrame = [self frame];
[self setFrame:NSMakeRect(0, 0, borderSize.width, borderSize.height)];
[self setFrameOrigin:NSMakePoint(0.0, 0.0)];
[self setFrameSize:borderSize];
[self lockFocus];


// some drawing here

[self unlockFocus];
[self setFrame:oldFrame];
}

This is a basic technique described here: http://developer.apple.com/documentation/Cocoa/Conceptual/Printing/Tasks/PaginatingViews.html

Everything works well, except that when I print multiple paged documents each next page take a little more time to process than a previous one. So at the end it gets really slow. Shark tells me that most of time (70%) is spent in setFrame: message (with descending [NSLayoutManager glyphRangeForBoundingRect:inTextContainer:])
There is no difference if I draw something or don't draw anything at all between lockFocus: & unlockFocus: so the problem is not in drawing code. If I do not change frame, then it prints instantly, but of course it doesn't look as supposed to. The difference in time of printing for eg 30 pages document is 11 sec vs. 1 min. (11 sec it the same result which i get when I use TextEdit)

So the question is: is this slowdown supposed to be so or is it a bug which should be reported?
I personally think that when I call setFrame: NSLayoutManager tries to "relayout" all already printed pages, and I'm not sure this is an intended behaviour. But what can I know, I'm just learning...

Thanks in advance,
Andrei
 _______________________________________________
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

  • Follow-Ups:
    • NSColor clearColor always returns black
      • From: Ken Tozier <email@hidden>
  • Prev by Date: Subclass of NSDocument close method called twice
  • Next by Date: Re: Drag File To somewhere and get path
  • Previous by thread: Subclass of NSDocument close method called twice
  • Next by thread: NSColor clearColor always returns black
  • Index(es):
    • Date
    • Thread