2 * Misc. graphics operations
4 * Copyright 1993, 1994 Alexandre Julliard
5 * Copyright 1997 Bertho A. Stultiens
19 #include "wine/winuser16.h"
21 DEFAULT_DEBUG_CHANNEL(gdi
)
24 /***********************************************************************
27 BOOL16 WINAPI
LineTo16( HDC16 hdc
, INT16 x
, INT16 y
)
29 return LineTo( hdc
, x
, y
);
33 /***********************************************************************
34 * LineTo32 (GDI32.249)
36 BOOL WINAPI
LineTo( HDC hdc
, INT x
, INT y
)
38 DC
* dc
= DC_GetDCPtr( hdc
);
40 if(dc
&& PATH_IsPathOpen(dc
->w
.path
))
41 if(!PATH_LineTo(hdc
, x
, y
))
44 return dc
&& dc
->funcs
->pLineTo
&&
45 dc
->funcs
->pLineTo(dc
,x
,y
);
49 /***********************************************************************
52 DWORD WINAPI
MoveTo16( HDC16 hdc
, INT16 x
, INT16 y
)
56 if (!MoveToEx16(hdc
,x
,y
,&pt
))
58 return MAKELONG(pt
.x
,pt
.y
);
62 /***********************************************************************
63 * MoveToEx16 (GDI.483)
65 BOOL16 WINAPI
MoveToEx16( HDC16 hdc
, INT16 x
, INT16 y
, LPPOINT16 pt
)
69 if (!MoveToEx( (HDC
)hdc
, (INT
)x
, (INT
)y
, &pt32
)) return FALSE
;
70 if (pt
) CONV_POINT32TO16( &pt32
, pt
);
76 /***********************************************************************
77 * MoveToEx32 (GDI32.254)
79 BOOL WINAPI
MoveToEx( HDC hdc
, INT x
, INT y
, LPPOINT pt
)
81 DC
* dc
= DC_GetDCPtr( hdc
);
83 if(dc
&& PATH_IsPathOpen(dc
->w
.path
))
87 return dc
&& dc
->funcs
->pMoveToEx
&&
88 dc
->funcs
->pMoveToEx(dc
,x
,y
,pt
);
92 /***********************************************************************
95 BOOL16 WINAPI
Arc16( HDC16 hdc
, INT16 left
, INT16 top
, INT16 right
,
96 INT16 bottom
, INT16 xstart
, INT16 ystart
,
97 INT16 xend
, INT16 yend
)
99 return Arc( (HDC
)hdc
, (INT
)left
, (INT
)top
, (INT
)right
,
100 (INT
)bottom
, (INT
)xstart
, (INT
)ystart
, (INT
)xend
,
105 /***********************************************************************
108 BOOL WINAPI
Arc( HDC hdc
, INT left
, INT top
, INT right
,
109 INT bottom
, INT xstart
, INT ystart
,
112 DC
* dc
= DC_GetDCPtr( hdc
);
114 if(dc
&& PATH_IsPathOpen(dc
->w
.path
))
115 if(!PATH_Arc(hdc
, left
, top
, right
, bottom
, xstart
, ystart
, xend
,
119 return dc
&& dc
->funcs
->pArc
&&
120 dc
->funcs
->pArc(dc
,left
,top
,right
,bottom
,xstart
,ystart
,xend
,yend
);
123 /***********************************************************************
126 BOOL WINAPI
ArcTo( HDC hdc
,
128 INT right
, INT bottom
,
129 INT xstart
, INT ystart
,
135 * According to the documentation, a line is drawn from the current
136 * position to the starting point of the arc.
138 LineTo(hdc
, xstart
, ystart
);
141 * Then the arc is drawn.
150 * If no error occured, the current position is moved to the ending
155 MoveToEx(hdc
, xend
, yend
, NULL
);
161 /***********************************************************************
164 BOOL16 WINAPI
Pie16( HDC16 hdc
, INT16 left
, INT16 top
,
165 INT16 right
, INT16 bottom
, INT16 xstart
, INT16 ystart
,
166 INT16 xend
, INT16 yend
)
168 return Pie( (HDC
)hdc
, (INT
)left
, (INT
)top
, (INT
)right
,
169 (INT
)bottom
, (INT
)xstart
, (INT
)ystart
, (INT
)xend
,
174 /***********************************************************************
177 BOOL WINAPI
Pie( HDC hdc
, INT left
, INT top
,
178 INT right
, INT bottom
, INT xstart
, INT ystart
,
181 DC
* dc
= DC_GetDCPtr( hdc
);
183 return dc
&& dc
->funcs
->pPie
&&
184 dc
->funcs
->pPie(dc
,left
,top
,right
,bottom
,xstart
,ystart
,xend
,yend
);
188 /***********************************************************************
191 BOOL16 WINAPI
Chord16( HDC16 hdc
, INT16 left
, INT16 top
,
192 INT16 right
, INT16 bottom
, INT16 xstart
, INT16 ystart
,
193 INT16 xend
, INT16 yend
)
195 return Chord( hdc
, left
, top
, right
, bottom
, xstart
, ystart
, xend
, yend
);
199 /***********************************************************************
202 BOOL WINAPI
Chord( HDC hdc
, INT left
, INT top
,
203 INT right
, INT bottom
, INT xstart
, INT ystart
,
206 DC
* dc
= DC_GetDCPtr( hdc
);
208 return dc
&& dc
->funcs
->pChord
&&
209 dc
->funcs
->pChord(dc
,left
,top
,right
,bottom
,xstart
,ystart
,xend
,yend
);
213 /***********************************************************************
216 BOOL16 WINAPI
Ellipse16( HDC16 hdc
, INT16 left
, INT16 top
,
217 INT16 right
, INT16 bottom
)
219 return Ellipse( hdc
, left
, top
, right
, bottom
);
223 /***********************************************************************
224 * Ellipse32 (GDI32.75)
226 BOOL WINAPI
Ellipse( HDC hdc
, INT left
, INT top
,
227 INT right
, INT bottom
)
229 DC
* dc
= DC_GetDCPtr( hdc
);
231 return dc
&& dc
->funcs
->pEllipse
&&
232 dc
->funcs
->pEllipse(dc
,left
,top
,right
,bottom
);
236 /***********************************************************************
237 * Rectangle16 (GDI.27)
239 BOOL16 WINAPI
Rectangle16( HDC16 hdc
, INT16 left
, INT16 top
,
240 INT16 right
, INT16 bottom
)
242 return Rectangle( hdc
, left
, top
, right
, bottom
);
246 /***********************************************************************
247 * Rectangle32 (GDI32.283)
249 BOOL WINAPI
Rectangle( HDC hdc
, INT left
, INT top
,
250 INT right
, INT bottom
)
252 DC
* dc
= DC_GetDCPtr( hdc
);
254 if(dc
&& PATH_IsPathOpen(dc
->w
.path
))
255 if(!PATH_Rectangle(hdc
, left
, top
, right
, bottom
))
258 return dc
&& dc
->funcs
->pRectangle
&&
259 dc
->funcs
->pRectangle(dc
,left
,top
,right
,bottom
);
263 /***********************************************************************
264 * RoundRect16 (GDI.28)
266 BOOL16 WINAPI
RoundRect16( HDC16 hdc
, INT16 left
, INT16 top
, INT16 right
,
267 INT16 bottom
, INT16 ell_width
, INT16 ell_height
)
269 return RoundRect( hdc
, left
, top
, right
, bottom
, ell_width
, ell_height
);
273 /***********************************************************************
274 * RoundRect32 (GDI32.291)
276 BOOL WINAPI
RoundRect( HDC hdc
, INT left
, INT top
, INT right
,
277 INT bottom
, INT ell_width
, INT ell_height
)
280 if(ell_width
== 0 || ell_height
== 0) /* Just an optimization */
281 return Rectangle(hdc
, left
, top
, right
, bottom
);
284 DC
* dc
= DC_GetDCPtr( hdc
);
286 return dc
&& dc
->funcs
->pRoundRect
&&
287 dc
->funcs
->pRoundRect(dc
,left
,top
,right
,bottom
,ell_width
,ell_height
);
292 /***********************************************************************
293 * FillRect16 (USER.81)
295 INT16 WINAPI
FillRect16( HDC16 hdc
, const RECT16
*rect
, HBRUSH16 hbrush
)
299 /* coordinates are logical so we cannot fast-check 'rect',
300 * it will be done later in the PatBlt().
303 if (!(prevBrush
= SelectObject16( hdc
, hbrush
))) return 0;
304 PatBlt( hdc
, rect
->left
, rect
->top
,
305 rect
->right
- rect
->left
, rect
->bottom
- rect
->top
, PATCOPY
);
306 SelectObject16( hdc
, prevBrush
);
311 /***********************************************************************
312 * FillRect32 (USER32.197)
314 INT WINAPI
FillRect( HDC hdc
, const RECT
*rect
, HBRUSH hbrush
)
318 if (!(prevBrush
= SelectObject( hdc
, hbrush
))) return 0;
319 PatBlt( hdc
, rect
->left
, rect
->top
,
320 rect
->right
- rect
->left
, rect
->bottom
- rect
->top
, PATCOPY
);
321 SelectObject( hdc
, prevBrush
);
326 /***********************************************************************
327 * InvertRect16 (USER.82)
329 void WINAPI
InvertRect16( HDC16 hdc
, const RECT16
*rect
)
331 PatBlt( hdc
, rect
->left
, rect
->top
,
332 rect
->right
- rect
->left
, rect
->bottom
- rect
->top
, DSTINVERT
);
336 /***********************************************************************
337 * InvertRect32 (USER32.330)
339 BOOL WINAPI
InvertRect( HDC hdc
, const RECT
*rect
)
341 return PatBlt( hdc
, rect
->left
, rect
->top
,
342 rect
->right
- rect
->left
, rect
->bottom
- rect
->top
,
347 /***********************************************************************
348 * FrameRect16 (USER.83)
350 INT16 WINAPI
FrameRect16( HDC16 hdc
, const RECT16
*rect
, HBRUSH16 hbrush
)
353 int left
, top
, right
, bottom
;
355 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
356 if (!dc
) return FALSE
;
358 left
= XLPTODP( dc
, rect
->left
);
359 top
= YLPTODP( dc
, rect
->top
);
360 right
= XLPTODP( dc
, rect
->right
);
361 bottom
= YLPTODP( dc
, rect
->bottom
);
363 if ( (right
<= left
) || (bottom
<= top
) ) return 0;
364 if (!(prevBrush
= SelectObject16( hdc
, hbrush
))) return 0;
366 PatBlt( hdc
, rect
->left
, rect
->top
, 1,
367 rect
->bottom
- rect
->top
, PATCOPY
);
368 PatBlt( hdc
, rect
->right
- 1, rect
->top
, 1,
369 rect
->bottom
- rect
->top
, PATCOPY
);
370 PatBlt( hdc
, rect
->left
, rect
->top
,
371 rect
->right
- rect
->left
, 1, PATCOPY
);
372 PatBlt( hdc
, rect
->left
, rect
->bottom
- 1,
373 rect
->right
- rect
->left
, 1, PATCOPY
);
375 SelectObject16( hdc
, prevBrush
);
380 /***********************************************************************
381 * FrameRect32 (USER32.203)
383 INT WINAPI
FrameRect( HDC hdc
, const RECT
*rect
, HBRUSH hbrush
)
386 CONV_RECT32TO16( rect
, &rect16
);
387 return FrameRect16( (HDC16
)hdc
, &rect16
, (HBRUSH16
)hbrush
);
391 /***********************************************************************
392 * SetPixel16 (GDI.31)
394 COLORREF WINAPI
SetPixel16( HDC16 hdc
, INT16 x
, INT16 y
, COLORREF color
)
396 return SetPixel( hdc
, x
, y
, color
);
400 /***********************************************************************
401 * SetPixel32 (GDI32.327)
403 COLORREF WINAPI
SetPixel( HDC hdc
, INT x
, INT y
, COLORREF color
)
405 DC
* dc
= DC_GetDCPtr( hdc
);
407 if (!dc
|| !dc
->funcs
->pSetPixel
) return 0;
408 return dc
->funcs
->pSetPixel(dc
,x
,y
,color
);
411 /***********************************************************************
412 * SetPixelV32 (GDI32.329)
414 BOOL WINAPI
SetPixelV( HDC hdc
, INT x
, INT y
, COLORREF color
)
416 DC
* dc
= DC_GetDCPtr( hdc
);
418 if (!dc
|| !dc
->funcs
->pSetPixel
) return FALSE
;
419 dc
->funcs
->pSetPixel(dc
,x
,y
,color
);
423 /***********************************************************************
424 * GetPixel16 (GDI.83)
426 COLORREF WINAPI
GetPixel16( HDC16 hdc
, INT16 x
, INT16 y
)
428 return GetPixel( hdc
, x
, y
);
432 /***********************************************************************
433 * GetPixel32 (GDI32.211)
435 COLORREF WINAPI
GetPixel( HDC hdc
, INT x
, INT y
)
437 DC
* dc
= DC_GetDCPtr( hdc
);
440 #ifdef SOLITAIRE_SPEED_HACK
444 /* FIXME: should this be in the graphics driver? */
445 if (!PtVisible( hdc
, x
, y
)) return 0;
446 if (!dc
|| !dc
->funcs
->pGetPixel
) return 0;
447 return dc
->funcs
->pGetPixel(dc
,x
,y
);
451 /******************************************************************************
452 * ChoosePixelFormat [GDI32.13]
453 * Matches a pixel format to given format
456 * hdc [I] Device context to search for best pixel match
457 * ppfd [I] Pixel format for which a match is sought
460 * Success: Pixel format index closest to given format
463 INT WINAPI
ChoosePixelFormat( HDC hdc
, const PIXELFORMATDESCRIPTOR
* ppfd
)
465 FIXME(gdi
, "(%d,%p): stub\n",hdc
,ppfd
);
470 /******************************************************************************
471 * SetPixelFormat [GDI32.328]
472 * Sets pixel format of device context
475 * hdc [I] Device context to search for best pixel match
476 * iPixelFormat [I] Pixel format index
477 * ppfd [I] Pixel format for which a match is sought
481 BOOL WINAPI
SetPixelFormat( HDC hdc
, int iPixelFormat
,
482 const PIXELFORMATDESCRIPTOR
* ppfd
)
484 FIXME(gdi
, "(%d,%d,%p): stub\n",hdc
,iPixelFormat
,ppfd
);
489 /******************************************************************************
490 * GetPixelFormat [GDI32.212]
491 * Gets index of pixel format of DC
494 * hdc [I] Device context whose pixel format index is sought
497 * Success: Currently selected pixel format
500 int WINAPI
GetPixelFormat( HDC hdc
)
502 FIXME(gdi
, "(%d): stub\n",hdc
);
507 /******************************************************************************
508 * DescribePixelFormat [GDI32.71]
509 * Gets info about pixel format from DC
512 * hdc [I] Device context
513 * iPixelFormat [I] Pixel format selector
514 * nBytes [I] Size of buffer
515 * ppfd [O] Pointer to structure to receive pixel format data
518 * Success: Maximum pixel format index of the device context
521 int WINAPI
DescribePixelFormat( HDC hdc
, int iPixelFormat
, UINT nBytes
,
522 LPPIXELFORMATDESCRIPTOR ppfd
)
524 FIXME(gdi
, "(%d,%d,%d,%p): stub\n",hdc
,iPixelFormat
,nBytes
,ppfd
);
525 ppfd
->nSize
= nBytes
;
531 /******************************************************************************
532 * SwapBuffers [GDI32.354]
533 * Exchanges front and back buffers of window
536 * hdc [I] Device context whose buffers get swapped
540 BOOL WINAPI
SwapBuffers( HDC hdc
)
542 FIXME(gdi
, "(%d): stub\n",hdc
);
547 /***********************************************************************
548 * PaintRgn16 (GDI.43)
550 BOOL16 WINAPI
PaintRgn16( HDC16 hdc
, HRGN16 hrgn
)
552 return PaintRgn( hdc
, hrgn
);
556 /***********************************************************************
557 * PaintRgn32 (GDI32.259)
559 BOOL WINAPI
PaintRgn( HDC hdc
, HRGN hrgn
)
561 DC
* dc
= DC_GetDCPtr( hdc
);
563 return dc
&& dc
->funcs
->pPaintRgn
&&
564 dc
->funcs
->pPaintRgn(dc
,hrgn
);
568 /***********************************************************************
571 BOOL16 WINAPI
FillRgn16( HDC16 hdc
, HRGN16 hrgn
, HBRUSH16 hbrush
)
573 return FillRgn( hdc
, hrgn
, hbrush
);
577 /***********************************************************************
578 * FillRgn32 (GDI32.101)
580 BOOL WINAPI
FillRgn( HDC hdc
, HRGN hrgn
, HBRUSH hbrush
)
583 HBRUSH prevBrush
= SelectObject( hdc
, hbrush
);
584 if (!prevBrush
) return FALSE
;
585 retval
= PaintRgn( hdc
, hrgn
);
586 SelectObject( hdc
, prevBrush
);
591 /***********************************************************************
592 * FrameRgn16 (GDI.41)
594 BOOL16 WINAPI
FrameRgn16( HDC16 hdc
, HRGN16 hrgn
, HBRUSH16 hbrush
,
595 INT16 nWidth
, INT16 nHeight
)
597 return FrameRgn( hdc
, hrgn
, hbrush
, nWidth
, nHeight
);
601 /***********************************************************************
602 * FrameRgn32 (GDI32.105)
604 BOOL WINAPI
FrameRgn( HDC hdc
, HRGN hrgn
, HBRUSH hbrush
,
605 INT nWidth
, INT nHeight
)
607 HRGN tmp
= CreateRectRgn( 0, 0, 0, 0 );
608 if(!REGION_FrameRgn( tmp
, hrgn
, nWidth
, nHeight
)) return FALSE
;
609 FillRgn( hdc
, tmp
, hbrush
);
615 /***********************************************************************
616 * InvertRgn16 (GDI.42)
618 BOOL16 WINAPI
InvertRgn16( HDC16 hdc
, HRGN16 hrgn
)
620 return InvertRgn( hdc
, hrgn
);
624 /***********************************************************************
625 * InvertRgn32 (GDI32.246)
627 BOOL WINAPI
InvertRgn( HDC hdc
, HRGN hrgn
)
629 HBRUSH prevBrush
= SelectObject( hdc
, GetStockObject(BLACK_BRUSH
) );
630 INT prevROP
= SetROP2( hdc
, R2_NOT
);
631 BOOL retval
= PaintRgn( hdc
, hrgn
);
632 SelectObject( hdc
, prevBrush
);
633 SetROP2( hdc
, prevROP
);
638 /***********************************************************************
639 * DrawFocusRect16 (USER.466)
641 void WINAPI
DrawFocusRect16( HDC16 hdc
, const RECT16
* rc
)
644 CONV_RECT16TO32( rc
, &rect32
);
645 DrawFocusRect( hdc
, &rect32
);
649 /***********************************************************************
650 * DrawFocusRect32 (USER32.156)
652 * FIXME: PatBlt(PATINVERT) with background brush.
654 BOOL WINAPI
DrawFocusRect( HDC hdc
, const RECT
* rc
)
657 HPEN hOldPen
, hNewPen
;
658 INT oldDrawMode
, oldBkMode
;
660 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
663 SetLastError( ERROR_INVALID_HANDLE
);
667 hOldBrush
= SelectObject(hdc
, GetStockObject(NULL_BRUSH
));
668 hNewPen
= CreatePen(PS_DOT
, 1, GetSysColor(COLOR_WINDOWTEXT
));
669 hOldPen
= SelectObject(hdc
, hNewPen
);
670 oldDrawMode
= SetROP2(hdc
, R2_XORPEN
);
671 oldBkMode
= SetBkMode(hdc
, TRANSPARENT
);
673 Rectangle(hdc
, rc
->left
, rc
->top
, rc
->right
, rc
->bottom
);
675 SetBkMode(hdc
, oldBkMode
);
676 SetROP2(hdc
, oldDrawMode
);
677 SelectObject(hdc
, hOldPen
);
678 DeleteObject(hNewPen
);
679 SelectObject(hdc
, hOldBrush
);
685 /**********************************************************************
686 * Polyline16 (GDI.37)
688 BOOL16 WINAPI
Polyline16( HDC16 hdc
, const POINT16
* pt
, INT16 count
)
692 LPPOINT pt32
= (LPPOINT
)HeapAlloc( GetProcessHeap(), 0,
693 count
*sizeof(POINT
) );
695 if (!pt32
) return FALSE
;
696 for (i
=count
;i
--;) CONV_POINT16TO32(&(pt
[i
]),&(pt32
[i
]));
697 ret
= Polyline(hdc
,pt32
,count
);
698 HeapFree( GetProcessHeap(), 0, pt32
);
703 /**********************************************************************
704 * Polyline32 (GDI32.276)
706 BOOL WINAPI
Polyline( HDC hdc
, const POINT
* pt
, INT count
)
708 DC
* dc
= DC_GetDCPtr( hdc
);
710 return dc
&& dc
->funcs
->pPolyline
&&
711 dc
->funcs
->pPolyline(dc
,pt
,count
);
714 /**********************************************************************
715 * PolylineTo32 (GDI32.277)
717 BOOL WINAPI
PolylineTo( HDC hdc
, const POINT
* pt
, DWORD cCount
)
719 POINT
*pts
= HeapAlloc( GetProcessHeap(), 0,
720 sizeof(POINT
) * (cCount
+ 1) );
721 if(!pts
) return FALSE
;
723 /* Get the current point */
724 MoveToEx( hdc
, 0, 0, pts
);
726 /* Add in the other points */
727 memcpy( pts
+ 1, pt
, sizeof(POINT
) * cCount
);
730 Polyline( hdc
, pts
, cCount
+ 1 );
732 /* Move to last point */
733 MoveToEx( hdc
, (pts
+ cCount
)->x
, (pts
+ cCount
)->y
, NULL
);
735 HeapFree( GetProcessHeap(), 0, pts
);
739 /**********************************************************************
742 BOOL16 WINAPI
Polygon16( HDC16 hdc
, const POINT16
* pt
, INT16 count
)
746 LPPOINT pt32
= (LPPOINT
)HeapAlloc( GetProcessHeap(), 0,
747 count
*sizeof(POINT
) );
749 if (!pt32
) return FALSE
;
750 for (i
=count
;i
--;) CONV_POINT16TO32(&(pt
[i
]),&(pt32
[i
]));
751 ret
= Polygon(hdc
,pt32
,count
);
752 HeapFree( GetProcessHeap(), 0, pt32
);
757 /**********************************************************************
758 * Polygon32 (GDI32.275)
760 BOOL WINAPI
Polygon( HDC hdc
, const POINT
* pt
, INT count
)
762 DC
* dc
= DC_GetDCPtr( hdc
);
764 return dc
&& dc
->funcs
->pPolygon
&&
765 dc
->funcs
->pPolygon(dc
,pt
,count
);
769 /**********************************************************************
770 * PolyPolygon16 (GDI.450)
772 BOOL16 WINAPI
PolyPolygon16( HDC16 hdc
, const POINT16
* pt
, const INT16
* counts
,
781 for (i
=polygons
;i
--;)
783 pt32
= (LPPOINT
)HEAP_xalloc( GetProcessHeap(), 0, sizeof(POINT
)*nrpts
);
785 CONV_POINT16TO32(&(pt
[i
]),&(pt32
[i
]));
786 counts32
= (LPINT
)HEAP_xalloc( GetProcessHeap(), 0,
787 polygons
*sizeof(INT
) );
788 for (i
=polygons
;i
--;) counts32
[i
]=counts
[i
];
790 ret
= PolyPolygon(hdc
,pt32
,counts32
,polygons
);
791 HeapFree( GetProcessHeap(), 0, counts32
);
792 HeapFree( GetProcessHeap(), 0, pt32
);
796 /**********************************************************************
797 * PolyPolygon32 (GDI.450)
799 BOOL WINAPI
PolyPolygon( HDC hdc
, const POINT
* pt
, const INT
* counts
,
802 DC
* dc
= DC_GetDCPtr( hdc
);
804 return dc
&& dc
->funcs
->pPolyPolygon
&&
805 dc
->funcs
->pPolyPolygon(dc
,pt
,counts
,polygons
);
808 /**********************************************************************
809 * PolyPolyline (GDI32.272)
811 BOOL WINAPI
PolyPolyline( HDC hdc
, const POINT
* pt
, const DWORD
* counts
,
814 DC
* dc
= DC_GetDCPtr( hdc
);
816 return dc
&& dc
->funcs
->pPolyPolyline
&&
817 dc
->funcs
->pPolyPolyline(dc
,pt
,counts
,polylines
);
820 /**********************************************************************
821 * ExtFloodFill16 (GDI.372)
823 BOOL16 WINAPI
ExtFloodFill16( HDC16 hdc
, INT16 x
, INT16 y
, COLORREF color
,
826 return ExtFloodFill( hdc
, x
, y
, color
, fillType
);
830 /**********************************************************************
831 * ExtFloodFill32 (GDI32.96)
833 BOOL WINAPI
ExtFloodFill( HDC hdc
, INT x
, INT y
, COLORREF color
,
836 DC
*dc
= DC_GetDCPtr( hdc
);
838 return dc
&& dc
->funcs
->pExtFloodFill
&&
839 dc
->funcs
->pExtFloodFill(dc
,x
,y
,color
,fillType
);
843 /**********************************************************************
844 * FloodFill16 (GDI.25)
846 BOOL16 WINAPI
FloodFill16( HDC16 hdc
, INT16 x
, INT16 y
, COLORREF color
)
848 return ExtFloodFill( hdc
, x
, y
, color
, FLOODFILLBORDER
);
852 /**********************************************************************
853 * FloodFill32 (GDI32.104)
855 BOOL WINAPI
FloodFill( HDC hdc
, INT x
, INT y
, COLORREF color
)
857 return ExtFloodFill( hdc
, x
, y
, color
, FLOODFILLBORDER
);
861 /**********************************************************************
862 * DrawAnimatedRects16 (USER.448)
864 BOOL16 WINAPI
DrawAnimatedRects16( HWND16 hwnd
, INT16 idAni
,
865 const RECT16
* lprcFrom
,
866 const RECT16
* lprcTo
)
868 RECT rcFrom32
, rcTo32
;
870 rcFrom32
.left
= (INT
)lprcFrom
->left
;
871 rcFrom32
.top
= (INT
)lprcFrom
->top
;
872 rcFrom32
.right
= (INT
)lprcFrom
->right
;
873 rcFrom32
.bottom
= (INT
)lprcFrom
->bottom
;
875 rcTo32
.left
= (INT
)lprcTo
->left
;
876 rcTo32
.top
= (INT
)lprcTo
->top
;
877 rcTo32
.right
= (INT
)lprcTo
->right
;
878 rcTo32
.bottom
= (INT
)lprcTo
->bottom
;
880 return DrawAnimatedRects((HWND
)hwnd
, (INT
)idAni
, &rcFrom32
, &rcTo32
);
884 /**********************************************************************
885 * DrawAnimatedRects32 (USER32.153)
887 BOOL WINAPI
DrawAnimatedRects( HWND hwnd
, int idAni
,
888 const RECT
* lprcFrom
,
891 FIXME(gdi
,"(0x%x,%d,%p,%p): stub\n",hwnd
,idAni
,lprcFrom
,lprcTo
);
896 /**********************************************************************
897 * PAINTING_DrawStateJam
899 * Jams in the requested type in the dc
901 static BOOL
PAINTING_DrawStateJam(HDC hdc
, UINT opcode
,
902 DRAWSTATEPROC func
, LPARAM lp
, WPARAM wp
,
903 LPRECT rc
, UINT dtflags
,
904 BOOL unicode
, BOOL _32bit
)
909 INT cx
= rc
->right
- rc
->left
;
910 INT cy
= rc
->bottom
- rc
->top
;
917 return DrawTextW(hdc
, (LPWSTR
)lp
, (INT
)wp
, rc
, dtflags
);
919 return DrawTextA(hdc
, (LPSTR
)lp
, (INT
)wp
, rc
, dtflags
);
921 return DrawTextA(hdc
, (LPSTR
)PTR_SEG_TO_LIN(lp
), (INT
)wp
, rc
, dtflags
);
924 return DrawIcon(hdc
, rc
->left
, rc
->top
, (HICON
)lp
);
927 memdc
= CreateCompatibleDC(hdc
);
928 if(!memdc
) return FALSE
;
929 hbmsave
= (HBITMAP
)SelectObject(memdc
, (HBITMAP
)lp
);
935 retval
= BitBlt(hdc
, rc
->left
, rc
->top
, cx
, cy
, memdc
, 0, 0, SRCCOPY
);
936 SelectObject(memdc
, hbmsave
);
943 return func(hdc
, lp
, wp
, cx
, cy
);
945 return (BOOL
)((DRAWSTATEPROC16
)func
)((HDC16
)hdc
, (LPARAM
)lp
, (WPARAM16
)wp
, (INT16
)cx
, (INT16
)cy
);
952 /**********************************************************************
953 * PAINTING_DrawState32()
955 static BOOL
PAINTING_DrawState(HDC hdc
, HBRUSH hbr
,
956 DRAWSTATEPROC func
, LPARAM lp
, WPARAM wp
,
957 INT x
, INT y
, INT cx
, INT cy
,
958 UINT flags
, BOOL unicode
, BOOL _32bit
)
960 HBITMAP hbm
, hbmsave
;
965 UINT dtflags
= DT_NOCLIP
;
967 UINT opcode
= flags
& 0xf;
971 if((opcode
== DST_TEXT
|| opcode
== DST_PREFIXTEXT
) && !len
) /* The string is '\0' terminated */
974 len
= lstrlenW((LPWSTR
)lp
);
976 len
= lstrlenA((LPSTR
)lp
);
978 len
= lstrlenA((LPSTR
)PTR_SEG_TO_LIN(lp
));
981 /* Find out what size the image has if not given by caller */
993 retval
= GetTextExtentPoint32W(hdc
, (LPWSTR
)lp
, len
, &s
);
995 retval
= GetTextExtentPoint32A(hdc
, (LPSTR
)lp
, len
, &s
);
997 retval
= GetTextExtentPoint32A(hdc
, PTR_SEG_TO_LIN(lp
), len
, &s
);
998 if(!retval
) return FALSE
;
1002 ici
= (CURSORICONINFO
*)GlobalLock16((HGLOBAL16
)lp
);
1003 if(!ici
) return FALSE
;
1005 s
.cy
= ici
->nHeight
;
1006 GlobalUnlock16((HGLOBAL16
)lp
);
1010 bmp
= (BITMAPOBJ
*)GDI_GetObjPtr((HBITMAP16
)lp
, BITMAP_MAGIC
);
1011 if(!bmp
) return FALSE
;
1012 s
.cx
= bmp
->bitmap
.bmWidth
;
1013 s
.cy
= bmp
->bitmap
.bmHeight
;
1016 case DST_COMPLEX
: /* cx and cy must be set in this mode */
1029 if(flags
& DSS_RIGHT
) /* This one is not documented in the win32.hlp file */
1030 dtflags
|= DT_RIGHT
;
1031 if(opcode
== DST_TEXT
)
1032 dtflags
|= DT_NOPREFIX
;
1034 /* For DSS_NORMAL we just jam in the image and return */
1035 if((flags
& 0x7ff0) == DSS_NORMAL
)
1037 return PAINTING_DrawStateJam(hdc
, opcode
, func
, lp
, len
, &rc
, dtflags
, unicode
, _32bit
);
1040 /* For all other states we need to convert the image to B/W in a local bitmap */
1041 /* before it is displayed */
1042 fg
= SetTextColor(hdc
, RGB(0, 0, 0));
1043 bg
= SetBkColor(hdc
, RGB(255, 255, 255));
1044 hbm
= (HBITMAP
)NULL
; hbmsave
= (HBITMAP
)NULL
;
1045 memdc
= (HDC
)NULL
; hbsave
= (HBRUSH
)NULL
;
1046 retval
= FALSE
; /* assume failure */
1048 /* From here on we must use "goto cleanup" when something goes wrong */
1049 hbm
= CreateBitmap(cx
, cy
, 1, 1, NULL
);
1050 if(!hbm
) goto cleanup
;
1051 memdc
= CreateCompatibleDC(hdc
);
1052 if(!memdc
) goto cleanup
;
1053 hbmsave
= (HBITMAP
)SelectObject(memdc
, hbm
);
1054 if(!hbmsave
) goto cleanup
;
1055 rc
.left
= rc
.top
= 0;
1058 if(!FillRect(memdc
, &rc
, (HBRUSH
)GetStockObject(WHITE_BRUSH
))) goto cleanup
;
1059 SetBkColor(memdc
, RGB(255, 255, 255));
1060 SetTextColor(memdc
, RGB(0, 0, 0));
1061 hfsave
= (HFONT
)SelectObject(memdc
, GetCurrentObject(hdc
, OBJ_FONT
));
1062 if(!hfsave
&& (opcode
== DST_TEXT
|| opcode
== DST_PREFIXTEXT
)) goto cleanup
;
1063 tmp
= PAINTING_DrawStateJam(memdc
, opcode
, func
, lp
, len
, &rc
, dtflags
, unicode
, _32bit
);
1064 if(hfsave
) SelectObject(memdc
, hfsave
);
1065 if(!tmp
) goto cleanup
;
1067 /* These states cause the image to be dithered */
1068 if(flags
& (DSS_UNION
|DSS_DISABLED
))
1070 hbsave
= (HBRUSH
)SelectObject(memdc
, CACHE_GetPattern55AABrush());
1071 if(!hbsave
) goto cleanup
;
1072 tmp
= PatBlt(memdc
, 0, 0, cx
, cy
, 0x00FA0089);
1073 if(hbsave
) SelectObject(memdc
, hbsave
);
1074 if(!tmp
) goto cleanup
;
1077 hbsave
= (HBRUSH
)SelectObject(hdc
, hbr
? hbr
: GetStockObject(WHITE_BRUSH
));
1078 if(!hbsave
) goto cleanup
;
1080 if(!BitBlt(hdc
, x
, y
, cx
, cy
, memdc
, 0, 0, 0x00B8074A)) goto cleanup
;
1082 /* DSS_DEFAULT makes the image boldface */
1083 if(flags
& DSS_DEFAULT
)
1085 if(!BitBlt(hdc
, x
+1, y
, cx
, cy
, memdc
, 0, 0, 0x00B8074A)) goto cleanup
;
1088 retval
= TRUE
; /* We succeeded */
1091 SetTextColor(hdc
, fg
);
1092 SetBkColor(hdc
, bg
);
1094 if(hbsave
) SelectObject(hdc
, hbsave
);
1095 if(hbmsave
) SelectObject(memdc
, hbmsave
);
1096 if(hbm
) DeleteObject(hbm
);
1097 if(memdc
) DeleteDC(memdc
);
1102 /**********************************************************************
1103 * DrawState32A() (USER32.162)
1105 BOOL WINAPI
DrawStateA(HDC hdc
, HBRUSH hbr
,
1106 DRAWSTATEPROC func
, LPARAM ldata
, WPARAM wdata
,
1107 INT x
, INT y
, INT cx
, INT cy
, UINT flags
)
1109 return PAINTING_DrawState(hdc
, hbr
, func
, ldata
, wdata
, x
, y
, cx
, cy
, flags
, FALSE
, TRUE
);
1112 /**********************************************************************
1113 * DrawState32W() (USER32.163)
1115 BOOL WINAPI
DrawStateW(HDC hdc
, HBRUSH hbr
,
1116 DRAWSTATEPROC func
, LPARAM ldata
, WPARAM wdata
,
1117 INT x
, INT y
, INT cx
, INT cy
, UINT flags
)
1119 return PAINTING_DrawState(hdc
, hbr
, func
, ldata
, wdata
, x
, y
, cx
, cy
, flags
, TRUE
, TRUE
);
1122 /**********************************************************************
1123 * DrawState16() (USER.449)
1125 BOOL16 WINAPI
DrawState16(HDC16 hdc
, HBRUSH16 hbr
,
1126 DRAWSTATEPROC16 func
, LPARAM ldata
, WPARAM16 wdata
,
1127 INT16 x
, INT16 y
, INT16 cx
, INT16 cy
, UINT16 flags
)
1129 return PAINTING_DrawState(hdc
, hbr
, (DRAWSTATEPROC
)func
, ldata
, wdata
, x
, y
, cx
, cy
, flags
, FALSE
, FALSE
);
1133 /******************************************************************************
1134 * PolyBezier16 [GDI.502]
1136 BOOL16 WINAPI
PolyBezier16( HDC16 hDc
, const POINT16
* lppt
, INT16 cPoints
)
1140 LPPOINT pt32
= (LPPOINT
)HeapAlloc( GetProcessHeap(), 0,
1141 cPoints
*sizeof(POINT
) );
1142 if(!pt32
) return FALSE
;
1143 for (i
=cPoints
;i
--;) CONV_POINT16TO32(&(lppt
[i
]),&(pt32
[i
]));
1144 ret
= PolyBezier(hDc
, pt32
, cPoints
);
1145 HeapFree( GetProcessHeap(), 0, pt32
);
1149 /******************************************************************************
1150 * PolyBezierTo16 [GDI.503]
1152 BOOL16 WINAPI
PolyBezierTo16( HDC16 hDc
, const POINT16
* lppt
, INT16 cPoints
)
1156 LPPOINT pt32
= (LPPOINT
)HeapAlloc( GetProcessHeap(), 0,
1157 cPoints
*sizeof(POINT
) );
1158 if(!pt32
) return FALSE
;
1159 for (i
=cPoints
;i
--;) CONV_POINT16TO32(&(lppt
[i
]),&(pt32
[i
]));
1160 ret
= PolyBezierTo(hDc
, pt32
, cPoints
);
1161 HeapFree( GetProcessHeap(), 0, pt32
);
1165 /******************************************************************************
1166 * PolyBezier32 [GDI32.268]
1167 * Draws one or more Bezier curves
1170 * hDc [I] Handle to device context
1171 * lppt [I] Pointer to endpoints and control points
1172 * cPoints [I] Count of endpoints and control points
1176 BOOL WINAPI
PolyBezier( HDC hdc
, const POINT
* lppt
, DWORD cPoints
)
1178 DC
* dc
= DC_GetDCPtr( hdc
);
1179 if(!dc
) return FALSE
;
1180 if(dc
&& PATH_IsPathOpen(dc
->w
.path
))
1181 FIXME(gdi
, "PATH_PolyBezier is not implemented!\n");
1182 /* if(!PATH_PolyBezier(hdc, x, y))
1184 return dc
->funcs
->pPolyBezier
&&
1185 dc
->funcs
->pPolyBezier(dc
, lppt
[0], lppt
+1, cPoints
-1);
1188 /******************************************************************************
1189 * PolyBezierTo32 [GDI32.269]
1190 * Draws one or more Bezier curves
1193 * hDc [I] Handle to device context
1194 * lppt [I] Pointer to endpoints and control points
1195 * cPoints [I] Count of endpoints and control points
1199 BOOL WINAPI
PolyBezierTo( HDC hdc
, const POINT
* lppt
, DWORD cPoints
)
1201 DC
* dc
= DC_GetDCPtr( hdc
);
1204 if(!dc
) return FALSE
;
1205 pt
.x
=dc
->w
.CursPosX
;
1206 pt
.y
=dc
->w
.CursPosY
;
1207 if(dc
&& PATH_IsPathOpen(dc
->w
.path
))
1208 FIXME(gdi
, "PATH_PolyBezierTo is not implemented!\n");
1209 /* if(!PATH_PolyBezier(hdc, x, y))
1211 ret
= dc
->funcs
->pPolyBezier
&&
1212 dc
->funcs
->pPolyBezier(dc
, pt
, lppt
, cPoints
);
1213 if( dc
->funcs
->pMoveToEx
)
1214 dc
->funcs
->pMoveToEx(dc
,lppt
[cPoints
].x
,lppt
[cPoints
].y
,&pt
);
1218 /***************************************************************
1219 * AngleArc (GDI32.5)
1222 BOOL WINAPI
AngleArc(HDC hdc
, INT x
, INT y
, DWORD dwRadius
,
1223 FLOAT eStartAngle
, FLOAT eSweepAngle
)
1225 FIXME(gdi
,"AngleArc, stub\n");
1229 /***************************************************************
1230 * PolyDraw (GDI32.270)
1233 BOOL WINAPI
PolyDraw(HDC hdc
, const POINT
*lppt
, const BYTE
*lpbTypes
,
1236 FIXME(gdi
,"PolyDraw, stub\n");