home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v92.tgz / v92.tar / v92 / src / h / macgraph.h < prev    next >
C/C++ Source or Header  |  1996-03-22  |  7KB  |  205 lines

  1. /*
  2.  * Constants
  3.  */
  4. #include <Quickdraw.h>
  5.  
  6. #define kEmptyString    "\p"
  7. #define kMoveToFront    (WindowPtr)-1L
  8. #define kVisible        true
  9. #define kInvisible      false
  10. #define kHasGoAway      true
  11. #define kNilRefCon      (long)nil
  12. #define kPi             3.14159265358979323846264338327950288419716939937511
  13. #define kSleep          400
  14.  
  15. #define kMenuBar        128
  16.  
  17. #define kAppleMenu      128
  18. #define kAboutMItem     1
  19.  
  20. #define kFileMenu       129
  21. #define kCompileMItem   1
  22. #define kRunMItem       1
  23. #define kQuitMItem      3
  24.  
  25. #define kOptionsMenu    130
  26. #define k_cMItem        1
  27. #define kRInMItem       1
  28. #define kROutMItem      2
  29. #define kArgsMItem      3
  30. #define kEchoOut2Con    5
  31.  
  32. #define kCLArgsDialog   128
  33. #define kArgStringField 3
  34.  
  35. #define kDisableButton  255
  36. #define kEnableButton   0
  37.  
  38. #define kStringID       128
  39. #define kNARGS          25
  40.  
  41. #define kMinDocSize     64
  42. #define kMaxDocSize     500
  43. #define kZeroTolerance  0x0000
  44.  
  45. #define DMAXCOLORS           256
  46. #define FS_SOLID             1
  47. #define FS_STIPPLE           2
  48. #define FS_OPAQUESTIPPLE     4
  49.  
  50.  
  51. /*
  52.  * Macros
  53.  */
  54.  
  55. #define STDLOCALS(wb) wcp wc=(wb)->context;\
  56.                       wsp ws=(wb)->window;\
  57.                       WindowPtr stdwin=ws->theWindow
  58.    
  59. #define ICONFILENAME(wb) ((wb)->window->iconimage)
  60. #define ICONLABEL(wb) ((wb)->window->iconlabel)
  61. #define WINDOWLABEL(wb) ((wb)->window->windowlabel)
  62.  
  63. #define ANGLE(ang) (ang)
  64. #define EXTENT(ang) (ang)
  65. #define RECX(recs) ((recs).x)
  66. #define RECY(recs) ((recs).y)
  67. #define RECWIDTH(recs) ((recs).width)
  68. #define RECHEIGHT(recs) ((recs).height)
  69.  
  70. #define FULLARC 360<<6
  71. #define ARCWIDTH(arc) ((arc).width)
  72. #define ARCHEIGHT(arc) ((arc).height)
  73.  
  74. #define RED(x) ((x).red)
  75. #define GREEN(x) ((x).green)
  76. #define BLUE(x) ((x).blue)
  77.  
  78. #define ASCENT(wb) ((wb)->context->font->fInfo.ascent)
  79. #define DESCENT(wb) ((wb)->context->font->fInfo.descent)
  80. #define LEADING(wb) ((wb)->context->font->fInfo.leading)
  81. #define FWIDTH(wb) ((wb)->context->font->fInfo.widMax)
  82. #define FHEIGHT(wb) ( (ASCENT(wb))+(DESCENT(wb))+(LEADING(wb)) )
  83. #define MAXDESCENDER(wb) ((wb)->context->font->fInfo.descent)
  84.  
  85. #define DISPLAYWIDTH(wb) (qd.screenBits.bounds.right-qd.screenBits.bounds.left)
  86. #define DISPLAYHEIGHT(wb) (qd.screenBits.bounds.bottom-qd.screenBits.bounds.top)
  87.  
  88. #define LINEWIDTH(wb) ((wb)->context->contextPtr->pnSize.h)
  89. #define TEXTWIDTH(wb,s,n) ( TextWidth(s,(int)(s),n) )
  90.  
  91. #define SCREENDEPTH(wb) 8
  92.  
  93. #define COPYCONTEXT(c) BackPat(&(c)->bkPat);\
  94.                        MoveTo((c)->pnLoc.h,(c)->pnLoc.v);\
  95.                        PenSize((c)->pnSize.h,(c)->pnSize.v);\
  96.                        PenMode((c)->pnMode);\
  97.                        PenPat(&(c)->pnPat);\
  98.                        TextFont((c)->txFont);\
  99.                        TextFace((c)->txFace);\
  100.                        TextMode((c)->txMode);\
  101.                        TextSize((c)->txSize);\
  102.                        SpaceExtra((c)->spExtra)
  103.                          
  104. #define SETCONTEXTDEFAULT(c) memcpy(&((c)->bkPat),&qd.white,sizeof(Pattern));\
  105.                              memcpy(&((c)->fillPat),&qd.black,sizeof(Pattern));\
  106.                              (c)->pnLoc.h=0;(c)->pnLoc.v=0;\
  107.                              (c)->pnSize.h=1;(c)->pnSize.v=1;\
  108.                              (c)->pnMode=patCopy;\
  109.                              memcpy(&((c)->pnPat),&qd.black,sizeof(Pattern));\
  110.                              (c)->txFont=0;\
  111.                              (c)->txFace=normal;\
  112.                              (c)->txMode=srcOr;\
  113.                              (c)->txSize=0;\
  114.                              (c)->spExtra=0;\
  115.                              (c)->fgColor.red=0;\
  116.                              (c)->fgColor.green=0;\
  117.                              (c)->fgColor.blue=0;\
  118.                              (c)->bgColor.red=65535;\
  119.                              (c)->bgColor.green=65535;\
  120.                              (c)->bgColor.blue=65535
  121.  
  122. #define PREPAREGWORLD(ws)  GetGWorld(&((ws)->origPort),&((ws)->origDev));\
  123.                            SetGWorld((ws)->offScreenGWorld,nil);\
  124.                            (ws)->offScreenPMHandle=GetGWorldPixMap((ws)->offScreenGWorld);\
  125.                            (ws)->lockOK=LockPixels((ws)->offScreenPMHandle)
  126.         
  127. #define GWORLD2WINDOW(ws)  (ws)->sourceRect=(ws)->theWindow->portRect;\
  128.                            (ws)->sourceRect.bottom=(ws)->theWindow->portRect.bottom;\
  129.                            (ws)->sourceRect.right=(ws)->theWindow->portRect.right;\
  130.                            (ws)->destRect=(ws)->theWindow->portRect;\
  131.                            (ws)->destRect.bottom=(ws)->theWindow->portRect.bottom;\
  132.                            (ws)->destRect.right=(ws)->theWindow->portRect.right;\
  133.                            CopyBits(&(((GrafPtr)((ws)->offScreenGWorld))->portBits),\
  134.                                     &(((GrafPtr)((ws)->theWindow))->portBits),\
  135.                                     &((ws)->sourceRect),&((ws)->destRect),srcCopy,\
  136.                                     nil);\
  137.                            UnlockPixels((ws)->offScreenPMHandle);\
  138.                            SetGWorld((ws)->origPort,(ws)->origDev)
  139.  
  140. #define EVQUEGET(ws,d) {\
  141.                        int i;\
  142.                        if (!c_get((struct b_list *)BlkLoc((ws)->listp),&d)) fatalerr(0,NULL);\
  143.                        if (Qual(d)) {\
  144.                           ws->eventQueue[(ws)->eQfront++] = *StrLoc(d);\
  145.                           if ((ws)->eQfront >= EQUEUELEN) (ws)->eQfront = 0;\
  146.                              (ws)->eQback = (ws)->eQfront;\
  147.                           }\
  148.                        }
  149.                        
  150. #define EVQUEEMPTY(ws) (BlkLoc((ws)->listp)->list.size == 0)
  151.  
  152. /*
  153.  * the bitmasks for the modifier keys
  154.  */
  155. #ifndef MACGRAPH_H
  156. #define MACGRAPH_H
  157.  
  158. #define ControlMask          (1 << 16)
  159. #define Mod1Mask           (2 << 16)
  160. #define ShiftMask            (4 << 16)
  161.  
  162. /*
  163.  * macros performing row/column to pixel y,x translations
  164.  * computation is 1-based and depends on the current font's size.
  165.  * exception: XTOCOL as defined is 0-based, because that's what its
  166.  * clients seem to need.
  167.  */
  168.  
  169. #define MARGIN 0
  170.  
  171. #define ROWTOY(wb,row) ((row-1) * LEADING(wb) + ASCENT(wb) + MARGIN)
  172. #define COLTOX(wb,col) ((col-1) * FWIDTH(wb) + MARGIN)
  173. #define YTOROW(wb,y)   (((y) - MARGIN) / LEADING(wb) + 1)
  174. #define XTOCOL(wb,x)  (!FWIDTH(wb) ? ((x)-MARGIN) : (((x) - MARGIN) / FWIDTH(wb)))
  175.  
  176. /*
  177.  * typedef & structs
  178.  */
  179.  
  180. typedef struct
  181.   {
  182.   long x, y;
  183.   long width, height;
  184.   long angle1, angle2;
  185.   } XArc;
  186.   
  187. typedef struct
  188.   {
  189.   long x,y;
  190.   } XPoint;
  191.   
  192. typedef struct 
  193.    {
  194.    long x1, y1;
  195.    long x2, y2;
  196.    } XSegment;
  197.    
  198. typedef struct
  199.    {
  200.    long x, y;
  201.    long width, height;
  202.    } XRectangle;
  203.  
  204. #endif   /* MACGRAPH_H */
  205.