
QUICKDRAW                         C Interface                          QUICKDRAW

NAME
      quickdraw -- QuickDraw graphics

SYNOPSIS 
      #include "c/include/types.h"
      #include "c/include/quickdraw.h"

      /* 16 Transfer Modes */
      
      #define  srcCopy       0
      #define  srcOr         1
      #define  srcXor        2
      #define  srcBic        3
      #define  notSrcCopy    4
      #define  notSrcOr      5
      #define  notSrcXor     6
      #define  notSrcBic     7
      #define  patCopy       8
      #define  patOr         9
      #define  patXor        10
      #define  patBic        11
      #define  notPatCopy    12
      #define  notPatOr      13
      #define  notPatXor     14
      #define  notPatBic     15
      
      /* QuickDraw Color Separation Constants */
      
      #define  normalBit     0
      #define  inverseBit    1
      #define  redBit        4      /* RGB Additive Mapping */
      #define  greenBit      3
      #define  blueBit       2
      #define  cyanBit       8      /* CMYBk Subtractive Mapping */
      #define  magentaBit    7
      #define  yellowBit     6
      #define  blackBit      5
      #define  blackColor    33     /* Colors Expressed in these Mappings */
      #define  whiteColor    30 
      #define  redColor      205
      #define  greenColor    341
      #define  blueColor     409
      #define  cyanColor     273
      #define  magentaColor  137
      #define  yellowColor   69
      
      /* Picture Comments */
      
      #define  picLParen     0
      #define  picRParen     1
      
      /* Type Style Constants */
            
      #define  normal        0x00
      #define  bold          0x01
      #define  italic        0x02
      #define  underline     0x04
      #define  outline       0x08
      #define  shadow        0x10
      #define  condense      0x20
      #define  expand        0x40


      /* Types */
      
      typedef  unsigned char Pattern[8];
      typedef  enum {frame,paint,erase,invert,fill} GrafVerb;
      typedef  short Style;
      
      typedef  struct {
         short    ascent;
         short    descent;
         short    maxWidth;
         short    leading;
         } FontInfo;
      
      typedef struct {
         short    v;
         short    h;
         } Point; 
      
      typedef struct {
         short    top;
         short    left;
         short    bottom;
         short    right;
         } Rect;

      typedef struct {
         Ptr      baseAddr;
         short    rowBytes;
         Rect     bounds;
         } BitMap;

      typedef struct {
         short    data[16];
         short    mask[16];
         Point    hotSpot;
         } Cursor;
      
      typedef struct {
         Point    pnLoc;
         Point    pnSize;
         short    pnMode;
         Pattern  pnPat;
         } PenState;
      
      typedef struct {
         short    rgnSize;
         Rect     rgnBBox;
         /* plus more data if not rectangular */
         } Region, *RgnPtr, **RgnHandle;
      
      typedef struct {
         short    picSize;
         Rect     picFrame;
         /* plus Picture contents */
         } Picture, *PicPtr, **PicHandle;
      
      typedef struct {
         short    polySize;
         Rect     polyBBox;
         Point    polyPoints[1];
         } Polygon, *PolyPtr, **PolyHandle;
      
      typedef struct {
         int      (*textProc)();
         int      (*lineProc)();
         int      (*rectProc)();
         int      (*rRectProc)();
         int      (*ovalProc)();
         int      (*arcProc)();
         int      (*polyProc)();
         int      (*rgnProc)();
         int      (*bitsProc)();
         int      (*commentProc)();
         short    (*txMeasProc)();
         int      (*getPicProc)();
         int      (*putPicProc)();
         } QDProcs, *QDProcsPtr;
      
      typedef struct {
         short       device;
         BitMap      portBits;
         Rect        portRect;
         RgnHandle   visRgn;
         RgnHandle   clipRgn;
         Pattern     bkPat;
         Pattern     fillPat;
         Point       pnLoc;
         Point       pnSize;
         short       pnMode;
         Pattern     pnPat;
         short       pnVis;
         short       txFont;
         Style       txFace;
         short       txMode;
         short       txSize;
         int         spExtra;
         int         fgColor;
         int         bkColor;
         short       colrBit;
         short       patStretch;
         PicHandle   picSave;
         RgnHandle   rgnSave;
         PolyHandle  polySave;
         QDProcsPtr  grafProcs;
         } GrafPort, *GrafPtr;
      

      /* External Variable Declarations */
                                           
      extern struct {
         char      private[78]; 
         int       randSeed;
         BitMap    screenBits;
         Cursor    arrow;
         Pattern   dkGray;
         Pattern   ltGray;
         Pattern   gray;
         Pattern   black;
         Pattern   white;
         GrafPtr   thePort;
         } qd;


      /* GrafPort Routines */
      
      pascal void InitGraf(globalPtr)
         Ptr globalPtr;
      pascal void OpenPort(port)
         GrafPtr port;
      pascal void InitPort(port)
         GrafPtr port;
      pascal void ClosePort(port)
         GrafPtr port;
      pascal void SetPort(port)
         GrafPtr port;
      pascal void GetPort(port)
         GrafPtr *port;
      pascal void GrafDevice(device)
         short device;
      pascal void SetPortBits(bm)
         BitMap *bm;
      pascal void PortSize(width,height)
         short width,height;
      pascal void MovePortTo(leftGlobal,rightGlobal)
         short leftGlobal,rightGlobal;
      pascal void SetOrigin(h,v)
         short h,v;
      pascal void SetClip(rgn)
         RgnHandle rgn;
      pascal void GetClip(rgn)
         RgnHandle rgn;
      pascal void ClipRect(r)
         Rect *r;
      pascal void BackPat(pat)
         Pattern *pat;
       

      /* Cursor Routines */

      pascal void InitCursor()
      pascal void SetCursor(crsr)
         Cursor *crsr;
      pascal void HideCursor()
      pascal void ShowCursor()
      pascal void ObscureCursor()


      /* Line Routines */
          
      pascal void HidePen()
      pascal void ShowPen()
      pascal void GetPen(pt)
         Point *pt;
      pascal void GetPenState(pnState)
         PenState *pnState;
      pascal void SetPenState(pnState)
         PenState *pnState;
      pascal void PenSize(width,height)
         short width,height;
      pascal void PenMode(mode)
         short mode;
      pascal void PenPat(pat)
         Pattern *pat;
      pascal void PenNormal()
      pascal void MoveTo(h,v)
         short h,v;
      pascal void Move(dh,dv)
         short dh,dv;
      pascal void LineTo(h,v)
         short h,v;
      pascal void Line(dh,dv)
         short dh,dv;
      
      
      /* Text Routines */
      
      pascal void TextFont(font)
         short font;
      pascal void TextFace(face)
         Style face;
      pascal void TextMode(mode)
         short mode;
      pascal void TextSize(size)
         short size;
      pascal void SpaceExtra(extra)
         int extra;
      pascal void DrawChar(ch)
         short ch;
      DrawString(s)
         char *s; 
      pascal void DrawText(textBuf,firstByte,byteCount)
         Ptr textBuf;
         short firstByte,byteCount;
      pascal short CharWidth(ch)
         short ch;
      short StringWidth(s)
         char *s;
      pascal short TextWidth(textBuf,firstByte,byteCount)
         Ptr textBuf;
         short firstByte,byteCount;
      pascal void GetFontInfo(info)
         FontInfo *info; 
 
         
      /* Drawing in Color */

      pascal void ForeColor(color)
         int color;
      pascal void BackColor(color)
         int color;
      pascal void ColorBit(whichBit)
         short whichBit;


      /* Rectangle Calculations */ 
      
      pascal void SetRect(r,left,top,right,bottom)
         Rect *r;
         short left,top,right,bottom;
      pascal void OffsetRect(r,dh,dv)
         Rect *r;
         short dh,dv;
      pascal void InsetRect(r,dh,dv)
         Rect *r;
         short dh,dv;
      pascal Boolean SectRect(src1,src2,dstRect)
         Rect *src1,*src2,*dstRect;
      pascal void UnionRect(src1,src2,dstRect)
         Rect *src1,*src2,*dstRect;
      Boolean PtInRect(pt,r)
         Point *pt;
         Rect *r;
      Pt2Rect(pt1,pt2,dstRect)
         Point *pt1, *pt2;
         Rect *dstRect;
      PtToAngle(r,pt,angle)
         Rect *r;
         Point *pt;
         short *angle;
      pascal Boolean EqualRect(rect1,rect2)
         Rect *rect1,*rect2;
      pascal Boolean EmptyRect(r)
         Rect *r;
      
      
      /* Graphical Operations on Rectangles */ 
      
      pascal void FrameRect(r)
         Rect *r;
      pascal void PaintRect(r)
         Rect *r;
      pascal void EraseRect(r)
         Rect *r;
      pascal void InvertRect(r)
         Rect *r;
      pascal void FillRect(r,pat)
         Rect *r;
         Pattern *pat;
      
      
      /* Oval Routines */
      
      pascal void FrameOval(r)
         Rect *r;
      pascal void PaintOval(r)
         Rect *r;
      pascal void EraseOval(r)
         Rect *r;
      pascal void InvertOval(r)
         Rect *r;
      pascal void FillOval(r,pat)
         Rect *r;
         Pattern *pat;
      
      
      /* RoundRect Routines */ 
      
      pascal void FrameRoundRect(r,ovWd,ovHt)
         Rect *r;
         short ovWd,ovHt;
      pascal void PaintRoundRect(r,ovWd,ovHt)
         Rect *r;
         short ovWd,ovHt;
      pascal void EraseRoundRect(r,ovWd,ovHt)
         Rect *r;
         short ovWd,ovHt;
      pascal void InvertRoundRect(r,ovWd,ovHt)
         Rect *r;
         short ovWd,ovHt;
      pascal void FillRoundRect(r,ovWd,ovHt,pat)
         Rect *r;
         short ovWd,ovHt;
         Pattern *pat;
      
      
      /* Arc Routines */
      
      pascal void FrameArc(r,startAngle,arcAngle)
         Rect *r;
         short startAngle,arcAngle;
      pascal void PaintArc(r,startAngle,arcAngle)
         Rect *r;
         short startAngle,arcAngle;
      pascal void EraseArc(r,startAngle,arcAngle)
         Rect *r;
         short startAngle,arcAngle;
      pascal void InvertArc(r,startAngle,arcAngle)
         Rect *r;
         short startAngle,arcAngle;
      pascal void FillArc(r,startAngle,arcAngle,pat)
         Rect *r;
         short startAngle,arcAngle;
         Pattern *pat;
      
      
      /* Region Calculations */
      
      pascal RgnHandle NewRgn()
      pascal void DisposeRgn(rgn)
         RgnHandle rgn;
      pascal void CopyRgn(srcRgn,dstRgn)
         RgnHandle srcRgn,dstRgn;
      pascal void SetEmptyRgn(rgn)
         RgnHandle rgn;
      pascal void SetRectRgn(rgn,left,top,right,bottom)
         RgnHandle rgn;
         short left,top,right,bottom;
      pascal void RectRgn(rgn,r)
         RgnHandle rgn;
         Rect *r;
      pascal void OpenRgn()
      pascal void CloseRgn(dstRgn)
         RgnHandle dstRgn;
      pascal void OffsetRgn(rgn,dh,dv)
         RgnHandle rgn;
         short dh,dv;
      pascal void InsetRgn(rgn,dh,dv)
         RgnHandle rgn;
         short dh,dv;
      pascal void SectRgn(srcRgnA,srcRgnB,dstRgn)
         RgnHandle srcRgnA,srcRgnB,dstRgn;
      pascal void UnionRgn(srcRgnA,srcRgnB,dstRgn)
         RgnHandle srcRgnA,srcRgnB,dstRgn;
      pascal void DiffRgn(srcRgnA,srcRgnB,dstRgn) 
         RgnHandle srcRgnA,srcRgnB,dstRgn;
      pascal void XorRgn(srcRgnA,srcRgnB,dstRgn) 
         RgnHandle srcRgnA,srcRgnB,dstRgn;
      Boolean PtInRgn(pt,rgn)
         Point *pt;
         RgnHandle rgn;
      pascal Boolean RectInRgn(r,rgn)
         Rect *r;
         RgnHandle rgn;
      pascal Boolean EqualRgn(rgnA,rgnB)
         RgnHandle rgnA,rgnB;
      pascal Boolean EmptyRgn(rgn)
         RgnHandle rgn;
                        
      
      /* Graphical Operations on Regions */ 
      
      pascal void FrameRgn(rgn)
         RgnHandle rgn;
      pascal void PaintRgn(rgn)
         RgnHandle rgn;
      pascal void EraseRgn(rgn)
         RgnHandle rgn;
      pascal void InvertRgn(rgn)
         RgnHandle rgn;
      pascal void FillRgn(rgn,pat)
         RgnHandle rgn;
         Pattern *pat;
      
      
      /* Graphical Operations on BitMaps */
      
      pascal void ScrollRect(dstRect,dh,dv,updateRgn)
         Rect *dstRect;
         short dh,dv;
         RgnHandle updateRgn;
      pascal void CopyBits(srcBits,dstBits,srcRect,dstRect,mode,maskRgn) 
         BitMap *srcBits,*dstBits;   
         Rect *srcRect,*dstRect;   
         short mode;         
         RgnHandle maskRgn;
      
      
      /* Picture Routines */
      
      pascal PicHandle OpenPicture(picFrame)
         Rect *picFrame;
      pascal void PicComment(kind,dataSize,dataHandle)  
         short kind,dataSize;
         Handle dataHandle;
      pascal void ClosePicture()
      pascal void DrawPicture(myPicture,dstRect)
         PicHandle myPicture;
         Rect *dstRect;
      pascal void KillPicture(myPicture)
         PicHandle myPicture;
      
      
      /* Polygon Calculations */
      
      pascal PolyHandle OpenPoly()
      pascal void ClosePoly()
      pascal void KillPoly(poly)
         PolyHandle poly;
      pascal void OffsetPoly(poly,dh,dv)
         PolyHandle poly; short dh,dv;

      
      /* Graphical Operations on Polygons */

      pascal void FramePoly(poly)
         PolyHandle poly;
      pascal void PaintPoly(poly)
         PolyHandle poly;
      pascal void ErasePoly(poly)
         PolyHandle poly;
      pascal void InvertPoly(poly)
         PolyHandle poly;
      pascal void FillPoly(poly,pat)
         PolyHandle poly; Pattern *pat;
      
      
      /* Point Calculations */
      
      AddPt(src,dst)
         Point *src,*dst;
      SubPt(src,dst)
         Point *src,*dst;
      pascal void SetPt(pt,h,v)
         Point *pt;
         short h,v;
      Boolean EqualPt(pt1,pt2)
         Point *pt1, *pt2;
      pascal void LocalToGlobal(pt)
         Point *pt;
      pascal void GlobalToLocal(pt)
         Point *pt;
      
      
      /* Misc Utility Routines */
      
      pascal short Random()
      pascal Boolean GetPixel(h,v)
         short h,v;
      StuffHex(thingPtr,s)
         Ptr thingPtr;
         char *s;
      pascal void ScalePt(pt,fromRect,toRect)
         Point *pt;
         Rect *fromRect,*toRect;
      pascal void MapPt(pt,fromRect,toRect)
         Point *pt;
         Rect *fromRect,*toRect;
      pascal void MapRect(r,fromRect,toRect)
         Rect *r,*fromRect,*toRect;
      pascal void MapRgn(rgn,fromRect,toRect)
         RgnHandle rgn;
         Rect *fromRect,*toRect;
      pascal void MapPoly(poly,fromRect,toRect)
         PolyHandle poly;
         Rect *fromRect,*toRect;
      
      
      /* Bottleneck Interface */   
      
      pascal void SetStdProcs(procs)
         QDProcsPtr procs;
      StdText(count,textAddr,numer,denom)
         short count;
         Ptr textAddr;
         Point *numer, *denom;
      StdLine(newPt)
         Point *newPt;
      pascal void StdRect(verb,r)
         GrafVerb verb;
         Rect *r;
      pascal void StdRRect(verb,r,ovWd,ovHt)
         GrafVerb verb;
         Rect *r;
         short ovWd,ovHt;
      pascal void StdOval(verb,r)
         GrafVerb verb;
         Rect *r;
      pascal void StdArc(verb,r,startAngle,arcAngle)
         GrafVerb verb;
         Rect *r;
         short startAngle,arcAngle;
      pascal void StdPoly(verb,poly)
         GrafVerb verb;
         PolyHandle poly;
      pascal void StdRgn(verb,rgn)
         GrafVerb verb;
         RgnHandle rgn;
      pascal void StdBits(srcBits,srcRect,dstRect,mode,maskRgn)
         BitMap *srcBits;
         Rect *srcRect,*dstRect;  
         short mode;
         RgnHandle maskRgn;
      pascal void StdComment(kind,dataSize,dataHandle)
         short kind,dataSize;
         Handle dataHandle;
      pascal short StdTxMeas(count,textAddr,numer,denom,info)
         short count;
         Ptr textAddr;     
         Point *numer,*denom;
         FontInfo *info;
      pascal void StdGetPic(dataPtr,byteCount)
         Ptr dataPtr;
         short byteCount;
      pascal void StdPutPic(dataPtr,byteCount)
         Ptr dataPtr;
         short byteCount;
      
      
DESCRIPTION
      QuickDraw is the Macintosh graphics package.  

      For more detailed information see the "QuickDraw" section of the
      "Inside Macintosh" documentation.

AUTHOR
      Quickdraw by Bill Atkinson
      C Interface by Rick Meyers
      Copyright 1984 Apple Computer Inc.

BUGS
      Capture procs are not yet implemented.
