logo       

Re: printing graphics in squeak: msg#00102

lang.smalltalk.squeak.beginners

Subject: Re: printing graphics in squeak

Hi

If you want to print a morph, get its form (imageForm message) and use the
primitive primPrintHScale of Form class
primPrintHScale: hScale vScale: vScale landscape: aBoolean
"On platforms that support it, this primitive prints the receiver, assumed
to be a Form, to the default printer."
"(Form extent: 10@10) primPrintHScale: 1.0 vScale: 1.0 landscape: true"

exemple:

| cont m length |
cont := Morph new.
cont color: Color lightBlue.
cont layoutPolicy: TableLayout new ;
listDirection: #topToBottom ; cellPositioning: #topLeft ;
hResizing: #shrinkWrap ; vResizing: #shrinkWrap.

#( 'Label A' 'Label B' 'Label C' 'Label D')
do: [ :label |
m:= Morph new.
m layoutPolicy: TableLayout new ;
listDirection: #leftToRight ; height: 25.
m cellInset: 4.
m color: Color random twiceLighter.
length := m width + 200 atRandom.
m width: length.
m addMorphBack: (StringMorph contents: label) .
m addMorphBack: (StringMorph contents: length asString).
cont addMorph: m.
].
cont cellInset: 4.
cont openInWorld.
cont imageForm primPrintHScale: 1.0 vScale: 1.0 landscape: true.

"(I think it was printh: 96.0 v: 96.0 landScape: false. on an older
version)"


See also the TextPrinter class (sender of primPrintHScale)

hope it helps

regards

alain




"Ching de la Serna" <ching.dls@xxxxxxxxx> a écrit dans le message de news:
29b6524b0709171847r486f73fm17c1d44e1874f1a1@xxxxxxxxxxxxxxxxx
Hi,

I would like to print graphics in Squeak. What classes do I need to do this?
Many thanks in advance.

Ching




_______________________________________________
Beginners mailing list
Beginners@xxxxxxxxxxxxxxxxxxxxxxxxxx
http://lists.squeakfoundation.org/mailman/listinfo/beginners


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise