#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "Pcl.h"
#include "gcstruct.h"
#include "windowstr.h"
void
PclPolyRectangle(
DrawablePtr pDrawable,
GCPtr pGC,
int nRects,
xRectangle *pRects)
{
char t[80];
FILE *outFile;
int nbox, i;
BoxPtr pbox;
xRectangle *drawRects, *r;
RegionPtr drawRegion, region;
short fudge;
int xoffset, yoffset;
XpContextPtr pCon;
PclContextPrivPtr pConPriv;
if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == FALSE )
return;
pCon = PclGetContextFromWindow( (WindowPtr) pDrawable );
pConPriv = (PclContextPrivPtr)
pCon->devPrivates[PclContextPrivateIndex].ptr;
region = REGION_CREATE( pGC->pScreen, NULL, 0 );
drawRects = (xRectangle *)xalloc( nRects * sizeof( xRectangle ) );
fudge = 3 * pGC->lineWidth + 1;
MACRO_START( outFile, pConPriv );
SAVE_PCL( outFile, pConPriv, "\033%0B" );
xoffset = pDrawable->x;
yoffset = pDrawable->y;
for( i = 0, r = drawRects; i < nRects; i++, r++ )
{
xRectangle rect = pRects[i];
sprintf( t, "PU%d,%d;ER%d,%d;", rect.x + xoffset,
rect.y + yoffset, rect.width, rect.height );
SAVE_PCL( outFile, pConPriv, t );
r->x = MIN( rect.x, rect.x + rect.width ) + xoffset -
fudge;
r->y = MIN( rect.y, rect.y + rect.height ) + yoffset -
fudge;
r->width = rect.width + 2 * fudge;
r->height = rect.height + 2 * fudge;
}
SAVE_PCL( outFile, pConPriv, ";\033%0A" );
MACRO_END( outFile );
drawRegion = RECTS_TO_REGION( pGC->pScreen, nRects,
drawRects, CT_UNSORTED );
REGION_INTERSECT( pGC->pScreen, region, drawRegion, pGC->pCompositeClip );
pbox = REGION_RECTS( region );
nbox = REGION_NUM_RECTS( region );
PclSendData(outFile, pConPriv, pbox, nbox, 1.0);
REGION_DESTROY( pGC->pScreen, drawRegion );
REGION_DESTROY( pGC->pScreen, region );
xfree( drawRects );
}
void
PclFillPolygon(
DrawablePtr pDrawable,
GCPtr pGC,
int shape,
int mode,
int nPoints,
DDXPointPtr pPoints)
{
char t[80];
FILE *outFile;
int nbox, i;
BoxPtr pbox;
BoxRec box;
RegionPtr drawRegion, region;
int xoffset, yoffset;
int xtop, xbottom, yleft, yright;
int fillRule;
XpContextPtr pCon;
PclContextPrivPtr pConPriv;
char *command;
if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == FALSE )
return;
pCon = PclGetContextFromWindow( (WindowPtr) pDrawable );
pConPriv = (PclContextPrivPtr)
pCon->devPrivates[PclContextPrivateIndex].ptr;
MACRO_START( outFile, pConPriv );
SAVE_PCL( outFile, pConPriv, "\033%0B" );
if( mode == CoordModeOrigin )
{
xoffset = pDrawable->x;
yoffset = pDrawable->y;
command = "PA";
}
else
{
xoffset = yoffset = 0;
command = "PR";
}
sprintf( t, "PU%d,%d;PM0;%s", pPoints[0].x + xoffset, pPoints[0].y
+ yoffset, command );
SAVE_PCL( outFile, pConPriv, t );
xtop = xbottom = pPoints[0].x + xoffset;
yleft = yright = pPoints[0].y + yoffset;
for( i = 1; i < nPoints; i++ )
{
if( i != 1 )
SAVE_PCL( outFile, pConPriv, "," );
sprintf( t, "%d,%d", pPoints[i].x + xoffset, pPoints[i].y +
yoffset );
SAVE_PCL( outFile, pConPriv, t );
xtop = MIN( xtop, pPoints[i].x + xoffset );
xbottom = MAX( xbottom, pPoints[i].x + xoffset );
yleft = MIN( yleft, pPoints[i].y + yoffset );
yright = MAX( yright, pPoints[i].y + yoffset );
}
if( pGC->fillRule == EvenOddRule )
fillRule = 0;
else
fillRule = 1;
sprintf( t, ";PM2;FP%d;\033%%0A", fillRule );
SAVE_PCL( outFile, pConPriv, t );
MACRO_END ( outFile );
box.x1 = xtop;
box.y1 = yleft;
box.x2 = xbottom;
box.y2 = yright;
drawRegion = REGION_CREATE( pGC->pScreen, &box, 0 );
if( mode == CoordModePrevious )
REGION_TRANSLATE( pGC->pScreen, drawRegion, pPoints[0].x, pPoints[0].y );
region = REGION_CREATE( pGC->pScreen, NULL, 0 );
REGION_INTERSECT( pGC->pScreen, region, drawRegion, pGC->pCompositeClip );
pbox = REGION_RECTS( region );
nbox = REGION_NUM_RECTS( region );
PclSendData(outFile, pConPriv, pbox, nbox, 1.0);
REGION_DESTROY( pGC->pScreen, drawRegion );
REGION_DESTROY( pGC->pScreen, region );
}
void
PclPolyFillRect(
DrawablePtr pDrawable,
GCPtr pGC,
int nRects,
xRectangle *pRects)
{
char t[80];
FILE *outFile;
int nbox, i;
BoxPtr pbox;
xRectangle *drawRects, *r;
RegionPtr drawRegion, region;
int xoffset, yoffset;
short fudge;
XpContextPtr pCon;
PclContextPrivPtr pConPriv;
if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == FALSE )
return;
pCon = PclGetContextFromWindow( (WindowPtr) pDrawable );
pConPriv = (PclContextPrivPtr)
pCon->devPrivates[PclContextPrivateIndex].ptr;
region = REGION_CREATE( pGC->pScreen, NULL, 0 );
drawRects = (xRectangle *)xalloc( nRects * sizeof( xRectangle ) );
fudge = 3 * pGC->lineWidth + 1;
MACRO_START( outFile, pConPriv );
SAVE_PCL( outFile, pConPriv, "\033%0B" );
xoffset = pDrawable->x;
yoffset = pDrawable->y;
for( i = 0, r = drawRects; i < nRects; i++, r++ )
{
xRectangle rect = pRects[i];
sprintf( t, "PU%d,%d;RR%d,%d;", rect.x + xoffset, rect.y +
yoffset, rect.width, rect.height );
SAVE_PCL( outFile, pConPriv, t );
r->x = MIN( rect.x, rect.x + rect.width ) + xoffset - fudge;
r->y = MIN( rect.y, rect.y + rect.height ) + yoffset -
fudge;
r->width = rect.width + 2 * fudge;
r->height = rect.height + 2 * fudge;
}
SAVE_PCL( outFile, pConPriv, ";\033%0A" );
MACRO_END( outFile );
drawRegion = RECTS_TO_REGION( pGC->pScreen, nRects,
drawRects, CT_UNSORTED );
REGION_INTERSECT( pGC->pScreen, region, drawRegion, pGC->pCompositeClip );
pbox = REGION_RECTS( region );
nbox = REGION_NUM_RECTS( region );
PclSendData(outFile, pConPriv, pbox, nbox, 1.0);
REGION_DESTROY( pGC->pScreen, drawRegion );
REGION_DESTROY( pGC->pScreen, region );
xfree( drawRects );
}