Started implementing Enhanced MetaFile driver.

This commit is contained in:
Huw D M Davies 1999-05-02 10:15:16 +00:00 committed by Alexandre Julliard
parent ebdea25edc
commit 3a24f3f91e
12 changed files with 1550 additions and 99 deletions

View File

@ -46,6 +46,7 @@ LIBSUBDIRS = \
dlls/wnaspi32 \
files \
graphics \
graphics/enhmetafiledrv \
graphics/metafiledrv \
graphics/psdrv \
graphics/ttydrv \
@ -120,6 +121,7 @@ LIBOBJS = \
dlls/wnaspi32/wnaspi32.o \
files/files.o \
graphics/graphics.o \
graphics/enhmetafiledrv/enhmetafiledrv.o \
graphics/metafiledrv/metafiledrv.o \
graphics/psdrv/psdrv.o \
graphics/ttydrv/ttydrv.o \

2
configure vendored
View File

@ -4911,6 +4911,7 @@ dlls/wnaspi32/Makefile
documentation/Makefile
files/Makefile
graphics/Makefile
graphics/enhmetafiledrv/Makefile
graphics/metafiledrv/Makefile
graphics/psdrv/Makefile
graphics/ttydrv/Makefile
@ -5076,6 +5077,7 @@ dlls/wnaspi32/Makefile
documentation/Makefile
files/Makefile
graphics/Makefile
graphics/enhmetafiledrv/Makefile
graphics/metafiledrv/Makefile
graphics/psdrv/Makefile
graphics/ttydrv/Makefile

View File

@ -731,6 +731,7 @@ dlls/wnaspi32/Makefile
documentation/Makefile
files/Makefile
graphics/Makefile
graphics/enhmetafiledrv/Makefile
graphics/metafiledrv/Makefile
graphics/psdrv/Makefile
graphics/ttydrv/Makefile

View File

@ -0,0 +1 @@
Makefile

View File

@ -0,0 +1,19 @@
DEFS = @DLLFLAGS@ -D__WINE__
TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = enhmetafiledrv
C_SRCS = \
dc.c \
graphics.c \
init.c \
mapping.c \
objects.c
all: $(MODULE).o
@MAKE_RULES@
### Dependencies:

View File

@ -0,0 +1,123 @@
/*
* Enhanced MetaFile driver dc value functions
*
* Copyright 1999 Huw D M Davies
*
*/
#include "enhmetafiledrv.h"
INT EMFDRV_SaveDC( DC *dc )
{
EMRSAVEDC emr;
emr.emr.iType = EMR_SAVEDC;
emr.emr.nSize = sizeof(emr);
return EMFDRV_WriteRecord( dc, &emr.emr );
}
BOOL EMFDRV_RestoreDC( DC *dc, INT level )
{
EMRRESTOREDC emr;
emr.emr.iType = EMR_RESTOREDC;
emr.emr.nSize = sizeof(emr);
emr.iRelative = level;
return EMFDRV_WriteRecord( dc, &emr.emr );
}
UINT EMFDRV_SetTextAlign( DC *dc, UINT align )
{
EMRSETTEXTALIGN emr;
emr.emr.iType = EMR_SETTEXTALIGN;
emr.emr.nSize = sizeof(emr);
emr.iMode = align;
return EMFDRV_WriteRecord( dc, &emr.emr );
}
INT EMFDRV_SetBkMode( DC *dc, INT mode )
{
EMRSETBKMODE emr;
emr.emr.iType = EMR_SETBKMODE;
emr.emr.nSize = sizeof(emr);
emr.iMode = mode;
return EMFDRV_WriteRecord( dc, &emr.emr );
}
INT EMFDRV_SetROP2( DC *dc, INT rop )
{
EMRSETROP2 emr;
emr.emr.iType = EMR_SETROP2;
emr.emr.nSize = sizeof(emr);
emr.iMode = rop;
return EMFDRV_WriteRecord( dc, &emr.emr );
}
INT EMFDRV_SetPolyFillMode( DC *dc, INT mode )
{
EMRSETPOLYFILLMODE emr;
emr.emr.iType = EMR_SETPOLYFILLMODE;
emr.emr.nSize = sizeof(emr);
emr.iMode = mode;
return EMFDRV_WriteRecord( dc, &emr.emr );
}
INT EMFDRV_SetStretchBltMode( DC *dc, INT mode )
{
EMRSETSTRETCHBLTMODE emr;
emr.emr.iType = EMR_SETSTRETCHBLTMODE;
emr.emr.nSize = sizeof(emr);
emr.iMode = mode;
return EMFDRV_WriteRecord( dc, &emr.emr );
}
INT EMFDRV_SetMapMode( DC *dc, INT mode )
{
EMRSETMAPMODE emr;
emr.emr.iType = EMR_SETMAPMODE;
emr.emr.nSize = sizeof(emr);
emr.iMode = mode;
return EMFDRV_WriteRecord( dc, &emr.emr );
}
INT EMFDRV_ExcludeClipRect( DC *dc, INT left, INT top, INT right, INT bottom )
{
EMREXCLUDECLIPRECT emr;
emr.emr.iType = EMR_EXCLUDECLIPRECT;
emr.emr.nSize = sizeof(emr);
emr.rclClip.left = left;
emr.rclClip.top = top;
emr.rclClip.right = right;
emr.rclClip.bottom = bottom;
return EMFDRV_WriteRecord( dc, &emr.emr );
}
INT EMFDRV_IntersectClipRect( DC *dc, INT left, INT top, INT right, INT bottom)
{
EMRINTERSECTCLIPRECT emr;
emr.emr.iType = EMR_INTERSECTCLIPRECT;
emr.emr.nSize = sizeof(emr);
emr.rclClip.left = left;
emr.rclClip.top = top;
emr.rclClip.right = right;
emr.rclClip.bottom = bottom;
return EMFDRV_WriteRecord( dc, &emr.emr );
}
INT EMFDRV_OffsetClipRgn( DC *dc, INT x, INT y )
{
EMROFFSETCLIPRGN emr;
emr.emr.iType = EMR_OFFSETCLIPRGN;
emr.emr.nSize = sizeof(emr);
emr.ptlOffset.x = x;
emr.ptlOffset.y = y;
return EMFDRV_WriteRecord( dc, &emr.emr );
}
DWORD EMFDRV_SetMapperFlags( DC *dc, DWORD flags )
{
EMRSETMAPPERFLAGS emr;
emr.emr.iType = EMR_SETMAPPERFLAGS;
emr.emr.nSize = sizeof(emr);
emr.dwFlags = flags;
return EMFDRV_WriteRecord( dc, &emr.emr );
}

View File

@ -0,0 +1,608 @@
/*
* Enhanced MetaFile driver graphics functions
*
* Copyright 1999 Huw D M Davies
*/
#include <stdlib.h>
#include "gdi.h"
#include "dc.h"
#include "enhmetafiledrv.h"
#include "heap.h"
#include "debug.h"
DEFAULT_DEBUG_CHANNEL(enhmetafile)
/**********************************************************************
* EMFDRV_MoveToEx
*/
BOOL
EMFDRV_MoveToEx(DC *dc,INT x,INT y,LPPOINT pt)
{
EMRMOVETOEX emr;
emr.emr.iType = EMR_MOVETOEX;
emr.emr.nSize = sizeof(emr);
emr.ptl.x = x;
emr.ptl.y = y;
if(!EMFDRV_WriteRecord( dc, &emr.emr ))
return FALSE;
if (pt) {
pt->x = dc->w.CursPosX;
pt->y = dc->w.CursPosY;
}
dc->w.CursPosX = x;
dc->w.CursPosY = y;
return TRUE;
}
/***********************************************************************
* EMFDRV_LineTo
*/
BOOL
EMFDRV_LineTo( DC *dc, INT x, INT y )
{
EMRLINETO emr;
RECTL bounds;
emr.emr.iType = EMR_LINETO;
emr.emr.nSize = sizeof(emr);
emr.ptl.x = x;
emr.ptl.y = y;
if(!EMFDRV_WriteRecord( dc, &emr.emr ))
return FALSE;
bounds.left = MIN(x, dc->w.CursPosX);
bounds.top = MIN(y, dc->w.CursPosY);
bounds.right = MAX(x, dc->w.CursPosX);
bounds.bottom = MAX(y, dc->w.CursPosY);
EMFDRV_UpdateBBox( dc, &bounds );
dc->w.CursPosX = x;
dc->w.CursPosY = y;
return TRUE;
}
/***********************************************************************
* EMFDRV_ArcChordPie
*/
static BOOL
EMFDRV_ArcChordPie( DC *dc, INT left, INT top, INT right, INT bottom,
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;
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;}
right--;
bottom--;
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;
bounds.left = MIN(xinterStart, xinterEnd);
bounds.top = MIN(yinterStart, yinterEnd);
bounds.right = MAX(xinterStart, xinterEnd);
bounds.bottom = MAX(yinterStart, yinterEnd);
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. */
switch(i % 4) {
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;
}
if(!EMFDRV_WriteRecord( dc, &emr.emr ))
return FALSE;
EMFDRV_UpdateBBox( dc, &bounds );
return TRUE;
}
/***********************************************************************
* EMFDRV_Arc
*/
BOOL
EMFDRV_Arc( DC *dc, INT left, INT top, INT right, INT bottom,
INT xstart, INT ystart, INT xend, INT yend )
{
return EMFDRV_ArcChordPie( dc, left, top, right, bottom, xstart, ystart,
xend, yend, EMR_ARC );
}
/***********************************************************************
* EMFDRV_Pie
*/
BOOL
EMFDRV_Pie( DC *dc, INT left, INT top, INT right, INT bottom,
INT xstart, INT ystart, INT xend, INT yend )
{
return EMFDRV_ArcChordPie( dc, left, top, right, bottom, xstart, ystart,
xend, yend, EMR_PIE );
}
/***********************************************************************
* EMFDRV_Chord
*/
BOOL
EMFDRV_Chord( DC *dc, INT left, INT top, INT right, INT bottom,
INT xstart, INT ystart, INT xend, INT yend )
{
return EMFDRV_ArcChordPie( dc, left, top, right, bottom, xstart, ystart,
xend, yend, EMR_CHORD );
}
/***********************************************************************
* EMFDRV_Ellipse
*/
BOOL
EMFDRV_Ellipse( DC *dc, INT left, INT top, INT right, INT bottom )
{
EMRELLIPSE emr;
INT temp;
TRACE(enhmetafile, "%d,%d - %d,%d\n", left, top, right, bottom);
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;}
right--;
bottom--;
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;
EMFDRV_UpdateBBox( dc, &emr.rclBox );
return EMFDRV_WriteRecord( dc, &emr.emr );
}
/***********************************************************************
* EMFDRV_Rectangle
*/
BOOL
EMFDRV_Rectangle(DC *dc, INT left, INT top, INT right, INT bottom)
{
EMRRECTANGLE emr;
INT temp;
TRACE(enhmetafile, "%d,%d - %d,%d\n", left, top, right, bottom);
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;}
right--;
bottom--;
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;
EMFDRV_UpdateBBox( dc, &emr.rclBox );
return EMFDRV_WriteRecord( dc, &emr.emr );
}
/***********************************************************************
* EMFDRV_RoundRect
*/
BOOL
EMFDRV_RoundRect( DC *dc, INT left, INT top, INT right,
INT bottom, INT ell_width, INT ell_height )
{
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;}
right--;
bottom--;
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;
EMFDRV_UpdateBBox( dc, &emr.rclBox );
return EMFDRV_WriteRecord( dc, &emr.emr );
}
/***********************************************************************
* EMFDRV_SetPixel
*/
COLORREF
EMFDRV_SetPixel( DC *dc, INT x, INT y, COLORREF color )
{
return TRUE;
}
/**********************************************************************
* EMFDRV_Polylinegon
*
* Helper for EMFDRV_Poly{line|gon}
*/
static BOOL
EMFDRV_Polylinegon( DC *dc, const POINT* pt, INT count, DWORD iType )
{
EMRPOLYLINE *emr;
DWORD size;
INT i;
BOOL ret;
size = sizeof(EMRPOLYLINE) + sizeof(POINTL) * (count - 1);
emr = HeapAlloc( SystemHeap, 0, size );
emr->emr.iType = iType;
emr->emr.nSize = size;
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;
memcpy(emr->aptl, pt, size);
ret = EMFDRV_WriteRecord( dc, &emr->emr );
if(ret)
EMFDRV_UpdateBBox( dc, &emr->rclBounds );
HeapFree( SystemHeap, 0, emr );
return ret;
}
/**********************************************************************
* EMFDRV_Polyline
*/
BOOL
EMFDRV_Polyline( DC *dc, const POINT* pt, INT count )
{
return EMFDRV_Polylinegon( dc, pt, count, EMR_POLYLINE );
}
/**********************************************************************
* EMFDRV_Polygon
*/
BOOL
EMFDRV_Polygon( DC *dc, const POINT* pt, INT count )
{
if(count < 2) return FALSE;
return EMFDRV_Polylinegon( dc, pt, count, EMR_POLYGON );
}
/**********************************************************************
* EMFDRV_PolyPolylinegon
*
* Helper for EMFDRV_PolyPoly{line|gon}
*/
static BOOL
EMFDRV_PolyPolylinegon( DC *dc, const POINT* pt, const INT* counts, UINT polys,
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++;
}
}
size = sizeof(EMRPOLYPOLYLINE) + (polys - 1) * sizeof(DWORD) +
(cptl - 1) * sizeof(POINTL);
emr = HeapAlloc( SystemHeap, 0, size );
emr->emr.iType = iType;
emr->emr.nSize = size;
emr->rclBounds = bounds;
emr->nPolys = polys;
emr->cptl = cptl;
memcpy(emr->aPolyCounts, counts, polys * sizeof(DWORD));
memcpy(emr->aPolyCounts + polys, pt, cptl * sizeof(POINT));
ret = EMFDRV_WriteRecord( dc, &emr->emr );
if(ret)
EMFDRV_UpdateBBox( dc, &emr->rclBounds );
HeapFree( SystemHeap, 0, emr );
return ret;
}
/**********************************************************************
* EMFDRV_PolyPolyline
*/
BOOL
EMFDRV_PolyPolyline(DC *dc, const POINT* pt, const DWORD* counts, DWORD polys)
{
return EMFDRV_PolyPolylinegon( dc, pt, (INT *)counts, polys,
EMR_POLYPOLYLINE );
}
/**********************************************************************
* EMFDRV_PolyPolygon
*/
BOOL
EMFDRV_PolyPolygon( DC *dc, const POINT* pt, const INT* counts, UINT polys )
{
return EMFDRV_PolyPolylinegon( dc, pt, counts, polys, EMR_POLYPOLYGON );
}
/**********************************************************************
* EMFDRV_ExtFloodFill
*/
BOOL
EMFDRV_ExtFloodFill( DC *dc, INT x, INT y, COLORREF color, UINT fillType )
{
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;
return EMFDRV_WriteRecord( dc, &emr.emr );
}
/*********************************************************************
* EMFDRV_FillRgn
*/
BOOL EMFDRV_FillRgn( DC *dc, HRGN hrgn, HBRUSH hbrush )
{
EMRFILLRGN *emr;
DWORD size, rgnsize, index;
BOOL ret;
index = EMFDRV_CreateBrushIndirect( dc, hbrush );
if(!index) return FALSE;
rgnsize = GetRegionData( hrgn, 0, NULL );
size = rgnsize + sizeof(EMRFILLRGN) - 1;
emr = HeapAlloc( SystemHeap, 0, size );
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;
ret = EMFDRV_WriteRecord( dc, &emr->emr );
if(ret)
EMFDRV_UpdateBBox( dc, &emr->rclBounds );
HeapFree( SystemHeap, 0, emr );
return ret;
}
/*********************************************************************
* EMFDRV_FrameRgn
*/
BOOL EMFDRV_FrameRgn( DC *dc, HRGN hrgn, HBRUSH hbrush, INT width, INT height )
{
EMRFRAMERGN *emr;
DWORD size, rgnsize, index;
BOOL ret;
index = EMFDRV_CreateBrushIndirect( dc, hbrush );
if(!index) return FALSE;
rgnsize = GetRegionData( hrgn, 0, NULL );
size = rgnsize + sizeof(EMRFRAMERGN) - 1;
emr = HeapAlloc( SystemHeap, 0, size );
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;
ret = EMFDRV_WriteRecord( dc, &emr->emr );
if(ret)
EMFDRV_UpdateBBox( dc, &emr->rclBounds );
HeapFree( SystemHeap, 0, emr );
return ret;
}
/*********************************************************************
* EMFDRV_PaintInvertRgn
*
* Helper for EMFDRV_{Paint|Invert}Rgn
*/
static BOOL EMFDRV_PaintInvertRgn( DC *dc, HRGN hrgn, DWORD iType )
{
EMRINVERTRGN *emr;
DWORD size, rgnsize;
BOOL ret;
rgnsize = GetRegionData( hrgn, 0, NULL );
size = rgnsize + sizeof(EMRINVERTRGN) - 1;
emr = HeapAlloc( SystemHeap, 0, size );
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;
ret = EMFDRV_WriteRecord( dc, &emr->emr );
if(ret)
EMFDRV_UpdateBBox( dc, &emr->rclBounds );
HeapFree( SystemHeap, 0, emr );
return ret;
}
/**********************************************************************
* EMFDRV_PaintRgn
*/
BOOL
EMFDRV_PaintRgn( DC *dc, HRGN hrgn )
{
return EMFDRV_PaintInvertRgn( dc, hrgn, EMR_PAINTRGN );
}
/**********************************************************************
* EMFDRV_InvertRgn
*/
BOOL
EMFDRV_InvertRgn( DC *dc, HRGN hrgn )
{
return EMFDRV_PaintInvertRgn( dc, hrgn, EMR_INVERTRGN );
}
/**********************************************************************
* EMFDRV_SetBkColor
*/
COLORREF
EMFDRV_SetBkColor( DC *dc, COLORREF color )
{
EMRSETBKCOLOR emr;
emr.emr.iType = EMR_SETBKCOLOR;
emr.emr.nSize = sizeof(emr);
emr.crColor = color;
return EMFDRV_WriteRecord( dc, &emr.emr );
}
/**********************************************************************
* EMFDRV_SetTextColor
*/
COLORREF
EMFDRV_SetTextColor( DC *dc, COLORREF color )
{
EMRSETTEXTCOLOR emr;
emr.emr.iType = EMR_SETTEXTCOLOR;
emr.emr.nSize = sizeof(emr);
emr.crColor = color;
return EMFDRV_WriteRecord( dc, &emr.emr );
}

View File

@ -0,0 +1,337 @@
/*
* Enhanced MetaFile driver initialisation functions
*
* Copyright 1999 Huw D M Davies
*/
#include "windef.h"
#include "wingdi.h"
#include "dc.h"
#include "heap.h"
#include "global.h"
#include "enhmetafile.h"
#include "enhmetafiledrv.h"
#include "wine/winestring.h"
#include "debug.h"
#include <string.h>
DEFAULT_DEBUG_CHANNEL(enhmetafile)
static const DC_FUNCTIONS EMFDRV_Funcs =
{
EMFDRV_Arc, /* pArc */
NULL, /* pBitBlt */
NULL, /* pBitmapBits */
EMFDRV_Chord, /* pChord */
NULL, /* pCreateBitmap */
NULL, /* no implementation */ /* pCreateDC */
NULL, /* no implementation */ /* pDeleteDC */
NULL, /* pCreateDIBSection */
NULL, /* pCreateDIBSection16 */
NULL, /* pDeleteObject */
EMFDRV_Ellipse, /* pEllipse */
NULL, /* pEnumDeviceFonts */
NULL, /* pEscape */
EMFDRV_ExcludeClipRect, /* pExcludeClipRect */
EMFDRV_ExtFloodFill, /* pExtFloodFill */
NULL, /* pExtTextOut */
EMFDRV_FillRgn, /* pFillRgn */
EMFDRV_FrameRgn, /* pFrameRgn */
NULL, /* pGetCharWidth */
NULL, /* no implementation */ /* pGetPixel */
NULL, /* pGetTextExtentPoint */
NULL, /* pGetTextMetrics */
EMFDRV_IntersectClipRect, /* pIntersectClipRect */
EMFDRV_InvertRgn, /* pInvertRgn */
EMFDRV_LineTo, /* pLineTo */
NULL, /* pLoadOEMResource */
EMFDRV_MoveToEx, /* pMoveToEx */
EMFDRV_OffsetClipRgn, /* pOffsetClipRgn */
NULL, /* pOffsetViewportOrg */
NULL, /* pOffsetWindowOrg */
EMFDRV_PaintRgn, /* pPaintRgn */
NULL, /* pPatBlt */
EMFDRV_Pie, /* pPie */
EMFDRV_PolyPolygon, /* pPolyPolygon */
EMFDRV_PolyPolyline, /* pPolyPolyline */
EMFDRV_Polygon, /* pPolygon */
EMFDRV_Polyline, /* pPolyline */
NULL, /* pPolyBezier */
NULL, /* pRealizePalette */
EMFDRV_Rectangle, /* pRectangle */
EMFDRV_RestoreDC, /* pRestoreDC */
EMFDRV_RoundRect, /* pRoundRect */
EMFDRV_SaveDC, /* pSaveDC */
EMFDRV_ScaleViewportExt, /* pScaleViewportExt */
EMFDRV_ScaleWindowExt, /* pScaleWindowExt */
NULL, /* pSelectClipRgn */
EMFDRV_SelectObject, /* pSelectObject */
NULL, /* pSelectPalette */
EMFDRV_SetBkColor, /* pSetBkColor */
EMFDRV_SetBkMode, /* pSetBkMode */
NULL, /* pSetDeviceClipping */
NULL, /* pSetDIBitsToDevice */
EMFDRV_SetMapMode, /* pSetMapMode */
EMFDRV_SetMapperFlags, /* pSetMapperFlags */
NULL, /* pSetPixel */
EMFDRV_SetPolyFillMode, /* pSetPolyFillMode */
EMFDRV_SetROP2, /* pSetROP2 */
NULL, /* pSetRelAbs */
EMFDRV_SetStretchBltMode, /* pSetStretchBltMode */
EMFDRV_SetTextAlign, /* pSetTextAlign */
NULL, /* pSetTextCharacterExtra */
EMFDRV_SetTextColor, /* pSetTextColor */
NULL, /* pSetTextJustification */
EMFDRV_SetViewportExt, /* pSetViewportExt */
EMFDRV_SetViewportOrg, /* pSetViewportOrg */
EMFDRV_SetWindowExt, /* pSetWindowExt */
EMFDRV_SetWindowOrg, /* pSetWindowOrg */
NULL, /* pStretchBlt */
NULL /* pStretchDIBits */
};
/**********************************************************************
* EMFDRV_DeleteDC
*/
static BOOL EMFDRV_DeleteDC( DC *dc )
{
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dc->physDev;
if (physDev->emh) HeapFree( SystemHeap, 0, physDev->emh );
HeapFree( SystemHeap, 0, physDev );
dc->physDev = NULL;
GDI_FreeObject(dc->hSelf);
return TRUE;
}
/******************************************************************
* EMFDRV_WriteRecord
*
* Warning: this function can change the pointer to the metafile header.
*/
BOOL EMFDRV_WriteRecord( DC *dc, EMR *emr )
{
DWORD len;
ENHMETAHEADER *emh;
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dc->physDev;
physDev->emh->nBytes += emr->nSize;
physDev->emh->nRecords++;
if(physDev->hFile) {
TRACE(enhmetafile,"Writing record to disk\n");
if (!WriteFile(physDev->hFile, (char *)emr, emr->nSize, NULL, NULL))
return FALSE;
} else {
len = physDev->emh->nBytes;
emh = HeapReAlloc( SystemHeap, 0, physDev->emh, len );
if (!emh) return FALSE;
physDev->emh = emh;
memcpy((CHAR *)physDev->emh + physDev->emh->nBytes - emr->nSize, emr,
emr->nSize);
}
return TRUE;
}
/******************************************************************
* EMFDRV_UpdateBBox
*/
void EMFDRV_UpdateBBox( DC *dc, RECTL *rect )
{
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dc->physDev;
RECTL *bounds = &physDev->emh->rclBounds;
if(bounds->left > bounds->right) {/* first rect */
*bounds = *rect;
return;
}
bounds->left = MIN(bounds->left, rect->left);
bounds->top = MIN(bounds->top, rect->top);
bounds->right = MAX(bounds->right, rect->right);
bounds->bottom = MAX(bounds->bottom, rect->bottom);
return;
}
/******************************************************************
* EMFDRV_AddHandleDC
*
* Note: this function assumes that we never delete objects.
* If we do someday, we'll need to maintain a table to re-use deleted
* handles.
*/
int EMFDRV_AddHandleDC( DC *dc )
{
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dc->physDev;
physDev->emh->nHandles++;
return physDev->nextHandle++;
}
/**********************************************************************
* CreateEnhMetaFileA (GDI32.41)
*/
HDC WINAPI CreateEnhMetaFileA(
HDC hdc, /* optional reference DC */
LPCSTR filename, /* optional filename for disk metafiles */
const RECT *rect, /* optional bounding rectangle */
LPCSTR description /* optional description */
)
{
LPWSTR filenameW = NULL;
LPWSTR descriptionW = NULL;
HDC hReturnDC;
DWORD len1, len2;
if(filename)
filenameW = HEAP_strdupAtoW( GetProcessHeap(), 0, filename );
if(description) {
len1 = strlen(description);
len2 = strlen(description + len1 + 1);
descriptionW = HeapAlloc( GetProcessHeap(), 0, (len1 + len2 + 3) * 2);
lstrcpyAtoW(descriptionW, description );
lstrcpyAtoW(descriptionW + len1 + 1 , description + len1 + 1);
*(descriptionW + len1 + len2 + 2) = 0;
}
hReturnDC = CreateEnhMetaFileW(hdc, filenameW, rect, descriptionW);
if(filenameW)
HeapFree( GetProcessHeap(), 0, filenameW );
if(descriptionW)
HeapFree( GetProcessHeap(), 0, descriptionW );
return hReturnDC;
}
/**********************************************************************
* CreateEnhMetaFileW (GDI32.42)
*/
HDC WINAPI CreateEnhMetaFileW(
HDC hdc, /* optional reference DC */
LPCWSTR filename, /* optional filename for disk metafiles */
const RECT* rect, /* optional bounding rectangle */
LPCWSTR description /* optional description */
)
{
DC *dc;
EMFDRV_PDEVICE *physDev;
HFILE hFile;
DWORD size = 0, length = 0;
TRACE(enhmetafile, "'%s'\n", debugstr_w(filename) );
if (!(dc = DC_AllocDC( &EMFDRV_Funcs ))) return 0;
dc->header.wMagic = ENHMETAFILE_DC_MAGIC;
physDev = (EMFDRV_PDEVICE *)HeapAlloc(SystemHeap,0,sizeof(*physDev));
if (!physDev) {
GDI_HEAP_FREE( dc->hSelf );
return 0;
}
dc->physDev = physDev;
if(description) { /* App name\0Title\0\0 */
length = lstrlenW(description);
length += lstrlenW(description + length + 1);
length += 3;
length *= 2;
}
size = sizeof(ENHMETAHEADER) + (length + 3) / 4 * 4;
if (!(physDev->emh = HeapAlloc( SystemHeap, HEAP_ZERO_MEMORY, size))) {
HeapFree( SystemHeap, 0, physDev );
GDI_HEAP_FREE( dc->hSelf );
return 0;
}
physDev->nextHandle = 1;
physDev->hFile = 0;
physDev->emh->iType = EMR_HEADER;
physDev->emh->nSize = size;
physDev->emh->dSignature = ENHMETA_SIGNATURE;
physDev->emh->nVersion = 0x10000;
physDev->emh->nBytes = physDev->emh->nSize;
physDev->emh->nRecords = 1;
physDev->emh->nHandles = 1;
physDev->emh->rclBounds.left = physDev->emh->rclBounds.top = 0;
physDev->emh->rclBounds.right = physDev->emh->rclBounds.bottom = -1;
physDev->emh->nDescription = length / 2;
physDev->emh->offDescription = length ? sizeof(ENHMETAHEADER) : 0;
memcpy((char *)physDev->emh + sizeof(ENHMETAHEADER), description, length);
if (filename) /* disk based metafile */
{
if ((hFile = CreateFileW(filename, GENERIC_WRITE | GENERIC_READ, 0,
NULL, CREATE_ALWAYS, 0, -1)) == HFILE_ERROR) {
EMFDRV_DeleteDC( dc );
return 0;
}
if (!WriteFile( hFile, (LPSTR)physDev->emh, size, NULL, NULL )) {
EMFDRV_DeleteDC( dc );
return 0;
}
physDev->hFile = hFile;
}
TRACE(enhmetafile, "returning %04x\n", dc->hSelf);
return dc->hSelf;
}
/******************************************************************
* CloseEnhMetaFile
*/
HENHMETAFILE WINAPI CloseEnhMetaFile( HDC hdc /* metafile DC */ )
{
HENHMETAFILE hmf;
EMFDRV_PDEVICE *physDev;
DC *dc;
EMREOF emr;
HANDLE hMapping = 0;
TRACE(enhmetafile, "(%04x)\n", hdc );
if (!(dc = (DC *) GDI_GetObjPtr( hdc, ENHMETAFILE_DC_MAGIC ))) return 0;
physDev = (EMFDRV_PDEVICE *)dc->physDev;
emr.emr.iType = EMR_EOF;
emr.emr.nSize = sizeof(emr);
emr.nPalEntries = 0;
emr.offPalEntries = 0;
emr.nSizeLast = emr.emr.nSize;
EMFDRV_WriteRecord( dc, &emr.emr );
if (physDev->hFile) /* disk based metafile */
{
if (SetFilePointer(physDev->hFile, 0, NULL, FILE_BEGIN) != 0) {
EMFDRV_DeleteDC( dc );
return 0;
}
if (!WriteFile(physDev->hFile, (LPSTR)physDev->emh,
sizeof(*physDev->emh), NULL, NULL)) {
EMFDRV_DeleteDC( dc );
return 0;
}
HeapFree( SystemHeap, 0, physDev->emh );
hMapping = CreateFileMappingA(physDev->hFile, NULL, PAGE_READONLY, 0,
0, NULL);
TRACE(enhmetafile, "hMapping = %08x\n", hMapping );
physDev->emh = MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, 0);
TRACE(enhmetafile, "view = %p\n", physDev->emh );
}
hmf = EMF_Create_HENHMETAFILE( physDev->emh, physDev->hFile, hMapping );
physDev->emh = NULL; /* So it won't be deleted */
EMFDRV_DeleteDC( dc );
return hmf;
}

View File

@ -0,0 +1,86 @@
/*
* Enhanced MetaFile driver mapping functions
*
* Copyright 1999 Huw D M Davies
*/
#include "enhmetafiledrv.h"
BOOL EMFDRV_SetViewportExt( DC *dc, INT cx, INT cy )
{
EMRSETVIEWPORTEXTEX emr;
emr.emr.iType = EMR_SETVIEWPORTEXTEX;
emr.emr.nSize = sizeof(emr);
emr.szlExtent.cx = cx;
emr.szlExtent.cy = cy;
return EMFDRV_WriteRecord( dc, &emr.emr );
}
BOOL EMFDRV_SetWindowExt( DC *dc, INT cx, INT cy )
{
EMRSETWINDOWEXTEX emr;
emr.emr.iType = EMR_SETWINDOWEXTEX;
emr.emr.nSize = sizeof(emr);
emr.szlExtent.cx = cx;
emr.szlExtent.cy = cy;
return EMFDRV_WriteRecord( dc, &emr.emr );
}
BOOL EMFDRV_SetViewportOrg( DC *dc, INT x, INT y )
{
EMRSETVIEWPORTORGEX emr;
emr.emr.iType = EMR_SETVIEWPORTORGEX;
emr.emr.nSize = sizeof(emr);
emr.ptlOrigin.x = x;
emr.ptlOrigin.y = y;
return EMFDRV_WriteRecord( dc, &emr.emr );
}
BOOL EMFDRV_SetWindowOrg( DC *dc, INT x, INT y )
{
EMRSETWINDOWORGEX emr;
emr.emr.iType = EMR_SETWINDOWORGEX;
emr.emr.nSize = sizeof(emr);
emr.ptlOrigin.x = x;
emr.ptlOrigin.y = y;
return EMFDRV_WriteRecord( dc, &emr.emr );
}
BOOL EMFDRV_ScaleViewportExt( DC *dc, INT xNum, INT xDenom, INT yNum,
INT yDenom )
{
EMRSCALEVIEWPORTEXTEX emr;
emr.emr.iType = EMR_SCALEVIEWPORTEXTEX;
emr.emr.nSize = sizeof(emr);
emr.xNum = xNum;
emr.xDenom = xDenom;
emr.yNum = yNum;
emr.yDenom = yDenom;
return EMFDRV_WriteRecord( dc, &emr.emr );
}
BOOL EMFDRV_ScaleWindowExt( DC *dc, INT xNum, INT xDenom, INT yNum,
INT yDenom )
{
EMRSCALEWINDOWEXTEX emr;
emr.emr.iType = EMR_SCALEWINDOWEXTEX;
emr.emr.nSize = sizeof(emr);
emr.xNum = xNum;
emr.xDenom = xDenom;
emr.yNum = yNum;
emr.yDenom = yDenom;
return EMFDRV_WriteRecord( dc, &emr.emr );
}

View File

@ -0,0 +1,260 @@
/*
* Enhanced MetaFile objects
*
* Copyright 1999 Huw D M Davies
*/
#include <stdlib.h>
#include <stdio.h>
#include "bitmap.h"
#include "brush.h"
#include "font.h"
#include "enhmetafiledrv.h"
#include "pen.h"
#include "debug.h"
#include "heap.h"
DEFAULT_DEBUG_CHANNEL(enhmetafile)
/***********************************************************************
* EMFDRV_BITMAP_SelectObject
*/
static HBITMAP EMFDRV_BITMAP_SelectObject( DC * dc, HBITMAP hbitmap )
{
return 0;
}
/***********************************************************************
* EMFDRV_CreateBrushIndirect
*/
DWORD EMFDRV_CreateBrushIndirect( DC *dc, HBRUSH hBrush )
{
DWORD index = 0;
BRUSHOBJ *brushObj = (BRUSHOBJ *)GDI_GetObjPtr( hBrush, BRUSH_MAGIC );
switch (brushObj->logbrush.lbStyle) {
case BS_SOLID:
case BS_HATCHED:
case BS_NULL:
{
EMRCREATEBRUSHINDIRECT emr;
emr.emr.iType = EMR_CREATEBRUSHINDIRECT;
emr.emr.nSize = sizeof(emr);
emr.ihBrush = index = EMFDRV_AddHandleDC( dc );
emr.lb = brushObj->logbrush;
if(!EMFDRV_WriteRecord( dc, &emr.emr ))
index = 0;
}
break;
case BS_DIBPATTERN:
{
EMRCREATEDIBPATTERNBRUSHPT *emr;
DWORD bmSize, biSize, size;
BITMAPINFO *info = GlobalLock16(brushObj->logbrush.lbHatch);
if (info->bmiHeader.biCompression)
bmSize = info->bmiHeader.biSizeImage;
else
bmSize = DIB_GetDIBImageBytes(info->bmiHeader.biWidth,
info->bmiHeader.biHeight,
info->bmiHeader.biBitCount);
biSize = DIB_BitmapInfoSize(info, LOWORD(brushObj->logbrush.lbColor));
size = sizeof(EMRCREATEDIBPATTERNBRUSHPT) + biSize + bmSize;
emr = HeapAlloc( SystemHeap, 0, size );
if(!emr) break;;
emr->emr.iType = EMR_CREATEDIBPATTERNBRUSHPT;
emr->emr.nSize = size;
emr->ihBrush = index = EMFDRV_AddHandleDC( dc );
emr->iUsage = LOWORD(brushObj->logbrush.lbColor);
emr->offBmi = sizeof(EMRCREATEDIBPATTERNBRUSHPT);
emr->cbBmi = biSize;
emr->offBits = sizeof(EMRCREATEDIBPATTERNBRUSHPT) + biSize;
memcpy((char *)emr + sizeof(EMRCREATEDIBPATTERNBRUSHPT), info,
biSize + bmSize );
if(!EMFDRV_WriteRecord( dc, &emr->emr ))
index = 0;
HeapFree( SystemHeap, 0, emr );
GlobalUnlock16(brushObj->logbrush.lbHatch);
}
break;
case BS_PATTERN:
FIXME(enhmetafile, "Unsupported style %x\n",
brushObj->logbrush.lbStyle);
break;
default:
FIXME(enhmetafile, "Unknown style %x\n", brushObj->logbrush.lbStyle);
return FALSE;
}
GDI_HEAP_UNLOCK( hBrush );
return index;
}
/***********************************************************************
* EMFDRV_BRUSH_SelectObject
*/
static HBRUSH EMFDRV_BRUSH_SelectObject(DC *dc, HBRUSH hBrush )
{
EMRSELECTOBJECT emr;
DWORD index;
HBRUSH hOldBrush;
index = EMFDRV_CreateBrushIndirect(dc, hBrush );
if(!index) return FALSE;
emr.emr.iType = EMR_SELECTOBJECT;
emr.emr.nSize = sizeof(emr);
emr.ihObject = index;
if(!EMFDRV_WriteRecord( dc, &emr.emr ))
return FALSE;
hOldBrush = dc->w.hBrush;
dc->w.hBrush = hBrush;
return hOldBrush;
}
/******************************************************************
* EMFDRV_CreateFontIndirect
*/
static BOOL EMFDRV_CreateFontIndirect(DC *dc, HFONT hFont )
{
DWORD index = 0;
FONTOBJ *fontObj = (FONTOBJ *)GDI_GetObjPtr( hFont, FONT_MAGIC );
EMREXTCREATEFONTINDIRECTW emr;
int i;
emr.emr.iType = EMR_EXTCREATEFONTINDIRECTW;
emr.emr.nSize = (sizeof(emr) + 3) / 4 * 4;
emr.ihFont = index = EMFDRV_AddHandleDC( dc );
FONT_LogFont16To32W( &(fontObj->logfont), &(emr.elfw.elfLogFont) );
emr.elfw.elfFullName[0] = '\0';
emr.elfw.elfStyle[0] = '\0';
emr.elfw.elfVersion = 0;
emr.elfw.elfStyleSize = 0;
emr.elfw.elfMatch = 0;
emr.elfw.elfReserved = 0;
for(i = 0; i < ELF_VENDOR_SIZE; i++)
emr.elfw.elfVendorId[i] = 0;
emr.elfw.elfCulture = PAN_CULTURE_LATIN;
emr.elfw.elfPanose.bFamilyType = PAN_NO_FIT;
emr.elfw.elfPanose.bSerifStyle = PAN_NO_FIT;
emr.elfw.elfPanose.bWeight = PAN_NO_FIT;
emr.elfw.elfPanose.bProportion = PAN_NO_FIT;
emr.elfw.elfPanose.bContrast = PAN_NO_FIT;
emr.elfw.elfPanose.bStrokeVariation = PAN_NO_FIT;
emr.elfw.elfPanose.bArmStyle = PAN_NO_FIT;
emr.elfw.elfPanose.bLetterform = PAN_NO_FIT;
emr.elfw.elfPanose.bMidline = PAN_NO_FIT;
emr.elfw.elfPanose.bXHeight = PAN_NO_FIT;
if(!EMFDRV_WriteRecord( dc, &emr.emr ))
index = 0;
GDI_HEAP_UNLOCK( hFont );
return index;
}
/***********************************************************************
* EMFDRV_FONT_SelectObject
*/
static HFONT EMFDRV_FONT_SelectObject( DC * dc, HFONT hFont )
{
EMRSELECTOBJECT emr;
DWORD index;
HFONT hOldFont;
index = EMFDRV_CreateFontIndirect(dc, hFont );
if(!index) return FALSE;
emr.emr.iType = EMR_SELECTOBJECT;
emr.emr.nSize = sizeof(emr);
emr.ihObject = index;
if(!EMFDRV_WriteRecord( dc, &emr.emr ))
return FALSE;
hOldFont = dc->w.hFont;
dc->w.hFont = hFont;
return hOldFont;
}
/******************************************************************
* EMFDRV_CreatePenIndirect
*/
static HPEN EMFDRV_CreatePenIndirect(DC *dc, HPEN hPen )
{
EMRCREATEPEN emr;
PENOBJ *penObj = (PENOBJ *)GDI_GetObjPtr( hPen, PEN_MAGIC );
DWORD index = 0;
emr.emr.iType = EMR_CREATEPEN;
emr.emr.nSize = sizeof(emr);
emr.ihPen = index = EMFDRV_AddHandleDC( dc );
emr.lopn = penObj->logpen;
if(!EMFDRV_WriteRecord( dc, &emr.emr ))
index = 0;
GDI_HEAP_UNLOCK( hPen );
return index;
}
/******************************************************************
* EMFDRV_PEN_SelectObject
*/
static HPEN EMFDRV_PEN_SelectObject(DC *dc, HPEN hPen )
{
EMRSELECTOBJECT emr;
DWORD index;
HFONT hOldPen;
index = EMFDRV_CreatePenIndirect(dc, hPen );
if(!index) return FALSE;
emr.emr.iType = EMR_SELECTOBJECT;
emr.emr.nSize = sizeof(emr);
emr.ihObject = index;
if(!EMFDRV_WriteRecord( dc, &emr.emr ))
return FALSE;
hOldPen = dc->w.hPen;
dc->w.hPen = hPen;
return hOldPen;
}
/***********************************************************************
* EMFDRV_SelectObject
*/
HGDIOBJ EMFDRV_SelectObject( DC *dc, HGDIOBJ handle )
{
GDIOBJHDR * ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE );
HGDIOBJ ret = 0;
if (!ptr) return 0;
TRACE(enhmetafile, "hdc=%04x %04x\n", dc->hSelf, handle );
switch(ptr->wMagic)
{
case PEN_MAGIC:
ret = EMFDRV_PEN_SelectObject( dc, handle );
break;
case BRUSH_MAGIC:
ret = EMFDRV_BRUSH_SelectObject( dc, handle );
break;
case FONT_MAGIC:
ret = EMFDRV_FONT_SelectObject( dc, handle );
break;
case BITMAP_MAGIC:
ret = EMFDRV_BITMAP_SelectObject( dc, handle );
break;
}
GDI_HEAP_UNLOCK( handle );
return ret;
}

View File

@ -478,102 +478,3 @@ int MFDRV_AddHandleDC( DC *dc )
}
/********************************************************************
Enhanced Metafile driver initializations
This possibly should be moved to their own file/directory
at some point.
**********************************************************************/
/**********************************************************************
* CreateEnhMetaFile32A (GDI32.41)
*/
HDC WINAPI CreateEnhMetaFileA(
HDC hdc, /* optional reference DC */
LPCSTR filename, /* optional filename for disk metafiles */
const RECT *rect, /* optional bounding rectangle */
LPCSTR description /* optional description */
)
{
#if 0
DC *dc;
METAFILEDRV_PDEVICE *physDev;
HFILE hFile;
if (!(dc = MFDRV_AllocMetaFile())) return 0;
physDev = (METAFILEDRV_PDEVICE *)dc->physDev;
if (filename) /* disk based metafile */
{
physDev->mh->mtType = METAFILE_DISK;
if ((hFile = _lcreat( filename, 0 )) == HFILE_ERROR)
{
MFDRV_DeleteDC( dc );
return 0;
}
if (_lwrite( hFile, (LPSTR)physDev->mh,
sizeof(*physDev->mh)) == HFILE_ERROR)
{
MFDRV_DeleteDC( dc );
return 0;
}
physDev->mh->mtNoParameters = hFile; /* store file descriptor here */
/* windows probably uses this too*/
}
else /* memory based metafile */
physDev->mh->mtType = METAFILE_MEMORY;
TRACE(metafile, "returning %04x\n", dc->hSelf);
return dc->hSelf;
#endif
FIXME(metafile, "(0x%lx,%s,%p,%s): stub\n",
(DWORD)hdc, filename, rect, description);
return 0;
}
/**********************************************************************
* CreateEnhMetaFile32W (GDI32.42)
*/
HDC WINAPI CreateEnhMetaFileW(
HDC hdc, /* optional reference DC */
LPCWSTR filename, /* optional filename for disk metafiles */
const RECT* rect, /* optional bounding rectangle */
LPCWSTR description /* optional description */
)
{
LPSTR filenameA;
LPSTR descriptionA;
HDC hReturnDC;
filenameA = HEAP_strdupWtoA( GetProcessHeap(), 0, filename );
descriptionA = HEAP_strdupWtoA( GetProcessHeap(), 0, description );
hReturnDC = CreateEnhMetaFileA(hdc,
filenameA,
rect,
descriptionA);
HeapFree( GetProcessHeap(), 0, filenameA );
HeapFree( GetProcessHeap(), 0, descriptionA );
return hReturnDC;
}
HENHMETAFILE WINAPI CloseEnhMetaFile( HDC hdc /* metafile DC */ )
{
/* write EMR_EOF(0x0, 0x10, 0x14) */
return 0;
}

111
include/enhmetafiledrv.h Normal file
View File

@ -0,0 +1,111 @@
/*
* Enhanced MetaFile driver definitions
*/
#ifndef __WINE_ENHMETAFILEDRV_H
#define __WINE_ENHMETAFILEDRV_H
#include "wingdi.h"
#include "gdi.h"
/* Enhanced Metafile driver physical DC */
typedef struct
{
ENHMETAHEADER *emh; /* Pointer to enhanced metafile header */
UINT nextHandle; /* Next handle number */
HFILE hFile; /* HFILE for disk based MetaFile */
} EMFDRV_PDEVICE;
extern BOOL EMFDRV_WriteRecord( DC *dc, EMR *emr );
extern int EMFDRV_AddHandleDC( DC *dc );
extern void EMFDRV_UpdateBBox( DC *dc, RECTL *rect );
extern DWORD EMFDRV_CreateBrushIndirect( DC *dc, HBRUSH hBrush );
/* Metafile driver functions */
extern BOOL EMFDRV_Arc( DC *dc, INT left, INT top, INT right,
INT bottom, INT xstart, INT ystart, INT xend,
INT yend );
extern BOOL EMFDRV_BitBlt( DC *dcDst, INT xDst, INT yDst,
INT width, INT height, DC *dcSrc,
INT xSrc, INT ySrc, DWORD rop );
extern BOOL EMFDRV_Chord( DC *dc, INT left, INT top, INT right,
INT bottom, INT xstart, INT ystart, INT xend,
INT yend );
extern BOOL EMFDRV_Ellipse( DC *dc, INT left, INT top,
INT right, INT bottom );
extern INT EMFDRV_ExcludeClipRect( DC *dc, INT left, INT top, INT right,
INT bottom );
extern BOOL EMFDRV_ExtFloodFill( DC *dc, INT x, INT y,
COLORREF color, UINT fillType );
extern BOOL EMFDRV_ExtTextOut( DC *dc, INT x, INT y,
UINT flags, const RECT *lprect, LPCSTR str,
UINT count, const INT *lpDx );
extern BOOL EMFDRV_FillRgn( DC *dc, HRGN hrgn, HBRUSH hbrush );
extern BOOL EMFDRV_FrameRgn( DC *dc, HRGN hrgn, HBRUSH hbrush, INT width,
INT height );
extern INT EMFDRV_IntersectClipRect( DC *dc, INT left, INT top, INT right,
INT bottom );
extern BOOL EMFDRV_InvertRgn( DC *dc, HRGN hrgn );
extern BOOL EMFDRV_LineTo( DC *dc, INT x, INT y );
extern BOOL EMFDRV_MoveToEx( DC *dc, INT x, INT y, LPPOINT pt);
extern INT EMFDRV_OffsetClipRgn( DC *dc, INT x, INT y );
extern BOOL EMFDRV_OffsetViewportOrg( DC *dc, INT x, INT y );
extern BOOL EMFDRV_OffsetWindowOrg( DC *dc, INT x, INT y );
extern BOOL EMFDRV_PaintRgn( DC *dc, HRGN hrgn );
extern BOOL EMFDRV_PatBlt( DC *dc, INT left, INT top,
INT width, INT height, DWORD rop );
extern BOOL EMFDRV_Pie( DC *dc, INT left, INT top, INT right,
INT bottom, INT xstart, INT ystart, INT xend,
INT yend );
extern BOOL EMFDRV_PolyPolygon( DC *dc, const POINT* pt,
const INT* counts, UINT polys);
extern BOOL EMFDRV_PolyPolyline( DC *dc, const POINT* pt,
const DWORD* counts, DWORD polys);
extern BOOL EMFDRV_Polygon( DC *dc, const POINT* pt, INT count );
extern BOOL EMFDRV_Polyline( DC *dc, const POINT* pt,INT count);
extern BOOL EMFDRV_Rectangle( DC *dc, INT left, INT top,
INT right, INT bottom);
extern BOOL EMFDRV_RestoreDC( DC *dc, INT level );
extern BOOL EMFDRV_RoundRect( DC *dc, INT left, INT top,
INT right, INT bottom, INT ell_width,
INT ell_height );
extern INT EMFDRV_SaveDC( DC *dc );
extern BOOL EMFDRV_ScaleViewportExt( DC *dc, INT xNum,
INT xDenom, INT yNum, INT yDenom );
extern BOOL EMFDRV_ScaleWindowExt( DC *dc, INT xNum, INT xDenom,
INT yNum, INT yDenom );
extern HGDIOBJ EMFDRV_SelectObject( DC *dc, HGDIOBJ handle );
extern COLORREF EMFDRV_SetBkColor( DC *dc, COLORREF color );
extern INT EMFDRV_SetBkMode( DC *dc, INT mode );
extern INT EMFDRV_SetDIBitsToDevice( DC *dc, INT xDest, INT yDest,
DWORD cx, DWORD cy, INT xSrc,
INT ySrc, UINT startscan, UINT lines,
LPCVOID bits, const BITMAPINFO *info,
UINT coloruse );
extern INT EMFDRV_SetMapMode( DC *dc, INT mode );
extern DWORD EMFDRV_SetMapperFlags( DC *dc, DWORD flags );
extern COLORREF EMFDRV_SetPixel( DC *dc, INT x, INT y, COLORREF color );
extern INT EMFDRV_SetPolyFillMode( DC *dc, INT mode );
extern INT EMFDRV_SetROP2( DC *dc, INT rop );
extern INT EMFDRV_SetStretchBltMode( DC *dc, INT mode );
extern UINT EMFDRV_SetTextAlign( DC *dc, UINT align );
extern COLORREF EMFDRV_SetTextColor( DC *dc, COLORREF color );
extern BOOL EMFDRV_SetViewportExt( DC *dc, INT x, INT y );
extern BOOL EMFDRV_SetViewportOrg( DC *dc, INT x, INT y );
extern BOOL EMFDRV_SetWindowExt( DC *dc, INT x, INT y );
extern BOOL EMFDRV_SetWindowOrg( DC *dc, INT x, INT y );
extern BOOL EMFDRV_StretchBlt( DC *dcDst, INT xDst, INT yDst,
INT widthDst, INT heightDst,
DC *dcSrc, INT xSrc, INT ySrc,
INT widthSrc, INT heightSrc, DWORD rop );
extern INT EMFDRV_StretchDIBits( DC *dc, INT xDst, INT yDst, INT widthDst,
INT heightDst, INT xSrc, INT ySrc,
INT widthSrc, INT heightSrc,
const void *bits, const BITMAPINFO *info,
UINT wUsage, DWORD dwRop );
#endif /* __WINE_METAFILEDRV_H */