/*  %kw # %v    %n    %d    %t # */
/* Version # 8    METPORTS.H    9-May-94    10:01:38 # */

/* ************************************************************** *
 * METPORTS.H  -  MetaWINDOW 'grafPort' and 'grafMap' Definitions *
 * Copyright (c) 1985-1992 Metagraphics Software Corporation      *
 * ************************************************************** */

/* This is a read only structure ! */
typedef struct _grafMap       /* "grafMap" Data Structure      */
 {
  short        devClass;      /* Device class                  */
  short        devTech;       /* Device technology             */
  long         devMode;       /* Device ID                     */
  short        pixBytes;      /* Bytes per scan line           */
  Word         pixWidth;      /* Pixels horizontal             */
  Word         pixHeight;     /* Pixels vertical               */
  short        pixResX;       /* Pixels per inch horzontally   */
  short        pixResY;       /* Pixels per inch vertically    */
  short        pixBits;       /* Color bits per pixel          */
  short        pixPlanes;     /* Color planes per pixel        */
  short        mapFlags;      /* grafMap flags                 */
  Byte         **mapTable[32];/* Pointers to rowTable(s)       */
  short        mapLock;       /* busy semaphore                */ 
  short        mapNextSel;    /* OS next segment cookie        */ 
  long         mapWinType;    /* Bank window type (0-3)        */
  long         mapWinOffset;  /* Offset to 2nd bank window     */
  long         mapWinYmin[2]; /* Current bank(s) min Y value   */
  long         mapWinYmax[2]; /* Current bank(s) max Y value   */
  long         mapWinPlane;   /* Current bank plane            */
  long         mapWinScans;   /* Scan lines per bank           */
  long         mapHandle;     /* Handle to access device       */
  void      ( *mapBankMgr)(); /* Ptr to bank manager function  */
  void      ( *mapPlaneMgr)();/* Ptr to plane manager function */
  void      ( *mapAltMgr)();  /* Ptr to alt manager function   */
  void      ( *devMgr)();     /* Ptr to device manager list    */       
  long         prFill;        /*  primitive vector for fills              */
  long         prBlitSS;      /*  primitive vector for self-self blits    */
  long         prBlit1S;      /*  primitive vector for mono-self blits    */
  long         prBlitMS;      /*  primitive vector for mem-self  blits    */
  long         prBlitSM;      /*  primitive vector for self-mem  blits    */
  long         prRdImg;       /*  primitive vector for read image         */
  long         prWrImg;       /*  primitive vector for write image        */
  long         prLine;        /*  primitive vector for thin lines         */
  long         prSetPx;       /*  primitive vector for set pixel          */
  long         prGetPx;       /*  primitive vector for get pixel          */
  long         cbSyncFunc;    /*  call back to resync function            */
  long         cbPostErr;     /*  call back to post an error              */
}  grafMap;

                       /* "devTech" definitions              */
#define dtUser    0x0000    /* User Supplied Primitives      */
#define dtMono    0x0001    /* Monochrome                    */
#define dtPlan    0x0003    /* MultiPlane                    */
#define dtEGA     0x0004    /* EGA                           */
#define dtVGA     0x0005    /* VGA                           */
#define dt8514    0x0007    /* IBM 8514                      */
#define dt8Bit    0x0008    /* 8-bit-per-pixel, 256-color    */
#define dt16Bit   0x0009    /* 16-bits per pixel, 64K-color  */

                       /* "mapFlags" definitions             */
#define mfPending 0x0008    /* operation pending on locked grafMap  */
#define mfRowTabl 0x0010    /* Row table(s) - interleaved(0)/linear(1) */
#define mfDspGraf 0x0020    /* Display status - text(0)/graphics(1) */
#define mfDac8    0x0100    /* Supports 8 bit per RGB DAC           */
#define mf565		0x0200	 /* hicolor format 1 = 5:6:5, 0 = 5:5:5  */

/* This is a read only structure ! */
typedef struct _grafPort  /* "grafPort" Data Structure       */
 {
  grafMap      *portMap;     /* Pointer to "grafMap" record  */
  rect         portRect;     /* Local coordinate port bounds */
  point        portOrgn;     /* Global origin of portRect    */
  rect         portVirt;     /* 'Virtual' port bounds        */
  rect         portClip;     /* Local clipping rectangle     */
  region       *portRegion;  /* Pointer to clipping region   */
  patList      *portPat;     /* Pointer to pattern list      */
  long         portMask;     /* Port plane mask              */
  long         portU2GP;    
  long         portU2GR;      
  long         portG2UP;      
  long         portG2UR;      
  short        portFlags;    /* Port flags                   */
  short        bkPat;        /* Background pattern index     */
  long         bkColor;      /* Background color             */
  long         pnColor;      /* Pen color                    */
  point        pnLoc;        /* Pen location                 */
  point        pnSize;       /* Pen size                     */
  short        pnLevel;      /* Pen visibility level         */
  short        pnMode;       /* Pen mode (rasterOp)          */
  short        pnPat;        /* Pen pattern index            */
  short        pnCap;        /* Pen end-cap style            */
  short        pnJoin;       /* Line join style              */
  short        pnMiter;      /* Line join miter limit        */
  short        pnFlags;      /* Current pen flags            */
  short        pnDash;       /* Current dash number          */
  short        pnDashNdx;    /* Current dash sequence index  */
  short        pnDashCnt;    /* Current dash sequence count  */
  dashes       *pnDashRcd;   /* Pointer to dash records      */
  fontRcd      *txFont;      /* Pointer to current text font */
  short        txFace;       /* Text facing flags            */
  short        txMode;       /* Text mode (rasterOp)         */
  short        txUnder;      /* Text underline position      */
  short        txScore;      /* Text underline scoring       */
  short        txPath;       /* Text path                    */
  short        txPat;        /* Text pattern                 */
  point        txAlign;      /* Text alignment               */
  long         txColor;      /* Text color                   */
  point        txSize;       /* Text size  (stroked)         */
  short        txAngle;      /* Text angle (stroked)         */
  short        txSlant;      /* Text slant (stroked)         */
  short        txExtra;      /* Text justify bits            */
  short        txSpace;      /* Space justify bits           */
  short        txBold;           
  short        txTerm;
  fontRcd      *mkFont;      /* Pointer to marker font       */
  short        mkType;       /* Marker type index            */
  short        mkAngle;      /* Marker angle                 */
  point        mkSize;       /* Marker size                  */
  fxdpnt       fxLoc[2];     /* Fixed-point pnLoc            */
  fxdpnt       fxExtra;      /* Fixed-point txExtra          */
  fxdpnt       fxSpace;      /* Fixed-point txSpace          */
  fxdpnt       fxVirt[4];    /* Fixed-point virtual rect     */
  int          spare[8];     /* rsvd                         */
  } grafPort;

typedef struct _pusharea   /* PUSHGRAFIX/POPGRAFIX savearea  */
 {short saveArea[sizeof(grafPort)/sizeof(short)];
 } pusharea;

/* -------------- Defines for grafPort flags --------------- */

/*  grafPort.portFlag" Flag Bit Definitions  */
#define pfUpper    0x0001  /* port origin - lowerleft(0)/upperleft(1)    */
#define pfVirtual  0x0002  /* port coordinates - local(0)/virtual(1)     */
#define pfGblCoord 0x0080  /* port coordinates - port(0)/global(1)       */
#define pfRecClip  0x0100  /* rectangle clipping disabled (0)/enabled(1) */
#define pfRgnClip  0x0200  /* region clippping - disabled(0)/enabled(1)  */
#define pfFillRule 0x1000  /* polygon fill rule - odd-even(0)/winding(1) */

/* "grafPort.pnFlags" Flag Bit Definitions  */
#define pnPattFlg   0x0001  /* pen pattern - solid(0)/patterned(1)        */
#define pnDashFlg   0x0002  /* pen dash style - solid(0)/dashed(1)        */
#define pnShapeFlg  0x0004  /* pen shape - elliptical(0)/rectangular(1)   */ 
#define pnSizeFlg   0x0008  /* pen size - singleWidth(0)/multiWidth(1)    */
#define pnDashStyle 0x0010  /* dash style - onOff(0)/doubleDash(1)        */
#define pnDashState 0x0020  /* dash sequence state - off(0)/on(1)         */

/* Get/SetPenstate are subsets of grafPort data */

#define penState grafPort 

/* End of File - METPORTS.H */
