2 * Misc. graphics operations
4 * Copyright 1993, 1994 Alexandre Julliard
5 * Copyright 1997 Bertho A. Stultiens
8 #include <X11/Intrinsic.h>
33 /***********************************************************************
36 BOOL16 WINAPI LineTo16( HDC16 hdc, INT16 x, INT16 y )
38 return LineTo32( hdc, x, y );
42 /***********************************************************************
43 * LineTo32 (GDI32.249)
45 BOOL32 WINAPI LineTo32( HDC32 hdc, INT32 x, INT32 y )
47 DC * dc = DC_GetDCPtr( hdc );
49 if(dc && PATH_IsPathOpen(dc->w.path))
50 if(!PATH_LineTo(hdc, x, y))
53 return dc && dc->funcs->pLineTo &&
54 dc->funcs->pLineTo(dc,x,y);
58 /***********************************************************************
61 DWORD WINAPI MoveTo( HDC16 hdc, INT16 x, INT16 y )
65 if (!MoveToEx16(hdc,x,y,&pt))
67 return MAKELONG(pt.x,pt.y);
71 /***********************************************************************
72 * MoveToEx16 (GDI.483)
74 BOOL16 WINAPI MoveToEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
78 if (!MoveToEx32( (HDC32)hdc, (INT32)x, (INT32)y, &pt32 )) return FALSE;
79 if (pt) CONV_POINT32TO16( &pt32, pt );
85 /***********************************************************************
86 * MoveToEx32 (GDI32.254)
88 BOOL32 WINAPI MoveToEx32( HDC32 hdc, INT32 x, INT32 y, LPPOINT32 pt )
90 DC * dc = DC_GetDCPtr( hdc );
92 if(dc && PATH_IsPathOpen(dc->w.path))
96 return dc && dc->funcs->pMoveToEx &&
97 dc->funcs->pMoveToEx(dc,x,y,pt);
101 /***********************************************************************
104 BOOL16 WINAPI Arc16( HDC16 hdc, INT16 left, INT16 top, INT16 right,
105 INT16 bottom, INT16 xstart, INT16 ystart,
106 INT16 xend, INT16 yend )
108 return Arc32( (HDC32)hdc, (INT32)left, (INT32)top, (INT32)right,
109 (INT32)bottom, (INT32)xstart, (INT32)ystart, (INT32)xend,
114 /***********************************************************************
117 BOOL32 WINAPI Arc32( HDC32 hdc, INT32 left, INT32 top, INT32 right,
118 INT32 bottom, INT32 xstart, INT32 ystart,
119 INT32 xend, INT32 yend )
121 DC * dc = DC_GetDCPtr( hdc );
123 if(dc && PATH_IsPathOpen(dc->w.path))
124 if(!PATH_Arc(hdc, left, top, right, bottom, xstart, ystart, xend,
128 return dc && dc->funcs->pArc &&
129 dc->funcs->pArc(dc,left,top,right,bottom,xstart,ystart,xend,yend);
132 /***********************************************************************
135 BOOL32 WINAPI ArcTo( HDC32 hdc,
136 INT32 left, INT32 top,
137 INT32 right, INT32 bottom,
138 INT32 xstart, INT32 ystart,
139 INT32 xend, INT32 yend )
144 * According to the documentation, a line is drawn from the current
145 * position to the starting point of the arc.
147 LineTo32(hdc, xstart, ystart);
150 * Then the arc is drawn.
159 * If no error occured, the current position is moved to the ending
164 MoveToEx32(hdc, xend, yend, NULL);
170 /***********************************************************************
173 BOOL16 WINAPI Pie16( HDC16 hdc, INT16 left, INT16 top,
174 INT16 right, INT16 bottom, INT16 xstart, INT16 ystart,
175 INT16 xend, INT16 yend )
177 return Pie32( (HDC32)hdc, (INT32)left, (INT32)top, (INT32)right,
178 (INT32)bottom, (INT32)xstart, (INT32)ystart, (INT32)xend,
183 /***********************************************************************
186 BOOL32 WINAPI Pie32( HDC32 hdc, INT32 left, INT32 top,
187 INT32 right, INT32 bottom, INT32 xstart, INT32 ystart,
188 INT32 xend, INT32 yend )
190 DC * dc = DC_GetDCPtr( hdc );
192 return dc && dc->funcs->pPie &&
193 dc->funcs->pPie(dc,left,top,right,bottom,xstart,ystart,xend,yend);
197 /***********************************************************************
200 BOOL16 WINAPI Chord16( HDC16 hdc, INT16 left, INT16 top,
201 INT16 right, INT16 bottom, INT16 xstart, INT16 ystart,
202 INT16 xend, INT16 yend )
204 return Chord32( hdc, left, top, right, bottom, xstart, ystart, xend, yend );
208 /***********************************************************************
211 BOOL32 WINAPI Chord32( HDC32 hdc, INT32 left, INT32 top,
212 INT32 right, INT32 bottom, INT32 xstart, INT32 ystart,
213 INT32 xend, INT32 yend )
215 DC * dc = DC_GetDCPtr( hdc );
217 return dc && dc->funcs->pChord &&
218 dc->funcs->pChord(dc,left,top,right,bottom,xstart,ystart,xend,yend);
222 /***********************************************************************
225 BOOL16 WINAPI Ellipse16( HDC16 hdc, INT16 left, INT16 top,
226 INT16 right, INT16 bottom )
228 return Ellipse32( hdc, left, top, right, bottom );
232 /***********************************************************************
233 * Ellipse32 (GDI32.75)
235 BOOL32 WINAPI Ellipse32( HDC32 hdc, INT32 left, INT32 top,
236 INT32 right, INT32 bottom )
238 DC * dc = DC_GetDCPtr( hdc );
240 return dc && dc->funcs->pEllipse &&
241 dc->funcs->pEllipse(dc,left,top,right,bottom);
245 /***********************************************************************
246 * Rectangle16 (GDI.27)
248 BOOL16 WINAPI Rectangle16( HDC16 hdc, INT16 left, INT16 top,
249 INT16 right, INT16 bottom )
251 return Rectangle32( hdc, left, top, right, bottom );
255 /***********************************************************************
256 * Rectangle32 (GDI32.283)
258 BOOL32 WINAPI Rectangle32( HDC32 hdc, INT32 left, INT32 top,
259 INT32 right, INT32 bottom )
261 DC * dc = DC_GetDCPtr( hdc );
263 if(dc && PATH_IsPathOpen(dc->w.path))
264 if(!PATH_Rectangle(hdc, left, top, right, bottom))
267 return dc && dc->funcs->pRectangle &&
268 dc->funcs->pRectangle(dc,left,top,right,bottom);
272 /***********************************************************************
273 * RoundRect16 (GDI.28)
275 BOOL16 WINAPI RoundRect16( HDC16 hdc, INT16 left, INT16 top, INT16 right,
276 INT16 bottom, INT16 ell_width, INT16 ell_height )
278 return RoundRect32( hdc, left, top, right, bottom, ell_width, ell_height );
282 /***********************************************************************
283 * RoundRect32 (GDI32.291)
285 BOOL32 WINAPI RoundRect32( HDC32 hdc, INT32 left, INT32 top, INT32 right,
286 INT32 bottom, INT32 ell_width, INT32 ell_height )
289 if(ell_width == 0 || ell_height == 0) /* Just an optimization */
290 return Rectangle32(hdc, left, top, right, bottom);
293 DC * dc = DC_GetDCPtr( hdc );
295 return dc && dc->funcs->pRoundRect &&
296 dc->funcs->pRoundRect(dc,left,top,right,bottom,ell_width,ell_height);
301 /***********************************************************************
302 * FillRect16 (USER.81)
304 INT16 WINAPI FillRect16( HDC16 hdc, const RECT16 *rect, HBRUSH16 hbrush )
308 /* coordinates are logical so we cannot fast-check 'rect',
309 * it will be done later in the PatBlt().
312 if (!(prevBrush = SelectObject16( hdc, hbrush ))) return 0;
313 PatBlt32( hdc, rect->left, rect->top,
314 rect->right - rect->left, rect->bottom - rect->top, PATCOPY );
315 SelectObject16( hdc, prevBrush );
320 /***********************************************************************
321 * FillRect32 (USER32.197)
323 INT32 WINAPI FillRect32( HDC32 hdc, const RECT32 *rect, HBRUSH32 hbrush )
327 if (!(prevBrush = SelectObject32( hdc, hbrush ))) return 0;
328 PatBlt32( hdc, rect->left, rect->top,
329 rect->right - rect->left, rect->bottom - rect->top, PATCOPY );
330 SelectObject32( hdc, prevBrush );
335 /***********************************************************************
336 * InvertRect16 (USER.82)
338 void WINAPI InvertRect16( HDC16 hdc, const RECT16 *rect )
340 PatBlt32( hdc, rect->left, rect->top,
341 rect->right - rect->left, rect->bottom - rect->top, DSTINVERT );
345 /***********************************************************************
346 * InvertRect32 (USER32.330)
348 BOOL32 WINAPI InvertRect32( HDC32 hdc, const RECT32 *rect )
350 return PatBlt32( hdc, rect->left, rect->top,
351 rect->right - rect->left, rect->bottom - rect->top,
356 /***********************************************************************
357 * FrameRect16 (USER.83)
359 INT16 WINAPI FrameRect16( HDC16 hdc, const RECT16 *rect, HBRUSH16 hbrush )
362 int left, top, right, bottom;
364 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
365 if (!dc) return FALSE;
367 left = XLPTODP( dc, rect->left );
368 top = YLPTODP( dc, rect->top );
369 right = XLPTODP( dc, rect->right );
370 bottom = YLPTODP( dc, rect->bottom );
372 if ( (right <= left) || (bottom <= top) ) return 0;
373 if (!(prevBrush = SelectObject16( hdc, hbrush ))) return 0;
375 PatBlt32( hdc, rect->left, rect->top, 1,
376 rect->bottom - rect->top, PATCOPY );
377 PatBlt32( hdc, rect->right - 1, rect->top, 1,
378 rect->bottom - rect->top, PATCOPY );
379 PatBlt32( hdc, rect->left, rect->top,
380 rect->right - rect->left, 1, PATCOPY );
381 PatBlt32( hdc, rect->left, rect->bottom - 1,
382 rect->right - rect->left, 1, PATCOPY );
384 SelectObject16( hdc, prevBrush );
389 /***********************************************************************
390 * FrameRect32 (USER32.203)
392 INT32 WINAPI FrameRect32( HDC32 hdc, const RECT32 *rect, HBRUSH32 hbrush )
395 CONV_RECT32TO16( rect, &rect16 );
396 return FrameRect16( (HDC16)hdc, &rect16, (HBRUSH16)hbrush );
400 /***********************************************************************
401 * SetPixel16 (GDI.31)
403 COLORREF WINAPI SetPixel16( HDC16 hdc, INT16 x, INT16 y, COLORREF color )
405 return SetPixel32( hdc, x, y, color );
409 /***********************************************************************
410 * SetPixel32 (GDI32.327)
412 COLORREF WINAPI SetPixel32( HDC32 hdc, INT32 x, INT32 y, COLORREF color )
414 DC * dc = DC_GetDCPtr( hdc );
416 if (!dc || !dc->funcs->pSetPixel) return 0;
417 return dc->funcs->pSetPixel(dc,x,y,color);
420 /***********************************************************************
421 * SetPixelV32 (GDI32.329)
423 BOOL32 WINAPI SetPixelV32( HDC32 hdc, INT32 x, INT32 y, COLORREF color )
425 DC * dc = DC_GetDCPtr( hdc );
427 if (!dc || !dc->funcs->pSetPixel) return FALSE;
428 dc->funcs->pSetPixel(dc,x,y,color);
432 /***********************************************************************
433 * GetPixel16 (GDI.83)
435 COLORREF WINAPI GetPixel16( HDC16 hdc, INT16 x, INT16 y )
437 return GetPixel32( hdc, x, y );
441 /***********************************************************************
442 * GetPixel32 (GDI32.211)
444 COLORREF WINAPI GetPixel32( HDC32 hdc, INT32 x, INT32 y )
446 DC * dc = DC_GetDCPtr( hdc );
449 #ifdef SOLITAIRE_SPEED_HACK
453 /* FIXME: should this be in the graphics driver? */
454 if (!PtVisible32( hdc, x, y )) return 0;
455 if (!dc || !dc->funcs->pGetPixel) return 0;
456 return dc->funcs->pGetPixel(dc,x,y);
460 /******************************************************************************
461 * ChoosePixelFormat [GDI32.13]
462 * Matches a pixel format to given format
465 * hdc [I] Device context to search for best pixel match
466 * ppfd [I] Pixel format for which a match is sought
469 * Success: Pixel format index closest to given format
472 INT32 WINAPI ChoosePixelFormat( HDC32 hdc, const PIXELFORMATDESCRIPTOR* ppfd )
474 FIXME(gdi, "(%d,%p): stub\n",hdc,ppfd);
479 /******************************************************************************
480 * SetPixelFormat [GDI32.328]
481 * Sets pixel format of device context
484 * hdc [I] Device context to search for best pixel match
485 * iPixelFormat [I] Pixel format index
486 * ppfd [I] Pixel format for which a match is sought
490 BOOL32 WINAPI SetPixelFormat( HDC32 hdc, int iPixelFormat,
491 const PIXELFORMATDESCRIPTOR* ppfd)
493 FIXME(gdi, "(%d,%d,%p): stub\n",hdc,iPixelFormat,ppfd);
498 /******************************************************************************
499 * GetPixelFormat [GDI32.212]
500 * Gets index of pixel format of DC
503 * hdc [I] Device context whose pixel format index is sought
506 * Success: Currently selected pixel format
509 int WINAPI GetPixelFormat( HDC32 hdc )
511 FIXME(gdi, "(%d): stub\n",hdc);
516 /******************************************************************************
517 * DescribePixelFormat [GDI32.71]
518 * Gets info about pixel format from DC
521 * hdc [I] Device context
522 * iPixelFormat [I] Pixel format selector
523 * nBytes [I] Size of buffer
524 * ppfd [O] Pointer to structure to receive pixel format data
527 * Success: Maximum pixel format index of the device context
530 int WINAPI DescribePixelFormat( HDC32 hdc, int iPixelFormat, UINT32 nBytes,
531 LPPIXELFORMATDESCRIPTOR ppfd )
533 FIXME(gdi, "(%d,%d,%d,%p): stub\n",hdc,iPixelFormat,nBytes,ppfd);
534 ppfd->nSize = nBytes;
540 /******************************************************************************
541 * SwapBuffers [GDI32.354]
542 * Exchanges front and back buffers of window
545 * hdc [I] Device context whose buffers get swapped
549 BOOL32 WINAPI SwapBuffers( HDC32 hdc )
551 FIXME(gdi, "(%d): stub\n",hdc);
556 /***********************************************************************
557 * PaintRgn16 (GDI.43)
559 BOOL16 WINAPI PaintRgn16( HDC16 hdc, HRGN16 hrgn )
561 return PaintRgn32( hdc, hrgn );
565 /***********************************************************************
566 * PaintRgn32 (GDI32.259)
568 BOOL32 WINAPI PaintRgn32( HDC32 hdc, HRGN32 hrgn )
570 DC * dc = DC_GetDCPtr( hdc );
572 return dc && dc->funcs->pPaintRgn &&
573 dc->funcs->pPaintRgn(dc,hrgn);
577 /***********************************************************************
580 BOOL16 WINAPI FillRgn16( HDC16 hdc, HRGN16 hrgn, HBRUSH16 hbrush )
582 return FillRgn32( hdc, hrgn, hbrush );
586 /***********************************************************************
587 * FillRgn32 (GDI32.101)
589 BOOL32 WINAPI FillRgn32( HDC32 hdc, HRGN32 hrgn, HBRUSH32 hbrush )
592 HBRUSH32 prevBrush = SelectObject32( hdc, hbrush );
593 if (!prevBrush) return FALSE;
594 retval = PaintRgn32( hdc, hrgn );
595 SelectObject32( hdc, prevBrush );
600 /***********************************************************************
601 * FrameRgn16 (GDI.41)
603 BOOL16 WINAPI FrameRgn16( HDC16 hdc, HRGN16 hrgn, HBRUSH16 hbrush,
604 INT16 nWidth, INT16 nHeight )
606 return FrameRgn32( hdc, hrgn, hbrush, nWidth, nHeight );
610 /***********************************************************************
611 * FrameRgn32 (GDI32.105)
613 BOOL32 WINAPI FrameRgn32( HDC32 hdc, HRGN32 hrgn, HBRUSH32 hbrush,
614 INT32 nWidth, INT32 nHeight )
616 HRGN32 tmp = CreateRectRgn32( 0, 0, 0, 0 );
617 if(!REGION_FrameRgn( tmp, hrgn, nWidth, nHeight )) return FALSE;
618 FillRgn32( hdc, tmp, hbrush );
619 DeleteObject32( tmp );
624 /***********************************************************************
625 * InvertRgn16 (GDI.42)
627 BOOL16 WINAPI InvertRgn16( HDC16 hdc, HRGN16 hrgn )
629 return InvertRgn32( hdc, hrgn );
633 /***********************************************************************
634 * InvertRgn32 (GDI32.246)
636 BOOL32 WINAPI InvertRgn32( HDC32 hdc, HRGN32 hrgn )
638 HBRUSH32 prevBrush = SelectObject32( hdc, GetStockObject32(BLACK_BRUSH) );
639 INT32 prevROP = SetROP232( hdc, R2_NOT );
640 BOOL32 retval = PaintRgn32( hdc, hrgn );
641 SelectObject32( hdc, prevBrush );
642 SetROP232( hdc, prevROP );
647 /***********************************************************************
648 * DrawFocusRect16 (USER.466)
650 void WINAPI DrawFocusRect16( HDC16 hdc, const RECT16* rc )
653 CONV_RECT16TO32( rc, &rect32 );
654 DrawFocusRect32( hdc, &rect32 );
658 /***********************************************************************
659 * DrawFocusRect32 (USER32.156)
661 * FIXME: PatBlt(PATINVERT) with background brush.
663 BOOL32 WINAPI DrawFocusRect32( HDC32 hdc, const RECT32* rc )
665 HPEN32 hOldPen, hnewPen;
666 INT32 oldDrawMode, oldBkMode;
667 INT32 left, top, right, bottom;
668 X11DRV_PDEVICE *physDev;
670 DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
673 SetLastError( ERROR_INVALID_HANDLE );
676 physDev = (X11DRV_PDEVICE *)dc->physDev;
678 left = XLPTODP( dc, rc->left );
679 top = YLPTODP( dc, rc->top );
680 right = XLPTODP( dc, rc->right );
681 bottom = YLPTODP( dc, rc->bottom );
683 if(left == right || top == bottom)
685 SetLastError( ERROR_INVALID_PARAMETER );
689 hnewPen = CreatePen32(PS_DOT, 1, GetSysColor32(COLOR_WINDOWTEXT) );
690 hOldPen = SelectObject32( hdc, hnewPen );
691 oldDrawMode = SetROP232(hdc, R2_XORPEN);
692 oldBkMode = SetBkMode32(hdc, TRANSPARENT);
694 /* Hack: make sure the XORPEN operation has an effect */
695 physDev->pen.pixel = (1 << MONITOR_GetDepth(&MONITOR_PrimaryMonitor)) - 1;
697 if (X11DRV_SetupGCForPen( dc ))
698 TSXDrawRectangle( display, physDev->drawable, physDev->gc,
699 dc->w.DCOrgX + left, dc->w.DCOrgY + top,
700 right-left-1, bottom-top-1 );
702 SetBkMode32(hdc, oldBkMode);
703 SetROP232(hdc, oldDrawMode);
704 SelectObject32(hdc, hOldPen);
705 DeleteObject32(hnewPen);
710 /**********************************************************************
711 * Polyline16 (GDI.37)
713 BOOL16 WINAPI Polyline16( HDC16 hdc, const POINT16* pt, INT16 count )
717 LPPOINT32 pt32 = (LPPOINT32)HeapAlloc( GetProcessHeap(), 0,
718 count*sizeof(POINT32) );
720 if (!pt32) return FALSE;
721 for (i=count;i--;) CONV_POINT16TO32(&(pt[i]),&(pt32[i]));
722 ret = Polyline32(hdc,pt32,count);
723 HeapFree( GetProcessHeap(), 0, pt32 );
728 /**********************************************************************
729 * Polyline32 (GDI32.276)
731 BOOL32 WINAPI Polyline32( HDC32 hdc, const POINT32* pt, INT32 count )
733 DC * dc = DC_GetDCPtr( hdc );
735 return dc && dc->funcs->pPolyline &&
736 dc->funcs->pPolyline(dc,pt,count);
739 /**********************************************************************
740 * PolylineTo32 (GDI32.277)
742 BOOL32 WINAPI PolylineTo32( HDC32 hdc, const POINT32* pt, DWORD cCount )
744 POINT32 *pts = HeapAlloc( GetProcessHeap(), 0,
745 sizeof(POINT32) * (cCount + 1) );
746 if(!pts) return FALSE;
748 /* Get the current point */
749 MoveToEx32( hdc, 0, 0, pts);
751 /* Add in the other points */
752 memcpy( pts + 1, pt, sizeof(POINT32) * cCount );
755 Polyline32( hdc, pts, cCount + 1 );
757 /* Move to last point */
758 MoveToEx32( hdc, (pts + cCount)->x, (pts + cCount)->y, NULL );
760 HeapFree( GetProcessHeap(), 0, pts );
764 /**********************************************************************
767 BOOL16 WINAPI Polygon16( HDC16 hdc, const POINT16* pt, INT16 count )
771 LPPOINT32 pt32 = (LPPOINT32)HeapAlloc( GetProcessHeap(), 0,
772 count*sizeof(POINT32) );
774 if (!pt32) return FALSE;
775 for (i=count;i--;) CONV_POINT16TO32(&(pt[i]),&(pt32[i]));
776 ret = Polygon32(hdc,pt32,count);
777 HeapFree( GetProcessHeap(), 0, pt32 );
782 /**********************************************************************
783 * Polygon32 (GDI32.275)
785 BOOL32 WINAPI Polygon32( HDC32 hdc, const POINT32* pt, INT32 count )
787 DC * dc = DC_GetDCPtr( hdc );
789 return dc && dc->funcs->pPolygon &&
790 dc->funcs->pPolygon(dc,pt,count);
794 /**********************************************************************
795 * PolyPolygon16 (GDI.450)
797 BOOL16 WINAPI PolyPolygon16( HDC16 hdc, const POINT16* pt, const INT16* counts,
806 for (i=polygons;i--;)
808 pt32 = (LPPOINT32)HEAP_xalloc( GetProcessHeap(), 0, sizeof(POINT32)*nrpts);
810 CONV_POINT16TO32(&(pt[i]),&(pt32[i]));
811 counts32 = (LPINT32)HEAP_xalloc( GetProcessHeap(), 0,
812 polygons*sizeof(INT32) );
813 for (i=polygons;i--;) counts32[i]=counts[i];
815 ret = PolyPolygon32(hdc,pt32,counts32,polygons);
816 HeapFree( GetProcessHeap(), 0, counts32 );
817 HeapFree( GetProcessHeap(), 0, pt32 );
821 /**********************************************************************
822 * PolyPolygon32 (GDI.450)
824 BOOL32 WINAPI PolyPolygon32( HDC32 hdc, const POINT32* pt, const INT32* counts,
827 DC * dc = DC_GetDCPtr( hdc );
829 return dc && dc->funcs->pPolyPolygon &&
830 dc->funcs->pPolyPolygon(dc,pt,counts,polygons);
833 /**********************************************************************
834 * PolyPolyline (GDI32.272)
836 BOOL32 WINAPI PolyPolyline( HDC32 hdc, const POINT32* pt, const DWORD* counts,
839 DC * dc = DC_GetDCPtr( hdc );
841 return dc && dc->funcs->pPolyPolyline &&
842 dc->funcs->pPolyPolyline(dc,pt,counts,polylines);
845 /**********************************************************************
846 * ExtFloodFill16 (GDI.372)
848 BOOL16 WINAPI ExtFloodFill16( HDC16 hdc, INT16 x, INT16 y, COLORREF color,
851 return ExtFloodFill32( hdc, x, y, color, fillType );
855 /**********************************************************************
856 * ExtFloodFill32 (GDI32.96)
858 BOOL32 WINAPI ExtFloodFill32( HDC32 hdc, INT32 x, INT32 y, COLORREF color,
861 DC *dc = DC_GetDCPtr( hdc );
863 return dc && dc->funcs->pExtFloodFill &&
864 dc->funcs->pExtFloodFill(dc,x,y,color,fillType);
868 /**********************************************************************
869 * FloodFill16 (GDI.25)
871 BOOL16 WINAPI FloodFill16( HDC16 hdc, INT16 x, INT16 y, COLORREF color )
873 return ExtFloodFill32( hdc, x, y, color, FLOODFILLBORDER );
877 /**********************************************************************
878 * FloodFill32 (GDI32.104)
880 BOOL32 WINAPI FloodFill32( HDC32 hdc, INT32 x, INT32 y, COLORREF color )
882 return ExtFloodFill32( hdc, x, y, color, FLOODFILLBORDER );
886 /**********************************************************************
887 * DrawAnimatedRects16 (USER.448)
889 BOOL16 WINAPI DrawAnimatedRects16( HWND16 hwnd, INT16 idAni,
890 const RECT16* lprcFrom,
891 const RECT16* lprcTo )
893 RECT32 rcFrom32, rcTo32;
895 rcFrom32.left = (INT32)lprcFrom->left;
896 rcFrom32.top = (INT32)lprcFrom->top;
897 rcFrom32.right = (INT32)lprcFrom->right;
898 rcFrom32.bottom = (INT32)lprcFrom->bottom;
900 rcTo32.left = (INT32)lprcTo->left;
901 rcTo32.top = (INT32)lprcTo->top;
902 rcTo32.right = (INT32)lprcTo->right;
903 rcTo32.bottom = (INT32)lprcTo->bottom;
905 return DrawAnimatedRects32((HWND32)hwnd, (INT32)idAni, &rcFrom32, &rcTo32);
909 /**********************************************************************
910 * DrawAnimatedRects32 (USER32.153)
912 BOOL32 WINAPI DrawAnimatedRects32( HWND32 hwnd, int idAni,
913 const RECT32* lprcFrom,
914 const RECT32* lprcTo )
916 FIXME(gdi,"(0x%x,%d,%p,%p): stub\n",hwnd,idAni,lprcFrom,lprcTo);
921 /**********************************************************************
922 * PAINTING_DrawStateJam
924 * Jams in the requested type in the dc
926 static BOOL32 PAINTING_DrawStateJam(HDC32 hdc, UINT32 opcode,
927 DRAWSTATEPROC32 func, LPARAM lp, WPARAM32 wp,
928 LPRECT32 rc, UINT32 dtflags,
929 BOOL32 unicode, BOOL32 _32bit)
934 INT32 cx = rc->right - rc->left;
935 INT32 cy = rc->bottom - rc->top;
942 return DrawText32W(hdc, (LPWSTR)lp, (INT32)wp, rc, dtflags);
944 return DrawText32A(hdc, (LPSTR)lp, (INT32)wp, rc, dtflags);
946 return DrawText32A(hdc, (LPSTR)PTR_SEG_TO_LIN(lp), (INT32)wp, rc, dtflags);
949 return DrawIcon32(hdc, rc->left, rc->top, (HICON32)lp);
952 memdc = CreateCompatibleDC32(hdc);
953 if(!memdc) return FALSE;
954 hbmsave = (HBITMAP32)SelectObject32(memdc, (HBITMAP32)lp);
960 retval = BitBlt32(hdc, rc->left, rc->top, cx, cy, memdc, 0, 0, SRCCOPY);
961 SelectObject32(memdc, hbmsave);
968 return func(hdc, lp, wp, cx, cy);
970 return (BOOL32)((DRAWSTATEPROC16)func)((HDC16)hdc, (LPARAM)lp, (WPARAM16)wp, (INT16)cx, (INT16)cy);
977 /**********************************************************************
978 * PAINTING_DrawState32()
980 static BOOL32 PAINTING_DrawState32(HDC32 hdc, HBRUSH32 hbr,
981 DRAWSTATEPROC32 func, LPARAM lp, WPARAM32 wp,
982 INT32 x, INT32 y, INT32 cx, INT32 cy,
983 UINT32 flags, BOOL32 unicode, BOOL32 _32bit)
985 HBITMAP32 hbm, hbmsave;
990 UINT32 dtflags = DT_NOCLIP;
992 UINT32 opcode = flags & 0xf;
996 if((opcode == DST_TEXT || opcode == DST_PREFIXTEXT) && !len) /* The string is '\0' terminated */
999 len = lstrlen32W((LPWSTR)lp);
1001 len = lstrlen32A((LPSTR)lp);
1003 len = lstrlen32A((LPSTR)PTR_SEG_TO_LIN(lp));
1006 /* Find out what size the image has if not given by caller */
1010 CURSORICONINFO *ici;
1016 case DST_PREFIXTEXT:
1018 retval = GetTextExtentPoint32W(hdc, (LPWSTR)lp, len, &s);
1020 retval = GetTextExtentPoint32A(hdc, (LPSTR)lp, len, &s);
1022 retval = GetTextExtentPoint32A(hdc, PTR_SEG_TO_LIN(lp), len, &s);
1023 if(!retval) return FALSE;
1027 ici = (CURSORICONINFO *)GlobalLock16((HGLOBAL16)lp);
1028 if(!ici) return FALSE;
1030 s.cy = ici->nHeight;
1031 GlobalUnlock16((HGLOBAL16)lp);
1035 bmp = (BITMAPOBJ *)GDI_GetObjPtr((HBITMAP16)lp, BITMAP_MAGIC);
1036 if(!bmp) return FALSE;
1037 s.cx = bmp->bitmap.bmWidth;
1038 s.cy = bmp->bitmap.bmHeight;
1041 case DST_COMPLEX: /* cx and cy must be set in this mode */
1054 if(flags & DSS_RIGHT) /* This one is not documented in the win32.hlp file */
1055 dtflags |= DT_RIGHT;
1056 if(opcode == DST_TEXT)
1057 dtflags |= DT_NOPREFIX;
1059 /* For DSS_NORMAL we just jam in the image and return */
1060 if((flags & 0x7ff0) == DSS_NORMAL)
1062 return PAINTING_DrawStateJam(hdc, opcode, func, lp, len, &rc, dtflags, unicode, _32bit);
1065 /* For all other states we need to convert the image to B/W in a local bitmap */
1066 /* before it is displayed */
1067 fg = SetTextColor32(hdc, RGB(0, 0, 0));
1068 bg = SetBkColor32(hdc, RGB(255, 255, 255));
1069 hbm = (HBITMAP32)NULL; hbmsave = (HBITMAP32)NULL;
1070 memdc = (HDC32)NULL; hbsave = (HBRUSH32)NULL;
1071 retval = FALSE; /* assume failure */
1073 /* From here on we must use "goto cleanup" when something goes wrong */
1074 hbm = CreateBitmap32(cx, cy, 1, 1, NULL);
1075 if(!hbm) goto cleanup;
1076 memdc = CreateCompatibleDC32(hdc);
1077 if(!memdc) goto cleanup;
1078 hbmsave = (HBITMAP32)SelectObject32(memdc, hbm);
1079 if(!hbmsave) goto cleanup;
1080 rc.left = rc.top = 0;
1083 if(!FillRect32(memdc, &rc, (HBRUSH32)GetStockObject32(WHITE_BRUSH))) goto cleanup;
1084 SetBkColor32(memdc, RGB(255, 255, 255));
1085 SetTextColor32(memdc, RGB(0, 0, 0));
1086 hfsave = (HFONT32)SelectObject32(memdc, GetCurrentObject(hdc, OBJ_FONT));
1087 if(!hfsave && (opcode == DST_TEXT || opcode == DST_PREFIXTEXT)) goto cleanup;
1088 tmp = PAINTING_DrawStateJam(memdc, opcode, func, lp, len, &rc, dtflags, unicode, _32bit);
1089 if(hfsave) SelectObject32(memdc, hfsave);
1090 if(!tmp) goto cleanup;
1092 /* These states cause the image to be dithered */
1093 if(flags & (DSS_UNION|DSS_DISABLED))
1095 hbsave = (HBRUSH32)SelectObject32(memdc, CACHE_GetPattern55AABrush());
1096 if(!hbsave) goto cleanup;
1097 tmp = PatBlt32(memdc, 0, 0, cx, cy, 0x00FA0089);
1098 if(hbsave) SelectObject32(memdc, hbsave);
1099 if(!tmp) goto cleanup;
1102 hbsave = (HBRUSH32)SelectObject32(hdc, hbr ? hbr : GetStockObject32(WHITE_BRUSH));
1103 if(!hbsave) goto cleanup;
1105 if(!BitBlt32(hdc, x, y, cx, cy, memdc, 0, 0, 0x00B8074A)) goto cleanup;
1107 /* DSS_DEFAULT makes the image boldface */
1108 if(flags & DSS_DEFAULT)
1110 if(!BitBlt32(hdc, x+1, y, cx, cy, memdc, 0, 0, 0x00B8074A)) goto cleanup;
1113 retval = TRUE; /* We succeeded */
1116 SetTextColor32(hdc, fg);
1117 SetBkColor32(hdc, bg);
1119 if(hbsave) SelectObject32(hdc, hbsave);
1120 if(hbmsave) SelectObject32(memdc, hbmsave);
1121 if(hbm) DeleteObject32(hbm);
1122 if(memdc) DeleteDC32(memdc);
1127 /**********************************************************************
1128 * DrawState32A() (USER32.162)
1130 BOOL32 WINAPI DrawState32A(HDC32 hdc, HBRUSH32 hbr,
1131 DRAWSTATEPROC32 func, LPARAM ldata, WPARAM32 wdata,
1132 INT32 x, INT32 y, INT32 cx, INT32 cy, UINT32 flags)
1134 return PAINTING_DrawState32(hdc, hbr, func, ldata, wdata, x, y, cx, cy, flags, FALSE, TRUE);
1137 /**********************************************************************
1138 * DrawState32W() (USER32.163)
1140 BOOL32 WINAPI DrawState32W(HDC32 hdc, HBRUSH32 hbr,
1141 DRAWSTATEPROC32 func, LPARAM ldata, WPARAM32 wdata,
1142 INT32 x, INT32 y, INT32 cx, INT32 cy, UINT32 flags)
1144 return PAINTING_DrawState32(hdc, hbr, func, ldata, wdata, x, y, cx, cy, flags, TRUE, TRUE);
1147 /**********************************************************************
1148 * DrawState16() (USER.449)
1150 BOOL16 WINAPI DrawState16(HDC16 hdc, HBRUSH16 hbr,
1151 DRAWSTATEPROC16 func, LPARAM ldata, WPARAM16 wdata,
1152 INT16 x, INT16 y, INT16 cx, INT16 cy, UINT16 flags)
1154 return PAINTING_DrawState32(hdc, hbr, (DRAWSTATEPROC32)func, ldata, wdata, x, y, cx, cy, flags, FALSE, FALSE);
1158 /******************************************************************************
1159 * PolyBezier16 [GDI.502]
1161 BOOL16 WINAPI PolyBezier16( HDC16 hDc, const POINT16* lppt, INT16 cPoints )
1165 LPPOINT32 pt32 = (LPPOINT32)HeapAlloc( GetProcessHeap(), 0,
1166 cPoints*sizeof(POINT32) );
1167 if(!pt32) return FALSE;
1168 for (i=cPoints;i--;) CONV_POINT16TO32(&(lppt[i]),&(pt32[i]));
1169 ret= PolyBezier32(hDc, pt32, cPoints);
1170 HeapFree( GetProcessHeap(), 0, pt32 );
1174 /******************************************************************************
1175 * PolyBezierTo16 [GDI.503]
1177 BOOL16 WINAPI PolyBezierTo16( HDC16 hDc, const POINT16* lppt, INT16 cPoints )
1181 LPPOINT32 pt32 = (LPPOINT32)HeapAlloc( GetProcessHeap(), 0,
1182 cPoints*sizeof(POINT32) );
1183 if(!pt32) return FALSE;
1184 for (i=cPoints;i--;) CONV_POINT16TO32(&(lppt[i]),&(pt32[i]));
1185 ret= PolyBezierTo32(hDc, pt32, cPoints);
1186 HeapFree( GetProcessHeap(), 0, pt32 );
1190 /******************************************************************************
1191 * PolyBezier32 [GDI32.268]
1192 * Draws one or more Bezier curves
1195 * hDc [I] Handle to device context
1196 * lppt [I] Pointer to endpoints and control points
1197 * cPoints [I] Count of endpoints and control points
1201 BOOL32 WINAPI PolyBezier32( HDC32 hdc, const POINT32* lppt, DWORD cPoints )
1203 DC * dc = DC_GetDCPtr( hdc );
1204 if(!dc) return FALSE;
1205 if(dc && PATH_IsPathOpen(dc->w.path))
1206 FIXME(gdi, "PATH_PolyBezier is not implemented!\n");
1207 /* if(!PATH_PolyBezier(hdc, x, y))
1209 return dc->funcs->pPolyBezier&&
1210 dc->funcs->pPolyBezier(dc, lppt[0], lppt+1, cPoints-1);
1213 /******************************************************************************
1214 * PolyBezierTo32 [GDI32.269]
1215 * Draws one or more Bezier curves
1218 * hDc [I] Handle to device context
1219 * lppt [I] Pointer to endpoints and control points
1220 * cPoints [I] Count of endpoints and control points
1224 BOOL32 WINAPI PolyBezierTo32( HDC32 hdc, const POINT32* lppt, DWORD cPoints )
1226 DC * dc = DC_GetDCPtr( hdc );
1229 if(!dc) return FALSE;
1230 pt.x=dc->w.CursPosX;
1231 pt.y=dc->w.CursPosY;
1232 if(dc && PATH_IsPathOpen(dc->w.path))
1233 FIXME(gdi, "PATH_PolyBezierTo is not implemented!\n");
1234 /* if(!PATH_PolyBezier(hdc, x, y))
1236 ret= dc->funcs->pPolyBezier &&
1237 dc->funcs->pPolyBezier(dc, pt, lppt, cPoints);
1238 if( dc->funcs->pMoveToEx)
1239 dc->funcs->pMoveToEx(dc,lppt[cPoints].x,lppt[cPoints].y,&pt);
1243 /***************************************************************
1244 * AngleArc (GDI32.5)
1247 BOOL32 WINAPI AngleArc(HDC32 hdc, INT32 x, INT32 y, DWORD dwRadius,
1248 FLOAT eStartAngle, FLOAT eSweepAngle)
1250 FIXME(gdi,"AngleArc, stub\n");
1254 /***************************************************************
1255 * PolyDraw (GDI32.270)
1258 BOOL32 WINAPI PolyDraw(HDC32 hdc, const POINT32 *lppt, const BYTE *lpbTypes,
1261 FIXME(gdi,"PolyDraw, stub\n");