summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorRoman Kennke <roman@kennke.org>2006-07-18 10:23:18 +0000
committerRoman Kennke <roman@kennke.org>2006-07-18 10:23:18 +0000
commitb77b54f200723f26d40e311c81e79b34c2538281 (patch)
tree59853158de787c5f57b64c37fa4753ed1f9143c7 /gnu
parent2adcd44e3754a208201959ff4e01bde1b287884f (diff)
downloadclasspath-b77b54f200723f26d40e311c81e79b34c2538281.tar.gz
2006-07-18 Roman Kennke <kennke@aicas.com>
* gnu/java/awt/peer/x/XDialogPeer.java: New class. * gnu/java/awt/peer/x/XEventPump.java (handleEvent): Cast to XWindowPeer rather than XFramePeer. * gnu/java/awt/peer/x/XFramePeer.java Made a subclass of XWindowPeer, rather than SwingFramePeer. * gnu/java/awt/peer/x/XGraphics.java Made subclass of Graphics rather than Graphics2D. Removed all Graphics2D specific method stubs. (setColor): Map colors using the X color map that is stored in XToolkit. * gnu/java/awt/peer/x/XToolkit.java (colorMap): New field. (getLocalGraphicsEnvironment): Return new XGraphicsEnvironment instance. (createDialog): Implemented. (createImage(ImageProducer)): Implemented. (createImage(InputStream)): Use createImage(ImageProducer) to convert the BufferedImage to an XImage. * gnu/java/awt/peer/x/XWindowPeer.java (XWindowPeer): Removed debug output.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/java/awt/peer/x/XDialogPeer.java61
-rw-r--r--gnu/java/awt/peer/x/XEventPump.java4
-rw-r--r--gnu/java/awt/peer/x/XFramePeer.java249
-rw-r--r--gnu/java/awt/peer/x/XGraphics.java227
-rw-r--r--gnu/java/awt/peer/x/XToolkit.java21
-rw-r--r--gnu/java/awt/peer/x/XWindowPeer.java1
6 files changed, 125 insertions, 438 deletions
diff --git a/gnu/java/awt/peer/x/XDialogPeer.java b/gnu/java/awt/peer/x/XDialogPeer.java
new file mode 100644
index 000000000..45ad24d67
--- /dev/null
+++ b/gnu/java/awt/peer/x/XDialogPeer.java
@@ -0,0 +1,61 @@
+/* XDialogPeer.java -- The peer for AWT dialogs
+ Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 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 gnu.java.awt.peer.x;
+
+import java.awt.Dialog;
+import java.awt.peer.DialogPeer;
+
+public class XDialogPeer
+ extends XWindowPeer
+ implements DialogPeer
+{
+
+ XDialogPeer(Dialog target)
+ {
+ super(target);
+ }
+
+ public void setResizable(boolean resizeable)
+ {
+ }
+
+ public void setTitle(String title)
+ {
+ }
+}
diff --git a/gnu/java/awt/peer/x/XEventPump.java b/gnu/java/awt/peer/x/XEventPump.java
index bd1ef08ce..870edf379 100644
--- a/gnu/java/awt/peer/x/XEventPump.java
+++ b/gnu/java/awt/peer/x/XEventPump.java
@@ -207,9 +207,9 @@ public class XEventPump
System.err.println("Setting size on AWT window: " + c.width()
+ ", " + c.height() + ", " + awtWindow.getWidth()
+ ", " + awtWindow.getHeight());
- ((XFramePeer) awtWindow.getPeer()).callback = true;
+ ((XWindowPeer) awtWindow.getPeer()).callback = true;
awtWindow.setSize(c.width(), c.height());
- ((XFramePeer) awtWindow.getPeer()).callback = false;
+ ((XWindowPeer) awtWindow.getPeer()).callback = false;
}
break;
case Expose.CODE:
diff --git a/gnu/java/awt/peer/x/XFramePeer.java b/gnu/java/awt/peer/x/XFramePeer.java
index 1d34b1a81..439a2a7bb 100644
--- a/gnu/java/awt/peer/x/XFramePeer.java
+++ b/gnu/java/awt/peer/x/XFramePeer.java
@@ -46,56 +46,25 @@ import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Insets;
+import java.awt.MenuBar;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.PaintEvent;
import java.awt.event.WindowEvent;
+import java.awt.peer.FramePeer;
import gnu.java.awt.peer.swing.SwingFramePeer;
import gnu.x11.Window;
import gnu.x11.event.Event;
public class XFramePeer
- extends SwingFramePeer
+ extends XWindowPeer
+ implements FramePeer
{
- private static int standardSelect = Event.BUTTON_PRESS_MASK
- | Event.BUTTON_RELEASE_MASK
- | Event.POINTER_MOTION_MASK
- //| Event.RESIZE_REDIRECT_MASK
- | Event.EXPOSURE_MASK
- //| Event.PROPERTY_CHANGE_MASK
- | Event.STRUCTURE_NOTIFY_MASK
- | Event.KEY_PRESS_MASK
- | Event.KEY_RELEASE_MASK
- ;
-
- /**
- * The X window.
- */
- private Window xwindow;
-
- /**
- * Indicates if we are in callback mode, that is when a property (like size)
- * is changed in reponse to a request from the X server and doesn't need
- * to be propagated back to the X server.
- */
- boolean callback = false;
-
- public XFramePeer(Frame frame)
+ XFramePeer(Frame f)
{
- super(frame);
- XGraphicsDevice dev = XToolkit.getDefaultDevice();
-
- // TODO: Maybe initialize lazily in show().
- int x = Math.max(frame.getX(), 0);
- int y = Math.max(frame.getY(), 0);
- int w = Math.max(frame.getWidth(), 1);
- int h = Math.max(frame.getHeight(), 1);
- xwindow = new Window(dev.getDisplay().default_root, x, y, w, h);
- xwindow.create();
- xwindow.select_input(standardSelect);
- dev.getEventPump().registerWindow(xwindow, frame);
+ super(f);
}
public void setIconImage(Image image)
@@ -104,6 +73,12 @@ public class XFramePeer
throw new UnsupportedOperationException("Not yet implemented.");
}
+ public void setMenuBar(MenuBar mb)
+ {
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
+ }
+
public void setResizable(boolean resizable)
{
// TODO: Implement this.
@@ -124,198 +99,42 @@ public class XFramePeer
public void setState(int state)
{
- // FIXME: Implement this.
+ // TODO: Implement this.
throw new UnsupportedOperationException("Not yet implemented.");
}
public void setMaximizedBounds(Rectangle r)
{
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented.");
- }
-
- public void setBoundsPrivate(int x, int y, int width, int height)
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented.");
- }
-
- public void toBack()
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented.");
- }
-
- public void toFront()
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented.");
- }
-
- public void updateAlwaysOnTop()
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented.");
- }
-
- public boolean requestWindowFocus()
- {
- // FIXME: Implement this.
+ // TODO: Implement this.
throw new UnsupportedOperationException("Not yet implemented.");
}
-
- public Point getLocationOnScreen()
- {
- return new Point(xwindow.x, xwindow.y);
- }
-
+
/**
- * Returns a XGraphics suitable for drawing on this frame.
- *
- * @return a XGraphics suitable for drawing on this frame
+ * Check if this frame peer supports being restacked.
+ *
+ * @return true if this frame peer can be restacked,
+ * false otherwise
+ * @since 1.5
*/
- public Graphics getGraphics()
- {
- return new XGraphics(xwindow);
- }
-
- public Image createImage(int w, int h)
+ public boolean isRestackSupported()
{
- return new XImage(w, h);
- }
-
- /**
- * Sets the visibility state of the component. This is called by
- * {@link Component#setVisible(boolean)}.
- *
- * This is implemented to call setVisible() on the Swing component.
- *
- * @param visible <code>true</code> to make the component visible,
- * <code>false</code> to make it invisible
- */
- public void setVisible(boolean visible)
- {
- if (visible)
- show();
- else
- hide();
- }
-
- /**
- * Makes the component visible. This is called by {@link Component#show()}.
- *
- * This is implemented to call setVisible(true) on the Swing component.
- */
- public void show()
- {
-// // Prevent ResizeRedirect events.
-// //xwindow.select_input(noResizeRedirectSelect);
-// Window.Attributes atts = new Window.Attributes();
-// atts.set_override_redirect(true);
-// xwindow.change_attributes(atts);
-
- // Prevent ResizeRedirect events.
- //xwindow.select_input(Event.NO_EVENT_MASK);
- //xwindow.select_input(noResizeRedirectSelect);
-
- xwindow.map();
- EventQueue eq = XToolkit.getDefaultToolkit().getSystemEventQueue();
- java.awt.Window w = (java.awt.Window) super.awtComponent;
- eq.postEvent(new WindowEvent(w, WindowEvent.WINDOW_OPENED));
- eq.postEvent(new PaintEvent(w, PaintEvent.PAINT,
- new Rectangle(0, 0, w.getWidth(),
- w.getHeight())));
-
-// // Reset input selection.
-// atts.set_override_redirect(false);
-// xwindow.change_attributes(atts);
- }
-
- /**
- * Makes the component invisible. This is called from
- * {@link Component#hide()}.
- *
- * This is implemented to call setVisible(false) on the Swing component.
- */
- public void hide()
- {
- xwindow.unmap();
- }
-
- /**
- * Notifies the peer that the bounds of this component have changed. This
- * is called by {@link Component#reshape(int, int, int, int)}.
- *
- * This is implemented to call setBounds() on the Swing component.
- *
- * @param x the X coordinate of the upper left corner of the component
- * @param y the Y coordinate of the upper left corner of the component
- * @param width the width of the component
- * @param height the height of the component
- */
- public void reshape(int x, int y, int width, int height)
- {
-// if (callback)
-// return;
-
- // Prevent ResizeRedirect events.
-// //xwindow.select_input(noResizeRedirectSelect);
-// Window.Attributes atts = new Window.Attributes();
-// atts.set_override_redirect(true);
-// xwindow.change_attributes(atts);
-
- // Need to substract insets because AWT size is including insets,
- // and X size is excuding insets.
- Insets i = insets();
- xwindow.move_resize(x - i.left, y - i.right, width - i.left - i.right,
- height - i.top - i.bottom);
-
- // Reset input selection.
-// atts = new Window.Attributes();
-// atts.set_override_redirect(false);
-// xwindow.change_attributes(atts);
- }
-
- public Insets insets()
- {
- Insets i = new Insets(0, 0, 0, 0);
-// Window.GeometryReply g = xwindow.geometry();
-// int b = g.border_width();
-// Insets i = new Insets(b, b, b, b);
-// Window.WMSizeHints wmSize = xwindow.wm_normal_hints();
-// if (wmSize != null)
-// {
-// i.left = wmSize.x() - g.x();
-// i.right = wmSize.width() - g.width() - i.left ;
-// i.top = wmSize.y() - g.y();
-// i.bottom = wmSize.height() - g.height() - i.top;
-// }
-// System.err.println("insets: " + i);
- return i;
- }
-
- /**
- * Returns the font metrics for the specified font.
- *
- * @return the font metrics for the specified font
- */
- public FontMetrics getFontMetrics(Font font)
- {
- XFontPeer fontPeer = (XFontPeer) font.getPeer();
- return fontPeer.getFontMetrics(font);
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
}
-
+
/**
- * Unregisters the window in the event pump when it is closed.
+ * Sets the bounds of this frame peer.
+ *
+ * @param x the new x co-ordinate
+ * @param y the new y co-ordinate
+ * @param width the new width
+ * @param height the new height
+ * @since 1.5
*/
- protected void finalize()
+ public void setBoundsPrivate(int x, int y, int width, int height)
{
- XGraphicsDevice dev = XToolkit.getDefaultDevice();
- dev.getEventPump().unregisterWindow(xwindow);
+ // TODO: Implement this.
+ throw new UnsupportedOperationException("Not yet implemented.");
}
- public Rectangle getBounds()
- {
- return new Rectangle(xwindow.x, xwindow.y, xwindow.width, xwindow.height);
- }
}
diff --git a/gnu/java/awt/peer/x/XGraphics.java b/gnu/java/awt/peer/x/XGraphics.java
index a651dcd4c..7c1ceecbc 100644
--- a/gnu/java/awt/peer/x/XGraphics.java
+++ b/gnu/java/awt/peer/x/XGraphics.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.java.awt.peer.x;
+import gnu.x11.Colormap;
import gnu.x11.Drawable;
import gnu.x11.GC;
import gnu.x11.Pixmap;
@@ -49,7 +50,6 @@ import java.awt.Composite;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
-import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.Image;
import java.awt.Paint;
@@ -57,6 +57,7 @@ import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.Shape;
import java.awt.Stroke;
+import java.awt.Toolkit;
import java.awt.RenderingHints.Key;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
@@ -68,10 +69,10 @@ import java.awt.image.ImageProducer;
import java.awt.image.RenderedImage;
import java.awt.image.renderable.RenderableImage;
import java.text.AttributedCharacterIterator;
-import java.util.Map;
+import java.util.HashMap;
public class XGraphics
- extends Graphics2D
+ extends Graphics
implements Cloneable
{
@@ -171,7 +172,18 @@ public class XGraphics
{
if (c != null)
{
- xgc.set_foreground(c.getRGB());
+ XToolkit tk = (XToolkit) Toolkit.getDefaultToolkit();
+ HashMap colorMap = tk.colorMap;
+ gnu.x11.Color col = (gnu.x11.Color) colorMap.get(c);
+ if (col == null)
+ {
+ Colormap map = xdrawable.display.default_colormap;
+ col = map.alloc_color (c.getRed() * 256,
+ c.getGreen() * 256,
+ c.getBlue() * 256);
+ colorMap.put(c, col);
+ }
+ xgc.set_foreground(col);
foreground = c;
}
}
@@ -590,213 +602,6 @@ public class XGraphics
}
}
- // Additional Graphics2D methods.
-
- public void draw(Shape shape)
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public boolean drawImage(Image image, AffineTransform xform, ImageObserver obs)
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public void drawImage(BufferedImage image, BufferedImageOp op, int x, int y)
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public void drawRenderedImage(RenderedImage image, AffineTransform xform)
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public void drawRenderableImage(RenderableImage image, AffineTransform xform)
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public void drawString(String text, float x, float y)
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public void drawString(AttributedCharacterIterator iterator, float x, float y)
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public void fill(Shape shape)
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public boolean hit(Rectangle rect, Shape text, boolean onStroke)
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public GraphicsConfiguration getDeviceConfiguration()
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public void setComposite(Composite comp)
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public void setPaint(Paint paint)
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public void setStroke(Stroke stroke)
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public void setRenderingHint(Key hintKey, Object hintValue)
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public Object getRenderingHint(Key hintKey)
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public void setRenderingHints(Map hints)
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public void addRenderingHints(Map hints)
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public RenderingHints getRenderingHints()
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public void translate(double tx, double ty)
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public void rotate(double theta)
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public void rotate(double theta, double x, double y)
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public void scale(double scaleX, double scaleY)
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public void shear(double shearX, double shearY)
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public void transform(AffineTransform Tx)
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public void setTransform(AffineTransform Tx)
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public AffineTransform getTransform()
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public Paint getPaint()
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public Composite getComposite()
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public void setBackground(Color color)
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public Color getBackground()
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public Stroke getStroke()
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public void clip(Shape s)
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public FontRenderContext getFontRenderContext()
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public void drawGlyphVector(GlyphVector g, float x, float y)
- {
- // FIXME: Implement this.
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
-
// Additional helper methods.
/**
diff --git a/gnu/java/awt/peer/x/XToolkit.java b/gnu/java/awt/peer/x/XToolkit.java
index e1a605693..222e57413 100644
--- a/gnu/java/awt/peer/x/XToolkit.java
+++ b/gnu/java/awt/peer/x/XToolkit.java
@@ -132,6 +132,11 @@ public class XToolkit
static boolean DEBUG = false;
/**
+ * Maps AWT colors to X colors.
+ */
+ HashMap colorMap = new HashMap();
+
+ /**
* The system event queue.
*/
private EventQueue eventQueue;
@@ -160,8 +165,7 @@ public class XToolkit
public GraphicsEnvironment getLocalGraphicsEnvironment()
{
- assert false : "Don't call this";
- return null;
+ return new XGraphicsEnvironment();
}
/**
@@ -286,8 +290,7 @@ public class XToolkit
protected DialogPeer createDialog(Dialog target)
{
- // TODO: Implement this.
- throw new UnsupportedOperationException("Not yet implemented.");
+ return new XDialogPeer(target);
}
protected MenuBarPeer createMenuBar(MenuBar target)
@@ -499,8 +502,10 @@ public class XToolkit
public Image createImage(ImageProducer producer)
{
- // TODO: Implement this.
- throw new UnsupportedOperationException("Not yet implemented.");
+ ImageConverter conv = new ImageConverter();
+ producer.startProduction(conv);
+ Image image = conv.getXImage();
+ return image;
}
public Image createImage(byte[] data, int offset, int len)
@@ -525,10 +530,8 @@ public class XToolkit
BufferedImage buffered = ImageIO.read(i);
if (buffered != null)
{
- ImageConverter conv = new ImageConverter();
ImageProducer source = buffered.getSource();
- source.startProduction(conv);
- image = conv.getXImage();
+ image = createImage(source);
}
else
{
diff --git a/gnu/java/awt/peer/x/XWindowPeer.java b/gnu/java/awt/peer/x/XWindowPeer.java
index f4815ce7f..28cc5a5ed 100644
--- a/gnu/java/awt/peer/x/XWindowPeer.java
+++ b/gnu/java/awt/peer/x/XWindowPeer.java
@@ -85,7 +85,6 @@ public class XWindowPeer
XWindowPeer(java.awt.Window window)
{
super(window);
- System.err.println("new XWindowPeer");
XGraphicsDevice dev = XToolkit.getDefaultDevice();
// TODO: Maybe initialize lazily in show().