2 * Misc. graphics operations
4 * Copyright 1993, 1994 Alexandre Julliard
5 * Copyright 1997 Bertho A. Stultiens
8 #include <X11/Intrinsic.h>
25 /***********************************************************************
28 BOOL16 WINAPI
LineTo16( HDC16 hdc
, INT16 x
, INT16 y
)
30 return LineTo32( hdc
, x
, y
);
34 /***********************************************************************
35 * LineTo32 (GDI32.249)
37 BOOL32 WINAPI
LineTo32( HDC32 hdc
, INT32 x
, INT32 y
)
39 DC
* dc
= DC_GetDCPtr( hdc
);
41 if(dc
&& PATH_IsPathOpen(dc
->w
.path
))
42 if(!PATH_LineTo(hdc
, x
, y
))
45 return dc
&& dc
->funcs
->pLineTo
&&
46 dc
->funcs
->pLineTo(dc
,x
,y
);
50 /***********************************************************************
53 DWORD WINAPI
MoveTo( HDC16 hdc
, INT16 x
, INT16 y
)
57 if (!MoveToEx16(hdc
,x
,y
,&pt
))
59 return MAKELONG(pt
.x
,pt
.y
);
63 /***********************************************************************
64 * MoveToEx16 (GDI.483)
66 BOOL16 WINAPI
MoveToEx16( HDC16 hdc
, INT16 x
, INT16 y
, LPPOINT16 pt
)
70 if (!MoveToEx32( (HDC32
)hdc
, (INT32
)x
, (INT32
)y
, &pt32
)) return FALSE
;
71 if (pt
) CONV_POINT32TO16( &pt32
, pt
);
77 /***********************************************************************
78 * MoveToEx32 (GDI32.254)
80 BOOL32 WINAPI
MoveToEx32( HDC32 hdc
, INT32 x
, INT32 y
, LPPOINT32 pt
)
82 DC
* dc
= DC_GetDCPtr( hdc
);
84 if(dc
&& PATH_IsPathOpen(dc
->w
.path
))
88 return dc
&& dc
->funcs
->pMoveToEx
&&
89 dc
->funcs
->pMoveToEx(dc
,x
,y
,pt
);
93 /***********************************************************************
96 BOOL16 WINAPI
Arc16( HDC16 hdc
, INT16 left
, INT16 top
, INT16 right
,
97 INT16 bottom
, INT16 xstart
, INT16 ystart
,
98 INT16 xend
, INT16 yend
)
100 return Arc32( (HDC32
)hdc
, (INT32
)left
, (INT32
)top
, (INT32
)right
,
101 (INT32
)bottom
, (INT32
)xstart
, (INT32
)ystart
, (INT32
)xend
,
106 /***********************************************************************
109 BOOL32 WINAPI
Arc32( HDC32 hdc
, INT32 left
, INT32 top
, INT32 right
,
110 INT32 bottom
, INT32 xstart
, INT32 ystart
,
111 INT32 xend
, INT32 yend
)
113 DC
* dc
= DC_GetDCPtr( hdc
);
115 if(dc
&& PATH_IsPathOpen(dc
->w
.path
))
116 if(!PATH_Arc(hdc
, left
, top
, right
, bottom
, xstart
, ystart
, xend
,
120 return dc
&& dc
->funcs
->pArc
&&
121 dc
->funcs
->pArc(dc
,left
,top
,right
,bottom
,xstart
,ystart
,xend
,yend
);
124 /***********************************************************************
127 BOOL32 WINAPI
ArcTo( HDC32 hdc
,
128 INT32 left
, INT32 top
,
129 INT32 right
, INT32 bottom
,
130 INT32 xstart
, INT32 ystart
,
131 INT32 xend
, INT32 yend
)
136 * According to the documentation, a line is drawn from the current
137 * position to the starting point of the arc.
139 LineTo32(hdc
, xstart
, ystart
);
142 * Then the arc is drawn.
151 * If no error occured, the current position is moved to the ending
156 MoveToEx32(hdc
, xend
, yend
, NULL
);
162 /***********************************************************************
165 BOOL16 WINAPI
Pie16( HDC16 hdc
, INT16 left
, INT16 top
,
166 INT16 right
, INT16 bottom
, INT16 xstart
, INT16 ystart
,
167 INT16 xend
, INT16 yend
)
169 return Pie32( (HDC32
)hdc
, (INT32
)left
, (INT32
)top
, (INT32
)right
,
170 (INT32
)bottom
, (INT32
)xstart
, (INT32
)ystart
, (INT32
)xend
,
175 /***********************************************************************
178 BOOL32 WINAPI
Pie32( HDC32 hdc
, INT32 left
, INT32 top
,
179 INT32 right
, INT32 bottom
, INT32 xstart
, INT32 ystart
,
180 INT32 xend
, INT32 yend
)
182 DC
* dc
= DC_GetDCPtr( hdc
);
184 return dc
&& dc
->funcs
->pPie
&&
185 dc
->funcs
->pPie(dc
,left
,top
,right
,bottom
,xstart
,ystart
,xend
,yend
);
189 /***********************************************************************
192 BOOL16 WINAPI
Chord16( HDC16 hdc
, INT16 left
, INT16 top
,
193 INT16 right
, INT16 bottom
, INT16 xstart
, INT16 ystart
,
194 INT16 xend
, INT16 yend
)
196 return Chord32( hdc
, left
, top
, right
, bottom
, xstart
, ystart
, xend
, yend
);
200 /***********************************************************************
203 BOOL32 WINAPI
Chord32( HDC32 hdc
, INT32 left
, INT32 top
,
204 INT32 right
, INT32 bottom
, INT32 xstart
, INT32 ystart
,
205 INT32 xend
, INT32 yend
)
207 DC
* dc
= DC_GetDCPtr( hdc
);
209 return dc
&& dc
->funcs
->pChord
&&
210 dc
->funcs
->pChord(dc
,left
,top
,right
,bottom
,xstart
,ystart
,xend
,yend
);
214 /***********************************************************************
217 BOOL16 WINAPI
Ellipse16( HDC16 hdc
, INT16 left
, INT16 top
,
218 INT16 right
, INT16 bottom
)
220 return Ellipse32( hdc
, left
, top
, right
, bottom
);
224 /***********************************************************************
225 * Ellipse32 (GDI32.75)
227 BOOL32 WINAPI
Ellipse32( HDC32 hdc
, INT32 left
, INT32 top
,
228 INT32 right
, INT32 bottom
)
230 DC
* dc
= DC_GetDCPtr( hdc
);
232 return dc
&& dc
->funcs
->pEllipse
&&
233 dc
->funcs
->pEllipse(dc
,left
,top
,right
,bottom
);
237 /***********************************************************************
238 * Rectangle16 (GDI.27)
240 BOOL16 WINAPI
Rectangle16( HDC16 hdc
, INT16 left
, INT16 top
,
241 INT16 right
, INT16 bottom
)
243 return Rectangle32( hdc
, left
, top
, right
, bottom
);
247 /***********************************************************************
248 * Rectangle32 (GDI32.283)
250 BOOL32 WINAPI
Rectangle32( HDC32 hdc
, INT32 left
, INT32 top
,
251 INT32 right
, INT32 bottom
)
253 DC
* dc
= DC_GetDCPtr( hdc
);
255 if(dc
&& PATH_IsPathOpen(dc
->w
.path
))
256 if(!PATH_Rectangle(hdc
, left
, top
, right
, bottom
))
259 return dc
&& dc
->funcs
->pRectangle
&&
260 dc
->funcs
->pRectangle(dc
,left
,top
,right
,bottom
);
264 /***********************************************************************
265 * RoundRect16 (GDI.28)
267 BOOL16 WINAPI
RoundRect16( HDC16 hdc
, INT16 left
, INT16 top
, INT16 right
,
268 INT16 bottom
, INT16 ell_width
, INT16 ell_height
)
270 return RoundRect32( hdc
, left
, top
, right
, bottom
, ell_width
, ell_height
);
274 /***********************************************************************
275 * RoundRect32 (GDI32.291)
277 BOOL32 WINAPI
RoundRect32( HDC32 hdc
, INT32 left
, INT32 top
, INT32 right
,
278 INT32 bottom
, INT32 ell_width
, INT32 ell_height
)
281 if(ell_width
== 0 || ell_height
== 0) /* Just an optimization */
282 return Rectangle32(hdc
, left
, top
, right
, bottom
);
285 DC
* dc
= DC_GetDCPtr( hdc
);
287 return dc
&& dc
->funcs
->pRoundRect
&&
288 dc
->funcs
->pRoundRect(dc
,left
,top
,right
,bottom
,ell_width
,ell_height
);
293 /***********************************************************************
294 * FillRect16 (USER.81)
296 INT16 WINAPI
FillRect16( HDC16 hdc
, const RECT16
*rect
, HBRUSH16 hbrush
)
300 /* coordinates are logical so we cannot fast-check 'rect',
301 * it will be done later in the PatBlt().
304 if (!(prevBrush
= SelectObject16( hdc
, hbrush
))) return 0;
305 PatBlt32( hdc
, rect
->left
, rect
->top
,
306 rect
->right
- rect
->left
, rect
->bottom
- rect
->top
, PATCOPY
);
307 SelectObject16( hdc
, prevBrush
);
312 /***********************************************************************
313 * FillRect32 (USER32.197)
315 INT32 WINAPI
FillRect32( HDC32 hdc
, const RECT32
*rect
, HBRUSH32 hbrush
)
319 if (!(prevBrush
= SelectObject32( hdc
, hbrush
))) return 0;
320 PatBlt32( hdc
, rect
->left
, rect
->top
,
321 rect
->right
- rect
->left
, rect
->bottom
- rect
->top
, PATCOPY
);
322 SelectObject32( hdc
, prevBrush
);
327 /***********************************************************************
328 * InvertRect16 (USER.82)
330 void WINAPI
InvertRect16( HDC16 hdc
, const RECT16
*rect
)
332 PatBlt32( hdc
, rect
->left
, rect
->top
,
333 rect
->right
- rect
->left
, rect
->bottom
- rect
->top
, DSTINVERT
);
337 /***********************************************************************
338 * InvertRect32 (USER32.330)
340 BOOL32 WINAPI
InvertRect32( HDC32 hdc
, const RECT32
*rect
)
342 return PatBlt32( hdc
, rect
->left
, rect
->top
,
343 rect
->right
- rect
->left
, rect
->bottom
- rect
->top
,
348 /***********************************************************************
349 * FrameRect16 (USER.83)
351 INT16 WINAPI
FrameRect16( HDC16 hdc
, const RECT16
*rect
, HBRUSH16 hbrush
)
354 int left
, top
, right
, bottom
;
356 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
357 if (!dc
) return FALSE
;
359 left
= XLPTODP( dc
, rect
->left
);
360 top
= YLPTODP( dc
, rect
->top
);
361 right
= XLPTODP( dc
, rect
->right
);
362 bottom
= YLPTODP( dc
, rect
->bottom
);
364 if ( (right
<= left
) || (bottom
<= top
) ) return 0;
365 if (!(prevBrush
= SelectObject16( hdc
, hbrush
))) return 0;
367 PatBlt32( hdc
, rect
->left
, rect
->top
, 1,
368 rect
->bottom
- rect
->top
, PATCOPY
);
369 PatBlt32( hdc
, rect
->right
- 1, rect
->top
, 1,
370 rect
->bottom
- rect
->top
, PATCOPY
);
371 PatBlt32( hdc
, rect
->left
, rect
->top
,
372 rect
->right
- rect
->left
, 1, PATCOPY
);
373 PatBlt32( hdc
, rect
->left
, rect
->bottom
- 1,
374 rect
->right
- rect
->left
, 1, PATCOPY
);
376 SelectObject16( hdc
, prevBrush
);
381 /***********************************************************************
382 * FrameRect32 (USER32.203)
384 INT32 WINAPI
FrameRect32( HDC32 hdc
, const RECT32
*rect
, HBRUSH32 hbrush
)
387 CONV_RECT32TO16( rect
, &rect16
);
388 return FrameRect16( (HDC16
)hdc
, &rect16
, (HBRUSH16
)hbrush
);
392 /***********************************************************************
393 * SetPixel16 (GDI.31)
395 COLORREF WINAPI
SetPixel16( HDC16 hdc
, INT16 x
, INT16 y
, COLORREF color
)
397 return SetPixel32( hdc
, x
, y
, color
);
401 /***********************************************************************
402 * SetPixel32 (GDI32.327)
404 COLORREF WINAPI
SetPixel32( HDC32 hdc
, INT32 x
, INT32 y
, COLORREF color
)
406 DC
* dc
= DC_GetDCPtr( hdc
);
408 if (!dc
|| !dc
->funcs
->pSetPixel
) return 0;
409 return dc
->funcs
->pSetPixel(dc
,x
,y
,color
);
412 /***********************************************************************
413 * SetPixelV32 (GDI32.329)
415 BOOL32 WINAPI
SetPixelV32( HDC32 hdc
, INT32 x
, INT32 y
, COLORREF color
)
417 DC
* dc
= DC_GetDCPtr( hdc
);
419 if (!dc
|| !dc
->funcs
->pSetPixel
) return FALSE
;
420 dc
->funcs
->pSetPixel(dc
,x
,y
,color
);
424 /***********************************************************************
425 * GetPixel16 (GDI.83)
427 COLORREF WINAPI
GetPixel16( HDC16 hdc
, INT16 x
, INT16 y
)
429 return GetPixel32( hdc
, x
, y
);
433 /***********************************************************************
434 * GetPixel32 (GDI32.211)
436 COLORREF WINAPI
GetPixel32( HDC32 hdc
, INT32 x
, INT32 y
)
438 DC
* dc
= DC_GetDCPtr( hdc
);
441 #ifdef SOLITAIRE_SPEED_HACK
445 /* FIXME: should this be in the graphics driver? */
446 if (!PtVisible32( hdc
, x
, y
)) return 0;
447 if (!dc
|| !dc
->funcs
->pGetPixel
) return 0;
448 return dc
->funcs
->pGetPixel(dc
,x
,y
);
452 /******************************************************************************
453 * ChoosePixelFormat [GDI32.13]
454 * Matches a pixel format to given format
457 * hdc [I] Device context to search for best pixel match
458 * ppfd [I] Pixel format for which a match is sought
461 * Success: Pixel format index closest to given format
464 INT32 WINAPI
ChoosePixelFormat( HDC32 hdc
, const PIXELFORMATDESCRIPTOR
* ppfd
)
466 FIXME(gdi
, "(%d,%p): stub\n",hdc
,ppfd
);
471 /******************************************************************************
472 * SetPixelFormat [GDI32.328]
473 * Sets pixel format of device context
476 * hdc [I] Device context to search for best pixel match
477 * iPixelFormat [I] Pixel format index
478 * ppfd [I] Pixel format for which a match is sought
482 BOOL32 WINAPI
SetPixelFormat( HDC32 hdc
, int iPixelFormat
,
483 const PIXELFORMATDESCRIPTOR
* ppfd
)
485 FIXME(gdi
, "(%d,%d,%p): stub\n",hdc
,iPixelFormat
,ppfd
);
490 /******************************************************************************
491 * GetPixelFormat [GDI32.212]
492 * Gets index of pixel format of DC
495 * hdc [I] Device context whose pixel format index is sought
498 * Success: Currently selected pixel format
501 int WINAPI
GetPixelFormat( HDC32 hdc
)
503 FIXME(gdi
, "(%d): stub\n",hdc
);
508 /******************************************************************************
509 * DescribePixelFormat [GDI32.71]
510 * Gets info about pixel format from DC
513 * hdc [I] Device context
514 * iPixelFormat [I] Pixel format selector
515 * nBytes [I] Size of buffer
516 * ppfd [O] Pointer to structure to receive pixel format data
519 * Success: Maximum pixel format index of the device context
522 int WINAPI
DescribePixelFormat( HDC32 hdc
, int iPixelFormat
, UINT32 nBytes
,
523 LPPIXELFORMATDESCRIPTOR ppfd
)
525 FIXME(gdi
, "(%d,%d,%d,%p): stub\n",hdc
,iPixelFormat
,nBytes
,ppfd
);
526 ppfd
->nSize
= nBytes
;
532 /******************************************************************************
533 * SwapBuffers [GDI32.354]
534 * Exchanges front and back buffers of window
537 * hdc [I] Device context whose buffers get swapped
541 BOOL32 WINAPI
SwapBuffers( HDC32 hdc
)
543 FIXME(gdi
, "(%d): stub\n",hdc
);
548 /***********************************************************************
549 * PaintRgn16 (GDI.43)
551 BOOL16 WINAPI
PaintRgn16( HDC16 hdc
, HRGN16 hrgn
)
553 return PaintRgn32( hdc
, hrgn
);
557 /***********************************************************************
558 * PaintRgn32 (GDI32.259)
560 BOOL32 WINAPI
PaintRgn32( HDC32 hdc
, HRGN32 hrgn
)
562 DC
* dc
= DC_GetDCPtr( hdc
);
564 return dc
&& dc
->funcs
->pPaintRgn
&&
565 dc
->funcs
->pPaintRgn(dc
,hrgn
);
569 /***********************************************************************
572 BOOL16 WINAPI
FillRgn16( HDC16 hdc
, HRGN16 hrgn
, HBRUSH16 hbrush
)
574 return FillRgn32( hdc
, hrgn
, hbrush
);
578 /***********************************************************************
579 * FillRgn32 (GDI32.101)
581 BOOL32 WINAPI
FillRgn32( HDC32 hdc
, HRGN32 hrgn
, HBRUSH32 hbrush
)
584 HBRUSH32 prevBrush
= SelectObject32( hdc
, hbrush
);
585 if (!prevBrush
) return FALSE
;
586 retval
= PaintRgn32( hdc
, hrgn
);
587 SelectObject32( hdc
, prevBrush
);
592 /***********************************************************************
593 * FrameRgn16 (GDI.41)
595 BOOL16 WINAPI
FrameRgn16( HDC16 hdc
, HRGN16 hrgn
, HBRUSH16 hbrush
,
596 INT16 nWidth
, INT16 nHeight
)
598 return FrameRgn32( hdc
, hrgn
, hbrush
, nWidth
, nHeight
);
602 /***********************************************************************
603 * FrameRgn32 (GDI32.105)
605 BOOL32 WINAPI
FrameRgn32( HDC32 hdc
, HRGN32 hrgn
, HBRUSH32 hbrush
,
606 INT32 nWidth
, INT32 nHeight
)
608 HRGN32 tmp
= CreateRectRgn32( 0, 0, 0, 0 );
609 if(!REGION_FrameRgn( tmp
, hrgn
, nWidth
, nHeight
)) return FALSE
;
610 FillRgn32( hdc
, tmp
, hbrush
);
611 DeleteObject32( tmp
);
616 /***********************************************************************
617 * InvertRgn16 (GDI.42)
619 BOOL16 WINAPI
InvertRgn16( HDC16 hdc
, HRGN16 hrgn
)
621 return InvertRgn32( hdc
, hrgn
);
625 /***********************************************************************
626 * InvertRgn32 (GDI32.246)
628 BOOL32 WINAPI
InvertRgn32( HDC32 hdc
, HRGN32 hrgn
)
630 HBRUSH32 prevBrush
= SelectObject32( hdc
, GetStockObject32(BLACK_BRUSH
) );
631 INT32 prevROP
= SetROP232( hdc
, R2_NOT
);
632 BOOL32 retval
= PaintRgn32( hdc
, hrgn
);
633 SelectObject32( hdc
, prevBrush
);
634 SetROP232( hdc
, prevROP
);
639 /***********************************************************************
640 * DrawFocusRect16 (USER.466)
642 void WINAPI
DrawFocusRect16( HDC16 hdc
, const RECT16
* rc
)
645 CONV_RECT16TO32( rc
, &rect32
);
646 DrawFocusRect32( hdc
, &rect32
);
650 /***********************************************************************
651 * DrawFocusRect32 (USER32.156)
653 * FIXME: PatBlt(PATINVERT) with background brush.
655 BOOL32 WINAPI
DrawFocusRect32( HDC32 hdc
, const RECT32
* rc
)
657 HPEN32 hOldPen
, hnewPen
;
658 INT32 oldDrawMode
, oldBkMode
;
659 INT32 left
, top
, right
, bottom
;
660 X11DRV_PDEVICE
*physDev
;
662 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
665 SetLastError( ERROR_INVALID_HANDLE
);
668 physDev
= (X11DRV_PDEVICE
*)dc
->physDev
;
670 left
= XLPTODP( dc
, rc
->left
);
671 top
= YLPTODP( dc
, rc
->top
);
672 right
= XLPTODP( dc
, rc
->right
);
673 bottom
= YLPTODP( dc
, rc
->bottom
);
675 if(left
== right
|| top
== bottom
)
677 SetLastError( ERROR_INVALID_PARAMETER
);
681 hnewPen
= CreatePen32(PS_DOT
, 1, GetSysColor32(COLOR_WINDOWTEXT
) );
682 hOldPen
= SelectObject32( hdc
, hnewPen
);
683 oldDrawMode
= SetROP232(hdc
, R2_XORPEN
);
684 oldBkMode
= SetBkMode32(hdc
, TRANSPARENT
);
686 /* Hack: make sure the XORPEN operation has an effect */
687 physDev
->pen
.pixel
= (1 << MONITOR_GetDepth(&MONITOR_PrimaryMonitor
)) - 1;
689 if (X11DRV_SetupGCForPen( dc
))
690 TSXDrawRectangle( display
, physDev
->drawable
, physDev
->gc
,
691 dc
->w
.DCOrgX
+ left
, dc
->w
.DCOrgY
+ top
,
692 right
-left
-1, bottom
-top
-1 );
694 SetBkMode32(hdc
, oldBkMode
);
695 SetROP232(hdc
, oldDrawMode
);
696 SelectObject32(hdc
, hOldPen
);
697 DeleteObject32(hnewPen
);
702 /**********************************************************************
703 * Polyline16 (GDI.37)
705 BOOL16 WINAPI
Polyline16( HDC16 hdc
, const POINT16
* pt
, INT16 count
)
709 LPPOINT32 pt32
= (LPPOINT32
)HeapAlloc( GetProcessHeap(), 0,
710 count
*sizeof(POINT32
) );
712 if (!pt32
) return FALSE
;
713 for (i
=count
;i
--;) CONV_POINT16TO32(&(pt
[i
]),&(pt32
[i
]));
714 ret
= Polyline32(hdc
,pt32
,count
);
715 HeapFree( GetProcessHeap(), 0, pt32
);
720 /**********************************************************************
721 * Polyline32 (GDI32.276)
723 BOOL32 WINAPI
Polyline32( HDC32 hdc
, const POINT32
* pt
, INT32 count
)
725 DC
* dc
= DC_GetDCPtr( hdc
);
727 return dc
&& dc
->funcs
->pPolyline
&&
728 dc
->funcs
->pPolyline(dc
,pt
,count
);
731 /**********************************************************************
732 * PolylineTo32 (GDI32.277)
734 BOOL32 WINAPI
PolylineTo32( HDC32 hdc
, const POINT32
* pt
, DWORD cCount
)
736 POINT32
*pts
= HeapAlloc( GetProcessHeap(), 0,
737 sizeof(POINT32
) * (cCount
+ 1) );
738 if(!pts
) return FALSE
;
740 /* Get the current point */
741 MoveToEx32( hdc
, 0, 0, pts
);
743 /* Add in the other points */
744 memcpy( pts
+ 1, pt
, sizeof(POINT32
) * cCount
);
747 Polyline32( hdc
, pts
, cCount
+ 1 );
749 /* Move to last point */
750 MoveToEx32( hdc
, (pts
+ cCount
)->x
, (pts
+ cCount
)->y
, NULL
);
752 HeapFree( GetProcessHeap(), 0, pts
);
756 /**********************************************************************
759 BOOL16 WINAPI
Polygon16( HDC16 hdc
, const POINT16
* pt
, INT16 count
)
763 LPPOINT32 pt32
= (LPPOINT32
)HeapAlloc( GetProcessHeap(), 0,
764 count
*sizeof(POINT32
) );
766 if (!pt32
) return FALSE
;
767 for (i
=count
;i
--;) CONV_POINT16TO32(&(pt
[i
]),&(pt32
[i
]));
768 ret
= Polygon32(hdc
,pt32
,count
);
769 HeapFree( GetProcessHeap(), 0, pt32
);
774 /**********************************************************************
775 * Polygon32 (GDI32.275)
777 BOOL32 WINAPI
Polygon32( HDC32 hdc
, const POINT32
* pt
, INT32 count
)
779 DC
* dc
= DC_GetDCPtr( hdc
);
781 return dc
&& dc
->funcs
->pPolygon
&&
782 dc
->funcs
->pPolygon(dc
,pt
,count
);
786 /**********************************************************************
787 * PolyPolygon16 (GDI.450)
789 BOOL16 WINAPI
PolyPolygon16( HDC16 hdc
, const POINT16
* pt
, const INT16
* counts
,
798 for (i
=polygons
;i
--;)
800 pt32
= (LPPOINT32
)HEAP_xalloc( GetProcessHeap(), 0, sizeof(POINT32
)*nrpts
);
802 CONV_POINT16TO32(&(pt
[i
]),&(pt32
[i
]));
803 counts32
= (LPINT32
)HEAP_xalloc( GetProcessHeap(), 0,
804 polygons
*sizeof(INT32
) );
805 for (i
=polygons
;i
--;) counts32
[i
]=counts
[i
];
807 ret
= PolyPolygon32(hdc
,pt32
,counts32
,polygons
);
808 HeapFree( GetProcessHeap(), 0, counts32
);
809 HeapFree( GetProcessHeap(), 0, pt32
);
813 /**********************************************************************
814 * PolyPolygon32 (GDI.450)
816 BOOL32 WINAPI
PolyPolygon32( HDC32 hdc
, const POINT32
* pt
, const INT32
* counts
,
819 DC
* dc
= DC_GetDCPtr( hdc
);
821 return dc
&& dc
->funcs
->pPolyPolygon
&&
822 dc
->funcs
->pPolyPolygon(dc
,pt
,counts
,polygons
);
825 /**********************************************************************
826 * PolyPolyline (GDI32.272)
828 BOOL32 WINAPI
PolyPolyline( HDC32 hdc
, const POINT32
* pt
, const DWORD
* counts
,
831 DC
* dc
= DC_GetDCPtr( hdc
);
833 return dc
&& dc
->funcs
->pPolyPolyline
&&
834 dc
->funcs
->pPolyPolyline(dc
,pt
,counts
,polylines
);
837 /**********************************************************************
838 * ExtFloodFill16 (GDI.372)
840 BOOL16 WINAPI
ExtFloodFill16( HDC16 hdc
, INT16 x
, INT16 y
, COLORREF color
,
843 return ExtFloodFill32( hdc
, x
, y
, color
, fillType
);
847 /**********************************************************************
848 * ExtFloodFill32 (GDI32.96)
850 BOOL32 WINAPI
ExtFloodFill32( HDC32 hdc
, INT32 x
, INT32 y
, COLORREF color
,
853 DC
*dc
= DC_GetDCPtr( hdc
);
855 return dc
&& dc
->funcs
->pExtFloodFill
&&
856 dc
->funcs
->pExtFloodFill(dc
,x
,y
,color
,fillType
);
860 /**********************************************************************
861 * FloodFill16 (GDI.25)
863 BOOL16 WINAPI
FloodFill16( HDC16 hdc
, INT16 x
, INT16 y
, COLORREF color
)
865 return ExtFloodFill32( hdc
, x
, y
, color
, FLOODFILLBORDER
);
869 /**********************************************************************
870 * FloodFill32 (GDI32.104)
872 BOOL32 WINAPI
FloodFill32( HDC32 hdc
, INT32 x
, INT32 y
, COLORREF color
)
874 return ExtFloodFill32( hdc
, x
, y
, color
, FLOODFILLBORDER
);
878 /**********************************************************************
879 * DrawAnimatedRects16 (USER.448)
881 BOOL16 WINAPI
DrawAnimatedRects16( HWND16 hwnd
, INT16 idAni
,
882 const RECT16
* lprcFrom
,
883 const RECT16
* lprcTo
)
885 RECT32 rcFrom32
, rcTo32
;
887 rcFrom32
.left
= (INT32
)lprcFrom
->left
;
888 rcFrom32
.top
= (INT32
)lprcFrom
->top
;
889 rcFrom32
.right
= (INT32
)lprcFrom
->right
;
890 rcFrom32
.bottom
= (INT32
)lprcFrom
->bottom
;
892 rcTo32
.left
= (INT32
)lprcTo
->left
;
893 rcTo32
.top
= (INT32
)lprcTo
->top
;
894 rcTo32
.right
= (INT32
)lprcTo
->right
;
895 rcTo32
.bottom
= (INT32
)lprcTo
->bottom
;
897 return DrawAnimatedRects32((HWND32
)hwnd
, (INT32
)idAni
, &rcFrom32
, &rcTo32
);
901 /**********************************************************************
902 * DrawAnimatedRects32 (USER32.153)
904 BOOL32 WINAPI
DrawAnimatedRects32( HWND32 hwnd
, int idAni
,
905 const RECT32
* lprcFrom
,
906 const RECT32
* lprcTo
)
908 FIXME(gdi
,"(0x%x,%d,%p,%p): stub\n",hwnd
,idAni
,lprcFrom
,lprcTo
);
913 /**********************************************************************
914 * PAINTING_DrawStateJam
916 * Jams in the requested type in the dc
918 static BOOL32
PAINTING_DrawStateJam(HDC32 hdc
, UINT32 opcode
,
919 DRAWSTATEPROC32 func
, LPARAM lp
, WPARAM32 wp
,
920 LPRECT32 rc
, UINT32 dtflags
,
921 BOOL32 unicode
, BOOL32 _32bit
)
926 INT32 cx
= rc
->right
- rc
->left
;
927 INT32 cy
= rc
->bottom
- rc
->top
;
934 return DrawText32W(hdc
, (LPWSTR
)lp
, (INT32
)wp
, rc
, dtflags
);
936 return DrawText32A(hdc
, (LPSTR
)lp
, (INT32
)wp
, rc
, dtflags
);
938 return DrawText32A(hdc
, (LPSTR
)PTR_SEG_TO_LIN(lp
), (INT32
)wp
, rc
, dtflags
);
941 return DrawIcon32(hdc
, rc
->left
, rc
->top
, (HICON32
)lp
);
944 memdc
= CreateCompatibleDC32(hdc
);
945 if(!memdc
) return FALSE
;
946 hbmsave
= (HBITMAP32
)SelectObject32(memdc
, (HBITMAP32
)lp
);
952 retval
= BitBlt32(hdc
, rc
->left
, rc
->top
, cx
, cy
, memdc
, 0, 0, SRCCOPY
);
953 SelectObject32(memdc
, hbmsave
);
960 return func(hdc
, lp
, wp
, cx
, cy
);
962 return (BOOL32
)((DRAWSTATEPROC16
)func
)((HDC16
)hdc
, (LPARAM
)lp
, (WPARAM16
)wp
, (INT16
)cx
, (INT16
)cy
);
969 /**********************************************************************
970 * PAINTING_DrawState32()
972 static BOOL32
PAINTING_DrawState32(HDC32 hdc
, HBRUSH32 hbr
,
973 DRAWSTATEPROC32 func
, LPARAM lp
, WPARAM32 wp
,
974 INT32 x
, INT32 y
, INT32 cx
, INT32 cy
,
975 UINT32 flags
, BOOL32 unicode
, BOOL32 _32bit
)
977 HBITMAP32 hbm
, hbmsave
;
982 UINT32 dtflags
= DT_NOCLIP
;
984 UINT32 opcode
= flags
& 0xf;
988 if((opcode
== DST_TEXT
|| opcode
== DST_PREFIXTEXT
) && !len
) /* The string is '\0' terminated */
991 len
= lstrlen32W((LPWSTR
)lp
);
993 len
= lstrlen32A((LPSTR
)lp
);
995 len
= lstrlen32A((LPSTR
)PTR_SEG_TO_LIN(lp
));
998 /* Find out what size the image has if not given by caller */
1002 CURSORICONINFO
*ici
;
1008 case DST_PREFIXTEXT
:
1010 retval
= GetTextExtentPoint32W(hdc
, (LPWSTR
)lp
, len
, &s
);
1012 retval
= GetTextExtentPoint32A(hdc
, (LPSTR
)lp
, len
, &s
);
1014 retval
= GetTextExtentPoint32A(hdc
, PTR_SEG_TO_LIN(lp
), len
, &s
);
1015 if(!retval
) return FALSE
;
1019 ici
= (CURSORICONINFO
*)GlobalLock16((HGLOBAL16
)lp
);
1020 if(!ici
) return FALSE
;
1022 s
.cy
= ici
->nHeight
;
1023 GlobalUnlock16((HGLOBAL16
)lp
);
1027 bmp
= (BITMAPOBJ
*)GDI_GetObjPtr((HBITMAP16
)lp
, BITMAP_MAGIC
);
1028 if(!bmp
) return FALSE
;
1029 s
.cx
= bmp
->bitmap
.bmWidth
;
1030 s
.cy
= bmp
->bitmap
.bmHeight
;
1033 case DST_COMPLEX
: /* cx and cy must be set in this mode */
1046 if(flags
& DSS_RIGHT
) /* This one is not documented in the win32.hlp file */
1047 dtflags
|= DT_RIGHT
;
1048 if(opcode
== DST_TEXT
)
1049 dtflags
|= DT_NOPREFIX
;
1051 /* For DSS_NORMAL we just jam in the image and return */
1052 if((flags
& 0x7ff0) == DSS_NORMAL
)
1054 return PAINTING_DrawStateJam(hdc
, opcode
, func
, lp
, len
, &rc
, dtflags
, unicode
, _32bit
);
1057 /* For all other states we need to convert the image to B/W in a local bitmap */
1058 /* before it is displayed */
1059 fg
= SetTextColor32(hdc
, RGB(0, 0, 0));
1060 bg
= SetBkColor32(hdc
, RGB(255, 255, 255));
1061 hbm
= (HBITMAP32
)NULL
; hbmsave
= (HBITMAP32
)NULL
;
1062 memdc
= (HDC32
)NULL
; hbsave
= (HBRUSH32
)NULL
;
1063 retval
= FALSE
; /* assume failure */
1065 /* From here on we must use "goto cleanup" when something goes wrong */
1066 hbm
= CreateBitmap32(cx
, cy
, 1, 1, NULL
);
1067 if(!hbm
) goto cleanup
;
1068 memdc
= CreateCompatibleDC32(hdc
);
1069 if(!memdc
) goto cleanup
;
1070 hbmsave
= (HBITMAP32
)SelectObject32(memdc
, hbm
);
1071 if(!hbmsave
) goto cleanup
;
1072 rc
.left
= rc
.top
= 0;
1075 if(!FillRect32(memdc
, &rc
, (HBRUSH32
)GetStockObject32(WHITE_BRUSH
))) goto cleanup
;
1076 SetBkColor32(memdc
, RGB(255, 255, 255));
1077 SetTextColor32(memdc
, RGB(0, 0, 0));
1078 hfsave
= (HFONT32
)SelectObject32(memdc
, GetCurrentObject(hdc
, OBJ_FONT
));
1079 if(!hfsave
&& (opcode
== DST_TEXT
|| opcode
== DST_PREFIXTEXT
)) goto cleanup
;
1080 tmp
= PAINTING_DrawStateJam(memdc
, opcode
, func
, lp
, len
, &rc
, dtflags
, unicode
, _32bit
);
1081 if(hfsave
) SelectObject32(memdc
, hfsave
);
1082 if(!tmp
) goto cleanup
;
1084 /* These states cause the image to be dithered */
1085 if(flags
& (DSS_UNION
|DSS_DISABLED
))
1087 hbsave
= (HBRUSH32
)SelectObject32(memdc
, CACHE_GetPattern55AABrush());
1088 if(!hbsave
) goto cleanup
;
1089 tmp
= PatBlt32(memdc
, 0, 0, cx
, cy
, 0x00FA0089);
1090 if(hbsave
) SelectObject32(memdc
, hbsave
);
1091 if(!tmp
) goto cleanup
;
1094 hbsave
= (HBRUSH32
)SelectObject32(hdc
, hbr
? hbr
: GetStockObject32(WHITE_BRUSH
));
1095 if(!hbsave
) goto cleanup
;
1097 if(!BitBlt32(hdc
, x
, y
, cx
, cy
, memdc
, 0, 0, 0x00B8074A)) goto cleanup
;
1099 /* DSS_DEFAULT makes the image boldface */
1100 if(flags
& DSS_DEFAULT
)
1102 if(!BitBlt32(hdc
, x
+1, y
, cx
, cy
, memdc
, 0, 0, 0x00B8074A)) goto cleanup
;
1105 retval
= TRUE
; /* We succeeded */
1108 SetTextColor32(hdc
, fg
);
1109 SetBkColor32(hdc
, bg
);
1111 if(hbsave
) SelectObject32(hdc
, hbsave
);
1112 if(hbmsave
) SelectObject32(memdc
, hbmsave
);
1113 if(hbm
) DeleteObject32(hbm
);
1114 if(memdc
) DeleteDC32(memdc
);
1119 /**********************************************************************
1120 * DrawState32A() (USER32.162)
1122 BOOL32 WINAPI
DrawState32A(HDC32 hdc
, HBRUSH32 hbr
,
1123 DRAWSTATEPROC32 func
, LPARAM ldata
, WPARAM32 wdata
,
1124 INT32 x
, INT32 y
, INT32 cx
, INT32 cy
, UINT32 flags
)
1126 return PAINTING_DrawState32(hdc
, hbr
, func
, ldata
, wdata
, x
, y
, cx
, cy
, flags
, FALSE
, TRUE
);
1129 /**********************************************************************
1130 * DrawState32W() (USER32.163)
1132 BOOL32 WINAPI
DrawState32W(HDC32 hdc
, HBRUSH32 hbr
,
1133 DRAWSTATEPROC32 func
, LPARAM ldata
, WPARAM32 wdata
,
1134 INT32 x
, INT32 y
, INT32 cx
, INT32 cy
, UINT32 flags
)
1136 return PAINTING_DrawState32(hdc
, hbr
, func
, ldata
, wdata
, x
, y
, cx
, cy
, flags
, TRUE
, TRUE
);
1139 /**********************************************************************
1140 * DrawState16() (USER.449)
1142 BOOL16 WINAPI
DrawState16(HDC16 hdc
, HBRUSH16 hbr
,
1143 DRAWSTATEPROC16 func
, LPARAM ldata
, WPARAM16 wdata
,
1144 INT16 x
, INT16 y
, INT16 cx
, INT16 cy
, UINT16 flags
)
1146 return PAINTING_DrawState32(hdc
, hbr
, (DRAWSTATEPROC32
)func
, ldata
, wdata
, x
, y
, cx
, cy
, flags
, FALSE
, FALSE
);
1150 /******************************************************************************
1151 * PolyBezier16 [GDI.502]
1153 BOOL16 WINAPI
PolyBezier16( HDC16 hDc
, const POINT16
* lppt
, INT16 cPoints
)
1157 LPPOINT32 pt32
= (LPPOINT32
)HeapAlloc( GetProcessHeap(), 0,
1158 cPoints
*sizeof(POINT32
) );
1159 if(!pt32
) return FALSE
;
1160 for (i
=cPoints
;i
--;) CONV_POINT16TO32(&(lppt
[i
]),&(pt32
[i
]));
1161 ret
= PolyBezier32(hDc
, pt32
, cPoints
);
1162 HeapFree( GetProcessHeap(), 0, pt32
);
1166 /******************************************************************************
1167 * PolyBezierTo16 [GDI.503]
1169 BOOL16 WINAPI
PolyBezierTo16( HDC16 hDc
, const POINT16
* lppt
, INT16 cPoints
)
1173 LPPOINT32 pt32
= (LPPOINT32
)HeapAlloc( GetProcessHeap(), 0,
1174 cPoints
*sizeof(POINT32
) );
1175 if(!pt32
) return FALSE
;
1176 for (i
=cPoints
;i
--;) CONV_POINT16TO32(&(lppt
[i
]),&(pt32
[i
]));
1177 ret
= PolyBezierTo32(hDc
, pt32
, cPoints
);
1178 HeapFree( GetProcessHeap(), 0, pt32
);
1182 /******************************************************************************
1183 * PolyBezier32 [GDI32.268]
1184 * Draws one or more Bezier curves
1187 * hDc [I] Handle to device context
1188 * lppt [I] Pointer to endpoints and control points
1189 * cPoints [I] Count of endpoints and control points
1193 BOOL32 WINAPI
PolyBezier32( HDC32 hdc
, const POINT32
* lppt
, DWORD cPoints
)
1195 DC
* dc
= DC_GetDCPtr( hdc
);
1196 if(!dc
) return FALSE
;
1197 if(dc
&& PATH_IsPathOpen(dc
->w
.path
))
1198 FIXME(gdi
, "PATH_PolyBezier is not implemented!\n");
1199 /* if(!PATH_PolyBezier(hdc, x, y))
1201 return dc
->funcs
->pPolyBezier
&&
1202 dc
->funcs
->pPolyBezier(dc
, lppt
[0], lppt
+1, cPoints
-1);
1205 /******************************************************************************
1206 * PolyBezierTo32 [GDI32.269]
1207 * Draws one or more Bezier curves
1210 * hDc [I] Handle to device context
1211 * lppt [I] Pointer to endpoints and control points
1212 * cPoints [I] Count of endpoints and control points
1216 BOOL32 WINAPI
PolyBezierTo32( HDC32 hdc
, const POINT32
* lppt
, DWORD cPoints
)
1218 DC
* dc
= DC_GetDCPtr( hdc
);
1221 if(!dc
) return FALSE
;
1222 pt
.x
=dc
->w
.CursPosX
;
1223 pt
.y
=dc
->w
.CursPosY
;
1224 if(dc
&& PATH_IsPathOpen(dc
->w
.path
))
1225 FIXME(gdi
, "PATH_PolyBezierTo is not implemented!\n");
1226 /* if(!PATH_PolyBezier(hdc, x, y))
1228 ret
= dc
->funcs
->pPolyBezier
&&
1229 dc
->funcs
->pPolyBezier(dc
, pt
, lppt
, cPoints
);
1230 if( dc
->funcs
->pMoveToEx
)
1231 dc
->funcs
->pMoveToEx(dc
,lppt
[cPoints
].x
,lppt
[cPoints
].y
,&pt
);
1235 /***************************************************************
1236 * AngleArc (GDI32.5)
1239 BOOL32 WINAPI
AngleArc(HDC32 hdc
, INT32 x
, INT32 y
, DWORD dwRadius
,
1240 FLOAT eStartAngle
, FLOAT eSweepAngle
)
1242 FIXME(gdi
,"AngleArc, stub\n");
1246 /***************************************************************
1247 * PolyDraw (GDI32.270)
1250 BOOL32 WINAPI
PolyDraw(HDC32 hdc
, const POINT32
*lppt
, const BYTE
*lpbTypes
,
1253 FIXME(gdi
,"PolyDraw, stub\n");