1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
33 #define G_PI 3.14159265358979323846
36 #include "gdkdrawable.h"
37 #include "gdkprivate.h"
38 #include "gdkwindow.h"
41 static void gdk_win32_drawable_destroy (GdkDrawable *drawable);
43 static void gdk_win32_draw_rectangle (GdkDrawable *drawable,
50 static void gdk_win32_draw_arc (GdkDrawable *drawable,
59 static void gdk_win32_draw_polygon (GdkDrawable *drawable,
64 static void gdk_win32_draw_text (GdkDrawable *drawable,
71 static void gdk_win32_draw_text_wc (GdkDrawable *drawable,
78 static void gdk_win32_draw_drawable (GdkDrawable *drawable,
87 static void gdk_win32_draw_points (GdkDrawable *drawable,
91 static void gdk_win32_draw_segments (GdkDrawable *drawable,
95 static void gdk_win32_draw_lines (GdkDrawable *drawable,
100 GdkDrawableClass _gdk_win32_drawable_class = {
101 gdk_win32_drawable_destroy,
103 gdk_win32_draw_rectangle,
105 gdk_win32_draw_polygon,
107 gdk_win32_draw_text_wc,
108 gdk_win32_draw_drawable,
109 gdk_win32_draw_points,
110 gdk_win32_draw_segments,
114 /*****************************************************
115 * Win32 specific implementations of generic functions *
116 *****************************************************/
119 gdk_drawable_get_colormap (GdkDrawable *drawable)
121 GdkDrawablePrivate *drawable_private;
123 g_return_val_if_fail (drawable != NULL, NULL);
124 drawable_private = (GdkDrawablePrivate*) drawable;
126 if (!GDK_DRAWABLE_DESTROYED (drawable))
128 if (drawable_private->colormap == NULL)
129 return gdk_colormap_get_system (); /* XXX ??? */
131 return drawable_private->colormap;
138 gdk_drawable_set_colormap (GdkDrawable *drawable,
139 GdkColormap *colormap)
141 GdkDrawablePrivate *drawable_private;
142 GdkColormapPrivateWin32 *colormap_private;
144 g_return_if_fail (drawable != NULL);
145 g_return_if_fail (colormap != NULL);
147 drawable_private = (GdkDrawablePrivate *) drawable;
148 colormap_private = (GdkColormapPrivateWin32 *) colormap;
150 if (!GDK_DRAWABLE_DESTROYED (drawable))
152 if (GDK_IS_WINDOW (drawable))
154 g_return_if_fail (colormap_private->base.visual !=
155 ((GdkColormapPrivate *) (drawable_private->colormap))->visual);
157 GDK_NOTE (MISC, g_print ("gdk_drawable_set_colormap: %#x %#x\n",
158 GDK_DRAWABLE_XID (drawable),
159 colormap_private->xcolormap));
161 if (drawable_private->colormap)
162 gdk_colormap_unref (drawable_private->colormap);
163 drawable_private->colormap = colormap;
164 gdk_colormap_ref (drawable_private->colormap);
166 if (GDK_IS_WINDOW (drawable)
167 && drawable_private->window_type != GDK_WINDOW_TOPLEVEL)
168 gdk_window_add_colormap_windows (drawable);
175 gdk_win32_drawable_destroy (GdkDrawable *drawable)
181 gdk_win32_draw_rectangle (GdkDrawable *drawable,
189 GdkGCPrivate *gc_private = (GdkGCPrivate*) gc;
190 GdkGCWin32Data *gc_data = GDK_GC_WIN32DATA (gc_private);
192 HGDIOBJ oldpen, oldbrush;
197 GDK_NOTE (MISC, g_print ("gdk_win32_draw_rectangle: %#x (%d) %s%dx%d@+%d+%d\n",
198 GDK_DRAWABLE_XID (drawable),
200 (filled ? "fill " : ""),
201 width, height, x, y));
203 hdc = gdk_gc_predraw (drawable, gc_private,
204 GDK_GC_FOREGROUND|GDK_GC_BACKGROUND);
208 HBRUSH hbr = GetCurrentObject (hdc, OBJ_BRUSH);
209 HPEN hpen = GetCurrentObject (hdc, OBJ_PEN);
212 GetObject (hbr, sizeof (lbr), &lbr);
213 GetObject (hpen, sizeof (lpen), &lpen);
215 g_print ("current brush: style = %s, color = 0x%.08x\n",
216 (lbr.lbStyle == BS_SOLID ? "SOLID" : "???"),
218 g_print ("current pen: style = %s, width = %d, color = 0x%.08x\n",
219 (lpen.lopnStyle == PS_SOLID ? "SOLID" : "???"),
225 if (gc_data->fill_style == GDK_OPAQUE_STIPPLED)
227 if (!BeginPath (hdc))
228 WIN32_API_FAILED ("BeginPath"), ok = FALSE;
230 /* Win9x doesn't support Rectangle calls in a path,
236 pts[1].x = x + width + 1;
238 pts[2].x = x + width + 1;
239 pts[2].y = y + height + 1;
241 pts[3].y = y + height + 1;
244 MoveToEx (hdc, x, y, NULL);
246 if (ok && !Polyline (hdc, pts, 4))
247 WIN32_API_FAILED ("Polyline"), ok = FALSE;
249 if (ok && !CloseFigure (hdc))
250 WIN32_API_FAILED ("CloseFigure"), ok = FALSE;
252 if (ok && !EndPath (hdc))
253 WIN32_API_FAILED ("EndPath"), ok = FALSE;
256 if (!WidenPath (hdc))
257 WIN32_API_FAILED ("WidenPath"), ok = FALSE;
259 if (ok && !FillPath (hdc))
260 WIN32_API_FAILED ("FillPath"), ok = FALSE;
263 if (!DeleteObject (hbr))
264 WIN32_API_FAILED ("DeleteObject");
269 oldpen = SelectObject (hdc, GetStockObject (NULL_PEN));
271 oldbrush = SelectObject (hdc, GetStockObject (HOLLOW_BRUSH));
273 if (!Rectangle (hdc, x, y, x+width+1, y+height+1))
274 WIN32_API_FAILED ("Rectangle");
277 SelectObject (hdc, oldpen);
279 SelectObject (hdc, oldbrush);
282 gdk_gc_postdraw (drawable, gc_private, GDK_GC_FOREGROUND|GDK_GC_BACKGROUND);
286 gdk_win32_draw_arc (GdkDrawable *drawable,
296 GdkGCPrivate *gc_private;
298 int nXStartArc, nYStartArc, nXEndArc, nYEndArc;
300 gc_private = (GdkGCPrivate*) gc;
302 GDK_NOTE (MISC, g_print ("gdk_draw_arc: %#x %d,%d,%d,%d %d %d\n",
303 GDK_DRAWABLE_XID (drawable),
304 x, y, width, height, angle1, angle2));
306 if (width != 0 && height != 0 && angle2 != 0)
308 hdc = gdk_gc_predraw (drawable, gc_private,
309 GDK_GC_FOREGROUND|GDK_GC_BACKGROUND);
311 if (angle2 >= 360*64)
313 nXStartArc = nYStartArc = nXEndArc = nYEndArc = 0;
317 /* The 100. is just an arbitrary value */
318 nXStartArc = x + width/2 + 100. * cos(angle1/64.*2.*G_PI/360.);
319 nYStartArc = y + height/2 + -100. * sin(angle1/64.*2.*G_PI/360.);
320 nXEndArc = x + width/2 + 100. * cos((angle1+angle2)/64.*2.*G_PI/360.);
321 nYEndArc = y + height/2 + -100. * sin((angle1+angle2)/64.*2.*G_PI/360.);
325 nXEndArc = x + width/2 + 100. * cos(angle1/64.*2.*G_PI/360.);
326 nYEndArc = y + height/2 + -100. * sin(angle1/64.*2.*G_PI/360.);
327 nXStartArc = x + width/2 + 100. * cos((angle1+angle2)/64.*2.*G_PI/360.);
328 nYStartArc = y + height/2 + -100. * sin((angle1+angle2)/64.*2.*G_PI/360.);
331 /* GDK_OPAQUE_STIPPLED arcs not implemented. */
335 GDK_NOTE (MISC, g_print ("...Pie(hdc,%d,%d,%d,%d,%d,%d,%d,%d)\n",
336 x, y, x+width, y+height,
337 nXStartArc, nYStartArc,
338 nXEndArc, nYEndArc));
339 Pie (hdc, x, y, x+width, y+height,
340 nXStartArc, nYStartArc, nXEndArc, nYEndArc);
344 GDK_NOTE (MISC, g_print ("...Arc(hdc,%d,%d,%d,%d,%d,%d,%d,%d)\n",
345 x, y, x+width, y+height,
346 nXStartArc, nYStartArc,
347 nXEndArc, nYEndArc));
348 Arc (hdc, x, y, x+width, y+height,
349 nXStartArc, nYStartArc, nXEndArc, nYEndArc);
351 gdk_gc_postdraw (drawable, gc_private,
352 GDK_GC_FOREGROUND|GDK_GC_BACKGROUND);
357 gdk_win32_draw_polygon (GdkDrawable *drawable,
363 GdkGCPrivate *gc_private = (GdkGCPrivate*) gc;
364 GdkGCWin32Data *gc_data = GDK_GC_WIN32DATA (gc_private);
371 GDK_NOTE (MISC, g_print ("gdk_win32_draw_polygon: %#x (%d) %d\n",
372 GDK_DRAWABLE_XID (drawable), gc_private,
378 hdc = gdk_gc_predraw (drawable, gc_private,
379 GDK_GC_FOREGROUND|GDK_GC_BACKGROUND);
380 pts = g_new (POINT, npoints+1);
382 for (i = 0; i < npoints; i++)
384 pts[i].x = points[i].x;
385 pts[i].y = points[i].y;
388 if (gc_data->fill_style == GDK_OPAQUE_STIPPLED)
390 if (!BeginPath (hdc))
391 WIN32_API_FAILED ("BeginPath"), ok = FALSE;
393 MoveToEx (hdc, points[0].x, points[0].y, NULL);
395 if (pts[0].x == pts[npoints-1].x && pts[0].y == pts[npoints-1].y)
398 if (ok && !Polyline (hdc, pts, 4))
399 WIN32_API_FAILED ("Polyline"), ok = FALSE;
401 if (ok && !CloseFigure (hdc))
402 WIN32_API_FAILED ("CloseFigure"), ok = FALSE;
404 if (ok && !EndPath (hdc))
405 WIN32_API_FAILED ("EndPath"), ok = FALSE;
408 if (!WidenPath (hdc))
409 WIN32_API_FAILED ("WidenPath"), ok = FALSE;
411 if (ok && !FillPath (hdc))
412 WIN32_API_FAILED ("FillPath"), ok = FALSE;
415 if (!DeleteObject (hbr))
416 WIN32_API_FAILED ("DeleteObject");
420 if (points[0].x != points[npoints-1].x
421 || points[0].y != points[npoints-1].y)
423 pts[npoints].x = points[0].x;
424 pts[npoints].y = points[0].y;
430 if (!Polygon (hdc, pts, npoints))
431 WIN32_API_FAILED ("Polygon");
435 if (!Polyline (hdc, pts, npoints))
436 WIN32_API_FAILED ("Polyline");
440 gdk_gc_postdraw (drawable, gc_private, GDK_GC_FOREGROUND|GDK_GC_BACKGROUND);
450 gdk_draw_text_handler (GdkWin32SingleFont *singlefont,
451 const wchar_t *wcstr,
457 gdk_draw_text_arg *argp = (gdk_draw_text_arg *) arg;
462 if ((oldfont = SelectObject (argp->hdc, singlefont->xfont)) == NULL)
464 WIN32_API_FAILED ("SelectObject");
468 if (!TextOutW (argp->hdc, argp->x, argp->y, wcstr, wclen))
469 WIN32_API_FAILED ("TextOutW");
470 GetTextExtentPoint32W (argp->hdc, wcstr, wclen, &size);
473 SelectObject (argp->hdc, oldfont);
477 gdk_win32_draw_text (GdkDrawable *drawable,
485 GdkGCPrivate *gc_private;
488 gdk_draw_text_arg arg;
491 if (GDK_DRAWABLE_DESTROYED (drawable))
494 if (text_length == 0)
497 g_assert (font->type == GDK_FONT_FONT || font->type == GDK_FONT_FONTSET);
499 gc_private = (GdkGCPrivate*) gc;
503 arg.hdc = gdk_gc_predraw (drawable, gc_private,
504 GDK_GC_FOREGROUND|GDK_GC_FONT);
506 GDK_NOTE (MISC, g_print ("gdk_draw_text: %#x (%d,%d) \"%.*s\" (len %d)\n",
507 GDK_DRAWABLE_XID (drawable),
509 (text_length > 10 ? 10 : text_length),
512 wcstr = g_new (wchar_t, text_length);
513 if ((wlen = gdk_nmbstowchar_ts (wcstr, text, text_length, text_length)) == -1)
514 g_warning ("gdk_draw_text: gdk_nmbstowchar_ts failed");
516 gdk_wchar_text_handle (font, wcstr, wlen,
517 gdk_draw_text_handler, &arg);
521 gdk_gc_postdraw (drawable, gc_private, GDK_GC_FOREGROUND|GDK_GC_FONT);
525 gdk_win32_draw_text_wc (GdkDrawable *drawable,
530 const GdkWChar *text,
533 GdkGCPrivate *gc_private;
536 gdk_draw_text_arg arg;
539 if (GDK_DRAWABLE_DESTROYED (drawable))
542 if (text_length == 0)
545 g_assert (font->type == GDK_FONT_FONT || font->type == GDK_FONT_FONTSET);
547 gc_private = (GdkGCPrivate*) gc;
551 arg.hdc = gdk_gc_predraw (drawable, gc_private,
552 GDK_GC_FOREGROUND|GDK_GC_FONT);
554 GDK_NOTE (MISC, g_print ("gdk_draw_text_wc: %#x (%d,%d) len: %d\n",
555 GDK_DRAWABLE_XID (drawable),
558 if (sizeof (wchar_t) != sizeof (GdkWChar))
560 wcstr = g_new (wchar_t, text_length);
561 for (i = 0; i < text_length; i++)
565 wcstr = (wchar_t *) text;
567 gdk_wchar_text_handle (font, wcstr, text_length,
568 gdk_draw_text_handler, &arg);
570 if (sizeof (wchar_t) != sizeof (GdkWChar))
573 gdk_gc_postdraw (drawable, gc_private, GDK_GC_FOREGROUND|GDK_GC_FONT);
577 gdk_win32_draw_drawable (GdkDrawable *drawable,
587 GdkDrawablePrivate *src_private;
588 GdkGCPrivate *gc_private;
592 HRGN src_rgn, draw_rgn, outside_rgn;
595 src_private = (GdkDrawablePrivate*) src;
596 gc_private = (GdkGCPrivate*) gc;
598 GDK_NOTE (MISC, g_print ("gdk_draw_pixmap: dest: %#x "
599 "src: %#x %dx%d@+%d+%d"
600 " dest: %#x @+%d+%d\n",
601 GDK_DRAWABLE_XID (drawable),
602 GDK_DRAWABLE_XID (src),
603 width, height, xsrc, ysrc,
604 GDK_DRAWABLE_XID (drawable), xdest, ydest));
606 hdc = gdk_gc_predraw (drawable, gc_private, 0);
608 src_rgn = CreateRectRgn (0, 0, src_private->width + 1, src_private->height + 1);
609 draw_rgn = CreateRectRgn (xsrc, ysrc, xsrc + width + 1, ysrc + height + 1);
611 outside_rgn = CreateRectRgnIndirect (&r);
613 if (GDK_DRAWABLE_TYPE (drawable) != GDK_DRAWABLE_PIXMAP)
615 /* If we are drawing on a window, calculate the region that is
616 * outside the source pixmap, and invalidate that, causing it to
619 if (CombineRgn (outside_rgn, draw_rgn, src_rgn, RGN_DIFF) != NULLREGION)
621 OffsetRgn (outside_rgn, xdest, ydest);
622 GDK_NOTE (MISC, (GetRgnBox (outside_rgn, &r),
623 g_print ("...calling InvalidateRgn, "
624 "bbox: %dx%d@+%d+%d\n",
625 r.right - r.left - 1, r.bottom - r.top - 1,
627 InvalidateRgn (GDK_DRAWABLE_XID (drawable), outside_rgn, TRUE);
631 #if 1 /* Don't know if this is necessary */
632 if (CombineRgn (draw_rgn, draw_rgn, src_rgn, RGN_AND) == COMPLEXREGION)
633 g_warning ("gdk_draw_pixmap: CombineRgn returned a COMPLEXREGION");
635 GetRgnBox (draw_rgn, &r);
638 || r.right != xsrc + width + 1
639 || r.bottom != ysrc + height + 1)
641 xdest += r.left - xsrc;
643 ydest += r.top - ysrc;
645 width = r.right - xsrc - 1;
646 height = r.bottom - ysrc - 1;
648 GDK_NOTE (MISC, g_print ("... restricted to src: %dx%d@+%d+%d, "
650 width, height, xsrc, ysrc,
655 DeleteObject (src_rgn);
656 DeleteObject (draw_rgn);
657 DeleteObject (outside_rgn);
659 /* Strangely enough, this function is called also to bitblt
662 if (src_private->window_type == GDK_DRAWABLE_PIXMAP)
664 if ((srcdc = CreateCompatibleDC (hdc)) == NULL)
665 WIN32_API_FAILED ("CreateCompatibleDC");
667 if ((hgdiobj = SelectObject (srcdc, GDK_DRAWABLE_XID (src))) == NULL)
668 WIN32_API_FAILED ("SelectObject #1");
670 if (!BitBlt (hdc, xdest, ydest, width, height,
671 srcdc, xsrc, ysrc, SRCCOPY))
672 WIN32_API_FAILED ("BitBlt");
674 if ((SelectObject (srcdc, hgdiobj) == NULL))
675 WIN32_API_FAILED ("SelectObject #2");
677 if (!DeleteDC (srcdc))
678 WIN32_API_FAILED ("DeleteDC");
682 if (GDK_DRAWABLE_XID(drawable) == GDK_DRAWABLE_XID (src))
684 /* Blitting inside a window, use ScrollDC */
685 RECT scrollRect, clipRect, emptyRect;
688 scrollRect.left = MIN (xsrc, xdest);
689 scrollRect.top = MIN (ysrc, ydest);
690 scrollRect.right = MAX (xsrc + width + 1, xdest + width + 1);
691 scrollRect.bottom = MAX (ysrc + height + 1, ydest + height + 1);
693 clipRect.left = xdest;
694 clipRect.top = ydest;
695 clipRect.right = xdest + width + 1;
696 clipRect.bottom = ydest + height + 1;
698 SetRectEmpty (&emptyRect);
699 updateRgn = CreateRectRgnIndirect (&emptyRect);
700 if (!ScrollDC (hdc, xdest - xsrc, ydest - ysrc,
701 &scrollRect, &clipRect,
703 WIN32_API_FAILED ("ScrollDC");
704 if (!InvalidateRgn (GDK_DRAWABLE_XID (drawable), updateRgn, FALSE))
705 WIN32_API_FAILED ("InvalidateRgn");
706 if (!UpdateWindow (GDK_DRAWABLE_XID (drawable)))
707 WIN32_API_FAILED ("UpdateWindow");
711 if ((srcdc = GetDC (GDK_DRAWABLE_XID (src))) == NULL)
712 WIN32_API_FAILED ("GetDC");
714 if (!BitBlt (hdc, xdest, ydest, width, height,
715 srcdc, xsrc, ysrc, SRCCOPY))
716 WIN32_API_FAILED ("BitBlt");
717 ReleaseDC (GDK_DRAWABLE_XID (src), srcdc);
720 gdk_gc_postdraw (drawable, gc_private, 0);
724 gdk_win32_draw_points (GdkDrawable *drawable,
731 GdkGCPrivate *gc_private = (GdkGCPrivate*) gc;
732 GdkGCWin32Data *gc_data = GDK_GC_WIN32DATA (gc_private);
733 GdkDrawablePrivate *drawable_private = (GdkDrawablePrivate *) drawable;
734 GdkColormapPrivateWin32 *colormap_private =
735 (GdkColormapPrivateWin32 *) drawable_private->colormap;
738 hdc = gdk_gc_predraw (drawable, gc_private, 0);
740 fg = gdk_colormap_color (colormap_private, gc_data->foreground);
742 GDK_NOTE (MISC, g_print ("gdk_draw_points: %#x %dx%.06x\n",
743 GDK_DRAWABLE_XID (drawable), npoints, fg));
745 for (i = 0; i < npoints; i++)
746 SetPixel (hdc, points[i].x, points[i].y, fg);
748 gdk_gc_postdraw (drawable, gc_private, 0);
752 gdk_win32_draw_segments (GdkDrawable *drawable,
757 GdkGCPrivate *gc_private = (GdkGCPrivate*) gc;
758 GdkGCWin32Data *gc_data = GDK_GC_WIN32DATA (gc_private);
764 GDK_NOTE (MISC, g_print ("gdk_win32_draw_segments: %#x destdc: (%d) %#x "
766 GDK_DRAWABLE_XID (drawable),
770 hdc = gdk_gc_predraw (drawable, gc_private,
771 GDK_GC_FOREGROUND|GDK_GC_BACKGROUND);
773 if (gc_data->fill_style == GDK_OPAQUE_STIPPLED)
775 if (!BeginPath (hdc))
776 WIN32_API_FAILED ("BeginPath"), ok = FALSE;
778 for (i = 0; i < nsegs; i++)
780 if (ok && !MoveToEx (hdc, segs[i].x1, segs[i].y1, NULL))
781 WIN32_API_FAILED ("MoveToEx"), ok = FALSE;
782 if (ok && !LineTo (hdc, segs[i].x2, segs[i].y2))
783 WIN32_API_FAILED ("LineTo #1"), ok = FALSE;
786 if (ok && gc_data->pen_width == 1)
787 if (!LineTo (hdc, segs[i].x2 + 1, segs[i].y2))
788 WIN32_API_FAILED ("LineTo #2"), ok = FALSE;
791 if (ok && !EndPath (hdc))
792 WIN32_API_FAILED ("EndPath"), ok = FALSE;
794 if (ok && !WidenPath (hdc))
795 WIN32_API_FAILED ("WidenPath"), ok = FALSE;
797 if (ok && !FillPath (hdc))
798 WIN32_API_FAILED ("FillPath"), ok = FALSE;
801 if (!DeleteObject (hbr))
802 WIN32_API_FAILED ("DeleteObject");
806 for (i = 0; i < nsegs; i++)
808 if (!MoveToEx (hdc, segs[i].x1, segs[i].y1, NULL))
809 WIN32_API_FAILED ("MoveToEx");
810 if (!LineTo (hdc, segs[i].x2, segs[i].y2))
811 WIN32_API_FAILED ("LineTo #1");
814 if (gc_data->pen_width == 1)
815 if (!LineTo (hdc, segs[i].x2 + 1, segs[i].y2))
816 WIN32_API_FAILED ("LineTo #2");
819 gdk_gc_postdraw (drawable, gc_private, GDK_GC_FOREGROUND|GDK_GC_BACKGROUND);
823 gdk_win32_draw_lines (GdkDrawable *drawable,
828 GdkGCPrivate *gc_private = (GdkGCPrivate*) gc;
829 GdkGCWin32Data *gc_data = GDK_GC_WIN32DATA (gc_private);
837 hdc = gdk_gc_predraw (drawable, gc_private,
838 GDK_GC_FOREGROUND|GDK_GC_BACKGROUND);
840 pts = g_new (POINT, npoints);
842 for (i = 0; i < npoints; i++)
844 pts[i].x = points[i].x;
845 pts[i].y = points[i].y;
848 if (!Polyline (hdc, pts, npoints))
849 WIN32_API_FAILED ("Polyline");
854 if (gc_data->pen_width == 1)
856 MoveToEx (hdc, points[npoints-1].x, points[npoints-1].y, NULL);
857 if (!LineTo (hdc, points[npoints-1].x + 1, points[npoints-1].y))
858 WIN32_API_FAILED ("LineTo");
861 MoveToEx (hdc, points[0].x, points[0].y, NULL);
862 for (i = 1; i < npoints; i++)
863 if (!LineTo (hdc, points[i].x, points[i].y))
864 WIN32_API_FAILED ("LineTo #1");
867 /* LineTo doesn't draw the last point, so if we have a pen width of 1,
868 * we draw the end pixel separately... With wider pens we don't care.
869 * //HB: But the NT developers don't read their API documentation ...
871 if (gc_data->pen_width == 1 && windows_version > 0x80000000)
872 if (!LineTo (hdc, points[npoints-1].x + 1, points[npoints-1].y))
873 WIN32_API_FAILED ("LineTo #2");
875 gdk_gc_postdraw (drawable, gc_private, GDK_GC_FOREGROUND|GDK_GC_BACKGROUND);