summaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-01-04 17:18:47 +0100
committerSven Gothel <[email protected]>2014-01-04 17:18:47 +0100
commitbec29cf970e6a55eb8f720afdae5a3bdc97c1ba2 (patch)
treeb94db19188923dc674b5a594de9cbed4c298fd9c /src/nativewindow/classes/jogamp
parentfcc0e7397bb6f3ceb1fe143667f8c59b5bf63874 (diff)
Bug 935: NEWT OSX PointerIcon/Pointer-Visibility: Impl. OffscreenLayerSurface (OSX CALayer) w/ JAWTWindow Path
Add setCursor(..) and hideCursor() to OffscreenLayerSurface interface, impl. in JAWTWindow w/ AWT. This allows an OSX NEWT Window using CALayer (i.e. NewtCanvasAWT) to have setPointerIcon(..) and setPointerVisible(..) functionality!
Diffstat (limited to 'src/nativewindow/classes/jogamp')
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java
index 0fa5006cc..31de84137 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java
@@ -27,21 +27,31 @@
*/
package jogamp.nativewindow.awt;
+import java.awt.Cursor;
import java.awt.FocusTraversalPolicy;
import java.awt.Insets;
+import java.awt.Point;
+import java.awt.Toolkit;
import java.awt.Window;
import java.awt.Component;
import java.awt.Container;
import java.awt.Frame;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.net.URLConnection;
+import java.util.HashMap;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JRootPane;
import javax.swing.WindowConstants;
+import javax.imageio.ImageIO;
import javax.media.nativewindow.NativeWindowException;
import javax.media.nativewindow.WindowClosingProtocol;
import javax.swing.MenuSelectionManager;
+import com.jogamp.common.util.IOUtil;
+
public class AWTMisc {
public static JFrame getJFrame(Component c) {
@@ -163,6 +173,33 @@ public class AWTMisc {
MenuSelectionManager.defaultManager().clearSelectedPath();
}
+ static final HashMap<String, Cursor> cursorMap = new HashMap<String, Cursor>();
+ static final Cursor nulCursor;
+ static {
+ final Toolkit toolkit = Toolkit.getDefaultToolkit();
+ BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR);
+ nulCursor = toolkit.createCustomCursor(img, new Point(0,0), "nullCursor");
+ }
+
+ public static synchronized Cursor getNullCursor() { return nulCursor; }
+
+ public static synchronized Cursor getCursor(IOUtil.ClassResources resources, Point hotSpot) throws IOException {
+ final String key = resources.getClass().getName()+":"+resources.resourcePaths[0];
+ Cursor cursor = cursorMap.get(key);
+ if( null == cursor ) {
+ cursor = createAWTCursor(resources, hotSpot);
+ cursorMap.put(key, cursor);
+ }
+ return cursor;
+ }
+ private static synchronized Cursor createAWTCursor(IOUtil.ClassResources resources, Point hotSpot) throws IOException {
+ final URLConnection urlConn = resources.resolve(0);
+ BufferedImage img = ImageIO.read(urlConn.getInputStream());
+
+ final Toolkit toolkit = Toolkit.getDefaultToolkit();
+ return toolkit.createCustomCursor(img, hotSpot, resources.resourcePaths[0]);
+ }
+
public static WindowClosingProtocol.WindowClosingMode AWT2NWClosingOperation(int awtClosingOperation) {
switch (awtClosingOperation) {
case WindowConstants.DISPOSE_ON_CLOSE: