diff options
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java | 4 | ||||
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Cursor.java | 65 |
2 files changed, 47 insertions, 22 deletions
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 338419fb4b..02cbb61513 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 @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Karsten Thoms <karsten.thoms@itemis.de> - Bug 522349 *******************************************************************************/ package org.eclipse.swt.internal.cocoa; @@ -132,6 +133,9 @@ public class OS extends C { public static final long /*int*/ sel_beginSheetModalForWindow_completionHandler_ = sel_registerName("beginSheetModalForWindow:completionHandler:"); + /** non-API selector for NSCursor **/ + public static final long /*int*/ sel_busyButClickableCursor = sel_registerName("busyButClickableCursor"); + /* These are not generated in order to avoid creating static methods on all classes */ public static final long /*int*/ sel_isSelectorExcludedFromWebScript_ = sel_registerName("isSelectorExcludedFromWebScript:"); public static final long /*int*/ sel_webScriptNameForSelector_ = sel_registerName("webScriptNameForSelector:"); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Cursor.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Cursor.java index 815ee8c812..949f076a36 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Cursor.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Cursor.java @@ -7,12 +7,13 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Karsten Thoms <karsten.thoms@itemis.de> - Bug 522349 *******************************************************************************/ package org.eclipse.swt.graphics; -import org.eclipse.swt.internal.cocoa.*; import org.eclipse.swt.*; +import org.eclipse.swt.internal.cocoa.*; /** * Instances of this class manage operating system resources that @@ -95,6 +96,22 @@ public final class Cursor extends Resource { */ public NSCursor handle; + /** + * Retrieves a handle for an animated waiting cursor. The used selector + * 'busyButClickableCursor' is not a public API, but yet existent. To be fail-safe + * it is checked that NSCursor responds to the selector. + * + * @return The cursor handle or <code>null</code> when NSCursor is not able to + * handle the 'busyButClickableCursor' selector. + */ + static NSCursor busyButClickableCursor() { + if (!new NSObject(OS.class_NSCursor).respondsToSelector(OS.sel_busyButClickableCursor)) { + return null; + } + long /*int*/ result = OS.objc_msgSend(OS.class_NSCursor, OS.sel_busyButClickableCursor); + return result != 0 ? new NSCursor(result) : null; + } + /** * Prevents uninitialized instances from being created outside the package. */ @@ -155,28 +172,32 @@ public Cursor(Device device, int style) { boolean shouldCreateCursor = false; try { switch (style) { - case SWT.CURSOR_HAND: handle = NSCursor.pointingHandCursor(); break; - case SWT.CURSOR_ARROW: handle = NSCursor.arrowCursor(); break; - case SWT.CURSOR_WAIT: shouldCreateCursor = true; break; - case SWT.CURSOR_CROSS: handle = NSCursor.crosshairCursor(); break; - case SWT.CURSOR_APPSTARTING: handle = NSCursor.arrowCursor(); break; - case SWT.CURSOR_HELP: handle = NSCursor.crosshairCursor(); break; - case SWT.CURSOR_SIZEALL: handle = NSCursor.crosshairCursor(); break; - case SWT.CURSOR_SIZENESW: handle = NSCursor.crosshairCursor(); break; + case SWT.CURSOR_HAND: handle = NSCursor.pointingHandCursor(); break; + case SWT.CURSOR_ARROW: handle = NSCursor.arrowCursor(); break; + case SWT.CURSOR_WAIT: { + handle = busyButClickableCursor(); + if (handle == null) shouldCreateCursor = true; // create when handle was not retrieved + break; + } + case SWT.CURSOR_CROSS: handle = NSCursor.crosshairCursor(); break; + case SWT.CURSOR_APPSTARTING: handle = NSCursor.arrowCursor(); break; + case SWT.CURSOR_HELP: handle = NSCursor.crosshairCursor(); break; + case SWT.CURSOR_SIZEALL: handle = NSCursor.crosshairCursor(); break; + case SWT.CURSOR_SIZENESW: handle = NSCursor.crosshairCursor(); break; case SWT.CURSOR_SIZENS: handle = NSCursor.resizeUpDownCursor(); break; - case SWT.CURSOR_SIZENWSE: handle = NSCursor.crosshairCursor(); break; - case SWT.CURSOR_SIZEWE: handle = NSCursor.resizeLeftRightCursor(); break; - case SWT.CURSOR_SIZEN: handle = NSCursor.resizeUpCursor(); break; - case SWT.CURSOR_SIZES: handle = NSCursor.resizeDownCursor(); break; - case SWT.CURSOR_SIZEE: handle = NSCursor.resizeRightCursor(); break; - case SWT.CURSOR_SIZEW: handle = NSCursor.resizeLeftCursor(); break; - case SWT.CURSOR_SIZENE: handle = NSCursor.crosshairCursor(); break; - case SWT.CURSOR_SIZESE: handle = NSCursor.crosshairCursor(); break; - case SWT.CURSOR_SIZESW: handle = NSCursor.crosshairCursor(); break; - case SWT.CURSOR_SIZENW: handle = NSCursor.crosshairCursor(); break; - case SWT.CURSOR_UPARROW: handle = NSCursor.crosshairCursor(); break; - case SWT.CURSOR_IBEAM: shouldCreateCursor = true; break; - case SWT.CURSOR_NO: handle = NSCursor.operationNotAllowedCursor(); break; + case SWT.CURSOR_SIZENWSE: handle = NSCursor.crosshairCursor(); break; + case SWT.CURSOR_SIZEWE: handle = NSCursor.resizeLeftRightCursor(); break; + case SWT.CURSOR_SIZEN: handle = NSCursor.resizeUpCursor(); break; + case SWT.CURSOR_SIZES: handle = NSCursor.resizeDownCursor(); break; + case SWT.CURSOR_SIZEE: handle = NSCursor.resizeRightCursor(); break; + case SWT.CURSOR_SIZEW: handle = NSCursor.resizeLeftCursor(); break; + case SWT.CURSOR_SIZENE: handle = NSCursor.crosshairCursor(); break; + case SWT.CURSOR_SIZESE: handle = NSCursor.crosshairCursor(); break; + case SWT.CURSOR_SIZESW: handle = NSCursor.crosshairCursor(); break; + case SWT.CURSOR_SIZENW: handle = NSCursor.crosshairCursor(); break; + case SWT.CURSOR_UPARROW: handle = NSCursor.crosshairCursor(); break; + case SWT.CURSOR_IBEAM: shouldCreateCursor = true; break; + case SWT.CURSOR_NO: handle = NSCursor.operationNotAllowedCursor(); break; default: SWT.error(SWT.ERROR_INVALID_ARGUMENT); } |