diff options
author | Silenio Quarti | 2007-11-14 22:03:09 +0000 |
---|---|---|
committer | Silenio Quarti | 2007-11-14 22:03:09 +0000 |
commit | a9afe83d993a7a93cb73d1cdb7a438e98f41e693 (patch) | |
tree | 50e54ea6523a0873c8f218103a392e593da369e2 | |
parent | 5db1d5db50ceaffc858895ba3a91a314130898a3 (diff) | |
download | eclipse.platform.swt-a9afe83d993a7a93cb73d1cdb7a438e98f41e693.tar.gz eclipse.platform.swt-a9afe83d993a7a93cb73d1cdb7a438e98f41e693.tar.xz eclipse.platform.swt-a9afe83d993a7a93cb73d1cdb7a438e98f41e693.zip |
*** empty log message ***
8 files changed, 79 insertions, 138 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_custom.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_custom.c index 27ff4fb8d5..b65ae7af9a 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_custom.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_custom.c @@ -128,6 +128,28 @@ fail: } #endif +#ifndef NO_objc_1msgSend_1struct__Lorg_eclipse_swt_internal_cocoa_NSRange_2IILorg_eclipse_swt_internal_cocoa_NSRange_2I +static SEL glyphRangeForCharacterRange; +JNIEXPORT void JNICALL OS_NATIVE(objc_1msgSend_1struct__Lorg_eclipse_swt_internal_cocoa_NSRange_2IILorg_eclipse_swt_internal_cocoa_NSRange_2I) + (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2, jobject arg3, jint arg4) +{ + NSRange _arg0, *lparg0=NULL; + NSRange _arg3, *lparg3=NULL; + OS_NATIVE_ENTER(env, that, objc_1msgSend_1struct__Lorg_eclipse_swt_internal_cocoa_NSRange_2IILorg_eclipse_swt_internal_cocoa_NSRange_2I_FUNC); + if (arg0) if ((lparg0 = getNSRangeFields(env, arg0, &_arg0)) == NULL) goto fail; + if (arg3) if ((lparg3 = getNSRangeFields(env, arg3, &_arg3)) == NULL) goto fail; + //objc_msgSend_struct(lparg0, arg1, arg2, lparg3, arg4); + if (glyphRangeForCharacterRange == 0) glyphRangeForCharacterRange = sel_registerName("glyphRangeForCharacterRange:actualCharacterRange::"); + if ((SEL)arg2 == glyphRangeForCharacterRange) { + *lparg0 = [(id)arg1 glyphRangeForCharacterRange: *lparg3 actualCharacterRange: arg4]; + } +fail: + if (arg3 && lparg3) setNSRangeFields(env, arg3, lparg3); + if (arg0 && lparg0) setNSRangeFields(env, arg0, lparg0); + OS_NATIVE_EXIT(env, that, objc_1msgSend_1struct__Lorg_eclipse_swt_internal_cocoa_NSRange_2IILorg_eclipse_swt_internal_cocoa_NSRange_2I_FUNC); +} +#endif + #ifndef NO_objc_1msgSend_1struct__Lorg_eclipse_swt_internal_cocoa_NSSize_2IILorg_eclipse_swt_internal_cocoa_NSSize_2ZZI static SEL frameSizeForContentSize; JNIEXPORT void JNICALL OS_NATIVE(objc_1msgSend_1struct__Lorg_eclipse_swt_internal_cocoa_NSSize_2IILorg_eclipse_swt_internal_cocoa_NSSize_2ZZI) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c index 6a31e32a05..13fcb79b4b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c @@ -14,8 +14,8 @@ #ifdef NATIVE_STATS -int OS_nativeFunctionCount = 312; -int OS_nativeFunctionCallCount[312]; +int OS_nativeFunctionCount = 313; +int OS_nativeFunctionCallCount[313]; char * OS_nativeFunctionNames[] = { "CGWarpMouseCursorPosition", "CloseRgn", @@ -322,6 +322,7 @@ char * OS_nativeFunctionNames[] = { "objc_1msgSend_1struct__Lorg_eclipse_swt_internal_cocoa_NSRange_2II", "objc_1msgSend_1struct__Lorg_eclipse_swt_internal_cocoa_NSRange_2III", "objc_1msgSend_1struct__Lorg_eclipse_swt_internal_cocoa_NSRange_2IILorg_eclipse_swt_internal_cocoa_NSRange_2", + "objc_1msgSend_1struct__Lorg_eclipse_swt_internal_cocoa_NSRange_2IILorg_eclipse_swt_internal_cocoa_NSRange_2I", "objc_1msgSend_1struct__Lorg_eclipse_swt_internal_cocoa_NSSize_2II", "objc_1msgSend_1struct__Lorg_eclipse_swt_internal_cocoa_NSSize_2IILorg_eclipse_swt_internal_cocoa_NSSize_2ZZI", "objc_1registerClassPair", diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h index d88d3effd0..d53e442b60 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h @@ -330,6 +330,7 @@ typedef enum { objc_1msgSend_1struct__Lorg_eclipse_swt_internal_cocoa_NSRange_2II_FUNC, objc_1msgSend_1struct__Lorg_eclipse_swt_internal_cocoa_NSRange_2III_FUNC, objc_1msgSend_1struct__Lorg_eclipse_swt_internal_cocoa_NSRange_2IILorg_eclipse_swt_internal_cocoa_NSRange_2_FUNC, + objc_1msgSend_1struct__Lorg_eclipse_swt_internal_cocoa_NSRange_2IILorg_eclipse_swt_internal_cocoa_NSRange_2I_FUNC, objc_1msgSend_1struct__Lorg_eclipse_swt_internal_cocoa_NSSize_2II_FUNC, objc_1msgSend_1struct__Lorg_eclipse_swt_internal_cocoa_NSSize_2IILorg_eclipse_swt_internal_cocoa_NSSize_2ZZI_FUNC, objc_1registerClassPair_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSLayoutManager.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSLayoutManager.java index dfcc2e660c..b5828b83bd 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSLayoutManager.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSLayoutManager.java @@ -227,7 +227,7 @@ public NSRange glyphRangeForBoundingRectWithoutAdditionalLayout(NSRect bounds, N public NSRange glyphRangeForCharacterRange(NSRange charRange, int actualCharRange) { NSRange result = new NSRange(); - OS.objc_msgSend_stret(result, this.id, OS.sel_glyphRangeForCharacterRange_1actualCharacterRange_1, charRange, actualCharRange); + OS.objc_msgSend_struct(result, this.id, OS.sel_glyphRangeForCharacterRange_1actualCharacterRange_1, charRange, actualCharRange); return result; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java index c8d74de6c6..2b799aff9f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java @@ -79,6 +79,7 @@ public static final native int objc_msgSend(int id, int sel, char[] arg0, NSRang public static final native int objc_msgSend(int id, int sel, String arg0); public static final native int objc_msgSend_struct(NSSize result, int object, int selector); +public static final native void objc_msgSend_struct(NSRange result, int id, int sel, NSRange arg0, int arg1); public static final native void objc_msgSend_struct(NSSize result, int id, int sel, NSSize arg0, boolean arg1, boolean arg2, int arg3); public static final native int objc_msgSend_struct(NSPoint result, int object, int selector); public static final native int objc_msgSend_struct(NSPoint result, int object, int selector, int arg0); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java index c721364fc2..93a9d7996d 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java @@ -987,7 +987,7 @@ public void drawPath(Path path) { handle.saveGraphicsState(); NSAffineTransform transform = NSAffineTransform.transform(); transform.translateXBy(data.drawXOffset, data.drawYOffset); - transform.set(); + transform.concat(); NSBezierPath drawPath = data.path; drawPath.appendBezierPath(path.handle); drawPath.stroke(); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Path.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Path.java index a986fbfa65..2129d4326a 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Path.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Path.java @@ -109,20 +109,17 @@ public Path (Device device) { */ public void addArc(float x, float y, float width, float height, float startAngle, float arcAngle) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); -// float[] cmt = new float[6]; -// OS.CGAffineTransformMake(width / 2f, 0, 0, height / 2f, x + width / 2f, y + height / 2f, cmt); -// if (arcAngle < 0) { -// float angle = -(startAngle + arcAngle) * (float)Compatibility.PI / 180; -// if (closed) OS.CGPathMoveToPoint(handle, cmt, (float)Math.cos(angle), (float)Math.sin(angle)); -// OS.CGPathAddArc(handle, cmt, 0, 0, 1, angle, -startAngle * (float)Compatibility.PI / 180, true); -// } else { -// float angle = -startAngle * (float)Compatibility.PI / 180; -// if (closed) OS.CGPathMoveToPoint(handle, cmt, (float)Math.cos(angle), (float)Math.sin(angle)); -// OS.CGPathAddArc(handle, cmt, 0, 0, 1, angle, -(startAngle + arcAngle) * (float)Compatibility.PI / 180, true); -// } -// moved = true; -// closed = false; -// if (Math.abs(arcAngle) >= 360) close(); + NSAffineTransform transform = NSAffineTransform.transform(); + transform.translateXBy(x + width / 2f, y + height / 2f); + transform.scaleXBy(width / 2f, height / 2f); + NSBezierPath path = NSBezierPath.bezierPath(); + if (arcAngle < 0) { + path.appendBezierPathWithArcWithCenter_radius_startAngle_endAngle_(new NSPoint(), 1, -(startAngle + arcAngle) * (float)Compatibility.PI / 180, -startAngle * (float)Compatibility.PI / 180); + } else { + path.appendBezierPathWithArcWithCenter_radius_startAngle_endAngle_(new NSPoint(), 1, -startAngle * (float)Compatibility.PI / 180, -(startAngle + arcAngle) * (float)Compatibility.PI / 180); + } + path.transformUsingAffineTransform(transform); + handle.appendBezierPath(path); } /** @@ -188,76 +185,38 @@ public void addString(String string, float x, float y, Font font) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (font == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); -// int length = string.length(); -// if (length == 0) return; -// moved = false; -// closed = true; -// -// Callback newPathCallback = new Callback(this, "newPathProc", 1); -// int newPathProc = newPathCallback.getAddress(); -// if (newPathProc == 0) SWT.error(SWT.ERROR_NO_MORE_CALLBACKS); -// Callback lineCallback = new Callback(this, "lineProc", 3); -// int lineProc = lineCallback.getAddress(); -// if (lineProc == 0) SWT.error(SWT.ERROR_NO_MORE_CALLBACKS); -// Callback curveCallback = new Callback(this, "curveProc", 4); -// int curveProc = curveCallback.getAddress(); -// if (curveProc == 0) SWT.error(SWT.ERROR_NO_MORE_CALLBACKS); -// Callback closePathCallback = new Callback(this, "closePathProc", 1); -// int closePathProc = closePathCallback.getAddress(); -// if (closePathProc == 0) SWT.error(SWT.ERROR_NO_MORE_CALLBACKS); -// -// int style = font.atsuiStyle; -// if (style == 0) style = font.createStyle(); -// if (style == 0) SWT.error(SWT.ERROR_NO_HANDLES); -// int[] buffer = new int[1]; -// OS.ATSUCreateTextLayout(buffer); -// if (buffer[0] == 0) SWT.error(SWT.ERROR_NO_HANDLES); -// int layout = buffer[0]; -// char[] chars = new char[length]; -// string.getChars(0, length, chars, 0); -// int textPtr = OS.NewPtr(length * 2); -// if (textPtr == 0) SWT.error(SWT.ERROR_NO_HANDLES); -// OS.memmove(textPtr, chars, length * 2); -// OS.ATSUSetTextPointerLocation(layout, textPtr, 0, length, length); -// OS.ATSUSetRunStyle(layout, style, 0, length); -// OS.ATSUSetTransientFontMatching(layout, true); -// int[] ascent = new int[1], descent = new int[1]; -// OS.ATSUGetUnjustifiedBounds(layout, 0, length, null, null, ascent, descent); -// y += OS.Fix2X(ascent[0]); -// -// int[] layoutRecords = new int[1], numRecords = new int[1], deltaYs = new int[1], numDeltaYs = new int[1]; -// OS.ATSUDirectGetLayoutDataArrayPtrFromTextLayout (layout, 0, OS.kATSUDirectDataLayoutRecordATSLayoutRecordCurrent, layoutRecords, numRecords); -// OS.ATSUDirectGetLayoutDataArrayPtrFromTextLayout (layout, 0, OS.kATSUDirectDataBaselineDeltaFixedArray, deltaYs, numDeltaYs); -// int[] deltaY = new int[1], status = new int[1]; -// ATSLayoutRecord record = new ATSLayoutRecord(); -// for (int i = 0; i < numRecords[0]; i++) { -// OS.memmove(record, layoutRecords[0] + (i * ATSLayoutRecord.sizeof), ATSLayoutRecord.sizeof); -// originX = x + (float)OS.Fix2X(record.realPos); -// if (deltaYs[0] == 0) { -// originY = y; -// } else { -// OS.memmove(deltaY, deltaYs[0] + (i * 4), 4); -// originY = y - (float)OS.Fix2X(deltaY[0]); -// } -// first = true; -// if (record.glyphID != OS.kATSDeletedGlyphcode) { -// OS.ATSUGlyphGetQuadraticPaths (style, record.glyphID, newPathProc, lineProc, curveProc, closePathProc, 0, status); -// } -// } -// OS.CGPathCloseSubpath(handle); -// if (deltaYs[0] != 0) { -// OS.ATSUDirectReleaseLayoutDataArrayPtr(0, OS.kATSUDirectDataBaselineDeltaFixedArray, deltaYs[0]); -// } -// OS.ATSUDirectReleaseLayoutDataArrayPtr(0, OS.kATSUDirectDataLayoutRecordATSLayoutRecordCurrent, layoutRecords[0]); -// -// if (style != font.atsuiStyle) OS.ATSUDisposeStyle(style); -// if (layout != 0) OS.ATSUDisposeTextLayout(layout); -// if (textPtr != 0) OS.DisposePtr(textPtr); -// -// newPathCallback.dispose(); -// lineCallback.dispose(); -// curveCallback.dispose(); -// closePathCallback.dispose(); + NSString str = NSString.stringWith(string); + NSTextStorage textStorage = ((NSTextStorage)new NSTextStorage().alloc()); + textStorage.initWithString_(str); + NSLayoutManager layoutManager = (NSLayoutManager)new NSLayoutManager().alloc().init(); + NSTextContainer textContainer = (NSTextContainer)new NSTextContainer().alloc(); + NSSize size = new NSSize(); + size.width = Float.MAX_VALUE; + size.height = Float.MAX_VALUE; + textContainer.initWithContainerSize(size); + textStorage.addLayoutManager(layoutManager); + layoutManager.addTextContainer(textContainer); + NSRange range = new NSRange(); + range.length = str.length(); + textStorage.beginEditing(); + textStorage.addAttribute(OS.NSFontAttributeName(), font.handle, range); + textStorage.endEditing(); + range = layoutManager.glyphRangeForTextContainer(textContainer); + if (range.length != 0) { + int glyphs = OS.malloc(4 * range.length * 2); + layoutManager.getGlyphs(glyphs, range); + NSBezierPath path = NSBezierPath.bezierPath(); + NSPoint point = new NSPoint(); + point.x = x; + point.y = y; + path.moveToPoint(point); + path.appendBezierPathWithGlyphs(glyphs, range.length, font.handle); + OS.free(glyphs); + handle.appendBezierPath(path); + } + textContainer.release(); + layoutManager.release(); + textStorage.release(); } /** @@ -301,49 +260,12 @@ 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); -// //TODO - see windows -// int pixel = OS.NewPtr(4); -// if (pixel == 0) SWT.error(SWT.ERROR_NO_HANDLES); -// int[] buffer = new int[]{0xFFFFFFFF}; -// OS.memmove(pixel, buffer, 4); -// int context = OS.CGBitmapContextCreate(pixel, 1, 1, 8, 4, device.colorspace, OS.kCGImageAlphaNoneSkipFirst); -// if (context == 0) { -// OS.DisposePtr(pixel); -// SWT.error(SWT.ERROR_NO_HANDLES); -// } -// GCData data = gc.data; -// int capStyle = 0; -// switch (data.lineCap) { -// case SWT.CAP_ROUND: capStyle = OS.kCGLineCapRound; break; -// case SWT.CAP_FLAT: capStyle = OS.kCGLineCapButt; break; -// case SWT.CAP_SQUARE: capStyle = OS.kCGLineCapSquare; break; -// } -// OS.CGContextSetLineCap(context, capStyle); -// int joinStyle = 0; -// switch (data.lineJoin) { -// case SWT.JOIN_MITER: joinStyle = OS.kCGLineJoinMiter; break; -// case SWT.JOIN_ROUND: joinStyle = OS.kCGLineJoinRound; break; -// case SWT.JOIN_BEVEL: joinStyle = OS.kCGLineJoinBevel; break; -// } -// OS.CGContextSetLineJoin(context, joinStyle); -// OS.CGContextSetLineWidth(context, data.lineWidth); -// OS.CGContextTranslateCTM(context, -x + 0.5f, -y + 0.5f); -// OS.CGContextAddPath(context, handle); -// if (outline) { -// OS.CGContextStrokePath(context); -// } else { -// if (data.fillRule == SWT.FILL_WINDING) { -// OS.CGContextFillPath(context); -// } else { -// OS.CGContextEOFillPath(context); -// } -// } -// OS.CGContextRelease(context); -// OS.memmove(buffer, pixel, 4); -// OS.DisposePtr(pixel); -// return buffer[0] != 0xFFFFFFFF; - return false; +// gc.checkGC(GC.LINE_CAP | GC.LINE_JOIN | GC.LINE_STYLE | GC.LINE_WIDTH); + //TODO outline + NSPoint point = new NSPoint(); + point.x = x; + point.y = y; + return handle.containsPoint(point); } /** @@ -479,7 +401,7 @@ public PathData getPathData() { OS.memmove(pt, points + NSPoint.sizeof, NSPoint.sizeof); pointArray[pointCount++] = (int)pt.x; pointArray[pointCount++] = (int)pt.y; - OS.memmove(pt, points + NSPoint.sizeof, NSPoint.sizeof); + OS.memmove(pt, points + NSPoint.sizeof + NSPoint.sizeof, NSPoint.sizeof); pointArray[pointCount++] = (int)pt.x; pointArray[pointCount++] = (int)pt.y; break; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java index 6cc8895b57..d36ffb8206 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java @@ -344,7 +344,6 @@ public Point computeSize (int wHint, int hHint, boolean changed) { // gc.dispose (); // width += getInsetWidth (column_id, true); } -// if ((style & SWT.CHECK) != 0) width += getCheckColumnWidth (); } else { width = wHint; } @@ -540,7 +539,6 @@ void createWidget () { super.createWidget (); items = new TreeItem [4]; columns = new TreeColumn [4]; -// itemHeight = -1; } Color defaultBackground () { @@ -2263,8 +2261,4 @@ public void showSelection () { if (selection.length > 0) showItem (selection [0], true); } -int trackingProc (int browser, int id, int property, int theRect, int startPt, int modifiers) { - return 1; -} - } |