BookMorph size and printing

Ned Konz ned at bike-nomad.com
Thu Sep 20 18:40:06 UTC 2001


On Thursday 20 September 2001 10:25 am, Gary McGovern wrote:

> I use Win 95 (no flames please) and there is no option to print PS file.

There is an option to print PS to file from Squeak. This makes a Postscript 
file. You just need to print the Postscript. But it's easy enough to save a 
GIF or something else. Unfortunately, I don't think that there was Windows 
printing support in 3.0. How did you intend to use a real printer, anyway?

Here's my method to save a drawing (a PasteUpMorph, so it'll work on your 
BookMorph pages) as a GIF file (note that I'm ignoring certain kinds of 
Morphs; you may wish to change this):

PasteUpMorph>>saveNCDrawingAsGIF
	"Dump the current drawing on me as a GIF file. Ignore windows, flaps, etc."
	"World saveNCDrawingAsGIF"
	| ignore border morphs printBounds canvas fileName |
	ignore _ #( MenuMorph
		ProjectNavigationMorph
		FlapTab
		PasteUpMorph
		SystemWindow
		NCButtonBar
		NCMakerButton ).
	border _ 10.		"border width around drawing"
	morphs _ self submorphs reject: [ :ea | ignore includes: ea class name ].
	printBounds _ morphs first bounds.
	morphs do: [ :ea | printBounds _ printBounds merge: ea bounds ].
	printBounds _ printBounds outsetBy: border.
	canvas _ FormCanvas extent: printBounds extent depth: 8.
	canvas setOrigin: printBounds origin negated clipRect: (0 at 0 extent: 
printBounds extent).
	canvas fillColor: self color.
	morphs reverseDo: [ :ea | ea fullDrawOn: canvas ].
	fileName _ FileDirectory default nextNameFor: 'drawing' extension: 'gif'.
	fileName _ FillInTheBlank request: 'GIF file name?' initialAnswer: fileName.
	fileName isEmpty ifTrue: [ ^self ]. 
	Utilities informUser: 'Writing ' , fileName
		during: [GIFReadWriter putForm: canvas form onFileNamed: fileName].

> This demo won't load in my image. Hangs forever. (Straight 3.0 image).

The project format changed from 3.0 to 3.1. You can load the project into a 
3.1 image and save the change set, then file the change set into your 3.0 
image.

> Yes, Ned, I took a look at your NCScrolledCompositeStateMorph.
> and I think a book morph page similar to that would be great. But I noted
> if an embedded morph was resized the scrollbars didn't resize
> automatically.

What do you mean by embedded morph? The PasteUpMorph inside the Scroller or 
some morph on the PasteUpMorph? The scrollbars' size relate to the size of 
the underlying PasteUpMorph, not its contents. Ah, I just noticed that if you 
resize the PasteUpMorph, the ScrollPane has to have setScrollDeltas called.

What's needed for both the BookMorph and the NCScrolledCompositeStateMorph is 
a TwoWayScrollPane with a PasteUpMorph that calls the ScrollPane's 
setScrollDeltas on its changed method. And maybe it could be smart enough 
that when the ScrollPane gets resized, the PasteUpMorph could expand as 
needed so it's not showing any blank parts.

You seem to want to have the scroll bars sensitive not to the size of the 
underlying PasteUpMorph, but to its contents, right? I suppose that's another 
way to do it, though it wouldn't work easily with the existing setup, unless 
the PasteUpMorph managed to tell the Scroller to re-position itself based on 
the PasteUpMorph's contents. And how would you add a new Morph outside the 
existing bounds if you couldn't scroll past them?

Another problem is changing the PasteUpMorph size; unless you give the user 
access to the halos (which isn't necessarily a good idea) there isn't a good 
way to do this. And dropping a Morph outside the PasteUpMorph won't work. So 
you need to make the PasteUpMorph big enough. How did you imagine doing this?

> Unfortunately I cannot get the whole of your project just some parts.

Use the trick above, or contact me and I'll send you the change set.

> Do you think it would be feasible to embed an ordinary morph into a page
> then add the scrollpanes into that ordinary morph ? It would mean an extra
> layer though.

What do you mean "an ordinary morph"? You can put anything in a 
TwoWayScrollPane:

     RectangleMorph new inATwoWayScrollPane openInWorld

What kind of behavior are you trying to get?

Note that the TwoWayScrollPane expects to have a single Morph inside its 
TransformMorph. I used a PasteUpMorph, because these have grids, backgrounds, 
menus, etc. But you don't need to use one of these; any old Morph will do.

-- 
Ned Konz
currently: Stanwood, WA
email:     ned at bike-nomad.com
homepage:  http://bike-nomad.com




More information about the Squeak-dev mailing list