2 * Misc. graphics operations
4 * Copyright 1993, 1994 Alexandre Julliard
5 * Copyright 1997 Bertho A. Stultiens
12 #include <X11/Intrinsic.h>
30 /***********************************************************************
33 BOOL16 WINAPI
LineTo16( HDC16 hdc
, INT16 x
, INT16 y
)
35 return LineTo32( hdc
, x
, y
);
39 /***********************************************************************
40 * LineTo32 (GDI32.249)
42 BOOL32 WINAPI
LineTo32( HDC32 hdc
, INT32 x
, INT32 y
)
44 DC
* dc
= DC_GetDCPtr( hdc
);
46 if(dc
&& PATH_IsPathOpen(dc
->w
.path
))
47 if(!PATH_LineTo(hdc
, x
, y
))
50 return dc
&& dc
->funcs
->pLineTo
&&
51 dc
->funcs
->pLineTo(dc
,x
,y
);
55 /***********************************************************************
58 DWORD WINAPI
MoveTo( HDC16 hdc
, INT16 x
, INT16 y
)
62 if (!MoveToEx16(hdc
,x
,y
,&pt
))
64 return MAKELONG(pt
.x
,pt
.y
);
68 /***********************************************************************
69 * MoveToEx16 (GDI.483)
71 BOOL16 WINAPI
MoveToEx16( HDC16 hdc
, INT16 x
, INT16 y
, LPPOINT16 pt
)
75 if (!MoveToEx32( (HDC32
)hdc
, (INT32
)x
, (INT32
)y
, &pt32
)) return FALSE
;
76 if (pt
) CONV_POINT32TO16( &pt32
, pt
);
82 /***********************************************************************
83 * MoveToEx32 (GDI32.254)
85 BOOL32 WINAPI
MoveToEx32( HDC32 hdc
, INT32 x
, INT32 y
, LPPOINT32 pt
)
87 DC
* dc
= DC_GetDCPtr( hdc
);
89 if(dc
&& PATH_IsPathOpen(dc
->w
.path
))
93 return dc
&& dc
->funcs
->pMoveToEx
&&
94 dc
->funcs
->pMoveToEx(dc
,x
,y
,pt
);
98 /***********************************************************************
101 BOOL16 WINAPI
Arc16( HDC16 hdc
, INT16 left
, INT16 top
, INT16 right
,
102 INT16 bottom
, INT16 xstart
, INT16 ystart
,
103 INT16 xend
, INT16 yend
)
105 return Arc32( (HDC32
)hdc
, (INT32
)left
, (INT32
)top
, (INT32
)right
,
106 (INT32
)bottom
, (INT32
)xstart
, (INT32
)ystart
, (INT32
)xend
,
111 /***********************************************************************
114 BOOL32 WINAPI
Arc32( HDC32 hdc
, INT32 left
, INT32 top
, INT32 right
,
115 INT32 bottom
, INT32 xstart
, INT32 ystart
,
116 INT32 xend
, INT32 yend
)
118 DC
* dc
= DC_GetDCPtr( hdc
);
120 if(dc
&& PATH_IsPathOpen(dc
->w
.path
))
121 if(!PATH_Arc(hdc
, left
, top
, right
, bottom
, xstart
, ystart
, xend
,
125 return dc
&& dc
->funcs
->pArc
&&
126 dc
->funcs
->pArc(dc
,left
,top
,right
,bottom
,xstart
,ystart
,xend
,yend
);
130 /***********************************************************************
133 BOOL16 WINAPI
Pie16( HDC16 hdc
, INT16 left
, INT16 top
,
134 INT16 right
, INT16 bottom
, INT16 xstart
, INT16 ystart
,
135 INT16 xend
, INT16 yend
)
137 return Pie32( (HDC32
)hdc
, (INT32
)left
, (INT32
)top
, (INT32
)right
,
138 (INT32
)bottom
, (INT32
)xstart
, (INT32
)ystart
, (INT32
)xend
,
143 /***********************************************************************
146 BOOL32 WINAPI
Pie32( HDC32 hdc
, INT32 left
, INT32 top
,
147 INT32 right
, INT32 bottom
, INT32 xstart
, INT32 ystart
,
148 INT32 xend
, INT32 yend
)
150 DC
* dc
= DC_GetDCPtr( hdc
);
152 return dc
&& dc
->funcs
->pPie
&&
153 dc
->funcs
->pPie(dc
,left
,top
,right
,bottom
,xstart
,ystart
,xend
,yend
);
157 /***********************************************************************
160 BOOL16 WINAPI
Chord16( HDC16 hdc
, INT16 left
, INT16 top
,
161 INT16 right
, INT16 bottom
, INT16 xstart
, INT16 ystart
,
162 INT16 xend
, INT16 yend
)
164 return Chord32( hdc
, left
, top
, right
, bottom
, xstart
, ystart
, xend
, yend
);
168 /***********************************************************************
171 BOOL32 WINAPI
Chord32( HDC32 hdc
, INT32 left
, INT32 top
,
172 INT32 right
, INT32 bottom
, INT32 xstart
, INT32 ystart
,
173 INT32 xend
, INT32 yend
)
175 DC
* dc
= DC_GetDCPtr( hdc
);
177 return dc
&& dc
->funcs
->pChord
&&
178 dc
->funcs
->pChord(dc
,left
,top
,right
,bottom
,xstart
,ystart
,xend
,yend
);
182 /***********************************************************************
185 BOOL16 WINAPI
Ellipse16( HDC16 hdc
, INT16 left
, INT16 top
,
186 INT16 right
, INT16 bottom
)
188 return Ellipse32( hdc
, left
, top
, right
, bottom
);
192 /***********************************************************************
193 * Ellipse32 (GDI32.75)
195 BOOL32 WINAPI
Ellipse32( HDC32 hdc
, INT32 left
, INT32 top
,
196 INT32 right
, INT32 bottom
)
198 DC
* dc
= DC_GetDCPtr( hdc
);
200 return dc
&& dc
->funcs
->pEllipse
&&
201 dc
->funcs
->pEllipse(dc
,left
,top
,right
,bottom
);
205 /***********************************************************************
206 * Rectangle16 (GDI.27)
208 BOOL16 WINAPI
Rectangle16( HDC16 hdc
, INT16 left
, INT16 top
,
209 INT16 right
, INT16 bottom
)
211 return Rectangle32( hdc
, left
, top
, right
, bottom
);
215 /***********************************************************************
216 * Rectangle32 (GDI32.283)
218 BOOL32 WINAPI
Rectangle32( HDC32 hdc
, INT32 left
, INT32 top
,
219 INT32 right
, INT32 bottom
)
221 DC
* dc
= DC_GetDCPtr( hdc
);
223 if(dc
&& PATH_IsPathOpen(dc
->w
.path
))
224 if(!PATH_Rectangle(hdc
, left
, top
, right
, bottom
))
227 return dc
&& dc
->funcs
->pRectangle
&&
228 dc
->funcs
->pRectangle(dc
,left
,top
,right
,bottom
);
232 /***********************************************************************
233 * RoundRect16 (GDI.28)
235 BOOL16 WINAPI
RoundRect16( HDC16 hdc
, INT16 left
, INT16 top
, INT16 right
,
236 INT16 bottom
, INT16 ell_width
, INT16 ell_height
)
238 return RoundRect32( hdc
, left
, top
, right
, bottom
, ell_width
, ell_height
);
242 /***********************************************************************
243 * RoundRect32 (GDI32.291)
245 BOOL32 WINAPI
RoundRect32( HDC32 hdc
, INT32 left
, INT32 top
, INT32 right
,
246 INT32 bottom
, INT32 ell_width
, INT32 ell_height
)
249 if(ell_width
== 0 || ell_height
== 0) /* Just an optimization */
250 return Rectangle32(hdc
, left
, top
, right
, bottom
);
253 DC
* dc
= DC_GetDCPtr( hdc
);
255 return dc
&& dc
->funcs
->pRoundRect
&&
256 dc
->funcs
->pRoundRect(dc
,left
,top
,right
,bottom
,ell_width
,ell_height
);
261 /***********************************************************************
262 * FillRect16 (USER.81)
264 INT16 WINAPI
FillRect16( HDC16 hdc
, const RECT16
*rect
, HBRUSH16 hbrush
)
268 /* coordinates are logical so we cannot fast-check 'rect',
269 * it will be done later in the PatBlt().
272 if (!(prevBrush
= SelectObject16( hdc
, hbrush
))) return 0;
273 PatBlt32( hdc
, rect
->left
, rect
->top
,
274 rect
->right
- rect
->left
, rect
->bottom
- rect
->top
, PATCOPY
);
275 SelectObject16( hdc
, prevBrush
);
280 /***********************************************************************
281 * FillRect32 (USER32.197)
283 INT32 WINAPI
FillRect32( HDC32 hdc
, const RECT32
*rect
, HBRUSH32 hbrush
)
287 if (!(prevBrush
= SelectObject32( hdc
, hbrush
))) return 0;
288 PatBlt32( hdc
, rect
->left
, rect
->top
,
289 rect
->right
- rect
->left
, rect
->bottom
- rect
->top
, PATCOPY
);
290 SelectObject32( hdc
, prevBrush
);
295 /***********************************************************************
296 * InvertRect16 (USER.82)
298 void WINAPI
InvertRect16( HDC16 hdc
, const RECT16
*rect
)
300 PatBlt32( hdc
, rect
->left
, rect
->top
,
301 rect
->right
- rect
->left
, rect
->bottom
- rect
->top
, DSTINVERT
);
305 /***********************************************************************
306 * InvertRect32 (USER32.330)
308 void WINAPI
InvertRect32( HDC32 hdc
, const RECT32
*rect
)
310 PatBlt32( hdc
, rect
->left
, rect
->top
,
311 rect
->right
- rect
->left
, rect
->bottom
- rect
->top
, DSTINVERT
);
315 /***********************************************************************
316 * FrameRect16 (USER.83)
318 INT16 WINAPI
FrameRect16( HDC16 hdc
, const RECT16
*rect
, HBRUSH16 hbrush
)
321 int left
, top
, right
, bottom
;
323 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
324 if (!dc
) return FALSE
;
326 left
= XLPTODP( dc
, rect
->left
);
327 top
= YLPTODP( dc
, rect
->top
);
328 right
= XLPTODP( dc
, rect
->right
);
329 bottom
= YLPTODP( dc
, rect
->bottom
);
331 if ( (right
<= left
) || (bottom
<= top
) ) return 0;
332 if (!(prevBrush
= SelectObject16( hdc
, hbrush
))) return 0;
334 if (DC_SetupGCForBrush( dc
))
336 PatBlt32( hdc
, rect
->left
, rect
->top
, 1,
337 rect
->bottom
- rect
->top
, PATCOPY
);
338 PatBlt32( hdc
, rect
->right
- 1, rect
->top
, 1,
339 rect
->bottom
- rect
->top
, PATCOPY
);
340 PatBlt32( hdc
, rect
->left
, rect
->top
,
341 rect
->right
- rect
->left
, 1, PATCOPY
);
342 PatBlt32( hdc
, rect
->left
, rect
->bottom
- 1,
343 rect
->right
- rect
->left
, 1, PATCOPY
);
345 SelectObject16( hdc
, prevBrush
);
350 /***********************************************************************
351 * FrameRect32 (USER32.203)
353 INT32 WINAPI
FrameRect32( HDC32 hdc
, const RECT32
*rect
, HBRUSH32 hbrush
)
356 CONV_RECT32TO16( rect
, &rect16
);
357 return FrameRect16( (HDC16
)hdc
, &rect16
, (HBRUSH16
)hbrush
);
361 /***********************************************************************
362 * SetPixel16 (GDI.31)
364 COLORREF WINAPI
SetPixel16( HDC16 hdc
, INT16 x
, INT16 y
, COLORREF color
)
366 return SetPixel32( hdc
, x
, y
, color
);
370 /***********************************************************************
371 * SetPixel32 (GDI32.327)
373 COLORREF WINAPI
SetPixel32( HDC32 hdc
, INT32 x
, INT32 y
, COLORREF color
)
375 DC
* dc
= DC_GetDCPtr( hdc
);
377 if (!dc
|| !dc
->funcs
->pSetPixel
) return 0;
378 return dc
->funcs
->pSetPixel(dc
,x
,y
,color
);
381 /***********************************************************************
382 * SetPixelV32 (GDI32.329)
384 BOOL32 WINAPI
SetPixelV32( HDC32 hdc
, INT32 x
, INT32 y
, COLORREF color
)
386 DC
* dc
= DC_GetDCPtr( hdc
);
388 if (!dc
|| !dc
->funcs
->pSetPixel
) return FALSE
;
389 dc
->funcs
->pSetPixel(dc
,x
,y
,color
);
393 /***********************************************************************
394 * GetPixel16 (GDI.83)
396 COLORREF WINAPI
GetPixel16( HDC16 hdc
, INT16 x
, INT16 y
)
398 return GetPixel32( hdc
, x
, y
);
402 /***********************************************************************
403 * GetPixel32 (GDI32.211)
405 COLORREF WINAPI
GetPixel32( HDC32 hdc
, INT32 x
, INT32 y
)
407 DC
* dc
= DC_GetDCPtr( hdc
);
410 #ifdef SOLITAIRE_SPEED_HACK
414 /* FIXME: should this be in the graphics driver? */
415 if (!PtVisible32( hdc
, x
, y
)) return 0;
416 if (!dc
|| !dc
->funcs
->pGetPixel
) return 0;
417 return dc
->funcs
->pGetPixel(dc
,x
,y
);
421 /******************************************************************************
422 * ChoosePixelFormat [GDI32.13]
423 * Matches a pixel format to given format
426 * hdc [I] Device context to search for best pixel match
427 * ppfd [I] Pixel format for which a match is sought
430 * Success: Pixel format index closest to given format
433 INT32 WINAPI
ChoosePixelFormat( HDC32 hdc
, const PIXELFORMATDESCRIPTOR
* ppfd
)
435 FIXME(gdi
, "(%d,%p): stub\n",hdc
,ppfd
);
440 /******************************************************************************
441 * SetPixelFormat [GDI32.328]
442 * Sets pixel format of device context
445 * hdc [I] Device context to search for best pixel match
446 * iPixelFormat [I] Pixel format index
447 * ppfd [I] Pixel format for which a match is sought
451 BOOL32 WINAPI
SetPixelFormat( HDC32 hdc
, int iPixelFormat
,
452 const PIXELFORMATDESCRIPTOR
* ppfd
)
454 FIXME(gdi
, "(%d,%d,%p): stub\n",hdc
,iPixelFormat
,ppfd
);
459 /******************************************************************************
460 * GetPixelFormat [GDI32.212]
461 * Gets index of pixel format of DC
464 * hdc [I] Device context whose pixel format index is sought
467 * Success: Currently selected pixel format
470 int WINAPI
GetPixelFormat( HDC32 hdc
)
472 FIXME(gdi
, "(%d): stub\n",hdc
);
477 /******************************************************************************
478 * DescribePixelFormat [GDI32.71]
479 * Gets info about pixel format from DC
482 * hdc [I] Device context
483 * iPixelFormat [I] Pixel format selector
484 * nBytes [I] Size of buffer
485 * ppfd [O] Pointer to structure to receive pixel format data
488 * Success: Maximum pixel format index of the device context
491 int WINAPI
DescribePixelFormat( HDC32 hdc
, int iPixelFormat
, UINT32 nBytes
,
492 LPPIXELFORMATDESCRIPTOR ppfd
)
494 FIXME(gdi
, "(%d,%d,%d,%p): stub\n",hdc
,iPixelFormat
,nBytes
,ppfd
);
495 ppfd
->nSize
= nBytes
;
501 /******************************************************************************
502 * SwapBuffers [GDI32.354]
503 * Exchanges front and back buffers of window
506 * hdc [I] Device context whose buffers get swapped
510 BOOL32 WINAPI
SwapBuffers( HDC32 hdc
)
512 FIXME(gdi
, "(%d): stub\n",hdc
);
517 /***********************************************************************
518 * PaintRgn16 (GDI.43)
520 BOOL16 WINAPI
PaintRgn16( HDC16 hdc
, HRGN16 hrgn
)
522 return PaintRgn32( hdc
, hrgn
);
526 /***********************************************************************
527 * PaintRgn32 (GDI32.259)
529 BOOL32 WINAPI
PaintRgn32( HDC32 hdc
, HRGN32 hrgn
)
531 DC
* dc
= DC_GetDCPtr( hdc
);
533 return dc
&& dc
->funcs
->pPaintRgn
&&
534 dc
->funcs
->pPaintRgn(dc
,hrgn
);
538 /***********************************************************************
541 BOOL16 WINAPI
FillRgn16( HDC16 hdc
, HRGN16 hrgn
, HBRUSH16 hbrush
)
543 return FillRgn32( hdc
, hrgn
, hbrush
);
547 /***********************************************************************
548 * FillRgn32 (GDI32.101)
550 BOOL32 WINAPI
FillRgn32( HDC32 hdc
, HRGN32 hrgn
, HBRUSH32 hbrush
)
553 HBRUSH32 prevBrush
= SelectObject32( hdc
, hbrush
);
554 if (!prevBrush
) return FALSE
;
555 retval
= PaintRgn32( hdc
, hrgn
);
556 SelectObject32( hdc
, prevBrush
);
561 /***********************************************************************
562 * FrameRgn16 (GDI.41)
564 BOOL16 WINAPI
FrameRgn16( HDC16 hdc
, HRGN16 hrgn
, HBRUSH16 hbrush
,
565 INT16 nWidth
, INT16 nHeight
)
567 return FrameRgn32( hdc
, hrgn
, hbrush
, nWidth
, nHeight
);
571 /***********************************************************************
572 * FrameRgn32 (GDI32.105)
574 BOOL32 WINAPI
FrameRgn32( HDC32 hdc
, HRGN32 hrgn
, HBRUSH32 hbrush
,
575 INT32 nWidth
, INT32 nHeight
)
577 HRGN32 tmp
= CreateRectRgn32( 0, 0, 0, 0 );
578 if(!REGION_FrameRgn( tmp
, hrgn
, nWidth
, nHeight
)) return FALSE
;
579 FillRgn32( hdc
, tmp
, hbrush
);
580 DeleteObject32( tmp
);
585 /***********************************************************************
586 * InvertRgn16 (GDI.42)
588 BOOL16 WINAPI
InvertRgn16( HDC16 hdc
, HRGN16 hrgn
)
590 return InvertRgn32( hdc
, hrgn
);
594 /***********************************************************************
595 * InvertRgn32 (GDI32.246)
597 BOOL32 WINAPI
InvertRgn32( HDC32 hdc
, HRGN32 hrgn
)
599 HBRUSH32 prevBrush
= SelectObject32( hdc
, GetStockObject32(BLACK_BRUSH
) );
600 INT32 prevROP
= SetROP232( hdc
, R2_NOT
);
601 BOOL32 retval
= PaintRgn32( hdc
, hrgn
);
602 SelectObject32( hdc
, prevBrush
);
603 SetROP232( hdc
, prevROP
);
608 /***********************************************************************
609 * DrawFocusRect16 (USER.466)
611 void WINAPI
DrawFocusRect16( HDC16 hdc
, const RECT16
* rc
)
614 CONV_RECT16TO32( rc
, &rect32
);
615 DrawFocusRect32( hdc
, &rect32
);
619 /***********************************************************************
620 * DrawFocusRect32 (USER32.156)
622 * FIXME: PatBlt(PATINVERT) with background brush.
624 void WINAPI
DrawFocusRect32( HDC32 hdc
, const RECT32
* rc
)
626 HPEN32 hOldPen
, hnewPen
;
627 INT32 oldDrawMode
, oldBkMode
;
628 INT32 left
, top
, right
, bottom
;
630 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
633 left
= XLPTODP( dc
, rc
->left
);
634 top
= YLPTODP( dc
, rc
->top
);
635 right
= XLPTODP( dc
, rc
->right
);
636 bottom
= YLPTODP( dc
, rc
->bottom
);
638 if(left
== right
|| top
== bottom
)
641 hnewPen
= CreatePen32(PS_DOT
, 1, GetSysColor32(COLOR_WINDOWTEXT
) );
642 hOldPen
= SelectObject32( hdc
, hnewPen
);
643 oldDrawMode
= SetROP232(hdc
, R2_XORPEN
);
644 oldBkMode
= SetBkMode32(hdc
, TRANSPARENT
);
646 /* Hack: make sure the XORPEN operation has an effect */
647 dc
->u
.x
.pen
.pixel
= (1 << screenDepth
) - 1;
649 if (DC_SetupGCForPen( dc
))
650 TSXDrawRectangle( display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
,
651 dc
->w
.DCOrgX
+ left
, dc
->w
.DCOrgY
+ top
,
652 right
-left
-1, bottom
-top
-1 );
654 SetBkMode32(hdc
, oldBkMode
);
655 SetROP232(hdc
, oldDrawMode
);
656 SelectObject32(hdc
, hOldPen
);
657 DeleteObject32(hnewPen
);
661 /**********************************************************************
662 * Polyline16 (GDI.37)
664 BOOL16 WINAPI
Polyline16( HDC16 hdc
, const POINT16
* pt
, INT16 count
)
668 LPPOINT32 pt32
= (LPPOINT32
)HeapAlloc( GetProcessHeap(), 0,
669 count
*sizeof(POINT32
) );
671 if (!pt32
) return FALSE
;
672 for (i
=count
;i
--;) CONV_POINT16TO32(&(pt
[i
]),&(pt32
[i
]));
673 ret
= Polyline32(hdc
,pt32
,count
);
674 HeapFree( GetProcessHeap(), 0, pt32
);
679 /**********************************************************************
680 * Polyline32 (GDI32.276)
682 BOOL32 WINAPI
Polyline32( HDC32 hdc
, const POINT32
* pt
, INT32 count
)
684 DC
* dc
= DC_GetDCPtr( hdc
);
686 return dc
&& dc
->funcs
->pPolyline
&&
687 dc
->funcs
->pPolyline(dc
,pt
,count
);
691 /**********************************************************************
694 BOOL16 WINAPI
Polygon16( HDC16 hdc
, const POINT16
* pt
, INT16 count
)
698 LPPOINT32 pt32
= (LPPOINT32
)HeapAlloc( GetProcessHeap(), 0,
699 count
*sizeof(POINT32
) );
701 if (!pt32
) return FALSE
;
702 for (i
=count
;i
--;) CONV_POINT16TO32(&(pt
[i
]),&(pt32
[i
]));
703 ret
= Polygon32(hdc
,pt32
,count
);
704 HeapFree( GetProcessHeap(), 0, pt32
);
709 /**********************************************************************
710 * Polygon32 (GDI32.275)
712 BOOL32 WINAPI
Polygon32( HDC32 hdc
, const POINT32
* pt
, INT32 count
)
714 DC
* dc
= DC_GetDCPtr( hdc
);
716 return dc
&& dc
->funcs
->pPolygon
&&
717 dc
->funcs
->pPolygon(dc
,pt
,count
);
721 /**********************************************************************
722 * PolyPolygon16 (GDI.450)
724 BOOL16 WINAPI
PolyPolygon16( HDC16 hdc
, const POINT16
* pt
, const INT16
* counts
,
733 for (i
=polygons
;i
--;)
735 pt32
= (LPPOINT32
)HEAP_xalloc( GetProcessHeap(), 0, sizeof(POINT32
)*nrpts
);
737 CONV_POINT16TO32(&(pt
[i
]),&(pt32
[i
]));
738 counts32
= (LPINT32
)HEAP_xalloc( GetProcessHeap(), 0,
739 polygons
*sizeof(INT32
) );
740 for (i
=polygons
;i
--;) counts32
[i
]=counts
[i
];
742 ret
= PolyPolygon32(hdc
,pt32
,counts32
,polygons
);
743 HeapFree( GetProcessHeap(), 0, counts32
);
744 HeapFree( GetProcessHeap(), 0, pt32
);
748 /**********************************************************************
749 * PolyPolygon32 (GDI.450)
751 BOOL32 WINAPI
PolyPolygon32( HDC32 hdc
, const POINT32
* pt
, const INT32
* counts
,
754 DC
* dc
= DC_GetDCPtr( hdc
);
756 return dc
&& dc
->funcs
->pPolyPolygon
&&
757 dc
->funcs
->pPolyPolygon(dc
,pt
,counts
,polygons
);
760 /**********************************************************************
761 * PolyPolyline32 (GDI32.272)
763 BOOL32 WINAPI
PolyPolyline32( HDC32 hdc
, const POINT32
* pt
, const DWORD
* counts
,
766 DC
* dc
= DC_GetDCPtr( hdc
);
768 return dc
&& dc
->funcs
->pPolyPolyline
&&
769 dc
->funcs
->pPolyPolyline(dc
,pt
,counts
,polylines
);
772 /**********************************************************************
773 * ExtFloodFill16 (GDI.372)
775 BOOL16 WINAPI
ExtFloodFill16( HDC16 hdc
, INT16 x
, INT16 y
, COLORREF color
,
778 return ExtFloodFill32( hdc
, x
, y
, color
, fillType
);
782 /**********************************************************************
783 * ExtFloodFill32 (GDI32.96)
785 BOOL32 WINAPI
ExtFloodFill32( HDC32 hdc
, INT32 x
, INT32 y
, COLORREF color
,
788 DC
*dc
= DC_GetDCPtr( hdc
);
790 return dc
&& dc
->funcs
->pExtFloodFill
&&
791 dc
->funcs
->pExtFloodFill(dc
,x
,y
,color
,fillType
);
795 /**********************************************************************
796 * FloodFill16 (GDI.25)
798 BOOL16 WINAPI
FloodFill16( HDC16 hdc
, INT16 x
, INT16 y
, COLORREF color
)
800 return ExtFloodFill32( hdc
, x
, y
, color
, FLOODFILLBORDER
);
804 /**********************************************************************
805 * FloodFill32 (GDI32.104)
807 BOOL32 WINAPI
FloodFill32( HDC32 hdc
, INT32 x
, INT32 y
, COLORREF color
)
809 return ExtFloodFill32( hdc
, x
, y
, color
, FLOODFILLBORDER
);
813 /**********************************************************************
814 * DrawAnimatedRects32 (USER32.153)
816 BOOL32 WINAPI
DrawAnimatedRects32( HWND32 hwnd
, int idAni
,
817 const RECT32
* lprcFrom
,
818 const RECT32
* lprcTo
)
820 FIXME(gdi
,"(0x%x,%d,%p,%p): stub\n",hwnd
,idAni
,lprcFrom
,lprcTo
);
825 /**********************************************************************
826 * PAINTING_DrawStateJam
828 * Jams in the requested type in the dc
830 static BOOL32
PAINTING_DrawStateJam(HDC32 hdc
, UINT32 opcode
,
831 DRAWSTATEPROC32 func
, LPARAM lp
, WPARAM32 wp
,
832 LPRECT32 rc
, UINT32 dtflags
,
833 BOOL32 unicode
, BOOL32 _32bit
)
838 INT32 cx
= rc
->right
- rc
->left
;
839 INT32 cy
= rc
->bottom
- rc
->top
;
846 return DrawText32W(hdc
, (LPWSTR
)lp
, (INT32
)wp
, rc
, dtflags
);
848 return DrawText32A(hdc
, (LPSTR
)lp
, (INT32
)wp
, rc
, dtflags
);
850 return DrawText32A(hdc
, (LPSTR
)PTR_SEG_TO_LIN(lp
), (INT32
)wp
, rc
, dtflags
);
853 return DrawIcon32(hdc
, rc
->left
, rc
->top
, (HICON32
)lp
);
856 memdc
= CreateCompatibleDC32(hdc
);
857 if(!memdc
) return FALSE
;
858 hbmsave
= (HBITMAP32
)SelectObject32(memdc
, (HBITMAP32
)lp
);
864 retval
= BitBlt32(hdc
, rc
->left
, rc
->top
, cx
, cy
, memdc
, 0, 0, SRCCOPY
);
865 SelectObject32(memdc
, hbmsave
);
872 return func(hdc
, lp
, wp
, cx
, cy
);
874 return (BOOL32
)((DRAWSTATEPROC16
)func
)((HDC16
)hdc
, (LPARAM
)lp
, (WPARAM16
)wp
, (INT16
)cx
, (INT16
)cy
);
881 /**********************************************************************
882 * PAINTING_DrawState32()
884 static BOOL32
PAINTING_DrawState32(HDC32 hdc
, HBRUSH32 hbr
,
885 DRAWSTATEPROC32 func
, LPARAM lp
, WPARAM32 wp
,
886 INT32 x
, INT32 y
, INT32 cx
, INT32 cy
,
887 UINT32 flags
, BOOL32 unicode
, BOOL32 _32bit
)
889 HBITMAP32 hbm
, hbmsave
;
894 UINT32 dtflags
= DT_NOCLIP
;
896 UINT32 opcode
= flags
& 0xf;
900 if((opcode
== DST_TEXT
|| opcode
== DST_PREFIXTEXT
) && !len
) /* The string is '\0' terminated */
903 len
= lstrlen32W((LPWSTR
)lp
);
905 len
= lstrlen32A((LPSTR
)lp
);
907 len
= lstrlen32A((LPSTR
)PTR_SEG_TO_LIN(lp
));
910 /* Find out what size the image has if not given by caller */
922 retval
= GetTextExtentPoint32W(hdc
, (LPWSTR
)lp
, len
, &s
);
924 retval
= GetTextExtentPoint32A(hdc
, (LPSTR
)lp
, len
, &s
);
926 retval
= GetTextExtentPoint32A(hdc
, PTR_SEG_TO_LIN(lp
), len
, &s
);
927 if(!retval
) return FALSE
;
931 ici
= (CURSORICONINFO
*)GlobalLock16((HGLOBAL16
)lp
);
932 if(!ici
) return FALSE
;
935 GlobalUnlock16((HGLOBAL16
)lp
);
939 bmp
= (BITMAPOBJ
*)GDI_GetObjPtr((HBITMAP16
)lp
, BITMAP_MAGIC
);
940 if(!bmp
) return FALSE
;
941 s
.cx
= bmp
->bitmap
.bmWidth
;
942 s
.cy
= bmp
->bitmap
.bmHeight
;
945 case DST_COMPLEX
: /* cx and cy must be set in this mode */
958 if(flags
& DSS_RIGHT
) /* This one is not documented in the win32.hlp file */
960 if(opcode
== DST_TEXT
)
961 dtflags
|= DT_NOPREFIX
;
963 /* For DSS_NORMAL we just jam in the image and return */
964 if((flags
& 0x7ff0) == DSS_NORMAL
)
966 return PAINTING_DrawStateJam(hdc
, opcode
, func
, lp
, len
, &rc
, dtflags
, unicode
, _32bit
);
969 /* For all other states we need to convert the image to B/W in a local bitmap */
970 /* before it is displayed */
971 fg
= SetTextColor32(hdc
, RGB(0, 0, 0));
972 bg
= SetBkColor32(hdc
, RGB(255, 255, 255));
973 hbm
= (HBITMAP32
)NULL
; hbmsave
= (HBITMAP32
)NULL
;
974 memdc
= (HDC32
)NULL
; hbsave
= (HBRUSH32
)NULL
;
975 retval
= FALSE
; /* assume failure */
977 /* From here on we must use "goto cleanup" when something goes wrong */
978 hbm
= CreateBitmap32(cx
, cy
, 1, 1, NULL
);
979 if(!hbm
) goto cleanup
;
980 memdc
= CreateCompatibleDC32(hdc
);
981 if(!memdc
) goto cleanup
;
982 hbmsave
= (HBITMAP32
)SelectObject32(memdc
, hbm
);
983 if(!hbmsave
) goto cleanup
;
984 rc
.left
= rc
.top
= 0;
987 if(!FillRect32(memdc
, &rc
, (HBRUSH32
)GetStockObject32(WHITE_BRUSH
))) goto cleanup
;
988 SetBkColor32(memdc
, RGB(255, 255, 255));
989 SetTextColor32(memdc
, RGB(0, 0, 0));
990 hfsave
= (HFONT32
)SelectObject32(memdc
, GetCurrentObject(hdc
, OBJ_FONT
));
991 if(!hfsave
&& (opcode
== DST_TEXT
|| opcode
== DST_PREFIXTEXT
)) goto cleanup
;
992 tmp
= PAINTING_DrawStateJam(memdc
, opcode
, func
, lp
, len
, &rc
, dtflags
, unicode
, _32bit
);
993 if(hfsave
) SelectObject32(memdc
, hfsave
);
994 if(!tmp
) goto cleanup
;
996 /* These states cause the image to be dithered */
997 if(flags
& (DSS_UNION
|DSS_DISABLED
))
999 hbsave
= (HBRUSH32
)SelectObject32(memdc
, CACHE_GetPattern55AABrush());
1000 if(!hbsave
) goto cleanup
;
1001 tmp
= PatBlt32(memdc
, 0, 0, cx
, cy
, 0x00FA0089);
1002 if(hbsave
) SelectObject32(memdc
, hbsave
);
1003 if(!tmp
) goto cleanup
;
1006 hbsave
= (HBRUSH32
)SelectObject32(hdc
, hbr
? hbr
: GetStockObject32(WHITE_BRUSH
));
1007 if(!hbsave
) goto cleanup
;
1009 if(!BitBlt32(hdc
, x
, y
, cx
, cy
, memdc
, 0, 0, 0x00B8074A)) goto cleanup
;
1011 /* DSS_DEFAULT makes the image boldface */
1012 if(flags
& DSS_DEFAULT
)
1014 if(!BitBlt32(hdc
, x
+1, y
, cx
, cy
, memdc
, 0, 0, 0x00B8074A)) goto cleanup
;
1017 retval
= TRUE
; /* We succeeded */
1020 SetTextColor32(hdc
, fg
);
1021 SetBkColor32(hdc
, bg
);
1023 if(hbsave
) SelectObject32(hdc
, hbsave
);
1024 if(hbmsave
) SelectObject32(memdc
, hbmsave
);
1025 if(hbm
) DeleteObject32(hbm
);
1026 if(memdc
) DeleteDC32(memdc
);
1031 /**********************************************************************
1032 * DrawState32A() (USER32.162)
1034 BOOL32 WINAPI
DrawState32A(HDC32 hdc
, HBRUSH32 hbr
,
1035 DRAWSTATEPROC32 func
, LPARAM ldata
, WPARAM32 wdata
,
1036 INT32 x
, INT32 y
, INT32 cx
, INT32 cy
, UINT32 flags
)
1038 return PAINTING_DrawState32(hdc
, hbr
, func
, ldata
, wdata
, x
, y
, cx
, cy
, flags
, FALSE
, TRUE
);
1041 /**********************************************************************
1042 * DrawState32W() (USER32.163)
1044 BOOL32 WINAPI
DrawState32W(HDC32 hdc
, HBRUSH32 hbr
,
1045 DRAWSTATEPROC32 func
, LPARAM ldata
, WPARAM32 wdata
,
1046 INT32 x
, INT32 y
, INT32 cx
, INT32 cy
, UINT32 flags
)
1048 return PAINTING_DrawState32(hdc
, hbr
, func
, ldata
, wdata
, x
, y
, cx
, cy
, flags
, TRUE
, TRUE
);
1051 /**********************************************************************
1052 * DrawState16() (USER.449)
1054 BOOL16 WINAPI
DrawState16(HDC16 hdc
, HBRUSH16 hbr
,
1055 DRAWSTATEPROC16 func
, LPARAM ldata
, WPARAM16 wdata
,
1056 INT16 x
, INT16 y
, INT16 cx
, INT16 cy
, UINT16 flags
)
1058 return PAINTING_DrawState32(hdc
, hbr
, (DRAWSTATEPROC32
)func
, ldata
, wdata
, x
, y
, cx
, cy
, flags
, FALSE
, FALSE
);
1062 /******************************************************************************
1063 * PolyBezier16 [GDI.502]
1065 BOOL16 WINAPI
PolyBezier16( HDC16 hDc
, const POINT16
* lppt
, INT16 cPoints
)
1069 LPPOINT32 pt32
= (LPPOINT32
)HeapAlloc( GetProcessHeap(), 0,
1070 cPoints
*sizeof(POINT32
) );
1071 if(!pt32
) return FALSE
;
1072 for (i
=cPoints
;i
--;) CONV_POINT16TO32(&(lppt
[i
]),&(pt32
[i
]));
1073 ret
= PolyBezier32(hDc
, pt32
, cPoints
);
1074 HeapFree( GetProcessHeap(), 0, pt32
);
1078 /******************************************************************************
1079 * PolyBezierTo16 [GDI.503]
1081 BOOL16 WINAPI
PolyBezierTo16( HDC16 hDc
, const POINT16
* lppt
, INT16 cPoints
)
1085 LPPOINT32 pt32
= (LPPOINT32
)HeapAlloc( GetProcessHeap(), 0,
1086 cPoints
*sizeof(POINT32
) );
1087 if(!pt32
) return FALSE
;
1088 for (i
=cPoints
;i
--;) CONV_POINT16TO32(&(lppt
[i
]),&(pt32
[i
]));
1089 ret
= PolyBezierTo32(hDc
, pt32
, cPoints
);
1090 HeapFree( GetProcessHeap(), 0, pt32
);
1094 /******************************************************************************
1095 * PolyBezier32 [GDI32.268]
1096 * Draws one or more Bezier curves
1099 * hDc [I] Handle to device context
1100 * lppt [I] Pointer to endpoints and control points
1101 * cPoints [I] Count of endpoints and control points
1105 BOOL32 WINAPI
PolyBezier32( HDC32 hdc
, const POINT32
* lppt
, DWORD cPoints
)
1107 DC
* dc
= DC_GetDCPtr( hdc
);
1108 if(!dc
) return FALSE
;
1109 if(dc
&& PATH_IsPathOpen(dc
->w
.path
))
1110 FIXME(gdi
, "PATH_PolyBezier is not implemented!\n");
1111 /* if(!PATH_PolyBezier(hdc, x, y))
1113 return dc
->funcs
->pPolyBezier
&&
1114 dc
->funcs
->pPolyBezier(dc
, lppt
[0], lppt
+1, cPoints
-1);
1117 /******************************************************************************
1118 * PolyBezierTo32 [GDI32.269]
1119 * Draws one or more Bezier curves
1122 * hDc [I] Handle to device context
1123 * lppt [I] Pointer to endpoints and control points
1124 * cPoints [I] Count of endpoints and control points
1128 BOOL32 WINAPI
PolyBezierTo32( HDC32 hdc
, const POINT32
* lppt
, DWORD cPoints
)
1130 DC
* dc
= DC_GetDCPtr( hdc
);
1133 if(!dc
) return FALSE
;
1134 pt
.x
=dc
->w
.CursPosX
;
1135 pt
.y
=dc
->w
.CursPosY
;
1136 if(dc
&& PATH_IsPathOpen(dc
->w
.path
))
1137 FIXME(gdi
, "PATH_PolyBezierTo is not implemented!\n");
1138 /* if(!PATH_PolyBezier(hdc, x, y))
1140 ret
= dc
->funcs
->pPolyBezier
&&
1141 dc
->funcs
->pPolyBezier(dc
, pt
, lppt
, cPoints
);
1142 if( dc
->funcs
->pMoveToEx
)
1143 dc
->funcs
->pMoveToEx(dc
,lppt
[cPoints
].x
,lppt
[cPoints
].y
,&pt
);
1147 INT32 WINAPI
EndDoc32(HDC32 a
)
1149 FIXME(gdi
,"stub\n");
1150 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1151 return 0; /* failure*/
1154 INT32 WINAPI
StartDoc32A(HDC32 hdc
,const DOCINFO32A
* doc
)
1156 FIXME(gdi
,"stub\n");
1157 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1158 return 0; /* failure*/