home *** CD-ROM | disk | FTP | other *** search
/ CLIX - Fazer Clix Custa Nix / CLIX-CD.cdr / mac / lib / Mac / QuickDraw.xs < prev    next >
Text File  |  1998-04-05  |  48KB  |  2,548 lines

  1. /* $Header: /home/neeri/MacCVS/MacPerl/perl/ext/Mac/QuickDraw/QuickDraw.xs,v 1.5 1997/11/18 00:53:15 neeri Exp $
  2.  *
  3.  *    Copyright (c) 1996 Matthias Neeracher
  4.  *
  5.  *    You may distribute under the terms of the Perl Artistic License,
  6.  *    as specified in the README file.
  7.  *
  8.  * $Log: QuickDraw.xs,v $
  9.  * Revision 1.5  1997/11/18 00:53:15  neeri
  10.  * MacPerl 5.1.5
  11.  *
  12.  * Revision 1.4  1997/09/02 23:06:42  neeri
  13.  * Added Structs, other minor fixes
  14.  *
  15.  * Revision 1.3  1997/08/08 16:39:29  neeri
  16.  * MacPerl 5.1.4b1 + time() fix
  17.  *
  18.  * Revision 1.2  1997/05/17 21:14:34  neeri
  19.  * Last tweaks before 5.004 merge
  20.  *
  21.  * Revision 1.1  1997/04/07 20:50:36  neeri
  22.  * Synchronized with MacPerl 5.1.4a1
  23.  *
  24.  */
  25.  
  26. #define MAC_CONTEXT
  27.  
  28. #include "EXTERN.h"
  29. #include "perl.h"
  30. #include "XSUB.h"
  31. #include <Types.h>
  32. #include <Memory.h>
  33. #include <Icons.h>
  34. #include <QuickDraw.h>
  35. #include <QuickDrawText.h>
  36.  
  37. typedef short Fixed412;
  38. typedef short Fixed016;
  39.  
  40. #ifndef __CFM68K__
  41. #include <FixMath.h>
  42. #else
  43. #define fixed1              ((Fixed) 0x00010000L)
  44. #define fract1              ((Fract) 0x40000000L)
  45. #define positiveInfinity    ((long)  0x7FFFFFFFL)
  46. #define negativeInfinity    ((long)  0x80000000L)
  47.  
  48. extern pascal long double Frac2X(Fract x) = 0xA845;
  49. extern pascal long double Fix2X(Fixed x) = 0xA843;
  50. extern pascal Fixed X2Fix(long double x) = 0xA844;
  51. extern pascal Fract X2Frac(long double x) = 0xA846;
  52. #endif
  53.  
  54. static Point    sZeroPoint;
  55. static Point    sUnityPoint = {1, 1};
  56.  
  57. #define COLORPORT(Port)     ((Port->portBits.rowBytes & 0xC000) == 0xC000)
  58. #define GRAFVARS(PORT)  (*((GVarHandle)((CGrafPtr)STRUCT)->grafVars))
  59.  
  60. MODULE = Mac::QuickDraw PACKAGE = Mac::QuickDraw
  61.  
  62. =item GrafPtr
  63.  
  64. A QuickDraw graphics port. Fields are:
  65.  
  66.     short                           device;
  67.     BitMap                          portBits;
  68.     RGBColor                        rgbOpColor;                 /*color for addPin  subPin and average*/
  69.     RGBColor                        rgbHiliteColor;             /*color for hiliting*/
  70.     Fixed412                        chExtra;
  71.     Fixed016                        pnLocHFrac;
  72.     Rect                            portRect;
  73.     RgnHandle                       visRgn;
  74.     RgnHandle                       clipRgn;
  75.     Pattern                         bkPat;
  76.     Pattern                         fillPat;
  77.     RGBColor                        rgbFgColor;
  78.     RGBColor                        rgbBkColor;
  79.     Point                           pnLoc;
  80.     Point                           pnSize;
  81.     short                           pnMode;
  82.     Pattern                         pnPat;
  83.     short                           pnVis;
  84.     short                           txFont;
  85.     U8                              txFace;             
  86.     short                           txMode;
  87.     short                           txSize;
  88.     Fixed                           spExtra;
  89.     long                            fgColor;
  90.     long                            bkColor;
  91.     short                           colrBit;
  92.  
  93. As opposed to the C interfaces, Perl has a unified definition for 
  94. GrafPorts and color GrafPorts, so everything that is noted as C<BitMap> or
  95. C<Pattern> above could be returned as a C<PixMapHandle> or a C<PixPatHandle>.
  96.  
  97. =cut
  98. STRUCT * GrafPtr
  99.     short                           device;
  100.     BitMap                          portBits;
  101.         INPUT:
  102.         if (!COLORPORT(STRUCT)) {
  103.             XS_INPUT(BitMap, STRUCT->portBits, $arg);
  104.         } else {
  105.             XS_INPUT(PixMapHandle, ((CGrafPtr)STRUCT)->portPixMap, $arg);
  106.         }
  107.         OUTPUT:
  108.         if (!COLORPORT(STRUCT)) {
  109.             XS_OUTPUT(BitMap, STRUCT->portBits, $arg);
  110.         } else {
  111.             XS_OUTPUT(PixMapHandle, ((CGrafPtr)STRUCT)->portPixMap, $arg);
  112.         }
  113.     RGBColor                        rgbOpColor;                 /*color for addPin  subPin and average*/
  114.         READ_ONLY
  115.         OUTPUT:
  116.         if (COLORPORT(STRUCT)) {
  117.             RGBColor    color = GRAFVARS(STRUCT)->rgbOpColor;
  118.             XS_OUTPUT(RGBColor, color, $arg);
  119.         } else {
  120.             XS_OUTPUT(SV *, &sv_undef, $arg);
  121.         }
  122.     RGBColor                        rgbHiliteColor;             /*color for hiliting*/
  123.         READ_ONLY
  124.         OUTPUT:
  125.         if (COLORPORT(STRUCT)) {
  126.             RGBColor    color = GRAFVARS(STRUCT)->rgbHiliteColor;
  127.             XS_OUTPUT(RGBColor, color, $arg);
  128.         } else {
  129.             XS_OUTPUT(SV *, &sv_undef, $arg);
  130.         }
  131.     Fixed412                        chExtra;
  132.         INPUT:
  133.         if (COLORPORT(STRUCT)) {
  134.             XS_INPUT(Fixed412, ((CGrafPtr)STRUCT)->chExtra, $arg);
  135.         }
  136.         OUTPUT:
  137.         if (!COLORPORT(STRUCT)) {
  138.             XS_OUTPUT(SV *, &sv_undef, $arg);
  139.         } else {
  140.             XS_OUTPUT(Fixed412, ((CGrafPtr)STRUCT)->chExtra, $arg);
  141.         }
  142.     Fixed016                        pnLocHFrac;
  143.         INPUT:
  144.         if (COLORPORT(STRUCT)) {
  145.             XS_INPUT(Fixed016, ((CGrafPtr)STRUCT)->pnLocHFrac, $arg);
  146.         }
  147.         OUTPUT:
  148.         if (!COLORPORT(STRUCT)) {
  149.             XS_OUTPUT(SV *, &sv_undef, $arg);
  150.         } else {
  151.             XS_OUTPUT(Fixed016, ((CGrafPtr)STRUCT)->pnLocHFrac, $arg);
  152.         }
  153.     Rect                            portRect;
  154.         READ_ONLY
  155.     RgnHandle                       visRgn;
  156.         READ_ONLY
  157.     RgnHandle                       clipRgn;
  158.         READ_ONLY
  159.     Pattern                         bkPat;
  160.         READ_ONLY
  161.         OUTPUT:
  162.         if (!COLORPORT(STRUCT)) {
  163.             XS_OUTPUT(Pattern, STRUCT->bkPat, $arg);
  164.         } else {
  165.             XS_OUTPUT(PixPatHandle, ((CGrafPtr)STRUCT)->bkPixPat, $arg);
  166.         }
  167.     Pattern                         fillPat;
  168.         READ_ONLY
  169.         OUTPUT:
  170.         if (!COLORPORT(STRUCT)) {
  171.             XS_OUTPUT(Pattern, STRUCT->fillPat, $arg);
  172.         } else {
  173.             XS_OUTPUT(PixPatHandle, ((CGrafPtr)STRUCT)->fillPixPat, $arg);
  174.         }
  175.     RGBColor                        rgbFgColor;
  176.         READ_ONLY
  177.         OUTPUT:
  178.         if (!COLORPORT(STRUCT)) {
  179.             XS_OUTPUT(SV *, &sv_undef, $arg);
  180.         } else {
  181.             XS_OUTPUT(RGBColor, ((CGrafPtr)STRUCT)->rgbFgColor, $arg);
  182.         }
  183.     RGBColor                        rgbBkColor;
  184.         READ_ONLY
  185.         OUTPUT:
  186.         if (!COLORPORT(STRUCT)) {
  187.             XS_OUTPUT(SV *, &sv_undef, $arg);
  188.         } else {
  189.             XS_OUTPUT(RGBColor, ((CGrafPtr)STRUCT)->rgbBkColor, $arg);
  190.         }
  191.     Point                           pnLoc;
  192.     Point                           pnSize;
  193.     short                           pnMode;
  194.     Pattern                         pnPat;
  195.         READ_ONLY
  196.         OUTPUT:
  197.         if (!COLORPORT(STRUCT)) {
  198.             XS_OUTPUT(Pattern, STRUCT->pnPat, $arg);
  199.         } else {
  200.             XS_OUTPUT(PixPatHandle, ((CGrafPtr)STRUCT)->pnPixPat, $arg);
  201.         }
  202.     short                           pnVis;
  203.     short                           txFont;
  204.     U8                              txFace;             
  205.     short                           txMode;
  206.     short                           txSize;
  207.     Fixed                           spExtra;
  208.     long                            fgColor;
  209.     long                            bkColor;
  210.     short                           colrBit;
  211.  
  212. =item BitMap
  213.  
  214. A bitmap. All accessible fields are read-only:
  215.  
  216.     short   rowBytes;
  217.     Rect    bounds;
  218.  
  219. =cut
  220. STRUCT BitMap
  221.     short   rowBytes;
  222.         READ_ONLY
  223.     Rect    bounds;
  224.         READ_ONLY
  225.  
  226. =item RgnHandle
  227.  
  228. A region. All accessible fields are read-only:
  229.  
  230.     short   rgnSize;                    
  231.     Rect    rgnBBox;
  232.  
  233. =over 4
  234.  
  235. =item new RgnHandle
  236.  
  237. Create a new region.
  238.  
  239. =back
  240.  
  241. =cut
  242. STRUCT ** RgnHandle
  243.     short   rgnSize;                    
  244.         READ_ONLY
  245.     Rect    rgnBBox;
  246.         READ_ONLY
  247.  
  248. =item PicHandle
  249.  
  250. A QuickDraw picture. All accessible fields are read-only:
  251.  
  252.     short   picSize
  253.     Rect    picFrame
  254.  
  255. =over 4
  256.  
  257. =item new PicHandle DATA
  258.  
  259. =item new PicHandle DATAHDL
  260.  
  261. Create a C<PicHandle> from binary data (presumably read out of a file).
  262.  
  263. =back
  264.  
  265. =cut
  266. STRUCT ** PicHandle
  267.     short   picSize
  268.         READ_ONLY
  269.     Rect    picFrame
  270.         READ_ONLY
  271.  
  272. =item PolyHandle
  273.  
  274. A polygon. All accessible fields are read-only:
  275.  
  276.     short   polySize;
  277.     Rect    polyBBox;
  278.  
  279. =cut
  280. STRUCT ** PolyHandle
  281.     short   polySize;
  282.         READ_ONLY
  283.     Rect    polyBBox;
  284.         READ_ONLY
  285.  
  286. =item RGBColor
  287.  
  288. A RGB color value. The color components are accessible
  289.  
  290.     U16     red;                        
  291.     U16     green;                      
  292.     U16     blue;                   
  293.  
  294. =cut
  295. STRUCT RGBColor
  296.     U16     red;                        
  297.     U16     green;                      
  298.     U16     blue;                   
  299.  
  300. =over 4
  301.  
  302. =item new RGBColor RED, GREEN, BLUE
  303.  
  304. Create a new RGBColor.
  305.  
  306. =back
  307.  
  308. =item PenState
  309.  
  310. A structure with the following members:
  311.  
  312.     Point       pnLoc;
  313.     Point       pnSize;
  314.     short       pnMode;
  315.     Pattern     pnPat;
  316.  
  317. =cut
  318. STRUCT PenState
  319.     Point       pnLoc;
  320.     Point       pnSize;
  321.     short       pnMode;
  322.     Pattern     pnPat;
  323.     
  324. MODULE = Mac::QuickDraw PACKAGE = Point
  325.  
  326. =item Point
  327.  
  328. A point, featuring the following fields
  329.  
  330.     short   h;
  331.     short   v;
  332.  
  333. =cut
  334. STRUCT Point
  335.     short   h;
  336.     short   v;
  337.  
  338. =over 4
  339.  
  340. =item new Point [H [, V]]
  341.  
  342. Create a new point.
  343.  
  344. =back
  345.  
  346. =cut
  347. Point
  348. new(class, h=0, v=0)
  349.     SV *    class
  350.     short   h
  351.     short   v
  352.     CODE:
  353.     RETVAL.h = h;
  354.     RETVAL.v = v;
  355.     OUTPUT:
  356.     RETVAL
  357.  
  358. MODULE = Mac::QuickDraw PACKAGE = Rect
  359.  
  360. =item Rect
  361.  
  362. A rectangle, featuring the following fields
  363.  
  364.     short   top
  365.     short   left
  366.     short   bottom
  367.     short   right
  368.     Point   topLeft
  369.     Point   botRight
  370.  
  371. =cut
  372. STRUCT Rect
  373.     short   top
  374.     short   left
  375.     short   bottom
  376.     short   right
  377.     Point   topLeft
  378.         ALIAS *(Point *)&STRUCT.top
  379.     Point   botRight
  380.         ALIAS *(Point *)&STRUCT.bottom
  381.  
  382. =over 4
  383.  
  384. =item new Rect [LEFT [, TOP [, RIGHT [, BOTTOM]]]]
  385.  
  386. =item new Rect TOPLEFT [,BOTRIGHT]
  387.  
  388. Create a new rectangle from either coordinates or points.
  389.  
  390. =back
  391.  
  392. =cut
  393. Rect
  394. _new(left=0, top=0, right=0, bottom=0)
  395.     short   left
  396.     short   top
  397.     short   right
  398.     short   bottom
  399.     CODE:
  400.     RETVAL.left     = left;
  401.     RETVAL.top      = top;
  402.     RETVAL.right    = right;
  403.     RETVAL.bottom   = bottom;
  404.     OUTPUT:
  405.     RETVAL
  406.  
  407. =item PixMap
  408.  
  409. A pixel map, the color equivalent to a bitmap.
  410.  
  411.     short           rowBytes;       /*offset to next line*/
  412.     Rect            bounds;         /*encloses bitmap*/
  413.     short           pmVersion;      /*pixMap version number*/
  414.     short           packType;       /*defines packing format*/
  415.     long            packSize;       /*length of pixel data*/
  416.     Fixed           hRes;           /*horiz. resolution (ppi)*/
  417.     Fixed           vRes;           /*vert. resolution (ppi)*/
  418.     short           pixelType;      /*defines pixel type*/
  419.     short           pixelSize;      /*# bits in pixel*/
  420.     short           cmpCount;       /*# components in pixel*/
  421.     short           cmpSize;        /*# bits per component*/
  422.     long            planeBytes;     /*offset to next plane*/
  423.     CTabHandle      pmTable;        /*color map for this pixMap*/
  424.  
  425. =cut
  426. STRUCT PixMap
  427.     short           rowBytes;                   /*offset to next line*/
  428.     Rect            bounds;                     /*encloses bitmap*/
  429.     short           pmVersion;                  /*pixMap version number*/
  430.     short           packType;                   /*defines packing format*/
  431.     long            packSize;                   /*length of pixel data*/
  432.     Fixed           hRes;                       /*horiz. resolution (ppi)*/
  433.     Fixed           vRes;                       /*vert. resolution (ppi)*/
  434.     short           pixelType;                  /*defines pixel type*/
  435.     short           pixelSize;                  /*# bits in pixel*/
  436.     short           cmpCount;                   /*# components in pixel*/
  437.     short           cmpSize;                    /*# bits per component*/
  438.     long            planeBytes;                 /*offset to next plane*/
  439.     CTabHandle      pmTable;                    /*color map for this pixMap*/
  440.  
  441. =item PixMapHandle
  442.  
  443. A pixel map, the color equivalent to a bitmap.
  444.  
  445.     short           rowBytes;       /*offset to next line*/
  446.     Rect            bounds;         /*encloses bitmap*/
  447.     short           pmVersion;      /*pixMap version number*/
  448.     short           packType;       /*defines packing format*/
  449.     long            packSize;       /*length of pixel data*/
  450.     Fixed           hRes;           /*horiz. resolution (ppi)*/
  451.     Fixed           vRes;           /*vert. resolution (ppi)*/
  452.     short           pixelType;      /*defines pixel type*/
  453.     short           pixelSize;      /*# bits in pixel*/
  454.     short           cmpCount;       /*# components in pixel*/
  455.     short           cmpSize;        /*# bits per component*/
  456.     long            planeBytes;     /*offset to next plane*/
  457.     CTabHandle      pmTable;        /*color map for this pixMap*/
  458.  
  459. =cut
  460. STRUCT ** PixMapHandle
  461.     short           rowBytes;                   /*offset to next line*/
  462.     Rect            bounds;                     /*encloses bitmap*/
  463.     short           pmVersion;                  /*pixMap version number*/
  464.     short           packType;                   /*defines packing format*/
  465.     long            packSize;                   /*length of pixel data*/
  466.     Fixed           hRes;                       /*horiz. resolution (ppi)*/
  467.     Fixed           vRes;                       /*vert. resolution (ppi)*/
  468.     short           pixelType;                  /*defines pixel type*/
  469.     short           pixelSize;                  /*# bits in pixel*/
  470.     short           cmpCount;                   /*# components in pixel*/
  471.     short           cmpSize;                    /*# bits per component*/
  472.     long            planeBytes;                 /*offset to next plane*/
  473.     CTabHandle      pmTable;                    /*color map for this pixMap*/
  474.  
  475. =item PixPatHandle
  476.  
  477. A pixel pattern.
  478.  
  479.     short           patType;    /*type of pattern*/
  480.     PixMapHandle    patMap;     /*the pattern's pixMap*/
  481.     Handle          patData;    /*pixmap's data*/
  482.     Handle          patXData;   /*expanded Pattern data*/
  483.     short           patXValid;  /*flags whether expanded Pattern valid*/
  484.     Handle          patXMap;    /*Handle to expanded Pattern data*/
  485.     Pattern         pat1Data;   /*old-Style pattern/RGB color*/
  486.  
  487. =cut
  488. STRUCT ** PixPatHandle
  489.     short                           patType;                    /*type of pattern*/
  490.     PixMapHandle                    patMap;                     /*the pattern's pixMap*/
  491.     Handle                          patData;                    /*pixmap's data*/
  492.     Handle                          patXData;                   /*expanded Pattern data*/
  493.     short                           patXValid;                  /*flags whether expanded Pattern valid*/
  494.     Handle                          patXMap;                    /*Handle to expanded Pattern data*/
  495.     Pattern                         pat1Data;                   /*old-Style pattern/RGB color*/
  496.  
  497. =item CTabHandle
  498.  
  499. A color table. Currently, the colors are not yet accessible, but the following are:
  500.  
  501.     long    ctSeed;     /*unique identifier for table*/
  502.     short   ctFlags;    /*high bit: 0 = PixMap; 1 = device*/
  503.     short   ctSize;     /*number of entries in CTTable*/
  504.  
  505. =cut
  506. STRUCT ** CTabHandle
  507.     long    ctSeed;     /*unique identifier for table*/
  508.     short   ctFlags;    /*high bit: 0 = PixMap; 1 = device*/
  509.     short   ctSize;     /*number of entries in CTTable*/
  510.  
  511. =item CCrsrHandle
  512.  
  513. A color cursor.
  514.  
  515.     short           crsrType;                   /*type of cursor*/
  516.     PixMapHandle    crsrMap;                    /*the cursor's pixmap*/
  517.     Handle          crsrData;                   /*cursor's data*/
  518.     Handle          crsrXData;                  /*expanded cursor data*/
  519.     short           crsrXValid;                 /*depth of expanded data (0 if none)*/
  520.     Cursor          crsr1;                      /*one-bit cursor and hotspot*/
  521.  
  522. =cut
  523. STRUCT ** CCrsrHandle
  524.     short           crsrType;                   /*type of cursor*/
  525.     PixMapHandle    crsrMap;                    /*the cursor's pixmap*/
  526.     Handle          crsrData;                   /*cursor's data*/
  527.     Handle          crsrXData;                  /*expanded cursor data*/
  528.     short           crsrXValid;                 /*depth of expanded data (0 if none)*/
  529.     Cursor          crsr1;                      /*one-bit cursor and hotspot*/
  530.         ALIAS *(Cursor *)&STRUCT[0]->crsr1Data
  531.  
  532. =item CIconHandle
  533.  
  534. A color icon
  535.  
  536.     PixMap          iconPMap;                   /*the icon's pixMap*/
  537.     BitMap          iconMask;                   /*the icon's mask*/
  538.     BitMap          iconBMap;                   /*the icon's bitMap*/
  539.     Handle          iconData;                   /*the icon's data*/
  540.  
  541. =cut
  542. STRUCT ** CIconHandle
  543.     PixMap          iconPMap;                   /*the icon's pixMap*/
  544.     BitMap          iconMask;                   /*the icon's mask*/
  545.     BitMap          iconBMap;                   /*the icon's bitMap*/
  546.     Handle          iconData;                   /*the icon's data*/
  547.  
  548. =item GDHandle
  549.  
  550. A graphics device
  551.  
  552.     short           gdRefNum;                   /*driver's unit number*/
  553.     short           gdID;                       /*client ID for search procs*/
  554.     short           gdType;                     /*fixed/CLUT/direct*/
  555.     short           gdResPref;                  /*preferred resolution of GDITable*/
  556.     short           gdFlags;                    /*grafDevice flags word*/
  557.     PixMapHandle    gdPMap;                     /*describing pixMap*/
  558.     long            gdRefCon;                   /*reference value*/
  559.     GDHandle        gdNextGD;                   /*GDHandle Handle of next gDevice*/
  560.     Rect            gdRect;                     /* device's bounds in global coordinates*/
  561.     long            gdMode;                     /*device's current mode*/
  562.     short           gdCCBytes;                  /*depth of expanded cursor data*/
  563.     short           gdCCDepth;                  /*depth of expanded cursor data*/
  564.  
  565. =cut
  566. STRUCT ** GDHandle
  567.     short           gdRefNum;                   /*driver's unit number*/
  568.     short           gdID;                       /*client ID for search procs*/
  569.     short           gdType;                     /*fixed/CLUT/direct*/
  570.     short           gdResPref;                  /*preferred resolution of GDITable*/
  571.     short           gdFlags;                    /*grafDevice flags word*/
  572.     PixMapHandle    gdPMap;                     /*describing pixMap*/
  573.     long            gdRefCon;                   /*reference value*/
  574.     GDHandle        gdNextGD;                   /*Handle of next gDevice*/
  575.         INPUT:
  576.         XS_INPUT(GDHandle, *(GDHandle *)&STRUCT[0]->gdNextGD, $arg);
  577.     Rect            gdRect;                     /* device's bounds in global coordinates*/
  578.     long            gdMode;                     /*device's current mode*/
  579.     short           gdCCBytes;                  /*depth of expanded cursor data*/
  580.     short           gdCCDepth;                  /*depth of expanded cursor data*/
  581.  
  582. =back
  583.  
  584. =cut
  585.  
  586. MODULE = Mac::QuickDraw PACKAGE = Mac::QuickDraw
  587.  
  588. =head2 Functions
  589.  
  590. =over 4
  591.  
  592. =item SetPort PORT
  593.  
  594. Set the current port.
  595.  
  596. =cut
  597. void
  598. SetPort(port)
  599.     GrafPtr     port
  600.  
  601. =item GetPort()
  602.  
  603. Return the current port.
  604.  
  605. =cut
  606. GrafPtr
  607. GetPort()
  608.     CODE:
  609.     GetPort(&RETVAL);
  610.     OUTPUT:
  611.     RETVAL
  612.  
  613. =item SetOrigin H, V
  614.  
  615. Set the origin of the current port.
  616.  
  617. =cut
  618. void
  619. SetOrigin(h, v)
  620.     short   h
  621.     short   v
  622.  
  623. =item SetClip REGION
  624.  
  625. Set the clipping region of the current port to a copy of C<REGION>.
  626.  
  627. =cut
  628. void
  629. SetClip(rgn)
  630.     RgnHandle   rgn
  631.  
  632. =item REGION = GetClip [REGION]
  633.  
  634. Get the clipping region.
  635.  
  636. =cut
  637. RgnHandle
  638. GetClip(rgn=nil)
  639.     RgnHandle   rgn
  640.     CODE:
  641.     if (!(RETVAL = rgn))
  642.         RETVAL = NewRgn();
  643.     GetClip(RETVAL);
  644.     OUTPUT:
  645.     RETVAL
  646.  
  647. =item ClipRect RECT
  648.  
  649. Set the clipping region to a rectangular region.
  650.  
  651. =cut
  652. void
  653. ClipRect(r)
  654.     Rect &r
  655.  
  656. =item BackPat PATTERN
  657.  
  658. Set background fill pattern.
  659.  
  660. =cut
  661. void
  662. BackPat(pat)
  663.     Pattern &pat
  664.  
  665. =item InitCursor
  666.  
  667. Set the cursor to the arrow cursor.
  668.  
  669. =cut
  670. void
  671. InitCursor()
  672.  
  673. =item SetCursor [ CURSOR | ID ]
  674.  
  675. Set the cursor to a cursor specified as a shape or a resource ID.
  676.  
  677. =cut
  678. void
  679. _SetCursor(crsr=qd.arrow)
  680.     Cursor &crsr
  681.     CODE:
  682.     SetCursor(&crsr);
  683.  
  684. =item HideCursor
  685.  
  686. Hide the cursor.
  687.  
  688. =cut
  689. void
  690. HideCursor()
  691.  
  692. =item ShowCursor
  693.  
  694. Show the cursor.
  695.  
  696. =cut
  697. void
  698. ShowCursor()
  699.  
  700. =item ObscureCursor
  701.  
  702. Hide the cursor until it is moved again.
  703.  
  704. =cut
  705. void
  706. ObscureCursor()
  707.  
  708. =item HidePen
  709.  
  710. Hide the "pen" drawing lines.
  711.  
  712. =cut
  713. void
  714. HidePen()
  715.  
  716. =item ShowPen
  717.  
  718. Show the "pen".
  719.  
  720. =cut
  721. void
  722. ShowPen()
  723.  
  724. =item GetPen()
  725.  
  726. Returns the pen position.
  727.  
  728. =cut
  729. Point
  730. GetPen()
  731.     CODE:
  732.     GetPen(&RETVAL);
  733.     OUTPUT:
  734.     RETVAL
  735.  
  736. =item GetPenState()
  737.  
  738. Returns the pen state.
  739.  
  740. =cut
  741. PenState
  742. GetPenState()
  743.     CODE:
  744.     GetPenState(&RETVAL);
  745.     OUTPUT:
  746.     RETVAL
  747.  
  748. =item SetPenState STATE
  749.  
  750. Restores a previously returned pen state.
  751.  
  752. =cut
  753. void
  754. SetPenState(pnState)
  755.     PenState &pnState
  756.  
  757. =item PenSize WIDTH, HEIGHT
  758.  
  759. Set the pen size.
  760.  
  761. =cut
  762. void
  763. PenSize(width, height)
  764.     short   width
  765.     short   height
  766.  
  767. =item PenMode MODE
  768.  
  769. Set the pen mode.
  770.  
  771. =cut
  772. void
  773. PenMode(mode)
  774.     short   mode
  775.  
  776. =item PenPat PATTERN
  777.  
  778. Set the pen pattern.
  779.  
  780. =cut
  781. void
  782. PenPat(pat)
  783.     Pattern &pat
  784.  
  785. =item PenNormal
  786.  
  787. Restore the pen to a sane state.
  788.  
  789. =cut
  790. void
  791. PenNormal()
  792.  
  793. =item MoveTo H, V
  794.  
  795. Move the pen without drawing.
  796.  
  797. =cut
  798. void
  799. MoveTo(H, V)
  800.     short   H
  801.     short   V
  802.  
  803. =item Move DH, DV
  804.  
  805. Move pen relatively.
  806.  
  807. =cut
  808. void
  809. Move(dh, dv)
  810.     short   dh
  811.     short   dv
  812.  
  813. =item LineTo H, V
  814.  
  815. Draw a line.
  816.  
  817. =cut
  818. void
  819. LineTo(H, V)
  820.     short   H
  821.     short   V
  822.  
  823. =item Line DH, DV
  824.  
  825. Draw relative line.
  826.  
  827. =cut
  828. void
  829. Line(dh, dv)
  830.     short   dh
  831.     short   dv
  832.  
  833. =item ForeColor COLOR
  834.  
  835. Set the foreground (Classic QuickDraw) color.
  836.  
  837. =cut
  838. void
  839. ForeColor(color)
  840.     long    color
  841.  
  842. =item BackColor COLOR
  843.  
  844. Set the background (Classic QuickDraw) color.
  845.  
  846. =cut
  847. void
  848. BackColor(color)
  849.     long    color
  850.  
  851. =item OffsetRect RECT, DH, DV
  852.  
  853. Return a rectangle offset relatively.
  854.  
  855. =cut
  856. Rect
  857. OffsetRect(r, dh, dv)
  858.     Rect   &r
  859.     short   dh
  860.     short   dv
  861.     CODE:
  862.     RETVAL = r;
  863.     OffsetRect(&RETVAL, dh, dv);
  864.     OUTPUT:
  865.     RETVAL
  866.  
  867. =item NEWRECT = InsetRect RECT, DH, DV
  868.  
  869. Return the rectangle with its boundaries moved inwards or outwards.
  870.  
  871. =cut
  872. Rect
  873. InsetRect(r, dh, dv)
  874.     Rect    &r
  875.     short   dh
  876.     short   dv
  877.     CODE:
  878.     RETVAL = r;
  879.     InsetRect(&RETVAL, dh, dv);
  880.     OUTPUT:
  881.     RETVAL
  882.  
  883. =item SectRect RECT1, RECT2
  884.  
  885. Return intersection of two rectangles or undef.
  886.  
  887. =cut
  888. Rect
  889. SectRect(src1, src2)
  890.     Rect &src1
  891.     Rect &src2
  892.     CODE:
  893.     if (!SectRect(&src1, &src2, &RETVAL)) {
  894.         XSRETURN_UNDEF;
  895.     }
  896.     OUTPUT:
  897.     RETVAL
  898.  
  899. =item UnionRect RECT1, RECT2
  900.  
  901. Return union of two rectangles.
  902.  
  903. =cut
  904. Rect
  905. UnionRect(src1, src2)
  906.     Rect &src1
  907.     Rect &src2
  908.     CODE:
  909.     UnionRect(&src1, &src2, &RETVAL);
  910.     OUTPUT:
  911.     RETVAL
  912.  
  913. =item EqualRect RECT1, RECT2
  914.  
  915. Compare two rectangles.
  916.  
  917. =cut
  918. Boolean
  919. EqualRect(rect1, rect2)
  920.     Rect &rect1
  921.     Rect &rect2
  922.  
  923. =item EmptyRect RECT
  924.  
  925. Is a rectangle empty?
  926.  
  927. =cut
  928. Boolean
  929. EmptyRect(r)
  930.     Rect &r
  931.  
  932. =item FrameRect RECT
  933.  
  934. Draw a frame around the rectangle.
  935.  
  936. =cut
  937. void
  938. FrameRect(r)
  939.     Rect &r
  940.  
  941. =item PaintRect RECT
  942.  
  943. Fill a rectangle with the pen pattern.
  944.  
  945. =cut
  946. void
  947. PaintRect(r)
  948.     Rect &r
  949.  
  950. =item EraseRect RECT
  951.  
  952. Fill a rectangle with the background pattern.
  953.  
  954. =cut
  955. void
  956. EraseRect(r)
  957.     Rect &r
  958.  
  959. =item InvertRect RECT
  960.  
  961. Invert a rectangle.
  962.  
  963. =cut
  964. void
  965. InvertRect(r)
  966.     Rect &r
  967.  
  968. =item FillRect RECT, PATTERN
  969.  
  970. Fill a rectangle with the given pattern.
  971.  
  972. =cut
  973. void
  974. FillRect(r, pat)
  975.     Rect    &r
  976.     Pattern &pat
  977.  
  978. =item FrameOval RECT
  979.  
  980. =item PaintOval RECT
  981.  
  982. =item EraseOval RECT
  983.  
  984. =item InvertOval RECT
  985.  
  986. =item FillOval RECT
  987.  
  988. Same as the C<...Rect> operations, but operating on an oval inscribed 
  989. in the rectangle.
  990.  
  991. =cut
  992. void
  993. FrameOval(r)
  994.     Rect &r
  995.  
  996. void
  997. PaintOval(r)
  998.     Rect &r
  999.  
  1000. void
  1001. EraseOval(r)
  1002.     Rect &r
  1003.  
  1004. void
  1005. InvertOval(r)
  1006.     Rect &r
  1007.  
  1008. void
  1009. FillOval(r, pat)
  1010.     Rect    &r
  1011.     Pattern &pat
  1012.  
  1013. =item FrameRoundRect RECT, CORNERWIDTH, CORNERHEIGHT
  1014.  
  1015. =item PaintRoundRect RECT, CORNERWIDTH, CORNERHEIGHT
  1016.  
  1017. =item EraseRoundRect RECT, CORNERWIDTH, CORNERHEIGHT
  1018.  
  1019. =item InvertRoundRect RECT, CORNERWIDTH, CORNERHEIGHT
  1020.  
  1021. =item FillRoundRect RECT, CORNERWIDTH, CORNERHEIGHT, PATTERN
  1022.  
  1023. Same as the C<...Rect> operations, but operating on an rectangle with
  1024. rounded corners.
  1025.  
  1026. =cut
  1027. void
  1028. FrameRoundRect(r, ovalWidth, ovalHeight)
  1029.     Rect &r
  1030.     short   ovalWidth
  1031.     short   ovalHeight
  1032.  
  1033. void
  1034. PaintRoundRect(r, ovalWidth, ovalHeight)
  1035.     Rect &r
  1036.     short   ovalWidth
  1037.     short   ovalHeight
  1038.  
  1039. void
  1040. EraseRoundRect(r, ovalWidth, ovalHeight)
  1041.     Rect &r
  1042.     short   ovalWidth
  1043.     short   ovalHeight
  1044.  
  1045. void
  1046. InvertRoundRect(r, ovalWidth, ovalHeight)
  1047.     Rect &r
  1048.     short   ovalWidth
  1049.     short   ovalHeight
  1050.  
  1051. void
  1052. FillRoundRect(r, ovalWidth, ovalHeight, pat)
  1053.     Rect &r
  1054.     short   ovalWidth
  1055.     short   ovalHeight
  1056.     Pattern &pat
  1057.  
  1058. =item FrameArc RECT, STARTANGLE, ARCANGLE
  1059.  
  1060. =item PaintArc RECT, STARTANGLE, ARCANGLE
  1061.  
  1062. =item EraseArc RECT, STARTANGLE, ARCANGLE
  1063.  
  1064. =item InvertArc RECT, STARTANGLE, ARCANGLE
  1065.  
  1066. =item FillArc RECT, STARTANGLE, ARCANGLE, PATTERN
  1067.  
  1068. Same as the C<...Oval> operations, but operating on a sector of the oval.
  1069.  
  1070. =cut
  1071. void
  1072. FrameArc(r, startAngle, arcAngle)
  1073.     Rect &r
  1074.     short   startAngle
  1075.     short   arcAngle
  1076.  
  1077. void
  1078. PaintArc(r, startAngle, arcAngle)
  1079.     Rect &r
  1080.     short   startAngle
  1081.     short   arcAngle
  1082.  
  1083. void
  1084. EraseArc(r, startAngle, arcAngle)
  1085.     Rect &r
  1086.     short   startAngle
  1087.     short   arcAngle
  1088.  
  1089. void
  1090. InvertArc(r, startAngle, arcAngle)
  1091.     Rect &r
  1092.     short   startAngle
  1093.     short   arcAngle
  1094.  
  1095. void
  1096. FillArc(r, startAngle, arcAngle, pat)
  1097.     Rect &r
  1098.     short   startAngle
  1099.     short   arcAngle
  1100.     Pattern &pat
  1101.  
  1102. =item REGION = NewRgn()
  1103.  
  1104. Create a region.
  1105.  
  1106. =cut
  1107. RgnHandle
  1108. NewRgn()    
  1109.  
  1110. =item OpenRgn
  1111.  
  1112. Start capturing commands to define a region.
  1113.  
  1114. =cut
  1115. void
  1116. OpenRgn()
  1117.  
  1118. =item REGION = CloseRgn [ REGION ]
  1119.  
  1120. End capturing and return the region.
  1121.  
  1122. =cut
  1123. RgnHandle
  1124. CloseRgn(dstRgn=NULL)
  1125.     RgnHandle   dstRgn
  1126.     CODE:
  1127.     if (!(RETVAL = dstRgn))
  1128.         RETVAL = NewRgn();
  1129.     CloseRgn(RETVAL);
  1130.     OUTPUT:
  1131.     RETVAL
  1132.  
  1133. =item BitMapToRegion [REGION, ] BITMAP
  1134.  
  1135. Turn a bitmap into a region, creating the region if none is passed.
  1136.  
  1137. =cut
  1138. MacOSRet
  1139. _BitMapToRegion(region, bMap)
  1140.     RgnHandle   region
  1141.     BitMap     &bMap
  1142.     CODE:
  1143.     RETVAL = BitMapToRegion(region, &bMap);
  1144.     OUTPUT:
  1145.     RETVAL
  1146.  
  1147. =item DisposeRgn REGION
  1148.  
  1149. Dispose a region.
  1150.  
  1151. =cut
  1152. void
  1153. DisposeRgn(rgn)
  1154.     RgnHandle   rgn
  1155.  
  1156. =item CopyRgn SRCREGION [, DESTREGION]
  1157.  
  1158. Make a copy of a region.
  1159.  
  1160. =cut
  1161. RgnHandle
  1162. CopyRgn(srcRgn, dstRgn=NULL)
  1163.     RgnHandle   srcRgn
  1164.     RgnHandle   dstRgn
  1165.     CODE:
  1166.     if (!(RETVAL = dstRgn))
  1167.         RETVAL = NewRgn();
  1168.     CopyRgn(srcRgn, RETVAL);
  1169.     OUTPUT:
  1170.     RETVAL
  1171.  
  1172. =item SetEmptyRegion REGION
  1173.  
  1174. Set a region to the empty region.
  1175.  
  1176. =cut
  1177. void
  1178. SetEmptyRgn(rgn)
  1179.     RgnHandle   rgn
  1180.  
  1181. =item SetRectRgn REGION, LEFT, TOP, RIGHT, BOTTOM
  1182.  
  1183. Set a region to a rectangle.
  1184.  
  1185. =cut
  1186. void
  1187. SetRectRgn(rgn, left, top, right, bottom)
  1188.     RgnHandle   rgn
  1189.     short   left
  1190.     short   top
  1191.     short   right
  1192.     short   bottom
  1193.  
  1194. =item RectRgn [REGION, ] RECT
  1195.  
  1196. Create or copy a region from a rectangle.
  1197.  
  1198. =cut
  1199. void
  1200. _RectRgn(rgn, r)
  1201.     RgnHandle   rgn
  1202.     Rect        &r
  1203.     CODE:
  1204.     RectRgn(rgn, &r);
  1205.  
  1206. =item OffsetRgn REGION, DH, DV
  1207.  
  1208. Shift a region.
  1209.  
  1210. =cut
  1211. void
  1212. OffsetRgn(rgn, dh, dv)
  1213.     RgnHandle   rgn
  1214.     short   dh
  1215.     short   dv
  1216.  
  1217. =item InsetRgn REGION, DH, DV
  1218.  
  1219. Inset a region.
  1220.  
  1221. =cut
  1222. void
  1223. InsetRgn(rgn, dh, dv)
  1224.     RgnHandle   rgn
  1225.     short   dh
  1226.     short   dv
  1227.  
  1228. =item SectRgn REG1, REG2 [, SECT]
  1229.  
  1230. Return the intersection of two regions.
  1231.  
  1232. =cut
  1233. RgnHandle
  1234. SectRgn(srcRgnA, srcRgnB, dstRgn=NULL)
  1235.     RgnHandle   srcRgnA
  1236.     RgnHandle   srcRgnB
  1237.     RgnHandle   dstRgn
  1238.     CODE:
  1239.     if (!(RETVAL = dstRgn))
  1240.         RETVAL = NewRgn();
  1241.     SectRgn(srcRgnA, srcRgnB, RETVAL);
  1242.     OUTPUT:
  1243.     RETVAL
  1244.  
  1245. =item UnionRgn REG1, REG2 [, SECT]
  1246.  
  1247. Return the union of two regions.
  1248.  
  1249. =cut
  1250. RgnHandle
  1251. UnionRgn(srcRgnA, srcRgnB, dstRgn=NULL)
  1252.     RgnHandle   srcRgnA
  1253.     RgnHandle   srcRgnB
  1254.     RgnHandle   dstRgn
  1255.     CODE:
  1256.     if (!(RETVAL = dstRgn))
  1257.         RETVAL = NewRgn();
  1258.     UnionRgn(srcRgnA, srcRgnB, RETVAL);
  1259.     OUTPUT:
  1260.     RETVAL
  1261.  
  1262. =item DiffRgn REG1, REG2 [, SECT]
  1263.  
  1264. Return the difference between two regions.
  1265.  
  1266. =cut
  1267. RgnHandle
  1268. DiffRgn(srcRgnA, srcRgnB, dstRgn=NULL)
  1269.     RgnHandle   srcRgnA
  1270.     RgnHandle   srcRgnB
  1271.     RgnHandle   dstRgn
  1272.     CODE:
  1273.     if (!(RETVAL = dstRgn))
  1274.         RETVAL = NewRgn();
  1275.     DiffRgn(srcRgnA, srcRgnB, RETVAL);
  1276.     OUTPUT:
  1277.     RETVAL
  1278.  
  1279. =item XorRgn REG1, REG2 [, SECT]
  1280.  
  1281. Return the symmetric difference between two regions.
  1282.  
  1283. =cut
  1284. RgnHandle
  1285. XorRgn(srcRgnA, srcRgnB, dstRgn=NULL)
  1286.     RgnHandle   srcRgnA
  1287.     RgnHandle   srcRgnB
  1288.     RgnHandle   dstRgn
  1289.     CODE:
  1290.     if (!(RETVAL = dstRgn))
  1291.         RETVAL = NewRgn();
  1292.     XorRgn(srcRgnA, srcRgnB, RETVAL);
  1293.     OUTPUT:
  1294.     RETVAL
  1295.  
  1296. =item INSIDE = RectInRgn RECT, REGION
  1297.  
  1298. Test if a rectangle is contained in a region.
  1299.  
  1300. =cut
  1301. Boolean
  1302. RectInRgn(r, rgn)
  1303.     Rect       &r
  1304.     RgnHandle   rgn
  1305.  
  1306. =item EQUAL = EqualRgn REG1, REG2
  1307.  
  1308. Compare two regions.
  1309.  
  1310. =cut
  1311. Boolean
  1312. EqualRgn(rgnA, rgnB)
  1313.     RgnHandle   rgnA
  1314.     RgnHandle   rgnB
  1315.  
  1316. =item EmptyRgn REGION
  1317.  
  1318. Test if a region is empty.
  1319.  
  1320. =cut
  1321. Boolean
  1322. EmptyRgn(rgn)
  1323.     RgnHandle   rgn
  1324.  
  1325. =item FrameRgn REGION
  1326.  
  1327. =item PaintRgn REGION
  1328.  
  1329. =item EraseRgn REGION
  1330.  
  1331. =item InvertRgn REGION
  1332.  
  1333. =item FillRgn REGION, PATTERN
  1334.  
  1335. Analogous to the C<...Rect> operations.
  1336.  
  1337. =cut
  1338. void
  1339. FrameRgn(rgn)
  1340.     RgnHandle   rgn
  1341.  
  1342. void
  1343. PaintRgn(rgn)
  1344.     RgnHandle   rgn
  1345.  
  1346. void
  1347. EraseRgn(rgn)
  1348.     RgnHandle   rgn
  1349.  
  1350. void
  1351. InvertRgn(rgn)
  1352.     RgnHandle   rgn
  1353.  
  1354. void
  1355. FillRgn(rgn, pat)
  1356.     RgnHandle rgn
  1357.     Pattern  &pat
  1358.  
  1359. =item ScrollRect RECT, DH, DV [, UPDATERGN]
  1360.  
  1361. Scroll the contents of a rectangle and return a region to be updated.
  1362.  
  1363. =cut
  1364. RgnHandle
  1365. ScrollRect(r, dh, dv, updateRgn)
  1366.     Rect       &r
  1367.     short       dh
  1368.     short       dv
  1369.     RgnHandle   updateRgn
  1370.     CODE:
  1371.     if (!(RETVAL = updateRgn))
  1372.         RETVAL = NewRgn();
  1373.     ScrollRect(&r, dh, dv, RETVAL);
  1374.     OUTPUT:
  1375.     RETVAL
  1376.  
  1377. =item CopyBits SRCBITS, DESTBITS, SRCRECT, DSTRECT, MODE [, MASKRGN]
  1378.  
  1379. Copy the contents of a rectangle from one bitmap into another.
  1380.  
  1381. =cut
  1382. void
  1383. CopyBits(srcBits, dstBits, srcRect, dstRect, mode, maskRgn=NULL)
  1384.     BitMap   &srcBits
  1385.     BitMap   &dstBits
  1386.     Rect     &srcRect
  1387.     Rect     &dstRect
  1388.     short     mode
  1389.     RgnHandle maskRgn
  1390.  
  1391. =item CopyMask SRCBITS, MASKBITS, DESTBITS, SRCRECT, MASKRECT, DSTRECT
  1392.  
  1393. Copy the masked contents of a rectangle from one bitmap into another.
  1394.  
  1395. =cut
  1396. void
  1397. CopyMask(srcBits, maskBits, dstBits, srcRect, maskRect, dstRect)
  1398.     BitMap &srcBits
  1399.     BitMap &maskBits
  1400.     BitMap &dstBits
  1401.     Rect   &srcRect
  1402.     Rect   &maskRect
  1403.     Rect   &dstRect
  1404.  
  1405. =item OpenPicture RECT
  1406.  
  1407. Start capturing commands to define a picture.
  1408.  
  1409. =cut
  1410. PicHandle
  1411. OpenPicture(picFrame)
  1412.     Rect &picFrame
  1413.  
  1414.  
  1415. =item PicComment KIND, DATASIZE, DATAHANDLE
  1416.  
  1417. Insert a comment into the picture being defined.
  1418.  
  1419. =cut
  1420. void
  1421. PicComment(kind, dataSize, dataHandle)
  1422.     short   kind
  1423.     short   dataSize
  1424.     Handle  dataHandle
  1425.  
  1426. =item ClosePicture
  1427.  
  1428. Stop capturing and return the picture.
  1429.  
  1430. =cut
  1431. void
  1432. ClosePicture()
  1433.  
  1434. =item DrawPicture PICT, RECT
  1435.  
  1436. Draw a picture.
  1437.  
  1438. =cut
  1439. void
  1440. DrawPicture(myPicture, dstRect)
  1441.     PicHandle   myPicture
  1442.     Rect       &dstRect
  1443.  
  1444. =item KillPicture PICT
  1445.  
  1446. Destroy a picture.
  1447.  
  1448. =cut
  1449. void
  1450. KillPicture(myPicture)
  1451.     PicHandle   myPicture
  1452.  
  1453. =item POLY = OpenPoly()
  1454.  
  1455. Start capturing commands to define a polygon.
  1456.  
  1457. =cut
  1458. PolyHandle
  1459. OpenPoly()
  1460.  
  1461. =item ClosePoly()
  1462.  
  1463. Stop capturing and return the polygon.
  1464.  
  1465. =cut
  1466. void
  1467. ClosePoly()
  1468.  
  1469. =item KillPoly POLY
  1470.  
  1471. Destroy a polygon.
  1472.  
  1473. =cut
  1474. void
  1475. KillPoly(poly)
  1476.     PolyHandle  poly
  1477.  
  1478. =item OffsetPoly POLY, DH, DV
  1479.  
  1480. Move a polygon.
  1481.  
  1482. =cut
  1483. void
  1484. OffsetPoly(poly, dh, dv)
  1485.     PolyHandle  poly
  1486.     short   dh
  1487.     short   dv
  1488.  
  1489. =item FramePoly POLY
  1490.  
  1491. =item PaintPoly POLY
  1492.  
  1493. =item ErasePoly POLY
  1494.  
  1495. =item InvertPoly POLY
  1496.  
  1497. =item FillPoly POLY, PATTERN
  1498.  
  1499. Analogous to their C<...Rgn> equivalents.
  1500.  
  1501. =cut
  1502. void
  1503. FramePoly(poly)
  1504.     PolyHandle  poly
  1505.  
  1506. void
  1507. PaintPoly(poly)
  1508.     PolyHandle  poly
  1509.  
  1510. void
  1511. ErasePoly(poly)
  1512.     PolyHandle  poly
  1513.  
  1514. void
  1515. InvertPoly(poly)
  1516.     PolyHandle  poly
  1517.  
  1518. void
  1519. FillPoly(poly, pat)
  1520.     PolyHandle  poly
  1521.     Pattern     &pat
  1522.  
  1523. =item LocalToGlobal LPT
  1524.  
  1525. Translate from port coordinates to global coordinates.
  1526.  
  1527. =cut
  1528. Point
  1529. LocalToGlobal(pt)
  1530.     Point   pt
  1531.     CODE:
  1532.     {
  1533.         RETVAL = pt;
  1534.         LocalToGlobal(&RETVAL);
  1535.     }
  1536.     OUTPUT:
  1537.     RETVAL
  1538.  
  1539. =item GlobalToLocal GPT
  1540.  
  1541. Translate from global coordinates to port coordinates.
  1542.  
  1543. =cut
  1544. Point
  1545. GlobalToLocal(pt)
  1546.     Point   pt
  1547.     CODE:
  1548.     {
  1549.         RETVAL = pt;
  1550.         GlobalToLocal(&RETVAL);
  1551.     }
  1552.     OUTPUT:
  1553.     RETVAL
  1554.  
  1555. =item Random()
  1556.  
  1557. Return a random number.
  1558.  
  1559. =cut
  1560. short
  1561. Random()
  1562.         
  1563. =item GetPixel H, V
  1564.  
  1565. Return the value of a screen pixel.
  1566.  
  1567. =cut
  1568. Boolean
  1569. GetPixel(h, v)
  1570.     short   h
  1571.     short   v
  1572.  
  1573. =item ScalePt PT, SRCRECT, DSTRECT
  1574.  
  1575. Map a (height, width) from a source area to a destination area.
  1576.  
  1577. =cut
  1578. Point
  1579. ScalePt(pt, srcRect, dstRect)
  1580.     Point  pt
  1581.     Rect  &srcRect
  1582.     Rect  &dstRect
  1583.     CODE:
  1584.     {
  1585.         RETVAL = pt;
  1586.         ScalePt(&RETVAL, &srcRect, &dstRect);
  1587.     }
  1588.     OUTPUT:
  1589.     RETVAL
  1590.  
  1591. =item MapPt PT, SRCRECT, DSTRECT
  1592.  
  1593. Map a point from a source area to a destination area and return it.
  1594.  
  1595. =cut
  1596. Point
  1597. MapPt(pt, srcRect, dstRect)
  1598.     Point  pt
  1599.     Rect  &srcRect
  1600.     Rect  &dstRect
  1601.     CODE:
  1602.     {
  1603.         RETVAL = pt;
  1604.         MapPt(&RETVAL, &srcRect, &dstRect);
  1605.     }
  1606.     OUTPUT:
  1607.     RETVAL
  1608.  
  1609. =item MapRect RECT, SRCRECT, DSTRECT
  1610.  
  1611. Map a rectangle from a source area to a destination area and return it.
  1612.  
  1613. =cut
  1614. Rect
  1615. MapRect(r, srcRect, dstRect)
  1616.     Rect  &r
  1617.     Rect  &srcRect
  1618.     Rect  &dstRect
  1619.     CODE:
  1620.     {
  1621.         RETVAL = r;
  1622.         MapRect(&RETVAL, &srcRect, &dstRect);
  1623.     }
  1624.     OUTPUT:
  1625.     RETVAL
  1626.  
  1627. =item MapRgn REGION, SRCRECT, DSTRECT
  1628.  
  1629. Map a region from a source area to a destination area.
  1630.  
  1631. =cut
  1632. void
  1633. MapRgn(rgn, srcRect, dstRect)
  1634.     RgnHandle   rgn
  1635.     Rect  &srcRect
  1636.     Rect  &dstRect
  1637.  
  1638. =item MapPoly POLY, SRCRECT, DSTRECT
  1639.  
  1640. Map a polygon from a source area to a destination area.
  1641.  
  1642. =cut
  1643. void
  1644. MapPoly(poly, srcRect, dstRect)
  1645.     PolyHandle  poly
  1646.     Rect &srcRect
  1647.     Rect &dstRect
  1648.  
  1649. =item PtInRect PT, RECT
  1650.  
  1651. Test whether a point is in a rectangle.
  1652.  
  1653. =cut
  1654. Boolean
  1655. PtInRect(pt, r)
  1656.     Point pt
  1657.     Rect &r
  1658.  
  1659. =item AddPt P1, P2
  1660.  
  1661. Add two points.
  1662.  
  1663. =cut
  1664. Point
  1665. AddPt(src, dst)
  1666.     Point   src
  1667.     Point   &dst
  1668.     CODE:
  1669.     RETVAL = dst;
  1670.     AddPt(src, &RETVAL);
  1671.     OUTPUT:
  1672.     RETVAL
  1673.  
  1674. =item EqualPt P1, P2
  1675.  
  1676. Compare two points.
  1677.  
  1678. =cut
  1679. Boolean
  1680. EqualPt(pt1, pt2)
  1681.     Point   pt1
  1682.     Point   pt2
  1683.  
  1684. =item Pt2Rect TOPLEFT, BOTRIGHT
  1685.  
  1686. Create a rectangle from two corner points.
  1687.  
  1688. =cut
  1689. Rect
  1690. Pt2Rect(pt1, pt2)
  1691.     Point   pt1
  1692.     Point   pt2
  1693.     CODE:
  1694.     Pt2Rect(pt1, pt2, &RETVAL);
  1695.     OUTPUT:
  1696.     RETVAL
  1697.  
  1698. =item SubPt SUBTRAHEND, MINUEND
  1699.  
  1700. Subtract two points.
  1701.  
  1702. =cut
  1703. Point
  1704. SubPt(src, dst)
  1705.     Point   src
  1706.     Point   &dst
  1707.     CODE:
  1708.     RETVAL = dst;
  1709.     SubPt(src, &RETVAL);
  1710.     OUTPUT:
  1711.     RETVAL
  1712.  
  1713. =item PtToAngle RECT, PT
  1714.  
  1715. Determine the angle of a point within an oval.
  1716.  
  1717. =cut
  1718. short
  1719. PtToAngle(r, pt)
  1720.     Rect  &r
  1721.     Point pt
  1722.     CODE:
  1723.     PtToAngle(&r, pt, &RETVAL);
  1724.     OUTPUT:
  1725.     RETVAL
  1726.         
  1727. =item PtInRgn PT, REGION
  1728.  
  1729. Test whether a point is in a region.
  1730.  
  1731. =cut
  1732. Boolean
  1733. PtInRgn(pt, rgn)
  1734.     Point       pt
  1735.     RgnHandle   rgn
  1736.  
  1737. =item PIXMAP = NewPixMap()
  1738.  
  1739. Create a new pixel map.
  1740.  
  1741. =cut
  1742. PixMapHandle
  1743. NewPixMap()
  1744.  
  1745. =item DisposePixMap PIXMAP
  1746.  
  1747. Destroy a pixel map.
  1748.  
  1749. =cut
  1750. void
  1751. DisposePixMap(pm)
  1752.     PixMapHandle    pm
  1753.  
  1754. =item CopyPixMap PIXMAP [, DSTPIXMAP]
  1755.  
  1756. Copy a pixmap.
  1757.  
  1758. =cut
  1759. PixMapHandle
  1760. CopyPixMap(srcPM, dstPM=NULL)
  1761.     PixMapHandle    srcPM
  1762.     PixMapHandle    dstPM
  1763.     CODE:
  1764.     if (!(RETVAL = dstPM))
  1765.         RETVAL = NewPixMap();
  1766.     CopyPixMap(srcPM, RETVAL);
  1767.     OUTPUT:
  1768.     RETVAL
  1769.  
  1770. =item PIXPAT = NewPixPat()
  1771.  
  1772. Create a pixel pattern.
  1773.  
  1774. =cut
  1775. PixPatHandle
  1776. NewPixPat()
  1777.  
  1778. =item DisposePixPat PIXPAT
  1779.  
  1780. Destroy a pixel pattern.
  1781.  
  1782. =cut
  1783. void
  1784. DisposePixPat(pp)
  1785.     PixPatHandle    pp
  1786.  
  1787. =item CopyPixPat PIXPAT [, DSTPIXPAT]
  1788.  
  1789. Copy a pixpat.
  1790.  
  1791. =cut
  1792. PixPatHandle
  1793. CopyPixPat(srcPP, dstPP=NULL)
  1794.     PixPatHandle    srcPP
  1795.     PixPatHandle    dstPP
  1796.     CODE:
  1797.     if (!(RETVAL = dstPP))
  1798.         RETVAL = NewPixPat();
  1799.     CopyPixPat(srcPP, RETVAL);
  1800.     OUTPUT:
  1801.     RETVAL
  1802.  
  1803. =item PenPixPat PIXPAT
  1804.  
  1805. Set the pen pixel pattern.
  1806.  
  1807. =cut
  1808. void
  1809. PenPixPat(pp)
  1810.     PixPatHandle    pp
  1811.  
  1812. =item BackPixPat PIXPAT
  1813.  
  1814. Set the fill pixel pattern.
  1815.  
  1816. =cut
  1817. void
  1818. BackPixPat(pp)
  1819.     PixPatHandle    pp
  1820.  
  1821. =item GetPixPat ID
  1822.  
  1823. Get a pixel pattern from a resource.
  1824.  
  1825. =cut
  1826. PixPatHandle
  1827. GetPixPat(patID)
  1828.     short   patID
  1829.  
  1830. =item MakeRGBPat [PATTERN, ] COLOR
  1831.  
  1832. Create a pixel pattern for a dithered color.
  1833.  
  1834. =cut
  1835. void
  1836. _MakeRGBPat(pp, myColor)
  1837.     PixPatHandle   pp
  1838.     RGBColor     & myColor
  1839.     CODE:
  1840.     MakeRGBPat(pp, &myColor);
  1841.  
  1842. =item FillCRect RECT, PIXPAT
  1843.  
  1844. =item FillCOval RECT, PIXPAT
  1845.  
  1846. =item FillCRoundRect RECT, CORNERWIDTH, CORNERHEIGHT, PIXPAT
  1847.  
  1848. =item FillCArc RECT, STARTANGLE, ARCANGLE, PIXPAT
  1849.  
  1850. =item FillCRgn REGION, PIXPAT
  1851.  
  1852. =item FillCPoly POLY, PIXPAT
  1853.  
  1854. Fill routines using pixel patterns instead of black and white patterns.
  1855.  
  1856. =cut
  1857. void
  1858. FillCRect(r, pp)
  1859.     Rect         &r
  1860.     PixPatHandle  pp
  1861.  
  1862. void
  1863. FillCOval(r, pp)
  1864.     Rect         &r
  1865.     PixPatHandle  pp
  1866.  
  1867. void
  1868. FillCRoundRect(r, ovalWidth, ovalHeight, pp)
  1869.     Rect   &r
  1870.     short   ovalWidth
  1871.     short   ovalHeight
  1872.     PixPatHandle    pp
  1873.  
  1874. void
  1875. FillCArc(r, startAngle, arcAngle, pp)
  1876.     Rect   &r
  1877.     short   startAngle
  1878.     short   arcAngle
  1879.     PixPatHandle    pp
  1880.  
  1881. void
  1882. FillCRgn(rgn, pp)
  1883.     RgnHandle   rgn
  1884.     PixPatHandle    pp
  1885.  
  1886. void
  1887. FillCPoly(poly, pp)
  1888.     PolyHandle  poly
  1889.     PixPatHandle    pp
  1890.  
  1891. =item RGBForeColor COLOR
  1892.  
  1893. Set an RGB color as the foreground color.
  1894.  
  1895. =cut
  1896. void
  1897. RGBForeColor(color)
  1898.     RGBColor &color
  1899.  
  1900. =item RGBBackColor COLOR
  1901.  
  1902. Set an RGB color as the background color.
  1903.  
  1904. =cut
  1905. void
  1906. RGBBackColor(color)
  1907.     RGBColor &color
  1908.  
  1909. =item SetCPixel H, V, COLOR
  1910.  
  1911. Set a pixel.
  1912.  
  1913. =cut
  1914. void
  1915. SetCPixel(h, v, color)
  1916.     short   h
  1917.     short   v
  1918.     RGBColor &color
  1919.  
  1920. =item SetPortPix PIXMAP
  1921.  
  1922. Set the pixmap for the current port.
  1923.  
  1924. =cut
  1925. void
  1926. SetPortPix(pm)
  1927.     PixMapHandle    pm
  1928.  
  1929. =item GetCPixel H, V
  1930.  
  1931. Get the color of a pixel.
  1932.  
  1933. =cut
  1934. RGBColor
  1935. GetCPixel(h, v)
  1936.     short   h
  1937.     short   v
  1938.     CODE:
  1939.     GetCPixel(h, v, &RETVAL);
  1940.     OUTPUT:
  1941.     RETVAL
  1942.  
  1943. =item GetForeColor
  1944.  
  1945. Return the foreground color.
  1946.  
  1947. =cut
  1948. RGBColor
  1949. GetForeColor()
  1950.     CODE:
  1951.     GetForeColor(&RETVAL);
  1952.     OUTPUT:
  1953.     RETVAL
  1954.  
  1955. =item GetBackColor
  1956.  
  1957. Return the background color.
  1958.  
  1959. =cut
  1960. RGBColor
  1961. GetBackColor()
  1962.     CODE:
  1963.     GetBackColor(&RETVAL);
  1964.     OUTPUT:
  1965.     RETVAL
  1966.  
  1967. =item PICT = OpenCPicture RECT [, HRES, VRES]
  1968.  
  1969. Start capturing a color picture.
  1970.  
  1971. =cut
  1972. PicHandle
  1973. OpenCPicture(r, hRes=0x0048000, vRes=0x0048000)
  1974.     Rect    r
  1975.     Fixed   hRes
  1976.     Fixed   vRes
  1977.     PREINIT:
  1978.     OpenCPicParams  params;
  1979.     CODE:
  1980.     {
  1981.         params.srcRect = r;
  1982.         params.hRes    = hRes;
  1983.         params.vRes    = vRes;
  1984.         params.version = -2;
  1985.         params.reserved1 = params.reserved2 = 0;
  1986.         RETVAL = OpenCPicture(¶ms);
  1987.     }
  1988.     OUTPUT:
  1989.     RETVAL
  1990.  
  1991. =item OpColor COLOR
  1992.  
  1993. Set color operand for pin and blend modes.
  1994.  
  1995. =cut
  1996. void
  1997. OpColor(color)
  1998.     RGBColor &color
  1999.  
  2000. =item HiliteColor COLOR
  2001.  
  2002. Set hilite color.
  2003.  
  2004. =cut
  2005. void
  2006. HiliteColor(color)
  2007.     RGBColor &color
  2008.  
  2009. =item DisposeCTable CTABLE
  2010.  
  2011. Dispose a color table.
  2012.  
  2013. =cut
  2014. void
  2015. DisposeCTable(cTable)
  2016.     CTabHandle  cTable
  2017.  
  2018. =item CTABLE = GetCTable ID
  2019.  
  2020. Read a color table from a resource.
  2021.  
  2022. =cut
  2023. CTabHandle
  2024. GetCTable(ctID)
  2025.     short   ctID
  2026.  
  2027. =item CURSOR = GetCCursor ID
  2028.  
  2029. Read a color cursor from a resource.
  2030.  
  2031. =cut
  2032. CCrsrHandle
  2033. GetCCursor(crsrID)
  2034.     short   crsrID
  2035.  
  2036. =item SetCCursor CURSOR
  2037.  
  2038. Set a color cursor.
  2039.  
  2040. =cut
  2041. void
  2042. SetCCursor(cCrsr)
  2043.     CCrsrHandle     cCrsr
  2044.  
  2045. =item DisposeCCursor CURSOR
  2046.  
  2047. Destroy a color cursor.
  2048.  
  2049. =cut
  2050. void
  2051. DisposeCCursor(cCrsr)
  2052.     CCrsrHandle     cCrsr
  2053.  
  2054. =item GetCIcon ID
  2055.  
  2056. Read a color icon.
  2057.  
  2058. =cut
  2059. CIconHandle
  2060. GetCIcon(iconID)
  2061.     short   iconID
  2062.  
  2063. =item PlotCIcon RECT, ICON
  2064.  
  2065. Plot a color icon.
  2066.  
  2067. =cut
  2068. void
  2069. PlotCIcon(theRect, theIcon)
  2070.     Rect       &theRect
  2071.     CIconHandle theIcon
  2072.  
  2073. =item DisposeCIcon ICON
  2074.  
  2075. Destroy a color icon.
  2076.  
  2077. =cut
  2078. void
  2079. DisposeCIcon(theIcon)
  2080.     CIconHandle     theIcon
  2081.  
  2082. =item GetMaxDevice RECT
  2083.  
  2084. Get the device containing the largest portion of the rectangle.
  2085.  
  2086. =cut
  2087. GDHandle
  2088. GetMaxDevice(globalRect)
  2089.     Rect &globalRect
  2090.  
  2091. =item GetDeviceList()
  2092.  
  2093. Get the first device.
  2094.  
  2095. =cut
  2096. GDHandle
  2097. GetDeviceList()
  2098.  
  2099. =item GetMainDevice()
  2100.  
  2101. Get the main device.
  2102.  
  2103. =cut
  2104. GDHandle
  2105. GetMainDevice()
  2106.  
  2107. =item GetNextDevice PREVGDEVICE
  2108.  
  2109. Get the next device in the device list.
  2110.  
  2111. =cut
  2112. GDHandle
  2113. GetNextDevice(curDevice)
  2114.     GDHandle    curDevice
  2115.  
  2116. =item TestDeviceAttribute GDEVICE, ATTR
  2117.  
  2118. Test a device for attributes.
  2119.  
  2120. =cut
  2121. Boolean
  2122. TestDeviceAttribute(gdh, attribute)
  2123.     GDHandle    gdh
  2124.     short   attribute
  2125.  
  2126. =item SetDeviceAttribute GDEVICE, ATTR, VAL
  2127.  
  2128. Set deive attributes.
  2129.  
  2130. =cut
  2131. void
  2132. SetDeviceAttribute(gdh, attribute, value)
  2133.     GDHandle    gdh
  2134.     short   attribute
  2135.     Boolean     value
  2136.  
  2137. =item NewGDevice REFNUM, MODE
  2138.  
  2139. Create a new graphics device.
  2140.  
  2141. =cut
  2142. GDHandle
  2143. NewGDevice(refNum, mode)
  2144.     short   refNum
  2145.     long    mode
  2146.  
  2147. =item DisposeGDevice GDEVICE
  2148.  
  2149. Destroy a graphics device structure.
  2150.  
  2151. =cut
  2152. void
  2153. DisposeGDevice(gdh)
  2154.     GDHandle    gdh
  2155.  
  2156. =item SetGDevice GDEVICE
  2157.  
  2158. Set the device of the current port.
  2159.  
  2160. =cut
  2161. void
  2162. SetGDevice(gd)
  2163.     GDHandle    gd
  2164.  
  2165. =item GetGDevice 
  2166.  
  2167. Return the device of the current port.
  2168.  
  2169. =cut
  2170. GDHandle
  2171. GetGDevice()
  2172.  
  2173. =item Color2Index COLOR 
  2174.  
  2175. Translate a color into an index in the color table.
  2176.  
  2177. =cut
  2178. long
  2179. Color2Index(myColor)
  2180.     RGBColor &myColor
  2181.  
  2182. =item Index2Color INDEX 
  2183.  
  2184. Translate an index into its color.
  2185.  
  2186. =cut
  2187. RGBColor
  2188. Index2Color(index)
  2189.     long    index
  2190.     CODE:
  2191.     Index2Color(index, &RETVAL);
  2192.     OUTPUT:
  2193.     RETVAL
  2194.  
  2195. =item InvertColor COLOR 
  2196.  
  2197. Return the inverse color.
  2198.  
  2199. =cut
  2200. RGBColor
  2201. InvertColor(myColor)
  2202.     RGBColor &myColor
  2203.     CODE:
  2204.     RETVAL = myColor;
  2205.     InvertColor(&RETVAL);
  2206.     OUTPUT:
  2207.     RETVAL
  2208.  
  2209. =item RealColor COLOR 
  2210.  
  2211. Test if the color is available.
  2212.  
  2213. =cut
  2214. Boolean
  2215. RealColor(color)
  2216.     RGBColor &color
  2217.  
  2218. =item ERROR = QDError()
  2219.  
  2220. =cut
  2221. MacOSRet
  2222. QDError()
  2223.         
  2224. =item CopyDeepMask SRCBITS, MASKBITS, DSTBITS, SRCRECT, MASKRECT, DSTRECT, MODE, MASKRGN
  2225.  
  2226. Combines the effects of C<CopyBits> and C<CopyMask>.
  2227.  
  2228. =cut
  2229. void
  2230. CopyDeepMask(srcBits, maskBits, dstBits, srcRect, maskRect, dstRect, mode, maskRgn=NULL)
  2231.     BitMap &srcBits
  2232.     BitMap &maskBits
  2233.     BitMap &dstBits
  2234.     Rect   &srcRect
  2235.     Rect   &maskRect
  2236.     Rect   &dstRect
  2237.     short   mode
  2238.     RgnHandle   maskRgn
  2239.  
  2240. =item GetPattern ID
  2241.  
  2242. Read a pattern from a resource.
  2243.  
  2244. =cut
  2245. Pattern
  2246. GetPattern(patternID)
  2247.     short   patternID
  2248.     PREINIT:
  2249.     PatHandle   ph;
  2250.     CODE:
  2251.     if (!(ph = GetPattern(patternID)))
  2252.         XSRETURN_UNDEF;
  2253.     else
  2254.         RETVAL = **ph;
  2255.     OUTPUT:
  2256.     RETVAL
  2257.  
  2258. =item GetCursor ID
  2259.  
  2260. Read a cursor from a resource.
  2261.  
  2262. =cut
  2263. Cursor
  2264. GetCursor(cursorID)
  2265.     short   cursorID
  2266.     PREINIT:
  2267.     CursHandle  ch;
  2268.     CODE:
  2269.     if (!(ch = GetCursor(cursorID)))
  2270.         XSRETURN_UNDEF;
  2271.     else
  2272.         RETVAL = **ch;
  2273.     OUTPUT:
  2274.     RETVAL
  2275.  
  2276. =item GetPicture ID
  2277.  
  2278. Read a picture from a resource.
  2279.  
  2280. =cut
  2281. PicHandle
  2282. GetPicture(pictureID)
  2283.     short   pictureID
  2284.  
  2285. =item ShieldCursor RECT [, OFFSET]
  2286.  
  2287. Define a rectangle within which the cursor is hidden.
  2288.  
  2289. =cut
  2290. void
  2291. ShieldCursor(shieldRect, pt=sZeroPoint)
  2292.     Rect   &shieldRect
  2293.     Point   pt
  2294.  
  2295. =item ScreenRes();
  2296.  
  2297. Return the resolution of the screen.
  2298.  
  2299.    ($hres, $vres) = ScreenRes;
  2300.  
  2301. =cut
  2302. void
  2303. ScreenRes()
  2304.     PREINIT:
  2305.     short scrnHRes;
  2306.     short scrnVRes;
  2307.     PPCODE:
  2308.     {
  2309.         ScreenRes(&scrnHRes, &scrnVRes);
  2310.         XS_XPUSH(short, scrnHRes);
  2311.         if (GIMME == G_ARRAY) {
  2312.             XS_XPUSH(short, scrnVRes);
  2313.         }
  2314.     }
  2315.  
  2316. =item GetIndPattern ID, INDEX
  2317.  
  2318. Get a pattern from a pattern list resource.
  2319.  
  2320. =cut
  2321. Pattern
  2322. GetIndPattern(patternListID, index)
  2323.     short   patternListID
  2324.     short   index
  2325.     CODE:
  2326.     GetIndPattern(&RETVAL, patternListID, index);
  2327.     OUTPUT:
  2328.     RETVAL
  2329.  
  2330. =item (POS, LEADING, WIDTH) = PixelToChar TEXT, SLOP, WIDTH, STYLERUN [, NUMER, DENOM]
  2331.  
  2332. Map a pixel position into a character position.
  2333.  
  2334.     ($characterPosition, $leadingEdge, $widthRemaining) =
  2335.         PixelToChar("Hello, World", 0, 35, smMiddleStyleRun);
  2336.  
  2337. =cut
  2338. void
  2339. PixelToChar(text, slop, pixelWidth, styleRunPosition, numer=sUnityPoint, denom=sUnityPoint)
  2340.     SV *    text
  2341.     Fixed   slop
  2342.     Fixed   pixelWidth
  2343.     JustStyleCode   styleRunPosition
  2344.     Point   numer;
  2345.     Point   denom;
  2346.     PPCODE:
  2347.     {
  2348.         short   pos;
  2349.         Boolean leadingEdge;
  2350.         Fixed   widthRemaining;
  2351.         void *  textPtr;
  2352.         STRLEN  textSize;
  2353.         
  2354.         textPtr =   SvPV(text, textSize);
  2355.         pos = 
  2356.             PixelToChar(
  2357.                 textPtr, textSize, slop, pixelWidth, 
  2358.                 &leadingEdge, &widthRemaining, styleRunPosition, numer, denom);
  2359.         EXTEND(sp,3);
  2360.         PUSHs(sv_2mortal(newSViv(pos)));
  2361.         PUSHs(sv_2mortal(newSViv(leadingEdge)));
  2362.         PUSHs(sv_2mortal(newSVnv(Fix2X(widthRemaining))));
  2363.     }
  2364.  
  2365. =item CharToPixel TEXT, SLOP, OFFSET, DIRECTION, STYLERUN [, NUMER, DENOM]
  2366.  
  2367. Translate a character position into a pixel offset.
  2368.  
  2369. =cut
  2370. short
  2371. CharToPixel(text, slop, offset, direction, styleRunPosition, numer=sUnityPoint, denom=sUnityPoint)
  2372.     SV *    text
  2373.     Fixed   slop
  2374.     long    offset
  2375.     short   direction
  2376.     JustStyleCode   styleRunPosition
  2377.     Point   numer;
  2378.     Point   denom;
  2379.     CODE:
  2380.     {
  2381.         void *  textPtr;
  2382.         STRLEN  textSize;
  2383.         
  2384.         textPtr =   SvPV(text, textSize);
  2385.         RETVAL = 
  2386.             CharToPixel(
  2387.                 textPtr, textSize, slop, offset, direction, 
  2388.                 styleRunPosition, numer, denom);
  2389.     }
  2390.     OUTPUT:
  2391.     RETVAL
  2392.  
  2393. =item DrawJustified TEXT, SLOP, STYLERUN [, NUMER, DENOM]
  2394.  
  2395. Draw a string with the specified amount of adjustment.
  2396.  
  2397. =cut
  2398. void
  2399. DrawJustified(text, slop, styleRunPosition, numer=sUnityPoint, denom=sUnityPoint)
  2400.     SV *    text
  2401.     Fixed   slop
  2402.     JustStyleCode   styleRunPosition
  2403.     Point   numer;
  2404.     Point   denom;
  2405.     CODE:
  2406.     {
  2407.         void *  textPtr;
  2408.         STRLEN  textSize;
  2409.         
  2410.         textPtr =   SvPV(text, textSize);
  2411.         DrawJustified(textPtr, textSize, slop, styleRunPosition, numer, denom);
  2412.     }
  2413.  
  2414. =item PortionLine TEXT, STYLERUN [, NUMER, DENOM]
  2415.  
  2416. Calculate a measure for the portion of space to be allocated to a style run.
  2417.  
  2418. =cut
  2419. Fixed
  2420. PortionLine(text, styleRunPosition, numer=sUnityPoint, denom=sUnityPoint)
  2421.     SV *    text
  2422.     JustStyleCode   styleRunPosition
  2423.     Point   numer;
  2424.     Point   denom;
  2425.     CODE:
  2426.     {
  2427.         void *  textPtr;
  2428.         STRLEN  textSize;
  2429.         
  2430.         textPtr =   SvPV(text, textSize);
  2431.         RETVAL = PortionLine(textPtr, textSize, styleRunPosition, numer, denom);
  2432.     }
  2433.     OUTPUT:
  2434.     RETVAL
  2435.  
  2436. =item VisibleLength TEXT
  2437.  
  2438. Calculate the length of the text as drawn.
  2439.  
  2440. =cut
  2441. long
  2442. VisibleLength(text)
  2443.     SV * text
  2444.     CODE:
  2445.     {
  2446.         void *  textPtr;
  2447.         STRLEN  textSize;
  2448.         
  2449.         textPtr =   SvPV(text, textSize);
  2450.         RETVAL = VisibleLength(textPtr, textSize);
  2451.     }
  2452.     OUTPUT:
  2453.     RETVAL
  2454.     
  2455. =item TextFont FONTNUM
  2456.  
  2457. Set the font ID for text.
  2458.  
  2459. =cut
  2460. void
  2461. TextFont(font)
  2462.     short   font
  2463.  
  2464. =item TextFace FACE
  2465.  
  2466. Set the text style.
  2467.  
  2468. =cut
  2469. void
  2470. TextFace(face)
  2471.     short   face
  2472.  
  2473. =item TextMode MODE
  2474.  
  2475. Set the text mode.
  2476.  
  2477. =cut
  2478. void
  2479. TextMode(mode)
  2480.     short   mode
  2481.  
  2482. =item TextSize SIZE
  2483.  
  2484. Set the text size.
  2485.  
  2486. =cut
  2487. void
  2488. TextSize(size)
  2489.     short   size
  2490.  
  2491. =item SpaceExtra EXTRA
  2492.  
  2493. Set the extra space to be added to each space character.
  2494.  
  2495. =cut
  2496. void
  2497. SpaceExtra(extra)
  2498.     Fixed   extra
  2499.  
  2500. =item DrawString STRING
  2501.  
  2502. Draw a string.
  2503.  
  2504. =cut
  2505. void
  2506. DrawString(s)
  2507.     Str255  s
  2508.  
  2509. =item StringWidth STRING
  2510.  
  2511. Return the width of a string.
  2512.  
  2513. =cut
  2514. short
  2515. StringWidth(s)
  2516.     Str255  s
  2517.  
  2518. =item GetFontInfo()
  2519.  
  2520. Get measurements for a font.
  2521.  
  2522.    ($ascent, $descend, $maxWidth, $leading) = GetFontInfo();
  2523.  
  2524. =cut
  2525. void
  2526. GetFontInfo()
  2527.     PPCODE:
  2528.     {
  2529.         FontInfo    info;
  2530.         
  2531.         GetFontInfo(&info);
  2532.         EXTEND(sp,4);
  2533.         PUSHs(sv_2mortal(newSViv(info.ascent)));
  2534.         PUSHs(sv_2mortal(newSViv(info.descent)));
  2535.         PUSHs(sv_2mortal(newSViv(info.widMax)));
  2536.         PUSHs(sv_2mortal(newSViv(info.leading)));
  2537.     }
  2538.  
  2539. =item CharExtra EXTRA
  2540.  
  2541. Specify the extra space to be added to each character.
  2542.  
  2543. =cut
  2544. void
  2545. CharExtra(extra)
  2546.     Fixed   extra
  2547.  
  2548.