home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / mac / programm / 20006 < prev    next >
Encoding:
Text File  |  1992-12-20  |  2.6 KB  |  89 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!stanford.edu!leland.Stanford.EDU!Ramon.M.Felciano
  3. From: felciano@summit.stanford.edu (Ramon M. Felciano)
  4. Subject: Can't restore pen pattern??
  5. Message-ID: <1992Dec18.020925.11127@leland.Stanford.EDU>
  6. X-Posted-From: InterNews1.0b3@leland.stanford.edu
  7. Sender: news@leland.Stanford.EDU (Mr News)
  8. Organization: Stanford University Medical Media and Information 
  9.  Technologies
  10. Date: Fri, 18 Dec 92 02:09:25 GMT
  11. Xdisclaimer: No attempt was made to authenticate the sender's name.
  12. Lines: 75
  13.  
  14.  
  15. Hello all --
  16.  
  17. I'm running into a problem with the Dialog Manager. I can't seem to get
  18. some of my custom draw procs to reset their environments correctly. In
  19. particular, if I have an editable text item after a gray-rectangle user
  20. item, the editText box gets drawn with a gray border, not a solid black
  21. one. Debugging seems to show that my restorePen routine isn't doing its
  22. job.
  23.  
  24. -----------------------------------------
  25. Here's my drawing proc:
  26.  
  27.  PROCEDURE DrawGrayRect (theDialog: DialogPtr; ItemNumber: Integer);
  28.   { Frame user item }
  29.   VAR
  30.    iType: Integer;
  31.    itmHdl: Handle;
  32.    thePen: PenState;
  33.    iRect: Rect;
  34.  BEGIN
  35.   SetPort(theDialog);                 { set window to current graf port
  36. }
  37.   GetDItem(theDialog, ItemNumber, iType, itmHdl, iRect); { get location
  38. }
  39.   GetPenState(thePen);                               { save current pen
  40. }
  41.   PenNormal;
  42.   PenPat(gray);
  43.   FrameRect(iRect);
  44.   SetPenState(thePen);                               { restore old pen
  45. }
  46.  END;  { of proc DrawGrayRect }
  47.  
  48. ----------------------------------------
  49.  
  50. and here are my Save and Restore routines:
  51.  
  52. PROCEDURE GetPenState (VAR ps: PenState);
  53.  VAR
  54.   p: GrafPtr;
  55. BEGIN
  56.  GetPort(p);
  57.  ps.pnLoc := p^.pnLoc;
  58.  ps.pnSize := p^.pnSize;
  59.  ps.pnMode := p^.pnMode;
  60.     ps.pnPat := p^.pnPat;
  61. END; { PROCEDURE GetPenState }
  62.  
  63. PROCEDURE SetPenState (ps: PenState);
  64. BEGIN
  65.  WITH ps.pnLoc DO
  66.   MoveTo(h, v);
  67.  WITH ps.pnSize DO
  68.   PenSize(h, v);
  69.  PenMode(ps.pnMode);
  70.  PenPat(ps.pnPat);
  71. END; { PROCEDURE SetPenState }
  72.  
  73. ---------------------------------------
  74.  
  75. A friend mentioned that the problem might be related to the difference
  76. betwen GrafPorts and CGrafPorts. Anyone concur? How should save/restore
  77. routines like this work? How can I tell if the current port is color or
  78. not?
  79.  
  80. Thanks!
  81.  
  82. Ramon
  83.  
  84. +----------------------------------------------------------------+
  85. | Ramon M. Felciano                felciano@summit.stanford.edu  |
  86. | Associate Director, SUMMIT       (415) 723-9688                |
  87. | Stanford University Medical Media and Information Technologies |
  88. +----------------------------------------------------------------+
  89.