01: /*
02: * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
03: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04: *
05: * This code is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU General Public License version 2 only, as
07: * published by the Free Software Foundation. Sun designates this
08: * particular file as subject to the "Classpath" exception as provided
09: * by Sun in the LICENSE file that accompanied this code.
10: *
11: * This code is distributed in the hope that it will be useful, but WITHOUT
12: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14: * version 2 for more details (a copy is included in the LICENSE file that
15: * accompanied this code).
16: *
17: * You should have received a copy of the GNU General Public License version
18: * 2 along with this work; if not, write to the Free Software Foundation,
19: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20: *
21: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22: * CA 95054 USA or visit www.sun.com if you need additional information or
23: * have any questions.
24: */
25:
26: package sun.awt.motif;
27:
28: import sun.awt.X11CustomCursor;
29: import sun.awt.CustomCursor;
30: import java.awt.*;
31: import java.awt.image.*;
32: import sun.awt.image.ImageRepresentation;
33:
34: public class MCustomCursor extends X11CustomCursor {
35:
36: public MCustomCursor(Image cursor, Point hotSpot, String name)
37: throws IndexOutOfBoundsException {
38: super (cursor, hotSpot, name);
39: }
40:
41: /**
42: * Returns the supported cursor size
43: */
44: public static Dimension getBestCursorSize(int preferredWidth,
45: int preferredHeight) {
46:
47: // Fix for bug 4212593 The Toolkit.createCustomCursor does not
48: // check absence of the image of cursor
49: // We use XQueryBestCursor which accepts unsigned ints to obtain
50: // the largest cursor size that could be dislpayed
51: Dimension d = new Dimension(Math.abs(preferredWidth), Math
52: .abs(preferredHeight));
53:
54: queryBestCursor(d);
55: return d;
56: }
57:
58: private static native void queryBestCursor(Dimension d);
59:
60: protected native void createCursor(byte[] xorMask, byte[] andMask,
61: int width, int height, int fcolor, int bcolor,
62: int xHotSpot, int yHotSpot);
63:
64: static {
65: cacheInit();
66: }
67:
68: private native static void cacheInit();
69: }
|