Is it possible to draw text to an offscreen view that has no window?
Is it possible to draw text to an offscreen view that has no window?
- Subject: Is it possible to draw text to an offscreen view that has no window?
- From: email@hidden
- Date: Fri, 31 Dec 2004 05:04:38 +0000
Summary:
How can I draw some text to an offscreen view and then print it? Looking for
a simple way to do this.
Details:
I have a bunch of NSTextFields in a window, the contents of which must be
printed. There is some other stuff in the window however, which I do not
want print with the text. Also the text must be repositioned for printing.
So, I decided the easiest way would be to copy the text from all of the
NSTextFields into an offscreen view, and then print that. But, I am running
into problems. Here is what I did:
1. Created a very basic subclass of NSView.
2. Instantiate this subclass from code using alloc/initwithframe.
3. Attempt to lockfocus on this NSView, so that I can draw text to it.
This is where I run into problems. Upon calling lockfocus I am given the
message in Run Log: "lockfocus sent to a view whose window is deferred and
does not yet have a corresponding platform window".
Do I have to put the view in a window if I want to draw offscreen? This
means I will have to instantiate the window as well as hide it, which is
more complicated than I had intended. It looks like my other option is the
unpublished defaultGlyphForChar method, using NSBezierPath to draw the text.
Again, this is not as simple as I was looking for. Is there an easy way to
draw text offscreen?
_______________________________________________
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