COMMENT @----------------------------------------------------------------------

	Copyright (c) GeoWorks 1989 -- All Rights Reserved

PROJECT:	PC GEOS
FILE:		graphics.def

DECLARER:	Kernel

DESCRIPTION:
	This file defines graphics structures and routines.

	$Id: graphics.def,v 1.1 97/04/04 14:22:28 newdeal Exp $

------------------------------------------------------------------------------@

SetDef	__GRAPHICS

include fontID.def
include font.def
include color.def

StartKernel

; text:
global GrCharWidth:far
global GrTextWidth:far
global GrTextWidthWBFixed:far
global GrGetTextBounds:far
global GrGetCharInfo:far

; bitmap:
global GrGetBitmap:far
global GrGetPoint:far
global GrCreateBitmap:far
global GrCreateBitmapRaw:far
global GrEditBitmap:far
global GrDestroyBitmap:far
global GrSetBitmapRes:far
global GrGetBitmapRes:far
global GrClearBitmap:far
global GrCompactBitmap:far
global GrUncompactBitmap:far
global GrGetBitmapSize:far
global GrGetHugeBitmapSize:far
global GrDrawHugeBitmap:far
global GrDrawHugeBitmapAtCP:far
global GrFillHugeBitmap:far
global GrFillHugeBitmapAtCP:far
global GrSetBitmapMode:far
global GrGetBitmapMode:far

; region:
global GrDrawRegion:far
global GrDrawRegionAtCP:far
global GrMoveReg:far
global GrGetPtrRegBounds:far
global GrTestPointInReg:far
global GrTestRectInReg:far
global GrTestRectInMask:far
global GrInvalRect:far
global GrInvalRectDWord:far
global GrGetWinBoundsDWord:far
global GrGetMaskBoundsDWord:far
global GrGetWinBounds:far
global GrGetMaskBounds:far
global GrDrawImage:far
global GrDrawHugeImage:far

; math:
global GrMulWWFixed:far
global GrMulWWFixedPtr:far
global GrMulDWFixed:far
global GrMulDWFixedPtr:far
global GrSDivWWFixed:far
global GrUDivWWFixed:far
global GrSqrWWFixed:far
global GrSqrRootWWFixed:far
global GrQuickSine:far
global GrQuickCosine:far
global GrQuickTangent:far
global GrQuickArcSine:far
global GrPolarToCartesian:far
global GrSDivDWFbyWWF:far

;path:
global GrTestPointInPath:far
global GrGetPath:far
global GrTestPath:far
global GrGetPathBounds:far
global GrGetPathBoundsDWord:far
global GrGetPathPoints:far
global GrGetPathRegion:far
global GrGetClipRegion:far

global GrCreateState:far
global GrDestroyState:far
global GrGrabExclusive:far
global GrGetExclusive:far
global GrReleaseExclusive:far
global GrTransformWWFixed:far
global GrUntransformWWFixed:far
global GrTransformDWFixed:far
global GrUntransformDWFixed:far
global GrTransformDWord:far
global GrUntransformDWord:far
global GrBitBlt:far
global GrTransform:far
global GrUntransform:far

global GrTransformByMatrix:far
global GrTransformByMatrixDWord:far
global GrUntransformByMatrix:far
global GrUntransformByMatrixDWord:far


global GrMapColorIndex:far
global GrMapColorRGB:far
global GrGetPalette:far

global GrSetPrivateData:far

global GrGetMixMode:far
global GrGetLineColor:far
global GrGetAreaColor:far
global GrGetTextColor:far
global GrGetLineMask:far
global GrGetAreaMask:far
global GrGetTextMask:far
global GrGetLineColorMap:far
global GrGetAreaColorMap:far
global GrGetTextColorMap:far
global GrGetTextSpacePad:far
global GrGetTextStyle:far
global GrGetTextMode:far
global GrGetTextDrawOffset:far
global GrGetLineWidth:far
global GrGetLineEnd:far
global GrGetLineJoin:far
global GrGetLineStyle:far
global GrGetMiterLimit:far
global GrGetCurPos:far
global GrGetCurPosWWFixed:far
global GrGetInfo:far
global GrGetTransform:far
global GrGetFont:far
global GrGetTrackKern:far
global GrTestPointInPolygon:far
global GrGetWinHandle:far
global GrGetGStringHandle:far

global GrSetVMFile:far

global GrGetFontWeight:far
global GrGetFontWidth:far
global GrGetSuperscriptAttr:far
global GrGetSubscriptAttr:far

global GrGetAreaPattern:far
global GrGetTextPattern:far

global	GrApplyRotation:far
global	GrApplyScale:far
global	GrApplyTranslation:far
global	GrApplyTransform:far
global	GrApplyTranslationDWord:far
global	GrSetTransform:far
global	GrSetNullTransform:far
global	GrSetDefaultTransform:far
global	GrInitDefaultTransform:far
global	GrSaveTransform:far
global	GrRestoreTransform:far
global	GrDrawLine:far
global	GrDrawLineTo:far
global	GrDrawRelLineTo:far
global	GrDrawHLine:far
global	GrDrawHLineTo:far
global	GrDrawVLine:far
global	GrDrawVLineTo:far
global	GrDrawPolyline:far
global	GrDrawArc:far
global	GrDrawArc3Point:far
global	GrDrawArc3PointTo:far
global	GrDrawRelArc3PointTo:far
global	GrDrawRect:far
global	GrDrawRectTo:far
global	GrDrawRoundRect:far
global	GrDrawRoundRectTo:far
global	GrDrawSpline:far
global	GrDrawSplineTo:far
global	GrDrawCurve:far
global	GrDrawCurveTo:far
global	GrDrawRelCurveTo:far
global	GrDrawEllipse:far
global	GrDrawPolygon:far
global	GrDrawPoint:far
global	GrDrawPointAtCP:far
global	GrBrushPolyline:far
global	GrDrawChar:far
global	GrDrawCharAtCP:far
global	GrDrawText:far
global	GrDrawTextAtCP:far
global	GrDrawTextField:far
global	GrDrawPath:far
global	GrFillRect:far
global	GrFillRectTo:far
global	GrFillRoundRect:far
global	GrFillRoundRectTo:far
global	GrFillArc:far
global	GrFillPolygon:far
global	GrFillEllipse:far
global	GrFillPath:far
global	GrFillArc3Point:far
global	GrFillArc3PointTo:far
global	GrFillBitmap:far
global	GrFillBitmapAtCP:far
global	GrDrawBitmap:far
global	GrDrawBitmapAtCP:far
global	GrSaveState:far
global	GrRestoreState:far
global	GrSetMixMode:far
global	GrMoveTo:far
global	GrMoveToWWFixed:far
global	GrRelMoveTo:far
global	GrCreatePalette:far
global	GrDestroyPalette:far
global	GrSetPaletteEntry:far
global	GrSetPalette:far
global	GrSetLineColor:far
global	GrSetLineMask:far
global	GrSetLineColorMap:far
global	GrSetLineWidth:far
global	GrSetLineJoin:far
global	GrSetLineEnd:far
global	GrSetLineAttr:far
global	GrSetMiterLimit:far
global	GrSetLineStyle:far
global	GrSetAreaColor:far
global	GrSetAreaMask:far
global	GrSetAreaColorMap:far
global	GrSetAreaAttr:far
global	GrSetAreaPattern:far
global	GrSetCustomAreaPattern:far
global	GrSetTextColor:far
global	GrSetTextMask:far
global	GrSetTextColorMap:far
global	GrSetTextStyle:far
global	GrSetTextMode:far
global	GrSetTextDrawOffset:far
global	GrSetTextSpacePad:far
global	GrSetTextAttr:far
global	GrSetFont:far
global	GrSetTrackKern:far
global	GrSetFontWeight:far
global	GrSetFontWidth:far
global	GrSetSuperscriptAttr:far
global	GrSetSubscriptAttr:far
global	GrSetTextPattern:far
global	GrSetCustomTextPattern:far
global	GrBeginPath:far
global	GrEndPath:far
global	GrSetClipRect:far
global	GrSetWinClipRect:far
global	GrCloseSubPath:far
global	GrSetClipPath:far
global	GrSetWinClipPath:far
global	GrSetStrokePath:far

;--------------------------------------------------------------------------
;			Maximum allowed values
;--------------------------------------------------------------------------

;	Range of allowable track kerning values (sword)

MIN_TRACK_KERNING	= -150
MAX_TRACK_KERNING	= 500

;	Range of allowable scaled track kern values (BBFixed)

MAX_KERN_VALUE		= 0x7ff0
MIN_KERN_VALUE		= 0x8001

;--------------------------------------------------------------------------
;		Constants and structures for justification
;--------------------------------------------------------------------------

Justification 	etype byte
J_LEFT 		enum Justification
J_RIGHT 	enum Justification
J_CENTER 	enum Justification
J_FULL 		enum Justification

;	structure for a draw mask -- the default mask has all bits set

DrawMask	type	8 dup (byte)

;	constants for system patterns and draw masks

SystemDrawMask 	etype byte

SDM_TILE	enum SystemDrawMask		; tile pattern
SDM_SHADED_BAR	enum SystemDrawMask		; shaded bar 
SDM_HORIZONTAL	enum SystemDrawMask		; horiz lines
SDM_VERTICAL	enum SystemDrawMask		; vertical lines
SDM_DIAG_NE	enum SystemDrawMask		; diagonal lines going up to NorthEast
SDM_DIAG_NW	enum SystemDrawMask		; diagonal lines going up to NorthWest
SDM_GRID	enum SystemDrawMask		; checkerboard
SDM_BIG_GRID	enum SystemDrawMask		; larger checkerboard
SDM_BRICK	enum SystemDrawMask		; brick wall
SDM_SLANT_BRICK enum SystemDrawMask		; slanted brick wall

SDM_0		enum SystemDrawMask, 89	; all zeroes
SDM_12_5	enum SystemDrawMask, 81	; 
SDM_25		enum SystemDrawMask, 73	; 
SDM_37_5	enum SystemDrawMask, 65	;
SDM_50		enum SystemDrawMask, 57	; 
SDM_62_5	enum SystemDrawMask, 49	; 
SDM_75		enum SystemDrawMask, 41	; 
SDM_87_5	enum SystemDrawMask, 33	; 
SDM_100	enum SystemDrawMask, 25	; all ones

SDM_CUSTOM	enum SystemDrawMask, 0x7f	; setting a custom mask
SET_CUSTOM_PATTERN	=	SDM_CUSTOM

; 	record to pass to GrSetXXXXMask

SysDrawMask	record	
	SDM_INVERSE:1		; bit 7: 0 for mask as is
				;	 1 for inverse of mask
	SDM_MASK SystemDrawMask:7	; bits 6-0: draw mask number
				;	    0x7f to set custom mask
SysDrawMask	end

;	enum to pass to GrGetXXXXMask routines

GetMaskType	etype	byte
GMT_ENUM	enum	GetMaskType
GMT_BUFFER	enum	GetMaskType

;--------------------------------------------------------------------------
;		Bitmap / Raster Constants and Structures
;--------------------------------------------------------------------------

; ImageBitSize
; Size of each resulting image bit, in pixels.
ImageBitSize	etype	byte
IBS_1		enum	ImageBitSize		;  1 to 1 mapping
IBS_2		enum	ImageBitSize		;  2 x  2 pixels
IBS_4		enum	ImageBitSize		;  4 x  4 pixels
IBS_8		enum	ImageBitSize		;  8 x  8 pixels
IBS_16		enum	ImageBitSize		; 16 x 16 pixels

; ImageFlags
; This record is passed to the routine GrDrawImage
;
ImageFlags	record
    IF_DRAW_IMAGE:1,		; reserved for internal use (set to zero)
    IF_HUGE:1,			; reserved for internal use (set to zero)
    :1,
    IF_IGNORE_MASK:1		; set to draw all pixels, regardless of mask
    IF_BORDER:1,		; set if border desired around each pixel
    IF_BITSIZE ImageBitSize:3	; size of each pixel
ImageFlags	end


;	bitblt flags

BLTMode 	etype word
BLTM_COPY 	enum BLTMode		; 0 = copy image
BLTM_MOVE 	enum BLTMode		; 1 = move image
BLTM_CLEAR 	enum BLTMode		; 2 = clear source rect

	; this record is passed to GrSetBitmapMode
	; If the EDIT_MASK bit is set, then all subsequent graphics drawing
	;  operations will affect the MASK data instead of the actual bitmap
	;  picture data.
	; If the CLUSTERED_DITHER bit is set, then grey-scale simulation on
	;  monochrome bitmaps will use a clustered dither instead of a 
	;  dispersed dither.  This is most useful for bitmaps being prepared
	;  by the spooler for printing.
BitmapMode	record	
    :14,				; to make it a word
    BM_EDIT_MASK:1,			; if set, mask is edited
    BM_CLUSTERED_DITHER:1		; if set, uses a clustered dither
					;  instead of a dispersed dither
					;  (only works for BMF_MONO bitmaps)
BitmapMode	end

	; This enum is passed to GrDestroyBitmap
BMDestroy	etype  byte
BMD_KILL_DATA	enum BMDestroy		; 0 = free bitmap (HugeArray)
BMD_LEAVE_DATA	enum BMDestroy		; 1 = leave bitmap data alone


;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;	Enum for B_compact
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
				
BMCompact 	etype byte
BMC_UNCOMPACTED 	enum BMCompact		;  0 = no compaction
BMC_PACKBITS 	enum BMCompact		;  1 = Mac packbits
BMC_LZG		enum BMCompact		;  2 = LZG compression

BMC_USER_DEFINED  enum BMCompact, 0x80	;  >0x80 = user defined compaction

;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;	Enum for BMT_FORMAT
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;
;	There are 4 bitmap formats supported under pcgeos, plus a CMYK format
;	that is used for color printing:
;
;		enum 		#planes	#bits/pixel/plane
;		----		-------	-----------------
;		BMF_MONO: 	   1		1
;		BMF_4BIT: 	   1		4
;		BMF_8BIT: 	   1		8
;		BMF_24BIT: 	   1		24
;
;		BMF_4CMYK: 	   4		1
;		BMF_3CMY: 	   3		1
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

BMFormat	etype byte, 0
BMF_MONO	enum BMFormat		; 0 = monochrome
BMF_4BIT	enum BMFormat		; 1 = 4-bit (EGA,VGA)
BMF_8BIT	enum BMFormat		; 2 = 8-bit (MCGA,SVGA)
BMF_24BIT	enum BMFormat		; 3 = 24-bit (high end cards)
BMF_4CMYK	enum BMFormat		; 4 = 4-bit CMYK (printers)
BMF_3CMY	enum BMFormat		; 5 = 3-bit CMY (printers)

;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;	Record for B_type
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

BMType		record
	BMT_PALETTE:1 		;   bit 6: 0 no palette stored with bitmap
				;	   1 palette supplied 
				;          (this bit ignored if BMT_COMPLEX=0)
	BMT_HUGE:1 		;   bit 5: 0 normal bitmap (one block)
				;	   1 bitmap stored in a HugeArray
	BMT_MASK:1 		;   bit 4: 0 for no mask stored
				;	   1 for mask stored along
				;	     with bitmap data
	BMT_COMPLEX:1 		;   bit 3: 0 for simple bitmaps
				;          1 for complex bitmaps
	BMT_FORMAT BMFormat:3	;   enum for bitmap format type (see above)
BMType		end

;TEMPORARY EQUATES FOR NAME_CHANGES - brianc 4/13/92
BMTypeOld	record
	BM_PALETTE:1
	BM_HUGE:1
	BM_MASK:1
	BM_COMPLEX:1
	BM_FORMAT BMFormat:3
BMTypeOld	end

;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;	Simple Bitmap Structure
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Bitmap	struct
    B_width		word			   ; width of bitmap, pixels
    B_height		word			   ; height of bitmap, pixels
    B_compact		BMCompact BMC_UNCOMPACTED	   ; method of compaction 
    B_type		BMType	<0,0,0,0,BMF_MONO> ; bitmap type:
Bitmap	ends

;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;	Complex Bitmap Structure
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CBitmap	struct
    CB_simple		Bitmap <> 		; simple bitmap structure
    CB_startScan		word	0		; starting row number
    CB_numScans		word	1		; # scans of data in this slice

    ; the following three offsets are offsets from the start of the bitmap
    ; structure

    CB_devInfo		word	0		; offset to device info
    CB_data		word	(size CBitmap)	; offset to start of data
    CB_palette		word	0		; offset to color table
						;  (if bit 6 set in B_type)
    CB_xres		word	72		; x resolution (DPI)
    CB_yres		word	72		; y resolution (DPI)
CBitmap	ends

;-----------------------------------------------------------------------------
;			Types for GrGetInfo
;-----------------------------------------------------------------------------

GrInfoType 		etype word, 0, 2
GIT_PRIVATE_DATA 	enum GrInfoType
GIT_WINDOW 		enum GrInfoType


;-----------------------------------------------------------------------------
;		Misc
;-----------------------------------------------------------------------------

PATTERN_SIZE	=	8		; size of pattern in bytes

;	different values for GS_mixMode

MixMode 	etype byte
MM_CLEAR 	enum MixMode	; dest <- 0
MM_COPY 	enum MixMode	; dest <- src
MM_NOP 	enum MixMode	; dest <- dest
MM_AND 	enum MixMode	; dest <- src AND dest
MM_INVERT 	enum MixMode	; dest <- NOT dest
MM_XOR 	enum MixMode	; dest <- src XOR dest
MM_SET 	enum MixMode	; dest <- 1
MM_OR 	enum MixMode	; dest <- src OR dest

LAST_MIX_MODE	=	MM_OR		; last legal draw mode

;	different values for color mapping modes

ColorMapType 		etype byte
CMT_CLOSEST 	enum ColorMapType	; Map to closest solid color
CMT_DITHER 	enum ColorMapType	; Map to dither pattern

;	The window record WinColorFlags assumes that ColorMapMode only uses
;	three bits.
;
;	The VisText object uses the high bit of ColorMapMode, passing the
;	low seven bits opaquely.

ColorMapMode	record 
    CMM_ON_BLACK:1,		; 1 if drawing on black
    :1,				; (used to be part of CMM_MAP_TYPE)
    CMM_MAP_TYPE ColorMapType:1	; color mapping mode
ColorMapMode	end

LAST_MAP_MODE	=	mask CMM_MAP_TYPE or mask CMM_ON_BLACK ; last legal value

;	options for line style

LineStyle 	etype byte
LS_SOLID 	enum LineStyle	; ___________	(solid)
LS_DASHED 	enum LineStyle	; _ _ _ _ _ _	(dashed)
LS_DOTTED 	enum LineStyle	; . . . . . .	(dotted)
LS_DASHDOT 	enum LineStyle	; _ . _ . _ . 	(dash-dot)
LS_DASHDDOT 	enum LineStyle	; _ . . _ . .	(dash-doub-dot)
LS_CUSTOM 	enum LineStyle

MAX_DASH_ARRAY_PAIRS = 5		;each element byte, each pair a word

;	structure for a dash pair array

DashPairArray type (MAX_DASH_ARRAY_PAIRS*2) dup (word)

;	constants for line join

LineJoin 	etype byte
LJ_MITERED 	enum LineJoin	; miter join
LJ_ROUND 	enum LineJoin	; round join
LJ_BEVELED 	enum LineJoin	; beveled join

LAST_LINE_JOIN_TYPE	=	LJ_BEVELED

;	constants for line end

LineEnd 	etype byte
LE_BUTTCAP 	enum LineEnd	; but cap
LE_ROUNDCAP 	enum LineEnd	; round cap
LE_SQUARECAP 	enum LineEnd	; square cap

LAST_LINE_END_TYPE	=	LE_SQUARECAP

;	values for GS_textStyle
; 	do not rearrange!

TextStyle	record
	:1			; NOTE:if this bit ever used, need to change 
				; code in GrSetTextStyle !
	TS_OUTLINE:1		
	TS_BOLD:1
	TS_ITALIC:1
	TS_SUPERSCRIPT:1
	TS_SUBSCRIPT:1
	TS_STRIKE_THRU:1
	TS_UNDERLINE:1
TextStyle	end

;	values for GS_textMode

TextMode	record
	TM_DRAW_CONTROL_CHARS:1	; Does the following mapping when drawing
				; text:
				;   C_SPACE	  -> C_CNTR_DOT
				;   C_NONBRKSPACE -> C_CNTR_DOT
				;   C_CR	  -> C_PARAGRAPH
				;   C_TAB	  -> C_LOGICAL_NOT
				;

	TM_TRACK_KERN:1		;internal only - not settable
	TM_PAIR_KERN:1		;internal only - not settable
	TM_PAD_SPACES:1		;internal only - not settable
	TM_DRAW_BASE:1
	TM_DRAW_BOTTOM:1
	TM_DRAW_ACCENT:1
	TM_DRAW_OPTIONAL_HYPHENS:1
TextMode	end

if DBCS_PCGEOS


if DBCS_PCGEOS
TextMiscModeFlags	record
	TMMF_CHARACTER_JUSTIFICATION:1	;TRUE: char just. ; FALSE: word just.
	:7			;pad to BYTE only
TextMiscModeFlags	end
endif

endif

;
; return value for GrGetCharInfo
;
CharInfo	record
	:1				;pad to a BYTE only
	CI_NEGATIVE_LSB:1		;TRUE if negative left-side bearing
	CI_ABOVE_ASCENT:1		;TRUE if very tall
	CI_BELOW_DESCENT:1		;TRUE if very low
	CI_NO_DATA:1			;TRUE if no data
	CI_IS_FIRST_KERN:1		;TRUE if first of a kern pair
	CI_IS_SECOND_KERN:1		;TRUE if second of a kern pair
	:1				;pad to a BYTE only
CharInfo	end

;------------------------------------------------------------------------------
;		Region Constants
;------------------------------------------------------------------------------

;	structure definition used for regions

Region	struct
    R_data	word
Region	ends

EOREGREC	=	8000h			; end of region record value
EOREG_HIGH	=	0x80			; high byte of EOREGREC

;	Return values from GrTestRectInReg

TestRectReturnType 	etype byte
TRRT_OUT		enum TestRectReturnType
TRRT_PARTIAL		enum TestRectReturnType
TRRT_IN		enum TestRectReturnType

;	structure of a rectangular region

RectRegion	struct
    RR_y1M1		word
    RR_eo1		word	EOREGREC
    RR_y2		word
    RR_x1		word
    RR_x2		word
    RR_eo2		word	EOREGREC
    RR_eo3		word	EOREGREC
RectRegion	ends

;	macro for creating rectangular regions

MakeRectRegion	macro	left, top, right, bottom
	word	left, top, right, bottom		;bounds
	word	(top)-1,                    EOREGREC
	word	bottom,   left, right,      EOREGREC
	word	EOREGREC
endm

;-----

;	standard structure for an X,Y pair

Point	struct
    P_x		sword
    P_y		sword
Point	ends

PointWWFixed	struct
    PF_x	WWFixed
    PF_y	WWFixed
PointWWFixed	ends

PointWBFixed	struct
    PWBF_x	WBFixed
    PWBF_y	WBFixed
PointWBFixed	ends

PointDWFixed	struct
    PDF_x	DWFixed
    PDF_y	DWFixed
PointDWFixed	ends

PointDWord	struct
    PD_x	sdword
    PD_y	sdword
PointDWord	ends

XYOffset	struct
    XYO_x	sword
    XYO_y	sword
XYOffset	ends

XYSize		struct
    XYS_width	word
    XYS_height	word
XYSize		ends


;	standard structure for a rectangle

Rectangle	struct
    R_left	sword
    R_top	sword
    R_right	sword
    R_bottom	sword
Rectangle	ends

;	standard structure for a rectangle in extended coords

RectDWord 	struct
    RD_left	sdword
    RD_top	sdword
    RD_right	sdword
    RD_bottom	sdword
RectDWord	ends

;	constants for region fill rule
				
RegionFillRule 		etype	byte
    RFR_ODD_EVEN 	enum	RegionFillRule	; 0 = odd-even rule
    RFR_WINDING 	enum	RegionFillRule	; 1 = winding rule

;	constants for GrNewPage

PageEndCommand		etype	byte
    PEC_FORM_FEED	enum	PageEndCommand	; 0 = form feed
    PEC_NO_FORM_FEED	enum	PageEndCommand	; 1 = no form feed

;	Constants for GrDrawRegion

; 0000-3fff -> positive coordinate
; 4000-5fff - PARAM_0 + coordinate
;	4000-4fff - PARAM_0 + negative coordinate
;	5000-5fff - PARAM_0 + positive coordinate
; 6000-7fff -
;	6000-6fff - PARAM_1 + negative coordinate
;	7000-7fff - PARAM_1 + positive coordinate
; 8000-9fff -
;	8000-8fff - PARAM_2 + negative coordinate
;	9000-9fff - PARAM_2 + positive coordinate
; a000-bfff -
;	a000-afff - PARAM_3 + negative coordinate
;	b000-bfff - PARAM_3 + positive coordinate
; c000-ffff -> negative coordinate

PARAM_0		=	05000h
PARAM_1		=	07000h
PARAM_2		=	09000h
PARAM_3		=	0b000h


; Flags to pass to path operation when combining Paths (& clip rectangles)
;
PathCombineType	etype word
	PCT_NULL		enum PathCombineType	; destroy current
	PCT_REPLACE		enum PathCombineType	; replace current
	PCT_UNION		enum PathCombineType	; add to current
	PCT_INTERSECTION	enum PathCombineType	; intersect with curr

; GetPathType
; Use this with GrGetPath to determine which path to get
GetPathType	etype	word
	GPT_CURRENT		enum GetPathType	; current path
	GPT_CLIP		enum GetPathType	; clip path
	GPT_WIN_CLIP		enum GetPathType	; win clip path

;--------------------------------------------------------------------------
;		Structure passed to arc routines
;--------------------------------------------------------------------------

ArcCloseType	etype	word
    ACT_OPEN	enum	ArcCloseType		; illegal for filled arcs
    ACT_CHORD	enum	ArcCloseType		; draw/fill as a chord
    ACT_PIE	enum	ArcCloseType		; draw/fill as a pie

ArcParams	struct
    AP_close	ArcCloseType			; how the arc should be closed
    AP_left	sword				; ellipse bounding box: left
    AP_top	sword				;                       top
    AP_right	sword				;                       right
    AP_bottom	sword				;                       bottom
    AP_angle1	sword				; start angle for arc
    AP_angle2	sword				; ending angle for arc
ArcParams	ends

ThreePointArcParams	struct
    TPAP_close	ArcCloseType			; how the arc should be closed
    TPAP_point1	PointWWFixed			; Point #1 (start of arc)
    TPAP_point2	PointWWFixed			; Point #2 (somewhere on arc)
    TPAP_point3	PointWWFixed			; Point #3 (end of arc)
ThreePointArcParams	ends

ThreePointArcToParams	struct
    TPATP_close	ArcCloseType			; how the arc should be closed
    TPATP_point2 PointWWFixed			; Point #2 (somewhere on arc)
    TPATP_point3 PointWWFixed			; Point #3 (end of arc)
ThreePointArcToParams	ends

ThreePointRelArcToParams	struct
    TPRATP_close ArcCloseType			; how the arc should be closed
    TPRATP_delta2 PointWWFixed			; delta to Point #2 
    TPRATP_delta3 PointWWFixed			; delta to Point #3 
ThreePointRelArcToParams	ends


;-----------------------------------------------------------------------------
;			System Patterns
;-----------------------------------------------------------------------------

; Types of patterns available in the graphic system

PatternType		etype	byte
    PT_SOLID		enum	PatternType	; solid pattern
						; Passed in AH: Nothing
    PT_SYSTEM_HATCH	enum	PatternType	; system-defined hatch pattern
						; Passed in AH: SystemHatch
    PT_SYSTEM_BITMAP	enum	PatternType	; system-defined tiled bitmap
						; Passed in AH: SystemBitmap
    PT_USER_HATCH	enum	PatternType	; user-defined hatch pattern
						; Passed in AH: 0-255
    PT_USER_BITMAP	enum	PatternType	; user-defined tiled bitmap
						; Passed in AH: 0-255
    PT_CUSTOM_HATCH	enum	PatternType	; appl-custom hatch pattern
						; Passed in AH: Nothing
    PT_CUSTOM_BITMAP	enum	PatternType	; appl-custom tiled bitmap
						; Passed in AH: Nothing

; Hatch patterns defined by the system

SystemHatch		etype	byte	
    SH_VERTICAL		enum	SystemHatch	; vertical lines
    SH_HORIZONTAL	enum	SystemHatch	; horizontal lines
    SH_45_DEGREE	enum	SystemHatch	; lines at 45 degrees
    SH_135_DEGREE	enum	SystemHatch	; lines at 135 degrees
    SH_BRICK		enum	SystemHatch	; basic brick
    SH_SLANTED_BRICK	enum	SystemHatch	; basic brick, slanted

; Bitmap patterns defined by the system

SystemBitmap		etype	byte

; Structure for storing a hatch pattern

GraphicPattern	struct
    GP_type	PatternType			; pattern type, who defined it
    GP_data	byte				; associated data
GraphicPattern	ends


;-----------------------------------------------------------------------------
;			Hatch Patterns
;-----------------------------------------------------------------------------

; A HatchPattern is comprised of one or more HatchLine structures, which
; in turn may contain 0 or more HatchDash structures.
;
HatchDash		struct
    HD_on		WWFixed		; length of dash to be drawn
    HD_off		WWFixed		; space to skip until next dash
HatchDash		ends

HatchLine		struct
    HL_origin		PointWWFixed	; origin of line
    HL_deltaX		WWFixed		; X offset to next line
    HL_deltaY		WWFixed		; Y offset to next line
    HL_angle		WWFixed		; angle at which line is to be drawn
    HL_color		ColorQuad	; color of line
    HL_numDashes	word		; number of dash pairs
    HL_dashData		label HatchDash	; array of pairs of on/off lengths
HatchLine		ends

HatchPattern		struct
    HP_numLines		word		; number of line records in this pattern
    HP_lineData		label HatchLine	; array of 1 or more hatch lines
HatchPattern		ends

MakeHatch	macro	name, numLines, inChunk
		if	(inChunk)
			name		chunk	HatchPattern
			HatchPattern	<numLines>
		else
			name		HatchPattern <numLines>
		endif
		_inChunk		= inChunk
endm

EndHatch	macro	name
		if	(_inChunk)
			name		endc
		else
			name&Size	equ $ - (offset name)
		endif
endm

MakeHatchLine	macro	originX, originY, deltaX, deltaY, angle, color, dashes
		WWFix		originX
		WWFix		originY
		WWFix		deltaX
		WWFix		deltaY
		WWFix		angle
		ColorQuad	<color>
		word		dashes
endm

MakeHatchDash	macro	on, off
		WWFix		on
		WWFix		off
endm

MAX_CUSTOM_PATTERN_SIZE		equ 16384	; maximum custom pattern size

;--------------------------------------------------------------------------
;		Structure passed to transformation matrix routines
;--------------------------------------------------------------------------

; This structure defines a 3x3 transformation matrix.  Since only six of the
; nine elements are actually used, the structure only has six elements.
;
;		e11	e12	0
;		e21	e22	0
;		e31	e32	1

TransMatrix	struct
    TM_e11	WWFixed	<0, 1>
    TM_e12	WWFixed	<0, 0>
    TM_e21	WWFixed	<0, 0>
    TM_e22	WWFixed	<0, 1>
    TM_e31	DWFixed	<0, 0>
    TM_e32	DWFixed	<0, 0>
TransMatrix	ends

;--------------------------------------------------------------------------
;		Structure used for GrSetAreaAttr
;--------------------------------------------------------------------------

AreaAttr	struct
    AA_colorFlag	ColorFlag CF_INDEX	; RGB or INDEX
    AA_color		RGBValue <0,0,0>	; RGB values or index
    AA_mask		SystemDrawMask		; draw mask
    AA_mapMode		ColorMapMode 		; color map mode
AreaAttr	ends

;--------------------------------------------------------------------------
;		Structure used for GrSetLineAttr
;--------------------------------------------------------------------------

LineAttr	struct
    LA_colorFlag	ColorFlag CF_INDEX	; RGB or INDEX
    LA_color		RGBValue <0,0,0>	; RGB values or index
    LA_mask		SystemDrawMask		; draw mask
    LA_mapMode		ColorMapMode 		; color map mode
    LA_end		LineEnd			; end type
    LA_join		LineJoin		; join type
    LA_style		LineStyle		; style type
    LA_width		WWFixed			; line width
LineAttr	ends

;--------------------------------------------------------------------------
;		Structure used for GrSetTextAttr and GrDrawTextField
;--------------------------------------------------------------------------

TextAttr	struct
    TA_color		ColorQuad		; RGB values or index
    TA_mask		SystemDrawMask		; draw mask
    TA_pattern		GraphicPattern		; pattern
    TA_styleSet		TextStyle		; text style bits to set
    TA_styleClear	TextStyle		; text style bits to clear
    TA_modeSet		TextMode		; text mode bits to set
    TA_modeClear	TextMode		; text mode bits to clear
    TA_spacePad		WBFixed			; space padding
    TA_font		FontID 			; typeface
    TA_size		WBFixed			; point size
    TA_trackKern	sword			; track kerning
    TA_fontWeight	FontWeight		; weight of font
    TA_fontWidth	FontWidth		; width of font
    align	word
TextAttr	ends

; Constants defining the largest positive and negative coordinates
; available to the graphics system.
;
LARGEST_POSITIVE_COORDINATE	= 0x4000
LARGEST_NEGATIVE_COORDINATE	= 0xffffc000

MAX_COORD	= LARGEST_POSITIVE_COORDINATE
MIN_COORD	= LARGEST_NEGATIVE_COORDINATE

MAX_COORD_DWORD	equ	0x7fffffff
MIN_COORD_DWORD equ	0x80000000

COMMENT @------------------------------------------------------------------

		Pointer Picture Definition Structure

	The picture data for the pointer is organized as two buffers
	that immediately follow the PointerDef structure.  The first buffer
	is the mask, the second buffer is the image.  Each buffer is 
	organized in scan line order, left to right and top to bottom.  
	The bits in the mask and image combine with the existing screen 
	contents in the following way:

		mask	image	->	screen
		pixel	pixel		pixel
		-----	-----		------
		  0	  0		unchanged
		  0	  1		xor
		  1	  0		black
		  1	  1		white

--------------------------------------------------------------------------@

STANDARD_CURSOR_IMAGE_SIZE =	32	; # bytes to hold the image

PointerDefWidth	record
	PDW_ALWAYS_SHOW_PTR:1
	; flag, set in BUSY cursors & any other cursors that should be shown
	; for status's sake, regardless of whether the ptr image is normally
	; hidden or not (such as in keyboard-only or ink-only systems).  
	; Interpreted, implemented by Input Manager -- Video drivers should
	; ignore.	-- Doug 3/9/93

	PDW_WIDTH:7
	; width of cursor
PointerDefWidth	end

PointerDef	struct
    PD_width	PointerDefWidth	; flag, width of cursor
    PD_height	byte		; height of cursor
    PD_hotX	sbyte		; offset to hot spot from upper left
    PD_hotY	sbyte		; offset to hot spot from upper left
PointerDef	ends

;----------------------

; C Interface routines

global GRDRAWTEXT:far
global GRDRAWTEXTATCP:far
global GRFILLRECT:far
global GRFILLRECTTO:far
global GRDRAWRECTTO:far
global GRENUMFONTS:far
global GRCHECKFONTAVAILID:far
global GRCHECKFONTAVAILNAME:far
global GRFINTNEARESTPOINTSIZE:far
global GRGETDEFFONTID:far
global GRGETBITMAP:far
global GRCREATEBITMAP:far
global GRCREATEBITMAPRAW:far
global GRDESTROYBITMAP:far
global GRSETBITMAPRES:far
global GRGETBITMAPRES:far
global GRCLEARBITMAP:far
global GRGETBITMAPSIZE:far
global GRGETHUGEBITMAPSIZE:far
global GRMOVEREG:far
global GRGETPTRREGBOUNDS:far
global GRTESTPOINTINREG:far
global GRTESTRECTINREG:far
global GRSQRROOTWWFIXED:far
global GRQUICKSINE:far
global GRQUICKCOSINE:far
global GRQUICKTANGENT:far
global GRQUICKARCSINE:far
global GRGRABEXCLUSIVE:far
global GRGETEXCLUSIVE:far
global GRRELEASEEXCLUSIVE:far
global GRTRANSFORMWWFIXED:far
global GRTRANSFORMDWFIXED:far
global GRUNTRANSFORMWWFIXED:far
global GRUNTRANSFORMDWFIXED:far
global GRBITBLT:far
global GRTRANSFORM:far
global GRTRANSFORMDWORD:far
global GRUNTRANSFORM:far
global GRUNTRANSFORMDWORD:far
global GRMAPCOLORINDEX:far
global GRMAPCOLORRGB:far
global GRGETPALETTE:far
global GRSETPRIVATEDATA:far
global GRGETMIXMODE:far
global GRGETLINECOLOR:far
global GRGETAREACOLOR:far
global GRGETTEXTCOLOR:far
global GRGETLINEMASK:far
global GRGETAREAMASK:far
global GRGETTEXTMASK:far
global GRGETLINECOLORMAP:far
global GRGETAREACOLORMAP:far
global GRGETTEXTCOLORMAP:far
global GRGETTEXTSPACEPAD:far
global GRGETTEXTSTYLE:far
global GRGETTEXTMODE:far
global GRGETTEXTDRAWOFFSET:far
global GRGETLINEWIDTH:far
global GRGETLINEEND:far
global GRGETLINEJOIN:far
global GRGETLINESTYLE:far
global GRGETMITERLIMIT:far
global GRGETCURPOS:far
global GRGETCURPOSWWFIXED:far
global GRGETINFO:far
global GRGETTRANSFORM:far
global GRGETFONT:far
global GRTESTPOINTINPOLYGON:far
global GRAPPLYROTATION:far
global GRAPPLYSCALE:far
global GRAPPLYTRANSLATION:far
global GRAPPLYTRANSLATIONDWORD:far
global GRSETTRANSFORM:far
global GRAPPLYTRANSFORM:far
global GRSAVETRANSFORM:far
global GRRESTORETRANSFORM:far
global GRSETNULLTRANSFORM:far
global GRDRAWROUNDRECT:far
global GRDRAWROUNDRECTTO:far
global GRDRAWPOINT:far
global GRDRAWPOINTATCP:far
global GRDRAWCHAR:far
global GRDRAWCHARATCP:far
global GRDRAWPOLYLINE:far
global GRDRAWELLIPSE:far
global GRDRAWARC:far
global GRDRAWARC3POINT:far
global GRDRAWARC3POINTTO:far
global GRDRAWRELARC3POINTTO:far
global GRDRAWSPLINE:far
global GRDRAWSPLINETO:far
global GRDRAWCURVE:far
global GRDRAWCURVETO:far
global GRDRAWPOLYGON:far
global GRFILLROUNDRECT:far
global GRFILLROUNDRECTTO:far
global GRFILLARC:far
global GRFILLARC3POINT:far
global GRFILLARC3POINTTO:far
global GRFILLRELARC3POINTTO:far
global GRFILLPOLYGON:far
global GRFILLELLIPSE:far
global GRSETLINEATTR:far
global GRSETAREAATTR:far
global GRCREATEPALETTE:far
global GRDESTROYPALETTE:far
global GRSETPALETTEENTRY:far
global GRSETPALETTE:far
global GRSETTRACKKERN:far
global GRINITDEFAULTTRANSFORM:far
global GRSETDEFAULTTRANSFORM:far
global GRCHARMETRICS:far
global GRFONTMETRICS:far
global GRCHARWIDTH:far
global GRTEXTWIDTH:far
global GRTEXTWIDTHWWFIXED:far
global GRDRAWREGION:far
global GRDRAWREGIONATCP:far
global GRMULWWFIXED:far
global GRMULDWFIXED:far
global GRSDIVWWFIXED:far
global GRUDIVWWFIXED:far
global GRSDIVDWFBYWWF:far
global GRCREATESTATE:far
global GRDESTROYSTATE:far
global GRSAVESTATE:far
global GRRESTORESTATE:far
global GRDRAWLINE:far
global GRDRAWLINETO:far
global GRDRAWHLINE:far
global GRDRAWHLINETO:far
global GRDRAWVLINE:far
global GRDRAWVLINETO:far
global GRDRAWBITMAP:far
global GRDRAWBITMAPATCP:far
global GRSETMIXMODE:far
global GRRELMOVETO:far
global GRDRAWRELLINETO:far
global GRMOVETO:far
global GRMOVETOWWFIXED:far
global GRSETLINECOLOR:far
global GRSETLINEMASKSYS:far
global GRSETLINEMASKCUSTOM:far
global GRSETLINECOLORMAP:far
global GRSETLINEWIDTH:far
global GRSETLINEJOIN:far
global GRSETLINEEND:far
global GRSETMITERLIMIT:far
global GRSETLINESTYLE:far
global GRSETAREACOLOR:far
global GRSETAREAMASKSYS:far
global GRSETAREAMASKCUSTOM:far
global GRSETAREACOLORMAP:far
global GRSETTEXTCOLOR:far
global GRSETTEXTMASKSYS:far
global GRSETTEXTMASKCUSTOM:far
global GRSETTEXTCOLORMAP:far
global GRSETTEXTSTYLE:far
global GRSETTEXTMODE:far
global GRSETTEXTDRAWOFFSET:far
global GRSETTEXTSPACEPAD:far
global GRSETTEXTATTR:far
global GRSETFONT:far
global GRSETCLIPRECT:far
global GRSETWINCLIPRECT:far
global GRDRAWRECT:far
global GRBEGINPATH:far
global GRENDPATH:far
global GRCLOSESUBPATH:far
global GRSETNULLPATH:far
global GRSETCLIPPATH:far
global GRSETWINCLIPPATH:far
global GRFILLPATH:far
global GRDRAWPATH:far
global GRSETSTROKEPATH:far
global GRTESTPOINTINPATH:far
global GRGETPATH:far
global GRTESTPATH:far
global GRGETPATHBOUNDS:far
global GRGETPATHBOUNDSDWORD:far
global GRGETPATHPOINTS:far
global GRGETPATHREGION:far
global GRGETCLIPREGION:far
global GRINVALRECT:far
global GRINVALRECTDWORD:far
global GRGETMASKBOUNDSDWORD:far
global GRGETWINBOUNDSDWORD:far
global GRGETWINHANDLE:far
global GRGETGSTRINGHANDLE:far
global GRBRUSHPOLYLINE:far
global GRDRAWHUGEBITMAP:far
global GRDRAWHUGEBITMAPATCP:far
global GRFILLHUGEBITMAP:far
global GRFILLHUGEBITMAPATCP:far
global GRSETBITMAPMODE:far
global GRGETBITMAPMODE:far
global GRFILLBITMAP:far
global GRFILLBITMAPATCP:far
global GRGETTRACKKERN:far
global GRGETFONTNAME:far
global GRSETFONTWEIGHT:far
global GRSETFONTWIDTH:far
global GRSETSUPERSCRIPTATTR:far
global GRSETSUBSCRIPTATTR:far
global GRGETFONTWEIGHT:far
global GRGETFONTWIDTH:far
global GRGETSUPERSCRIPTATTR:far
global GRGETSUBSCRIPTATTR:far
global GRGETMASKBOUNDS:far
global GRGETWINBOUNDS:far
global GRSETAREAPATTERN:far
global GRSETCUSTOMAREAPATTERN:far
global GRSETTEXTPATTERN:far
global GRSETCUSTOMTEXTPATTERN:far
global GRGETAREAPATTERN:far
global GRGETTEXTPATTERN:far
global GRGETTEXTBOUNDS:far
global GREDITBITMAP:far
global GRDRAWIMAGE:far
global GRDRAWHUGEIMAGE:far
global GRTESTRECTINMASK:far
global GRGETPOINT:far
global GRCOMPACTBITMAP:far
global GRUNCOMPACTBITMAP:far
global GRGETCHARINFO:far
global GRSETVMFILE:far
EndKernel
