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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1999-05-02 12:15:16 +02:00
|
|
|
*/
|
|
|
|
|
2002-08-29 01:42:34 +02:00
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
2006-11-17 14:52:07 +01:00
|
|
|
#include <stdarg.h>
|
1999-05-02 12:15:16 +02:00
|
|
|
#include <stdlib.h>
|
1999-07-31 19:36:48 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
2006-11-17 14:52:07 +01:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.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
|
|
|
|
2016-06-17 08:08:22 +02:00
|
|
|
static const RECTL empty_bounds = { 0, 0, -1, -1 };
|
|
|
|
|
|
|
|
/* determine if we can use 16-bit points to store all the input points */
|
|
|
|
static BOOL can_use_short_points( const POINT *pts, UINT count )
|
|
|
|
{
|
|
|
|
UINT i;
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
if (((pts[i].x + 0x8000) & ~0xffff) || ((pts[i].y + 0x8000) & ~0xffff))
|
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* store points in either long or short format; return a pointer to the end of the stored data */
|
|
|
|
static void *store_points( POINTL *dest, const POINT *pts, UINT count, BOOL short_points )
|
|
|
|
{
|
|
|
|
if (short_points)
|
|
|
|
{
|
|
|
|
UINT i;
|
|
|
|
POINTS *dest_short = (POINTS *)dest;
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
dest_short[i].x = pts[i].x;
|
|
|
|
dest_short[i].y = pts[i].y;
|
|
|
|
}
|
|
|
|
return dest_short + count;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
memcpy( dest, pts, count * sizeof(*dest) );
|
|
|
|
return dest + count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compute the bounds of an array of points, optionally including the current position */
|
2016-07-29 16:09:35 +02:00
|
|
|
static void get_points_bounds( RECTL *bounds, const POINT *pts, UINT count, DC *dc )
|
2016-06-17 08:08:22 +02:00
|
|
|
{
|
|
|
|
UINT i;
|
|
|
|
|
2016-07-29 16:09:35 +02:00
|
|
|
if (dc)
|
2016-06-17 08:08:22 +02:00
|
|
|
{
|
2016-07-29 16:09:35 +02:00
|
|
|
bounds->left = bounds->right = dc->cur_pos.x;
|
|
|
|
bounds->top = bounds->bottom = dc->cur_pos.y;
|
2016-06-17 08:08:22 +02:00
|
|
|
}
|
|
|
|
else if (count)
|
|
|
|
{
|
|
|
|
bounds->left = bounds->right = pts[0].x;
|
|
|
|
bounds->top = bounds->bottom = pts[0].y;
|
|
|
|
}
|
|
|
|
else *bounds = empty_bounds;
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
bounds->left = min( bounds->left, pts[i].x );
|
|
|
|
bounds->right = max( bounds->right, pts[i].x );
|
|
|
|
bounds->top = min( bounds->top, pts[i].y );
|
|
|
|
bounds->bottom = max( bounds->bottom, pts[i].y );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-21 08:16:04 +02:00
|
|
|
/* helper for path stroke and fill functions */
|
|
|
|
static BOOL emfdrv_stroke_and_fill_path( PHYSDEV dev, INT type )
|
|
|
|
{
|
2016-07-29 16:09:26 +02:00
|
|
|
DC *dc = get_physdev_dc( dev );
|
2016-06-21 08:16:04 +02:00
|
|
|
EMRSTROKEANDFILLPATH emr;
|
2016-07-14 15:28:13 +02:00
|
|
|
struct gdi_path *path;
|
2016-06-21 08:16:04 +02:00
|
|
|
POINT *points;
|
|
|
|
BYTE *flags;
|
|
|
|
|
|
|
|
emr.emr.iType = type;
|
|
|
|
emr.emr.nSize = sizeof(emr);
|
|
|
|
|
2016-07-29 16:09:26 +02:00
|
|
|
if ((path = get_gdi_flat_path( dc, NULL )))
|
2016-06-21 08:16:04 +02:00
|
|
|
{
|
2016-07-14 15:28:13 +02:00
|
|
|
int count = get_gdi_path_data( path, &points, &flags );
|
2016-06-21 08:16:04 +02:00
|
|
|
get_points_bounds( &emr.rclBounds, points, count, 0 );
|
2016-07-14 15:28:13 +02:00
|
|
|
free_gdi_path( path );
|
2016-06-21 08:16:04 +02:00
|
|
|
}
|
|
|
|
else emr.rclBounds = empty_bounds;
|
|
|
|
|
|
|
|
if (!EMFDRV_WriteRecord( dev, &emr.emr )) return FALSE;
|
2016-07-14 15:28:13 +02:00
|
|
|
if (!path) return FALSE;
|
2016-06-21 08:16:04 +02:00
|
|
|
EMFDRV_UpdateBBox( dev, &emr.rclBounds );
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
*/
|
2011-07-13 14:56:12 +02:00
|
|
|
BOOL 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
|
|
|
|
*/
|
2011-07-13 14:56:12 +02:00
|
|
|
BOOL EMFDRV_LineTo( PHYSDEV dev, INT x, INT y )
|
1999-05-02 12:15:16 +02:00
|
|
|
{
|
2016-06-21 07:52:43 +02:00
|
|
|
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
|
2016-07-29 16:09:35 +02:00
|
|
|
DC *dc = get_physdev_dc( dev );
|
2004-03-11 01:37:46 +01:00
|
|
|
POINT pt;
|
1999-05-02 12:15:16 +02:00
|
|
|
EMRLINETO emr;
|
|
|
|
RECTL bounds;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2016-07-29 16:09:35 +02:00
|
|
|
pt = dc->cur_pos;
|
2004-03-11 01:37:46 +01:00
|
|
|
|
|
|
|
bounds.left = min(x, pt.x);
|
|
|
|
bounds.top = min(y, pt.y);
|
|
|
|
bounds.right = max(x, pt.x);
|
|
|
|
bounds.bottom = max(y, pt.y);
|
1999-05-02 12:15:16 +02:00
|
|
|
|
2016-04-28 18:47:43 +02:00
|
|
|
if(!physDev->path)
|
|
|
|
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 )
|
|
|
|
{
|
2016-06-21 07:52:43 +02:00
|
|
|
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
|
2016-07-29 16:09:35 +02:00
|
|
|
DC *dc = get_physdev_dc( dev );
|
1999-05-02 12:15:16 +02:00
|
|
|
INT temp, xCentre, yCentre, i;
|
|
|
|
double angleStart, angleEnd;
|
|
|
|
double xinterStart, yinterStart, xinterEnd, yinterEnd;
|
|
|
|
EMRARC emr;
|
|
|
|
RECTL bounds;
|
|
|
|
|
|
|
|
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;}
|
|
|
|
|
2016-07-29 16:09:35 +02: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;
|
2010-06-01 15:16:23 +02:00
|
|
|
emr.ptlEnd.y = yend;
|
1999-05-02 12:15:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* 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;
|
2012-10-24 19:27:08 +02:00
|
|
|
else if(bounds.bottom < yCentre) bounds.bottom = yCentre;
|
1999-05-02 12:15:16 +02:00
|
|
|
}
|
2016-06-17 06:51:05 +02:00
|
|
|
if (iType == EMR_ARCTO)
|
|
|
|
{
|
|
|
|
POINT pt;
|
2016-07-29 16:09:35 +02:00
|
|
|
pt = dc->cur_pos;
|
2016-06-17 06:51:05 +02:00
|
|
|
bounds.left = min( bounds.left, pt.x );
|
|
|
|
bounds.top = min( bounds.top, pt.y );
|
|
|
|
bounds.right = max( bounds.right, pt.x );
|
|
|
|
bounds.bottom = max( bounds.bottom, pt.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;
|
2016-04-28 18:48:18 +02:00
|
|
|
if(!physDev->path)
|
|
|
|
EMFDRV_UpdateBBox( dev, &bounds );
|
1999-05-02 12:15:16 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EMFDRV_Arc
|
|
|
|
*/
|
2011-07-13 14:56:12 +02:00
|
|
|
BOOL EMFDRV_Arc( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
|
|
|
|
INT xstart, INT ystart, INT xend, INT yend )
|
1999-05-02 12:15:16 +02:00
|
|
|
{
|
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 );
|
|
|
|
}
|
|
|
|
|
2016-06-17 06:51:05 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* EMFDRV_ArcTo
|
|
|
|
*/
|
|
|
|
BOOL EMFDRV_ArcTo( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
|
|
|
|
INT xstart, INT ystart, INT xend, INT yend )
|
|
|
|
{
|
|
|
|
return EMFDRV_ArcChordPie( dev, left, top, right, bottom, xstart, ystart,
|
|
|
|
xend, yend, EMR_ARCTO );
|
|
|
|
}
|
|
|
|
|
1999-05-02 12:15:16 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* EMFDRV_Pie
|
|
|
|
*/
|
2011-07-13 14:56:12 +02:00
|
|
|
BOOL EMFDRV_Pie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
|
|
|
|
INT xstart, INT ystart, INT xend, INT yend )
|
1999-05-02 12:15:16 +02:00
|
|
|
{
|
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
|
|
|
|
*/
|
2011-07-13 14:56:12 +02:00
|
|
|
BOOL EMFDRV_Chord( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
|
|
|
|
INT xstart, INT ystart, INT xend, INT yend )
|
1999-05-02 12:15:16 +02:00
|
|
|
{
|
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 );
|
|
|
|
}
|
|
|
|
|
2016-06-17 09:24:54 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* EMFDRV_AngleArc
|
|
|
|
*/
|
|
|
|
BOOL EMFDRV_AngleArc( PHYSDEV dev, INT x, INT y, DWORD radius, FLOAT start, FLOAT sweep )
|
|
|
|
{
|
|
|
|
EMRANGLEARC emr;
|
|
|
|
|
|
|
|
emr.emr.iType = EMR_ANGLEARC;
|
|
|
|
emr.emr.nSize = sizeof( emr );
|
|
|
|
emr.ptlCenter.x = x;
|
|
|
|
emr.ptlCenter.y = y;
|
|
|
|
emr.nRadius = radius;
|
|
|
|
emr.eStartAngle = start;
|
|
|
|
emr.eSweepAngle = sweep;
|
|
|
|
|
|
|
|
return EMFDRV_WriteRecord( dev, &emr.emr );
|
|
|
|
}
|
|
|
|
|
1999-05-02 12:15:16 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* EMFDRV_Ellipse
|
|
|
|
*/
|
2011-07-13 14:56:12 +02:00
|
|
|
BOOL EMFDRV_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
|
1999-05-02 12:15:16 +02:00
|
|
|
{
|
2016-06-21 07:52:43 +02:00
|
|
|
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
|
2016-07-29 16:09:35 +02:00
|
|
|
DC *dc = get_physdev_dc( dev );
|
1999-05-02 12:15:16 +02:00
|
|
|
EMRELLIPSE emr;
|
|
|
|
INT temp;
|
|
|
|
|
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;}
|
|
|
|
|
2016-07-29 16:09:35 +02: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;
|
|
|
|
|
2016-04-28 18:48:32 +02:00
|
|
|
if(!physDev->path)
|
|
|
|
EMFDRV_UpdateBBox( dev, &emr.rclBox );
|
2002-03-28 23:22:05 +01:00
|
|
|
return EMFDRV_WriteRecord( dev, &emr.emr );
|
1999-05-02 12:15:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EMFDRV_Rectangle
|
|
|
|
*/
|
2011-07-13 14:56:12 +02:00
|
|
|
BOOL EMFDRV_Rectangle(PHYSDEV dev, INT left, INT top, INT right, INT bottom)
|
1999-05-02 12:15:16 +02:00
|
|
|
{
|
2016-06-21 07:52:43 +02:00
|
|
|
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
|
2016-07-29 16:09:35 +02:00
|
|
|
DC *dc = get_physdev_dc( dev );
|
1999-05-02 12:15:16 +02:00
|
|
|
EMRRECTANGLE emr;
|
|
|
|
INT temp;
|
|
|
|
|
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;}
|
|
|
|
|
2016-07-29 16:09:35 +02: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;
|
|
|
|
|
2016-04-28 18:47:30 +02:00
|
|
|
if(!physDev->path)
|
|
|
|
EMFDRV_UpdateBBox( dev, &emr.rclBox );
|
2002-03-28 23:22:05 +01:00
|
|
|
return EMFDRV_WriteRecord( dev, &emr.emr );
|
1999-05-02 12:15:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EMFDRV_RoundRect
|
|
|
|
*/
|
2011-07-13 14:56:12 +02:00
|
|
|
BOOL 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 )
|
|
|
|
{
|
2016-06-21 07:52:43 +02:00
|
|
|
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
|
2016-07-29 16:09:35 +02:00
|
|
|
DC *dc = get_physdev_dc( dev );
|
1999-05-02 12:15:16 +02:00
|
|
|
EMRROUNDRECT emr;
|
|
|
|
INT temp;
|
|
|
|
|
|
|
|
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;}
|
|
|
|
|
2016-07-29 16:09:35 +02: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;
|
|
|
|
|
2016-04-28 18:48:46 +02:00
|
|
|
if(!physDev->path)
|
|
|
|
EMFDRV_UpdateBBox( dev, &emr.rclBox );
|
2002-03-28 23:22:05 +01:00
|
|
|
return EMFDRV_WriteRecord( dev, &emr.emr );
|
1999-05-02 12:15:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EMFDRV_SetPixel
|
|
|
|
*/
|
2011-07-13 14:56:12 +02:00
|
|
|
COLORREF EMFDRV_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color )
|
1999-05-02 12:15:16 +02:00
|
|
|
{
|
2003-10-09 00:34:15 +02:00
|
|
|
EMRSETPIXELV emr;
|
|
|
|
|
|
|
|
emr.emr.iType = EMR_SETPIXELV;
|
|
|
|
emr.emr.nSize = sizeof(emr);
|
|
|
|
emr.ptlPixel.x = x;
|
|
|
|
emr.ptlPixel.y = y;
|
|
|
|
emr.crColor = color;
|
|
|
|
|
|
|
|
if (EMFDRV_WriteRecord( dev, &emr.emr )) {
|
|
|
|
RECTL bounds;
|
|
|
|
bounds.left = bounds.right = x;
|
|
|
|
bounds.top = bounds.bottom = y;
|
|
|
|
EMFDRV_UpdateBBox( dev, &bounds );
|
|
|
|
return color;
|
|
|
|
}
|
|
|
|
return -1;
|
1999-05-02 12:15:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* 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
|
|
|
{
|
2016-06-21 07:52:43 +02:00
|
|
|
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
|
2016-07-29 16:09:35 +02:00
|
|
|
DC *dc = get_physdev_dc( dev );
|
1999-05-02 12:15:16 +02:00
|
|
|
EMRPOLYLINE *emr;
|
|
|
|
DWORD size;
|
2016-06-17 08:08:22 +02:00
|
|
|
BOOL ret, use_small_emr = can_use_short_points( pt, count );
|
1999-05-02 12:15:16 +02:00
|
|
|
|
2016-06-17 08:08:22 +02:00
|
|
|
size = use_small_emr ? offsetof( EMRPOLYLINE16, apts[count] ) : offsetof( EMRPOLYLINE, aptl[count] );
|
1999-05-02 12:15:16 +02:00
|
|
|
|
2000-02-16 23:47:24 +01:00
|
|
|
emr = HeapAlloc( GetProcessHeap(), 0, size );
|
2016-06-17 08:08:22 +02:00
|
|
|
emr->emr.iType = use_small_emr ? iType + EMR_POLYLINE16 - EMR_POLYLINE : iType;
|
1999-05-02 12:15:16 +02:00
|
|
|
emr->emr.nSize = size;
|
2016-04-28 18:48:58 +02:00
|
|
|
emr->cptl = count;
|
|
|
|
|
2016-06-17 08:08:22 +02:00
|
|
|
store_points( emr->aptl, pt, count, use_small_emr );
|
1999-05-02 12:15:16 +02:00
|
|
|
|
2016-06-17 08:08:22 +02:00
|
|
|
if (!physDev->path)
|
|
|
|
get_points_bounds( &emr->rclBounds, pt, count,
|
2016-07-29 16:09:35 +02:00
|
|
|
(iType == EMR_POLYBEZIERTO || iType == EMR_POLYLINETO) ? dc : 0 );
|
2016-04-28 18:47:04 +02:00
|
|
|
else
|
2016-06-17 08:08:22 +02:00
|
|
|
emr->rclBounds = empty_bounds;
|
1999-05-02 12:15:16 +02:00
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
ret = EMFDRV_WriteRecord( dev, &emr->emr );
|
2016-06-17 08:08:22 +02:00
|
|
|
if (ret && !physDev->path)
|
2004-03-30 01:04:32 +02:00
|
|
|
EMFDRV_UpdateBBox( dev, &emr->rclBounds );
|
|
|
|
HeapFree( GetProcessHeap(), 0, emr );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-05-02 12:15:16 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* EMFDRV_Polyline
|
|
|
|
*/
|
2011-07-13 14:56:12 +02:00
|
|
|
BOOL 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
|
|
|
}
|
|
|
|
|
2016-06-17 07:00:17 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* EMFDRV_PolylineTo
|
|
|
|
*/
|
|
|
|
BOOL EMFDRV_PolylineTo( PHYSDEV dev, const POINT* pt, INT count )
|
|
|
|
{
|
|
|
|
return EMFDRV_Polylinegon( dev, pt, count, EMR_POLYLINETO );
|
|
|
|
}
|
|
|
|
|
1999-05-02 12:15:16 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* EMFDRV_Polygon
|
|
|
|
*/
|
2011-07-13 14:56:12 +02:00
|
|
|
BOOL 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
|
|
|
}
|
|
|
|
|
2012-01-17 04:38:15 +01:00
|
|
|
/**********************************************************************
|
|
|
|
* EMFDRV_PolyBezier
|
|
|
|
*/
|
|
|
|
BOOL EMFDRV_PolyBezier( PHYSDEV dev, const POINT *pts, DWORD count )
|
|
|
|
{
|
|
|
|
return EMFDRV_Polylinegon( dev, pts, count, EMR_POLYBEZIER );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* EMFDRV_PolyBezierTo
|
|
|
|
*/
|
|
|
|
BOOL EMFDRV_PolyBezierTo( PHYSDEV dev, const POINT *pts, DWORD count )
|
|
|
|
{
|
|
|
|
return EMFDRV_Polylinegon( dev, pts, count, EMR_POLYBEZIERTO );
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2016-06-21 07:52:43 +02:00
|
|
|
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
|
1999-05-02 12:15:16 +02:00
|
|
|
EMRPOLYPOLYLINE *emr;
|
2016-06-17 08:08:22 +02:00
|
|
|
DWORD cptl = 0, poly, size;
|
|
|
|
BOOL ret, use_small_emr, bounds_valid = TRUE;
|
|
|
|
|
1999-05-02 12:15:16 +02:00
|
|
|
for(poly = 0; poly < polys; poly++) {
|
|
|
|
cptl += counts[poly];
|
2016-03-09 12:17:04 +01:00
|
|
|
if(counts[poly] < 2) bounds_valid = FALSE;
|
1999-05-02 12:15:16 +02:00
|
|
|
}
|
2016-03-09 12:17:04 +01:00
|
|
|
if(!cptl) bounds_valid = FALSE;
|
2016-06-17 08:08:22 +02:00
|
|
|
use_small_emr = can_use_short_points( pt, cptl );
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2016-03-09 12:17:03 +01:00
|
|
|
size = FIELD_OFFSET(EMRPOLYPOLYLINE, aPolyCounts[polys]);
|
|
|
|
if(use_small_emr)
|
|
|
|
size += cptl * sizeof(POINTS);
|
|
|
|
else
|
|
|
|
size += cptl * sizeof(POINTL);
|
1999-05-02 12:15:16 +02:00
|
|
|
|
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;
|
2016-03-09 12:17:03 +01:00
|
|
|
if(use_small_emr) emr->emr.iType += EMR_POLYPOLYLINE16 - EMR_POLYPOLYLINE;
|
|
|
|
|
1999-05-02 12:15:16 +02:00
|
|
|
emr->emr.nSize = size;
|
2016-04-28 18:49:07 +02:00
|
|
|
if(bounds_valid && !physDev->path)
|
2016-06-17 08:08:22 +02:00
|
|
|
get_points_bounds( &emr->rclBounds, pt, cptl, 0 );
|
2016-03-09 12:17:04 +01:00
|
|
|
else
|
2016-06-17 08:08:22 +02:00
|
|
|
emr->rclBounds = empty_bounds;
|
1999-05-02 12:15:16 +02:00
|
|
|
emr->nPolys = polys;
|
|
|
|
emr->cptl = cptl;
|
2016-03-09 12:17:03 +01:00
|
|
|
|
|
|
|
if(polys)
|
|
|
|
{
|
|
|
|
memcpy( emr->aPolyCounts, counts, polys * sizeof(DWORD) );
|
2016-06-17 08:08:22 +02:00
|
|
|
store_points( (POINTL *)(emr->aPolyCounts + polys), pt, cptl, use_small_emr );
|
2016-03-09 12:17:03 +01:00
|
|
|
}
|
|
|
|
|
2002-03-28 23:22:05 +01:00
|
|
|
ret = EMFDRV_WriteRecord( dev, &emr->emr );
|
2016-03-09 12:17:04 +01:00
|
|
|
if(ret && !bounds_valid)
|
|
|
|
{
|
|
|
|
ret = FALSE;
|
|
|
|
SetLastError( ERROR_INVALID_PARAMETER );
|
|
|
|
}
|
2016-04-28 18:49:07 +02:00
|
|
|
if(ret && !physDev->path)
|
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
|
|
|
|
*/
|
2011-07-13 14:56:12 +02:00
|
|
|
BOOL EMFDRV_PolyPolyline(PHYSDEV dev, const POINT* pt, const DWORD* counts, DWORD polys)
|
1999-05-02 12:15:16 +02:00
|
|
|
{
|
2004-11-30 22:38:57 +01:00
|
|
|
return EMFDRV_PolyPolylinegon( dev, pt, (const INT *)counts, polys,
|
1999-05-02 12:15:16 +02:00
|
|
|
EMR_POLYPOLYLINE );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* EMFDRV_PolyPolygon
|
|
|
|
*/
|
2011-07-13 14:56:12 +02:00
|
|
|
BOOL 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
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-06-17 08:08:57 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* EMFDRV_PolyDraw
|
|
|
|
*/
|
|
|
|
BOOL EMFDRV_PolyDraw( PHYSDEV dev, const POINT *pts, const BYTE *types, DWORD count )
|
|
|
|
{
|
2016-06-21 07:52:43 +02:00
|
|
|
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
|
2016-06-17 08:08:57 +02:00
|
|
|
EMRPOLYDRAW *emr;
|
|
|
|
BOOL ret;
|
|
|
|
BYTE *types_dest;
|
|
|
|
BOOL use_small_emr = can_use_short_points( pts, count );
|
|
|
|
DWORD size;
|
|
|
|
|
|
|
|
size = use_small_emr ? offsetof( EMRPOLYDRAW16, apts[count] ) : offsetof( EMRPOLYDRAW, aptl[count] );
|
|
|
|
size += (count + 3) & ~3;
|
|
|
|
|
|
|
|
if (!(emr = HeapAlloc( GetProcessHeap(), 0, size ))) return FALSE;
|
|
|
|
|
|
|
|
emr->emr.iType = use_small_emr ? EMR_POLYDRAW16 : EMR_POLYDRAW;
|
|
|
|
emr->emr.nSize = size;
|
|
|
|
emr->cptl = count;
|
|
|
|
|
|
|
|
types_dest = store_points( emr->aptl, pts, count, use_small_emr );
|
|
|
|
memcpy( types_dest, types, count );
|
|
|
|
if (count & 3) memset( types_dest + count, 0, 4 - (count & 3) );
|
|
|
|
|
|
|
|
if (!physDev->path)
|
|
|
|
get_points_bounds( &emr->rclBounds, pts, count, 0 );
|
|
|
|
else
|
|
|
|
emr->rclBounds = empty_bounds;
|
|
|
|
|
|
|
|
ret = EMFDRV_WriteRecord( dev, &emr->emr );
|
|
|
|
if (ret && !physDev->path) EMFDRV_UpdateBBox( dev, &emr->rclBounds );
|
|
|
|
HeapFree( GetProcessHeap(), 0, emr );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-05-02 12:15:16 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* EMFDRV_ExtFloodFill
|
|
|
|
*/
|
2011-07-13 14:56:12 +02:00
|
|
|
BOOL 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
|
|
|
|
*/
|
2011-07-13 14:56:12 +02: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
|
|
|
|
*/
|
2011-07-13 14:56:12 +02: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
|
|
|
|
*/
|
2011-07-13 14:56:12 +02:00
|
|
|
BOOL 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
|
|
|
|
*/
|
2011-07-13 14:56:12 +02:00
|
|
|
BOOL 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
|
|
|
}
|
|
|
|
|
2002-08-17 03:36:55 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* EMFDRV_ExtTextOut
|
|
|
|
*/
|
2011-07-13 14:56:12 +02:00
|
|
|
BOOL EMFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT *lprect,
|
|
|
|
LPCWSTR str, UINT count, const INT *lpDx )
|
2002-08-17 03:36:55 +02:00
|
|
|
{
|
2016-06-21 07:52:43 +02:00
|
|
|
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
|
2016-07-29 16:09:35 +02:00
|
|
|
DC *dc = get_physdev_dc( dev );
|
2002-08-17 03:36:55 +02:00
|
|
|
EMREXTTEXTOUTW *pemr;
|
|
|
|
DWORD nSize;
|
|
|
|
BOOL ret;
|
2003-10-09 21:44:35 +02:00
|
|
|
int textHeight = 0;
|
|
|
|
int textWidth = 0;
|
2016-07-29 16:09:35 +02:00
|
|
|
const UINT textAlign = dc->textAlign;
|
|
|
|
const INT graphicsMode = dc->GraphicsMode;
|
2011-02-18 23:56:01 +01:00
|
|
|
FLOAT exScale, eyScale;
|
2002-08-17 03:36:55 +02:00
|
|
|
|
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
|
|
|
|
2006-10-12 22:56:56 +02:00
|
|
|
TRACE("%s %s count %d nSize = %d\n", debugstr_wn(str, count),
|
2005-11-07 17:40:20 +01:00
|
|
|
wine_dbgstr_rect(lprect), count, nSize);
|
2003-10-09 21:44:35 +02:00
|
|
|
pemr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nSize);
|
2002-08-17 03:36:55 +02:00
|
|
|
|
2011-02-18 23:56:01 +01:00
|
|
|
if (graphicsMode == GM_COMPATIBLE)
|
|
|
|
{
|
2011-04-04 12:27:09 +02:00
|
|
|
const INT horzSize = GetDeviceCaps( dev->hdc, HORZSIZE );
|
|
|
|
const INT horzRes = GetDeviceCaps( dev->hdc, HORZRES );
|
|
|
|
const INT vertSize = GetDeviceCaps( dev->hdc, VERTSIZE );
|
|
|
|
const INT vertRes = GetDeviceCaps( dev->hdc, VERTRES );
|
2011-02-18 23:56:01 +01:00
|
|
|
SIZE wndext, vportext;
|
|
|
|
|
2011-04-04 12:27:09 +02:00
|
|
|
GetViewportExtEx( dev->hdc, &vportext );
|
|
|
|
GetWindowExtEx( dev->hdc, &wndext );
|
2011-02-18 23:56:01 +01:00
|
|
|
exScale = 100.0 * ((FLOAT)horzSize / (FLOAT)horzRes) /
|
|
|
|
((FLOAT)wndext.cx / (FLOAT)vportext.cx);
|
|
|
|
eyScale = 100.0 * ((FLOAT)vertSize / (FLOAT)vertRes) /
|
|
|
|
((FLOAT)wndext.cy / (FLOAT)vportext.cy);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
exScale = 0.0;
|
|
|
|
eyScale = 0.0;
|
|
|
|
}
|
|
|
|
|
2002-08-17 03:36:55 +02:00
|
|
|
pemr->emr.iType = EMR_EXTTEXTOUTW;
|
|
|
|
pemr->emr.nSize = nSize;
|
2011-02-18 23:56:01 +01:00
|
|
|
pemr->iGraphicsMode = graphicsMode;
|
|
|
|
pemr->exScale = exScale;
|
|
|
|
pemr->eyScale = eyScale;
|
2002-08-17 03:36:55 +02:00
|
|
|
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-10-09 21:44:35 +02:00
|
|
|
pemr->emrtext.offDx = pemr->emrtext.offString + ((count+1) & ~1) * sizeof(WCHAR);
|
|
|
|
if(lpDx) {
|
|
|
|
UINT i;
|
|
|
|
SIZE strSize;
|
|
|
|
memcpy((char*)pemr + pemr->emrtext.offDx, lpDx, count * sizeof(INT));
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
textWidth += lpDx[i];
|
|
|
|
}
|
2011-04-04 12:27:09 +02:00
|
|
|
if (GetTextExtentPoint32W( dev->hdc, str, count, &strSize ))
|
2006-10-22 21:48:19 +02:00
|
|
|
textHeight = strSize.cy;
|
2003-10-09 21:44:35 +02:00
|
|
|
}
|
|
|
|
else {
|
2003-05-19 20:48:37 +02:00
|
|
|
UINT i;
|
|
|
|
INT *dx = (INT *)((char*)pemr + pemr->emrtext.offDx);
|
2003-10-09 21:44:35 +02:00
|
|
|
SIZE charSize;
|
|
|
|
for (i = 0; i < count; i++) {
|
2011-04-04 12:27:09 +02:00
|
|
|
if (GetTextExtentPoint32W( dev->hdc, str + i, 1, &charSize )) {
|
2006-10-22 21:48:19 +02:00
|
|
|
dx[i] = charSize.cx;
|
|
|
|
textWidth += charSize.cx;
|
|
|
|
textHeight = max(textHeight, charSize.cy);
|
|
|
|
}
|
2003-05-19 20:48:37 +02:00
|
|
|
}
|
|
|
|
}
|
2002-08-17 03:36:55 +02:00
|
|
|
|
2016-04-28 18:47:14 +02:00
|
|
|
if (physDev->path)
|
2008-05-25 14:31:20 +02:00
|
|
|
{
|
|
|
|
pemr->rclBounds.left = pemr->rclBounds.top = 0;
|
|
|
|
pemr->rclBounds.right = pemr->rclBounds.bottom = -1;
|
|
|
|
goto no_bounds;
|
|
|
|
}
|
|
|
|
|
2016-04-28 18:47:14 +02:00
|
|
|
/* FIXME: handle font escapement */
|
2003-10-09 21:44:35 +02:00
|
|
|
switch (textAlign & (TA_LEFT | TA_RIGHT | TA_CENTER)) {
|
|
|
|
case TA_CENTER: {
|
|
|
|
pemr->rclBounds.left = x - (textWidth / 2) - 1;
|
|
|
|
pemr->rclBounds.right = x + (textWidth / 2) + 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TA_RIGHT: {
|
|
|
|
pemr->rclBounds.left = x - textWidth - 1;
|
|
|
|
pemr->rclBounds.right = x;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: { /* TA_LEFT */
|
|
|
|
pemr->rclBounds.left = x;
|
|
|
|
pemr->rclBounds.right = x + textWidth + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (textAlign & (TA_TOP | TA_BOTTOM | TA_BASELINE)) {
|
|
|
|
case TA_BASELINE: {
|
|
|
|
TEXTMETRICW tm;
|
2011-04-04 12:27:09 +02:00
|
|
|
if (!GetTextMetricsW( dev->hdc, &tm ))
|
2006-10-22 21:48:19 +02:00
|
|
|
tm.tmDescent = 0;
|
2003-10-09 21:44:35 +02:00
|
|
|
/* Play safe here... it's better to have a bounding box */
|
|
|
|
/* that is too big than too small. */
|
|
|
|
pemr->rclBounds.top = y - textHeight - 1;
|
|
|
|
pemr->rclBounds.bottom = y + tm.tmDescent + 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TA_BOTTOM: {
|
|
|
|
pemr->rclBounds.top = y - textHeight - 1;
|
|
|
|
pemr->rclBounds.bottom = y;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: { /* TA_TOP */
|
|
|
|
pemr->rclBounds.top = y;
|
|
|
|
pemr->rclBounds.bottom = y + textHeight + 1;
|
|
|
|
}
|
|
|
|
}
|
2009-11-11 13:07:10 +01:00
|
|
|
EMFDRV_UpdateBBox( dev, &pemr->rclBounds );
|
2003-10-09 21:44:35 +02:00
|
|
|
|
2008-05-25 14:31:20 +02:00
|
|
|
no_bounds:
|
2002-08-17 03:36:55 +02:00
|
|
|
ret = EMFDRV_WriteRecord( dev, &pemr->emr );
|
|
|
|
HeapFree( GetProcessHeap(), 0, pemr );
|
|
|
|
return ret;
|
|
|
|
}
|
2016-04-08 12:40:56 +02:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* EMFDRV_GradientFill
|
|
|
|
*/
|
|
|
|
BOOL EMFDRV_GradientFill( PHYSDEV dev, TRIVERTEX *vert_array, ULONG nvert,
|
|
|
|
void *grad_array, ULONG ngrad, ULONG mode )
|
|
|
|
{
|
|
|
|
EMRGRADIENTFILL *emr;
|
|
|
|
ULONG i, pt, size, num_pts = ngrad * (mode == GRADIENT_FILL_TRIANGLE ? 3 : 2);
|
|
|
|
const ULONG *pts = (const ULONG *)grad_array;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
size = FIELD_OFFSET(EMRGRADIENTFILL, Ver[nvert]) + num_pts * sizeof(pts[0]);
|
|
|
|
|
|
|
|
emr = HeapAlloc( GetProcessHeap(), 0, size );
|
|
|
|
if (!emr) return FALSE;
|
|
|
|
|
|
|
|
for (i = 0; i < num_pts; i++)
|
|
|
|
{
|
|
|
|
pt = pts[i];
|
|
|
|
|
|
|
|
if (i == 0)
|
|
|
|
{
|
|
|
|
emr->rclBounds.left = emr->rclBounds.right = vert_array[pt].x;
|
|
|
|
emr->rclBounds.top = emr->rclBounds.bottom = vert_array[pt].y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (vert_array[pt].x < emr->rclBounds.left)
|
|
|
|
emr->rclBounds.left = vert_array[pt].x;
|
|
|
|
else if (vert_array[pt].x > emr->rclBounds.right)
|
|
|
|
emr->rclBounds.right = vert_array[pt].x;
|
|
|
|
if (vert_array[pt].y < emr->rclBounds.top)
|
|
|
|
emr->rclBounds.top = vert_array[pt].y;
|
|
|
|
else if (vert_array[pt].y > emr->rclBounds.bottom)
|
|
|
|
emr->rclBounds.bottom = vert_array[pt].y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
emr->rclBounds.right--;
|
|
|
|
emr->rclBounds.bottom--;
|
|
|
|
|
|
|
|
emr->emr.iType = EMR_GRADIENTFILL;
|
|
|
|
emr->emr.nSize = size;
|
|
|
|
emr->nVer = nvert;
|
|
|
|
emr->nTri = ngrad;
|
|
|
|
emr->ulMode = mode;
|
|
|
|
memcpy( emr->Ver, vert_array, nvert * sizeof(vert_array[0]) );
|
|
|
|
memcpy( emr->Ver + nvert, pts, num_pts * sizeof(pts[0]) );
|
|
|
|
|
|
|
|
EMFDRV_UpdateBBox( dev, &emr->rclBounds );
|
|
|
|
ret = EMFDRV_WriteRecord( dev, &emr->emr );
|
|
|
|
HeapFree( GetProcessHeap(), 0, emr );
|
|
|
|
return ret;
|
|
|
|
}
|
2016-06-21 08:16:04 +02:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* EMFDRV_FillPath
|
|
|
|
*/
|
|
|
|
BOOL EMFDRV_FillPath( PHYSDEV dev )
|
|
|
|
{
|
|
|
|
return emfdrv_stroke_and_fill_path( dev, EMR_FILLPATH );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* EMFDRV_StrokeAndFillPath
|
|
|
|
*/
|
|
|
|
BOOL EMFDRV_StrokeAndFillPath( PHYSDEV dev )
|
|
|
|
{
|
|
|
|
return emfdrv_stroke_and_fill_path( dev, EMR_STROKEANDFILLPATH );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2016-07-07 05:35:04 +02:00
|
|
|
* EMFDRV_StrokePath
|
2016-06-21 08:16:04 +02:00
|
|
|
*/
|
|
|
|
BOOL EMFDRV_StrokePath( PHYSDEV dev )
|
|
|
|
{
|
|
|
|
return emfdrv_stroke_and_fill_path( dev, EMR_STROKEPATH );
|
|
|
|
}
|