| 1 | /* Copyright (C) 1999, 2000, 2002 Free Software Foundation
|
|---|
| 2 |
|
|---|
| 3 | This file is part of GNU Classpath.
|
|---|
| 4 |
|
|---|
| 5 | GNU Classpath is free software; you can redistribute it and/or modify
|
|---|
| 6 | it under the terms of the GNU General Public License as published by
|
|---|
| 7 | the Free Software Foundation; either version 2, or (at your option)
|
|---|
| 8 | any later version.
|
|---|
| 9 |
|
|---|
| 10 | GNU Classpath is distributed in the hope that it will be useful, but
|
|---|
| 11 | WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 13 | General Public License for more details.
|
|---|
| 14 |
|
|---|
| 15 | You should have received a copy of the GNU General Public License
|
|---|
| 16 | along with GNU Classpath; see the file COPYING. If not, write to the
|
|---|
| 17 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|---|
| 18 | 02111-1307 USA.
|
|---|
| 19 |
|
|---|
| 20 | Linking this library statically or dynamically with other modules is
|
|---|
| 21 | making a combined work based on this library. Thus, the terms and
|
|---|
| 22 | conditions of the GNU General Public License cover the whole
|
|---|
| 23 | combination.
|
|---|
| 24 |
|
|---|
| 25 | As a special exception, the copyright holders of this library give you
|
|---|
| 26 | permission to link this library with independent modules to produce an
|
|---|
| 27 | executable, regardless of the license terms of these independent
|
|---|
| 28 | modules, and to copy and distribute the resulting executable under
|
|---|
| 29 | terms of your choice, provided that you also meet, for each linked
|
|---|
| 30 | independent module, the terms and conditions of the license of that
|
|---|
| 31 | module. An independent module is a module which is not derived from
|
|---|
| 32 | or based on this library. If you modify this library, you may extend
|
|---|
| 33 | this exception to your version of the library, but you are not
|
|---|
| 34 | obligated to do so. If you do not wish to do so, delete this
|
|---|
| 35 | exception statement from your version. */
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 | package java.awt;
|
|---|
| 39 |
|
|---|
| 40 | /**
|
|---|
| 41 | * This class represents various predefined cursor types.
|
|---|
| 42 | *
|
|---|
| 43 | * @author Aaron M. Renn ([email protected])
|
|---|
| 44 | */
|
|---|
| 45 | public class Cursor implements java.io.Serializable
|
|---|
| 46 | {
|
|---|
| 47 | /**
|
|---|
| 48 | * Constant for the system default cursor type
|
|---|
| 49 | */
|
|---|
| 50 | public static final int DEFAULT_CURSOR = 0;
|
|---|
| 51 |
|
|---|
| 52 | /**
|
|---|
| 53 | * Constant for a cross-hair cursor.
|
|---|
| 54 | */
|
|---|
| 55 | public static final int CROSSHAIR_CURSOR = 1;
|
|---|
| 56 |
|
|---|
| 57 | /**
|
|---|
| 58 | * Constant for a cursor over a text field.
|
|---|
| 59 | */
|
|---|
| 60 | public static final int TEXT_CURSOR = 2;
|
|---|
| 61 |
|
|---|
| 62 | /**
|
|---|
| 63 | * Constant for a cursor to display while waiting for an action to complete.
|
|---|
| 64 | */
|
|---|
| 65 | public static final int WAIT_CURSOR = 3;
|
|---|
| 66 |
|
|---|
| 67 | /**
|
|---|
| 68 | * Cursor used over SW corner of window decorations.
|
|---|
| 69 | */
|
|---|
| 70 | public static final int SW_RESIZE_CURSOR = 4;
|
|---|
| 71 |
|
|---|
| 72 | /**
|
|---|
| 73 | * Cursor used over SE corner of window decorations.
|
|---|
| 74 | */
|
|---|
| 75 | public static final int SE_RESIZE_CURSOR = 5;
|
|---|
| 76 |
|
|---|
| 77 | /**
|
|---|
| 78 | * Cursor used over NW corner of window decorations.
|
|---|
| 79 | */
|
|---|
| 80 | public static final int NW_RESIZE_CURSOR = 6;
|
|---|
| 81 |
|
|---|
| 82 | /**
|
|---|
| 83 | * Cursor used over NE corner of window decorations.
|
|---|
| 84 | */
|
|---|
| 85 | public static final int NE_RESIZE_CURSOR = 7;
|
|---|
| 86 |
|
|---|
| 87 | /**
|
|---|
| 88 | * Cursor used over N edge of window decorations.
|
|---|
| 89 | */
|
|---|
| 90 | public static final int N_RESIZE_CURSOR = 8;
|
|---|
| 91 |
|
|---|
| 92 | /**
|
|---|
| 93 | * Cursor used over S edge of window decorations.
|
|---|
| 94 | */
|
|---|
| 95 | public static final int S_RESIZE_CURSOR = 9;
|
|---|
| 96 |
|
|---|
| 97 | /**
|
|---|
| 98 | * Cursor used over W edge of window decorations.
|
|---|
| 99 | */
|
|---|
| 100 | public static final int W_RESIZE_CURSOR = 10;
|
|---|
| 101 |
|
|---|
| 102 | /**
|
|---|
| 103 | * Cursor used over E edge of window decorations.
|
|---|
| 104 | */
|
|---|
| 105 | public static final int E_RESIZE_CURSOR = 11;
|
|---|
| 106 |
|
|---|
| 107 | /**
|
|---|
| 108 | * Constant for a hand cursor.
|
|---|
| 109 | */
|
|---|
| 110 | public static final int HAND_CURSOR = 12;
|
|---|
| 111 |
|
|---|
| 112 | /**
|
|---|
| 113 | * Constant for a cursor used during window move operations.
|
|---|
| 114 | */
|
|---|
| 115 | public static final int MOVE_CURSOR = 13;
|
|---|
| 116 |
|
|---|
| 117 | public static final int CUSTOM_CURSOR = 0xFFFFFFFF;
|
|---|
| 118 |
|
|---|
| 119 | private static final int PREDEFINED_COUNT = 14;
|
|---|
| 120 |
|
|---|
| 121 | protected static Cursor[] predefined = new Cursor[PREDEFINED_COUNT];
|
|---|
| 122 | protected String name;
|
|---|
| 123 |
|
|---|
| 124 | /**
|
|---|
| 125 | * @serial The numeric id of this cursor.
|
|---|
| 126 | */
|
|---|
| 127 | int type;
|
|---|
| 128 |
|
|---|
| 129 | /**
|
|---|
| 130 | * Initializes a new instance of <code>Cursor</code> with the specified
|
|---|
| 131 | * type.
|
|---|
| 132 | *
|
|---|
| 133 | * @param type The cursor type.
|
|---|
| 134 | */
|
|---|
| 135 | public Cursor(int type)
|
|---|
| 136 | {
|
|---|
| 137 | if (type < 0 || type >= PREDEFINED_COUNT)
|
|---|
| 138 | throw new IllegalArgumentException ("invalid cursor " + type);
|
|---|
| 139 | this.type = type;
|
|---|
| 140 | // FIXME: lookup and set name?
|
|---|
| 141 | }
|
|---|
| 142 |
|
|---|
| 143 | /** This constructor is used internally only.
|
|---|
| 144 | * Application code should call Toolkit.createCustomCursor().
|
|---|
| 145 | */
|
|---|
| 146 | protected Cursor(String name)
|
|---|
| 147 | {
|
|---|
| 148 | this.name = name;
|
|---|
| 149 | this.type = CUSTOM_CURSOR;
|
|---|
| 150 | }
|
|---|
| 151 |
|
|---|
| 152 | /**
|
|---|
| 153 | * Returns an instance of <code>Cursor</code> for one of the specified
|
|---|
| 154 | * predetermined types.
|
|---|
| 155 | *
|
|---|
| 156 | * @param type The type contant from this class.
|
|---|
| 157 | *
|
|---|
| 158 | * @return The requested predefined cursor.
|
|---|
| 159 | *
|
|---|
| 160 | * @exception IllegalArgumentException If the constant is not one of the
|
|---|
| 161 | * predefined cursor type constants from this class.
|
|---|
| 162 | */
|
|---|
| 163 | public static Cursor getPredefinedCursor(int type)
|
|---|
| 164 | {
|
|---|
| 165 | if (type < 0 || type >= PREDEFINED_COUNT)
|
|---|
| 166 | throw new IllegalArgumentException ("invalid cursor " + type);
|
|---|
| 167 | if (predefined[type] == null)
|
|---|
| 168 | predefined[type] = new Cursor(type);
|
|---|
| 169 | return predefined[type];
|
|---|
| 170 | }
|
|---|
| 171 |
|
|---|
| 172 | public static Cursor getSystemCustomCursor(String name)
|
|---|
| 173 | throws AWTException
|
|---|
| 174 | {
|
|---|
| 175 | // FIXME
|
|---|
| 176 | return null;
|
|---|
| 177 | }
|
|---|
| 178 |
|
|---|
| 179 | /**
|
|---|
| 180 | * Returns an instance of the system default cursor type.
|
|---|
| 181 | *
|
|---|
| 182 | * @return The system default cursor.
|
|---|
| 183 | */
|
|---|
| 184 | public static Cursor getDefaultCursor()
|
|---|
| 185 | {
|
|---|
| 186 | return getPredefinedCursor(DEFAULT_CURSOR);
|
|---|
| 187 | }
|
|---|
| 188 |
|
|---|
| 189 | /**
|
|---|
| 190 | * Returns the numeric type identifier for this cursor.
|
|---|
| 191 | *
|
|---|
| 192 | * @return The cursor id.
|
|---|
| 193 | */
|
|---|
| 194 | public int getType()
|
|---|
| 195 | {
|
|---|
| 196 | return type;
|
|---|
| 197 | }
|
|---|
| 198 |
|
|---|
| 199 | public String getName()
|
|---|
| 200 | {
|
|---|
| 201 | return name;
|
|---|
| 202 | }
|
|---|
| 203 |
|
|---|
| 204 | public String toString()
|
|---|
| 205 | {
|
|---|
| 206 | return (this.getClass() + "[" + getName() + "]");
|
|---|
| 207 | }
|
|---|
| 208 | }
|
|---|