[comp.sys.mac.programmer] Patterns in WDEF ?

pbuck@tcs.com (Peter Buckner) (01/30/91)

In response to the wDraw message inside a customer WDEF, I'd like to use a 
pattern to paint the window frame. However, I cannot seem to get the pattern recognized & used. Basically, the code looks like this (with some simplification):

case wDraw: if(theWindow->hilited && theWindow->visible){
                 PenPat(gray);
                 PenSize(5,5);
                 FrameRgn(theWindow->strucRgn);
            }
            break;

The change to PenSize seems to work great in that if I do not call PenPat, 
I get a black, 5-pixel box around the frame. If I call PenPat, I get garbage pattern, 5-pixels around the frame. Use my own Pattern, you say? Did that, same result.  I have also tried FillRgn(rgn, myPat) since it will ignore the current PenState. Failed also.

Note I can draw in the frame perfectly well, using LineTo, etc. Only the 
patterns get garbaged.

231b3679@fergvax.unl.edu (CS 231 section 2) (02/01/91)

Looks like to me you need to:
PenPat(&myGray);

Also, make sure you have myGray defined; unless you've properly gotten a
copy of the quickdraw globals, you won't have a valid pattern, just garbage.

Here's a cool way to whip up a pattern, the hard-coded method:
Pattern altGray = {136,34,136,34,136,34,136,34};

--mike gleason