summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
authorMichael Natterer <mitch@imendio.com>2007-06-07 22:26:27 +0000
committerMichael Natterer <mitch@src.gnome.org>2007-06-07 22:26:27 +0000
commit6c3637ea3eff2447db609722160ee5e1c110176f (patch)
treeae3306e587cc82852d6cc3be722435b6d6ecd516 /gdk
parentdde0d5ffa5335ae7e12ae8103ad89d90bfda6601 (diff)
downloadgtk+-6c3637ea3eff2447db609722160ee5e1c110176f.tar.gz
add utility function gdk_quartz_fix_cap_not_last_line() which fixes the
2007-06-08 Michael Natterer <mitch@imendio.com> * gdk/quartz/gdkdrawable-quartz.c: add utility function gdk_quartz_fix_cap_not_last_line() which fixes the coordinates for GDK_CAP_NOT_LAST lines at least for horizontal and vertical lines. (gdk_quartz_draw_segments) (gdk_quartz_draw_lines): use it here. svn path=/trunk/; revision=18080
Diffstat (limited to 'gdk')
-rw-r--r--gdk/quartz/gdkdrawable-quartz.c58
1 files changed, 54 insertions, 4 deletions
diff --git a/gdk/quartz/gdkdrawable-quartz.c b/gdk/quartz/gdkdrawable-quartz.c
index 113bee4d67..30ac909782 100644
--- a/gdk/quartz/gdkdrawable-quartz.c
+++ b/gdk/quartz/gdkdrawable-quartz.c
@@ -366,6 +366,33 @@ gdk_quartz_draw_points (GdkDrawable *drawable,
gdk_quartz_drawable_release_context (drawable, context);
}
+static inline void
+gdk_quartz_fix_cap_not_last_line (GdkGCQuartz *private,
+ gint x1,
+ gint y1,
+ gint x2,
+ gint y2,
+ gint *xfix,
+ gint *yfix)
+{
+ *xfix = 0;
+ *yfix = 0;
+
+ if (private->cap_style == GDK_CAP_NOT_LAST && private->line_width == 0)
+ {
+ /* fix only vertical and horizontal lines for now */
+
+ if (y1 == y2 && x1 != x2)
+ {
+ *xfix = (x1 < x2) ? -1 : 1;
+ }
+ else if (x1 == x2 && y1 != y2)
+ {
+ *yfix = (y1 < y2) ? -1 : 1;
+ }
+ }
+}
+
static void
gdk_quartz_draw_segments (GdkDrawable *drawable,
GdkGC *gc,
@@ -373,18 +400,28 @@ gdk_quartz_draw_segments (GdkDrawable *drawable,
gint nsegs)
{
CGContextRef context = gdk_quartz_drawable_get_context (drawable, FALSE);
+ GdkGCQuartz *private;
int i;
if (!context)
return;
+ private = GDK_GC_QUARTZ (gc);
+
_gdk_quartz_gc_update_cg_context (gc, drawable, context,
GDK_QUARTZ_CONTEXT_STROKE);
for (i = 0; i < nsegs; i++)
{
+ gint xfix, yfix;
+
+ gdk_quartz_fix_cap_not_last_line (private,
+ segs[i].x1, segs[i].y1,
+ segs[i].x2, segs[i].y2,
+ &xfix, &yfix);
+
CGContextMoveToPoint (context, segs[i].x1 + 0.5, segs[i].y1 + 0.5);
- CGContextAddLineToPoint (context, segs[i].x2 + 0.5, segs[i].y2 + 0.5);
+ CGContextAddLineToPoint (context, segs[i].x2 + 0.5 + xfix, segs[i].y2 + 0.5 + yfix);
}
CGContextStrokePath (context);
@@ -399,19 +436,32 @@ gdk_quartz_draw_lines (GdkDrawable *drawable,
gint npoints)
{
CGContextRef context = gdk_quartz_drawable_get_context (drawable, FALSE);
- int i;
+ GdkGCQuartz *private;
+ gint xfix, yfix;
+ gint i;
if (!context)
return;
+ private = GDK_GC_QUARTZ (gc);
+
_gdk_quartz_gc_update_cg_context (gc, drawable, context,
- GDK_QUARTZ_CONTEXT_STROKE);
+ GDK_QUARTZ_CONTEXT_STROKE);
CGContextMoveToPoint (context, points[0].x + 0.5, points[0].y + 0.5);
- for (i = 1; i < npoints; i++)
+ for (i = 1; i < npoints - 1; i++)
CGContextAddLineToPoint (context, points[i].x + 0.5, points[i].y + 0.5);
+ gdk_quartz_fix_cap_not_last_line (private,
+ points[npoints - 2].x, points[npoints - 2].y,
+ points[npoints - 1].x, points[npoints - 1].y,
+ &xfix, &yfix);
+
+ CGContextAddLineToPoint (context,
+ points[npoints - 1].x + 0.5 + xfix,
+ points[npoints - 1].y + 0.5 + yfix);
+
CGContextStrokePath (context);
gdk_quartz_drawable_release_context (drawable, context);