home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / Modula / Source / QUICKDRAW.DEF < prev    next >
Text File  |  1985-04-25  |  11KB  |  297 lines

  1. (*===================================================================*)
  2. DEFINITION MODULE QuickDraw;    (* Franz Kronseder 07.12.84 *)
  3.                                 (* last modification 06.02.85 *)
  4. FROM SYSTEM IMPORT ADDRESS,WORD;
  5.  
  6. EXPORT QUALIFIED   (* constants *)
  7.                    srcCopy,       srcOr,        srcXor,       srcBic,
  8.                    notSrcCopy,    notSrcOr,     notSrcXor,    notSrcBic,
  9.                    patCopy,       patOr,         patXor,       patBic,
  10.                    notPatCopy,    notPatOr,      notPatXor,    notPatBic,
  11.  
  12.                   (* simple  and ARRAY-types *)
  13.                   QDHandle,  Pattern, Bits16 , VHSelect,GrafVerb,StyleItem,   Style,
  14.  
  15.                   (* structured  record types *)
  16.                   FontInfo , Point ,Rect ,BitMap , Cursor, PenState ,RgnHandle,
  17.                   RgnPtr ,Region, PicHandle, PicPtr, Picture, PolyHandle, PolyPtr,
  18.                   Polygon, QDProcsPtr , QDProcs , GrafPtr,GrafPort, Str255,
  19.  
  20.                   (* QuickDraw global Variables
  21.                   thePort, screenBits,randSeed,
  22.                   white,black ,gray,ltGray,dkGray ,arrow, *)
  23.  
  24.                   (* GrafPort Routines *)
  25.                   InitGraf,OpenPort,InitPort,ClosePort,SetPort,GetPort,
  26.                   GrafDevice,SetPortBits,PortSize,MovePortTo,SetOrigin,
  27.                   SetClip,GetClip,ClipRect,BackPat,
  28.  
  29.                   (* Cursor Routines *)
  30.                   InitCursor,SetCursor,HideCursor, ShowCursor,ObscureCursor,
  31.  
  32.                   (* Line Routines *)
  33.                   HidePen,ShowPen,GetPen,GetPenState,SetPenState,PenSize,
  34.                   PenMode,PenPat,PenNormal,MoveTo,Move,LineTo,Line,
  35.  
  36.                   (* Text Routines *)
  37.                   TextFont,TextFace,TextMode,TextSize,SpaceExtra,DrawChar,
  38.                   DrawString,DrawText,CharWidth,StringWidth,TextWidth,
  39.                   GetFontInfo,TextBox,
  40.  
  41.                   (* Graphical Operations on Rectangles *)
  42.                   FrameRect,PaintRect,EraseRect,InvertRect,FillRect,
  43.  
  44.                   (* Graphical Operations on BitMaps *)
  45.                   ScrollRect,CopyBits,
  46.  
  47.                   (* Region Operations *)
  48.                   NewRgn,DisposeRgn,CopyRgn,SetEmptyRgn,SetRectRgn,
  49.                   FrameRgn,PaintRgn,EraseRgn,InvertRgn,FillRgn;
  50.  
  51.  
  52. (*--------------------------------------------- *)
  53. TYPE LONGINT = ADDRESS ; (* 32 bits *)
  54.  
  55. (* these definitions come from the MacIntosh Interface files
  56.  on the Lisa Workshop Supplement for the MAC.  Copyright 1983 Apple Computer Inc. *)
  57.  
  58.  (* the 16 transfer modes *)
  59. CONST
  60.  srcCopy    =  0;   srcOr     =  1;   srcXor     = 2;   srcBic      =  3;
  61.  notSrcCopy =  4;   notSrcOr  =  5;   notSrcXor  = 6;   notSrcBic   =  7;
  62.  patCopy    =  8;   patOr     =  9;  patXor     = 10;  patBic       = 11;
  63.  notPatCopy = 12; notPatOr    = 13;  notPatXor  = 14;  notPatBic    = 15;
  64.  
  65. (* QuickDraw color separation constants *)
  66.  normalBit =0;  inverseBit =1;  redBit     =4;      greenBit     =3;
  67.  blueBit   =2;  cyanBit    =8;  magentaBit =7;      yellowBit    =6;
  68.  blackBit  =5;
  69.  (* normal screen mapping   inverse screen mapping  *)
  70.  (* RGB additive mapping CMYBk subtractive mapping *)
  71.  (* colors expressed in these mappings *)
  72.  blackColor   = 33;       whiteColor   = 30;
  73.  redColor     = 205;      greenColor   = 341;
  74.  blueColor    = 409;      cyanColor    = 273;
  75.  magentaColor = 137;      yellowColor  = 69;
  76.  
  77.  picLParen =0;  picRParen =1;     (* standard picture comments *)
  78.  
  79. TYPE QDHandle  =  POINTER TO ADDRESS;               (* blind handle  *)
  80.      Str255    =  ARRAY [0..255] OF CHAR;         (* Pascal compatible String *)
  81.      Pattern   =  ARRAY[0..7] OF [0..255];
  82.      Bits16    =  ARRAY[0..15] OF INTEGER;
  83.      VHSelect  =  (v,h);
  84.      GrafVerb  =  (frame,paint,erase,invert,fill);
  85.      StyleItem =  (bold,italic,underline,outline,shadow,condense,extend);
  86.      Style     =  SET OF StyleItem;
  87.  
  88.      FontInfo  =  RECORD
  89.                     ascent:  INTEGER;  descent: INTEGER;
  90.                     widMax:  INTEGER;  leading: INTEGER; END;
  91.  
  92.      Point = RECORD CASE INTEGER OF
  93.                0: v: INTEGER;h: INTEGER;
  94.              | 1: vh: ARRAY VHSelect  OF INTEGER;         END END;
  95.  
  96.      Rect = RECORD CASE INTEGER OF
  97.               0:  top:      INTEGER;
  98.                   left:     INTEGER;
  99.                   bottom:   INTEGER;
  100.                   right:    INTEGER;
  101.             | 1:  topLeft:  Point;  botRight: Point;       END  END;
  102.  
  103.  
  104.      BitMap = RECORD
  105.                 baseAddr: ADDRESS;
  106.                 rowBytes: INTEGER;
  107.                 bounds:   Rect;              END;
  108.  
  109.  
  110.      Cursor = RECORD
  111.                 data:    Bits16; mask:    Bits16;
  112.                 hotSpot: Point;              END;
  113.  
  114.  
  115.      PenState = RECORD
  116.                   pnLoc:   Point;
  117.                   pnSize:  Point;
  118.                   pnMode:  INTEGER;
  119.                   pnPat:   Pattern;
  120.                 END;
  121.  
  122.      RgnHandle = POINTER TO RgnPtr;
  123.      RgnPtr    = POINTER TO Region;
  124.      Region    =  RECORD
  125.                     rgnSize:   INTEGER;  (* rgnSize = 10 for rectangular *)
  126.                     rgnBBox:   Rect;
  127.                     (* plus more data if not rectangular *)
  128.                   END;
  129.  
  130.      PicHandle = POINTER TO PicPtr;
  131.      PicPtr    = POINTER TO Picture;
  132.      Picture   = RECORD
  133.                    picSize:  INTEGER;
  134.                    picFrame: Rect; (* picture definition data *)
  135.                  END;
  136.  
  137.      PolyHandle = POINTER TO PolyPtr;
  138.      PolyPtr    = POINTER TO Polygon;
  139.      Polygon    = RECORD
  140.                     polySize:   INTEGER;
  141.                     polyBBox:   Rect;
  142.                     polyPoints: ARRAY [0..0] OF Point
  143.                   END;
  144.  
  145.      QDProcsPtr = POINTER TO QDProcs;
  146.      QDProcs = RECORD
  147.                  textProc:    ADDRESS;
  148.                  lineProc:    ADDRESS;
  149.                  rectProc:    ADDRESS;
  150.                  rRectProc:   ADDRESS;
  151.                  ovalProc:    ADDRESS;
  152.                  arcProc:     ADDRESS;
  153.                  polyProc:    ADDRESS;
  154.                  rgnProc:     ADDRESS;
  155.                  bitsProc:    ADDRESS;
  156.                  commentProc: ADDRESS;
  157.                  txMeasProc:  ADDRESS;
  158.                  getPicProc:  ADDRESS;
  159.                  putPicProc:  ADDRESS;
  160.                END;
  161.  
  162.  
  163.      GrafPtr  = POINTER TO GrafPort;
  164.      GrafPort = RECORD
  165.                   device:      INTEGER;
  166.                   portBits:    BitMap;
  167.                   portRect:    Rect;
  168.                   visRgn:      RgnHandle;
  169.                   clipRgn:     RgnHandle;
  170.                   bkPat:       Pattern;
  171.                   fillPat:     Pattern;
  172.                   pnLoc:       Point;
  173.                   pnSize:      Point;
  174.                   pnMode:      INTEGER;
  175.                   pnPat:       Pattern;
  176.                   pnVis:       INTEGER;
  177.                   txFont:      INTEGER;
  178.                   txFace:      Style;
  179.                   txMode:      INTEGER;
  180.                   txSize:      INTEGER;
  181.                   spExtra:     LONGINT;
  182.                   fgColor:     LONGINT;
  183.                   bkColor:     LONGINT;
  184.                   colrBit:     INTEGER;
  185.                   patStretch:  INTEGER;
  186.                   picSave:     QDHandle;
  187.                   rgnSave:     QDHandle;
  188.                   polySave:    QDHandle;
  189.                   grafProcs:   QDProcsPtr;
  190.                 END;
  191.  
  192. (*
  193. VAR thePort:    GrafPtr;
  194.    white:      Pattern;
  195.     black:      Pattern;
  196.     gray:       Pattern;
  197.     ltGray:     Pattern;
  198.     dkGray:     Pattern;
  199.     arrow:      Cursor;
  200.     screenBits: BitMap;
  201.     randSeed:   LONGINT; these variables exist already in surrounding Loader Environment *)
  202.  
  203.  
  204. (* GrafPort Routines *)
  205. PROCEDURE InitGraf   (globalPtr: ADDRESS);
  206.  (* Note-kept as external for compiler *)
  207. PROCEDURE OpenPort   (port: GrafPtr);
  208. PROCEDURE InitPort   (port: GrafPtr);
  209. PROCEDURE ClosePort  (port: GrafPtr);
  210. PROCEDURE SetPort    (port: GrafPtr);
  211. PROCEDURE GetPort    (VAR port: GrafPtr);
  212. PROCEDURE GrafDevice (device: INTEGER);
  213. PROCEDURE SetPortBits(VAR bm: BitMap);
  214. PROCEDURE PortSize   (width,height: INTEGER);
  215. PROCEDURE MovePortTo (leftGlobal,topGlobal: INTEGER);
  216. PROCEDURE SetOrigin  (h,v: INTEGER);
  217. PROCEDURE SetClip    (rgn: RgnHandle);
  218. PROCEDURE GetClip    (rgn: RgnHandle);
  219. PROCEDURE ClipRect   (VAR r: Rect);
  220. PROCEDURE BackPat    (VAR pat: Pattern);
  221.  
  222.  
  223. (* Cursor Routines *)
  224. PROCEDURE InitCursor;
  225. PROCEDURE SetCursor(VAR crsr: Cursor);
  226. PROCEDURE HideCursor;
  227. PROCEDURE ShowCursor;
  228. PROCEDURE ObscureCursor;
  229.  
  230.  
  231. (* Line Routines *)
  232. PROCEDURE HidePen;
  233. PROCEDURE ShowPen;
  234. PROCEDURE GetPen     (VAR pt: Point);
  235. PROCEDURE GetPenState(VAR pnState: PenState);
  236. PROCEDURE SetPenState(VAR pnState: PenState);
  237. PROCEDURE PenSize    (width,height: INTEGER);
  238. PROCEDURE PenMode    (mode: INTEGER);
  239. PROCEDURE PenPat     (VAR pat: Pattern);
  240. PROCEDURE PenNormal;
  241. PROCEDURE MoveTo     (h,v: INTEGER);
  242. PROCEDURE Move       (dh,dv: INTEGER);
  243. PROCEDURE LineTo     (h,v: INTEGER);
  244. PROCEDURE Line       (dh,dv: INTEGER);
  245.  
  246.  
  247. (* Text Routines *)
  248. PROCEDURE TextFont     (font: INTEGER);
  249. PROCEDURE TextFace     (face: Style);
  250. PROCEDURE TextMode     (mode: INTEGER);
  251. PROCEDURE TextSize     (size: INTEGER);
  252. PROCEDURE SpaceExtra   (extra: LONGINT);
  253. PROCEDURE DrawChar     (ch: CHAR);
  254. PROCEDURE DrawString   (stringPtr:ADDRESS);
  255. PROCEDURE DrawText     (textBuf: ADDRESS; firstByte,byteCount: INTEGER);
  256. PROCEDURE CharWidth    (ch: CHAR): INTEGER;
  257. PROCEDURE StringWidth  (stringPtr:ADDRESS): INTEGER;
  258. PROCEDURE TextWidth    (textBuf: ADDRESS; firstByte,byteCount: INTEGER): INTEGER;
  259. PROCEDURE GetFontInfo  (VAR info: FontInfo);
  260. (*Box drawing utility*)
  261. PROCEDURE TextBox( inText: ADDRESS; textLength: LONGINT; r: Rect; style: INTEGER );(*INLINE $A9CE;*)
  262.  
  263.  
  264. (* Graphical Operations on Rectangles *)
  265. PROCEDURE FrameRect  (VAR r: Rect);
  266. PROCEDURE PaintRect  (VAR r: Rect);
  267. PROCEDURE EraseRect  (VAR r: Rect);
  268. PROCEDURE InvertRect (VAR r: Rect);
  269. PROCEDURE FillRect   (VAR r: Rect;VAR  pat: Pattern);
  270.  
  271. (* MacIntosh QuickDraw Region Operations *)
  272. PROCEDURE NewRgn():   RgnHandle;
  273. PROCEDURE DisposeRgn(rgn: RgnHandle);
  274. PROCEDURE CopyRgn   (srcRgn,dstRgn: RgnHandle);
  275. PROCEDURE SetEmptyRgn(rgn: RgnHandle);
  276. PROCEDURE SetRectRgn(rgn: RgnHandle; left,top,right,bottom: INTEGER);
  277.  
  278. (* Graphical Operations on Regions *)
  279. PROCEDURE FrameRgn  (rgn: RgnHandle);
  280. PROCEDURE PaintRgn  (rgn: RgnHandle);
  281. PROCEDURE EraseRgn  (rgn: RgnHandle);
  282. PROCEDURE InvertRgn (rgn: RgnHandle);
  283. PROCEDURE FillRgn   (rgn: RgnHandle; pat: Pattern);
  284.  
  285. (* Graphical Operations on BitMaps *)
  286. PROCEDURE ScrollRect(VAR dstRect: Rect; dh,dv: INTEGER; updateRgn: RgnHandle);
  287. PROCEDURE CopyBits  (VAR srcBits,dstBits: BitMap;
  288.                      VAR srcRect,dstRect: Rect;
  289.                      mode:            INTEGER;
  290.                      maskRgn:         RgnHandle);
  291.  
  292. END QuickDraw.
  293. (*======================================================================*)
  294.  
  295.  
  296.  
  297.