2 * Enhanced MetaFile driver graphics functions
4 * Copyright 1999 Huw D M Davies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/port.h"
31 #include "enhmfdrv/enhmetafiledrv.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(enhmetafile);
36 /**********************************************************************
40 EMFDRV_MoveTo(PHYSDEV dev, INT x, INT y)
44 emr.emr.iType = EMR_MOVETOEX;
45 emr.emr.nSize = sizeof(emr);
49 return EMFDRV_WriteRecord( dev, &emr.emr );
52 /***********************************************************************
56 EMFDRV_LineTo( PHYSDEV dev, INT x, INT y )
61 EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
63 emr.emr.iType = EMR_LINETO;
64 emr.emr.nSize = sizeof(emr);
68 if(!EMFDRV_WriteRecord( dev, &emr.emr ))
71 GetCurrentPositionEx(physDev->hdc, &pt);
73 bounds.left = min(x, pt.x);
74 bounds.top = min(y, pt.y);
75 bounds.right = max(x, pt.x);
76 bounds.bottom = max(y, pt.y);
78 EMFDRV_UpdateBBox( dev, &bounds );
84 /***********************************************************************
88 EMFDRV_ArcChordPie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
89 INT xstart, INT ystart, INT xend, INT yend, DWORD iType )
91 INT temp, xCentre, yCentre, i;
92 double angleStart, angleEnd;
93 double xinterStart, yinterStart, xinterEnd, yinterEnd;
96 EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
98 if(left == right || top == bottom) return FALSE;
100 if(left > right) {temp = left; left = right; right = temp;}
101 if(top > bottom) {temp = top; top = bottom; bottom = temp;}
103 if(GetGraphicsMode(physDev->hdc) == GM_COMPATIBLE) {
108 emr.emr.iType = iType;
109 emr.emr.nSize = sizeof(emr);
110 emr.rclBox.left = left;
111 emr.rclBox.top = top;
112 emr.rclBox.right = right;
113 emr.rclBox.bottom = bottom;
114 emr.ptlStart.x = xstart;
115 emr.ptlStart.y = ystart;
120 /* Now calculate the BBox */
121 xCentre = (left + right + 1) / 2;
122 yCentre = (top + bottom + 1) / 2;
129 /* invert y co-ords to get angle anti-clockwise from x-axis */
130 angleStart = atan2( -(double)ystart, (double)xstart);
131 angleEnd = atan2( -(double)yend, (double)xend);
133 /* These are the intercepts of the start/end lines with the arc */
135 xinterStart = (right - left + 1)/2 * cos(angleStart) + xCentre;
136 yinterStart = -(bottom - top + 1)/2 * sin(angleStart) + yCentre;
137 xinterEnd = (right - left + 1)/2 * cos(angleEnd) + xCentre;
138 yinterEnd = -(bottom - top + 1)/2 * sin(angleEnd) + yCentre;
140 if(angleStart < 0) angleStart += 2 * M_PI;
141 if(angleEnd < 0) angleEnd += 2 * M_PI;
142 if(angleEnd < angleStart) angleEnd += 2 * M_PI;
144 bounds.left = min(xinterStart, xinterEnd);
145 bounds.top = min(yinterStart, yinterEnd);
146 bounds.right = max(xinterStart, xinterEnd);
147 bounds.bottom = max(yinterStart, yinterEnd);
149 for(i = 0; i <= 8; i++) {
150 if(i * M_PI / 2 < angleStart) /* loop until we're past start */
152 if(i * M_PI / 2 > angleEnd) /* if we're past end we're finished */
155 /* the arc touches the rectangle at the start of quadrant i, so adjust
156 BBox to reflect this. */
160 bounds.right = right;
169 bounds.bottom = bottom;
174 /* If we're drawing a pie then make sure we include the centre */
175 if(iType == EMR_PIE) {
176 if(bounds.left > xCentre) bounds.left = xCentre;
177 else if(bounds.right < xCentre) bounds.right = xCentre;
178 if(bounds.top > yCentre) bounds.top = yCentre;
179 else if(bounds.bottom < yCentre) bounds.right = yCentre;
181 if(!EMFDRV_WriteRecord( dev, &emr.emr ))
183 EMFDRV_UpdateBBox( dev, &bounds );
188 /***********************************************************************
192 EMFDRV_Arc( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
193 INT xstart, INT ystart, INT xend, INT yend )
195 return EMFDRV_ArcChordPie( dev, left, top, right, bottom, xstart, ystart,
196 xend, yend, EMR_ARC );
199 /***********************************************************************
203 EMFDRV_Pie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
204 INT xstart, INT ystart, INT xend, INT yend )
206 return EMFDRV_ArcChordPie( dev, left, top, right, bottom, xstart, ystart,
207 xend, yend, EMR_PIE );
211 /***********************************************************************
215 EMFDRV_Chord( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
216 INT xstart, INT ystart, INT xend, INT yend )
218 return EMFDRV_ArcChordPie( dev, left, top, right, bottom, xstart, ystart,
219 xend, yend, EMR_CHORD );
222 /***********************************************************************
226 EMFDRV_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
230 EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
232 TRACE("%d,%d - %d,%d\n", left, top, right, bottom);
234 if(left == right || top == bottom) return FALSE;
236 if(left > right) {temp = left; left = right; right = temp;}
237 if(top > bottom) {temp = top; top = bottom; bottom = temp;}
239 if(GetGraphicsMode(physDev->hdc) == GM_COMPATIBLE) {
244 emr.emr.iType = EMR_ELLIPSE;
245 emr.emr.nSize = sizeof(emr);
246 emr.rclBox.left = left;
247 emr.rclBox.top = top;
248 emr.rclBox.right = right;
249 emr.rclBox.bottom = bottom;
251 EMFDRV_UpdateBBox( dev, &emr.rclBox );
252 return EMFDRV_WriteRecord( dev, &emr.emr );
255 /***********************************************************************
259 EMFDRV_Rectangle(PHYSDEV dev, INT left, INT top, INT right, INT bottom)
263 EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
265 TRACE("%d,%d - %d,%d\n", left, top, right, bottom);
267 if(left == right || top == bottom) return FALSE;
269 if(left > right) {temp = left; left = right; right = temp;}
270 if(top > bottom) {temp = top; top = bottom; bottom = temp;}
272 if(GetGraphicsMode(physDev->hdc) == GM_COMPATIBLE) {
277 emr.emr.iType = EMR_RECTANGLE;
278 emr.emr.nSize = sizeof(emr);
279 emr.rclBox.left = left;
280 emr.rclBox.top = top;
281 emr.rclBox.right = right;
282 emr.rclBox.bottom = bottom;
284 EMFDRV_UpdateBBox( dev, &emr.rclBox );
285 return EMFDRV_WriteRecord( dev, &emr.emr );
288 /***********************************************************************
292 EMFDRV_RoundRect( PHYSDEV dev, INT left, INT top, INT right,
293 INT bottom, INT ell_width, INT ell_height )
297 EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
299 if(left == right || top == bottom) return FALSE;
301 if(left > right) {temp = left; left = right; right = temp;}
302 if(top > bottom) {temp = top; top = bottom; bottom = temp;}
304 if(GetGraphicsMode(physDev->hdc) == GM_COMPATIBLE) {
309 emr.emr.iType = EMR_ROUNDRECT;
310 emr.emr.nSize = sizeof(emr);
311 emr.rclBox.left = left;
312 emr.rclBox.top = top;
313 emr.rclBox.right = right;
314 emr.rclBox.bottom = bottom;
315 emr.szlCorner.cx = ell_width;
316 emr.szlCorner.cy = ell_height;
318 EMFDRV_UpdateBBox( dev, &emr.rclBox );
319 return EMFDRV_WriteRecord( dev, &emr.emr );
322 /***********************************************************************
326 EMFDRV_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color )
330 emr.emr.iType = EMR_SETPIXELV;
331 emr.emr.nSize = sizeof(emr);
336 if (EMFDRV_WriteRecord( dev, &emr.emr )) {
338 bounds.left = bounds.right = x;
339 bounds.top = bounds.bottom = y;
340 EMFDRV_UpdateBBox( dev, &bounds );
346 /**********************************************************************
349 * Helper for EMFDRV_Poly{line|gon}
352 EMFDRV_Polylinegon( PHYSDEV dev, const POINT* pt, INT count, DWORD iType )
359 size = sizeof(EMRPOLYLINE) + sizeof(POINTL) * (count - 1);
361 emr = HeapAlloc( GetProcessHeap(), 0, size );
362 emr->emr.iType = iType;
363 emr->emr.nSize = size;
365 emr->rclBounds.left = emr->rclBounds.right = pt[0].x;
366 emr->rclBounds.top = emr->rclBounds.bottom = pt[0].y;
368 for(i = 1; i < count; i++) {
369 if(pt[i].x < emr->rclBounds.left)
370 emr->rclBounds.left = pt[i].x;
371 else if(pt[i].x > emr->rclBounds.right)
372 emr->rclBounds.right = pt[i].x;
373 if(pt[i].y < emr->rclBounds.top)
374 emr->rclBounds.top = pt[i].y;
375 else if(pt[i].y > emr->rclBounds.bottom)
376 emr->rclBounds.bottom = pt[i].y;
380 memcpy(emr->aptl, pt, count * sizeof(POINTL));
382 ret = EMFDRV_WriteRecord( dev, &emr->emr );
384 EMFDRV_UpdateBBox( dev, &emr->rclBounds );
385 HeapFree( GetProcessHeap(), 0, emr );
390 /**********************************************************************
391 * EMFDRV_Polylinegon16
393 * Helper for EMFDRV_Poly{line|gon}
395 * This is not a legacy function!
396 * We are using SHORT integers to save space.
399 EMFDRV_Polylinegon16( PHYSDEV dev, const POINT* pt, INT count, DWORD iType )
406 /* check whether all points fit in the SHORT int POINT structure */
407 for(i = 0; i < count; i++) {
408 if( ((pt[i].x+0x8000) & ~0xffff ) ||
409 ((pt[i].y+0x8000) & ~0xffff ) )
413 size = sizeof(EMRPOLYLINE16) + sizeof(POINTS) * (count - 1);
415 emr = HeapAlloc( GetProcessHeap(), 0, size );
416 emr->emr.iType = iType;
417 emr->emr.nSize = size;
419 emr->rclBounds.left = emr->rclBounds.right = pt[0].x;
420 emr->rclBounds.top = emr->rclBounds.bottom = pt[0].y;
422 for(i = 1; i < count; i++) {
423 if(pt[i].x < emr->rclBounds.left)
424 emr->rclBounds.left = pt[i].x;
425 else if(pt[i].x > emr->rclBounds.right)
426 emr->rclBounds.right = pt[i].x;
427 if(pt[i].y < emr->rclBounds.top)
428 emr->rclBounds.top = pt[i].y;
429 else if(pt[i].y > emr->rclBounds.bottom)
430 emr->rclBounds.bottom = pt[i].y;
434 for(i = 0; i < count; i++ ) {
435 emr->apts[i].x = pt[i].x;
436 emr->apts[i].y = pt[i].y;
439 ret = EMFDRV_WriteRecord( dev, &emr->emr );
441 EMFDRV_UpdateBBox( dev, &emr->rclBounds );
442 HeapFree( GetProcessHeap(), 0, emr );
447 /**********************************************************************
451 EMFDRV_Polyline( PHYSDEV dev, const POINT* pt, INT count )
453 if( EMFDRV_Polylinegon16( dev, pt, count, EMR_POLYLINE16 ) )
455 return EMFDRV_Polylinegon( dev, pt, count, EMR_POLYLINE );
458 /**********************************************************************
462 EMFDRV_Polygon( PHYSDEV dev, const POINT* pt, INT count )
464 if(count < 2) return FALSE;
465 if( EMFDRV_Polylinegon16( dev, pt, count, EMR_POLYGON16 ) )
467 return EMFDRV_Polylinegon( dev, pt, count, EMR_POLYGON );
471 /**********************************************************************
472 * EMFDRV_PolyPolylinegon
474 * Helper for EMFDRV_PolyPoly{line|gon}
477 EMFDRV_PolyPolylinegon( PHYSDEV dev, const POINT* pt, const INT* counts, UINT polys,
480 EMRPOLYPOLYLINE *emr;
481 DWORD cptl = 0, poly, size;
487 bounds.left = bounds.right = pt[0].x;
488 bounds.top = bounds.bottom = pt[0].y;
491 for(poly = 0; poly < polys; poly++) {
492 cptl += counts[poly];
493 for(point = 0; point < counts[poly]; point++) {
494 if(bounds.left > pts->x) bounds.left = pts->x;
495 else if(bounds.right < pts->x) bounds.right = pts->x;
496 if(bounds.top > pts->y) bounds.top = pts->y;
497 else if(bounds.bottom < pts->y) bounds.bottom = pts->y;
502 size = sizeof(EMRPOLYPOLYLINE) + (polys - 1) * sizeof(DWORD) +
503 (cptl - 1) * sizeof(POINTL);
505 emr = HeapAlloc( GetProcessHeap(), 0, size );
507 emr->emr.iType = iType;
508 emr->emr.nSize = size;
509 emr->rclBounds = bounds;
512 memcpy(emr->aPolyCounts, counts, polys * sizeof(DWORD));
513 memcpy(emr->aPolyCounts + polys, pt, cptl * sizeof(POINTL));
514 ret = EMFDRV_WriteRecord( dev, &emr->emr );
516 EMFDRV_UpdateBBox( dev, &emr->rclBounds );
517 HeapFree( GetProcessHeap(), 0, emr );
521 /**********************************************************************
522 * EMFDRV_PolyPolyline
525 EMFDRV_PolyPolyline(PHYSDEV dev, const POINT* pt, const DWORD* counts, DWORD polys)
527 return EMFDRV_PolyPolylinegon( dev, pt, (const INT *)counts, polys,
531 /**********************************************************************
535 EMFDRV_PolyPolygon( PHYSDEV dev, const POINT* pt, const INT* counts, UINT polys )
537 return EMFDRV_PolyPolylinegon( dev, pt, counts, polys, EMR_POLYPOLYGON );
541 /**********************************************************************
542 * EMFDRV_ExtFloodFill
545 EMFDRV_ExtFloodFill( PHYSDEV dev, INT x, INT y, COLORREF color, UINT fillType )
549 emr.emr.iType = EMR_EXTFLOODFILL;
550 emr.emr.nSize = sizeof(emr);
554 emr.iMode = fillType;
556 return EMFDRV_WriteRecord( dev, &emr.emr );
560 /*********************************************************************
563 BOOL CDECL EMFDRV_FillRgn( PHYSDEV dev, HRGN hrgn, HBRUSH hbrush )
566 DWORD size, rgnsize, index;
569 index = EMFDRV_CreateBrushIndirect( dev, hbrush );
570 if(!index) return FALSE;
572 rgnsize = GetRegionData( hrgn, 0, NULL );
573 size = rgnsize + offsetof(EMRFILLRGN,RgnData);
574 emr = HeapAlloc( GetProcessHeap(), 0, size );
576 GetRegionData( hrgn, rgnsize, (RGNDATA *)&emr->RgnData );
578 emr->emr.iType = EMR_FILLRGN;
579 emr->emr.nSize = size;
580 emr->rclBounds.left = ((RGNDATA *)&emr->RgnData)->rdh.rcBound.left;
581 emr->rclBounds.top = ((RGNDATA *)&emr->RgnData)->rdh.rcBound.top;
582 emr->rclBounds.right = ((RGNDATA *)&emr->RgnData)->rdh.rcBound.right - 1;
583 emr->rclBounds.bottom = ((RGNDATA *)&emr->RgnData)->rdh.rcBound.bottom - 1;
584 emr->cbRgnData = rgnsize;
585 emr->ihBrush = index;
587 ret = EMFDRV_WriteRecord( dev, &emr->emr );
589 EMFDRV_UpdateBBox( dev, &emr->rclBounds );
590 HeapFree( GetProcessHeap(), 0, emr );
593 /*********************************************************************
596 BOOL CDECL EMFDRV_FrameRgn( PHYSDEV dev, HRGN hrgn, HBRUSH hbrush, INT width, INT height )
599 DWORD size, rgnsize, index;
602 index = EMFDRV_CreateBrushIndirect( dev, hbrush );
603 if(!index) return FALSE;
605 rgnsize = GetRegionData( hrgn, 0, NULL );
606 size = rgnsize + offsetof(EMRFRAMERGN,RgnData);
607 emr = HeapAlloc( GetProcessHeap(), 0, size );
609 GetRegionData( hrgn, rgnsize, (RGNDATA *)&emr->RgnData );
611 emr->emr.iType = EMR_FRAMERGN;
612 emr->emr.nSize = size;
613 emr->rclBounds.left = ((RGNDATA *)&emr->RgnData)->rdh.rcBound.left;
614 emr->rclBounds.top = ((RGNDATA *)&emr->RgnData)->rdh.rcBound.top;
615 emr->rclBounds.right = ((RGNDATA *)&emr->RgnData)->rdh.rcBound.right - 1;
616 emr->rclBounds.bottom = ((RGNDATA *)&emr->RgnData)->rdh.rcBound.bottom - 1;
617 emr->cbRgnData = rgnsize;
618 emr->ihBrush = index;
619 emr->szlStroke.cx = width;
620 emr->szlStroke.cy = height;
622 ret = EMFDRV_WriteRecord( dev, &emr->emr );
624 EMFDRV_UpdateBBox( dev, &emr->rclBounds );
625 HeapFree( GetProcessHeap(), 0, emr );
629 /*********************************************************************
630 * EMFDRV_PaintInvertRgn
632 * Helper for EMFDRV_{Paint|Invert}Rgn
634 static BOOL EMFDRV_PaintInvertRgn( PHYSDEV dev, HRGN hrgn, DWORD iType )
641 rgnsize = GetRegionData( hrgn, 0, NULL );
642 size = rgnsize + offsetof(EMRINVERTRGN,RgnData);
643 emr = HeapAlloc( GetProcessHeap(), 0, size );
645 GetRegionData( hrgn, rgnsize, (RGNDATA *)&emr->RgnData );
647 emr->emr.iType = iType;
648 emr->emr.nSize = size;
649 emr->rclBounds.left = ((RGNDATA *)&emr->RgnData)->rdh.rcBound.left;
650 emr->rclBounds.top = ((RGNDATA *)&emr->RgnData)->rdh.rcBound.top;
651 emr->rclBounds.right = ((RGNDATA *)&emr->RgnData)->rdh.rcBound.right - 1;
652 emr->rclBounds.bottom = ((RGNDATA *)&emr->RgnData)->rdh.rcBound.bottom - 1;
653 emr->cbRgnData = rgnsize;
655 ret = EMFDRV_WriteRecord( dev, &emr->emr );
657 EMFDRV_UpdateBBox( dev, &emr->rclBounds );
658 HeapFree( GetProcessHeap(), 0, emr );
662 /**********************************************************************
666 EMFDRV_PaintRgn( PHYSDEV dev, HRGN hrgn )
668 return EMFDRV_PaintInvertRgn( dev, hrgn, EMR_PAINTRGN );
671 /**********************************************************************
675 EMFDRV_InvertRgn( PHYSDEV dev, HRGN hrgn )
677 return EMFDRV_PaintInvertRgn( dev, hrgn, EMR_INVERTRGN );
680 /**********************************************************************
684 EMFDRV_SetBkColor( PHYSDEV dev, COLORREF color )
687 EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
689 if (physDev->restoring) return color; /* don't output records during RestoreDC */
691 emr.emr.iType = EMR_SETBKCOLOR;
692 emr.emr.nSize = sizeof(emr);
695 return EMFDRV_WriteRecord( dev, &emr.emr ) ? color : CLR_INVALID;
699 /**********************************************************************
700 * EMFDRV_SetTextColor
703 EMFDRV_SetTextColor( PHYSDEV dev, COLORREF color )
706 EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
708 if (physDev->restoring) return color; /* don't output records during RestoreDC */
710 emr.emr.iType = EMR_SETTEXTCOLOR;
711 emr.emr.nSize = sizeof(emr);
714 return EMFDRV_WriteRecord( dev, &emr.emr ) ? color : CLR_INVALID;
717 /**********************************************************************
720 BOOL CDECL EMFDRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
721 const RECT *lprect, LPCWSTR str, UINT count,
724 EMREXTTEXTOUTW *pemr;
727 EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*) dev;
730 const UINT textAlign = GetTextAlign(physDev->hdc);
732 nSize = sizeof(*pemr) + ((count+1) & ~1) * sizeof(WCHAR) + count * sizeof(INT);
734 TRACE("%s %s count %d nSize = %d\n", debugstr_wn(str, count),
735 wine_dbgstr_rect(lprect), count, nSize);
736 pemr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nSize);
738 pemr->emr.iType = EMR_EXTTEXTOUTW;
739 pemr->emr.nSize = nSize;
741 pemr->iGraphicsMode = GetGraphicsMode(physDev->hdc);
742 pemr->exScale = pemr->eyScale = 1.0; /* FIXME */
744 pemr->emrtext.ptlReference.x = x;
745 pemr->emrtext.ptlReference.y = y;
746 pemr->emrtext.nChars = count;
747 pemr->emrtext.offString = sizeof(*pemr);
748 memcpy((char*)pemr + pemr->emrtext.offString, str, count * sizeof(WCHAR));
749 pemr->emrtext.fOptions = flags;
751 pemr->emrtext.rcl.left = pemr->emrtext.rcl.top = 0;
752 pemr->emrtext.rcl.right = pemr->emrtext.rcl.bottom = -1;
754 pemr->emrtext.rcl.left = lprect->left;
755 pemr->emrtext.rcl.top = lprect->top;
756 pemr->emrtext.rcl.right = lprect->right;
757 pemr->emrtext.rcl.bottom = lprect->bottom;
760 pemr->emrtext.offDx = pemr->emrtext.offString + ((count+1) & ~1) * sizeof(WCHAR);
764 memcpy((char*)pemr + pemr->emrtext.offDx, lpDx, count * sizeof(INT));
765 for (i = 0; i < count; i++) {
766 textWidth += lpDx[i];
768 if (GetTextExtentPoint32W(physDev->hdc, str, count, &strSize))
769 textHeight = strSize.cy;
773 INT *dx = (INT *)((char*)pemr + pemr->emrtext.offDx);
775 for (i = 0; i < count; i++) {
776 if (GetTextExtentPoint32W(physDev->hdc, str + i, 1, &charSize)) {
778 textWidth += charSize.cx;
779 textHeight = max(textHeight, charSize.cy);
786 pemr->rclBounds.left = pemr->rclBounds.top = 0;
787 pemr->rclBounds.right = pemr->rclBounds.bottom = -1;
791 switch (textAlign & (TA_LEFT | TA_RIGHT | TA_CENTER)) {
793 pemr->rclBounds.left = x - (textWidth / 2) - 1;
794 pemr->rclBounds.right = x + (textWidth / 2) + 1;
798 pemr->rclBounds.left = x - textWidth - 1;
799 pemr->rclBounds.right = x;
802 default: { /* TA_LEFT */
803 pemr->rclBounds.left = x;
804 pemr->rclBounds.right = x + textWidth + 1;
808 switch (textAlign & (TA_TOP | TA_BOTTOM | TA_BASELINE)) {
811 if (!GetTextMetricsW(physDev->hdc, &tm))
813 /* Play safe here... it's better to have a bounding box */
814 /* that is too big than too small. */
815 pemr->rclBounds.top = y - textHeight - 1;
816 pemr->rclBounds.bottom = y + tm.tmDescent + 1;
820 pemr->rclBounds.top = y - textHeight - 1;
821 pemr->rclBounds.bottom = y;
824 default: { /* TA_TOP */
825 pemr->rclBounds.top = y;
826 pemr->rclBounds.bottom = y + textHeight + 1;
829 EMFDRV_UpdateBBox( dev, &pemr->rclBounds );
832 ret = EMFDRV_WriteRecord( dev, &pemr->emr );
833 HeapFree( GetProcessHeap(), 0, pemr );
837 /**********************************************************************
838 * EMFDRV_SetArcDirection
840 INT CDECL EMFDRV_SetArcDirection(PHYSDEV dev, INT arcDirection)
842 EMRSETARCDIRECTION emr;
844 emr.emr.iType = EMR_SETARCDIRECTION;
845 emr.emr.nSize = sizeof(emr);
846 emr.iArcDirection = arcDirection;
848 EMFDRV_WriteRecord(dev, &emr.emr);
850 /* We don't know the old arc direction and we don't care... */