1999-05-02 12:15:16 +02:00
|
|
|
/*
|
|
|
|
* Enhanced MetaFile driver graphics functions
|
|
|
|
*
|
|
|
|
* Copyright 1999 Huw D M Davies
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1999-05-02 12:15:16 +02:00
|
|
|
*/
|
|
|
|
|
2002-08-29 01:42:34 +02:00
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
1999-05-02 12:15:16 +02:00
|
|
|
#include <stdlib.h>
|
1999-07-31 19:36:48 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
1999-05-02 12:15:16 +02:00
|
|
|
#include "gdi.h"
|
2002-03-27 22:13:40 +01:00
|
|
|
#include "enhmfdrv/enhmetafiledrv.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1999-05-02 12:15:16 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(enhmetafile);
|
1999-05-02 12:15:16 +02:00
|
|
|
|
|
|
|
/**********************************************************************
|
2000-11-05 04:28:18 +01:00
|
|
|
* EMFDRV_MoveTo
|
1999-05-02 12:15:16 +02:00
|
|
|
*/
|
|
|
|
BOOL
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_MoveTo(PHYSDEV dev, INT x, INT y)
|
1999-05-02 12:15:16 +02:00
|
|
|
{
|
|
|
|
EMRMOVETOEX emr;
|
|
|
|
|
|
|
|
emr.emr.iType = EMR_MOVETOEX;
|
|
|
|
emr.emr.nSize = sizeof(emr);
|
|
|
|
emr.ptl.x = x;
|
|
|
|
emr.ptl.y = y;
|
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
return EMFDRV_WriteRecord( dev, &emr.emr );
|
1999-05-02 12:15:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EMFDRV_LineTo
|
|
|
|
*/
|
|
|
|
BOOL
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_LineTo( PHYSDEV dev, INT x, INT y )
|
1999-05-02 12:15:16 +02:00
|
|
|
{
|
|
|
|
EMRLINETO emr;
|
|
|
|
RECTL bounds;
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
|
|
|
|
DC *dc = physDev->dc;
|
1999-05-02 12:15:16 +02:00
|
|
|
|
|
|
|
emr.emr.iType = EMR_LINETO;
|
|
|
|
emr.emr.nSize = sizeof(emr);
|
|
|
|
emr.ptl.x = x;
|
|
|
|
emr.ptl.y = y;
|
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
if(!EMFDRV_WriteRecord( dev, &emr.emr ))
|
1999-05-02 12:15:16 +02:00
|
|
|
return FALSE;
|
|
|
|
|
2000-11-05 03:05:07 +01:00
|
|
|
bounds.left = min(x, dc->CursPosX);
|
|
|
|
bounds.top = min(y, dc->CursPosY);
|
|
|
|
bounds.right = max(x, dc->CursPosX);
|
|
|
|
bounds.bottom = max(y, dc->CursPosY);
|
1999-05-02 12:15:16 +02:00
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_UpdateBBox( dev, &bounds );
|
1999-05-02 12:15:16 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EMFDRV_ArcChordPie
|
|
|
|
*/
|
|
|
|
static BOOL
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_ArcChordPie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
|
1999-05-02 12:15:16 +02:00
|
|
|
INT xstart, INT ystart, INT xend, INT yend, DWORD iType )
|
|
|
|
{
|
|
|
|
INT temp, xCentre, yCentre, i;
|
|
|
|
double angleStart, angleEnd;
|
|
|
|
double xinterStart, yinterStart, xinterEnd, yinterEnd;
|
|
|
|
EMRARC emr;
|
|
|
|
RECTL bounds;
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
|
|
|
|
DC *dc = physDev->dc;
|
1999-05-02 12:15:16 +02:00
|
|
|
|
|
|
|
if(left == right || top == bottom) return FALSE;
|
|
|
|
|
|
|
|
if(left > right) {temp = left; left = right; right = temp;}
|
|
|
|
if(top > bottom) {temp = top; top = bottom; bottom = temp;}
|
|
|
|
|
2000-11-05 03:05:07 +01:00
|
|
|
if(dc->GraphicsMode == GM_COMPATIBLE) {
|
2000-04-14 16:07:51 +02:00
|
|
|
right--;
|
|
|
|
bottom--;
|
|
|
|
}
|
1999-05-02 12:15:16 +02:00
|
|
|
|
|
|
|
emr.emr.iType = iType;
|
|
|
|
emr.emr.nSize = sizeof(emr);
|
|
|
|
emr.rclBox.left = left;
|
|
|
|
emr.rclBox.top = top;
|
|
|
|
emr.rclBox.right = right;
|
|
|
|
emr.rclBox.bottom = bottom;
|
|
|
|
emr.ptlStart.x = xstart;
|
|
|
|
emr.ptlStart.y = ystart;
|
|
|
|
emr.ptlEnd.x = xend;
|
|
|
|
emr.ptlEnd.x = yend;
|
|
|
|
|
|
|
|
|
|
|
|
/* Now calculate the BBox */
|
|
|
|
xCentre = (left + right + 1) / 2;
|
|
|
|
yCentre = (top + bottom + 1) / 2;
|
|
|
|
|
|
|
|
xstart -= xCentre;
|
|
|
|
ystart -= yCentre;
|
|
|
|
xend -= xCentre;
|
|
|
|
yend -= yCentre;
|
|
|
|
|
|
|
|
/* invert y co-ords to get angle anti-clockwise from x-axis */
|
|
|
|
angleStart = atan2( -(double)ystart, (double)xstart);
|
|
|
|
angleEnd = atan2( -(double)yend, (double)xend);
|
|
|
|
|
|
|
|
/* These are the intercepts of the start/end lines with the arc */
|
|
|
|
|
|
|
|
xinterStart = (right - left + 1)/2 * cos(angleStart) + xCentre;
|
|
|
|
yinterStart = -(bottom - top + 1)/2 * sin(angleStart) + yCentre;
|
|
|
|
xinterEnd = (right - left + 1)/2 * cos(angleEnd) + xCentre;
|
|
|
|
yinterEnd = -(bottom - top + 1)/2 * sin(angleEnd) + yCentre;
|
|
|
|
|
|
|
|
if(angleStart < 0) angleStart += 2 * M_PI;
|
|
|
|
if(angleEnd < 0) angleEnd += 2 * M_PI;
|
|
|
|
if(angleEnd < angleStart) angleEnd += 2 * M_PI;
|
|
|
|
|
2000-03-25 22:44:35 +01:00
|
|
|
bounds.left = min(xinterStart, xinterEnd);
|
|
|
|
bounds.top = min(yinterStart, yinterEnd);
|
|
|
|
bounds.right = max(xinterStart, xinterEnd);
|
|
|
|
bounds.bottom = max(yinterStart, yinterEnd);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-02 12:15:16 +02:00
|
|
|
for(i = 0; i <= 8; i++) {
|
|
|
|
if(i * M_PI / 2 < angleStart) /* loop until we're past start */
|
|
|
|
continue;
|
|
|
|
if(i * M_PI / 2 > angleEnd) /* if we're past end we're finished */
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* the arc touches the rectangle at the start of quadrant i, so adjust
|
|
|
|
BBox to reflect this. */
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
switch(i % 4) {
|
1999-05-02 12:15:16 +02:00
|
|
|
case 0:
|
|
|
|
bounds.right = right;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
bounds.top = top;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
bounds.left = left;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
bounds.bottom = bottom;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we're drawing a pie then make sure we include the centre */
|
|
|
|
if(iType == EMR_PIE) {
|
|
|
|
if(bounds.left > xCentre) bounds.left = xCentre;
|
|
|
|
else if(bounds.right < xCentre) bounds.right = xCentre;
|
|
|
|
if(bounds.top > yCentre) bounds.top = yCentre;
|
|
|
|
else if(bounds.bottom < yCentre) bounds.right = yCentre;
|
|
|
|
}
|
2002-03-28 23:22:05 +01:00
|
|
|
if(!EMFDRV_WriteRecord( dev, &emr.emr ))
|
1999-05-02 12:15:16 +02:00
|
|
|
return FALSE;
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_UpdateBBox( dev, &bounds );
|
1999-05-02 12:15:16 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EMFDRV_Arc
|
|
|
|
*/
|
|
|
|
BOOL
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_Arc( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
|
1999-05-02 12:15:16 +02:00
|
|
|
INT xstart, INT ystart, INT xend, INT yend )
|
|
|
|
{
|
2002-03-28 23:22:05 +01:00
|
|
|
return EMFDRV_ArcChordPie( dev, left, top, right, bottom, xstart, ystart,
|
1999-05-02 12:15:16 +02:00
|
|
|
xend, yend, EMR_ARC );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EMFDRV_Pie
|
|
|
|
*/
|
|
|
|
BOOL
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_Pie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
|
1999-05-02 12:15:16 +02:00
|
|
|
INT xstart, INT ystart, INT xend, INT yend )
|
|
|
|
{
|
2002-03-28 23:22:05 +01:00
|
|
|
return EMFDRV_ArcChordPie( dev, left, top, right, bottom, xstart, ystart,
|
1999-05-02 12:15:16 +02:00
|
|
|
xend, yend, EMR_PIE );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EMFDRV_Chord
|
|
|
|
*/
|
|
|
|
BOOL
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_Chord( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
|
1999-05-02 12:15:16 +02:00
|
|
|
INT xstart, INT ystart, INT xend, INT yend )
|
|
|
|
{
|
2002-03-28 23:22:05 +01:00
|
|
|
return EMFDRV_ArcChordPie( dev, left, top, right, bottom, xstart, ystart,
|
1999-05-02 12:15:16 +02:00
|
|
|
xend, yend, EMR_CHORD );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EMFDRV_Ellipse
|
|
|
|
*/
|
|
|
|
BOOL
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
|
1999-05-02 12:15:16 +02:00
|
|
|
{
|
|
|
|
EMRELLIPSE emr;
|
|
|
|
INT temp;
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
|
|
|
|
DC *dc = physDev->dc;
|
1999-05-02 12:15:16 +02:00
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("%d,%d - %d,%d\n", left, top, right, bottom);
|
1999-05-02 12:15:16 +02:00
|
|
|
|
|
|
|
if(left == right || top == bottom) return FALSE;
|
|
|
|
|
|
|
|
if(left > right) {temp = left; left = right; right = temp;}
|
|
|
|
if(top > bottom) {temp = top; top = bottom; bottom = temp;}
|
|
|
|
|
2000-11-05 03:05:07 +01:00
|
|
|
if(dc->GraphicsMode == GM_COMPATIBLE) {
|
2000-04-14 16:07:51 +02:00
|
|
|
right--;
|
|
|
|
bottom--;
|
|
|
|
}
|
1999-05-02 12:15:16 +02:00
|
|
|
|
|
|
|
emr.emr.iType = EMR_ELLIPSE;
|
|
|
|
emr.emr.nSize = sizeof(emr);
|
|
|
|
emr.rclBox.left = left;
|
|
|
|
emr.rclBox.top = top;
|
|
|
|
emr.rclBox.right = right;
|
|
|
|
emr.rclBox.bottom = bottom;
|
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_UpdateBBox( dev, &emr.rclBox );
|
|
|
|
return EMFDRV_WriteRecord( dev, &emr.emr );
|
1999-05-02 12:15:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EMFDRV_Rectangle
|
|
|
|
*/
|
|
|
|
BOOL
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_Rectangle(PHYSDEV dev, INT left, INT top, INT right, INT bottom)
|
1999-05-02 12:15:16 +02:00
|
|
|
{
|
|
|
|
EMRRECTANGLE emr;
|
|
|
|
INT temp;
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
|
|
|
|
DC *dc = physDev->dc;
|
1999-05-02 12:15:16 +02:00
|
|
|
|
1999-06-26 21:09:08 +02:00
|
|
|
TRACE("%d,%d - %d,%d\n", left, top, right, bottom);
|
1999-05-02 12:15:16 +02:00
|
|
|
|
|
|
|
if(left == right || top == bottom) return FALSE;
|
|
|
|
|
|
|
|
if(left > right) {temp = left; left = right; right = temp;}
|
|
|
|
if(top > bottom) {temp = top; top = bottom; bottom = temp;}
|
|
|
|
|
2000-11-05 03:05:07 +01:00
|
|
|
if(dc->GraphicsMode == GM_COMPATIBLE) {
|
2000-04-14 16:07:51 +02:00
|
|
|
right--;
|
|
|
|
bottom--;
|
|
|
|
}
|
1999-05-02 12:15:16 +02:00
|
|
|
|
|
|
|
emr.emr.iType = EMR_RECTANGLE;
|
|
|
|
emr.emr.nSize = sizeof(emr);
|
|
|
|
emr.rclBox.left = left;
|
|
|
|
emr.rclBox.top = top;
|
|
|
|
emr.rclBox.right = right;
|
|
|
|
emr.rclBox.bottom = bottom;
|
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_UpdateBBox( dev, &emr.rclBox );
|
|
|
|
return EMFDRV_WriteRecord( dev, &emr.emr );
|
1999-05-02 12:15:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EMFDRV_RoundRect
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
BOOL
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_RoundRect( PHYSDEV dev, INT left, INT top, INT right,
|
1999-05-02 12:15:16 +02:00
|
|
|
INT bottom, INT ell_width, INT ell_height )
|
|
|
|
{
|
|
|
|
EMRROUNDRECT emr;
|
|
|
|
INT temp;
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
|
|
|
|
DC *dc = physDev->dc;
|
1999-05-02 12:15:16 +02:00
|
|
|
|
|
|
|
if(left == right || top == bottom) return FALSE;
|
|
|
|
|
|
|
|
if(left > right) {temp = left; left = right; right = temp;}
|
|
|
|
if(top > bottom) {temp = top; top = bottom; bottom = temp;}
|
|
|
|
|
2000-11-05 03:05:07 +01:00
|
|
|
if(dc->GraphicsMode == GM_COMPATIBLE) {
|
2000-04-14 16:07:51 +02:00
|
|
|
right--;
|
|
|
|
bottom--;
|
|
|
|
}
|
1999-05-02 12:15:16 +02:00
|
|
|
|
|
|
|
emr.emr.iType = EMR_ROUNDRECT;
|
|
|
|
emr.emr.nSize = sizeof(emr);
|
|
|
|
emr.rclBox.left = left;
|
|
|
|
emr.rclBox.top = top;
|
|
|
|
emr.rclBox.right = right;
|
|
|
|
emr.rclBox.bottom = bottom;
|
|
|
|
emr.szlCorner.cx = ell_width;
|
|
|
|
emr.szlCorner.cy = ell_height;
|
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_UpdateBBox( dev, &emr.rclBox );
|
|
|
|
return EMFDRV_WriteRecord( dev, &emr.emr );
|
1999-05-02 12:15:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EMFDRV_SetPixel
|
|
|
|
*/
|
|
|
|
COLORREF
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color )
|
1999-05-02 12:15:16 +02:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* EMFDRV_Polylinegon
|
|
|
|
*
|
|
|
|
* Helper for EMFDRV_Poly{line|gon}
|
|
|
|
*/
|
|
|
|
static BOOL
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_Polylinegon( PHYSDEV dev, const POINT* pt, INT count, DWORD iType )
|
1999-05-02 12:15:16 +02:00
|
|
|
{
|
|
|
|
EMRPOLYLINE *emr;
|
|
|
|
DWORD size;
|
|
|
|
INT i;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
size = sizeof(EMRPOLYLINE) + sizeof(POINTL) * (count - 1);
|
|
|
|
|
2000-02-16 23:47:24 +01:00
|
|
|
emr = HeapAlloc( GetProcessHeap(), 0, size );
|
1999-05-02 12:15:16 +02:00
|
|
|
emr->emr.iType = iType;
|
|
|
|
emr->emr.nSize = size;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-02 12:15:16 +02:00
|
|
|
emr->rclBounds.left = emr->rclBounds.right = pt[0].x;
|
|
|
|
emr->rclBounds.top = emr->rclBounds.bottom = pt[0].y;
|
|
|
|
|
|
|
|
for(i = 1; i < count; i++) {
|
|
|
|
if(pt[i].x < emr->rclBounds.left)
|
|
|
|
emr->rclBounds.left = pt[i].x;
|
|
|
|
else if(pt[i].x > emr->rclBounds.right)
|
|
|
|
emr->rclBounds.right = pt[i].x;
|
|
|
|
if(pt[i].y < emr->rclBounds.top)
|
|
|
|
emr->rclBounds.top = pt[i].y;
|
|
|
|
else if(pt[i].y > emr->rclBounds.bottom)
|
|
|
|
emr->rclBounds.bottom = pt[i].y;
|
|
|
|
}
|
|
|
|
|
|
|
|
emr->cptl = count;
|
1999-05-13 20:46:46 +02:00
|
|
|
memcpy(emr->aptl, pt, count * sizeof(POINTL));
|
1999-05-02 12:15:16 +02:00
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
ret = EMFDRV_WriteRecord( dev, &emr->emr );
|
1999-05-02 12:15:16 +02:00
|
|
|
if(ret)
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_UpdateBBox( dev, &emr->rclBounds );
|
2000-02-16 23:47:24 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, emr );
|
1999-05-02 12:15:16 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* EMFDRV_Polyline
|
|
|
|
*/
|
|
|
|
BOOL
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_Polyline( PHYSDEV dev, const POINT* pt, INT count )
|
1999-05-02 12:15:16 +02:00
|
|
|
{
|
2002-03-28 23:22:05 +01:00
|
|
|
return EMFDRV_Polylinegon( dev, pt, count, EMR_POLYLINE );
|
1999-05-02 12:15:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* EMFDRV_Polygon
|
|
|
|
*/
|
|
|
|
BOOL
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_Polygon( PHYSDEV dev, const POINT* pt, INT count )
|
1999-05-02 12:15:16 +02:00
|
|
|
{
|
|
|
|
if(count < 2) return FALSE;
|
2002-03-28 23:22:05 +01:00
|
|
|
return EMFDRV_Polylinegon( dev, pt, count, EMR_POLYGON );
|
1999-05-02 12:15:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* EMFDRV_PolyPolylinegon
|
|
|
|
*
|
|
|
|
* Helper for EMFDRV_PolyPoly{line|gon}
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static BOOL
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_PolyPolylinegon( PHYSDEV dev, const POINT* pt, const INT* counts, UINT polys,
|
1999-05-02 12:15:16 +02:00
|
|
|
DWORD iType)
|
|
|
|
{
|
|
|
|
EMRPOLYPOLYLINE *emr;
|
|
|
|
DWORD cptl = 0, poly, size, point;
|
|
|
|
RECTL bounds;
|
|
|
|
const POINT *pts;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
bounds.left = bounds.right = pt[0].x;
|
|
|
|
bounds.top = bounds.bottom = pt[0].y;
|
|
|
|
|
|
|
|
pts = pt;
|
|
|
|
for(poly = 0; poly < polys; poly++) {
|
|
|
|
cptl += counts[poly];
|
|
|
|
for(point = 0; point < counts[poly]; point++) {
|
|
|
|
if(bounds.left > pts->x) bounds.left = pts->x;
|
|
|
|
else if(bounds.right < pts->x) bounds.right = pts->x;
|
|
|
|
if(bounds.top > pts->y) bounds.top = pts->y;
|
|
|
|
else if(bounds.bottom < pts->y) bounds.bottom = pts->y;
|
|
|
|
pts++;
|
|
|
|
}
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
|
|
|
size = sizeof(EMRPOLYPOLYLINE) + (polys - 1) * sizeof(DWORD) +
|
1999-05-02 12:15:16 +02:00
|
|
|
(cptl - 1) * sizeof(POINTL);
|
|
|
|
|
2000-02-16 23:47:24 +01:00
|
|
|
emr = HeapAlloc( GetProcessHeap(), 0, size );
|
1999-05-02 12:15:16 +02:00
|
|
|
|
|
|
|
emr->emr.iType = iType;
|
|
|
|
emr->emr.nSize = size;
|
|
|
|
emr->rclBounds = bounds;
|
|
|
|
emr->nPolys = polys;
|
|
|
|
emr->cptl = cptl;
|
|
|
|
memcpy(emr->aPolyCounts, counts, polys * sizeof(DWORD));
|
1999-05-13 20:46:46 +02:00
|
|
|
memcpy(emr->aPolyCounts + polys, pt, cptl * sizeof(POINTL));
|
2002-03-28 23:22:05 +01:00
|
|
|
ret = EMFDRV_WriteRecord( dev, &emr->emr );
|
1999-05-02 12:15:16 +02:00
|
|
|
if(ret)
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_UpdateBBox( dev, &emr->rclBounds );
|
2000-02-16 23:47:24 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, emr );
|
1999-05-02 12:15:16 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* EMFDRV_PolyPolyline
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
BOOL
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_PolyPolyline(PHYSDEV dev, const POINT* pt, const DWORD* counts, DWORD polys)
|
1999-05-02 12:15:16 +02:00
|
|
|
{
|
2002-03-28 23:22:05 +01:00
|
|
|
return EMFDRV_PolyPolylinegon( dev, pt, (INT *)counts, polys,
|
1999-05-02 12:15:16 +02:00
|
|
|
EMR_POLYPOLYLINE );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* EMFDRV_PolyPolygon
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
BOOL
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_PolyPolygon( PHYSDEV dev, const POINT* pt, const INT* counts, UINT polys )
|
1999-05-02 12:15:16 +02:00
|
|
|
{
|
2002-03-28 23:22:05 +01:00
|
|
|
return EMFDRV_PolyPolylinegon( dev, pt, counts, polys, EMR_POLYPOLYGON );
|
1999-05-02 12:15:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* EMFDRV_ExtFloodFill
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
BOOL
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_ExtFloodFill( PHYSDEV dev, INT x, INT y, COLORREF color, UINT fillType )
|
1999-05-02 12:15:16 +02:00
|
|
|
{
|
|
|
|
EMREXTFLOODFILL emr;
|
|
|
|
|
|
|
|
emr.emr.iType = EMR_EXTFLOODFILL;
|
|
|
|
emr.emr.nSize = sizeof(emr);
|
|
|
|
emr.ptlStart.x = x;
|
|
|
|
emr.ptlStart.y = y;
|
|
|
|
emr.crColor = color;
|
|
|
|
emr.iMode = fillType;
|
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
return EMFDRV_WriteRecord( dev, &emr.emr );
|
1999-05-02 12:15:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* EMFDRV_FillRgn
|
|
|
|
*/
|
2002-03-28 23:22:05 +01:00
|
|
|
BOOL EMFDRV_FillRgn( PHYSDEV dev, HRGN hrgn, HBRUSH hbrush )
|
1999-05-02 12:15:16 +02:00
|
|
|
{
|
|
|
|
EMRFILLRGN *emr;
|
|
|
|
DWORD size, rgnsize, index;
|
|
|
|
BOOL ret;
|
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
index = EMFDRV_CreateBrushIndirect( dev, hbrush );
|
1999-05-02 12:15:16 +02:00
|
|
|
if(!index) return FALSE;
|
|
|
|
|
|
|
|
rgnsize = GetRegionData( hrgn, 0, NULL );
|
2002-05-29 00:47:49 +02:00
|
|
|
size = rgnsize + offsetof(EMRFILLRGN,RgnData);
|
2000-02-16 23:47:24 +01:00
|
|
|
emr = HeapAlloc( GetProcessHeap(), 0, size );
|
1999-05-02 12:15:16 +02:00
|
|
|
|
|
|
|
GetRegionData( hrgn, rgnsize, (RGNDATA *)&emr->RgnData );
|
|
|
|
|
|
|
|
emr->emr.iType = EMR_FILLRGN;
|
|
|
|
emr->emr.nSize = size;
|
|
|
|
emr->rclBounds.left = ((RGNDATA *)&emr->RgnData)->rdh.rcBound.left;
|
|
|
|
emr->rclBounds.top = ((RGNDATA *)&emr->RgnData)->rdh.rcBound.top;
|
|
|
|
emr->rclBounds.right = ((RGNDATA *)&emr->RgnData)->rdh.rcBound.right - 1;
|
|
|
|
emr->rclBounds.bottom = ((RGNDATA *)&emr->RgnData)->rdh.rcBound.bottom - 1;
|
|
|
|
emr->cbRgnData = rgnsize;
|
|
|
|
emr->ihBrush = index;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
ret = EMFDRV_WriteRecord( dev, &emr->emr );
|
1999-05-02 12:15:16 +02:00
|
|
|
if(ret)
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_UpdateBBox( dev, &emr->rclBounds );
|
2000-02-16 23:47:24 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, emr );
|
1999-05-02 12:15:16 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
/*********************************************************************
|
|
|
|
* EMFDRV_FrameRgn
|
|
|
|
*/
|
2002-03-28 23:22:05 +01:00
|
|
|
BOOL EMFDRV_FrameRgn( PHYSDEV dev, HRGN hrgn, HBRUSH hbrush, INT width, INT height )
|
1999-05-02 12:15:16 +02:00
|
|
|
{
|
|
|
|
EMRFRAMERGN *emr;
|
|
|
|
DWORD size, rgnsize, index;
|
|
|
|
BOOL ret;
|
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
index = EMFDRV_CreateBrushIndirect( dev, hbrush );
|
1999-05-02 12:15:16 +02:00
|
|
|
if(!index) return FALSE;
|
|
|
|
|
|
|
|
rgnsize = GetRegionData( hrgn, 0, NULL );
|
2002-05-29 00:47:49 +02:00
|
|
|
size = rgnsize + offsetof(EMRFRAMERGN,RgnData);
|
2000-02-16 23:47:24 +01:00
|
|
|
emr = HeapAlloc( GetProcessHeap(), 0, size );
|
1999-05-02 12:15:16 +02:00
|
|
|
|
|
|
|
GetRegionData( hrgn, rgnsize, (RGNDATA *)&emr->RgnData );
|
|
|
|
|
|
|
|
emr->emr.iType = EMR_FRAMERGN;
|
|
|
|
emr->emr.nSize = size;
|
|
|
|
emr->rclBounds.left = ((RGNDATA *)&emr->RgnData)->rdh.rcBound.left;
|
|
|
|
emr->rclBounds.top = ((RGNDATA *)&emr->RgnData)->rdh.rcBound.top;
|
|
|
|
emr->rclBounds.right = ((RGNDATA *)&emr->RgnData)->rdh.rcBound.right - 1;
|
|
|
|
emr->rclBounds.bottom = ((RGNDATA *)&emr->RgnData)->rdh.rcBound.bottom - 1;
|
|
|
|
emr->cbRgnData = rgnsize;
|
|
|
|
emr->ihBrush = index;
|
|
|
|
emr->szlStroke.cx = width;
|
|
|
|
emr->szlStroke.cy = height;
|
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
ret = EMFDRV_WriteRecord( dev, &emr->emr );
|
1999-05-02 12:15:16 +02:00
|
|
|
if(ret)
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_UpdateBBox( dev, &emr->rclBounds );
|
2000-02-16 23:47:24 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, emr );
|
1999-05-02 12:15:16 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* EMFDRV_PaintInvertRgn
|
|
|
|
*
|
|
|
|
* Helper for EMFDRV_{Paint|Invert}Rgn
|
|
|
|
*/
|
2002-03-28 23:22:05 +01:00
|
|
|
static BOOL EMFDRV_PaintInvertRgn( PHYSDEV dev, HRGN hrgn, DWORD iType )
|
1999-05-02 12:15:16 +02:00
|
|
|
{
|
|
|
|
EMRINVERTRGN *emr;
|
|
|
|
DWORD size, rgnsize;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
|
|
|
|
rgnsize = GetRegionData( hrgn, 0, NULL );
|
2002-05-29 00:47:49 +02:00
|
|
|
size = rgnsize + offsetof(EMRINVERTRGN,RgnData);
|
2000-02-16 23:47:24 +01:00
|
|
|
emr = HeapAlloc( GetProcessHeap(), 0, size );
|
1999-05-02 12:15:16 +02:00
|
|
|
|
|
|
|
GetRegionData( hrgn, rgnsize, (RGNDATA *)&emr->RgnData );
|
|
|
|
|
|
|
|
emr->emr.iType = iType;
|
|
|
|
emr->emr.nSize = size;
|
|
|
|
emr->rclBounds.left = ((RGNDATA *)&emr->RgnData)->rdh.rcBound.left;
|
|
|
|
emr->rclBounds.top = ((RGNDATA *)&emr->RgnData)->rdh.rcBound.top;
|
|
|
|
emr->rclBounds.right = ((RGNDATA *)&emr->RgnData)->rdh.rcBound.right - 1;
|
|
|
|
emr->rclBounds.bottom = ((RGNDATA *)&emr->RgnData)->rdh.rcBound.bottom - 1;
|
|
|
|
emr->cbRgnData = rgnsize;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
ret = EMFDRV_WriteRecord( dev, &emr->emr );
|
1999-05-02 12:15:16 +02:00
|
|
|
if(ret)
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_UpdateBBox( dev, &emr->rclBounds );
|
2000-02-16 23:47:24 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, emr );
|
1999-05-02 12:15:16 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* EMFDRV_PaintRgn
|
|
|
|
*/
|
|
|
|
BOOL
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_PaintRgn( PHYSDEV dev, HRGN hrgn )
|
1999-05-02 12:15:16 +02:00
|
|
|
{
|
2002-03-28 23:22:05 +01:00
|
|
|
return EMFDRV_PaintInvertRgn( dev, hrgn, EMR_PAINTRGN );
|
1999-05-02 12:15:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* EMFDRV_InvertRgn
|
|
|
|
*/
|
|
|
|
BOOL
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_InvertRgn( PHYSDEV dev, HRGN hrgn )
|
1999-05-02 12:15:16 +02:00
|
|
|
{
|
2002-03-28 23:22:05 +01:00
|
|
|
return EMFDRV_PaintInvertRgn( dev, hrgn, EMR_INVERTRGN );
|
1999-05-02 12:15:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* EMFDRV_SetBkColor
|
|
|
|
*/
|
|
|
|
COLORREF
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_SetBkColor( PHYSDEV dev, COLORREF color )
|
1999-05-02 12:15:16 +02:00
|
|
|
{
|
|
|
|
EMRSETBKCOLOR emr;
|
|
|
|
|
|
|
|
emr.emr.iType = EMR_SETBKCOLOR;
|
|
|
|
emr.emr.nSize = sizeof(emr);
|
|
|
|
emr.crColor = color;
|
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
return EMFDRV_WriteRecord( dev, &emr.emr ) ? color : CLR_INVALID;
|
1999-05-02 12:15:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* EMFDRV_SetTextColor
|
|
|
|
*/
|
|
|
|
COLORREF
|
2002-03-28 23:22:05 +01:00
|
|
|
EMFDRV_SetTextColor( PHYSDEV dev, COLORREF color )
|
1999-05-02 12:15:16 +02:00
|
|
|
{
|
|
|
|
EMRSETTEXTCOLOR emr;
|
|
|
|
|
|
|
|
emr.emr.iType = EMR_SETTEXTCOLOR;
|
|
|
|
emr.emr.nSize = sizeof(emr);
|
|
|
|
emr.crColor = color;
|
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
return EMFDRV_WriteRecord( dev, &emr.emr ) ? color : CLR_INVALID;
|
1999-05-02 12:15:16 +02:00
|
|
|
}
|
2002-08-17 03:36:55 +02:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* EMFDRV_ExtTextOut
|
|
|
|
*/
|
|
|
|
BOOL EMFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
|
|
|
|
const RECT *lprect, LPCWSTR str, UINT count,
|
|
|
|
const INT *lpDx )
|
|
|
|
{
|
|
|
|
EMREXTTEXTOUTW *pemr;
|
|
|
|
DWORD nSize;
|
|
|
|
BOOL ret;
|
|
|
|
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*) dev;
|
|
|
|
|
2003-05-19 20:48:37 +02:00
|
|
|
nSize = sizeof(*pemr) + ((count+1) & ~1) * sizeof(WCHAR) + count * sizeof(INT);
|
2002-08-17 03:36:55 +02:00
|
|
|
|
|
|
|
TRACE("%s count %d nSize = %ld\n", debugstr_wn(str, count), count, nSize);
|
|
|
|
pemr = HeapAlloc(GetProcessHeap(), 0, nSize);
|
|
|
|
|
|
|
|
pemr->emr.iType = EMR_EXTTEXTOUTW;
|
|
|
|
pemr->emr.nSize = nSize;
|
|
|
|
|
|
|
|
/* FIXME: Calculation of these requires honouring alignment mode, escapement etc. */
|
|
|
|
pemr->rclBounds.left = pemr->rclBounds.right = x;
|
|
|
|
pemr->rclBounds.top = pemr->rclBounds.bottom = y;
|
|
|
|
|
|
|
|
pemr->iGraphicsMode = GetGraphicsMode(physDev->hdc);
|
|
|
|
pemr->exScale = pemr->eyScale = 1.0; /* FIXME */
|
|
|
|
|
|
|
|
pemr->emrtext.ptlReference.x = x;
|
|
|
|
pemr->emrtext.ptlReference.y = y;
|
|
|
|
pemr->emrtext.nChars = count;
|
|
|
|
pemr->emrtext.offString = sizeof(*pemr);
|
|
|
|
memcpy((char*)pemr + pemr->emrtext.offString, str, count * sizeof(WCHAR));
|
|
|
|
pemr->emrtext.fOptions = flags;
|
|
|
|
if(!lprect) {
|
|
|
|
pemr->emrtext.rcl.left = pemr->emrtext.rcl.top = 0;
|
|
|
|
pemr->emrtext.rcl.right = pemr->emrtext.rcl.bottom = -1;
|
|
|
|
} else {
|
|
|
|
pemr->emrtext.rcl.left = lprect->left;
|
|
|
|
pemr->emrtext.rcl.top = lprect->top;
|
|
|
|
pemr->emrtext.rcl.right = lprect->right;
|
|
|
|
pemr->emrtext.rcl.bottom = lprect->bottom;
|
|
|
|
}
|
|
|
|
|
2003-05-19 20:48:37 +02:00
|
|
|
pemr->emrtext.offDx = pemr->emrtext.offString + count * sizeof(WCHAR);
|
|
|
|
if(lpDx)
|
2002-08-17 03:36:55 +02:00
|
|
|
memcpy((char*)pemr + pemr->emrtext.offDx, lpDx, count * sizeof(INT));
|
2003-05-19 20:48:37 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
UINT i;
|
|
|
|
INT *dx = (INT *)((char*)pemr + pemr->emrtext.offDx);
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
GetCharWidth32W(physDev->hdc, str[i], str[i], &dx[i]);
|
|
|
|
}
|
|
|
|
}
|
2002-08-17 03:36:55 +02:00
|
|
|
|
|
|
|
ret = EMFDRV_WriteRecord( dev, &pemr->emr );
|
|
|
|
if(ret)
|
|
|
|
EMFDRV_UpdateBBox( dev, &pemr->rclBounds );
|
|
|
|
HeapFree( GetProcessHeap(), 0, pemr );
|
|
|
|
return ret;
|
|
|
|
}
|