[comp.sys.mac.programmer] Graying out a PICT

mikeoro@hubcap.clemson.edu (Michael K O'Rourke) (07/13/89)

How can one go about drawing a PICT resource grayed out?  I tried setting the
penpattern to gray and calling drawpicture, but this doesn't work. Has anyone
done this before?  I have a PICT button and i need to have some way of graying
it out when the button is inactive.

Michael O'Rourke

rick@Jessica.stanford.edu (Rick Wong) (07/13/89)

In article <5982@hubcap.clemson.edu> mikeoro@hubcap.clemson.edu (Michael K O'Rourke) writes:
>How can one go about drawing a PICT resource grayed out?  I tried setting the
>penpattern to gray and calling drawpicture, but this doesn't work. Has anyone
>done this before?  I have a PICT button and i need to have some way of graying
>it out when the button is inactive.
>
>Michael O'Rourke


Because the penpats/penmodes/etc. are saved with the picture definition,
setting them before calling DrawPicture has no effect.  An easy way to
achieve the desired effect is to gray out the image AFTER drawing it,
by using the patBic penmode.  For example:

void
DrawGrayedPict(PicHandle ph)
{
Rect	r = (**ph).picFrame;

	DrawPicture(ph, &r);

	/* Here we go . . . */
	PenMode(patBic);
	PenPat(gray);
	PaintRect(&r);
}

This, by the way, is the same technique used to draw grayed-out text
in menu items, buttons, and so forth.

Rick Wong
Stanford University, Courseware Authoring Tools Project
rick@jessica.stanford.edu

mnkonar@gorby.SRC.Honeywell.COM (Murat N. Konar) (07/13/89)

In article <5982@hubcap.clemson.edu> mikeoro@hubcap.clemson.edu (Michael K O'Rourke) writes:
>How can one go about drawing a PICT resource grayed out?  I tried setting the
>penpattern to gray and calling drawpicture, but this doesn't work. Has anyone
>done this before?  I have a PICT button and i need to have some way of graying
>it out when the button is inactive.
>
This is just off the top of my head but her goes:
Set the foreColor to white  (old style color) 
Set the PenMode to patOr
Call PaintRect with the rect of the PICT as its argument.

This should work on both Classic and Color Quickdraw Systems.


____________________________________________________________________
Have a day. :^|
Murat N. Konar        Honeywell Systems & Research Center, Camden, MN
mnkonar@SRC.honeywell.com (internet) {umn-cs,ems,bthpyd}!srcsip!mnkonar(UUCP)

u-atgoat@wasatch.utah.edu (Alan Goates) (07/13/89)

Draw the picture, and then draw a gray rectangle over it using a Bic pen
(i.e. FillRect with patBic).

Al