#ifndef GC_H_INCLUDED #define GC_H_INCLUDED typedef long tCoord; typedef unsigned long tColor; typedef struct sPoint { tCoord x; tCoord y; } tPoint; typedef struct sRect { tPoint UpperLeft; tPoint BottomRight; } tRect; /* forward declaration */ struct sGC; typedef struct sGDC { char *name; int (*OnRegister)(struct sGC *pGC); } tGDC; #define GC_EDGE_TOP (1<<3) #define GC_EDGE_LEFT (1<<2) #define GC_EDGE_BOTTOM (1<<1) #define GC_EDGE_RIGHT (1<<0) #define GC_EDGE_ALL (GC_EDGE_TOP|GC_EDGE_LEFT|GC_EDGE_BOTTOM|GC_EDGE_RIGHT) #define GC_EDGE_NONE (0) #define GC_ROP_REPLACE (1<<0) #define GC_ROP_OR (1<<1) #define GC_ROP_XOR (1<<2) #define GC_ROP_AND (1<<3) #define GC_ROP_DRAWBG (1<<4) #define GC_ROP_CLIP (1<<5) typedef struct sGC { struct sGC *next; struct sGDC *pGDC; tColor fgColor; tColor bgColor; unsigned long fgDeviceColor; unsigned long bgDeviceColor; unsigned long rop; int fntindex; tRect ClipRect; tCoord x; tCoord y; /* mandatory */ // void (*SetColorDirect) (struct sGC *GC, unsigned long color); void (*DrawPixelDirect) (struct sGC *GC, tCoord x, tCoord y, unsigned long color ); tCoord (*GetWidth) (struct sGC *GC ); tCoord (*GetHeight) (struct sGC *GC ); /* optional */ unsigned long (*ConvColorToBytes)(struct sGC *GC, tColor color); tColor (*ConvBytesToColor) (struct sGC *GC, unsigned long color); int (*SetClipRect) (struct sGC *GC, tRect *r ); int (*OnOpen) (struct sGC *GC, void *param); void (*OnClose) (struct sGC *GC ); void (*DrawBegin) (struct sGC *GC ); void (*DrawEnd) (struct sGC *GC ); tColor (*SetFGColor) (struct sGC *GC, tColor color ); tColor (*GetFGColor) (struct sGC *GC ); tColor (*SetBGColor) (struct sGC *GC, tColor color ); tColor (*GetBGColor) (struct sGC *GC ); void (*DrawPointCoord) (struct sGC *GC, tCoord x, tCoord y ); void (*DrawLineCoord) (struct sGC *GC, tCoord x1, tCoord y1, tCoord x2, tCoord y2 ); void (*DrawRectCoord) (struct sGC *GC, tCoord ulx, tCoord uly, tCoord brx, tCoord bry ); void (*FillRectCoord) (struct sGC *GC, tCoord ulx, tCoord uly, tCoord brx, tCoord bry ); } tGC; enum eGCMethod { gcDrawPixelDirect, gcGetWidth, gcGetHeight, gcConvColorToBytes, gcConvBytesToColor, gcSetClipRect, gcOnOpen, gcOnClose, gcDrawBegin, gcDrawEnd, gcSetFGColor, gcGetFGColor, gcSetBGColor, gcGetBGColor, gcDrawPointCoord, gcDrawLineCoord, gcDrawRectCoord, gcFillRectCoord, gcMaxMethod }; /* gdevice.c */ tGC *AllocGC ( void); void FreeGC ( tGC *pGC); tGC *OpenGC ( const char *name, void *param ); void CloseGC ( tGC *gc ); tGC *RegisterDeviceGC ( tGDC *pGDC ); int RegisterGCMethod ( tGC *pGC, enum eGCMethod method, void *p ); /* gutils.c */ int ClipPointAgainstRect( tPoint *p, tRect *dst ); int ClipRectAgainstRect ( tRect *src, tRect *dst ); void CenterRectH ( tRect *a, tRect *b ); void CenterRectV ( tRect *a, tRect *b ); void CenterRect ( tRect *a, tRect *b ); void CenterRectToPoint ( tRect *a, tPoint *b ); void ExtendRect ( tRect *d, tRect *s, tCoord v ); void NormRect ( tRect *d ); tColor SetColorRGB ( int R, int G, int B ); tColor SetColorRGBA ( int R, int G, int B, int A ); int GetColorRed ( tColor color ); int GetColorGreen ( tColor color ); int GetColorBlue ( tColor color ); int GetColorAlpha ( tColor color ); tColor RGBToYUV ( tColor rgb ); tColor YUVToRGB ( tColor yuv ); tColor RGBToBW ( tColor rgb ); /* gc.c */ tCoord GGetWidth ( tGC *pGC ); tCoord GGetHeight ( tGC *pGC ); tColor GSetFGColor ( tGC *pGC, tColor color ); tColor GGetFGColor ( tGC *pGC ); tColor GSetBGColor ( tGC *pGC, tColor color ); tColor GGetBGColor ( tGC *pGC ); void GDrawBegin ( tGC *pGC ); void GDrawEnd ( tGC *pGC ); void GDrawPointCoord ( tGC *pGC, tCoord x1, tCoord y1 ); void GDrawPoint ( tGC *pGC, tPoint *p ); void GDrawLineCoord ( tGC *pGC, tCoord x1, tCoord y1, tCoord x2, tCoord y2 ); void GDrawLinePoint ( tGC *pGC, tPoint *ps, tPoint *pe ); void GDrawRectCoord ( tGC *pGC, tCoord ulx, tCoord uly, tCoord brx, tCoord bry ); void GDrawRectPoint ( tGC *pGC, tPoint *ps, tPoint *pe ); void GDrawRect ( tGC *pGC, tRect *r ); void GMoveToPointCoord ( tGC *pGC, tCoord x, tCoord y ); void GMoveToPoint ( tGC *pGC, tPoint *p ); void GLineToPointCoord ( tGC *pGC, tCoord x, tCoord y ); void GLineToPoint ( tGC *pGC, tPoint *p ); void GPolyLineCoord ( tGC *pGC, int count, tCoord *x, tCoord *y ); void GPolyLinePoint ( tGC *pGC, int count, tPoint *p ); void GPolygonCoord ( tGC *pGC, int count, tCoord *x, tCoord *y ); void GPolygonPoint ( tGC *pGC, int count, tPoint *p ); void GDrawText ( tGC *pGC, tRect *r, const char *text ); void GTextRect ( tGC *pGC, tRect *r, const char *text ); void GRasterMode ( tGC *pGC, unsigned long rm ); void GFillRectCoord ( tGC *pGC, tCoord ulx, tCoord uly, tCoord brx, tCoord bry ); void GFillRectPoint ( tGC *pGC, tPoint *ps, tPoint *pe ); void GFillRect ( tGC *pGC, tRect *r ); void GDrawCircle ( tGC *pGC, int x0, int y0, int radius ); void GDrawCircleRect ( tGC *pGC, tRect *r ); void GSetFont ( tGC *pGC, int fntindex ); void GClear ( tGC *pGC ); int GSetClipRect ( tGC *pGC, tRect *r ); void GGetScreenRect ( tGC *pGC, tRect *r ); /* default implementaions */ tCoord GCGetWidth ( tGC *pGC ); tCoord GCGetHeight ( tGC *pGC ); void GCDrawPixelDirect ( tGC *pGC, tCoord x, tCoord y, unsigned long color ); unsigned long GCConvColorToBytes( tGC *pGC, tColor color ); tColor GCConvBytesToColor( tGC *pGC, unsigned long color ); int GCOnOpen ( tGC *pGC, void *param ); void GCOnClose ( tGC *pGC ); void GCDrawBegin ( tGC *pGC ); void GCDrawEnd ( tGC *pGC ); tColor GCSetFGColor ( tGC *pGC, tColor color ); tColor GCGetFGColor ( tGC *pGC ); tColor GCSetBGColor ( tGC *pGC, tColor color ); tColor GCGetBGColor ( tGC *pGC ); void GCDrawPointCoord ( tGC *pGC, tCoord x1, tCoord y1 ); void GCDrawLineCoord ( tGC *pGC, tCoord x1, tCoord y1, tCoord x2, tCoord y2 ); void GCDrawRectCoord ( tGC *pGC, tCoord ulx, tCoord uly, tCoord brx, tCoord bry ); void GCFillRectCoord ( tGC *pGC, tCoord ulx, tCoord uly, tCoord brx, tCoord bry ); int GCSetClipRect ( tGC *pGC, tRect *r ); #endif