home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / progrmng / thinkc40.sit / Color.h Update / Color.h < prev   
Encoding:
C/C++ Source or Header  |  1990-03-29  |  6.7 KB  |  372 lines  |  [TEXT/KAHL]

  1.  
  2. /*
  3.  *  Color.h
  4.  *
  5.  *  Copyright (c) 1989 Symantec Corporation.  All rights reserved.
  6.  *
  7.  *  These interfaces are based on material copyrighted
  8.  *  by Apple Computer, Inc., 1985-1989.
  9.  *
  10.  */
  11.  
  12. #ifndef _Color_
  13. #define _Color_
  14.  
  15. #ifndef _Quickdraw_
  16. #include "Quickdraw.h"
  17. #endif
  18.  
  19.  
  20. #define invalColReq        (-1)
  21.  
  22. /*  transfer modes  */
  23.  
  24. enum {
  25.     blend = 32,
  26.     addPin,
  27.     addOver,
  28.     subPin,
  29.     transparent,
  30.     addMax, adMax = addMax,
  31.     subOver,
  32.     addMin, adMin = addMin
  33. };
  34.  
  35. /* VALUES FOR GDType */
  36.  
  37. #define clutType        0
  38. #define fixedType        1
  39. #define directType        2
  40.  
  41. /*  BIT ASSIGNMENTS FOR GDFlags */
  42.  
  43. #define gdDevType        0
  44. #define ramInit            10
  45. #define mainScreen        11
  46. #define allInit            12
  47. #define screenDevice    13
  48. #define noDriver        14
  49. #define screenActive    15        
  50.  
  51. #define hiliteBit        7
  52. #define pHiliteBit        0
  53.  
  54. #define defQDColors     127
  55.  
  56.  
  57. typedef struct RGBColor{
  58.     unsigned short    red;
  59.     unsigned short    green;
  60.     unsigned short    blue;
  61. } RGBColor;
  62.  
  63. typedef struct ColorSpec{
  64.     short            value;
  65.     RGBColor        rgb;
  66. } ColorSpec;
  67.  
  68. typedef ColorSpec CSpecArray[1];        /* array [0..0] of ColorSpec */
  69.  
  70. typedef struct ColorTable{
  71.     long            ctSeed;
  72.     short            ctFlags;
  73.     short            ctSize;
  74.     CSpecArray        ctTable;
  75. } ColorTable, *CTabPtr, **CTabHandle;
  76. #define transIndex ctFlags
  77.  
  78. typedef struct MatchRec{
  79.     unsigned short    red;
  80.     unsigned short    green;
  81.     unsigned short    blue;
  82.     long            matchData;
  83. } MatchRec;
  84.  
  85. typedef struct PixMap{
  86.     Ptr                baseAddr;
  87.     short            rowBytes;
  88.     Rect            bounds;
  89.     short            pmVersion;
  90.     short            packType;
  91.     long            packSize;
  92.     Fixed            hRes;
  93.     Fixed            vRes;
  94.     short            pixelType;
  95.     short            pixelSize;
  96.     short            cmpCount;
  97.     short            cmpSize;
  98.     long            planeBytes;
  99.     CTabHandle        pmTable;
  100.     long            pmReserved;
  101. } PixMap, *PixMapPtr, **PixMapHandle;
  102.  
  103. typedef struct PixPat{
  104.     short            patType;
  105.     PixMapHandle    patMap;
  106.     Handle            patData;
  107.     Handle            patXData;
  108.     short            patXValid;
  109.     Handle            patXMap;
  110.     Pattern            pat1Data;
  111. } PixPat, *PixPatPtr, **PixPatHandle;
  112.  
  113. typedef struct CCrsr{
  114.     short            crsrType;
  115.     PixMapHandle    crsrMap;
  116.     Handle            crsrData;
  117.     Handle            crsrXData;
  118.     short            crsrXValid;
  119.     Handle            crsrXHandle;
  120.     Bits16            crsr1Data;
  121.     Bits16            crsrMask;
  122.     Point            crsrHotSpot;
  123.     long            crsrXTable;
  124.     long            crsrID;
  125. } CCrsr, *CCrsrPtr, **CCrsrHandle;
  126.  
  127. typedef struct CIcon{
  128.     PixMap            iconPMap;
  129.     BitMap            iconMask;
  130.     BitMap            iconBMap;
  131.     Handle            iconData;
  132.     short            iconMaskData[1];
  133. } CIcon, *CIconPtr, **CIconHandle;
  134.  
  135. typedef struct GammaTbl{
  136.     short            gVersion;
  137.     short            gType;
  138.     short            gFormulaSize;
  139.     short            gChanCnt;
  140.     short            gDataCnt;
  141.     short            gDataWidth;
  142.     short            gFormulaData[1];
  143. } GammaTbl, *GammaTblPtr, **GammaTblHandle;
  144.  
  145. typedef struct ITab{
  146.     long            iTabSeed;
  147.     short            iTabRes;
  148.     char            iTTable[1];
  149. } ITab, *ITabPtr, **ITabHandle;
  150.  
  151. typedef struct SProcRec{
  152.     struct SProcRec    **nxtSrch;
  153.     ProcPtr            srchProc;
  154. } SProcRec, *SProcPtr, **SProcHndl;
  155.  
  156. typedef struct CProcRec{
  157.     struct CProcRec    **nxtComp;
  158.     ProcPtr            compProc;
  159. } CProcRec, *CProcPtr, **CProcHndl;
  160.  
  161. typedef struct GDevice{
  162.     short            gdRefNum;
  163.     short            gdID;
  164.     short            gdType;
  165.     ITabHandle        gdITable;
  166.     short            gdResPref;
  167.     SProcHndl        gdSearchProc;
  168.     CProcHndl        gdCompProc;
  169.     short            gdFlags;
  170.     PixMapHandle    gdPMap;
  171.     long            gdRefCon;
  172.     struct GDevice    **gdNextGD;
  173.     Rect            gdRect;
  174.     long            gdMode;
  175.     short            gdCCBytes;
  176.     short            gdCCDepth;
  177.     Handle            gdCCXData;
  178.     Handle            gdCCXMask;
  179.     long            gdReserved;
  180. } GDevice, *GDPtr, **GDHandle;
  181.  
  182. typedef struct CQDProcs {
  183.     Ptr                textProc;
  184.     Ptr                lineProc;
  185.     Ptr                rectProc;
  186.     Ptr                rRectProc;
  187.     Ptr                ovalProc;
  188.     Ptr                arcProc;
  189.     Ptr                polyProc;
  190.     Ptr                rgnProc;
  191.     Ptr                bitsProc;
  192.     Ptr                commentProc;
  193.     Ptr                txMeasProc;
  194.     Ptr                getPicProc;
  195.     Ptr                putPicProc;
  196.     Ptr                opcodeProc;            /* fields added to QDProcs */
  197.     Ptr                newProc1;
  198.     Ptr                newProc2;
  199.     Ptr                newProc3;
  200.     Ptr                newProc4;
  201.     Ptr                newProc5;
  202.     Ptr                newProc6;
  203. } CQDProcs,*CQDProcsPtr;
  204.  
  205. typedef struct CGrafPort{
  206.     short            device;
  207.     PixMapHandle    portPixMap;
  208.     short            portVersion;
  209.     Handle            grafVars;
  210.     short            chExtra;
  211.     short            pnLocHFrac;
  212.     Rect            portRect;
  213.     RgnHandle        visRgn;
  214.     RgnHandle        clipRgn;
  215.     PixPatHandle    bkPixPat;
  216.     RGBColor        rgbFgColor;
  217.     RGBColor        rgbBkColor;
  218.     Point            pnLoc;
  219.     Point            pnSize;
  220.     short            pnMode;
  221.     PixPatHandle    pnPixPat;
  222.     PixPatHandle    fillPixPat;
  223.     short            pnVis;
  224.     short            txFont;
  225.     Style            txFace;
  226.     short            txMode;
  227.     short            txSize;
  228.     Fixed            spExtra;
  229.     long            fgColor;
  230.     long            bkColor;
  231.     short            colrBit;
  232.     short            patStretch;
  233.     QDHandle        picSave;
  234.     QDHandle        rgnSave;
  235.     QDHandle        polySave;
  236.     CQDProcsPtr        grafProcs;
  237. } CGrafPort, *CGrafPtr;
  238.  
  239. typedef struct GrafVars{
  240.     RGBColor        rgbOpColor;
  241.     RGBColor        rgbHiliteColor;
  242.     Handle            pmFgColor;
  243.     short            pmFgIndex;
  244.     Handle            pmBkColor;
  245.     short            pmBkIndex;
  246.     short            pmFlags;
  247. } GrafVars;
  248.  
  249.  
  250. typedef short QDErr;
  251.  
  252. typedef struct ReqListRec{
  253.     short            reqLSize;
  254.     short            reqLData[1];
  255. } ReqListRec;
  256.  
  257.  
  258. /*  Palette Manager  */
  259.  
  260.     /* Usage constants */
  261. #define        pmCourteous        0
  262. #define        pmTolerant        2
  263. #define        pmAnimated        4
  264. #define        pmExplicit        8
  265.  
  266.     /* NSetPalette update constants */
  267. #define        pmNoUpdates        0x8000
  268. #define        pmBkUpdates        0xA000
  269. #define        pmFgUpdates        0xC000
  270. #define        pmAllUpdates    0xE000
  271.             
  272. typedef struct ColorInfo{
  273.         RGBColor    ciRGB;
  274.         short        ciUsage;
  275.         short        ciTolerance;
  276.         short        ciFlags;
  277.         long        ciPrivate;
  278. } ColorInfo;
  279.             
  280. typedef struct Palette{
  281.         short            pmEntries;
  282.         GrafPtr            pmWindow;
  283.         short            pmPrivate;
  284.         long            pmDevices;
  285.         long            pmSeeds;
  286.         ColorInfo        pmInfo[1];
  287. } Palette, *PalettePtr, **PaletteHandle;
  288.  
  289.  
  290. /*  Color Picker Package  */
  291.  
  292. #define MaxSmallFract     0x0000FFFFL
  293.  
  294.  
  295. typedef unsigned short SmallFract;    /* Unsigned fraction between 0 and 1         */
  296.                                     
  297.  
  298.  
  299. typedef struct HSVColor {
  300.     SmallFract        hue;
  301.     SmallFract        saturation;
  302.     SmallFract        value;
  303. } HSVColor;
  304.  
  305. typedef struct HSLColor {
  306.     SmallFract        hue;
  307.     SmallFract        saturation;
  308.     SmallFract        lightness;
  309. } HSLColor;
  310.  
  311. typedef struct CMYColor {
  312.     SmallFract        cyan;
  313.     SmallFract        magenta;
  314.     SmallFract        yellow;
  315. } CMYColor;
  316.  
  317.  
  318. /*  error codes  */
  319.  
  320. enum {
  321.     rgnTooBigErr = -500,
  322.     cResErr = -156,
  323.     cDevErr,
  324.     cProtectErr,
  325.     cRangeErr,
  326.     cNoMemErr,
  327.     cTempMemErr,
  328.     cMatchErr,
  329.     updPixMemErr = -125,
  330.     seNoMemErr = -21,
  331.     seInvRequest,
  332.     reRangeErr,
  333.     gdBadDev,
  334.     i2CRangeErr,
  335.     seProtErr,
  336.     seOutOfRange,
  337.     noRoomErr,
  338.     overRun,
  339.     tblAllocErr,
  340.     qAllocErr,
  341.     noColMatch,
  342.     iTabPurgErr
  343. };
  344.  
  345.  
  346. /*  functions returning non-integral values  */
  347. pascal PixMapHandle NewPixMap();
  348. pascal PixPatHandle NewPixPat();
  349. pascal PixPatHandle GetPixPat();
  350. pascal CTabHandle GetCTable();
  351. pascal CCrsrHandle GetCCursor();
  352. pascal CIconHandle GetCIcon();
  353. pascal GDHandle GetMaxDevice();
  354. pascal GDHandle GetDeviceList();
  355. pascal GDHandle GetMainDevice();
  356. pascal GDHandle GetNextDevice();
  357. pascal GDHandle NewGDevice();
  358. pascal GDHandle GetGDevice();
  359. pascal PaletteHandle NewPalette();
  360. pascal PaletteHandle GetNewPalette();
  361. pascal PaletteHandle GetPalette();
  362.  
  363.  
  364. /*  low-memory globals  */
  365. extern char HiliteMode : 0x938;
  366. extern GDHandle MainDevice : 0x8A4;
  367. extern GDHandle DeviceList : 0x8A8;
  368. extern GDHandle TheGDevice : 0xCC8;
  369. extern CGrafPtr WMgrCPort : 0xD2C;
  370.  
  371.  
  372. #endif _Color_