JWindow.java, [...]: New versions from classpath.

2003-06-27  Michael Koch  <konqueror@gmx.de>

	* 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
This commit is contained in:
Michael Koch 2003-06-27 12:41:52 +00:00 committed by Michael Koch
parent 37706dd19d
commit 1c9d1c5bb9
17 changed files with 1223 additions and 167 deletions

View File

@ -1,3 +1,25 @@
2003-06-27 Michael Koch <konqueror@gmx.de>
* 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 <konqueror@gmx.de>
* Makefile.am

View File

@ -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)
{

View File

@ -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.
*
* <p>To obtain an instance of <code>Popup</code>, use the
* {@link javax.swing.PopupFactory}.
*
* @since 1.4
*
* @author Sascha Brawer (brawer@dandelis.ch)
*/
public class Popup
{
/**
* Constructs a new <code>Popup</code> given its owner,
* contents and the screen position where the popup
* will appear.
*
* @param owner the Component to which <code>x</code> and
* <code>y</code> are relative, or <code>null</code> for
* placing the popup relative to the origin of the screen.
*
* @param contents the contents that will be displayed inside
* the <code>Popup</code>.
*
* @param x the horizontal position where the Popup will appear.
*
* @param y the vertical position where the Popup will appear.
*
* @throws IllegalArgumentException if <code>contents</code>
* is <code>null</code>.
*/
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 <code>Popup</code>.
*/
protected Popup()
{
}
/**
* Displays the <code>Popup</code> on the screen. Nothing happens
* if it is currently shown.
*/
public void show()
{
// Implemented by subclasses, for instance JWindowPopup.
}
/**
* Removes the <code>Popup</code> from the screen. Nothing happens
* if it is currently hidden.
*/
public void hide()
{
// Implemented by subclasses, for instance JWindowPopup.
}
/**
* A <code>Popup</code> that uses a <code>JWindow</code> for
* displaying its contents.
*
* @see PopupFactory#getPopup
*
* @author Sascha Brawer (brawer@dandelis.ch)
*/
static class JWindowPopup
extends Popup
{
/**
* The <code>JWindow</code> used for displaying the contents
* of the popup.
*/
JWindow window;
/**
* Constructs a new <code>JWindowPopup</code> given its owner,
* contents and the screen position where the popup
* will appear.
*
* @param owner the Component to which <code>x</code> and
* <code>y</code> are relative, or <code>null</code> for
* placing the popup relative to the origin of the screen.
*
* @param contents the contents that will be displayed inside
* the <code>Popup</code>.
*
* @param x the horizontal position where the Popup will appear.
*
* @param y the vertical position where the Popup will appear.
*
* @throws IllegalArgumentException if <code>contents</code>
* is <code>null</code>.
*/
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&#x2019;s <code>JWindow</code> on the screen.
* Nothing happens if it is already visible.
*/
public void show()
{
window.show();
}
/**
* Removes the popup&#x2019;s <code>JWindow</code> 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();
}
}
}

View File

@ -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 <code>Popup</code> 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 <code>PopupFactory</code>. Usually, a single
* <code>PopupFactory</code> is shared among multiple consumers
* of <code>Popup</code>. 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 <code>factory</code>
* is <code>null</code>.
*/
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 <code>PopupFactory</code> that can be used
* to create <code>Popup</code> 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 <code>Popup</code> given its owner,
* contents and the screen position where the popup
* will appear.
*
* @param owner the Component to which <code>x</code> and
* <code>y</code> are relative, or <code>null</code> for
* placing the popup relative to the origin of the screen.
*
* @param contents the contents that will be displayed inside
* the <code>Popup</code>.
*
* @param x the horizontal position where the Popup will appear.
*
* @param y the vertical position where the Popup will appear.
*
* @throws IllegalArgumentException if <code>contents</code>
* is <code>null</code>.
*/
public Popup getPopup(Component owner, Component contents,
int x, int y)
{
return new Popup.JWindowPopup(owner, contents, x, y);
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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 <code>JInternalFrameEvent</code> object.

View File

@ -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;

View File

@ -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;

View File

@ -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 <code>JPopupMenu</code>.
*
* @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()
public abstract class PopupMenuUI
extends ComponentUI
{
/**
* Constructs a new <code>PopupMenuUI</code>.
*/
public PopupMenuUI()
{
}
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* isPopupTrigger
* @param event TODO
* @returns boolean
*/
public boolean isPopupTrigger(MouseEvent event) {
return false; // TODO
} // isPopupTrigger()
/**
* Tests whether or not a mouse event triggers a popup menu.
*
* <p>The default implementation calls
* <code>event.isPopupTrigger()</code>, 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 <code>true</code> if the event triggers a popup menu;
* <code>false</code> otherwise.
*
* @since 1.3
*/
public boolean isPopupTrigger(MouseEvent event)
{
return event.isPopupTrigger();
}
} // PopupMenuUI
/**
* Creates a <code>Popup</code> for displaying the popup menu. The
* default implementation uses the {@link javax.swing.PopupFactory}
* for retrieving a suitable <code>Popup</code>, but subclasses
* might want to override this method if a LookAndFeel needs special
* Popups.
*
* @param popup the <code>JPopupMenu</code> for whose display
* a <code>Popup</code> 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 <code>Popup</code> 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);
}
}

View File

@ -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 <code>JSplitPane</code>.
*
* @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()
public abstract class SplitPaneUI
extends ComponentUI
{
/**
* Constructs a new <code>SplitPaneUI</code>.
*/
public 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);
/**
* Moves the divider to the location which best respects
* the preferred sizes of the children.
*
* @param pane the <code>JSplitPane</code> for thich this
* delegate provides the look and feel.
*/
public abstract void resetToPreferredSizes(JSplitPane pane);
} // SplitPaneUI
/**
* Moves the divider to the specified location.
*
* @param pane the <code>JSplitPane</code> 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 <code>JSplitPane</code> 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 <code>JSplitPane</code> 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 <code>JSplitPane</code> 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 <code>JSplitPane</code> after it has finished
* painting its children.
*
* @param pane the <code>JSplitPane</code> for thich this
* delegate provides the look and feel.
*
* @param g the Graphics used for painting.
*/
public abstract void finishedPaintingChildren(JSplitPane pane,
Graphics g);
}

View File

@ -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 <code>JTabbedPane</code>.
*
* @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;
}
/**
* Constructs a new <code>TabbedPaneUI</code>.
*/
public TabbedPaneUI()
{
}
/**
* Determines which tab lies at a given position.
*
* @param pane the <code>JTabbedPane</code> for which this
* delegate object provides the user interface.
*
* @param x the horizontal position, where zero is the left
* edge of <code>pane</code>.
*
* @param y the vertical position, where zero is the top
* edge of <code>pane</code>.
*
* @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);
public int getTabRunCount(JTabbedPane pane)
{
return 0;
}
/**
* Calculates the bounding box of a tab.
*
* @param pane the <code>JTabbedPane</code> for which this
* delegate object provides the user interface.
*
* @param index the index of the tab, which must be an integer
* in the range <code>[0 .. pane.getTabCount() - 1]</code>.
*
* @return the bounding box of the <code>index</code>-th tab,
* in the coordinate system of <code>pane</code>.
*/
public abstract Rectangle getTabBounds(JTabbedPane pane, int index);
public int tabForCoordinate(JTabbedPane pane, int x, int y)
{
return 0;
}
/**
* Determines how many runs are used to display tabs.
*
* @param pane the <code>JTabbedPane</code> 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);
}

View File

@ -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 <code>TextUI</code>.
*/
public TextUI()
{
}
/**
* Calculates the geometric extent of the character at the
* given offset.
*
* @param tc the <code>JTextComponent</code> 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
* <code>pos</code>, in view coordinates.
*
* @throws BadLocationException if <code>pos</code> 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 <code>JTextComponent</code> 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 <code>pos</code>. 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
* <code>pos</code>, in view coordinates.
*
* @throws BadLocationException if <code>pos</code> 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 <code>JTextComponent</code> for which this
* delegate object provides the user interface.
*
* @param loc the position in view coordinates.
*
* @return the caret position which is closest to <code>loc</code>.
*
* @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 <code>JTextComponent</code> 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, <code>outBias[0]</code> will indicate
* whether <code>loc</code> is in the glyph before
* (<code>Position.Bias.Backward</code>) or after
* (<code>Position.Bias.Forward</code>) the returned
* caret position.
*
* @return the caret position which is closest to <code>loc</code>.
*/
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 <code>JTextComponent</code> 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 <code>pos</code>. 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 <code>pos</code> does not
* designate a valid position in the document model.
*
* @throws IllegalArgumentException if <code>direction</code>
* is not one of <code>Position.Bias.Forward</code>
* or <code>Position.Biad.Backward</code>.
*/
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 <code>JTextComponent</code> 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.
* <code>end</code> must be greater than or equal to
* <code>start</code>.
*/
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 <code>JTextComponent</code> 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.
* <code>end</code> must be greater than or equal to
* <code>start</code>.
*/
public abstract void damageRange(JTextComponent tc,
int start, int end,
Position.Bias startBias,
Position.Bias endBias);
/**
* Retrieves the <code>EditorKit</code> managing policies and
* persistent state.
*
* @param tc the <code>JTextComponent</code> for which this
* delegate object provides the user interface.
*
* @return the <code>EditorKit</code> used by <code>tc</code>.
*/
public abstract EditorKit getEditorKit(JTextComponent tc);
/**
* Retrieves the root of the view tree that visually presents
* the text.
*
* @param tc the <code>JTextComponent</code> for which this
* delegate object provides the user interface.
*
* @return the root <code>View</code> used by <code>tc</code>.
*/
public abstract View getRootView(JTextComponent tc);
/**
* Returns a String for presenting a tool tip at the specified
* location.
*
* @param tc the <code>JTextComponent</code> 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 <code>null</code> to
* display no tool tip.
*
* @since 1.4
*/
public String getToolTipText(JTextComponent tc, Point loc)
{
return null;
}
}

View File

@ -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 <code>JTree</code>.
*
* @see javax.swing.JTree
*
* @author Sascha Brawer (brawer@dandelis.ch)
*/
public abstract class TreeUI
extends ComponentUI
{
/**
* Constructs a new <code>TreeUI</code>.
*/
public TreeUI()
{
}
/**
* Determines the geometric extent of the label that is
* drawn for a path.
*
* @param tree the <code>JTree</code> 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 <code>null</code>
* if <code>path</code> contains invalid nodes.
*/
public abstract Rectangle getPathBounds(JTree tree, TreePath path);
/**
* Creates a <code>TreePath</code> for the specified row.
*
* @param tree the <code>JTree</code> for which this delegate
* object provides the user interface.
*
* @param row the index of the row, which should be a number
* in the range <code>[0, getRowCount(tree) - 1]</code>.
*
* @return a <code>TreePath</code> for the specified row, or
* <code>null</code> if <code>row</code> is outside
* the valid range.
*/
public abstract TreePath getPathForRow(JTree tree, int row);
/**
* Determines in which row a <code>TreePath</code> is currently
* being displayed.
*
* @param tree the <code>JTree</code> 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 <code>[0, getRowCount(tree)
* - 1]</code> if the path is currently on display;
* <code>-1</code> 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 <code>JTree</code> 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.
*
* <p><img src="TreeUI-1.png" width="300" height="250"
* alt="[A screen shot of a JTree] />
*
* <p>As shown by the above illustration, the bounds of the
* closest path do not necessarily need to contain the passed
* location.
*
* @param tree the <code>JTree</code> for which this delegate
* object provides the user interface.
*
* @param x the horizontal location, relative to the origin
* of <code>tree</code>.
*
* @param y the vertical location, relative to the origin
* of <code>tree</code>.
*
* @return the closest path, or <code>null</code> if the
* tree is currenlty not displaying any paths at all.
*/
public abstract TreePath getClosestPathForLocation(JTree tree,
int x, int y);
/**
* Determines whether the user is currently editing a tree cell.
*
* @param tree the <code>JTree</code> for which this delegate
* object provides the user interface.
*
* @see #getEditingPath
*/
public abstract boolean isEditing(JTree tree);
/**
* Stops editing a tree cell, committing the entered value into the
* tree&#x2019;s model. If no editing session is active, or if the
* active editor does not agree to stopping, nothing happens. In
* some look and feels, this action happens when the user has
* pressed the enter key.
*
* @param tree the <code>JTree</code> for which this delegate
* object provides the user interface.
*
* @return <code>false</code> if the editing still goes on because
* the cell editor has objected to stopping the session;
* <code>true</code> if editing has been stopped.
*/
public abstract boolean stopEditing(JTree tree);
/**
* Cancels editing a tree cell, discarding any entered value.
* If no editing session is active, nothing happens. The cell
* editor is not given an opportunity to veto the canceling.
* In some look and feels, this action happens when the user has
* pressed the escape key.
*
* @param tree the <code>JTree</code> for which this delegate
* object provides the user interface.
*/
public abstract void cancelEditing(JTree tree);
/**
* Starts a session to edit a tree cell. If the cell editor
* rejects editing the cell, it will just be selected.
*
* @param tree the <code>JTree</code> for which this delegate
* object provides the user interface.
*
* @param path the cell to edit.
*/
public abstract void startEditingAtPath(JTree tree, TreePath path);
/**
* Retrieves the tree cell that is currently being edited.
*
* @return the currently edited path, or <code>null</code>
* if no editing session is currently active.
*/
public abstract TreePath getEditingPath(JTree tree);
}

View File

@ -1,5 +1,5 @@
/* BasicTextUI.java
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -46,10 +46,16 @@ import javax.swing.*;
public class BasicTextUI extends TextUI
{
int gap = 3;
View view = new RootView();
View view = null; // was: new RootView();
Color textColor, disabledTextColor, normalBackgroundColor;
EditorKit kit = new DefaultEditorKit();
/* *****************************************************************
* This View is way too incomplete to be of any use. To avoid errors
* when compiling with the Sun JDK, it has been commented out.
* -- Sascha Brawer (brawer@dandelis.ch)
*
* (begin of commented out section)
class RootView extends View
{
RootView()
@ -68,6 +74,8 @@ public class BasicTextUI extends TextUI
}
}
}
* (end of commented out section)
*************************************************************** */
public BasicTextUI()
{
@ -128,6 +136,7 @@ public class BasicTextUI extends TextUI
Position.Bias b,
int direction,
Position.Bias[] biasRet)
throws BadLocationException
{
return 0;
}
@ -138,11 +147,13 @@ public class BasicTextUI extends TextUI
}
public Rectangle modelToView(JTextComponent t, int pos)
throws BadLocationException
{
return modelToView(t, pos, null);
}
public Rectangle modelToView(JTextComponent t, int pos, Position.Bias bias)
throws BadLocationException
{
return null;
}

View File

@ -1,5 +1,5 @@
/* BasicTreeUI.java
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -38,8 +38,199 @@ exception statement from your version. */
package javax.swing.plaf.basic;
import javax.swing.plaf.*;
import java.awt.Rectangle;
import javax.swing.JTree;
import javax.swing.plaf.TreeUI;
import javax.swing.tree.TreePath;
public class BasicTreeUI extends TreeUI
/**
* A delegate providing the user interface for <code>JTree</code>
* according to the Basic look and feel. The current implementation
* of GNU Classpath does really work; it is just a stub that allows
* compiling the code.
*
* @see javax.swing.JTree
*
* @author Sascha Brawer (brawer@dandelis.ch)
*/
public class BasicTreeUI
extends TreeUI
{
/**
* Determines the geometric extent of the label that is
* drawn for a path.
*
* @param tree the <code>JTree</code> 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 <code>null</code>
* if <code>path</code> contains invalid nodes.
*/
public Rectangle getPathBounds(JTree tree, TreePath path)
{
return null; // FIXME: not implemented
}
/**
* Creates a <code>TreePath</code> for the specified row.
*
* @param tree the <code>JTree</code> for which this delegate
* object provides the user interface.
*
* @param row the index of the row, which should be a number
* in the range <code>[0, getRowCount(tree) - 1]</code>.
*
* @return a <code>TreePath</code> for the specified row, or
* <code>null</code> if <code>row</code> is outside
* the valid range.
*/
public TreePath getPathForRow(JTree tree, int row)
{
return null; // FIXME: not implemented
}
/**
* Determines in which row a <code>TreePath</code> is currently
* being displayed.
*
* @param tree the <code>JTree</code> 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 <code>[0, getRowCount(tree)
* - 1]</code> if the path is currently on display;
* <code>-1</code> if the path is not shown to the
* user.
*/
public int getRowForPath(JTree tree, TreePath path)
{
return -1; // FIXME: not implemented
}
/**
* Counts how many rows are currently displayed.
*
* @param tree the <code>JTree</code> for which this delegate
* object provides the user interface.
*
* @return the number of visible rows.
*/
public int getRowCount(JTree tree)
{
return 0; // FIXME: not implemented
}
/**
* Finds the path that is closest to the specified position.
*
* <p><img src="../TreeUI-1.png" width="300" height="250"
* alt="[A screen shot of a JTree] />
*
* <p>As shown by the above illustration, the bounds of the
* closest path do not necessarily need to contain the passed
* location.
*
* @param tree the <code>JTree</code> for which this delegate
* object provides the user interface.
*
* @param x the horizontal location, relative to the origin
* of <code>tree</code>.
*
* @param y the vertical location, relative to the origin
* of <code>tree</code>.
*
* @return the closest path, or <code>null</code> if the
* tree is currenlty not displaying any paths at all.
*/
public TreePath getClosestPathForLocation(JTree tree,
int x, int y)
{
return null; // FIXME: not implemented
}
/**
* Determines whether the user is currently editing a tree cell.
*
* @param tree the <code>JTree</code> for which this delegate
* object provides the user interface.
*
* @see #getEditingPath
*/
public boolean isEditing(JTree tree)
{
return false; // FIXME: not implemented
}
/**
* Stops editing a tree cell, committing the entered value into the
* tree&#x2019;s model. If no editing session is active, or if the
* active editor does not agree to stopping, nothing happens. In
* some look and feels, this action happens when the user has
* pressed the enter key.
*
* @param tree the <code>JTree</code> for which this delegate
* object provides the user interface.
*
* @return <code>false</code> if the editing still goes on because
* the cell editor has objected to stopping the session;
* <code>true</code> if editing has been stopped.
*/
public boolean stopEditing(JTree tree)
{
return true; // FIXME: not implemented
}
/**
* Cancels editing a tree cell, discarding any entered value.
* If no editing session is active, nothing happens. The cell
* editor is not given an opportunity to veto the canceling.
* In some look and feels, this action happens when the user has
* pressed the escape key.
*
* @param tree the <code>JTree</code> for which this delegate
* object provides the user interface.
*/
public void cancelEditing(JTree tree)
{
// FIXME: not implemented
}
/**
* Starts a session to edit a tree cell. If the cell editor
* rejects editing the cell, it will just be selected.
*
* @param tree the <code>JTree</code> for which this delegate
* object provides the user interface.
*
* @param path the cell to edit.
*/
public void startEditingAtPath(JTree tree, TreePath path)
{
// FIXME: not implemented
}
/**
* Retrieves the tree cell that is currently being edited.
*
* @return the currently edited path, or <code>null</code>
* if no editing session is currently active.
*/
public TreePath getEditingPath(JTree tree)
{
return null; // FIXME: not implemented
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB