diff options
author | Felipe Heidrich <fheidric> | 2007-03-15 21:32:34 +0000 |
---|---|---|
committer | Felipe Heidrich <fheidric> | 2007-03-15 21:32:34 +0000 |
commit | 9b08189f8ee7e189cc76f5fea12f3ad05eb7e51b (patch) | |
tree | e43613c3a034a4c5f37343ed782fba5b18c07f19 | |
parent | bd64112265c2a125577ef5db8ecfbdb762c0aeab (diff) | |
download | eclipse.platform.swt-9b08189f8ee7e189cc76f5fea12f3ad05eb7e51b.tar.gz eclipse.platform.swt-9b08189f8ee7e189cc76f5fea12f3ad05eb7e51b.tar.xz eclipse.platform.swt-9b08189f8ee7e189cc76f5fea12f3ad05eb7e51b.zip |
LineAttributes
8 files changed, 136 insertions, 19 deletions
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.wpf.OS.properties b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.wpf.OS.properties index d09770f0b6..586c429222 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.wpf.OS.properties +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.wpf.OS.properties @@ -2011,6 +2011,10 @@ OS_Pen_LineJoin=flags=setter OS_Pen_LineJoin_0=cast=(Pen^),flags=gcobject OS_Pen_LineJoin_1=cast=(PenLineJoin) +OS_Pen_MiterLimit=flags=setter +OS_Pen_MiterLimit_0=cast=(Pen^),flags=gcobject +OS_Pen_MiterLimit_1= + OS_Pen_StartLineCap=flags=setter OS_Pen_StartLineCap_0=cast=(Pen^),flags=gcobject OS_Pen_StartLineCap_1=cast=(PenLineCap) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/library/os.cpp b/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/library/os.cpp index 64142bbbf3..8a12733c85 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/library/os.cpp +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/library/os.cpp @@ -7262,6 +7262,17 @@ JNIEXPORT void JNICALL OS_NATIVE(Pen_1LineJoin) } #endif +#ifndef NO_Pen_1MiterLimit +extern "C" JNIEXPORT void JNICALL OS_NATIVE(Pen_1MiterLimit)(JNIEnv *env, jclass that, jint arg0, jdouble arg1); +JNIEXPORT void JNICALL OS_NATIVE(Pen_1MiterLimit) + (JNIEnv *env, jclass that, jint arg0, jdouble arg1) +{ + OS_NATIVE_ENTER(env, that, Pen_1MiterLimit_FUNC); + ((Pen^)TO_OBJECT(arg0))->MiterLimit = (arg1); + OS_NATIVE_EXIT(env, that, Pen_1MiterLimit_FUNC); +} +#endif + #ifndef NO_Pen_1StartLineCap extern "C" JNIEXPORT void JNICALL OS_NATIVE(Pen_1StartLineCap)(JNIEnv *env, jclass that, jint arg0, jint arg1); JNIEXPORT void JNICALL OS_NATIVE(Pen_1StartLineCap) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/library/os_stats.cpp b/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/library/os_stats.cpp index 6c5d3f0e4f..b3d803fd8b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/library/os_stats.cpp +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/library/os_stats.cpp @@ -14,8 +14,8 @@ #ifdef NATIVE_STATS -int OS_nativeFunctionCount = 1218; -int OS_nativeFunctionCallCount[1218]; +int OS_nativeFunctionCount = 1219; +int OS_nativeFunctionCallCount[1219]; char * OS_nativeFunctionNames[] = { "AccessText_1AccessKey", "AccessText_1Text", @@ -609,6 +609,7 @@ char * OS_nativeFunctionNames[] = { "Pen_1DashStyle", "Pen_1EndLineCap", "Pen_1LineJoin", + "Pen_1MiterLimit", "Pen_1StartLineCap", "Pen_1Thickness", "PixelFormat_1BitsPerPixel", diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/library/os_stats.h index 2bd42e373c..c192888f74 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/library/os_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/library/os_stats.h @@ -617,6 +617,7 @@ typedef enum { Pen_1DashStyle_FUNC, Pen_1EndLineCap_FUNC, Pen_1LineJoin_FUNC, + Pen_1MiterLimit_FUNC, Pen_1StartLineCap_FUNC, Pen_1Thickness_FUNC, PixelFormat_1BitsPerPixel_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/org/eclipse/swt/internal/wpf/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/org/eclipse/swt/internal/wpf/OS.java index 20646cd80e..cebe0b822f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/org/eclipse/swt/internal/wpf/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/wpf/org/eclipse/swt/internal/wpf/OS.java @@ -1013,6 +1013,7 @@ public static final native void Pen_DashStyle(int sender, int value); public static final native void Pen_EndLineCap(int sender, int value); public static final native void Pen_StartLineCap(int sender, int value); public static final native void Pen_LineJoin(int sender, int value); +public static final native void Pen_MiterLimit(int sender, double value); public static final native void Pen_Thickness(int sender, double value); public static final native int PixelFormat_BitsPerPixel(int sender); public static final native int PixelFormats_Bgr101010(); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/graphics/GC.java index 37be456fb0..5896ac58e5 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/graphics/GC.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/graphics/GC.java @@ -67,9 +67,10 @@ public final class GC extends Resource { static final int LINE_WIDTH = 1 << 4; static final int LINE_CAP = 1 << 5; static final int LINE_JOIN = 1 << 6; - static final int ALPHA = 1 << 7; - static final int CLIPPING = 1 << 8; - static final int TRANSFORM = 1 << 9; + static final int LINE_MITERLIMIT = 1 << 7; + static final int ALPHA = 1 << 8; + static final int CLIPPING = 1 << 9; + static final int TRANSFORM = 1 << 10; static final int DRAW = FOREGROUND | LINE_STYLE | LINE_WIDTH | LINE_CAP | LINE_JOIN | ALPHA | CLIPPING | TRANSFORM; static final int FILL = BACKGROUND | ALPHA | CLIPPING | TRANSFORM; @@ -160,7 +161,7 @@ void checkGC(int mask) { if ((state & mask) == mask) return; state = (state ^ mask) & mask; data.state |= mask; - if ((state & (FOREGROUND | LINE_WIDTH | LINE_STYLE | LINE_JOIN | LINE_CAP)) != 0) { + if ((state & (FOREGROUND | LINE_WIDTH | LINE_STYLE | LINE_JOIN | LINE_CAP | LINE_MITERLIMIT)) != 0) { int pen = data.pen; if (pen != 0) OS.GCHandle_Free(pen); pen = data.pen = OS.gcnew_Pen(); @@ -175,8 +176,8 @@ void checkGC(int mask) { } OS.Pen_Brush(pen, brush); if (pattern == null) OS.GCHandle_Free(brush); - int width = data.lineWidth; - OS.Pen_Thickness(pen, Math.max (1, width)); + float width = data.lineWidth; + OS.Pen_Thickness(pen, width); double[] dashes = null; int dashStyle = 0; switch (data.lineStyle) { @@ -203,7 +204,7 @@ void checkGC(int mask) { for (int i = 0; i < dashes.length; i++) { OS.DoubleCollection_Add(list, dashes[i]); } - dashStyle = OS.gcnew_DashStyle(list, 0); + dashStyle = OS.gcnew_DashStyle(list, data.lineDashesOffset); OS.GCHandle_Free(list); } OS.Pen_DashStyle(pen, dashStyle); @@ -224,6 +225,7 @@ void checkGC(int mask) { OS.Pen_DashCap(pen, capStyle); OS.Pen_EndLineCap(pen, capStyle); OS.Pen_StartLineCap(pen, capStyle); + OS.Pen_MiterLimit(pen, data.lineMiterLimit); } if ((state & BACKGROUND) != 0) { if (data.brush != 0) OS.GCHandle_Free(data.brush); @@ -1833,8 +1835,13 @@ public int getInterpolation() { * @since 3.3 */ public LineAttributes getLineAttributes() { - //TODO - return null; + if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); + float[] dashes = null; + if (data.lineDashes != null) { + dashes = new float[data.lineDashes.length]; + System.arraycopy(data.lineDashes, 0, dashes, 0, dashes.length); + } + return new LineAttributes(data.lineWidth, data.lineCap, data.lineJoin, data.lineStyle, dashes, data.lineDashesOffset, data.lineMiterLimit); } /** @@ -1924,7 +1931,7 @@ public int getLineStyle() { */ public int getLineWidth() { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - return data.lineWidth; + return (int)data.lineWidth; } /** @@ -2499,7 +2506,95 @@ public void setInterpolation(int interpolation) { * @since 3.3 */ public void setLineAttributes(LineAttributes attributes) { - //TODO + if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); + if (attributes == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + int mask = 0; + float lineWidth = attributes.width; + if (lineWidth != data.lineWidth) { + mask |= LINE_WIDTH; + } + int lineStyle = attributes.style; + if (lineStyle != data.lineStyle) { + mask |= LINE_STYLE; + switch (lineStyle) { + case SWT.LINE_SOLID: + case SWT.LINE_DASH: + case SWT.LINE_DOT: + case SWT.LINE_DASHDOT: + case SWT.LINE_DASHDOTDOT: + break; + case SWT.LINE_CUSTOM: + if (attributes.dash == null) lineStyle = SWT.LINE_SOLID; + break; + default: + SWT.error(SWT.ERROR_INVALID_ARGUMENT); + } + } + int join = attributes.join; + if (join != data.lineJoin) { + mask |= LINE_JOIN; + switch (join) { + case SWT.CAP_ROUND: + case SWT.CAP_FLAT: + case SWT.CAP_SQUARE: + break; + default: + SWT.error(SWT.ERROR_INVALID_ARGUMENT); + } + } + int cap = attributes.join; + if (cap != data.lineCap) { + mask |= LINE_CAP; + switch (cap) { + case SWT.JOIN_MITER: + case SWT.JOIN_ROUND: + case SWT.JOIN_BEVEL: + break; + default: + SWT.error(SWT.ERROR_INVALID_ARGUMENT); + } + } + float[] dashes = attributes.dash; + float[] lineDashes = data.lineDashes; + if (dashes != null && dashes.length > 0) { + boolean changed = lineDashes == null || lineDashes.length != dashes.length; + for (int i = 0; i < dashes.length; i++) { + float dash = dashes[i]; + if (dash <= 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); + if (!changed && lineDashes[i] != dash) changed = true; + } + if (changed) { + float[] newDashes = new float[dashes.length]; + System.arraycopy(dashes, 0, newDashes, 0, dashes.length); + dashes = newDashes; + mask |= LINE_STYLE; + } else { + dashes = lineDashes; + } + } else { + if (lineDashes != null && lineDashes.length > 0) { + mask |= LINE_STYLE; + } else { + dashes = lineDashes; + } + } + float dashOffset = attributes.dashOffset; + if (dashOffset != data.lineDashesOffset) { + mask |= LINE_STYLE; + } + float miterLimit = attributes.miterLimit; + if (miterLimit != data.lineMiterLimit) { + mask |= LINE_MITERLIMIT; + } + if (mask == 0) return; + data.lineWidth = lineWidth; + data.lineStyle = lineStyle; + data.lineCap = cap; + data.lineJoin = join; + data.lineDashes = dashes; + data.lineDashesOffset = dashOffset; + data.lineMiterLimit = miterLimit; + data.state &= ~mask; } /** @@ -2552,7 +2647,7 @@ public void setLineCap(int cap) { */ public void setLineDash(int[] dashes) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - int[] lineDashes = data.lineDashes; + float[] lineDashes = data.lineDashes; if (dashes != null && dashes.length > 0) { boolean changed = data.lineStyle != SWT.LINE_CUSTOM || lineDashes == null || lineDashes.length != dashes.length; for (int i = 0; i < dashes.length; i++) { @@ -2561,8 +2656,10 @@ public void setLineDash(int[] dashes) { if (!changed && lineDashes[i] != dash) changed = true; } if (!changed) return; - data.lineDashes = new int[dashes.length]; - System.arraycopy(dashes, 0, data.lineDashes, 0, dashes.length); + data.lineDashes = new float[dashes.length]; + for (int i = 0; i < dashes.length; i++) { + data.lineDashes[i] = dashes[i]; + } data.lineStyle = SWT.LINE_CUSTOM; } else { if (data.lineStyle == SWT.LINE_SOLID && (lineDashes == null || lineDashes.length == 0)) return; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/graphics/GCData.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/graphics/GCData.java index 866b4d20d2..745200bbda 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/graphics/GCData.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/graphics/GCData.java @@ -38,10 +38,12 @@ public final class GCData { public int antialias = SWT.DEFAULT; public int textAntialias = SWT.DEFAULT; public int lineStyle = SWT.LINE_SOLID; - public int lineWidth; + public float lineWidth; public int lineCap = SWT.CAP_FLAT; public int lineJoin = SWT.JOIN_MITER; - public int[] lineDashes; + public float lineDashesOffset; + public float[] lineDashes; + public float lineMiterLimit = 10; public int alpha = 0xFF; public Image image; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/graphics/Path.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/graphics/Path.java index 2daa39d940..6b21644adc 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/graphics/Path.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/graphics/Path.java @@ -302,7 +302,7 @@ public boolean contains(float x, float y, GC gc, boolean outline) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (gc == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (gc.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - gc.checkGC(GC.LINE_CAP | GC.LINE_JOIN | GC.LINE_STYLE | GC.LINE_WIDTH | GC.TRANSFORM); + gc.checkGC(GC.LINE_CAP | GC.LINE_JOIN | GC.LINE_STYLE | GC.LINE_WIDTH | GC.LINE_MITERLIMIT | GC.TRANSFORM); boolean result; int point = OS.gcnew_Point(x, y); if (outline) { |