From: Michael Koch Date: Fri, 27 Jun 2003 12:41:52 +0000 (+0000) Subject: JWindow.java, [...]: New versions from classpath. X-Git-Tag: releases/gcc-3.4.0~5426 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1c9d1c5bb9ff30d675a280ae8eeebc0207ec06c3;p=thirdparty%2Fgcc.git JWindow.java, [...]: New versions from classpath. 2003-06-27 Michael Koch * javax/swing/JWindow.java, javax/swing/event/AncestorEvent.java, javax/swing/event/HyperlinkEvent.java, javax/swing/event/InternalFrameEvent.java, javax/swing/event/ListDataEvent.java, javax/swing/event/TableModelEvent.java, javax/swing/plaf/PopupMenuUI.java, javax/swing/plaf/SplitPaneUI.java, javax/swing/plaf/TabbedPaneUI.java, javax/swing/plaf/TextUI.java, javax/swing/plaf/TreeUI.java, javax/swing/plaf/basic/BasicTextUI.java, javax/swing/plaf/basic/BasicTreeUI.java: New versions from classpath. * javax/swing/Popup.java, javax/swing/PopupFactory.jav: New source files from classpath. * javax/swing/plaf/doc-files/TreeUI-1.png: New binary files from classpath. From-SVN: r68568 --- diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 26274fe10aa1..1392095acca8 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,25 @@ +2003-06-27 Michael Koch + + * javax/swing/JWindow.java, + javax/swing/event/AncestorEvent.java, + javax/swing/event/HyperlinkEvent.java, + javax/swing/event/InternalFrameEvent.java, + javax/swing/event/ListDataEvent.java, + javax/swing/event/TableModelEvent.java, + javax/swing/plaf/PopupMenuUI.java, + javax/swing/plaf/SplitPaneUI.java, + javax/swing/plaf/TabbedPaneUI.java, + javax/swing/plaf/TextUI.java, + javax/swing/plaf/TreeUI.java, + javax/swing/plaf/basic/BasicTextUI.java, + javax/swing/plaf/basic/BasicTreeUI.java: + New versions from classpath. + * javax/swing/Popup.java, + javax/swing/PopupFactory.jav: + New source files from classpath. + * javax/swing/plaf/doc-files/TreeUI-1.png: + New binary files from classpath. + 2003-06-25 Michael Koch * Makefile.am diff --git a/libjava/javax/swing/JWindow.java b/libjava/javax/swing/JWindow.java index 50d0c316895a..5edf5b254129 100644 --- a/libjava/javax/swing/JWindow.java +++ b/libjava/javax/swing/JWindow.java @@ -1,5 +1,5 @@ /* JWindow.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -78,6 +78,11 @@ public class JWindow extends Window implements Accessible * *************/ + public JWindow() + { + this(null); + } + // huuu ? public JWindow(Frame f) { diff --git a/libjava/javax/swing/Popup.java b/libjava/javax/swing/Popup.java new file mode 100644 index 000000000000..b1cb4460a495 --- /dev/null +++ b/libjava/javax/swing/Popup.java @@ -0,0 +1,189 @@ +/* Popup.java -- + Copyright (C) 2003 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.swing; + +import java.awt.Component; + + +/** + * Manages a popup window that displays a Component on top of + * everything else. + * + *

To obtain an instance of Popup, use the + * {@link javax.swing.PopupFactory}. + * + * @since 1.4 + * + * @author Sascha Brawer (brawer@dandelis.ch) + */ +public class Popup +{ + /** + * Constructs a new Popup given its owner, + * contents and the screen position where the popup + * will appear. + * + * @param owner the Component to which x and + * y are relative, or null for + * placing the popup relative to the origin of the screen. + * + * @param contents the contents that will be displayed inside + * the Popup. + * + * @param x the horizontal position where the Popup will appear. + * + * @param y the vertical position where the Popup will appear. + * + * @throws IllegalArgumentException if contents + * is null. + */ + protected Popup(Component owner, Component contents, + int x, int y) + { + if (contents == null) + throw new IllegalArgumentException(); + + // The real stuff happens in the implementation of subclasses, + // for instance JWindowPopup. + } + + + /** + * Constructs a new Popup. + */ + protected Popup() + { + } + + + /** + * Displays the Popup on the screen. Nothing happens + * if it is currently shown. + */ + public void show() + { + // Implemented by subclasses, for instance JWindowPopup. + } + + + /** + * Removes the Popup from the screen. Nothing happens + * if it is currently hidden. + */ + public void hide() + { + // Implemented by subclasses, for instance JWindowPopup. + } + + + /** + * A Popup that uses a JWindow for + * displaying its contents. + * + * @see PopupFactory#getPopup + * + * @author Sascha Brawer (brawer@dandelis.ch) + */ + static class JWindowPopup + extends Popup + { + /** + * The JWindow used for displaying the contents + * of the popup. + */ + JWindow window; + + + /** + * Constructs a new JWindowPopup given its owner, + * contents and the screen position where the popup + * will appear. + * + * @param owner the Component to which x and + * y are relative, or null for + * placing the popup relative to the origin of the screen. + * + * @param contents the contents that will be displayed inside + * the Popup. + * + * @param x the horizontal position where the Popup will appear. + * + * @param y the vertical position where the Popup will appear. + * + * @throws IllegalArgumentException if contents + * is null. + */ + public JWindowPopup(Component owner, Component contents, + int x, int y) + { + /* Checks whether contents is null. */ + super(owner, contents, x, y); + + window = new JWindow(); + window.getRootPane().add(contents); + window.setLocation(x, y); + window.pack(); + } + + + /** + * Displays the popup’s JWindow on the screen. + * Nothing happens if it is already visible. + */ + public void show() + { + window.show(); + } + + + /** + * Removes the popup’s JWindow from the + * screen. Nothing happens if it is currently not visible. + */ + public void hide() + { + /* Calling dispose() instead of hide() will conserve native + * system resources, for example memory in an X11 server. + * They will automatically be re-allocated by a call to + * show(). + */ + window.dispose(); + } + } +} diff --git a/libjava/javax/swing/PopupFactory.java b/libjava/javax/swing/PopupFactory.java new file mode 100644 index 000000000000..571de22d0ed2 --- /dev/null +++ b/libjava/javax/swing/PopupFactory.java @@ -0,0 +1,139 @@ +/* PopupFactory.java -- + Copyright (C) 2003 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.swing; + +import java.awt.Component; + + +/** + * A factory for Popup objects. These are used to + * managed little windows that float over everything else, + * typically containing a popup menu. + * + * @since 1.4 + * + * @author Sascha Brawer (brawer@dandelis.ch) + */ +public class PopupFactory +{ + /** + * The shared factory object. + * + * @see #getSharedFactory + * @see #setSharedFactory + */ + private static PopupFactory sharedFactory; + + + /** + * Constructs a new PopupFactory. Usually, a single + * PopupFactory is shared among multiple consumers + * of Popup. Use {@link #getSharedInstance} to retrieve + * the current factory. + */ + public PopupFactory() + { + } + + + /** + * Sets the shared factory. + * + * @param factory the PopupFactory that future invocations of + * {@link #getSharedInstance} will return. + * + * @throws IllegalArgumentException if factory + * is null. + */ + public static void setSharedInstance(PopupFactory factory) + { + if (factory == null) + throw new IllegalArgumentException(); + + /* Swing is not designed to be thread-safe, so there is no + * need to synchronize the access to the global variable. + */ + sharedFactory = factory; + } + + + /** + * Retrieves the shared factory, creating a new factory if + * necessary. + * + * @return a PopupFactory that can be used + * to create Popup objects. + */ + public static PopupFactory getSharedInstance() + { + /* Swing is not designed to be thread-safe, so there is no + * need to synchronize the access to the global variable. + */ + if (sharedFactory == null) + sharedFactory = new PopupFactory(); + + return sharedFactory; + } + + + /** + * Creates a new Popup given its owner, + * contents and the screen position where the popup + * will appear. + * + * @param owner the Component to which x and + * y are relative, or null for + * placing the popup relative to the origin of the screen. + * + * @param contents the contents that will be displayed inside + * the Popup. + * + * @param x the horizontal position where the Popup will appear. + * + * @param y the vertical position where the Popup will appear. + * + * @throws IllegalArgumentException if contents + * is null. + */ + public Popup getPopup(Component owner, Component contents, + int x, int y) + { + return new Popup.JWindowPopup(owner, contents, x, y); + } +} diff --git a/libjava/javax/swing/event/AncestorEvent.java b/libjava/javax/swing/event/AncestorEvent.java index 0259bad07a81..c6173932bb98 100644 --- a/libjava/javax/swing/event/AncestorEvent.java +++ b/libjava/javax/swing/event/AncestorEvent.java @@ -48,11 +48,11 @@ import javax.swing.JComponent; */ public class AncestorEvent extends AWTEvent { - private static final long serialVersionUID = 4799843792513591457L; + private static final long serialVersionUID = -8079801679695605002L; - public static int ANCESTOR_ADDED = 0; - public static int ANCESTOR_MOVED = 1; - public static int ANCESTOR_REMOVED = 2; + public static final int ANCESTOR_ADDED = 0; + public static final int ANCESTOR_MOVED = 1; + public static final int ANCESTOR_REMOVED = 2; private JComponent sourceComponent; private Container ancestor; diff --git a/libjava/javax/swing/event/HyperlinkEvent.java b/libjava/javax/swing/event/HyperlinkEvent.java index a1dfeb8d006d..c979fbf62dab 100644 --- a/libjava/javax/swing/event/HyperlinkEvent.java +++ b/libjava/javax/swing/event/HyperlinkEvent.java @@ -75,7 +75,7 @@ public class HyperlinkEvent extends EventObject } } - private static final long serialVersionUID = -8168964465779154277L; + private static final long serialVersionUID = -2054640811732867012L; private EventType type; private URL url; diff --git a/libjava/javax/swing/event/InternalFrameEvent.java b/libjava/javax/swing/event/InternalFrameEvent.java index 1fe65258f6a7..15d12f2efcf6 100644 --- a/libjava/javax/swing/event/InternalFrameEvent.java +++ b/libjava/javax/swing/event/InternalFrameEvent.java @@ -46,52 +46,52 @@ import javax.swing.JInternalFrame; */ public class InternalFrameEvent extends AWTEvent { - private static final long serialVersionUID = 9195444901064686684L; + private static final long serialVersionUID = -5204823611874873183L; /** * Internal frame activated event */ - public static int INTERNAL_FRAME_ACTIVATED = 25554; + public static final int INTERNAL_FRAME_ACTIVATED = 25554; /** * Internal frame closed event */ - public static int INTERNAL_FRAME_CLOSED = 25551; + public static final int INTERNAL_FRAME_CLOSED = 25551; /** * Internal frame closing event */ - public static int INTERNAL_FRAME_CLOSING = 25550; + public static final int INTERNAL_FRAME_CLOSING = 25550; /** * Internal frame deactivated event */ - public static int INTERNAL_FRAME_DEACTIVATED = 25555; + public static final int INTERNAL_FRAME_DEACTIVATED = 25555; /** * Internal frame deiconifed event */ - public static int INTERNAL_FRAME_DEICONIFIED = 25553; + public static final int INTERNAL_FRAME_DEICONIFIED = 25553; /** * Internal frame frame first event */ - public static int INTERNAL_FRAME_FIRST = 25549; + public static final int INTERNAL_FRAME_FIRST = 25549; /** * Internal frame iconified event */ - public static int INTERNAL_FRAME_ICONIFIED = 2552; + public static final int INTERNAL_FRAME_ICONIFIED = 2552; /** * Internal frame last event */ - public static int INTERNAL_FRAME_LAST = 25555; + public static final int INTERNAL_FRAME_LAST = 25555; /** * Internal frame opened event */ - public static int INTERNAL_FRAME_OPENED = 25550; + public static final int INTERNAL_FRAME_OPENED = 25550; /** * Creates a JInternalFrameEvent object. diff --git a/libjava/javax/swing/event/ListDataEvent.java b/libjava/javax/swing/event/ListDataEvent.java index 3b22ad63bc00..c86e86abe926 100644 --- a/libjava/javax/swing/event/ListDataEvent.java +++ b/libjava/javax/swing/event/ListDataEvent.java @@ -46,11 +46,11 @@ import java.util.EventObject; */ public class ListDataEvent extends EventObject { - private static final long serialVersionUID = -7131487416250401903L; + private static final long serialVersionUID = 2510353260071004774L; - public static int CONTENTS_CHANGED = 0; - public static int INTERVAL_ADDED = 1; - public static int INTERVAL_REMOVED = 2; + public static final int CONTENTS_CHANGED = 0; + public static final int INTERVAL_ADDED = 1; + public static final int INTERVAL_REMOVED = 2; private int type = 0; private int index0 = 0; diff --git a/libjava/javax/swing/event/TableModelEvent.java b/libjava/javax/swing/event/TableModelEvent.java index 2dee423eac40..6bd969719507 100644 --- a/libjava/javax/swing/event/TableModelEvent.java +++ b/libjava/javax/swing/event/TableModelEvent.java @@ -46,13 +46,13 @@ import javax.swing.table.TableModel; */ public class TableModelEvent extends EventObject { - private static final long serialVersionUID = -7037680193569691706L; + private static final long serialVersionUID = -7849342674552212824L; - public static int ALL_COLUMNS = -1; - public static int DELETE = -1; - public static int HEADER_ROW = -1; - public static int INSERT = 1; - public static int UPDATE = 0; + public static final int ALL_COLUMNS = -1; + public static final int DELETE = -1; + public static final int HEADER_ROW = -1; + public static final int INSERT = 1; + public static final int UPDATE = 0; protected int column = 0; protected int firstRow = 0; diff --git a/libjava/javax/swing/plaf/PopupMenuUI.java b/libjava/javax/swing/plaf/PopupMenuUI.java index d1faa78d1467..1871b9b79853 100644 --- a/libjava/javax/swing/plaf/PopupMenuUI.java +++ b/libjava/javax/swing/plaf/PopupMenuUI.java @@ -1,5 +1,5 @@ /* PopupMenuUI.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -37,40 +37,80 @@ exception statement from your version. */ package javax.swing.plaf; -// Imports -import java.awt.event.*; +import java.awt.event.MouseEvent; +import javax.swing.JPopupMenu; +import javax.swing.Popup; +import javax.swing.PopupFactory; + /** - * PopupMenuUI - * @author Andrew Selkirk - * @version 1.0 + * An abstract base class for delegates that implement the pluggable + * look and feel for a JPopupMenu. + * + * @see javax.swing.JPopupMenu + * + * @author Andrew Selkirk (aselkirk@sympatico.ca) + * @author Sascha Brawer (brawer@dandelis.ch) */ -public abstract class PopupMenuUI extends ComponentUI { - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - - /** - * Constructor PopupMenuUI - */ - public PopupMenuUI() { - // TODO - } // PopupMenuUI() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * isPopupTrigger - * @param event TODO - * @returns boolean - */ - public boolean isPopupTrigger(MouseEvent event) { - return false; // TODO - } // isPopupTrigger() - - -} // PopupMenuUI +public abstract class PopupMenuUI + extends ComponentUI +{ + /** + * Constructs a new PopupMenuUI. + */ + public PopupMenuUI() + { + } + + + /** + * Tests whether or not a mouse event triggers a popup menu. + * + *

The default implementation calls + * event.isPopupTrigger(), which checks for the gesture + * that is common for the platform on which the application runs. If + * a look and feel wants to employ non-standard conventions for + * triggering a popup menu, it can override this method. + * + * @param event the event to check. + * + * @return true if the event triggers a popup menu; + * false otherwise. + * + * @since 1.3 + */ + public boolean isPopupTrigger(MouseEvent event) + { + return event.isPopupTrigger(); + } + + + /** + * Creates a Popup for displaying the popup menu. The + * default implementation uses the {@link javax.swing.PopupFactory} + * for retrieving a suitable Popup, but subclasses + * might want to override this method if a LookAndFeel needs special + * Popups. + * + * @param popup the JPopupMenu for whose display + * a Popup is needed. + * + * @param x the horizontal position where the popup will be + * displayed. + * + * @param y the vertical position where the popup will be + * displayed. + * + * @return a Popup for showing and hiding + * the menu. + * + * @since 1.4 + */ + public Popup getPopup(JPopupMenu popup, int x, int y) + { + return PopupFactory.getSharedInstance().getPopup( + /* origin/owner of the popup */ popup.getInvoker(), + /* contents */ popup, + x, y); + } +} diff --git a/libjava/javax/swing/plaf/SplitPaneUI.java b/libjava/javax/swing/plaf/SplitPaneUI.java index 6448ba866530..020a54a626f6 100644 --- a/libjava/javax/swing/plaf/SplitPaneUI.java +++ b/libjava/javax/swing/plaf/SplitPaneUI.java @@ -1,5 +1,5 @@ /* SplitPaneUI.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -37,75 +37,97 @@ exception statement from your version. */ package javax.swing.plaf; -// Imports -import java.awt.*; -import javax.swing.*; + +import java.awt.Graphics; +import javax.swing.JSplitPane; + /** - * SplitPaneUI - * @author Andrew Selkirk - * @version 1.0 + * An abstract base class for delegates that implement the pluggable + * look and feel for a JSplitPane. + * + * @see javax.swing.JSplitPane + * + * @author Andrew Selkirk (aselkirk@sympatico.ca) + * @author Sascha Brawer (brawer@dandelis.ch) */ -public abstract class SplitPaneUI extends ComponentUI { - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - - /** - * Constructor SplitPaneUI - */ - public SplitPaneUI() { - // TODO - } // SplitPaneUI() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * resetToPreferredSizes - * @param splitpane TODO - */ - public abstract void resetToPreferredSizes(JSplitPane splitpane); - - /** - * setDividerLocation - * @param splitpane TODO - * @param location TODO - */ - public abstract void setDividerLocation(JSplitPane splitpane, - int location); - - /** - * getDividerLocation - * @param splitpane TODO - * @returns int - */ - public abstract int getDividerLocation(JSplitPane splitpane); - - /** - * getMinimumDividerLocation - * @param splitpane TODO - * @returns int - */ - public abstract int getMinimumDividerLocation(JSplitPane splitpane); - - /** - * getMaximumDividerLocation - * @param splitpane TODO - * @returns int - */ - public abstract int getMaximumDividerLocation(JSplitPane splitpane); - - /** - * finishedPaintingChildren - * @param splitpane TODO - * @param graphics TODO - */ - public abstract void finishedPaintingChildren(JSplitPane splitpane, - Graphics graphics); - - -} // SplitPaneUI +public abstract class SplitPaneUI + extends ComponentUI +{ + /** + * Constructs a new SplitPaneUI. + */ + public SplitPaneUI() + { + } + + + /** + * Moves the divider to the location which best respects + * the preferred sizes of the children. + * + * @param pane the JSplitPane for thich this + * delegate provides the look and feel. + */ + public abstract void resetToPreferredSizes(JSplitPane pane); + + + /** + * Moves the divider to the specified location. + * + * @param pane the JSplitPane for thich this + * delegate provides the look and feel. + * + * @param location the new location of the divider. + */ + public abstract void setDividerLocation(JSplitPane pane, + int location); + + + /** + * Determines the current location of the divider. + * + * @param pane the JSplitPane for thich this + * delegate provides the look and feel. + * + * @return the current location of the divider. + */ + public abstract int getDividerLocation(JSplitPane pane); + + + /** + * Determines the minimum location of the divider. + * + * @param pane the JSplitPane for thich this + * delegate provides the look and feel. + * + * @return the leftmost (or topmost) possible location + * of the divider. + */ + public abstract int getMinimumDividerLocation(JSplitPane pane); + + + /** + * Determines the maximum location of the divider. + * + * @param pane the JSplitPane for thich this + * delegate provides the look and feel. + * + * @return the bottommost (or rightmost) possible location + * of the divider. + */ + public abstract int getMaximumDividerLocation(JSplitPane pane); + + + /** + * Called by the JSplitPane after it has finished + * painting its children. + * + * @param pane the JSplitPane for thich this + * delegate provides the look and feel. + * + * @param g the Graphics used for painting. + */ + public abstract void finishedPaintingChildren(JSplitPane pane, + Graphics g); +} diff --git a/libjava/javax/swing/plaf/TabbedPaneUI.java b/libjava/javax/swing/plaf/TabbedPaneUI.java index a9211c96705e..20c36c30c21e 100644 --- a/libjava/javax/swing/plaf/TabbedPaneUI.java +++ b/libjava/javax/swing/plaf/TabbedPaneUI.java @@ -1,5 +1,5 @@ /* TabbedPaneUI.java - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,24 +38,74 @@ exception statement from your version. */ package javax.swing.plaf; -import java.awt.*; -import javax.swing.*; +import java.awt.Rectangle; +import javax.swing.JTabbedPane; -public class TabbedPaneUI extends ComponentUI + +/** + * An abstract base class for delegates that implement the pluggable + * look and feel for a JTabbedPane. + * + * @see javax.swing.JTabbedPane + * + * @author Andrew Selkirk (aselkirk@sympatico.ca) + * @author Sascha Brawer (brawer@dandelis.ch) + */ +public abstract class TabbedPaneUI + extends ComponentUI { - public Rectangle getTabBounds(JTabbedPane pane, int index) - { - return null; - } - - public int getTabRunCount(JTabbedPane pane) - { - return 0; - } - - public int tabForCoordinate(JTabbedPane pane, int x, int y) - { - return 0; - } + /** + * Constructs a new TabbedPaneUI. + */ + public TabbedPaneUI() + { + } + + + /** + * Determines which tab lies at a given position. + * + * @param pane the JTabbedPane for which this + * delegate object provides the user interface. + * + * @param x the horizontal position, where zero is the left + * edge of pane. + * + * @param y the vertical position, where zero is the top + * edge of pane. + * + * @return the zero-based index of the tab, or -1 if no + * tab is at the specified position. + */ + public abstract int tabForCoordinate(JTabbedPane pane, + int x, int y); + + + /** + * Calculates the bounding box of a tab. + * + * @param pane the JTabbedPane for which this + * delegate object provides the user interface. + * + * @param index the index of the tab, which must be an integer + * in the range [0 .. pane.getTabCount() - 1]. + * + * @return the bounding box of the index-th tab, + * in the coordinate system of pane. + */ + public abstract Rectangle getTabBounds(JTabbedPane pane, int index); + + + /** + * Determines how many runs are used to display tabs. + * + * @param pane the JTabbedPane for which this + * delegate object provides the user interface. + * + * @return the number of tab runs. + * + * @see javax.swing.JTabbedPane#getTabRunCount() + */ + public abstract int getTabRunCount(JTabbedPane pane); } diff --git a/libjava/javax/swing/plaf/TextUI.java b/libjava/javax/swing/plaf/TextUI.java index abf5316d215c..14f89d6006e2 100644 --- a/libjava/javax/swing/plaf/TextUI.java +++ b/libjava/javax/swing/plaf/TextUI.java @@ -1,5 +1,5 @@ /* TextUI.java - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,27 +38,247 @@ exception statement from your version. */ package javax.swing.plaf; -import javax.swing.text.*; -import java.awt.*; +import java.awt.Point; +import java.awt.Rectangle; +import javax.swing.text.BadLocationException; +import javax.swing.text.EditorKit; +import javax.swing.text.JTextComponent; +import javax.swing.text.Position; +import javax.swing.text.View; -public abstract class TextUI extends ComponentUI + +/** + * An abstract base class for delegates that provide the user + * interface for text editors. + * + * @see javax.swing.text.JTextComponent + * + * @author Ronald Veldema (rveldema@cs.vu.nl) + * @author Sascha Brawer (brawer@dandelis.ch) + */ +public abstract class TextUI + extends ComponentUI { - public TextUI() - { - } - - public abstract void damageRange(JTextComponent t, int p0, int p1); - public abstract void damageRange(JTextComponent t, int p0, int p1, Position.Bias firstBias, Position.Bias secondBias); - public abstract EditorKit getEditorKit(JTextComponent t); - public abstract int getNextVisualPositionFrom(JTextComponent t, - int pos, - Position.Bias b, - int direction, - Position.Bias[] biasRet); - public abstract View getRootView(JTextComponent t); - public abstract Rectangle modelToView(JTextComponent t, int pos); - public abstract Rectangle modelToView(JTextComponent t, int pos, Position.Bias bias); - public abstract int viewToModel(JTextComponent t, Point pt); - public abstract int viewToModel(JTextComponent t, Point pt, Position.Bias[] biasReturn); + /** + * Constructs a new TextUI. + */ + public TextUI() + { + } + + + /** + * Calculates the geometric extent of the character at the + * given offset. + * + * @param tc the JTextComponent for which this + * delegate object provides the user interface. + * + * @param pos the zero-based index of the character into the + * document model. + * + * @return the bounding box of the character at index + * pos, in view coordinates. + * + * @throws BadLocationException if pos does not + * designate a valid position in the document model. + * + * @see javax.swing.text.View#modelToView(int, + * javax.swing.text.Position.Bias, int, + * javax.swing.text.position.Bias, java.awt.Shape) + */ + public abstract Rectangle modelToView(JTextComponent tc, int pos) + throws BadLocationException; + + + /** + * Calculates the geometric extent of the character at the + * given offset. + * + * @param tc the JTextComponent for which this + * delegate object provides the user interface. + * + * @param pos the zero-based index of the character into the + * document model. + * + * @param bias whether to take the character before or after the + * caret position indicated by pos. The value + * must be either {@link + * javax.swing.text.Position.Bias#Backward} or {@link + * javax.swing.text.Position.Bias#Forward}. + * + * @return the bounding box of the character at index + * pos, in view coordinates. + * + * @throws BadLocationException if pos does not + * designate a valid position in the document model. + * + * @see javax.swing.text.View#modelToView(int, + * javax.swing.text.Position.Bias, int, + * javax.swing.text.position.Bias, java.awt.Shape) + */ + public abstract Rectangle modelToView(JTextComponent tc, int pos, + Position.Bias bias) + throws BadLocationException; + + + /** + * Finds the caret position which is closest to the specified visual + * location. + * + * @param tc the JTextComponent for which this + * delegate object provides the user interface. + * + * @param loc the position in view coordinates. + * + * @return the caret position which is closest to loc. + * + * @see #viewToModel(JTextComponent, Point, Position.Bias[]) + */ + public abstract int viewToModel(JTextComponent t, Point pt); + + + /** + * Finds the caret position which is closest to the specified visual + * location. + * + * @param tc the JTextComponent for which this + * delegate object provides the user interface. + * + * @param loc the position in view coordinates. + * + * @param outBias an array whose size must be at least one. + * After the call, outBias[0] will indicate + * whether loc is in the glyph before + * (Position.Bias.Backward) or after + * (Position.Bias.Forward) the returned + * caret position. + * + * @return the caret position which is closest to loc. + */ + public abstract int viewToModel(JTextComponent tc, Point loc, + Position.Bias[] outBias); + + + /** + * Calculates the caret position that is visually next to the given + * position. This is useful to determine where to move the caret + * after the user has pressed an arrow key. + * + * @param tc the JTextComponent for which this + * delegate object provides the user interface. + * + * @param pos the current caret position, a zero-based index + * into the document model. + * + * @param bias whether to take the character before or after the + * caret position indicated by pos. The value + * must be either {@link + * javax.swing.text.Position.Bias#Backward} or {@link + * javax.swing.text.Position.Bias#Forward}. + * + * @param direction the visual direction. Pass + * {@link javax.swing.SwingConstants#WEST} for the left + * arrow key, {@link javax.swing.SwingConstants#EAST} + * for the right arrow key, {@link + * javax.swing.SwingConstants#NORTH} for the up arrow + * key, or {@link javax.swing.SwingConstants#SOUTH} + * for the down arrow key. + * + * @throws BadLocationException if pos does not + * designate a valid position in the document model. + * + * @throws IllegalArgumentException if direction + * is not one of Position.Bias.Forward + * or Position.Biad.Backward. + */ + public abstract int getNextVisualPositionFrom(JTextComponent tc, + int pos, + Position.Bias bias, + int direction, + Position.Bias[] outBias) + throws BadLocationException; + + + /** + * Repaints a range of characters. + * + * @param tc the JTextComponent for which this + * delegate object provides the user interface. + * + * @param start the first character in the range that needs + * painting, indicated as an index into the document model. + * + * @param end the last character in the range that needs + * painting, indicated as an index into the document model. + * end must be greater than or equal to + * start. + */ + public abstract void damageRange(JTextComponent tc, int start, int end); + + + /** + * Repaints a range of characters, also specifying the bias for the + * start and end of the range. + * + * @param tc the JTextComponent for which this + * delegate object provides the user interface. + * + * @param start the first character in the range that needs + * painting, indicated as an index into the document model. + * + * @param end the last character in the range that needs + * painting, indicated as an index into the document model. + * end must be greater than or equal to + * start. + */ + public abstract void damageRange(JTextComponent tc, + int start, int end, + Position.Bias startBias, + Position.Bias endBias); + + + /** + * Retrieves the EditorKit managing policies and + * persistent state. + * + * @param tc the JTextComponent for which this + * delegate object provides the user interface. + * + * @return the EditorKit used by tc. + */ + public abstract EditorKit getEditorKit(JTextComponent tc); + + + /** + * Retrieves the root of the view tree that visually presents + * the text. + * + * @param tc the JTextComponent for which this + * delegate object provides the user interface. + * + * @return the root View used by tc. + */ + public abstract View getRootView(JTextComponent tc); + + + /** + * Returns a String for presenting a tool tip at the specified + * location. + * + * @param tc the JTextComponent for which this + * delegate object provides the user interface. + * + * @param loc the location for which the tool tip is requested. + * + * @return the text for the tool tip, or null to + * display no tool tip. + * + * @since 1.4 + */ + public String getToolTipText(JTextComponent tc, Point loc) + { + return null; + } } diff --git a/libjava/javax/swing/plaf/TreeUI.java b/libjava/javax/swing/plaf/TreeUI.java index f5f884fca2a0..59dca9d877f6 100644 --- a/libjava/javax/swing/plaf/TreeUI.java +++ b/libjava/javax/swing/plaf/TreeUI.java @@ -1,5 +1,5 @@ /* TreeUI.java - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,7 +38,174 @@ exception statement from your version. */ package javax.swing.plaf; +import java.awt.Rectangle; +import javax.swing.JTree; +import javax.swing.tree.TreePath; -public class TreeUI extends ComponentUI + +/** + * An abstract base class for delegates that provide the user + * interface for JTree. + * + * @see javax.swing.JTree + * + * @author Sascha Brawer (brawer@dandelis.ch) + */ +public abstract class TreeUI + extends ComponentUI { + /** + * Constructs a new TreeUI. + */ + public TreeUI() + { + } + + + /** + * Determines the geometric extent of the label that is + * drawn for a path. + * + * @param tree the JTree for which this delegate + * object provides the user interface. + * + * @param path the path whose label extent is requested. + * + * @return a rectangle enclosing the label, or null + * if path contains invalid nodes. + */ + public abstract Rectangle getPathBounds(JTree tree, TreePath path); + + + /** + * Creates a TreePath for the specified row. + * + * @param tree the JTree for which this delegate + * object provides the user interface. + * + * @param row the index of the row, which should be a number + * in the range [0, getRowCount(tree) - 1]. + * + * @return a TreePath for the specified row, or + * null if row is outside + * the valid range. + */ + public abstract TreePath getPathForRow(JTree tree, int row); + + + /** + * Determines in which row a TreePath is currently + * being displayed. + * + * @param tree the JTree for which this delegate + * object provides the user interface. + * + * @param path the path for which the caller wants to know + * in which row it is being displayed. + * + * @return a number in the range [0, getRowCount(tree) + * - 1] if the path is currently on display; + * -1 if the path is not shown to the + * user. + */ + public abstract int getRowForPath(JTree tree, TreePath path); + + + /** + * Counts how many rows are currently displayed. + * + * @param tree the JTree for which this delegate + * object provides the user interface. + * + * @return the number of visible rows. + */ + public abstract int getRowCount(JTree tree); + + + /** + * Finds the path that is closest to the specified position. + * + *