summaryrefslogtreecommitdiff
path: root/java/awt/Cursor.java
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2002-01-22 22:00:14 +0000
committerTom Tromey <tromey@redhat.com>2002-01-22 22:00:14 +0000
commit055c02559944c80442c8b9e144a0ce39c92bc7ea (patch)
treee0347d2c7548b2f4d91778c307d5161eed7fc0a9 /java/awt/Cursor.java
parent4ac669bb646a8eb472dcfe8ca6489f76084a4a94 (diff)
downloadclasspath-055c02559944c80442c8b9e144a0ce39c92bc7ea.tar.gz
* java/awt/PopupMenu.java (addNotify): New implementation from
libgcj. * java/awt/MenuBar.java (add): Handle case where menu already has a parent. (deleteShortcut): Delete shortcut from all menus. (remove(int)): New implementation from libgcj. (setHelpMenu): Likewise. * java/awt/MenuItem.java (paramString): Don't include class name or brackets. Call superclass paramString. * java/awt/MenuComponent.java (toString): Call paramString. (paramString): Compute string; don't call toString. * java/awt/Label.java (paramString): Don't include class name or brackets. Call superclass paramString. * java/awt/Checkbox.java (paramString): Don't include class name or brackets. Call superclass paramString. * java/awt/Button.java (paramString): Don't include class name or brackets. Call superclass paramString. * java/awt/MenuComponent.java (getTreeLock): Now protected. * java/awt/Panel.java (addNotify): Call superclass addNotify. * java/awt/PaintContext.java: New file from libgcj. * java/awt/MenuShortcut.java (equals(Object)): New method. (hashCode): Likewise. (toString): Use paramString and square brackets. * java/awt/MenuContainer.java (postEvent): Resurrected. * java/awt/Menu.java (menuSerializedDataVersion): New field. (addNotify): Use peer field directly. Call superclass addNotify. (add): New implementation from libgcj. (separator): New field. (addSeparator): New implementation from libgcj. (insertSeparator): Likewise. (removeAll): Removed redundant test. Always remove item 0. (paramString): Include tearOff, isHelpMenu, and superclass paramString. * java/awt/List.java (List()): Default to 4 rows. (addNotify): Use `peer' directly. Call superclass addNotify. (addItem(String)): Deprecated. (add(String)): Call add, not addItem. (add(String,int)): Do work here. (addItem(String,int)): Call add. Deprecated. (removeAll): Use `clear' on items. Use `peer' field directly. (remove(String)): Use remove, not delItem. (replaceItem): Likewise. (remove(int)): New implementation from libgcj. (delItem(int)): Use remove. (getSelectedIndex): New implementation from libgcj. (getSelectedIndexes): Likewise. (isIndexSelected): Remove redundant test. (setMultipleMode): Use `peer' field directly. (makeVisible): Likewise. (paramString): New implementation from libgcj. (delItems): Run loop in reverse direction. Use `peer' field directly. * java/awt/Insets.java (equals): Removed redundant test. (hashCode): New method. * java/awt/GridBagConstraints.java: New file from libgcj. * java/awt/FontMetrics.java (getMaxAdvance): Return -1. (toString): Use libgcj implementation. * java/awt/Font.java (ROMAN_BASELINE, CENTER_BASELINE, HANGING_BASELINE): New constants. (pointSize): New field. (Font): Initialize pointSize. (getStyle): New method. (getSize2D): Likewise. * java/awt/FileDialog.java (addNotify): Use `peer' field directly. Call superclass addNotify. (paramString): Don't include class name or brackets. Call superclass paramString. (setDirectory): Use `peer' field directly. (setFile): Likewise. (setFilenameFilter): Likewise. * java/awt/Dialog.java (Dialog(Dialog)): New constructor. (Dialog(Dialog,String)): Likewise. (Dialog(Dialog,String,boolean)): Likewise. (addNotify): Use `peer' field directly. Call superclass addNotify. (setTitle): Use `peer' field directly. (setResizable): Likewise. (paramString): Don't include class name or brackets. Call superclass paramString. * java/awt/Cursor.java: Merged with libgcj. * java/awt/Color.java (white, lightGray, gray, darkGray, black, red, pink, orange, yellow, green, magenta, cyan, blue): Set alpha value. (value): Initialize. (Color(int,boolean)): New constructor. (Color(int,int,int,int)): Likewise. (alphamask): New constant. (getAlpha): New method. (BRIGHT_STEP): New constant. (brighter, darker): New implementation from libgcj. (getTransparency): New method. (equals): Remove redundant test. Compare `value' fields directly. * java/awt/Choice.java (selectedIndex): Initialize to -1. (add): Throw exception if item is null. Use `peer' field directly. Select item if it is the first. (addItem): Call add. (addNotify): Use `peer' field directly. Call superclass addNotify. (getSelectedItem): Handle case where selectedIndex is -1. (insert): Use `peer' field directly. Only cast if peer is non-null. Handle case where `index' is too large. Select item if it is the first one. (paramString): Don't include class name or brackets. Call superclass paramString. (remove(String)): Throw exception if item not found. (remove(int)): Use `peer' field directly. Update selection. (removeAll): Correctly remove items. Remove redundant check. (select(String)): Throw exception if item not found. (select(int)): Use `peer' field directly. Don't cast unless peer is non-null. * java/awt/CheckboxMenuItem.java (addNotify): Use `peer' field directly. Call superclass addNotify. (paramString): Don't include class name or brackets. Call superclass paramString. (processEvent): Call superclass processEvent. (setState): Use `peer' field directly. Don't cast unless peer is non-null.
Diffstat (limited to 'java/awt/Cursor.java')
-rw-r--r--java/awt/Cursor.java250
1 files changed, 123 insertions, 127 deletions
diff --git a/java/awt/Cursor.java b/java/awt/Cursor.java
index 948c412e9..79b1d6c52 100644
--- a/java/awt/Cursor.java
+++ b/java/awt/Cursor.java
@@ -1,5 +1,4 @@
-/* Cursor.java -- Mouse pointer class
- Copyright (C) 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2000, 2002 Free Software Foundation
This file is part of GNU Classpath.
@@ -34,168 +33,165 @@ package java.awt;
*/
public class Cursor implements java.io.Serializable
{
-
-/*
- * Static Variables
- */
-
-/**
+ /**
* Constant for the system default cursor type
*/
-public static final int DEFAULT_CURSOR = 0;
+ public static final int DEFAULT_CURSOR = 0;
-/**
+ /**
* Constant for a cross-hair cursor.
*/
-public static final int CROSSHAIR_CURSOR = 1;
+ public static final int CROSSHAIR_CURSOR = 1;
-/**
+ /**
* Constant for a cursor over a text field.
*/
-public static final int TEXT_CURSOR = 2;
+ public static final int TEXT_CURSOR = 2;
-/**
+ /**
* Constant for a cursor to display while waiting for an action to complete.
*/
-public static final int WAIT_CURSOR = 3;
+ public static final int WAIT_CURSOR = 3;
-/**
+ /**
* Cursor used over SW corner of window decorations.
*/
-public static final int SW_RESIZE_CURSOR = 4;
+ public static final int SW_RESIZE_CURSOR = 4;
-/**
+ /**
* Cursor used over SE corner of window decorations.
*/
-public static final int SE_RESIZE_CURSOR = 5;
+ public static final int SE_RESIZE_CURSOR = 5;
-/**
+ /**
* Cursor used over NW corner of window decorations.
*/
-public static final int NW_RESIZE_CURSOR = 6;
+ public static final int NW_RESIZE_CURSOR = 6;
-/**
+ /**
* Cursor used over NE corner of window decorations.
*/
-public static final int NE_RESIZE_CURSOR = 7;
+ public static final int NE_RESIZE_CURSOR = 7;
-/**
+ /**
* Cursor used over N edge of window decorations.
*/
-public static final int N_RESIZE_CURSOR = 8;
+ public static final int N_RESIZE_CURSOR = 8;
-/**
+ /**
* Cursor used over S edge of window decorations.
*/
-public static final int S_RESIZE_CURSOR = 9;
+ public static final int S_RESIZE_CURSOR = 9;
-/**
- * Cursor used over E edge of window decorations.
+ /**
+ * Cursor used over W edge of window decorations.
*/
-public static final int E_RESIZE_CURSOR = 10;
+ public static final int W_RESIZE_CURSOR = 10;
-/**
- * Cursor used over W edge of window decorations.
+ /**
+ * Cursor used over E edge of window decorations.
*/
-public static final int W_RESIZE_CURSOR = 11;
+ public static final int E_RESIZE_CURSOR = 11;
-/**
+ /**
* Constant for a hand cursor.
*/
-public static final int HAND_CURSOR = 12;
+ public static final int HAND_CURSOR = 12;
-/**
+ /**
* Constant for a cursor used during window move operations.
*/
-public static final int MOVE_CURSOR = 13;
-
-// Serialization constant
-private static final long serialVersionUID = 8028237497568985504L;
-
-/*************************************************************************/
-
-/*
- * Instance Variables
- */
-
-/**
- * @serial The numeric id of this cursor.
- */
-private int type;
-
-/*************************************************************************/
-
-/*
- * Static Methods
- */
-
-/**
- * Returns an instance of the system default cursor type.
- *
- * @return The system default cursor.
- */
-public static Cursor
-getDefaultCursor()
-{
- return(new Cursor(DEFAULT_CURSOR));
-}
-
-/*************************************************************************/
-
-/**
- * Returns an instance of <code>Cursor</code> for one of the specified
- * predetermined types.
- *
- * @param type The type contant from this class.
- *
- * @return The requested predefined cursor.
- *
- * @exception IllegalArgumentException If the constant is not one of the
- * predefined cursor type constants from this class.
- */
-public static Cursor
-getPredefinedCursor(int type) throws IllegalArgumentException
-{
- if ((type < DEFAULT_CURSOR) || (type > MOVE_CURSOR))
- throw new IllegalArgumentException("Bad predefined cursor type: " + type);
-
- return(new Cursor(type));
+ public static final int MOVE_CURSOR = 13;
+
+ public static final int CUSTOM_CURSOR = 0xFFFFFFFF;
+
+ private static final int PREDEFINED_COUNT = 14;
+
+ protected static Cursor[] predefined = new Cursor[PREDEFINED_COUNT];
+ protected String name;
+
+ /**
+ * @serial The numeric id of this cursor.
+ */
+ int type;
+
+ /**
+ * Initializes a new instance of <code>Cursor</code> with the specified
+ * type.
+ *
+ * @param type The cursor type.
+ */
+ public Cursor(int type)
+ {
+ if (type < 0 || type >= PREDEFINED_COUNT)
+ throw new IllegalArgumentException ("invalid cursor " + type);
+ this.type = type;
+ // FIXME: lookup and set name?
+ }
+
+ /** This constructor is used internally only.
+ * Application code should call Toolkit.createCustomCursor().
+ */
+ protected Cursor(String name)
+ {
+ this.name = name;
+ this.type = CUSTOM_CURSOR;
+ }
+
+ /**
+ * Returns an instance of <code>Cursor</code> for one of the specified
+ * predetermined types.
+ *
+ * @param type The type contant from this class.
+ *
+ * @return The requested predefined cursor.
+ *
+ * @exception IllegalArgumentException If the constant is not one of the
+ * predefined cursor type constants from this class.
+ */
+ public static Cursor getPredefinedCursor(int type)
+ {
+ if (type < 0 || type >= PREDEFINED_COUNT)
+ throw new IllegalArgumentException ("invalid cursor " + type);
+ if (predefined[type] == null)
+ predefined[type] = new Cursor(type);
+ return predefined[type];
+ }
+
+ public static Cursor getSystemCustomCursor(String name)
+ throws AWTException
+ {
+ // FIXME
+ return null;
+ }
+
+ /**
+ * Returns an instance of the system default cursor type.
+ *
+ * @return The system default cursor.
+ */
+ public static Cursor getDefaultCursor()
+ {
+ return getPredefinedCursor(DEFAULT_CURSOR);
+ }
+
+ /**
+ * Returns the numeric type identifier for this cursor.
+ *
+ * @return The cursor id.
+ */
+ public int getType()
+ {
+ return type;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String toString()
+ {
+ return (this.getClass() + "[" + getName() + "]");
+ }
}
-
-/*************************************************************************/
-
-/*
- * Constructors
- */
-
-/**
- * Initializes a new instance of <code>Cursor</code> with the specified
- * type.
- *
- * @param type The cursor type.
- */
-public
-Cursor(int type)
-{
- this.type = type;
-}
-
-/*************************************************************************/
-
-/**
- * Instance Variables
- */
-
-/**
- * Returns the numeric type identifier for this cursor.
- *
- * @return The cursor id.
- */
-public int
-getType()
-{
- return(type);
-}
-
-} // class Cursor
-