Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!apple!voder!pyramid!decwrl!shelby!polya!ali From: ali@polya.Stanford.EDU (Ali T. Ozer) Newsgroups: comp.sys.next Subject: Re: App printing problem Message-ID: <8969@polya.Stanford.EDU> Date: 5 May 89 14:51:12 GMT References: <1601@hub.ucsb.edu> Sender: Ali T. Ozer Reply-To: aozer@NeXT.com (Ali Ozer) Organization: . Lines: 31 In article <1601@hub.ucsb.edu> trainoff@sbphy.ucsb.edu writes: >I have just written my first App. I created a CustomView that >basically emulates a graphics library ... The print: method just >calls [self printPSCode:self] This correctly fires up a print panel >and spools a file to the printer. The problem is that it prints two >blank pages, not what is on the screen. I traced the problem down to >the fact that I had implemented a bunch of methods in my View that >send PS to the current context via pswrap routines or PSxxxx() calls. >I did not, however, create a drawSelf:: method. Evidently >printPSCode: calls display or drawSelf:: to create its page. Every view should implement drawSelf::, and drawSelf:: should be able to recreate whatever is visible in the view at the time it is called. It's possible to create views that do not have drawSelf:: methods, of course, but then you run into problems such as the above. If you do not create a drawSelf:: method, then you are probably using some other mechanism to draw in your view. That makes your view highly unportable; as you noticed, it becomes harder to print, and it will also be harder to do such things as put your view in an Interface Builder palette, or cut/copy PostScript from your view into the pasteboard, to put your view in a ScrollView, and so on. With drawSelf:: in place, and correctly working, the above tasks reduce to a few lines (if any) of code. You might want to create a drawSelf:: method that calls your other drawing routines in the correct order to recreate what's in the view. Leave everything else as it is... Ali Ozer, NeXT Developer Support aozer@NeXT.com