2 * Misc. graphics operations
4 * Copyright 1993, 1994 Alexandre Julliard
5 * Copyright 1997 Bertho A. Stultiens
12 #include <X11/Intrinsic.h>
29 /***********************************************************************
32 BOOL16 WINAPI
LineTo16( HDC16 hdc
, INT16 x
, INT16 y
)
34 return LineTo32( hdc
, x
, y
);
38 /***********************************************************************
39 * LineTo32 (GDI32.249)
41 BOOL32 WINAPI
LineTo32( HDC32 hdc
, INT32 x
, INT32 y
)
43 DC
* dc
= DC_GetDCPtr( hdc
);
45 if(dc
&& PATH_IsPathOpen(dc
->w
.path
))
46 if(!PATH_LineTo(hdc
, x
, y
))
49 return dc
&& dc
->funcs
->pLineTo
&&
50 dc
->funcs
->pLineTo(dc
,x
,y
);
54 /***********************************************************************
57 DWORD WINAPI
MoveTo( HDC16 hdc
, INT16 x
, INT16 y
)
61 if (!MoveToEx16(hdc
,x
,y
,&pt
))
63 return MAKELONG(pt
.x
,pt
.y
);
67 /***********************************************************************
68 * MoveToEx16 (GDI.483)
70 BOOL16 WINAPI
MoveToEx16( HDC16 hdc
, INT16 x
, INT16 y
, LPPOINT16 pt
)
74 if (!MoveToEx32( (HDC32
)hdc
, (INT32
)x
, (INT32
)y
, &pt32
)) return FALSE
;
75 if (pt
) CONV_POINT32TO16( &pt32
, pt
);
81 /***********************************************************************
82 * MoveToEx32 (GDI32.254)
84 BOOL32 WINAPI
MoveToEx32( HDC32 hdc
, INT32 x
, INT32 y
, LPPOINT32 pt
)
86 DC
* dc
= DC_GetDCPtr( hdc
);
88 if(dc
&& PATH_IsPathOpen(dc
->w
.path
))
92 return dc
&& dc
->funcs
->pMoveToEx
&&
93 dc
->funcs
->pMoveToEx(dc
,x
,y
,pt
);
97 /***********************************************************************
100 BOOL16 WINAPI
Arc16( HDC16 hdc
, INT16 left
, INT16 top
, INT16 right
,
101 INT16 bottom
, INT16 xstart
, INT16 ystart
,
102 INT16 xend
, INT16 yend
)
104 return Arc32( (HDC32
)hdc
, (INT32
)left
, (INT32
)top
, (INT32
)right
,
105 (INT32
)bottom
, (INT32
)xstart
, (INT32
)ystart
, (INT32
)xend
,
110 /***********************************************************************
113 BOOL32 WINAPI
Arc32( HDC32 hdc
, INT32 left
, INT32 top
, INT32 right
,
114 INT32 bottom
, INT32 xstart
, INT32 ystart
,
115 INT32 xend
, INT32 yend
)
117 DC
* dc
= DC_GetDCPtr( hdc
);
119 if(dc
&& PATH_IsPathOpen(dc
->w
.path
))
120 if(!PATH_Arc(hdc
, left
, top
, right
, bottom
, xstart
, ystart
, xend
,
124 return dc
&& dc
->funcs
->pArc
&&
125 dc
->funcs
->pArc(dc
,left
,top
,right
,bottom
,xstart
,ystart
,xend
,yend
);
129 /***********************************************************************
132 BOOL16 WINAPI
Pie16( HDC16 hdc
, INT16 left
, INT16 top
,
133 INT16 right
, INT16 bottom
, INT16 xstart
, INT16 ystart
,
134 INT16 xend
, INT16 yend
)
136 return Pie32( (HDC32
)hdc
, (INT32
)left
, (INT32
)top
, (INT32
)right
,
137 (INT32
)bottom
, (INT32
)xstart
, (INT32
)ystart
, (INT32
)xend
,
142 /***********************************************************************
145 BOOL32 WINAPI
Pie32( HDC32 hdc
, INT32 left
, INT32 top
,
146 INT32 right
, INT32 bottom
, INT32 xstart
, INT32 ystart
,
147 INT32 xend
, INT32 yend
)
149 DC
* dc
= DC_GetDCPtr( hdc
);
151 return dc
&& dc
->funcs
->pPie
&&
152 dc
->funcs
->pPie(dc
,left
,top
,right
,bottom
,xstart
,ystart
,xend
,yend
);
156 /***********************************************************************
159 BOOL16 WINAPI
Chord16( HDC16 hdc
, INT16 left
, INT16 top
,
160 INT16 right
, INT16 bottom
, INT16 xstart
, INT16 ystart
,
161 INT16 xend
, INT16 yend
)
163 return Chord32( hdc
, left
, top
, right
, bottom
, xstart
, ystart
, xend
, yend
);
167 /***********************************************************************
170 BOOL32 WINAPI
Chord32( HDC32 hdc
, INT32 left
, INT32 top
,
171 INT32 right
, INT32 bottom
, INT32 xstart
, INT32 ystart
,
172 INT32 xend
, INT32 yend
)
174 DC
* dc
= DC_GetDCPtr( hdc
);
176 return dc
&& dc
->funcs
->pChord
&&
177 dc
->funcs
->pChord(dc
,left
,top
,right
,bottom
,xstart
,ystart
,xend
,yend
);
181 /***********************************************************************
184 BOOL16 WINAPI
Ellipse16( HDC16 hdc
, INT16 left
, INT16 top
,
185 INT16 right
, INT16 bottom
)
187 return Ellipse32( hdc
, left
, top
, right
, bottom
);
191 /***********************************************************************
192 * Ellipse32 (GDI32.75)
194 BOOL32 WINAPI
Ellipse32( HDC32 hdc
, INT32 left
, INT32 top
,
195 INT32 right
, INT32 bottom
)
197 DC
* dc
= DC_GetDCPtr( hdc
);
199 return dc
&& dc
->funcs
->pEllipse
&&
200 dc
->funcs
->pEllipse(dc
,left
,top
,right
,bottom
);
204 /***********************************************************************
205 * Rectangle16 (GDI.27)
207 BOOL16 WINAPI
Rectangle16( HDC16 hdc
, INT16 left
, INT16 top
,
208 INT16 right
, INT16 bottom
)
210 return Rectangle32( hdc
, left
, top
, right
, bottom
);
214 /***********************************************************************
215 * Rectangle32 (GDI32.283)
217 BOOL32 WINAPI
Rectangle32( HDC32 hdc
, INT32 left
, INT32 top
,
218 INT32 right
, INT32 bottom
)
220 DC
* dc
= DC_GetDCPtr( hdc
);
222 if(dc
&& PATH_IsPathOpen(dc
->w
.path
))
223 if(!PATH_Rectangle(hdc
, left
, top
, right
, bottom
))
226 return dc
&& dc
->funcs
->pRectangle
&&
227 dc
->funcs
->pRectangle(dc
,left
,top
,right
,bottom
);
231 /***********************************************************************
232 * RoundRect16 (GDI.28)
234 BOOL16 WINAPI
RoundRect16( HDC16 hdc
, INT16 left
, INT16 top
, INT16 right
,
235 INT16 bottom
, INT16 ell_width
, INT16 ell_height
)
237 return RoundRect32( hdc
, left
, top
, right
, bottom
, ell_width
, ell_height
);
241 /***********************************************************************
242 * RoundRect32 (GDI32.291)
244 BOOL32 WINAPI
RoundRect32( HDC32 hdc
, INT32 left
, INT32 top
, INT32 right
,
245 INT32 bottom
, INT32 ell_width
, INT32 ell_height
)
247 DC
* dc
= DC_GetDCPtr( hdc
);
249 return dc
&& dc
->funcs
->pRoundRect
&&
250 dc
->funcs
->pRoundRect(dc
,left
,top
,right
,bottom
,ell_width
,ell_height
);
254 /***********************************************************************
255 * FillRect16 (USER.81)
257 INT16 WINAPI
FillRect16( HDC16 hdc
, const RECT16
*rect
, HBRUSH16 hbrush
)
261 /* coordinates are logical so we cannot fast-check 'rect',
262 * it will be done later in the PatBlt().
265 if (!(prevBrush
= SelectObject16( hdc
, hbrush
))) return 0;
266 PatBlt32( hdc
, rect
->left
, rect
->top
,
267 rect
->right
- rect
->left
, rect
->bottom
- rect
->top
, PATCOPY
);
268 SelectObject16( hdc
, prevBrush
);
273 /***********************************************************************
274 * FillRect32 (USER32.197)
276 INT32 WINAPI
FillRect32( HDC32 hdc
, const RECT32
*rect
, HBRUSH32 hbrush
)
280 if (!(prevBrush
= SelectObject32( hdc
, hbrush
))) return 0;
281 PatBlt32( hdc
, rect
->left
, rect
->top
,
282 rect
->right
- rect
->left
, rect
->bottom
- rect
->top
, PATCOPY
);
283 SelectObject32( hdc
, prevBrush
);
288 /***********************************************************************
289 * InvertRect16 (USER.82)
291 void WINAPI
InvertRect16( HDC16 hdc
, const RECT16
*rect
)
293 PatBlt32( hdc
, rect
->left
, rect
->top
,
294 rect
->right
- rect
->left
, rect
->bottom
- rect
->top
, DSTINVERT
);
298 /***********************************************************************
299 * InvertRect32 (USER32.330)
301 void WINAPI
InvertRect32( HDC32 hdc
, const RECT32
*rect
)
303 PatBlt32( hdc
, rect
->left
, rect
->top
,
304 rect
->right
- rect
->left
, rect
->bottom
- rect
->top
, DSTINVERT
);
308 /***********************************************************************
309 * FrameRect16 (USER.83)
311 INT16 WINAPI
FrameRect16( HDC16 hdc
, const RECT16
*rect
, HBRUSH16 hbrush
)
314 int left
, top
, right
, bottom
;
316 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
317 if (!dc
) return FALSE
;
319 left
= XLPTODP( dc
, rect
->left
);
320 top
= YLPTODP( dc
, rect
->top
);
321 right
= XLPTODP( dc
, rect
->right
);
322 bottom
= YLPTODP( dc
, rect
->bottom
);
324 if ( (right
<= left
) || (bottom
<= top
) ) return 0;
325 if (!(prevBrush
= SelectObject16( hdc
, hbrush
))) return 0;
327 if (DC_SetupGCForBrush( dc
))
329 PatBlt32( hdc
, rect
->left
, rect
->top
, 1,
330 rect
->bottom
- rect
->top
, PATCOPY
);
331 PatBlt32( hdc
, rect
->right
- 1, rect
->top
, 1,
332 rect
->bottom
- rect
->top
, PATCOPY
);
333 PatBlt32( hdc
, rect
->left
, rect
->top
,
334 rect
->right
- rect
->left
, 1, PATCOPY
);
335 PatBlt32( hdc
, rect
->left
, rect
->bottom
- 1,
336 rect
->right
- rect
->left
, 1, PATCOPY
);
338 SelectObject16( hdc
, prevBrush
);
343 /***********************************************************************
344 * FrameRect32 (USER32.203)
346 INT32 WINAPI
FrameRect32( HDC32 hdc
, const RECT32
*rect
, HBRUSH32 hbrush
)
349 CONV_RECT32TO16( rect
, &rect16
);
350 return FrameRect16( (HDC16
)hdc
, &rect16
, (HBRUSH16
)hbrush
);
354 /***********************************************************************
355 * SetPixel16 (GDI.31)
357 COLORREF WINAPI
SetPixel16( HDC16 hdc
, INT16 x
, INT16 y
, COLORREF color
)
359 return SetPixel32( hdc
, x
, y
, color
);
363 /***********************************************************************
364 * SetPixel32 (GDI32.327)
366 COLORREF WINAPI
SetPixel32( HDC32 hdc
, INT32 x
, INT32 y
, COLORREF color
)
368 DC
* dc
= DC_GetDCPtr( hdc
);
370 if (!dc
|| !dc
->funcs
->pSetPixel
) return 0;
371 return dc
->funcs
->pSetPixel(dc
,x
,y
,color
);
374 /***********************************************************************
375 * SetPixelV32 (GDI32.329)
377 BOOL32 WINAPI
SetPixelV32( HDC32 hdc
, INT32 x
, INT32 y
, COLORREF color
)
379 DC
* dc
= DC_GetDCPtr( hdc
);
381 if (!dc
|| !dc
->funcs
->pSetPixel
) return FALSE
;
382 dc
->funcs
->pSetPixel(dc
,x
,y
,color
);
386 /***********************************************************************
387 * GetPixel16 (GDI.83)
389 COLORREF WINAPI
GetPixel16( HDC16 hdc
, INT16 x
, INT16 y
)
391 return GetPixel32( hdc
, x
, y
);
395 /***********************************************************************
396 * GetPixel32 (GDI32.211)
398 COLORREF WINAPI
GetPixel32( HDC32 hdc
, INT32 x
, INT32 y
)
400 DC
* dc
= DC_GetDCPtr( hdc
);
403 #ifdef SOLITAIRE_SPEED_HACK
407 /* FIXME: should this be in the graphics driver? */
408 if (!PtVisible32( hdc
, x
, y
)) return 0;
409 if (!dc
|| !dc
->funcs
->pGetPixel
) return 0;
410 return dc
->funcs
->pGetPixel(dc
,x
,y
);
414 /******************************************************************************
415 * ChoosePixelFormat [GDI32.13]
416 * Matches a pixel format to given format
419 * hdc [I] Device context to search for best pixel match
420 * ppfd [I] Pixel format for which a match is sought
423 * Success: Pixel format index closest to given format
426 INT32 WINAPI
ChoosePixelFormat( HDC32 hdc
, const PIXELFORMATDESCRIPTOR
* ppfd
)
428 FIXME(gdi
, "(%d,%p): stub\n",hdc
,ppfd
);
433 /******************************************************************************
434 * SetPixelFormat [GDI32.328]
435 * Sets pixel format of device context
438 * hdc [I] Device context to search for best pixel match
439 * iPixelFormat [I] Pixel format index
440 * ppfd [I] Pixel format for which a match is sought
444 BOOL32 WINAPI
SetPixelFormat( HDC32 hdc
, int iPixelFormat
,
445 const PIXELFORMATDESCRIPTOR
* ppfd
)
447 FIXME(gdi
, "(%d,%d,%p): stub\n",hdc
,iPixelFormat
,ppfd
);
452 /******************************************************************************
453 * GetPixelFormat [GDI32.212]
454 * Gets index of pixel format of DC
457 * hdc [I] Device context whose pixel format index is sought
460 * Success: Currently selected pixel format
463 int WINAPI
GetPixelFormat( HDC32 hdc
)
465 FIXME(gdi
, "(%d): stub\n",hdc
);
470 /******************************************************************************
471 * DescribePixelFormat [GDI32.71]
472 * Gets info about pixel format from DC
475 * hdc [I] Device context
476 * iPixelFormat [I] Pixel format selector
477 * nBytes [I] Size of buffer
478 * ppfd [O] Pointer to structure to receive pixel format data
481 * Success: Maximum pixel format index of the device context
484 int WINAPI
DescribePixelFormat( HDC32 hdc
, int iPixelFormat
, UINT32 nBytes
,
485 LPPIXELFORMATDESCRIPTOR ppfd
)
487 FIXME(gdi
, "(%d,%d,%d,%p): stub\n",hdc
,iPixelFormat
,nBytes
,ppfd
);
488 ppfd
->nSize
= nBytes
;
494 /******************************************************************************
495 * SwapBuffers [GDI32.354]
496 * Exchanges front and back buffers of window
499 * hdc [I] Device context whose buffers get swapped
503 BOOL32 WINAPI
SwapBuffers( HDC32 hdc
)
505 FIXME(gdi
, "(%d): stub\n",hdc
);
510 /***********************************************************************
511 * PaintRgn16 (GDI.43)
513 BOOL16 WINAPI
PaintRgn16( HDC16 hdc
, HRGN16 hrgn
)
515 return PaintRgn32( hdc
, hrgn
);
519 /***********************************************************************
520 * PaintRgn32 (GDI32.259)
522 BOOL32 WINAPI
PaintRgn32( HDC32 hdc
, HRGN32 hrgn
)
524 DC
* dc
= DC_GetDCPtr( hdc
);
526 return dc
&& dc
->funcs
->pPaintRgn
&&
527 dc
->funcs
->pPaintRgn(dc
,hrgn
);
531 /***********************************************************************
534 BOOL16 WINAPI
FillRgn16( HDC16 hdc
, HRGN16 hrgn
, HBRUSH16 hbrush
)
536 return FillRgn32( hdc
, hrgn
, hbrush
);
540 /***********************************************************************
541 * FillRgn32 (GDI32.101)
543 BOOL32 WINAPI
FillRgn32( HDC32 hdc
, HRGN32 hrgn
, HBRUSH32 hbrush
)
546 HBRUSH32 prevBrush
= SelectObject32( hdc
, hbrush
);
547 if (!prevBrush
) return FALSE
;
548 retval
= PaintRgn32( hdc
, hrgn
);
549 SelectObject32( hdc
, prevBrush
);
554 /***********************************************************************
555 * FrameRgn16 (GDI.41)
557 BOOL16 WINAPI
FrameRgn16( HDC16 hdc
, HRGN16 hrgn
, HBRUSH16 hbrush
,
558 INT16 nWidth
, INT16 nHeight
)
560 return FrameRgn32( hdc
, hrgn
, hbrush
, nWidth
, nHeight
);
564 /***********************************************************************
565 * FrameRgn32 (GDI32.105)
567 BOOL32 WINAPI
FrameRgn32( HDC32 hdc
, HRGN32 hrgn
, HBRUSH32 hbrush
,
568 INT32 nWidth
, INT32 nHeight
)
570 HRGN32 tmp
= CreateRectRgn32( 0, 0, 0, 0 );
571 if(!REGION_FrameRgn( tmp
, hrgn
, nWidth
, nHeight
)) return FALSE
;
572 FillRgn32( hdc
, tmp
, hbrush
);
573 DeleteObject32( tmp
);
578 /***********************************************************************
579 * InvertRgn16 (GDI.42)
581 BOOL16 WINAPI
InvertRgn16( HDC16 hdc
, HRGN16 hrgn
)
583 return InvertRgn32( hdc
, hrgn
);
587 /***********************************************************************
588 * InvertRgn32 (GDI32.246)
590 BOOL32 WINAPI
InvertRgn32( HDC32 hdc
, HRGN32 hrgn
)
592 HBRUSH32 prevBrush
= SelectObject32( hdc
, GetStockObject32(BLACK_BRUSH
) );
593 INT32 prevROP
= SetROP232( hdc
, R2_NOT
);
594 BOOL32 retval
= PaintRgn32( hdc
, hrgn
);
595 SelectObject32( hdc
, prevBrush
);
596 SetROP232( hdc
, prevROP
);
601 /***********************************************************************
602 * DrawFocusRect16 (USER.466)
604 void WINAPI
DrawFocusRect16( HDC16 hdc
, const RECT16
* rc
)
607 CONV_RECT16TO32( rc
, &rect32
);
608 DrawFocusRect32( hdc
, &rect32
);
612 /***********************************************************************
613 * DrawFocusRect32 (USER32.156)
615 * FIXME: PatBlt(PATINVERT) with background brush.
617 void WINAPI
DrawFocusRect32( HDC32 hdc
, const RECT32
* rc
)
619 HPEN32 hOldPen
, hnewPen
;
620 INT32 oldDrawMode
, oldBkMode
;
621 INT32 left
, top
, right
, bottom
;
623 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
626 left
= XLPTODP( dc
, rc
->left
);
627 top
= YLPTODP( dc
, rc
->top
);
628 right
= XLPTODP( dc
, rc
->right
);
629 bottom
= YLPTODP( dc
, rc
->bottom
);
631 if(left
== right
|| top
== bottom
)
634 hnewPen
= CreatePen32(PS_DOT
, 1, GetSysColor32(COLOR_WINDOWTEXT
) );
635 hOldPen
= SelectObject32( hdc
, hnewPen
);
636 oldDrawMode
= SetROP232(hdc
, R2_XORPEN
);
637 oldBkMode
= SetBkMode32(hdc
, TRANSPARENT
);
639 /* Hack: make sure the XORPEN operation has an effect */
640 dc
->u
.x
.pen
.pixel
= (1 << screenDepth
) - 1;
642 if (DC_SetupGCForPen( dc
))
643 TSXDrawRectangle( display
, dc
->u
.x
.drawable
, dc
->u
.x
.gc
,
644 dc
->w
.DCOrgX
+ left
, dc
->w
.DCOrgY
+ top
,
645 right
-left
-1, bottom
-top
-1 );
647 SetBkMode32(hdc
, oldBkMode
);
648 SetROP232(hdc
, oldDrawMode
);
649 SelectObject32(hdc
, hOldPen
);
650 DeleteObject32(hnewPen
);
654 /**********************************************************************
655 * Polyline16 (GDI.37)
657 BOOL16 WINAPI
Polyline16( HDC16 hdc
, const POINT16
* pt
, INT16 count
)
661 LPPOINT32 pt32
= (LPPOINT32
)HeapAlloc( GetProcessHeap(), 0,
662 count
*sizeof(POINT32
) );
664 if (!pt32
) return FALSE
;
665 for (i
=count
;i
--;) CONV_POINT16TO32(&(pt
[i
]),&(pt32
[i
]));
666 ret
= Polyline32(hdc
,pt32
,count
);
667 HeapFree( GetProcessHeap(), 0, pt32
);
672 /**********************************************************************
673 * Polyline32 (GDI32.276)
675 BOOL32 WINAPI
Polyline32( HDC32 hdc
, const POINT32
* pt
, INT32 count
)
677 DC
* dc
= DC_GetDCPtr( hdc
);
679 return dc
&& dc
->funcs
->pPolyline
&&
680 dc
->funcs
->pPolyline(dc
,pt
,count
);
684 /**********************************************************************
687 BOOL16 WINAPI
Polygon16( HDC16 hdc
, const POINT16
* pt
, INT16 count
)
691 LPPOINT32 pt32
= (LPPOINT32
)HeapAlloc( GetProcessHeap(), 0,
692 count
*sizeof(POINT32
) );
694 if (!pt32
) return FALSE
;
695 for (i
=count
;i
--;) CONV_POINT16TO32(&(pt
[i
]),&(pt32
[i
]));
696 ret
= Polygon32(hdc
,pt32
,count
);
697 HeapFree( GetProcessHeap(), 0, pt32
);
702 /**********************************************************************
703 * Polygon32 (GDI32.275)
705 BOOL32 WINAPI
Polygon32( HDC32 hdc
, const POINT32
* pt
, INT32 count
)
707 DC
* dc
= DC_GetDCPtr( hdc
);
709 return dc
&& dc
->funcs
->pPolygon
&&
710 dc
->funcs
->pPolygon(dc
,pt
,count
);
714 /**********************************************************************
715 * PolyPolygon16 (GDI.450)
717 BOOL16 WINAPI
PolyPolygon16( HDC16 hdc
, const POINT16
* pt
, const INT16
* counts
,
726 for (i
=polygons
;i
--;)
728 pt32
= (LPPOINT32
)HEAP_xalloc( GetProcessHeap(), 0, sizeof(POINT32
)*nrpts
);
730 CONV_POINT16TO32(&(pt
[i
]),&(pt32
[i
]));
731 counts32
= (LPINT32
)HEAP_xalloc( GetProcessHeap(), 0,
732 polygons
*sizeof(INT32
) );
733 for (i
=polygons
;i
--;) counts32
[i
]=counts
[i
];
735 ret
= PolyPolygon32(hdc
,pt32
,counts32
,polygons
);
736 HeapFree( GetProcessHeap(), 0, counts32
);
737 HeapFree( GetProcessHeap(), 0, pt32
);
741 /**********************************************************************
742 * PolyPolygon32 (GDI.450)
744 BOOL32 WINAPI
PolyPolygon32( HDC32 hdc
, const POINT32
* pt
, const INT32
* counts
,
747 DC
* dc
= DC_GetDCPtr( hdc
);
749 return dc
&& dc
->funcs
->pPolyPolygon
&&
750 dc
->funcs
->pPolyPolygon(dc
,pt
,counts
,polygons
);
753 /**********************************************************************
754 * PolyPolyline32 (GDI32.272)
756 BOOL32 WINAPI
PolyPolyline32( HDC32 hdc
, const POINT32
* pt
, const DWORD
* counts
,
759 DC
* dc
= DC_GetDCPtr( hdc
);
761 return dc
&& dc
->funcs
->pPolyPolyline
&&
762 dc
->funcs
->pPolyPolyline(dc
,pt
,counts
,polylines
);
765 /**********************************************************************
766 * ExtFloodFill16 (GDI.372)
768 BOOL16 WINAPI
ExtFloodFill16( HDC16 hdc
, INT16 x
, INT16 y
, COLORREF color
,
771 return ExtFloodFill32( hdc
, x
, y
, color
, fillType
);
775 /**********************************************************************
776 * ExtFloodFill32 (GDI32.96)
778 BOOL32 WINAPI
ExtFloodFill32( HDC32 hdc
, INT32 x
, INT32 y
, COLORREF color
,
781 DC
*dc
= DC_GetDCPtr( hdc
);
783 return dc
&& dc
->funcs
->pExtFloodFill
&&
784 dc
->funcs
->pExtFloodFill(dc
,x
,y
,color
,fillType
);
788 /**********************************************************************
789 * FloodFill16 (GDI.25)
791 BOOL16 WINAPI
FloodFill16( HDC16 hdc
, INT16 x
, INT16 y
, COLORREF color
)
793 return ExtFloodFill32( hdc
, x
, y
, color
, FLOODFILLBORDER
);
797 /**********************************************************************
798 * FloodFill32 (GDI32.104)
800 BOOL32 WINAPI
FloodFill32( HDC32 hdc
, INT32 x
, INT32 y
, COLORREF color
)
802 return ExtFloodFill32( hdc
, x
, y
, color
, FLOODFILLBORDER
);
806 /**********************************************************************
807 * DrawAnimatedRects32 (USER32.153)
809 BOOL32 WINAPI
DrawAnimatedRects32( HWND32 hwnd
, int idAni
,
810 const RECT32
* lprcFrom
,
811 const RECT32
* lprcTo
)
813 FIXME(gdi
,"(0x%x,%d,%p,%p): stub\n",hwnd
,idAni
,lprcFrom
,lprcTo
);
818 /**********************************************************************
819 * PAINTING_DrawStateJam
821 * Jams in the requested type in the dc
823 static BOOL32
PAINTING_DrawStateJam(HDC32 hdc
, UINT32 opcode
,
824 DRAWSTATEPROC32 func
, LPARAM lp
, WPARAM32 wp
,
825 LPRECT32 rc
, UINT32 dtflags
,
826 BOOL32 unicode
, BOOL32 _32bit
)
831 INT32 cx
= rc
->right
- rc
->left
;
832 INT32 cy
= rc
->bottom
- rc
->top
;
839 return DrawText32W(hdc
, (LPWSTR
)lp
, (INT32
)wp
, rc
, dtflags
);
841 return DrawText32A(hdc
, (LPSTR
)lp
, (INT32
)wp
, rc
, dtflags
);
843 return DrawText32A(hdc
, (LPSTR
)PTR_SEG_TO_LIN(lp
), (INT32
)wp
, rc
, dtflags
);
846 return DrawIcon32(hdc
, rc
->left
, rc
->top
, (HICON32
)lp
);
849 memdc
= CreateCompatibleDC32(hdc
);
850 if(!memdc
) return FALSE
;
851 hbmsave
= (HBITMAP32
)SelectObject32(memdc
, (HBITMAP32
)lp
);
857 retval
= BitBlt32(hdc
, rc
->left
, rc
->top
, cx
, cy
, memdc
, 0, 0, SRCCOPY
);
858 SelectObject32(memdc
, hbmsave
);
865 return func(hdc
, lp
, wp
, cx
, cy
);
867 return (BOOL32
)((DRAWSTATEPROC16
)func
)((HDC16
)hdc
, (LPARAM
)lp
, (WPARAM16
)wp
, (INT16
)cx
, (INT16
)cy
);
874 /**********************************************************************
875 * PAINTING_DrawState32()
877 static BOOL32
PAINTING_DrawState32(HDC32 hdc
, HBRUSH32 hbr
,
878 DRAWSTATEPROC32 func
, LPARAM lp
, WPARAM32 wp
,
879 INT32 x
, INT32 y
, INT32 cx
, INT32 cy
,
880 UINT32 flags
, BOOL32 unicode
, BOOL32 _32bit
)
882 HBITMAP32 hbm
, hbmsave
;
887 UINT32 dtflags
= DT_NOCLIP
;
889 UINT32 opcode
= flags
& 0xf;
893 if((opcode
== DST_TEXT
|| opcode
== DST_PREFIXTEXT
) && !len
) /* The string is '\0' terminated */
896 len
= lstrlen32W((LPWSTR
)lp
);
898 len
= lstrlen32A((LPSTR
)lp
);
900 len
= lstrlen32A((LPSTR
)PTR_SEG_TO_LIN(lp
));
903 /* Find out what size the image has if not given by caller */
915 retval
= GetTextExtentPoint32W(hdc
, (LPWSTR
)lp
, len
, &s
);
917 retval
= GetTextExtentPoint32A(hdc
, (LPSTR
)lp
, len
, &s
);
919 retval
= GetTextExtentPoint32A(hdc
, PTR_SEG_TO_LIN(lp
), len
, &s
);
920 if(!retval
) return FALSE
;
924 ici
= (CURSORICONINFO
*)GlobalLock16((HGLOBAL16
)lp
);
925 if(!ici
) return FALSE
;
928 GlobalUnlock16((HGLOBAL16
)lp
);
932 bmp
= (BITMAPOBJ
*)GDI_GetObjPtr((HBITMAP16
)lp
, BITMAP_MAGIC
);
933 if(!bmp
) return FALSE
;
934 s
.cx
= bmp
->bitmap
.bmWidth
;
935 s
.cy
= bmp
->bitmap
.bmHeight
;
938 case DST_COMPLEX
: /* cx and cy must be set in this mode */
951 if(flags
& DSS_RIGHT
) /* This one is not documented in the win32.hlp file */
953 if(opcode
== DST_TEXT
)
954 dtflags
|= DT_NOPREFIX
;
956 /* For DSS_NORMAL we just jam in the image and return */
957 if((flags
& 0x7ff0) == DSS_NORMAL
)
959 return PAINTING_DrawStateJam(hdc
, opcode
, func
, lp
, len
, &rc
, dtflags
, unicode
, _32bit
);
962 /* For all other states we need to convert the image to B/W in a local bitmap */
963 /* before it is displayed */
964 fg
= SetTextColor32(hdc
, RGB(0, 0, 0));
965 bg
= SetBkColor32(hdc
, RGB(255, 255, 255));
966 hbm
= (HBITMAP32
)NULL
; hbmsave
= (HBITMAP32
)NULL
;
967 memdc
= (HDC32
)NULL
; hbsave
= (HBRUSH32
)NULL
;
968 retval
= FALSE
; /* assume failure */
970 /* From here on we must use "goto cleanup" when something goes wrong */
971 hbm
= CreateBitmap32(cx
, cy
, 1, 1, NULL
);
972 if(!hbm
) goto cleanup
;
973 memdc
= CreateCompatibleDC32(hdc
);
974 if(!memdc
) goto cleanup
;
975 hbmsave
= (HBITMAP32
)SelectObject32(memdc
, hbm
);
976 if(!hbmsave
) goto cleanup
;
977 rc
.left
= rc
.top
= 0;
980 if(!FillRect32(memdc
, &rc
, (HBRUSH32
)GetStockObject32(WHITE_BRUSH
))) goto cleanup
;
981 SetBkColor32(memdc
, RGB(255, 255, 255));
982 SetTextColor32(memdc
, RGB(0, 0, 0));
983 hfsave
= (HFONT32
)SelectObject32(memdc
, GetCurrentObject(hdc
, OBJ_FONT
));
984 if(!hfsave
&& (opcode
== DST_TEXT
|| opcode
== DST_PREFIXTEXT
)) goto cleanup
;
985 tmp
= PAINTING_DrawStateJam(memdc
, opcode
, func
, lp
, len
, &rc
, dtflags
, unicode
, _32bit
);
986 if(hfsave
) SelectObject32(memdc
, hfsave
);
987 if(!tmp
) goto cleanup
;
989 /* These states cause the image to be dithered */
990 if(flags
& (DSS_UNION
|DSS_DISABLED
))
992 hbsave
= (HBRUSH32
)SelectObject32(memdc
, CACHE_GetPattern55AABrush());
993 if(!hbsave
) goto cleanup
;
994 tmp
= PatBlt32(memdc
, 0, 0, cx
, cy
, 0x00FA0089);
995 if(hbsave
) SelectObject32(memdc
, hbsave
);
996 if(!tmp
) goto cleanup
;
999 hbsave
= (HBRUSH32
)SelectObject32(hdc
, hbr
? hbr
: GetStockObject32(WHITE_BRUSH
));
1000 if(!hbsave
) goto cleanup
;
1002 if(!BitBlt32(hdc
, x
, y
, cx
, cy
, memdc
, 0, 0, 0x00B8074A)) goto cleanup
;
1004 /* DSS_DEFAULT makes the image boldface */
1005 if(flags
& DSS_DEFAULT
)
1007 if(!BitBlt32(hdc
, x
+1, y
, cx
, cy
, memdc
, 0, 0, 0x00B8074A)) goto cleanup
;
1010 retval
= TRUE
; /* We succeeded */
1013 SetTextColor32(hdc
, fg
);
1014 SetBkColor32(hdc
, bg
);
1016 if(hbsave
) SelectObject32(hdc
, hbsave
);
1017 if(hbmsave
) SelectObject32(memdc
, hbmsave
);
1018 if(hbm
) DeleteObject32(hbm
);
1019 if(memdc
) DeleteDC32(memdc
);
1024 /**********************************************************************
1025 * DrawState32A() (USER32.162)
1027 BOOL32 WINAPI
DrawState32A(HDC32 hdc
, HBRUSH32 hbr
,
1028 DRAWSTATEPROC32 func
, LPARAM ldata
, WPARAM32 wdata
,
1029 INT32 x
, INT32 y
, INT32 cx
, INT32 cy
, UINT32 flags
)
1031 return PAINTING_DrawState32(hdc
, hbr
, func
, ldata
, wdata
, x
, y
, cx
, cy
, flags
, FALSE
, TRUE
);
1034 /**********************************************************************
1035 * DrawState32W() (USER32.163)
1037 BOOL32 WINAPI
DrawState32W(HDC32 hdc
, HBRUSH32 hbr
,
1038 DRAWSTATEPROC32 func
, LPARAM ldata
, WPARAM32 wdata
,
1039 INT32 x
, INT32 y
, INT32 cx
, INT32 cy
, UINT32 flags
)
1041 return PAINTING_DrawState32(hdc
, hbr
, func
, ldata
, wdata
, x
, y
, cx
, cy
, flags
, TRUE
, TRUE
);
1044 /**********************************************************************
1045 * DrawState16() (USER.449)
1047 BOOL16 WINAPI
DrawState16(HDC16 hdc
, HBRUSH16 hbr
,
1048 DRAWSTATEPROC16 func
, LPARAM ldata
, WPARAM16 wdata
,
1049 INT16 x
, INT16 y
, INT16 cx
, INT16 cy
, UINT16 flags
)
1051 return PAINTING_DrawState32(hdc
, hbr
, (DRAWSTATEPROC32
)func
, ldata
, wdata
, x
, y
, cx
, cy
, flags
, FALSE
, FALSE
);
1055 /******************************************************************************
1056 * PolyBezier16 [GDI.502]
1058 BOOL16 WINAPI
PolyBezier16( HDC16 hDc
, const POINT16
* lppt
, INT16 cPoints
)
1062 LPPOINT32 pt32
= (LPPOINT32
)HeapAlloc( GetProcessHeap(), 0,
1063 cPoints
*sizeof(POINT32
) );
1064 if(!pt32
) return FALSE
;
1065 for (i
=cPoints
;i
--;) CONV_POINT16TO32(&(lppt
[i
]),&(pt32
[i
]));
1066 ret
= PolyBezier32(hDc
, pt32
, cPoints
);
1067 HeapFree( GetProcessHeap(), 0, pt32
);
1071 /******************************************************************************
1072 * PolyBezierTo16 [GDI.503]
1074 BOOL16 WINAPI
PolyBezierTo16( HDC16 hDc
, const POINT16
* lppt
, INT16 cPoints
)
1078 LPPOINT32 pt32
= (LPPOINT32
)HeapAlloc( GetProcessHeap(), 0,
1079 cPoints
*sizeof(POINT32
) );
1080 if(!pt32
) return FALSE
;
1081 for (i
=cPoints
;i
--;) CONV_POINT16TO32(&(lppt
[i
]),&(pt32
[i
]));
1082 ret
= PolyBezierTo32(hDc
, pt32
, cPoints
);
1083 HeapFree( GetProcessHeap(), 0, pt32
);
1087 /******************************************************************************
1088 * PolyBezier32 [GDI32.268]
1089 * Draws one or more Bezier curves
1092 * hDc [I] Handle to device context
1093 * lppt [I] Pointer to endpoints and control points
1094 * cPoints [I] Count of endpoints and control points
1098 BOOL32 WINAPI
PolyBezier32( HDC32 hdc
, const POINT32
* lppt
, DWORD cPoints
)
1100 DC
* dc
= DC_GetDCPtr( hdc
);
1101 if(!dc
) return FALSE
;
1102 if(dc
&& PATH_IsPathOpen(dc
->w
.path
))
1103 FIXME(gdi
, "PATH_PolyBezier is not implemented!\n");
1104 /* if(!PATH_PolyBezier(hdc, x, y))
1106 return dc
->funcs
->pPolyBezier
&&
1107 dc
->funcs
->pPolyBezier(dc
, lppt
[0], lppt
+1, cPoints
-1);
1110 /******************************************************************************
1111 * PolyBezierTo32 [GDI32.269]
1112 * Draws one or more Bezier curves
1115 * hDc [I] Handle to device context
1116 * lppt [I] Pointer to endpoints and control points
1117 * cPoints [I] Count of endpoints and control points
1121 BOOL32 WINAPI
PolyBezierTo32( HDC32 hdc
, const POINT32
* lppt
, DWORD cPoints
)
1123 DC
* dc
= DC_GetDCPtr( hdc
);
1126 if(!dc
) return FALSE
;
1127 pt
.x
=dc
->w
.CursPosX
;
1128 pt
.y
=dc
->w
.CursPosY
;
1129 if(dc
&& PATH_IsPathOpen(dc
->w
.path
))
1130 FIXME(gdi
, "PATH_PolyBezierTo is not implemented!\n");
1131 /* if(!PATH_PolyBezier(hdc, x, y))
1133 ret
= dc
->funcs
->pPolyBezier
&&
1134 dc
->funcs
->pPolyBezier(dc
, pt
, lppt
, cPoints
);
1135 if( dc
->funcs
->pMoveToEx
)
1136 dc
->funcs
->pMoveToEx(dc
,lppt
[cPoints
].x
,lppt
[cPoints
].y
,&pt
);