2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libjava / java / awt / Cursor.java
blob8652a1e5ebe0b0eddf21927d114b9bf4fad8498c
1 /* Copyright (C) 1999, 2000, 2002 Free Software Foundation
3 This file is part of GNU Classpath.
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.
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.
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.
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.
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. */
38 package java.awt;
40 /**
41 * This class represents various predefined cursor types.
43 * @author Aaron M. Renn (arenn@urbanophile.com)
45 public class Cursor implements java.io.Serializable
47 static final long serialVersionUID = 8028237497568985504L;
49 /**
50 * Constant for the system default cursor type
52 public static final int DEFAULT_CURSOR = 0;
54 /**
55 * Constant for a cross-hair cursor.
57 public static final int CROSSHAIR_CURSOR = 1;
59 /**
60 * Constant for a cursor over a text field.
62 public static final int TEXT_CURSOR = 2;
64 /**
65 * Constant for a cursor to display while waiting for an action to complete.
67 public static final int WAIT_CURSOR = 3;
69 /**
70 * Cursor used over SW corner of window decorations.
72 public static final int SW_RESIZE_CURSOR = 4;
74 /**
75 * Cursor used over SE corner of window decorations.
77 public static final int SE_RESIZE_CURSOR = 5;
79 /**
80 * Cursor used over NW corner of window decorations.
82 public static final int NW_RESIZE_CURSOR = 6;
84 /**
85 * Cursor used over NE corner of window decorations.
87 public static final int NE_RESIZE_CURSOR = 7;
89 /**
90 * Cursor used over N edge of window decorations.
92 public static final int N_RESIZE_CURSOR = 8;
94 /**
95 * Cursor used over S edge of window decorations.
97 public static final int S_RESIZE_CURSOR = 9;
99 /**
100 * Cursor used over W edge of window decorations.
102 public static final int W_RESIZE_CURSOR = 10;
105 * Cursor used over E edge of window decorations.
107 public static final int E_RESIZE_CURSOR = 11;
110 * Constant for a hand cursor.
112 public static final int HAND_CURSOR = 12;
115 * Constant for a cursor used during window move operations.
117 public static final int MOVE_CURSOR = 13;
119 public static final int CUSTOM_CURSOR = 0xFFFFFFFF;
121 private static final int PREDEFINED_COUNT = 14;
123 protected static Cursor[] predefined = new Cursor[PREDEFINED_COUNT];
124 protected String name;
127 * @serial The numeric id of this cursor.
129 int type;
132 * Initializes a new instance of <code>Cursor</code> with the specified
133 * type.
135 * @param type The cursor type.
137 * @exception IllegalArgumentException If the specified cursor type is invalid
139 public Cursor(int type)
141 if (type < 0 || type >= PREDEFINED_COUNT)
142 throw new IllegalArgumentException ("invalid cursor " + type);
144 this.type = type;
145 // FIXME: lookup and set name?
148 /** This constructor is used internally only.
149 * Application code should call Toolkit.createCustomCursor().
151 protected Cursor(String name)
153 this.name = name;
154 this.type = CUSTOM_CURSOR;
158 * Returns an instance of <code>Cursor</code> for one of the specified
159 * predetermined types.
161 * @param type The type contant from this class.
163 * @return The requested predefined cursor.
165 * @exception IllegalArgumentException If the constant is not one of the
166 * predefined cursor type constants from this class.
168 public static Cursor getPredefinedCursor(int type)
170 if (type < 0 || type >= PREDEFINED_COUNT)
171 throw new IllegalArgumentException ("invalid cursor " + type);
172 if (predefined[type] == null)
173 predefined[type] = new Cursor(type);
174 return predefined[type];
178 * Retrieves the system specific custom Cursor named Cursor names are,
179 * for example: "Invalid.16x16".
181 * @exception AWTException
182 * @exception HeadlessException If GraphicsEnvironment.isHeadless()
183 * returns true.
185 public static Cursor getSystemCustomCursor(String name)
186 throws AWTException
188 if (GraphicsEnvironment.isHeadless())
189 throw new HeadlessException ();
191 // FIXME
192 return null;
196 * Returns an instance of the system default cursor type.
198 * @return The system default cursor.
200 public static Cursor getDefaultCursor()
202 return getPredefinedCursor(DEFAULT_CURSOR);
206 * Returns the numeric type identifier for this cursor.
208 * @return The cursor id.
210 public int getType()
212 return type;
215 public String getName()
217 return name;
220 public String toString()
222 return (this.getClass() + "[" + getName() + "]");