Makefile.am (gtk_awt_peer_sources): Add gnu/java/awt/peer/GLightweightPeer.java.

2003-08-21  Scott Gilbertson  <scottg@mantatest.com>
            Thomas Fitzsimmons  <fitzsim@redhat.com>

	* Makefile.am (gtk_awt_peer_sources): Add
	gnu/java/awt/peer/GLightweightPeer.java.  Remove
	gnu/java/awt/GLightweightPeer.java.
	* gnu/java/awt/GLightweightPeer.java: Remove file.
	* gnu/java/awt/peer/GLightweightPeer.java: New file.
	* java/awt/Component.java (getToolkit): Add comment about
	lightweight components.
	* java/awt/Toolkit.java (createComponent): Return
	gnu.java.awt.peer.GLightweightPeer.

Co-Authored-By: Thomas Fitzsimmons <fitzsim@redhat.com>

From-SVN: r70657
This commit is contained in:
Scott Gilbertson 2003-08-21 18:39:56 +00:00 committed by Thomas Fitzsimmons
parent eb84999398
commit c79c6c5b9e
9 changed files with 168 additions and 105 deletions

View file

@ -1,4 +1,5 @@
/* Copyright (C) 2000, 2002 Free Software Foundation
/* GLightweightPeer.java --
Copyright (C) 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -34,34 +35,109 @@ 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 gnu.java.awt;
package gnu.java.awt.peer;
import java.awt.*;
import java.awt.AWTEvent;
import java.awt.AWTException;
import java.awt.BufferCapabilities;
import java.awt.Color;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.PaintEvent;
import java.awt.peer.*;
import java.awt.image.*;
import java.awt.image.ColorModel;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.awt.image.VolatileImage;
import java.awt.peer.ContainerPeer;
import java.awt.peer.LightweightPeer;
/*
* Another possible implementation strategy for lightweight peers is
* to make GLightweightPeer a placeholder class that implements
* LightweightPeer. Then the Component and Container classes could
* identify a peer as lightweight and handle it specially. The
* current approach is probably more clear but less efficient.
*/
/**
* @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
* A stub class that implements the ComponentPeer and ContainerPeer
* interfaces using callbacks into the Component and Container
* classes. GLightweightPeer allows the Component and Container
* classes to treat lightweight and heavyweight peers in the same way.
*
* Lightweight components are painted directly onto their parent
* containers through an Image object provided by the toolkit.
*/
public class GLightweightPeer implements LightweightPeer
public class GLightweightPeer
implements LightweightPeer, ContainerPeer
{
public static final GLightweightPeer INSTANCE = new GLightweightPeer();
private Component comp;
public GLightweightPeer() {}
private Insets containerInsets;
public GLightweightPeer(Component comp)
{
this.comp = comp;
}
// -------- java.awt.peer.ContainerPeer implementation:
public Insets insets()
{
return getInsets ();
}
public Insets getInsets()
{
if (containerInsets == null)
containerInsets = new Insets (0,0,0,0);
return containerInsets;
}
public void beginValidate()
{
}
public void endValidate()
{
}
public void beginLayout()
{
}
public void endLayout()
{
}
public boolean isPaintPending()
{
return false;
}
// -------- java.awt.peer.ComponentPeer implementation:
public int checkImage(Image img, int width, int height, ImageObserver o)
{
return 0;
return comp.getToolkit().checkImage(img, width, height, o);
}
public Image createImage(ImageProducer prod)
{
return null;
return comp.getToolkit().createImage(prod);
}
/* This method is not called. */
public Image createImage(int width, int height)
{
return null;
@ -77,12 +153,14 @@ public class GLightweightPeer implements LightweightPeer
{
return null;
}
public FontMetrics getFontMetrics(Font f)
{
return null;
return comp.getToolkit().getFontMetrics(f);
}
/* Returning null here tells the Component object that called us to
* use its parent's Graphics. */
public Graphics getGraphics()
{
return null;
@ -90,19 +168,25 @@ public class GLightweightPeer implements LightweightPeer
public Point getLocationOnScreen()
{
return null;
Point parentLocation = comp.getParent().getLocationOnScreen();
return new Point (parentLocation.x + comp.getX(),
parentLocation.y + comp.getY());
}
public Dimension getMinimumSize()
{
return null;
return new Dimension(comp.getWidth(), comp.getHeight());
}
/* A lightweight component's preferred size is equivalent to its
* Component width and height values. */
public Dimension getPreferredSize()
{
return null;
return new Dimension(comp.getWidth(), comp.getHeight());
}
/* Returning null here tells the Component object that called us to
* use its parent's Toolkit. */
public Toolkit getToolkit()
{
return null;
@ -124,12 +208,12 @@ public class GLightweightPeer implements LightweightPeer
public Dimension minimumSize()
{
return null;
return getMinimumSize();
}
public Dimension preferredSize()
{
return null;
return getPreferredSize();
}
public void paint(Graphics graphics) {}
@ -137,7 +221,7 @@ public class GLightweightPeer implements LightweightPeer
public boolean prepareImage(Image img, int width, int height,
ImageObserver o)
{
return false;
return comp.getToolkit().prepareImage(img, width, height, o);
}
public void print(Graphics graphics) {}
@ -146,13 +230,16 @@ public class GLightweightPeer implements LightweightPeer
public void requestFocus() {}
public boolean requestFocus(java.awt.Component source, boolean bool1, boolean bool2, long x) { return false; }
public boolean requestFocus(Component source, boolean bool1, boolean bool2, long x)
{
return false;
}
public void reshape(int x, int y, int width, int height) {}
public void setBackground(Color color) {}
public void setBounds(int x, int y, int width, int height) {}
public void setBounds(int x, int y, int width, int height) { }
public void setCursor(Cursor cursor) {}
@ -170,12 +257,18 @@ public class GLightweightPeer implements LightweightPeer
public ColorModel getColorModel ()
{
return null;
return comp.getColorModel ();
}
public boolean isObscured() { return false; }
public boolean isObscured()
{
return false;
}
public boolean canDetermineObscurity() { return false; }
public boolean canDetermineObscurity()
{
return false;
}
public void coalescePaintEvent(PaintEvent e) { }
@ -186,14 +279,20 @@ public class GLightweightPeer implements LightweightPeer
return null;
}
public boolean handlesWheelScrolling() { return false; }
public boolean handlesWheelScrolling()
{
return false;
}
public void createBuffers(int x, java.awt.BufferCapabilities capabilities)
throws java.awt.AWTException { }
public void createBuffers(int x, BufferCapabilities capabilities)
throws AWTException { }
public java.awt.Image getBackBuffer() { return null; }
public Image getBackBuffer()
{
return null;
}
public void flip(java.awt.BufferCapabilities.FlipContents contents) { }
public void flip(BufferCapabilities.FlipContents contents) { }
public void destroyBuffers() { }
}