home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!stanford.edu!leland.Stanford.EDU!Ramon.M.Felciano
- From: felciano@summit.stanford.edu (Ramon M. Felciano)
- Subject: Can't restore pen pattern??
- Message-ID: <1992Dec18.020925.11127@leland.Stanford.EDU>
- X-Posted-From: InterNews1.0b3@leland.stanford.edu
- Sender: news@leland.Stanford.EDU (Mr News)
- Organization: Stanford University Medical Media and Information
- Technologies
- Date: Fri, 18 Dec 92 02:09:25 GMT
- Xdisclaimer: No attempt was made to authenticate the sender's name.
- Lines: 75
-
-
- Hello all --
-
- I'm running into a problem with the Dialog Manager. I can't seem to get
- some of my custom draw procs to reset their environments correctly. In
- particular, if I have an editable text item after a gray-rectangle user
- item, the editText box gets drawn with a gray border, not a solid black
- one. Debugging seems to show that my restorePen routine isn't doing its
- job.
-
- -----------------------------------------
- Here's my drawing proc:
-
- PROCEDURE DrawGrayRect (theDialog: DialogPtr; ItemNumber: Integer);
- { Frame user item }
- VAR
- iType: Integer;
- itmHdl: Handle;
- thePen: PenState;
- iRect: Rect;
- BEGIN
- SetPort(theDialog); { set window to current graf port
- }
- GetDItem(theDialog, ItemNumber, iType, itmHdl, iRect); { get location
- }
- GetPenState(thePen); { save current pen
- }
- PenNormal;
- PenPat(gray);
- FrameRect(iRect);
- SetPenState(thePen); { restore old pen
- }
- END; { of proc DrawGrayRect }
-
- ----------------------------------------
-
- and here are my Save and Restore routines:
-
- PROCEDURE GetPenState (VAR ps: PenState);
- VAR
- p: GrafPtr;
- BEGIN
- GetPort(p);
- ps.pnLoc := p^.pnLoc;
- ps.pnSize := p^.pnSize;
- ps.pnMode := p^.pnMode;
- ps.pnPat := p^.pnPat;
- END; { PROCEDURE GetPenState }
-
- PROCEDURE SetPenState (ps: PenState);
- BEGIN
- WITH ps.pnLoc DO
- MoveTo(h, v);
- WITH ps.pnSize DO
- PenSize(h, v);
- PenMode(ps.pnMode);
- PenPat(ps.pnPat);
- END; { PROCEDURE SetPenState }
-
- ---------------------------------------
-
- A friend mentioned that the problem might be related to the difference
- betwen GrafPorts and CGrafPorts. Anyone concur? How should save/restore
- routines like this work? How can I tell if the current port is color or
- not?
-
- Thanks!
-
- Ramon
-
- +----------------------------------------------------------------+
- | Ramon M. Felciano felciano@summit.stanford.edu |
- | Associate Director, SUMMIT (415) 723-9688 |
- | Stanford University Medical Media and Information Technologies |
- +----------------------------------------------------------------+
-