[plt-scheme] Fwd: drawing snips

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sun Jun 4 08:47:21 EDT 2006

At Sat, 3 Jun 2006 22:58:48 -0700, Jordan Johnson wrote:
> I'm a bit perplexed by one line in the MrEd manual about method  
> "draw" in snip%:
> 	"Before this method is called, the correct font, text color, and pen  
> color will have been set in the drawing context for this snip already."

I've inserted "for this snip's style" to clarify a little.

> Now, I'm looking to make a pasteboard (using the mixins in mrlib's  
> graph.ss, actually) for three types of snips, differentiated by shape  
> and color.  So, should I take the above quotation to mean that I  
> shouldn't monkey with the color settings in the draw method I define?  
> (And, does "pen color" imply brush color as well?)

No, you can change them if you want (but change them back before
returning).

> If so, should I be doing this through styles instead? 

It depends. If you want users of the snip to be able to set the color,
etc. though a style, then use a style. If you want the snip to have a
fixed color, etc. in all contexts, then probably you shouldn't bother
with a style.

> (As far as I  
> can tell, this would entail creating the appropriate style and  
> calling set-style in my snip constructor.  Is that correct?)

Yes, or use the pasteboard's `change-style' method after inserting the
snip.

Matthew


Posted on the users mailing list.