From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- libjava/gnu/awt/LightweightRedirector.h | 51 ++ libjava/gnu/awt/LightweightRedirector.java | 183 +++++++ libjava/gnu/awt/j2d/AbstractGraphicsState.h | 90 ++++ libjava/gnu/awt/j2d/AbstractGraphicsState.java | 141 +++++ libjava/gnu/awt/j2d/DirectRasterGraphics.h | 71 +++ libjava/gnu/awt/j2d/DirectRasterGraphics.java | 85 +++ libjava/gnu/awt/j2d/Graphics2DImpl.h | 157 ++++++ libjava/gnu/awt/j2d/Graphics2DImpl.java | 545 +++++++++++++++++++ .../j2d/IntegerGraphicsState$ScreenCoupledImage.h | 39 ++ libjava/gnu/awt/j2d/IntegerGraphicsState.h | 94 ++++ libjava/gnu/awt/j2d/IntegerGraphicsState.java | 427 +++++++++++++++ libjava/gnu/awt/j2d/MappedRaster.h | 49 ++ libjava/gnu/awt/j2d/MappedRaster.java | 72 +++ libjava/gnu/awt/xlib/XCanvasPeer$DoMap.h | 43 ++ libjava/gnu/awt/xlib/XCanvasPeer.h | 164 ++++++ libjava/gnu/awt/xlib/XCanvasPeer.java | 600 +++++++++++++++++++++ libjava/gnu/awt/xlib/XEventLoop.h | 75 +++ libjava/gnu/awt/xlib/XEventLoop.java | 274 ++++++++++ libjava/gnu/awt/xlib/XEventQueue.h | 50 ++ libjava/gnu/awt/xlib/XEventQueue.java | 99 ++++ libjava/gnu/awt/xlib/XFontMetrics.h | 54 ++ libjava/gnu/awt/xlib/XFontMetrics.java | 47 ++ libjava/gnu/awt/xlib/XFontPeer.h | 73 +++ libjava/gnu/awt/xlib/XFontPeer.java | 277 ++++++++++ libjava/gnu/awt/xlib/XFramePeer.h | 89 +++ libjava/gnu/awt/xlib/XFramePeer.java | 248 +++++++++ libjava/gnu/awt/xlib/XGraphics$XRaster.h | 53 ++ libjava/gnu/awt/xlib/XGraphics.h | 92 ++++ libjava/gnu/awt/xlib/XGraphics.java | 305 +++++++++++ ...n$FontMetricsCache$PerDisplayCache$CacheEntry.h | 46 ++ ...onfiguration$FontMetricsCache$PerDisplayCache.h | 49 ++ .../xlib/XGraphicsConfiguration$FontMetricsCache.h | 52 ++ libjava/gnu/awt/xlib/XGraphicsConfiguration.h | 103 ++++ libjava/gnu/awt/xlib/XGraphicsConfiguration.java | 550 +++++++++++++++++++ libjava/gnu/awt/xlib/XGraphicsDevice.h | 53 ++ libjava/gnu/awt/xlib/XGraphicsDevice.java | 58 ++ libjava/gnu/awt/xlib/XGraphicsEnvironment.h | 60 +++ libjava/gnu/awt/xlib/XGraphicsEnvironment.java | 59 ++ libjava/gnu/awt/xlib/XOffScreenImage.h | 87 +++ libjava/gnu/awt/xlib/XOffScreenImage.java | 280 ++++++++++ libjava/gnu/awt/xlib/XPanelPeer.h | 50 ++ libjava/gnu/awt/xlib/XPanelPeer.java | 61 +++ libjava/gnu/awt/xlib/XToolkit.h | 214 ++++++++ libjava/gnu/awt/xlib/XToolkit.java | 502 +++++++++++++++++ 44 files changed, 6771 insertions(+) create mode 100644 libjava/gnu/awt/LightweightRedirector.h create mode 100644 libjava/gnu/awt/LightweightRedirector.java create mode 100644 libjava/gnu/awt/j2d/AbstractGraphicsState.h create mode 100644 libjava/gnu/awt/j2d/AbstractGraphicsState.java create mode 100644 libjava/gnu/awt/j2d/DirectRasterGraphics.h create mode 100644 libjava/gnu/awt/j2d/DirectRasterGraphics.java create mode 100644 libjava/gnu/awt/j2d/Graphics2DImpl.h create mode 100644 libjava/gnu/awt/j2d/Graphics2DImpl.java create mode 100644 libjava/gnu/awt/j2d/IntegerGraphicsState$ScreenCoupledImage.h create mode 100644 libjava/gnu/awt/j2d/IntegerGraphicsState.h create mode 100644 libjava/gnu/awt/j2d/IntegerGraphicsState.java create mode 100644 libjava/gnu/awt/j2d/MappedRaster.h create mode 100644 libjava/gnu/awt/j2d/MappedRaster.java create mode 100644 libjava/gnu/awt/xlib/XCanvasPeer$DoMap.h create mode 100644 libjava/gnu/awt/xlib/XCanvasPeer.h create mode 100644 libjava/gnu/awt/xlib/XCanvasPeer.java create mode 100644 libjava/gnu/awt/xlib/XEventLoop.h create mode 100644 libjava/gnu/awt/xlib/XEventLoop.java create mode 100644 libjava/gnu/awt/xlib/XEventQueue.h create mode 100644 libjava/gnu/awt/xlib/XEventQueue.java create mode 100644 libjava/gnu/awt/xlib/XFontMetrics.h create mode 100644 libjava/gnu/awt/xlib/XFontMetrics.java create mode 100644 libjava/gnu/awt/xlib/XFontPeer.h create mode 100644 libjava/gnu/awt/xlib/XFontPeer.java create mode 100644 libjava/gnu/awt/xlib/XFramePeer.h create mode 100644 libjava/gnu/awt/xlib/XFramePeer.java create mode 100644 libjava/gnu/awt/xlib/XGraphics$XRaster.h create mode 100644 libjava/gnu/awt/xlib/XGraphics.h create mode 100644 libjava/gnu/awt/xlib/XGraphics.java create mode 100644 libjava/gnu/awt/xlib/XGraphicsConfiguration$FontMetricsCache$PerDisplayCache$CacheEntry.h create mode 100644 libjava/gnu/awt/xlib/XGraphicsConfiguration$FontMetricsCache$PerDisplayCache.h create mode 100644 libjava/gnu/awt/xlib/XGraphicsConfiguration$FontMetricsCache.h create mode 100644 libjava/gnu/awt/xlib/XGraphicsConfiguration.h create mode 100644 libjava/gnu/awt/xlib/XGraphicsConfiguration.java create mode 100644 libjava/gnu/awt/xlib/XGraphicsDevice.h create mode 100755 libjava/gnu/awt/xlib/XGraphicsDevice.java create mode 100644 libjava/gnu/awt/xlib/XGraphicsEnvironment.h create mode 100755 libjava/gnu/awt/xlib/XGraphicsEnvironment.java create mode 100644 libjava/gnu/awt/xlib/XOffScreenImage.h create mode 100644 libjava/gnu/awt/xlib/XOffScreenImage.java create mode 100644 libjava/gnu/awt/xlib/XPanelPeer.h create mode 100644 libjava/gnu/awt/xlib/XPanelPeer.java create mode 100644 libjava/gnu/awt/xlib/XToolkit.h create mode 100644 libjava/gnu/awt/xlib/XToolkit.java (limited to 'libjava/gnu/awt') diff --git a/libjava/gnu/awt/LightweightRedirector.h b/libjava/gnu/awt/LightweightRedirector.h new file mode 100644 index 000000000..03474c0da --- /dev/null +++ b/libjava/gnu/awt/LightweightRedirector.h @@ -0,0 +1,51 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __gnu_awt_LightweightRedirector__ +#define __gnu_awt_LightweightRedirector__ + +#pragma interface + +#include +#include + +extern "Java" +{ + namespace gnu + { + namespace awt + { + class LightweightRedirector; + } + } + namespace java + { + namespace awt + { + class AWTEvent; + class Component; + namespace event + { + class InputEvent; + class MouseEvent; + } + } + } +} + +class gnu::awt::LightweightRedirector : public ::java::lang::Object +{ + +public: + LightweightRedirector(); + virtual ::java::awt::AWTEvent * redirect(::java::awt::AWTEvent *); +public: // actually package-private + virtual ::java::awt::event::MouseEvent * redirectMouse(::java::awt::event::MouseEvent *); + virtual jint getButtonNumber(::java::awt::event::InputEvent *); + static const jint LAST_BUTTON_NUMBER = 3; + JArray< ::java::awt::Component * > * __attribute__((aligned(__alignof__( ::java::lang::Object)))) releaseTargets; +public: + static ::java::lang::Class class$; +}; + +#endif // __gnu_awt_LightweightRedirector__ diff --git a/libjava/gnu/awt/LightweightRedirector.java b/libjava/gnu/awt/LightweightRedirector.java new file mode 100644 index 000000000..41dc12427 --- /dev/null +++ b/libjava/gnu/awt/LightweightRedirector.java @@ -0,0 +1,183 @@ +/* Copyright (C) 2000 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.awt; + +import java.awt.AWTEvent; +import java.awt.AWTError; +import java.awt.Component; +import java.awt.Container; +import java.awt.event.MouseEvent; +import java.awt.event.InputEvent; + +/** + * Encapsulates the logic required to dispatch events to the correct + * component in a component tree that may contain lightweight + * components. Toolkits typically only identify heavyweight components + * as the source of events. This class redirects the events to the + * appropriate lightweight children of the heavyweight component. + */ +public class LightweightRedirector +{ + final static int LAST_BUTTON_NUMBER = 3; + + /* We sacrifice one array element to allow the button number to + match the index of this array. */ + Component[] releaseTargets = new Component[LAST_BUTTON_NUMBER+1]; + + /** + * + * Modifies or replaces the given event with an event that has been + * properly redirected. State of button presses are kept so that + * button releases can be redirected to the same component as the + * button press. It is required that all events are sent through + * this method in chronological order. + */ + public AWTEvent redirect(AWTEvent event) + { + if (event instanceof MouseEvent) + return redirectMouse((MouseEvent) event); + + /* In case we don't know how to redirect the event, simply return + the event unchanged. */ + return event; + } + + MouseEvent redirectMouse(MouseEvent event) + { + int button = getButtonNumber(event); + int id = event.getID(); + + Component heavySource = (Component) event.getSource(); + Component source = heavySource; + int x = event.getX(); + int y = event.getY(); + + if (id == MouseEvent.MOUSE_RELEASED) + { + Component target = releaseTargets[button]; + + if (target != null) + { + releaseTargets[button] = null; + source = target; + + Component child = source; + while (child != heavySource) + { + x -= child.getX(); + y -= child.getY(); + child = child.getParent(); + if (child == null) + System.err.println("warning, orphaned release target"); + } + } + } + else + { + /* Find real component, and adjust source, x and y + accordingly. */ + + while (true) + { + Component parent = source; + + Component child = parent.getComponentAt(x, y); + + if (parent == child) + break; + + // maybe ignoring would be better? + if (child == null) + { + String msg = "delivered event not within component. " + + "Heavyweight source was " + heavySource + ". " + + "Component was " + parent; + throw new AWTError(msg); + } + if (child.isLightweight()) + { + // descend down to child + source = child; + x -= child.getX(); + y -= child.getY(); + } + else + { + System.err.println("warning: event delivered to wrong " + + "heavyweight component. Was " + + "delivered to " + source + ". " + + "Should have been delivered to " + + child + ". Maybe the native window " + + "system is bubbling events up the " + + "containment hierarchy."); + break; + } + } + + /* ensure that the release event is delivered to the same + component as the press event. For most toolkits this is + only necessary for lightweight components, since the + underlying windowing system takes care of its heavyweight + components. */ + if (id == MouseEvent.MOUSE_PRESSED) + releaseTargets[button] = source; + } + + + if (source == heavySource) + return event; // no change in event + + // print warning for heavyweights + /* this warning can safely be removed if a toolkit that + needs heavyweight redirection support is ever created. */ + if (!source.isLightweight()) + System.err.println("warning: redirecting to heavyweight"); + + MouseEvent redirected = new MouseEvent(source, event.getID(), + event.getWhen(), + event.getModifiersEx(), + x, y, + event.getClickCount(), + event.isPopupTrigger()); + + return redirected; + } + + /** + * Identifies the button number for an input event. + * + * @returns the button number, or 0 if no button modifier was set + * for the event. + */ + int getButtonNumber(InputEvent event) + { + int modifiers = event.getModifiersEx(); + + modifiers &= + InputEvent.BUTTON1_DOWN_MASK | + InputEvent.BUTTON2_DOWN_MASK | + InputEvent.BUTTON3_DOWN_MASK; + + switch (modifiers) + { + case InputEvent.BUTTON1_DOWN_MASK: + return 1; + case InputEvent.BUTTON2_DOWN_MASK: + return 2; + case InputEvent.BUTTON3_DOWN_MASK: + return 3; + case 0: + return 0; + + default: + System.err.println("FIXME: multibutton event"); + return 0; + } + } +} diff --git a/libjava/gnu/awt/j2d/AbstractGraphicsState.h b/libjava/gnu/awt/j2d/AbstractGraphicsState.h new file mode 100644 index 000000000..973d9106a --- /dev/null +++ b/libjava/gnu/awt/j2d/AbstractGraphicsState.h @@ -0,0 +1,90 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __gnu_awt_j2d_AbstractGraphicsState__ +#define __gnu_awt_j2d_AbstractGraphicsState__ + +#pragma interface + +#include +#include + +extern "Java" +{ + namespace gnu + { + namespace awt + { + namespace j2d + { + class AbstractGraphicsState; + class Graphics2DImpl; + } + } + } + namespace java + { + namespace awt + { + class Color; + class Font; + class FontMetrics; + class Image; + class Rectangle; + class Shape; + namespace image + { + class ImageObserver; + } + } + } +} + +class gnu::awt::j2d::AbstractGraphicsState : public ::java::lang::Object +{ + +public: + AbstractGraphicsState(); + virtual void setFrontend(::gnu::awt::j2d::Graphics2DImpl *); + virtual void dispose(); + virtual void setColor(::java::awt::Color *) = 0; + virtual void setPaintMode() = 0; + virtual void setXORMode(::java::awt::Color *) = 0; + virtual void setFont(::java::awt::Font *) = 0; + virtual ::java::awt::FontMetrics * getFontMetrics(::java::awt::Font *) = 0; + virtual void setClip(::java::awt::Shape *) = 0; + virtual ::java::awt::Shape * getClip() = 0; + virtual ::java::awt::Rectangle * getClipBounds() = 0; + virtual void copyArea(jint, jint, jint, jint, jint, jint) = 0; + virtual void drawLine(jint, jint, jint, jint) = 0; + virtual void fillRect(jint, jint, jint, jint) = 0; + virtual void clearRect(jint, jint, jint, jint) = 0; + virtual void drawRoundRect(jint, jint, jint, jint, jint, jint) = 0; + virtual void fillRoundRect(jint, jint, jint, jint, jint, jint) = 0; + virtual void drawOval(jint, jint, jint, jint) = 0; + virtual void fillOval(jint, jint, jint, jint) = 0; + virtual void drawArc(jint, jint, jint, jint, jint, jint) = 0; + virtual void fillArc(jint, jint, jint, jint, jint, jint) = 0; + virtual void drawPolyline(JArray< jint > *, JArray< jint > *, jint) = 0; + virtual void drawPolygon(JArray< jint > *, JArray< jint > *, jint) = 0; + virtual void fillPolygon(JArray< jint > *, JArray< jint > *, jint) = 0; + virtual jboolean drawImage(::java::awt::Image *, jint, jint, ::java::awt::image::ImageObserver *) = 0; + virtual void draw(::java::awt::Shape *) = 0; + virtual void fill(::java::awt::Shape *) = 0; + virtual jboolean hit(::java::awt::Rectangle *, ::java::awt::Shape *, jboolean) = 0; + virtual void drawString(::java::lang::String *, jint, jint) = 0; + virtual void drawString(::java::lang::String *, jfloat, jfloat) = 0; + virtual void translate(jint, jint) = 0; + virtual void translate(jdouble, jdouble) = 0; + virtual void rotate(jdouble) = 0; + virtual void rotate(jdouble, jdouble, jdouble) = 0; + virtual void scale(jdouble, jdouble) = 0; + virtual void shear(jdouble, jdouble) = 0; + virtual ::java::lang::Object * clone(); +public: // actually package-private + ::gnu::awt::j2d::Graphics2DImpl * __attribute__((aligned(__alignof__( ::java::lang::Object)))) frontend; +public: + static ::java::lang::Class class$; +}; + +#endif // __gnu_awt_j2d_AbstractGraphicsState__ diff --git a/libjava/gnu/awt/j2d/AbstractGraphicsState.java b/libjava/gnu/awt/j2d/AbstractGraphicsState.java new file mode 100644 index 000000000..038bc9c6c --- /dev/null +++ b/libjava/gnu/awt/j2d/AbstractGraphicsState.java @@ -0,0 +1,141 @@ +/* Copyright (C) 2000, 2001 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.awt.j2d; + +import java.awt.Color; +import java.awt.Image; +import java.awt.Shape; +import java.awt.Rectangle; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GraphicsConfiguration; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.image.ImageObserver; + +/** + * Base class for graphics state objects (State pattern, GOF book) + * that represents the current pipeline configuration. The Graphics2D + * object forwards most of the requests to the state object. The + * Graphics2D object itself only administers properties that are not + * specific for a certain state. + */ +public abstract class AbstractGraphicsState implements Cloneable +{ + Graphics2DImpl frontend; + + public void setFrontend(Graphics2DImpl frontend) + { + this.frontend = frontend; + } + + public void dispose() + { + frontend = null; + } + + // -------- Graphics methods: + + public abstract void setColor(Color color); + + public abstract void setPaintMode(); + + public abstract void setXORMode(Color altColor); + + public abstract void setFont(Font font); + + public abstract FontMetrics getFontMetrics(Font font); + + public abstract void setClip(Shape clip); + + public abstract Shape getClip(); + public abstract Rectangle getClipBounds(); + + public abstract void copyArea(int x, int y, + int width, int height, + int dx, int dy); + + public abstract void drawLine(int x1, int y1, + int x2, int y2); + + public abstract void fillRect(int x, int y, + int width, int height); + + public abstract void clearRect(int x, int y, + int width, int height); + + public abstract void drawRoundRect(int x, int y, + int width, int height, + int arcWidth, int arcHeight); + + public abstract void fillRoundRect(int x, int y, + int width, int height, + int arcWidth, int arcHeight); + + public abstract void drawOval(int x, int y, + int width, int height); + + public abstract void fillOval(int x, int y, + int width, int height); + + public abstract void drawArc(int x, int y, + int width, int height, + int startAngle, int arcAngle); + + public abstract void fillArc(int x, int y, + int width, int height, + int startAngle, int arcAngle); + + public abstract void drawPolyline(int[] xPoints, int[] yPoints,int nPoints); + + public abstract void drawPolygon(int[] xPoints, int[] yPoints, int nPoints); + + public abstract void fillPolygon(int[] xPoints, int[] yPoints, int nPoints); + + public abstract boolean drawImage(Image image, int x, int y, + ImageObserver observer); + + + // -------- Graphics2D methods: + + public abstract void draw(Shape shape); + + public abstract void fill(Shape shape); + + public abstract boolean hit(Rectangle rect, Shape text, boolean onStroke); + + public abstract void drawString(String text, int x, int y); + + public abstract void drawString(String text, float x, float y); + + public abstract void translate(int x, int y); + + public abstract void translate(double tx, double ty); + + public abstract void rotate(double theta); + + public abstract void rotate(double theta, double x, double y); + + public abstract void scale(double scaleX, double scaleY); + + public abstract void shear(double shearX, double shearY); + + public Object clone () + { + try + { + return super.clone (); + } + catch (CloneNotSupportedException ex) + { + // This should never happen. + throw new InternalError (); + } + } +} diff --git a/libjava/gnu/awt/j2d/DirectRasterGraphics.h b/libjava/gnu/awt/j2d/DirectRasterGraphics.h new file mode 100644 index 000000000..4cb63f7f7 --- /dev/null +++ b/libjava/gnu/awt/j2d/DirectRasterGraphics.h @@ -0,0 +1,71 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __gnu_awt_j2d_DirectRasterGraphics__ +#define __gnu_awt_j2d_DirectRasterGraphics__ + +#pragma interface + +#include +#include + +extern "Java" +{ + namespace gnu + { + namespace awt + { + namespace j2d + { + class DirectRasterGraphics; + class MappedRaster; + } + } + } + namespace java + { + namespace awt + { + class Color; + class Font; + class FontMetrics; + class Image; + class Rectangle; + class Shape; + namespace image + { + class ImageObserver; + } + } + } +} + +class gnu::awt::j2d::DirectRasterGraphics : public ::java::lang::Object +{ + +public: + virtual void dispose() = 0; + virtual void setColor(::java::awt::Color *) = 0; + virtual void setPaintMode() = 0; + virtual void setXORMode(::java::awt::Color *) = 0; + virtual void setFont(::java::awt::Font *) = 0; + virtual ::java::awt::FontMetrics * getFontMetrics(::java::awt::Font *) = 0; + virtual void setClip(::java::awt::Shape *) = 0; + virtual void copyArea(jint, jint, jint, jint, jint, jint) = 0; + virtual void drawLine(jint, jint, jint, jint) = 0; + virtual void drawRect(jint, jint, jint, jint) = 0; + virtual void fillRect(jint, jint, jint, jint) = 0; + virtual void drawArc(jint, jint, jint, jint, jint, jint) = 0; + virtual void fillArc(jint, jint, jint, jint, jint, jint) = 0; + virtual void drawPolyline(JArray< jint > *, JArray< jint > *, jint) = 0; + virtual void drawPolygon(JArray< jint > *, JArray< jint > *, jint) = 0; + virtual void fillPolygon(JArray< jint > *, JArray< jint > *, jint, jint, jint) = 0; + virtual void drawString(::java::lang::String *, jint, jint) = 0; + virtual jboolean drawImage(::java::awt::Image *, jint, jint, ::java::awt::image::ImageObserver *) = 0; + virtual ::gnu::awt::j2d::MappedRaster * mapRaster(::java::awt::Rectangle *) = 0; + virtual void unmapRaster(::gnu::awt::j2d::MappedRaster *) = 0; + virtual ::java::lang::Object * clone() = 0; + static ::java::lang::Class class$; +} __attribute__ ((java_interface)); + +#endif // __gnu_awt_j2d_DirectRasterGraphics__ diff --git a/libjava/gnu/awt/j2d/DirectRasterGraphics.java b/libjava/gnu/awt/j2d/DirectRasterGraphics.java new file mode 100644 index 000000000..d7248b9d8 --- /dev/null +++ b/libjava/gnu/awt/j2d/DirectRasterGraphics.java @@ -0,0 +1,85 @@ +/* Copyright (C) 2000, 2003 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.awt.j2d; + +import java.awt.Color; +import java.awt.Image; +import java.awt.Shape; +import java.awt.Rectangle; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GraphicsConfiguration; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.image.Raster; +import java.awt.image.ImageObserver; + +/** + * Interface for a simple pixel based backend graphics object that + * does not handle translation/transforms, curves, nor advanced + * compositing. + */ +public interface DirectRasterGraphics extends Cloneable +{ + void dispose(); + + void setColor(Color color); + + void setPaintMode(); + + void setXORMode(Color altColor); + + void setFont(Font font); + + FontMetrics getFontMetrics(Font font); + + // supports rects, multi-rects and polygons + void setClip(Shape clip); + + void copyArea(int x, int y, int width, int height, + int dx, int dy); + + void drawLine(int x1, int y1, int x2, int y2); + + void drawRect(int x, int y, int width, int height); + + void fillRect(int x, int y, int width, int height); + + void drawArc(int x, int y, int width, int height, + int startAngle, int arcAngle); + + void fillArc(int x, int y, int width, int height, + int startAngle, int arcAngle); + + void drawPolyline(int[] xPoints, int[] yPoints, int nPoints); + + void drawPolygon(int[] xPoints, int[] yPoints, int nPoints); + + void fillPolygon(int[] xPoints, int[] yPoints, int nPoints, + int translateX, int translateY); + + void drawString(String str, int x, int y); + + boolean drawImage(Image image, int x, int y, + ImageObserver observer); + + /** + * Map the data for screen pixels in the requested bounds to a + * raster object. This gives read/write access to the screen + * pixels, allowing neat alpha and composite tricks. + */ + MappedRaster mapRaster(Rectangle bounds); + + /** + * Detach previously mapped pixel data from a raster object. + */ + void unmapRaster(MappedRaster mappedRaster); + + Object clone(); +} diff --git a/libjava/gnu/awt/j2d/Graphics2DImpl.h b/libjava/gnu/awt/j2d/Graphics2DImpl.h new file mode 100644 index 000000000..c7e8a8c1d --- /dev/null +++ b/libjava/gnu/awt/j2d/Graphics2DImpl.h @@ -0,0 +1,157 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __gnu_awt_j2d_Graphics2DImpl__ +#define __gnu_awt_j2d_Graphics2DImpl__ + +#pragma interface + +#include +#include + +extern "Java" +{ + namespace gnu + { + namespace awt + { + namespace j2d + { + class AbstractGraphicsState; + class Graphics2DImpl; + } + } + } + namespace java + { + namespace awt + { + class Color; + class Composite; + class Font; + class FontMetrics; + class Graphics; + class GraphicsConfiguration; + class Image; + class Paint; + class Rectangle; + class RenderingHints; + class RenderingHints$Key; + class Shape; + class Stroke; + namespace font + { + class FontRenderContext; + class GlyphVector; + } + namespace geom + { + class AffineTransform; + } + namespace image + { + class BufferedImage; + class BufferedImageOp; + class ImageObserver; + class RenderedImage; + namespace renderable + { + class RenderableImage; + } + } + } + namespace text + { + class AttributedCharacterIterator; + } + } +} + +class gnu::awt::j2d::Graphics2DImpl : public ::java::awt::Graphics2D +{ + +public: + Graphics2DImpl(::java::awt::GraphicsConfiguration *); + virtual void setState(::gnu::awt::j2d::AbstractGraphicsState *); + virtual ::java::lang::Object * clone(); + virtual ::java::awt::Graphics * create(); + virtual ::java::awt::Color * getColor(); + virtual void setColor(::java::awt::Color *); + virtual void setPaintMode(); + virtual void setXORMode(::java::awt::Color *); + virtual ::java::awt::Font * getFont(); + virtual void setFont(::java::awt::Font *); + virtual ::java::awt::FontMetrics * getFontMetrics(::java::awt::Font *); + virtual ::java::awt::Rectangle * getClipBounds(); + virtual void clipRect(jint, jint, jint, jint); + virtual void setClip(jint, jint, jint, jint); + virtual ::java::awt::Shape * getClip(); + virtual void setClip(::java::awt::Shape *); + virtual void copyArea(jint, jint, jint, jint, jint, jint); + virtual void drawLine(jint, jint, jint, jint); + virtual void fillRect(jint, jint, jint, jint); + virtual void clearRect(jint, jint, jint, jint); + virtual void drawRoundRect(jint, jint, jint, jint, jint, jint); + virtual void fillRoundRect(jint, jint, jint, jint, jint, jint); + virtual void drawOval(jint, jint, jint, jint); + virtual void fillOval(jint, jint, jint, jint); + virtual void drawArc(jint, jint, jint, jint, jint, jint); + virtual void fillArc(jint, jint, jint, jint, jint, jint); + virtual void drawPolyline(JArray< jint > *, JArray< jint > *, jint); + virtual void drawPolygon(JArray< jint > *, JArray< jint > *, jint); + virtual void fillPolygon(JArray< jint > *, JArray< jint > *, jint); + virtual jboolean drawImage(::java::awt::Image *, jint, jint, ::java::awt::image::ImageObserver *); + virtual jboolean drawImage(::java::awt::Image *, jint, jint, jint, jint, ::java::awt::image::ImageObserver *); + virtual jboolean drawImage(::java::awt::Image *, jint, jint, ::java::awt::Color *, ::java::awt::image::ImageObserver *); + virtual jboolean drawImage(::java::awt::Image *, jint, jint, jint, jint, ::java::awt::Color *, ::java::awt::image::ImageObserver *); + virtual jboolean drawImage(::java::awt::Image *, jint, jint, jint, jint, jint, jint, jint, jint, ::java::awt::image::ImageObserver *); + virtual jboolean drawImage(::java::awt::Image *, jint, jint, jint, jint, jint, jint, jint, jint, ::java::awt::Color *, ::java::awt::image::ImageObserver *); + virtual void dispose(); + virtual void draw(::java::awt::Shape *); + virtual jboolean drawImage(::java::awt::Image *, ::java::awt::geom::AffineTransform *, ::java::awt::image::ImageObserver *); + virtual void drawString(::java::lang::String *, jint, jint); + virtual void drawString(::java::lang::String *, jfloat, jfloat); + virtual void fill(::java::awt::Shape *); + virtual jboolean hit(::java::awt::Rectangle *, ::java::awt::Shape *, jboolean); + virtual ::java::awt::GraphicsConfiguration * getDeviceConfiguration(); + virtual void setPaint(::java::awt::Paint *); + virtual void setRenderingHint(::java::awt::RenderingHints$Key *, ::java::lang::Object *); + virtual ::java::lang::Object * getRenderingHint(::java::awt::RenderingHints$Key *); + virtual ::java::awt::RenderingHints * getRenderingHints(); + virtual void translate(jint, jint); + virtual void translate(jdouble, jdouble); + virtual void rotate(jdouble); + virtual void rotate(jdouble, jdouble, jdouble); + virtual void scale(jdouble, jdouble); + virtual void shear(jdouble, jdouble); + virtual void transform(::java::awt::geom::AffineTransform *); + virtual void setTransform(::java::awt::geom::AffineTransform *); + virtual ::java::awt::geom::AffineTransform * getTransform(); + virtual ::java::awt::Paint * getPaint(); + virtual void setBackground(::java::awt::Color *); + virtual ::java::awt::Color * getBackground(); + virtual void clip(::java::awt::Shape *); + virtual void drawImage(::java::awt::image::BufferedImage *, ::java::awt::image::BufferedImageOp *, jint, jint); + virtual void drawRenderedImage(::java::awt::image::RenderedImage *, ::java::awt::geom::AffineTransform *); + virtual void drawRenderableImage(::java::awt::image::renderable::RenderableImage *, ::java::awt::geom::AffineTransform *); + virtual void drawString(::java::text::AttributedCharacterIterator *, jint, jint); + virtual void drawString(::java::text::AttributedCharacterIterator *, jfloat, jfloat); + virtual void setComposite(::java::awt::Composite *); + virtual void setStroke(::java::awt::Stroke *); + virtual void setRenderingHints(::java::util::Map *); + virtual void addRenderingHints(::java::util::Map *); + virtual ::java::awt::Composite * getComposite(); + virtual ::java::awt::Stroke * getStroke(); + virtual ::java::awt::font::FontRenderContext * getFontRenderContext(); + virtual void drawGlyphVector(::java::awt::font::GlyphVector *, jfloat, jfloat); +public: // actually package-private + ::java::awt::GraphicsConfiguration * __attribute__((aligned(__alignof__( ::java::awt::Graphics2D)))) config; + ::gnu::awt::j2d::AbstractGraphicsState * state; + ::java::awt::Color * fg; + ::java::awt::Color * bg; + ::java::awt::Font * font; +public: + static ::java::lang::Class class$; +}; + +#endif // __gnu_awt_j2d_Graphics2DImpl__ diff --git a/libjava/gnu/awt/j2d/Graphics2DImpl.java b/libjava/gnu/awt/j2d/Graphics2DImpl.java new file mode 100644 index 000000000..5091af69f --- /dev/null +++ b/libjava/gnu/awt/j2d/Graphics2DImpl.java @@ -0,0 +1,545 @@ +/* Copyright (C) 2000, 2002, 2003 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.awt.j2d; + +import java.awt.Color; +import java.awt.Composite; +import java.awt.Image; +import java.awt.Shape; +import java.awt.Rectangle; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GraphicsConfiguration; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Paint; +import java.awt.RenderingHints; +import java.awt.Stroke; +import java.awt.font.FontRenderContext; +import java.awt.font.GlyphVector; +import java.awt.geom.AffineTransform; +import java.awt.image.ImageObserver; +import java.awt.image.BufferedImage; +import java.awt.image.BufferedImageOp; +import java.awt.image.RenderedImage; +import java.awt.image.renderable.RenderableImage; +import java.text.AttributedCharacterIterator; +import java.util.Map; + +/** + * Delegates almost all work to a state object, that allows us to + * hot-swap rendering strategies based on state changes inflicted on + * this Graphics object. This class keeps track of properties that are + * not affected by the state, (such as clip shape, + * foreground/background color, font, etc.). + * + *

The far front-end of the rendering pipeline consists of the + * Graphics2D API. In the far back-end, lies the native graphics + * libraries. In most cases the native graphics libraries only have + * direct support for a subset of the properties of Graphics2D. To + * make up missing features in the native graphics libraries, the + * pipeline between the front-end and the back-end need to translate + * drawing request to primitive operations that are supported by the + * back-end. E.g. for X11, drawing a straight line will translate to + * an XDrawLine, drawing a bezier curve will trigger flattening of the + * curve and will result in a call to XDrawLines. + * + *

This is the basic strategy for the rendering pipeline: Whenever + * a graphics property change occurs, that causes the current pipeline + * to be insufficient, amend or replace parts of the pipeline so that + * the pipeline will once again be able to translate requests to the + * set of primitives supported by the native graphics library. + * + *

Most graphics libraries share common subsets of + * functionality. To be able to reuse pieces of the rendering pipeline + * for several backends, we define interfaces that describe subsets of + * characteristics supported by the backends. A wrapper for the native + * library can implement several interfaces to describe its range of + * functionality. + * + *

Typically, most painting is done with a graphics object with + * simple properties. Unless one is using a complex Look & Feel, the + * painting of Swing components will never require affine transforms, + * alpha blending, non-rectangular clipping, etc. When graphics + * objects are created, they start off in a state where all the + * properties are simple. Most graphics objects experience only + * trivial property changes, and never leave this simple state. It is + * therefore wise to ensure that the rendering pipeline for this + * initial state is lean and as much as possible plugs directly into + * the backend. + * + *

The initial state for graphics object of most raster displays + * would call for two levels of indirection: + * + *

+ * Graphics2D object ---> IntegerGraphicsState ---> DirectRasterGraphics
+ * 
+ */ +public class Graphics2DImpl extends Graphics2D implements Cloneable +{ + GraphicsConfiguration config; + + AbstractGraphicsState state; + + Color fg; + Color bg; + + Font font; + + public Graphics2DImpl(GraphicsConfiguration config) + { + this.config = config; + } + + public void setState(AbstractGraphicsState state) + { + this.state = state; + this.state.setFrontend(this); + } + + public Object clone() + { + try + { + Graphics2DImpl gfxCopy = (Graphics2DImpl) super.clone(); + AbstractGraphicsState stateCopy = + (AbstractGraphicsState) state.clone(); + gfxCopy.setState(stateCopy); + + return gfxCopy; + } + catch (CloneNotSupportedException ex) + { + // This should never happen. + throw new InternalError (); + } + } + + + // -------- Graphics methods: + + public Graphics create() + { + Graphics2DImpl gfxCopy = (Graphics2DImpl) clone(); + return gfxCopy; + } + + public Color getColor() + { + return fg; + } + + public void setColor(Color color) + { + fg = color; + state.setColor(color); + } + + public void setPaintMode() + { + state.setPaintMode(); + } + + public void setXORMode(Color altColor) + { + state.setXORMode(altColor); + } + + public Font getFont() + { + return font; + } + + public void setFont(Font font) + { + this.font = font; + state.setFont(font); + } + + public FontMetrics getFontMetrics(Font font) + { + return state.getFontMetrics(font); + } + + public Rectangle getClipBounds() + { + return state.getClipBounds(); + } + + public void clipRect(int x, int y, int width, int height) + { + Shape clip = state.getClip(); + if (clip == null) + { + clip = new Rectangle (x,y,width,height); + setClip (clip); + return; + } + if (clip instanceof Rectangle) + { + Rectangle clipRect = (Rectangle) clip; + clip = clipRect.intersection(new Rectangle(x, y, width, height)); + setClip(clip); + return; + } + + String msg = + "intersecting current clip shape " + clip + " with new rectangle " + + "has not been implemented yet"; + throw new UnsupportedOperationException(msg); + } + + public void setClip(int x, int y, int width, int height) + { + Rectangle clip = new Rectangle(x, y, width, height); + setClip(clip); + } + + public Shape getClip() + { + return state.getClip(); + } + + public void setClip(Shape clip) + { + state.setClip(clip); + } + + public void copyArea(int x, int y, int width, int height, + int dx, int dy) + { + state.copyArea(x, y, width, height, dx, dy); + } + + public void drawLine(int x1, int y1, int x2, int y2) + { + state.drawLine(x1, y1, x2, y2); + } + + public void fillRect(int x, int y, int width, int height) + { + state.fillRect(x, y, width, height); + } + + public void clearRect(int x, int y, int width, int height) + { + state.clearRect(x, y, width, height); + } + + public void drawRoundRect(int x, int y, int width, int height, + int arcWidth, int arcHeight) + { + state.drawRoundRect(x, y, width, height, arcWidth, arcHeight); + } + + public void fillRoundRect(int x, int y, int width, int height, + int arcWidth, int arcHeight) + { + state.fillRoundRect(x, y, width, height, arcWidth, arcHeight); + } + + public void drawOval(int x, int y, int width, int height) + { + state.drawOval(x, y, width, height); + } + + public void fillOval(int x, int y, int width, int height) + { + state.fillOval(x, y, width, height); + } + + public void drawArc(int x, int y, int width, int height, + int startAngle, int arcAngle) + { + state.drawArc(x, y, width, height, startAngle, arcAngle); + } + + public void fillArc(int x, int y, int width, int height, + int startAngle, int arcAngle) + { + state.fillArc(x, y, width, height, startAngle, arcAngle); + } + + public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) + { + state.drawPolyline(xPoints, yPoints, nPoints); + } + + public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) + { + state.drawPolygon(xPoints, yPoints, nPoints); + } + + public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) + { + state.fillPolygon(xPoints, yPoints, nPoints); + } + + public boolean drawImage(Image image, int x, int y, + ImageObserver observer) + { + return state.drawImage(image, x, y, observer); + } + + public boolean drawImage(Image img, int x, int y, + int width, int height, + ImageObserver observer) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public boolean drawImage(Image img, int x, int y, Color bgcolor, + ImageObserver observer) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public boolean drawImage(Image img, int x, int y, + int width, int height, Color bgcolor, + ImageObserver observer) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public boolean drawImage(Image img, + int dx1, int dy1, int dx2, int dy2, + int sx1, int sy1, int sx2, int sy2, + ImageObserver observer) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public boolean drawImage(Image img, + int dx1, int dy1, int dx2, int dy2, + int sx1, int sy1, int sx2, int sy2, + Color bgcolor, ImageObserver observer) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public void dispose() + { + AbstractGraphicsState lState = state; + + state = null; + config = null; + font = null; + fg = null; + bg = null; + + if (lState != null) + lState.dispose(); + } + + + + // -------- Graphics2D methods: + + public void draw(Shape shape) + { + state.draw(shape); + } + + public boolean drawImage(Image image, AffineTransform xform, + ImageObserver obs) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + + public void drawString(String text, int x, int y) + { + state.drawString(text, x, y); + } + + public void drawString(String text, float x, float y) + { + state.drawString(text, x, y); + } + + public void fill(Shape shape) + { + state.fill(shape); + } + + public boolean hit(Rectangle rect, Shape text, boolean onStroke) + { + return state.hit(rect, text, onStroke); + } + + public GraphicsConfiguration getDeviceConfiguration() + { + return config; + } + + public void setPaint(Paint paint) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public void setRenderingHint(RenderingHints.Key hintKey, + Object hintValue) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public Object getRenderingHint(RenderingHints.Key hintKey) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public RenderingHints getRenderingHints() + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public void translate(int x, int y) + { + state.translate(x, y); + } + + public void translate(double tx, double ty) + { + state.translate(tx, ty); + } + + public void rotate(double theta) + { + state.rotate(theta); + } + + public void rotate(double theta, double x, double y) + { + state.rotate(theta, x, y); + } + + public void scale(double scaleX, double scaleY) + { + state.scale(scaleX, scaleY); + } + + public void shear(double shearX, double shearY) + { + state.shear(shearX, shearY); + } + + public void transform(AffineTransform Tx) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public void setTransform(AffineTransform Tx) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public AffineTransform getTransform() + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public Paint getPaint() + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public void setBackground(Color color) + { + bg = color; + } + + public Color getBackground() + { + return bg; + } + + public void clip(Shape shape) + { + Shape clip = state.getClip(); + + if ((shape instanceof Rectangle) && (clip instanceof Rectangle)) + { + clip = ((Rectangle) clip).intersection((Rectangle) shape); + state.setClip(clip); + return; + } + + String msg = + "intersecting current clip shape " + clip + " with new shape " + shape + + "has not been implemented yet"; + throw new UnsupportedOperationException(msg); + } + + public void drawImage(BufferedImage image, BufferedImageOp op, int x, int y) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public void drawRenderedImage(RenderedImage image, AffineTransform xform) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public void drawRenderableImage(RenderableImage image, AffineTransform xform) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public void drawString(AttributedCharacterIterator iterator, + int x, int y) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public void drawString(AttributedCharacterIterator iterator, float x, + float y) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public void setComposite(Composite comp) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public void setStroke(Stroke stroke) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public void setRenderingHints(Map hints) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public void addRenderingHints(Map hints) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public Composite getComposite() + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public Stroke getStroke() + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public FontRenderContext getFontRenderContext () + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public void drawGlyphVector (GlyphVector g, float x, float y) + { + throw new UnsupportedOperationException("not implemented yet"); + } +} diff --git a/libjava/gnu/awt/j2d/IntegerGraphicsState$ScreenCoupledImage.h b/libjava/gnu/awt/j2d/IntegerGraphicsState$ScreenCoupledImage.h new file mode 100644 index 000000000..eaa7c93a8 --- /dev/null +++ b/libjava/gnu/awt/j2d/IntegerGraphicsState$ScreenCoupledImage.h @@ -0,0 +1,39 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __gnu_awt_j2d_IntegerGraphicsState$ScreenCoupledImage__ +#define __gnu_awt_j2d_IntegerGraphicsState$ScreenCoupledImage__ + +#pragma interface + +#include +extern "Java" +{ + namespace gnu + { + namespace awt + { + namespace j2d + { + class IntegerGraphicsState$ScreenCoupledImage; + } + } + } + namespace java + { + namespace awt + { + class GraphicsConfiguration; + } + } +} + +class gnu::awt::j2d::IntegerGraphicsState$ScreenCoupledImage : public ::java::lang::Object +{ + +public: + virtual ::java::awt::GraphicsConfiguration * getGraphicsConfiguration() = 0; + static ::java::lang::Class class$; +} __attribute__ ((java_interface)); + +#endif // __gnu_awt_j2d_IntegerGraphicsState$ScreenCoupledImage__ diff --git a/libjava/gnu/awt/j2d/IntegerGraphicsState.h b/libjava/gnu/awt/j2d/IntegerGraphicsState.h new file mode 100644 index 000000000..9a2260993 --- /dev/null +++ b/libjava/gnu/awt/j2d/IntegerGraphicsState.h @@ -0,0 +1,94 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __gnu_awt_j2d_IntegerGraphicsState__ +#define __gnu_awt_j2d_IntegerGraphicsState__ + +#pragma interface + +#include +#include + +extern "Java" +{ + namespace gnu + { + namespace awt + { + namespace j2d + { + class DirectRasterGraphics; + class IntegerGraphicsState; + } + } + } + namespace java + { + namespace awt + { + class Color; + class Font; + class FontMetrics; + class Image; + class Rectangle; + class Shape; + namespace image + { + class ImageObserver; + } + } + } +} + +class gnu::awt::j2d::IntegerGraphicsState : public ::gnu::awt::j2d::AbstractGraphicsState +{ + +public: + IntegerGraphicsState(::gnu::awt::j2d::DirectRasterGraphics *); + virtual ::java::lang::Object * clone(); + virtual void dispose(); + virtual void setColor(::java::awt::Color *); + virtual void setPaintMode(); + virtual void setXORMode(::java::awt::Color *); + virtual void setFont(::java::awt::Font *); + virtual ::java::awt::FontMetrics * getFontMetrics(::java::awt::Font *); + virtual void setClip(::java::awt::Shape *); + virtual ::java::awt::Shape * getClip(); + virtual ::java::awt::Rectangle * getClipBounds(); + virtual void copyArea(jint, jint, jint, jint, jint, jint); + virtual void drawLine(jint, jint, jint, jint); + virtual void fillRect(jint, jint, jint, jint); + virtual void clearRect(jint, jint, jint, jint); + virtual void drawRoundRect(jint, jint, jint, jint, jint, jint); + virtual void fillRoundRect(jint, jint, jint, jint, jint, jint); + virtual void drawOval(jint, jint, jint, jint); + virtual void fillOval(jint, jint, jint, jint); + virtual void drawArc(jint, jint, jint, jint, jint, jint); + virtual void fillArc(jint, jint, jint, jint, jint, jint); + virtual void drawPolyline(JArray< jint > *, JArray< jint > *, jint); + virtual void drawPolygon(JArray< jint > *, JArray< jint > *, jint); + virtual void fillPolygon(JArray< jint > *, JArray< jint > *, jint); + virtual jboolean drawImage(::java::awt::Image *, jint, jint, ::java::awt::image::ImageObserver *); + virtual void draw(::java::awt::Shape *); + virtual void fill(::java::awt::Shape *); + virtual jboolean hit(::java::awt::Rectangle *, ::java::awt::Shape *, jboolean); + virtual void drawString(::java::lang::String *, jint, jint); + virtual void drawString(::java::lang::String *, jfloat, jfloat); + virtual void translate(jint, jint); + virtual void translate(jdouble, jdouble); + virtual void rotate(jdouble); + virtual void rotate(jdouble, jdouble, jdouble); + virtual void scale(jdouble, jdouble); + virtual void shear(jdouble, jdouble); +private: + void needAffineTransform(); +public: // actually package-private + jint __attribute__((aligned(__alignof__( ::gnu::awt::j2d::AbstractGraphicsState)))) tx; + jint ty; + ::gnu::awt::j2d::DirectRasterGraphics * directGfx; + ::java::awt::Shape * clip; +public: + static ::java::lang::Class class$; +}; + +#endif // __gnu_awt_j2d_IntegerGraphicsState__ diff --git a/libjava/gnu/awt/j2d/IntegerGraphicsState.java b/libjava/gnu/awt/j2d/IntegerGraphicsState.java new file mode 100644 index 000000000..bcfacd008 --- /dev/null +++ b/libjava/gnu/awt/j2d/IntegerGraphicsState.java @@ -0,0 +1,427 @@ +/* Copyright (C) 2000, 2003 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.awt.j2d; + +import java.awt.Color; +import java.awt.Image; +import java.awt.Shape; +import java.awt.Rectangle; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GraphicsConfiguration; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.image.BufferedImage; +import java.awt.image.ImageObserver; +import java.awt.image.Raster; +import java.awt.image.WritableRaster; +import java.awt.image.ColorModel; + +/** + * IntegerGraphicsState is one of several graphics state + * implementations. This graphics state is used when the graphics + * object has simple properties, (coordinate translation only, no + * transform) and the backend supports integer coordinates (pixel + * based). For primitive paint operations, this object translates the + * coordinates and forwards the request to the backend. For requests + * to draw arbitrary shapes and paths, this object translates the + * requests to primitive drawing operations supported by the + * backend. IntegerGraphicsState is meant to support the most common + * state of an graphics object. The degree of functionality is roughly + * equivalent with the old java.awt.Graphics API. + */ +public class IntegerGraphicsState extends AbstractGraphicsState +{ + int tx; + int ty; + + DirectRasterGraphics directGfx; + Shape clip; + + /** Interface for images which are coupled to a GraphicsConfiguration, + * as is typically the case for an off-screen buffer used in + * double-buffering. Any image which implements this interface is + * rendered directly by DirectRasterGraphics (i.e. by directGfx.drawImage) + */ + public interface ScreenCoupledImage + { + /** Get the GraphicsConfiguration to which this image is coupled + * @return the GraphicsConfiguration + */ + GraphicsConfiguration getGraphicsConfiguration (); + } + + public IntegerGraphicsState(DirectRasterGraphics directGfx) + { + this.directGfx = directGfx; + } + + public Object clone() + { + IntegerGraphicsState clone = (IntegerGraphicsState) super.clone(); + clone.directGfx = (DirectRasterGraphics) directGfx.clone(); + + return clone; + } + + public void dispose() + { + DirectRasterGraphics lDeviceGfx = directGfx; + + directGfx = null; + + if (lDeviceGfx != null) + lDeviceGfx.dispose(); + + super.dispose(); + } + + // -------- Graphics methods: + + public void setColor(Color color) + { + directGfx.setColor(color); + } + + public void setPaintMode() + { + directGfx.setPaintMode(); + } + + public void setXORMode(Color altColor) + { + directGfx.setXORMode(altColor); + } + + public void setFont(Font font) + { + directGfx.setFont(font); + } + + public FontMetrics getFontMetrics(Font font) + { + return directGfx.getFontMetrics(font); + } + + public void setClip(Shape clip) + { + if (clip instanceof Rectangle) + { + Rectangle clipRect = (Rectangle) ((Rectangle) clip).clone(); + clipRect.x += tx; + clipRect.y += ty; + + this.clip = clipRect; + + directGfx.setClip(clipRect); + return; + } + + String msg = + "translating clip shape " + clip + " into device " + + "coordinate space has not been implemented yet"; + + throw new UnsupportedOperationException(msg); + } + + public Shape getClip() + { + if (clip == null) + return null; + if (clip instanceof Rectangle) + { + Rectangle clipRect = (Rectangle) ((Rectangle) clip).clone(); + clipRect.x -= tx; + clipRect.y -= ty; + return clipRect; + } + + String msg = + "translating clip shape " + clip + " into user " + + "coordinate space has not been implemented yet"; + + throw new UnsupportedOperationException(msg); + } + + public Rectangle getClipBounds() + { + if (clip == null) + return null; + Rectangle clipRect = clip.getBounds(); + + clipRect.x -= tx; + clipRect.y -= ty; + return clipRect; + } + + public void copyArea(int x, int y, + int width, int height, + int dx, int dy) + { + directGfx.copyArea(x+tx, y+ty, width, height, dx, dy); + } + + public void drawLine(int x1, int y1, + int x2, int y2) + { + directGfx.drawLine(x1+tx, y1+ty, x2+tx, y2+ty); + } + + public void fillRect(int x, int y, + int width, int height) + { + directGfx.fillRect(x+tx, y+ty, width, height); + } + + public void clearRect(int x, int y, + int width, int height) + { + directGfx.setColor(frontend.getBackground()); + directGfx.fillRect(x+tx, y+ty, width, height); + directGfx.setColor(frontend.getColor()); + } + + public void drawRoundRect(int x, int y, + int width, int height, + int arcWidth, int arcHeight) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public void fillRoundRect(int x, int y, + int width, int height, + int arcWidth, int arcHeight) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public void drawOval(int x, int y, + int width, int height) + { + drawArc (x, y, width, height, 0, 360); + } + + public void fillOval(int x, int y, + int width, int height) + { + fillArc (x, y, width, height, 0, 360); + } + + public void drawArc(int x, int y, + int width, int height, + int startAngle, int arcAngle) + { + directGfx.drawArc(x+tx, y+ty, width, height, startAngle, arcAngle); + } + + public void fillArc(int x, int y, + int width, int height, + int startAngle, int arcAngle) + { + directGfx.fillArc(x+tx, y+ty, width, height, startAngle, arcAngle); + } + + public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) + { + if ((tx == 0) && (ty == 0)) + { + directGfx.drawPolyline(xPoints, yPoints, nPoints); + return; + } + + throw new UnsupportedOperationException("translate not implemented"); + } + + public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) + { + if ((tx == 0) && (ty == 0)) + { + directGfx.drawPolygon(xPoints, yPoints, nPoints); + return; + } + + throw new UnsupportedOperationException("translate not implemented"); + } + + public void fillPolygon (int[] xPoints, int[] yPoints, int nPoints) + { + // FIXME: remove tx & ty args once translation via AffineTransform + // is implemented. + directGfx.fillPolygon (xPoints, yPoints, nPoints, tx, ty); + } + + public boolean drawImage(Image image, int x, int y, + ImageObserver observer) + { + x += tx; + y += ty; + + if (image instanceof ScreenCoupledImage) + { + GraphicsConfiguration config + = ((ScreenCoupledImage)image).getGraphicsConfiguration (); + if (config == frontend.config) + return directGfx.drawImage (image, x, y, observer); + } + if (image instanceof BufferedImage) + { + BufferedImage bImage = (BufferedImage) image; + // FIXME: eliminate? ScreenCoupledImage is probably more efficient + Object config = bImage.getProperty ("java.awt.GraphicsConfiguration"); + if (config == frontend.config) + return directGfx.drawImage (image, x, y, observer); + + int width = image.getWidth (null); + int height = image.getHeight (null); + + Rectangle bounds = new Rectangle (x, y, width, height); + + MappedRaster mr = directGfx.mapRaster (bounds); + + // manipulate raster here... + ColorModel colorModel = mr.getColorModel (); + WritableRaster raster = mr.getRaster (); + + int xEnd = x + width; + int yEnd = y + height; + + // FIXME: Use the following code only as a fallback. It's SLOW! + + Object rgbElem = null; + for (int yy=0; yy>> 24) & 0xff) + 1; + int sr = ((srgb >>> 16) & 0xff) + 1; + int sg = ((srgb >>> 8) & 0xff) + 1; + int sb = (srgb & 0xff) + 1; + + rgbElem = raster.getDataElements (xx+x, yy+y, rgbElem); + int drgb = colorModel.getRGB (rgbElem); + int dr = ((drgb >>> 16) & 0xff) + 1; + int dg = ((drgb >>> 8) & 0xff) + 1; + int db = (drgb & 0xff) + 1; + int da = 256 - sa; + + dr = ((sr*sa + dr*da) >>> 8) - 1; + dg = ((sg*sa + dg*da) >>> 8) - 1; + db = ((sb*sa + db*da) >>> 8) - 1; + + drgb = (dr<<16) | (dg<<8) | db; + + rgbElem = colorModel.getDataElements (drgb, rgbElem); + + raster.setDataElements (xx+x, yy+y, rgbElem); + } + } + directGfx.unmapRaster (mr); + return true; + + } + throw new UnsupportedOperationException ("drawing image " + image + + "not implemented"); + } + + + // -------- Graphics2D methods: + + public void draw(Shape shape) + { + if (shape instanceof Rectangle) + { + Rectangle rect = (Rectangle) shape; + directGfx.drawRect(rect.x+tx, rect.y+ty, rect.width, rect.height); + return; + } + + throw new UnsupportedOperationException("shape not implemented"); + } + + public void fill(Shape shape) + { + if (shape instanceof Rectangle) + { + Rectangle rect = (Rectangle) shape; + directGfx.fillRect(rect.x+tx, rect.y+ty, rect.width, rect.height); + return; + } + + throw new UnsupportedOperationException("not implemented"); + } + + public boolean hit(Rectangle rect, Shape text, + boolean onStroke) + { + throw new UnsupportedOperationException("not implemented"); + } + + public void drawString(String text, int x, int y) + { + directGfx.drawString(text, x+tx, y+ty); + } + + public void drawString(String text, float x, float y) + { + drawString(text, (int) x, (int) y); + } + + public void translate(int x, int y) + { + tx += x; + ty += y; + } + + public void translate(double tx, double ty) + { + if ((tx == 0) && (ty == 0)) + return; + + needAffineTransform(); + } + + public void rotate(double theta) + { + if (theta == 0) + return; + + needAffineTransform(); + } + + public void rotate(double theta, double x, double y) + { + if (theta == 0) + return; + + needAffineTransform(); + } + + public void scale(double scaleX, double scaleY) + { + if ((scaleX == 1) && (scaleY == 1)) + return; + + needAffineTransform(); + } + + public void shear(double shearX, double shearY) + { + if ((shearX == 0) && (shearY == 0)) + return; + + needAffineTransform(); + } + + private void needAffineTransform() + { + throw new UnsupportedOperationException("state with affine " + + "transform not implemented"); + } +} diff --git a/libjava/gnu/awt/j2d/MappedRaster.h b/libjava/gnu/awt/j2d/MappedRaster.h new file mode 100644 index 000000000..ab5a81e4b --- /dev/null +++ b/libjava/gnu/awt/j2d/MappedRaster.h @@ -0,0 +1,49 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __gnu_awt_j2d_MappedRaster__ +#define __gnu_awt_j2d_MappedRaster__ + +#pragma interface + +#include +extern "Java" +{ + namespace gnu + { + namespace awt + { + namespace j2d + { + class MappedRaster; + } + } + } + namespace java + { + namespace awt + { + namespace image + { + class ColorModel; + class WritableRaster; + } + } + } +} + +class gnu::awt::j2d::MappedRaster : public ::java::lang::Object +{ + +public: + MappedRaster(::java::awt::image::WritableRaster *, ::java::awt::image::ColorModel *); + virtual ::java::awt::image::WritableRaster * getRaster(); + virtual ::java::awt::image::ColorModel * getColorModel(); +public: // actually package-private + ::java::awt::image::WritableRaster * __attribute__((aligned(__alignof__( ::java::lang::Object)))) raster; + ::java::awt::image::ColorModel * cm; +public: + static ::java::lang::Class class$; +}; + +#endif // __gnu_awt_j2d_MappedRaster__ diff --git a/libjava/gnu/awt/j2d/MappedRaster.java b/libjava/gnu/awt/j2d/MappedRaster.java new file mode 100644 index 000000000..eb41eecf9 --- /dev/null +++ b/libjava/gnu/awt/j2d/MappedRaster.java @@ -0,0 +1,72 @@ +/* Copyright (C) 2000 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.awt.j2d; + +import java.awt.image.WritableRaster; +import java.awt.image.ColorModel; + +/* The raster and associated properties of a mapped screen region. + * The compositing capabilities of backends are often insufficient. + * The backend may not support alpha blending, or may not support some + * other special compositing rule. This means that compositing must + * sometimes be done within the rendering pipeline. The general + * compositing operation consists of combining new color and alpha + * values with existing color values on the drawing surface, to find + * the new color values for the drawing surface. The way the values + * are combined, determines what kind of compositing operation that is + * performed. The default compositing operation is alpha compositing. + * + *

In order to perform alpha compositing and other compositing + * operations, we need access to the color values of the imagery that + * has already been drawn on the drawing surface. The + * DirectRasterGraphics interface must therefore contain methods that + * makes it possible to gain access to the pixel values of the drawing + * surface. The methods are modeled after the POSIX mmap() and + * munmap() functions. But, instead of mapping and unmapping portions + * of data from a file descriptor to memory, the methods in + * DirectRasterGraphics maps and unmaps portions of the drawing + * surface to data arrays within writable raster objects. A call to + * mapRaster() will return a writable raster object, encapsulating the + * image data of the drawing surface in the requested domain. The data + * encapsulated by this raster object can be modified using the + * WritableRaster API, or the data buffers can be retrieved from the + * raster, so that the data arrays can be manipulated directly. When + * the raster image has been modified as desired, the data can be + * resynchronized with the drawing surface by calling mapRaster(). + * + *

As with mmap() and munmap() the methods may work by direct + * manipulation of shared memory, (i.e. the raster object directly + * wraps the actual image data of the drawing surface), or may make a + * private copy that is resynched when the raster is unmapped. The + * backend may choose to implement either mechanism, and the pipeline + * code should not care what mechanism is actually used. This design + * allows us to make full use of speedups such as X shared memory + * extentions when available. + */ +public class MappedRaster +{ + WritableRaster raster; + ColorModel cm; + + public MappedRaster(WritableRaster raster, ColorModel cm) + { + this.raster = raster; + this.cm = cm; + } + + public final WritableRaster getRaster() + { + return raster; + } + + public final ColorModel getColorModel() + { + return cm; + } +} diff --git a/libjava/gnu/awt/xlib/XCanvasPeer$DoMap.h b/libjava/gnu/awt/xlib/XCanvasPeer$DoMap.h new file mode 100644 index 000000000..08498e179 --- /dev/null +++ b/libjava/gnu/awt/xlib/XCanvasPeer$DoMap.h @@ -0,0 +1,43 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __gnu_awt_xlib_XCanvasPeer$DoMap__ +#define __gnu_awt_xlib_XCanvasPeer$DoMap__ + +#pragma interface + +#include +extern "Java" +{ + namespace gnu + { + namespace awt + { + namespace xlib + { + class XCanvasPeer$DoMap; + } + } + namespace gcj + { + namespace xlib + { + class Window; + } + } + } +} + +class gnu::awt::xlib::XCanvasPeer$DoMap : public ::java::lang::Object +{ + +public: + XCanvasPeer$DoMap(::gnu::gcj::xlib::Window *); + virtual void run(); +public: // actually package-private + ::gnu::gcj::xlib::Window * __attribute__((aligned(__alignof__( ::java::lang::Object)))) window; +public: + static ::java::lang::Class class$; +}; + +#endif // __gnu_awt_xlib_XCanvasPeer$DoMap__ diff --git a/libjava/gnu/awt/xlib/XCanvasPeer.h b/libjava/gnu/awt/xlib/XCanvasPeer.h new file mode 100644 index 000000000..509b98e33 --- /dev/null +++ b/libjava/gnu/awt/xlib/XCanvasPeer.h @@ -0,0 +1,164 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __gnu_awt_xlib_XCanvasPeer__ +#define __gnu_awt_xlib_XCanvasPeer__ + +#pragma interface + +#include +extern "Java" +{ + namespace gnu + { + namespace awt + { + namespace xlib + { + class XCanvasPeer; + class XGraphicsConfiguration; + class XToolkit; + } + } + namespace gcj + { + namespace xlib + { + class Window; + class WindowAttributes; + } + } + } + namespace java + { + namespace awt + { + class AWTEvent; + class BufferCapabilities; + class BufferCapabilities$FlipContents; + class Color; + class Component; + class Cursor; + class Dimension; + class Font; + class FontMetrics; + class Graphics; + class GraphicsConfiguration; + class Image; + class Point; + class Rectangle; + class Toolkit; + namespace event + { + class PaintEvent; + } + namespace image + { + class ColorModel; + class ImageObserver; + class ImageProducer; + class VolatileImage; + } + namespace peer + { + class ContainerPeer; + } + } + } + namespace sun + { + namespace awt + { + class CausedFocusEvent$Cause; + } + } +} + +class gnu::awt::xlib::XCanvasPeer : public ::java::lang::Object +{ + +public: + XCanvasPeer(::java::awt::Component *); +public: // actually package-private + virtual ::gnu::gcj::xlib::Window * locateParentWindow(::java::awt::Rectangle *); + virtual void initWindowProperties(); + virtual ::gnu::awt::xlib::XToolkit * getXToolkit(); +public: // actually protected + virtual void ensureFlush(); +public: + virtual ::java::awt::Component * getComponent(); +public: // actually package-private + virtual jlong getBasicEventMask(); +public: + virtual jint checkImage(::java::awt::Image *, jint, jint, ::java::awt::image::ImageObserver *); + virtual ::java::awt::Image * createImage(::java::awt::image::ImageProducer *); + virtual ::java::awt::Image * createImage(jint, jint); + virtual void dispose(); + virtual ::java::awt::GraphicsConfiguration * getGraphicsConfiguration(); + virtual ::java::awt::FontMetrics * getFontMetrics(::java::awt::Font *); + virtual ::java::awt::image::ColorModel * getColorModel(); + virtual ::java::awt::Graphics * getGraphics(); + virtual ::java::awt::Point * getLocationOnScreen(); + virtual ::java::awt::Dimension * getMinimumSize(); + virtual ::java::awt::Dimension * minimumSize(); + virtual ::java::awt::Dimension * getPreferredSize(); + virtual ::java::awt::Dimension * preferredSize(); + virtual ::java::awt::Toolkit * getToolkit(); + virtual void handleEvent(::java::awt::AWTEvent *); + virtual jboolean isFocusTraversable(); + virtual void paint(::java::awt::Graphics *); + virtual jboolean prepareImage(::java::awt::Image *, jint, jint, ::java::awt::image::ImageObserver *); + virtual void print(::java::awt::Graphics *); + virtual void repaint(jlong, jint, jint, jint, jint); + virtual void requestFocus(); + virtual void setBackground(::java::awt::Color *); + virtual void setBounds(jint, jint, jint, jint); + virtual void reshape(jint, jint, jint, jint); + virtual void setCursor(::java::awt::Cursor *); + virtual void setEnabled(jboolean); + virtual void enable(); + virtual void disable(); + virtual void setEventMask(jlong); + virtual void setFont(::java::awt::Font *); + virtual void setForeground(::java::awt::Color *); + virtual void setVisible(jboolean); + virtual void show(); + virtual void hide(); + virtual jboolean isFocusable(); + virtual jboolean requestFocus(::java::awt::Component *, jboolean, jboolean, jlong); + virtual jboolean requestFocus(::java::awt::Component *, jboolean, jboolean, jlong, ::sun::awt::CausedFocusEvent$Cause *); + virtual jboolean isObscured(); + virtual jboolean canDetermineObscurity(); + virtual void coalescePaintEvent(::java::awt::event::PaintEvent *); + virtual void updateCursorImmediately(); + virtual ::java::awt::image::VolatileImage * createVolatileImage(jint, jint); + virtual jboolean handlesWheelScrolling(); + virtual void createBuffers(jint, ::java::awt::BufferCapabilities *); + virtual ::java::awt::Image * getBackBuffer(); + virtual void flip(::java::awt::BufferCapabilities$FlipContents *); + virtual void destroyBuffers(); + virtual jboolean isRestackSupported(); + virtual void cancelPendingPaint(jint, jint, jint, jint); + virtual void restack(); + virtual ::java::awt::Rectangle * getBounds(); + virtual void reparent(::java::awt::peer::ContainerPeer *); + virtual void setBounds(jint, jint, jint, jint, jint); + virtual jboolean isReparentSupported(); + virtual void layout(); +public: // actually package-private + static ::java::awt::Dimension * MIN_SIZE; +public: + ::gnu::gcj::xlib::Window * __attribute__((aligned(__alignof__( ::java::lang::Object)))) window; +public: // actually package-private + ::gnu::gcj::xlib::Window * parent; + ::java::awt::Component * component; + ::gnu::awt::xlib::XGraphicsConfiguration * config; +private: + ::gnu::gcj::xlib::WindowAttributes * attributes; + jlong eventMask; + ::java::awt::Rectangle * locationBounds; +public: + static ::java::lang::Class class$; +}; + +#endif // __gnu_awt_xlib_XCanvasPeer__ diff --git a/libjava/gnu/awt/xlib/XCanvasPeer.java b/libjava/gnu/awt/xlib/XCanvasPeer.java new file mode 100644 index 000000000..6d1fb6752 --- /dev/null +++ b/libjava/gnu/awt/xlib/XCanvasPeer.java @@ -0,0 +1,600 @@ +/* Copyright (C) 2000, 2002, 2003 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.awt.xlib; + +import java.awt.Dimension; +import java.awt.BufferCapabilities; +import java.awt.Component; +import java.awt.EventQueue; +import java.awt.Rectangle; +import java.awt.Color; +import java.awt.Container; +import java.awt.Image; +import java.awt.GraphicsConfiguration; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Toolkit; +import java.awt.AWTEvent; +import java.awt.Cursor; +import java.awt.Shape; + +import java.awt.peer.*; +import java.awt.image.*; + +import java.awt.event.MouseListener; +import java.awt.event.PaintEvent; + +import java.util.EventListener; + +import gnu.gcj.xlib.WMSizeHints; +import gnu.gcj.xlib.Window; +import gnu.gcj.xlib.WindowAttributes; +import gnu.gcj.xlib.Display; +import gnu.gcj.xlib.Visual; +import gnu.gcj.xlib.Screen; +import gnu.gcj.xlib.XImage; + +import gnu.awt.j2d.*; + +import sun.awt.CausedFocusEvent; + +public class XCanvasPeer implements CanvasPeer +{ + static final Dimension MIN_SIZE = new Dimension(1, 1); + + public // temporary + + Window window; + Window parent; + + Component component; + XGraphicsConfiguration config; + private WindowAttributes attributes = new WindowAttributes(); + private long eventMask; + + public XCanvasPeer(Component component) + { + this.component = component; + + // Set up graphics configuration (ie. screen + visual): + + config = (XGraphicsConfiguration) + component.getGraphicsConfiguration(); + + if (config == null) + { + // This will usually only happen for toplevel windows + config = getXToolkit().getDefaultXGraphicsConfiguration(); + } + + Rectangle bounds = component.getBounds(); + parent = locateParentWindow(bounds); + + // Windows in X must atleast be of size 1x1 + boolean boundsChanged = false; + if (bounds.width < 1) + { + boundsChanged = true; + bounds.width = 1; + } + if (bounds.height < 1) + { + boundsChanged = true; + bounds.height = 1; + } + + /* don't worry about this calling back to us, since the real + component object has not yet received a reference to this peer + object. */ + component.setBounds(bounds); + + + /* Set background color */ + Color bg = component.getBackground(); + if (bg != null) + { + int[] components = + { + bg.getRed(), + bg.getGreen(), + bg.getBlue(), + 0xff + }; + + ColorModel cm = config.getColorModel(); + long pixel = cm.getDataElement(components, 0); + attributes.setBackground(pixel); + } + + /* Set exposure mask so that we get exposure events + that can be translated into paint() calls. */ + long eventMask = WindowAttributes.MASK_EXPOSURE; + + /* It would be nice to set up all other required events here, but + it is not possible to do so before after all the children of + this component has been realized. The reason is that it is not + determined whether a component is lightweight before after the + addNotify() method has been called. Thus, it is not possible + for parent component to determine what events it needs to + furnish for lightweight children. Instead, we currently rely + on the component calling our setEventMask() method after the + correct event mask has been determined. */ + + attributes.setEventMask(eventMask); + + + // TODO: set more window attributes? + + /* don't allow event queue to process events from the newly + created window before this peer has been registered as client + data. */ + synchronized (getXToolkit().eventLoop) + { + window = new gnu.gcj.xlib.Window(parent, bounds, attributes); + window.setClientData(this); /* make it possible to find back + to this peer object. Used by + XEventQueue. */ + } + + initWindowProperties(); + + if (component.isVisible()) + EventQueue.invokeLater(new DoMap(window)); + } + + /** + * Override this in subclasses to implement other ways of obtaining + * parent windows. Toplevel windows will typically have a different + * implementation. + */ + gnu.gcj.xlib.Window locateParentWindow(Rectangle bounds) + { + Container parent = component.getParent(); + while (parent.isLightweight()) + { + bounds.x += parent.getX(); + bounds.y += parent.getY(); + parent = parent.getParent(); + // a null pointer here is a genuine error + } + + XCanvasPeer parentPeer = (XCanvasPeer) parent.getPeer(); + if (parentPeer == null) + throw new NullPointerException("Parent has no peer. This should " + + "not be possible, since the " + + "calls leading here should come " + + "from parent, after it has " + + "set the parent peer."); + return parentPeer.window; + } + + + /** + * Template method to allow subclasses to apply properties to X11 + * window right after creation. + */ + void initWindowProperties() + { + } + + XToolkit getXToolkit() + { + return XToolkit.INSTANCE; + } + + protected void ensureFlush() + { + getXToolkit().flushIfIdle(); + } + + public Component getComponent() + { + return component; + } + + long getBasicEventMask() + { + return WindowAttributes.MASK_EXPOSURE; + } + + // -------- java.awt.peer.ComponentPeer implementation + + public int checkImage(Image img, int width, int height, ImageObserver o) + { + throw new UnsupportedOperationException("FIXME, not implemented"); + } + public Image createImage(ImageProducer prod) + { + return new XOffScreenImage (config, window, prod, config.getColorModel()); + } + public Image createImage(int width, int height) + { + return new XOffScreenImage (config, window, width, height, config.getColorModel()); + } + public void dispose() + { + throw new UnsupportedOperationException("FIXME, not implemented"); + } + + public GraphicsConfiguration getGraphicsConfiguration() + { + return config; + } + + public FontMetrics getFontMetrics(Font f) + { + throw new UnsupportedOperationException("FIXME, not implemented"); + } + + public ColorModel getColorModel () + { + return null; + } + + public Graphics getGraphics() + { + DirectRasterGraphics gfxDevice = new XGraphics(window, config); + IntegerGraphicsState igState = new IntegerGraphicsState(gfxDevice); + Graphics2DImpl gfx2d = new Graphics2DImpl(config); + + gfx2d.setState(igState); + gfx2d.setColor(component.getBackground()); + return gfx2d; + } + + private Rectangle locationBounds; + public Point getLocationOnScreen() + { + locationBounds = window.getBounds (locationBounds); + return new Point (locationBounds.x,locationBounds.y); + } + + public Dimension getMinimumSize () + { + return MIN_SIZE; + } + + public Dimension minimumSize () + { + return getMinimumSize (); + } + + public Dimension getPreferredSize () + { + return component.getSize(); + } + + public Dimension preferredSize () + { + return getPreferredSize(); + } + + public Toolkit getToolkit() + { + return getXToolkit(); + } + + public void handleEvent(AWTEvent event) + { + int id = event.getID (); + + switch (id) + { + case PaintEvent.PAINT: + case PaintEvent.UPDATE: + { + try + { + Graphics g = getGraphics (); + g.setClip (((PaintEvent)event).getUpdateRect ()); + + if (id == PaintEvent.PAINT) + component.paint (g); + else + component.update (g); + + g.dispose (); + } + catch (InternalError e) + { + System.err.println (e); + } + } + break; + } + } + + public boolean isFocusTraversable() + { + throw new UnsupportedOperationException("FIXME, not implemented"); + } + + public void paint(Graphics gfx) + { + // do nothing by default + } + + public boolean prepareImage(Image img, int width, int height, + ImageObserver o) + { + throw new UnsupportedOperationException("FIXME, not implemented"); + } + + public void print(Graphics graphics) + { + paint(graphics); + } + + public void repaint(long tm, int x, int y, int w, int h) + { + /* TODO? + + X allows intelligent X servers to do smart + refreshing. Perhaps involve X in repainting of components, + rather that keeping it all within the local event queue. */ + + PaintEvent updateEvent = new PaintEvent(component, + PaintEvent.UPDATE, + new Rectangle(x, y, w, h)); + getXToolkit().queue.postEvent(updateEvent); + } + + public void requestFocus() + { + throw new UnsupportedOperationException("FIXME, not implemented"); + } + + public void setBackground(Color color) + { + if (color != null) + { + int[] components = + { + color.getRed (), + color.getGreen (), + color.getBlue (), + 0xff + }; + + ColorModel cm = config.getColorModel (); + long pixel = cm.getDataElement (components, 0); + attributes.setBackground (pixel); + window.setAttributes (attributes); + } + } + + public void setBounds(int x, int y, int width, int height) + { + width = Math.max(width, 1); + height = Math.max(height, 1); + window.setBounds(x, y, width, height); + ensureFlush(); + } + + public void reshape (int x, int y, int width, int height) + { + setBounds (x, y, width, height); + } + + public void setCursor(Cursor cursor) + { + throw new UnsupportedOperationException("FIXME, not implemented"); + } + + public void setEnabled(boolean enabled) + { + throw new UnsupportedOperationException("FIXME, not implemented"); + } + + public void enable () + { + setEnabled (true); + } + + public void disable () + { + setEnabled (false); + } + + public void setEventMask(long eventMask) + { + if (this.eventMask != eventMask) + { + this.eventMask = eventMask; + long xEventMask = getBasicEventMask (); + + if ((eventMask & AWTEvent.MOUSE_EVENT_MASK) != 0) + { + xEventMask |= + WindowAttributes.MASK_BUTTON_PRESS | + WindowAttributes.MASK_BUTTON_RELEASE; + } + + attributes.setEventMask (xEventMask); + window.setAttributes (attributes); + ensureFlush (); + } + } + + public void setFont(Font font) + { + /* default canvas peer does not keep track of font, since it won't + paint anything. */ + } + + public void setForeground(Color color) + { + /* default canvas peer does not keep track of foreground, since it won't + paint anything. */ + } + + public void setVisible(boolean visible) + { + if (visible) + { + window.map(); + ensureFlush(); + } + else + { + window.unmap(); + ensureFlush(); + } + } + + public void show () + { + setVisible (true); + } + + public void hide () + { + setVisible (false); + } + + public boolean isFocusable () + { + return false; + } + + public boolean requestFocus (Component source, boolean b1, + boolean b2, long x) + { + return false; + } + + public boolean requestFocus (Component source, boolean b1, + boolean b2, long x, + CausedFocusEvent.Cause cause) + { + return false; + } + + public boolean isObscured () + { + return false; + } + + public boolean canDetermineObscurity () + { + return false; + } + + public void coalescePaintEvent (PaintEvent e) + { + } + + public void updateCursorImmediately () + { + } + + public VolatileImage createVolatileImage (int width, int height) + { + return null; + } + + public boolean handlesWheelScrolling () + { + return false; + } + + public void createBuffers (int x, BufferCapabilities capabilities) + throws java.awt.AWTException + + { + } + + public Image getBackBuffer () + { + return null; + } + + public void flip (BufferCapabilities.FlipContents contents) + { + } + + public void destroyBuffers () + { + } + + static class DoMap implements Runnable + { + Window window; + public DoMap(Window w) + { + this.window = w; + } + + public void run() + { + window.map(); + } + } + + /** + * @since 1.5 + */ + public boolean isRestackSupported () + { + return false; + } + + /** + * @since 1.5 + */ + public void cancelPendingPaint (int x, int y, int width, int height) + { + } + + /** + * @since 1.5 + */ + public void restack () + { + } + + /** + * @since 1.5 + */ + public Rectangle getBounds () + { + return null; + } + + /** + * @since 1.5 + */ + public void reparent (ContainerPeer parent) + { + } + + /** + * @since 1.5 + */ + public void setBounds (int x, int y, int width, int height, int z) + { + } + + /** + * @since 1.5 + */ + public boolean isReparentSupported () + { + return false; + } + + /** + * @since 1.5 + */ + public void layout () + { + } +} diff --git a/libjava/gnu/awt/xlib/XEventLoop.h b/libjava/gnu/awt/xlib/XEventLoop.h new file mode 100644 index 000000000..8061e9a94 --- /dev/null +++ b/libjava/gnu/awt/xlib/XEventLoop.h @@ -0,0 +1,75 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __gnu_awt_xlib_XEventLoop__ +#define __gnu_awt_xlib_XEventLoop__ + +#pragma interface + +#include +extern "Java" +{ + namespace gnu + { + namespace awt + { + class LightweightRedirector; + namespace xlib + { + class XEventLoop; + } + } + namespace gcj + { + namespace xlib + { + class Display; + class XAnyEvent; + } + } + } + namespace java + { + namespace awt + { + class AWTEvent; + class Component; + class EventQueue; + } + } +} + +class gnu::awt::xlib::XEventLoop : public ::java::lang::Object +{ + +public: + XEventLoop(::gnu::gcj::xlib::Display *, ::java::awt::EventQueue *); + virtual void run(); +public: // actually package-private + virtual jboolean postNextEvent(jboolean); +public: + virtual ::java::awt::AWTEvent * getNextEvent(jboolean); +public: // actually package-private + virtual jboolean loadNextEvent(jboolean); + virtual ::java::awt::AWTEvent * createEvent(); + virtual ::java::awt::AWTEvent * createPaintEvent(::java::awt::Component *); + virtual ::java::awt::AWTEvent * createMouseEvent(jint, ::java::awt::Component *); + virtual void configureNotify(::java::lang::Object *); +public: + virtual void flushIfIdle(); +public: // actually package-private + virtual void setIdle(jboolean); + virtual jboolean isIdle(); + ::gnu::gcj::xlib::Display * __attribute__((aligned(__alignof__( ::java::lang::Object)))) display; + ::java::awt::EventQueue * queue; + ::gnu::gcj::xlib::XAnyEvent * anyEvent; +private: + ::java::lang::Thread * eventLoopThread; +public: // actually package-private + ::gnu::awt::LightweightRedirector * lightweightRedirector; + jboolean volatile idle; +public: + static ::java::lang::Class class$; +}; + +#endif // __gnu_awt_xlib_XEventLoop__ diff --git a/libjava/gnu/awt/xlib/XEventLoop.java b/libjava/gnu/awt/xlib/XEventLoop.java new file mode 100644 index 000000000..d0c46a804 --- /dev/null +++ b/libjava/gnu/awt/xlib/XEventLoop.java @@ -0,0 +1,274 @@ +package gnu.awt.xlib; + +/* Copyright (C) 2000 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +import java.awt.*; + +import gnu.awt.LightweightRedirector; +import gnu.gcj.xlib.Display; +import gnu.gcj.xlib.XAnyEvent; +import gnu.gcj.xlib.XExposeEvent; +import gnu.gcj.xlib.XButtonEvent; +import gnu.gcj.xlib.XConfigureEvent; +import java.awt.event.PaintEvent; +import java.awt.event.InputEvent; +import java.awt.event.MouseEvent; +import java.util.Vector; + +public class XEventLoop implements Runnable +{ + Display display; + EventQueue queue; + XAnyEvent anyEvent; + private Thread eventLoopThread; + + LightweightRedirector lightweightRedirector = new LightweightRedirector(); + + public XEventLoop(Display display, EventQueue queue) + { + this.display = display; + this.queue = queue; + + anyEvent = new XAnyEvent(display); + eventLoopThread = new Thread(this, "AWT thread for XEventLoop"); + eventLoopThread.start(); + } + + public void run () + { + // FIXME: do we need an interrupt mechanism for window shutdown? + while (true) + postNextEvent (true); + } + + /** If there's an event available, post it. + * @return true if an event was posted + */ + boolean postNextEvent(boolean block) + { + AWTEvent evt = getNextEvent(block); + if (evt != null) + queue.postEvent(evt); + return evt != null; + } + + /** Get the next event. + * @param block If true, block until an event becomes available + */ + public AWTEvent getNextEvent(boolean block) + { + // ASSERT: + if (isIdle()) + throw new Error("should not be idle"); + + AWTEvent event = null; + if (loadNextEvent(block)) + { + event = createEvent(); + event = lightweightRedirector.redirect(event); + } + return event; + } + + boolean loadNextEvent(boolean block) + { + boolean gotEvent = false; + try + { + setIdle(true); + + /* The code below will result in an XFlush(). However, + while we are waiting for events after calling XFlush(), + new X requests issued on other threads will not + automatically be flushed. This can lead to a deadlock + since XFlush() will not be called before after the + processing of the next event, and new events arriving + might be dependent on the delivery of the X + requests. + + Code that issues X requests should therefore call + flushIfIdle() after they're done, to ensure that the + requests are delivered in a timely manner. XFlush is not + run if event processing is underway, since we are assured + that the event loop execution will return to this point, + where requests are flushed again, before waiting for new + events. + + Alternatively, do the work on the AWT thread, since the + XEventQueue knows how to flush the display when it runs out + of events. */ + + //display.flush(); // implicit? + gotEvent = anyEvent.loadNext(block); + } + catch (RuntimeException re) + { + System.err.println("Exception thrown on event thread:" + re); + } + finally + { + setIdle(false); + } + return gotEvent; + } + + /** + * @returns an AWT event created based on the current XEvent. + * Returns null if the current XEvent does not map to any perticular + * AWT event. + */ + + AWTEvent createEvent () + { + int type = anyEvent.getType (); + // Ignore some events without further processing + switch (type) + { + // ignore "no expose" events, which are generated whenever a pixmap + // is copied to copied to a window which is entirely unobscured + case XAnyEvent.TYPE_NO_EXPOSE: + case XAnyEvent.TYPE_UNMAP_NOTIFY: // ignore for now + case XAnyEvent.TYPE_MAP_NOTIFY: // ignore for now + case XAnyEvent.TYPE_REPARENT_NOTIFY: // ignore for now + return null; + default: + break; // continue processing events not in ignore list + } + /* avoid attempting to get client data before client data has + been set. */ + Object peer; + synchronized (this) + { + peer = anyEvent.getWindow ().getClientData (); + } + + Component source = null; + + // Try to identify source component + + if (peer instanceof XCanvasPeer) + { + source = ((XCanvasPeer) peer).getComponent (); + } + + if (source == null) + { + String msg = "unable to locate source for event (" + + anyEvent + "): peer=" + peer; + throw new RuntimeException (msg); + } + + /* if a mapping from anyEvent to AWTEvent is possible, construct a + new AWTEvent and return it. */ + + switch (type) + { + case XAnyEvent.TYPE_EXPOSE: + return createPaintEvent (source); + case XAnyEvent.TYPE_BUTTON_PRESS: + case XAnyEvent.TYPE_BUTTON_RELEASE: + return createMouseEvent (type, source); + case XAnyEvent.TYPE_CONFIGURE_NOTIFY: + configureNotify (peer); + return null; + + default: + String msg = "Do not know how to handle event (" + anyEvent + ")"; + throw new RuntimeException (msg); + } + } + + AWTEvent createPaintEvent(Component src) + { + XExposeEvent expose = new XExposeEvent(anyEvent); + PaintEvent pe = new PaintEvent(src, PaintEvent.PAINT, + expose.getBounds()); + return pe; + } + + AWTEvent createMouseEvent(int type, Component src) + { + XButtonEvent buttonEvt = new XButtonEvent(anyEvent); + + int modifiers = 0; //buttonToModifierMap[buttonEvt.button]; + + /* Warning: this makes assumptions on the contents of + X.h... Button1 = 1, Button2 = 2, etc... */ + switch (buttonEvt.button) + { + case 1: + modifiers = InputEvent.BUTTON1_DOWN_MASK; + break; + case 2: + modifiers = InputEvent.BUTTON2_DOWN_MASK; + break; + case 3: + modifiers = InputEvent.BUTTON2_DOWN_MASK; + break; + } + + int state = buttonEvt.state; + + // remap bits from state to modifiers: + + if ((state & XButtonEvent.MASK_SHIFT) != 0) + modifiers |= InputEvent.SHIFT_MASK; + + + if ((state & XButtonEvent.MASK_CONTROL) != 0) + modifiers |= InputEvent.CTRL_MASK; + + + /* FIXME: we need additional X code to properly map MODn states to + input modifiers */ + + int clickCount = 1; // FIXME... Can't get this from X. + boolean popupTrigger = false; // FIXME: look up policy somewhere + + int x = buttonEvt.x; + int y = buttonEvt.y; + + int id = (type == XAnyEvent.TYPE_BUTTON_PRESS) ? + MouseEvent.MOUSE_PRESSED : + MouseEvent.MOUSE_RELEASED; + + MouseEvent me = new MouseEvent(src, + id, + buttonEvt.time, modifiers, + buttonEvt.x, buttonEvt.y, + clickCount, popupTrigger); + return me; + } + + void configureNotify(Object peerObj) + { + XConfigureEvent configEvent = new XConfigureEvent(anyEvent); + XFramePeer peer = (XFramePeer) peerObj; + + peer.configureNotify(configEvent); + } + + public void flushIfIdle() + { + if (isIdle()) + display.flush(); + } + + volatile boolean idle = false; + + final synchronized void setIdle(boolean idle) + { + this.idle = idle; + } + + final synchronized boolean isIdle() + { + return idle; + } +} diff --git a/libjava/gnu/awt/xlib/XEventQueue.h b/libjava/gnu/awt/xlib/XEventQueue.h new file mode 100644 index 000000000..ca41be73e --- /dev/null +++ b/libjava/gnu/awt/xlib/XEventQueue.h @@ -0,0 +1,50 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __gnu_awt_xlib_XEventQueue__ +#define __gnu_awt_xlib_XEventQueue__ + +#pragma interface + +#include +extern "Java" +{ + namespace gnu + { + namespace awt + { + namespace xlib + { + class XEventQueue; + } + } + namespace gcj + { + namespace xlib + { + class Display; + } + } + } + namespace java + { + namespace awt + { + class AWTEvent; + } + } +} + +class gnu::awt::xlib::XEventQueue : public ::java::awt::EventQueue +{ + +public: + XEventQueue(::gnu::gcj::xlib::Display *); + virtual ::java::awt::AWTEvent * getNextEvent(); +public: // actually package-private + ::gnu::gcj::xlib::Display * __attribute__((aligned(__alignof__( ::java::awt::EventQueue)))) display; +public: + static ::java::lang::Class class$; +}; + +#endif // __gnu_awt_xlib_XEventQueue__ diff --git a/libjava/gnu/awt/xlib/XEventQueue.java b/libjava/gnu/awt/xlib/XEventQueue.java new file mode 100644 index 000000000..b068daf1b --- /dev/null +++ b/libjava/gnu/awt/xlib/XEventQueue.java @@ -0,0 +1,99 @@ +/* Copyright (C) 2000 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.awt.xlib; + +import gnu.gcj.xlib.Display; +import java.awt.AWTEvent; +import java.awt.Component; +import java.awt.Container; +import java.awt.EventQueue; +import java.awt.event.ComponentEvent; +import java.awt.event.ContainerEvent; + +/** + * The main difference here from a standard EventQueue is that the X + * display connection is flushed before waiting for more events. + */ +public class XEventQueue extends EventQueue +{ + Display display; + + public XEventQueue(Display display) + { + this.display = display; + } + + public AWTEvent getNextEvent() throws InterruptedException + { + if ((peekEvent() == null) && (display != null)) + display.flush(); + AWTEvent event = super.getNextEvent(); + if (event != null) + { + switch (event.getID ()) + { + case ContainerEvent.COMPONENT_ADDED: + { + /* If a component has been added to a container, it needs to be + * invalidated, to ensure that it ultimately gets an addNotify. + * If it's not invalidated, the component will never display in + * an already-showing container (probably applies only to CardLayout). + * Perhaps this code should be in java.awt, but the problem only seems + * to happen with xlib peers (not with gtk peers) so it's here instead. + */ + ContainerEvent ce = (ContainerEvent)event; + ce.getChild ().invalidate (); + ce.getContainer ().validate (); + } + break; + + case ComponentEvent.COMPONENT_RESIZED: + { + ComponentEvent ce = (ComponentEvent)event; + // FIXME: there may be opportunities to coalesce resize events + ce.getComponent ().validate (); + } + break; + + case ComponentEvent.COMPONENT_SHOWN: + { + ComponentEvent ce = (ComponentEvent)event; + Component comp = ce.getComponent (); + if (!comp.isValid ()) + { + /* Try to validate, going up the tree to the highest-level invalid + * Container. The idea is to ensure that addNotify gets called for + * any non-top-level component being shown, to make it create a peer. + */ + Container parent = comp.getParent (); + while (parent != null) + { + Container next = parent.getParent (); + if (next == null || next.isValid ()) + { + parent.validate (); + break; + } + else + parent = next; + } + if (comp instanceof Container) + comp.validate (); + } + comp.repaint (); + } + break; + + default: + break; + } + } + return event; + } +} diff --git a/libjava/gnu/awt/xlib/XFontMetrics.h b/libjava/gnu/awt/xlib/XFontMetrics.h new file mode 100644 index 000000000..55b218978 --- /dev/null +++ b/libjava/gnu/awt/xlib/XFontMetrics.h @@ -0,0 +1,54 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __gnu_awt_xlib_XFontMetrics__ +#define __gnu_awt_xlib_XFontMetrics__ + +#pragma interface + +#include +extern "Java" +{ + namespace gnu + { + namespace awt + { + namespace xlib + { + class XFontMetrics; + } + } + namespace gcj + { + namespace xlib + { + class Font; + } + } + } + namespace java + { + namespace awt + { + class Font; + } + } +} + +class gnu::awt::xlib::XFontMetrics : public ::java::awt::FontMetrics +{ + +public: + XFontMetrics(::gnu::gcj::xlib::Font *, ::java::awt::Font *); + virtual jint getAscent(); + virtual jint getDescent(); + virtual jint getMaxAscent(); + virtual jint getMaxDescent(); + virtual jint stringWidth(::java::lang::String *); +public: // actually package-private + ::gnu::gcj::xlib::Font * __attribute__((aligned(__alignof__( ::java::awt::FontMetrics)))) xfont; +public: + static ::java::lang::Class class$; +}; + +#endif // __gnu_awt_xlib_XFontMetrics__ diff --git a/libjava/gnu/awt/xlib/XFontMetrics.java b/libjava/gnu/awt/xlib/XFontMetrics.java new file mode 100644 index 000000000..4e45a1f82 --- /dev/null +++ b/libjava/gnu/awt/xlib/XFontMetrics.java @@ -0,0 +1,47 @@ +/* Copyright (C) 2000 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.awt.xlib; + +import java.awt.FontMetrics; + +public class XFontMetrics extends FontMetrics +{ + gnu.gcj.xlib.Font xfont; + + public XFontMetrics(gnu.gcj.xlib.Font xfont, java.awt.Font awtFont) + { + super(awtFont); + this.xfont = xfont; + } + + public int getAscent() + { + return xfont.getAscent(); + } + + public int getDescent() + { + return xfont.getDescent(); + } + + public int getMaxAscent() + { + return xfont.getMaxAscent(); + } + + public int getMaxDescent() + { + return xfont.getMaxDescent(); + } + + public int stringWidth(String str) + { + return xfont.getStringWidth(str); + } +} diff --git a/libjava/gnu/awt/xlib/XFontPeer.h b/libjava/gnu/awt/xlib/XFontPeer.h new file mode 100644 index 000000000..b497d06cb --- /dev/null +++ b/libjava/gnu/awt/xlib/XFontPeer.h @@ -0,0 +1,73 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __gnu_awt_xlib_XFontPeer__ +#define __gnu_awt_xlib_XFontPeer__ + +#pragma interface + +#include +#include + +extern "Java" +{ + namespace gnu + { + namespace awt + { + namespace xlib + { + class XFontPeer; + } + } + } + namespace java + { + namespace awt + { + class Font; + class FontMetrics; + namespace font + { + class FontRenderContext; + class GlyphVector; + class LineMetrics; + } + namespace geom + { + class Rectangle2D; + } + } + namespace text + { + class CharacterIterator; + } + } +} + +class gnu::awt::xlib::XFontPeer : public ::gnu::java::awt::peer::ClasspathFontPeer +{ + +public: + XFontPeer(::java::lang::String *, jint); + XFontPeer(::java::lang::String *, jint, jfloat); + virtual jboolean canDisplay(::java::awt::Font *, jint); + virtual jint canDisplayUpTo(::java::awt::Font *, ::java::text::CharacterIterator *, jint, jint); + virtual ::java::awt::font::GlyphVector * createGlyphVector(::java::awt::Font *, ::java::awt::font::FontRenderContext *, ::java::text::CharacterIterator *); + virtual ::java::awt::font::GlyphVector * createGlyphVector(::java::awt::Font *, ::java::awt::font::FontRenderContext *, JArray< jint > *); + virtual jbyte getBaselineFor(::java::awt::Font *, jchar); + virtual ::java::awt::FontMetrics * getFontMetrics(::java::awt::Font *); + virtual ::java::lang::String * getGlyphName(::java::awt::Font *, jint); + virtual ::java::awt::font::LineMetrics * getLineMetrics(::java::awt::Font *, ::java::text::CharacterIterator *, jint, jint, ::java::awt::font::FontRenderContext *); + virtual ::java::awt::geom::Rectangle2D * getMaxCharBounds(::java::awt::Font *, ::java::awt::font::FontRenderContext *); + virtual jint getMissingGlyphCode(::java::awt::Font *); + virtual jint getNumGlyphs(::java::awt::Font *); + virtual ::java::lang::String * getPostScriptName(::java::awt::Font *); + virtual ::java::awt::geom::Rectangle2D * getStringBounds(::java::awt::Font *, ::java::text::CharacterIterator *, jint, jint, ::java::awt::font::FontRenderContext *); + virtual ::java::lang::String * getSubFamilyName(::java::awt::Font *, ::java::util::Locale *); + virtual jboolean hasUniformLineMetrics(::java::awt::Font *); + virtual ::java::awt::font::GlyphVector * layoutGlyphVector(::java::awt::Font *, ::java::awt::font::FontRenderContext *, JArray< jchar > *, jint, jint, jint); + static ::java::lang::Class class$; +}; + +#endif // __gnu_awt_xlib_XFontPeer__ diff --git a/libjava/gnu/awt/xlib/XFontPeer.java b/libjava/gnu/awt/xlib/XFontPeer.java new file mode 100644 index 000000000..cd05a11fb --- /dev/null +++ b/libjava/gnu/awt/xlib/XFontPeer.java @@ -0,0 +1,277 @@ +/* Copyright (C) 2000, 2002, 2003 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.awt.xlib; + +import java.awt.*; +import gnu.java.awt.ClasspathToolkit; +import gnu.java.awt.peer.ClasspathFontPeer; +import java.util.Locale; +import java.awt.font.*; +import java.awt.geom.*; +import java.text.CharacterIterator; + +/** + * Classpath-compatible peer for a font + */ +public class XFontPeer extends ClasspathFontPeer +{ + public XFontPeer (String name, int style) + { + this (name, style, 12 /* kludge */); + } + + public XFontPeer (String name, int style, float size) + { + super (name, style, (int)size); + } + + /** + * Implementation of {@link Font#canDisplay(char)} + * + * @param font the font this peer is being called from. This may be + * useful if you are sharing peers between Font objects. Otherwise it may + * be ignored. + */ + public boolean canDisplay (Font font, int c) + { + throw new UnsupportedOperationException (); + } + + /** + * Implementation of {@link Font#canDisplay(String)}, + * {@link Font#canDisplay(char [], int, int)}, and + * {@link Font#canDisplay(CharacterIterator, int, int)}. + * + * @param font the font this peer is being called from. This may be + * useful if you are sharing peers between Font objects. Otherwise it may + * be ignored. + */ + public int canDisplayUpTo (Font font, CharacterIterator i, int start, int limit) + { + throw new UnsupportedOperationException (); + } + + /** + * Implementation of {@link + * Font#createGlyphVector(FontRenderContext, String)}, {@link + * Font#createGlyphVector(FontRenderContext, char[])}, and {@link + * Font#createGlyphVector(FontRenderContext, CharacterIterator)}. + * + * @param font the font object that the created GlyphVector will return + * when it gets asked for its font. This argument is needed because the + * public API of {@link GlyphVector} works with {@link java.awt.Font}, + * not with font peers. + */ + public GlyphVector createGlyphVector (Font font, FontRenderContext frc, CharacterIterator ci) + { + throw new UnsupportedOperationException (); + } + + /** + * Implementation of {@link Font#createGlyphVector(FontRenderContext, + * int[])}. + * + * @param font the font object that the created GlyphVector will return + * when it gets asked for its font. This argument is needed because the + * public API of {@link GlyphVector} works with {@link java.awt.Font}, + * not with font peers. + */ + public GlyphVector createGlyphVector (Font font, FontRenderContext ctx, int[] glyphCodes) + { + throw new UnsupportedOperationException (); + } + + /** + * Implementation of {@link Font#getBaselineFor(char)} + * + * @param font the font this peer is being called from. This may be + * useful if you are sharing peers between Font objects. Otherwise it may + * be ignored. + */ + public byte getBaselineFor (Font font, char c) + { + throw new UnsupportedOperationException (); + } + + /** + * Implementation of {@link Font#getFontMetrics()} + * + * @param font the font this peer is being called from. This may be + * useful if you are sharing peers between Font objects. Otherwise it may + * be ignored. + */ + public FontMetrics getFontMetrics (Font font) + { + throw new UnsupportedOperationException (); + } + + /** Returns a name for the specified glyph. This is useful for + * generating PostScript or PDF files that embed some glyphs of a + * font. If the implementation follows glyph naming conventions + * specified by Adobe, search engines can extract the original text + * from the generated PostScript and PDF files. + * + *

This method is currently not used by GNU Classpath. However, + * it would be very useful for someone wishing to write a good + * PostScript or PDF stream provider for the + * javax.print package. + * + *

Names are not unique: Under some rare circumstances, + * the same name can be returned for different glyphs. It is + * therefore recommended that printer drivers check whether the same + * name has already been returned for antoher glyph, and make the + * name unique by adding the string ".alt" followed by the glyph + * index.

+ * + *

This situation would occur for an OpenType or TrueType font + * that has a post table of format 3 and provides a + * mapping from glyph IDs to Unicode sequences through a + * Zapf table. If the same sequence of Unicode + * codepoints leads to different glyphs (depending on contextual + * position, for example, or on typographic sophistication level), + * the same name would get synthesized for those glyphs. To avoid + * this, the font peer would have to go through the names of all + * glyphs, which would make this operation very inefficient with + * large fonts. + * + * @param font the font containing the glyph whose name is + * requested. + * + * @param glyphIndex the glyph whose name the caller wants to + * retrieve. + * + * @return the glyph name, or null if a font does not + * provide glyph names. + */ + public String getGlyphName (Font font, int glyphIndex) + { + throw new UnsupportedOperationException (); + } + + /** + * Implementation of {@link Font#getLineMetrics(CharacterIterator, int, + * int, FontRenderContext)} + * + * @param font the font this peer is being called from. This may be + * useful if you are sharing peers between Font objects. Otherwise it may + * be ignored. + */ + public LineMetrics getLineMetrics (Font font, CharacterIterator ci, int begin, int limit, FontRenderContext rc) + { + throw new UnsupportedOperationException (); + } + + /** + * Implementation of {@link Font#getMaxCharBounds(FontRenderContext)} + * + * @param font the font this peer is being called from. This may be + * useful if you are sharing peers between Font objects. Otherwise it may + * be ignored. + */ + public Rectangle2D getMaxCharBounds (Font font, FontRenderContext rc) + { + throw new UnsupportedOperationException (); + } + + /** + * Implementation of {@link Font#getMissingGlyphCode()} + * + * @param font the font this peer is being called from. This may be + * useful if you are sharing peers between Font objects. Otherwise it may + * be ignored. + */ + public int getMissingGlyphCode (Font font) + { + throw new UnsupportedOperationException (); + } + + /** + * Implementation of {@link Font#getNumGlyphs()} + * + * @param font the font this peer is being called from. This may be + * useful if you are sharing peers between Font objects. Otherwise it may + * be ignored. + */ + public int getNumGlyphs (Font font) + { + throw new UnsupportedOperationException (); + } + + /** + * Implementation of {@link Font#getPSName()} + * + * @param font the font this peer is being called from. This may be + * useful if you are sharing peers between Font objects. Otherwise it may + * be ignored. + */ + public String getPostScriptName (Font font) + { + throw new UnsupportedOperationException (); + } + + /** + * Implementation of {@link Font#getStringBounds(CharacterIterator, int, + * int, FontRenderContext)} + * + * @param font the font this peer is being called from. This may be + * useful if you are sharing peers between Font objects. Otherwise it may + * be ignored. + */ + public Rectangle2D getStringBounds (Font font, CharacterIterator ci, int begin, int limit, FontRenderContext frc) + { + throw new UnsupportedOperationException (); + } + + /** Returns the name of this font face inside the family, for example + * “Light”. + * + *

This method is currently not used by {@link Font}. However, + * this name would be needed by any serious desktop publishing + * application. + * + * @param font the font whose sub-family name is requested. + * + * @param locale the locale for which to localize the name. If + * locale is null, the returned name is + * localized to the user’s default locale. + * + * @return the name of the face inside its family, or + * null if the font does not provide a sub-family name. + */ + public String getSubFamilyName (Font font, Locale locale) + { + throw new UnsupportedOperationException (); + } + + /** + * Implementation of {@link Font#hasUniformLineMetrics()} + * + * @param font the font this peer is being called from. This may be + * useful if you are sharing peers between Font objects. Otherwise it may + * be ignored. + */ + public boolean hasUniformLineMetrics (Font font) + { + throw new UnsupportedOperationException (); + } + + /** + * Implementation of {@link Font#layoutGlyphVector(FontRenderContext, + * char[], int, int, int)}. + * + * @param font the font object that the created GlyphVector will return + * when it gets asked for its font. This argument is needed because the + * public API of {@link GlyphVector} works with {@link java.awt.Font}, + * not with font peers. + */ + public GlyphVector layoutGlyphVector (Font font, FontRenderContext frc, char[] chars, int start, int limit, int flags) + { + throw new UnsupportedOperationException (); + } +} diff --git a/libjava/gnu/awt/xlib/XFramePeer.h b/libjava/gnu/awt/xlib/XFramePeer.h new file mode 100644 index 000000000..1ca28c61a --- /dev/null +++ b/libjava/gnu/awt/xlib/XFramePeer.h @@ -0,0 +1,89 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __gnu_awt_xlib_XFramePeer__ +#define __gnu_awt_xlib_XFramePeer__ + +#pragma interface + +#include +extern "Java" +{ + namespace gnu + { + namespace awt + { + namespace xlib + { + class XFramePeer; + } + } + namespace gcj + { + namespace xlib + { + class Window; + class XConfigureEvent; + } + } + } + namespace java + { + namespace awt + { + class Dialog; + class Frame; + class Image; + class Insets; + class MenuBar; + class Rectangle; + } + } +} + +class gnu::awt::xlib::XFramePeer : public ::gnu::awt::xlib::XCanvasPeer +{ + +public: + XFramePeer(::java::awt::Frame *); +public: // actually package-private + virtual ::gnu::gcj::xlib::Window * locateParentWindow(::java::awt::Rectangle *); + virtual void initWindowProperties(); + virtual jlong getBasicEventMask(); + virtual void configureNotify(::gnu::gcj::xlib::XConfigureEvent *); +public: + virtual void setBounds(jint, jint, jint, jint); + virtual ::java::awt::Insets * getInsets(); + virtual ::java::awt::Insets * insets(); + virtual void beginValidate(); + virtual void endValidate(); + virtual void toBack(); + virtual void toFront(); + virtual void setIconImage(::java::awt::Image *); + virtual void setMenuBar(::java::awt::MenuBar *); + virtual void setTitle(::java::lang::String *); + virtual void setResizable(jboolean); + virtual jint getState(); + virtual void setState(jint); + virtual void setMaximizedBounds(::java::awt::Rectangle *); + virtual void beginLayout(); + virtual void endLayout(); + virtual jboolean isPaintPending(); + virtual void setBoundsPrivate(jint, jint, jint, jint); + virtual ::java::awt::Rectangle * getBoundsPrivate(); + virtual void updateAlwaysOnTop(); + virtual jboolean requestWindowFocus(); + virtual void setAlwaysOnTop(jboolean); + virtual void updateFocusableWindowState(); + virtual void setModalBlocked(::java::awt::Dialog *, jboolean); + virtual void updateMinimumSize(); + virtual void updateIconImages(); +private: + jboolean __attribute__((aligned(__alignof__( ::gnu::awt::xlib::XCanvasPeer)))) processingConfigureNotify; +public: // actually package-private + static ::java::awt::Insets * INSETS_0_PROTOTYPE; +public: + static ::java::lang::Class class$; +}; + +#endif // __gnu_awt_xlib_XFramePeer__ diff --git a/libjava/gnu/awt/xlib/XFramePeer.java b/libjava/gnu/awt/xlib/XFramePeer.java new file mode 100644 index 000000000..2f9b503af --- /dev/null +++ b/libjava/gnu/awt/xlib/XFramePeer.java @@ -0,0 +1,248 @@ +/* Copyright (C) 2000, 2002, 2003 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.awt.xlib; + +import java.awt.*; +import java.awt.peer.*; +import java.awt.image.*; +import gnu.gcj.xlib.WMSizeHints; +import gnu.gcj.xlib.WindowAttributes; +import gnu.gcj.xlib.Display; +import gnu.gcj.xlib.Visual; +import gnu.gcj.xlib.Screen; +import gnu.gcj.xlib.XConfigureEvent; + +/** FIXME: a lot of the code here should be moved down to XWindowPeer. */ + +public class XFramePeer extends XCanvasPeer implements FramePeer +{ + private boolean processingConfigureNotify = false; + + public XFramePeer(Frame frame) + { + super(frame); + + // Set some defaults for a toplevel component: + if (frame.getFont() == null) + frame.setFont(new Font("helvetica", Font.PLAIN, 12)); + + if (frame.getBackground() == null) + frame.setBackground(Color.lightGray); + + if (frame.getForeground() == null) + frame.setForeground(Color.black); + } + + /** Find parent window for toplevel window, ie. root window of + selected screen. Bounds are not changed. */ + gnu.gcj.xlib.Window locateParentWindow(Rectangle bounds) + { + Screen screen = config.getVisual().getScreen(); + return screen.getRootWindow(); + } + + void initWindowProperties() + { + Frame frame = (Frame) component; + setResizable(frame.isResizable()); + String title = frame.getTitle(); + if (!title.equals("")) setTitle(title); + } + + long getBasicEventMask() + { + return super.getBasicEventMask() | + WindowAttributes.MASK_STRUCTURE_NOTIFY; + } + + void configureNotify(XConfigureEvent configEvent) + { + processingConfigureNotify = true; // to avoid setBounds flood + component.setBounds(configEvent.getBounds()); + processingConfigureNotify = false; + } + + /* Overridden to ignore request to set bounds if the request occurs + while processing an XConfigureNotify event, in which case the X + window already has the desired bounds. + That's what java.awt.Window.setBoundsCallback is for, but it's + package-private, and using our own flag eliminates the need to + circumvent java security. + */ + public void setBounds(int x, int y, int width, int height) + { + if (!processingConfigureNotify) + super.setBounds(x, y, width, height); + } + + // Implementing ContainerPeer: + + static final Insets INSETS_0_PROTOTYPE = new Insets(0, 0, 0, 0); + + public Insets getInsets() + { + return (Insets) INSETS_0_PROTOTYPE.clone(); + } + + public Insets insets () + { + return getInsets (); + } + + public void beginValidate() + { + } + + public void endValidate() + { + // reassert sizing hints + Frame frame = (Frame) component; + setResizable(frame.isResizable()); + } + + + // Implementing WindowPeer: + + public void toBack() + { + window.toBack (); + } + + public void toFront() + { + window.toFront (); + } + + + // Implementing FramePeer: + + public void setIconImage(Image image) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public void setMenuBar(MenuBar mb) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + + public void setTitle(String title) + { + synchronized (window.getDisplay()) + { + // Oh, what a nice implementation :-) + window.setProperty("WM_NAME", "STRING", title); + + ensureFlush(); + } + } + + public void setResizable(boolean resizable) + { + Frame frame = (Frame) component; + + WMSizeHints sizeHints = new WMSizeHints(); + if (resizable) + { + Dimension minSize = frame.getMinimumSize(); + sizeHints.setMinSize(minSize.width, minSize.height); + + Dimension maxSize = frame.getMaximumSize(); + + if ((maxSize.width < Short.MAX_VALUE) || + (maxSize.height < Short.MAX_VALUE)) + { + maxSize.width = Math.min(maxSize.width, Short.MAX_VALUE); + maxSize.height = Math.min(maxSize.height, Short.MAX_VALUE); + sizeHints.setMaxSize(maxSize.width, maxSize.height); + } + } + else + { + // lock resizing to current bounds + Dimension size = frame.getSize(); + sizeHints.setMinSize(size.width, size.height); + sizeHints.setMaxSize(size.width, size.height); + } + sizeHints.applyNormalHints(window); + } + + public int getState () + { + return 0; + } + + public void setState (int state) + { + } + + public void setMaximizedBounds (Rectangle r) + { + } + + public void beginLayout () { } + public void endLayout () { } + public boolean isPaintPending () { return false; } + + /** + * @since 1.5 + */ + public void setBoundsPrivate (int x, int y, int width, int height) + { + // TODO: Implement this. + throw new UnsupportedOperationException("Not yet implemented."); + } + + public Rectangle getBoundsPrivate() + { + // TODO: Implement this. + throw new UnsupportedOperationException("Not yet implemented."); + } + + /** + * @since 1.5 + */ + public void updateAlwaysOnTop() + { + } + + /** + * @since 1.5 + */ + public boolean requestWindowFocus () + { + return false; + } + + public void setAlwaysOnTop(boolean alwaysOnTop) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public void updateFocusableWindowState() + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public void setModalBlocked(Dialog blocker, boolean blocked) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public void updateMinimumSize() + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public void updateIconImages() + { + throw new UnsupportedOperationException("not implemented yet"); + } +} diff --git a/libjava/gnu/awt/xlib/XGraphics$XRaster.h b/libjava/gnu/awt/xlib/XGraphics$XRaster.h new file mode 100644 index 000000000..8183599d6 --- /dev/null +++ b/libjava/gnu/awt/xlib/XGraphics$XRaster.h @@ -0,0 +1,53 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __gnu_awt_xlib_XGraphics$XRaster__ +#define __gnu_awt_xlib_XGraphics$XRaster__ + +#pragma interface + +#include +extern "Java" +{ + namespace gnu + { + namespace awt + { + namespace xlib + { + class XGraphics$XRaster; + } + } + namespace gcj + { + namespace xlib + { + class XImage; + } + } + } + namespace java + { + namespace awt + { + namespace image + { + class ColorModel; + class WritableRaster; + } + } + } +} + +class gnu::awt::xlib::XGraphics$XRaster : public ::gnu::awt::j2d::MappedRaster +{ + +public: + XGraphics$XRaster(::java::awt::image::WritableRaster *, ::gnu::gcj::xlib::XImage *, ::java::awt::image::ColorModel *); +public: // actually package-private + ::gnu::gcj::xlib::XImage * __attribute__((aligned(__alignof__( ::gnu::awt::j2d::MappedRaster)))) ximage; +public: + static ::java::lang::Class class$; +}; + +#endif // __gnu_awt_xlib_XGraphics$XRaster__ diff --git a/libjava/gnu/awt/xlib/XGraphics.h b/libjava/gnu/awt/xlib/XGraphics.h new file mode 100644 index 000000000..4098ba441 --- /dev/null +++ b/libjava/gnu/awt/xlib/XGraphics.h @@ -0,0 +1,92 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __gnu_awt_xlib_XGraphics__ +#define __gnu_awt_xlib_XGraphics__ + +#pragma interface + +#include +#include + +extern "Java" +{ + namespace gnu + { + namespace awt + { + namespace j2d + { + class MappedRaster; + } + namespace xlib + { + class XFontMetrics; + class XGraphics; + class XGraphicsConfiguration; + } + } + namespace gcj + { + namespace xlib + { + class Drawable; + class GC; + } + } + } + namespace java + { + namespace awt + { + class Color; + class Font; + class FontMetrics; + class Image; + class Rectangle; + class Shape; + namespace image + { + class ImageObserver; + } + } + } +} + +class gnu::awt::xlib::XGraphics : public ::java::lang::Object +{ + +public: + virtual ::java::lang::Object * clone(); + virtual void dispose(); + XGraphics(::gnu::gcj::xlib::Drawable *, ::gnu::awt::xlib::XGraphicsConfiguration *); + virtual void setColor(::java::awt::Color *); + virtual void setPaintMode(); + virtual void setXORMode(::java::awt::Color *); + virtual void setFont(::java::awt::Font *); + virtual ::java::awt::FontMetrics * getFontMetrics(::java::awt::Font *); + virtual void setClip(jint, jint, jint, jint); + virtual void setClip(::java::awt::Shape *); + virtual void copyArea(jint, jint, jint, jint, jint, jint); + virtual void drawLine(jint, jint, jint, jint); + virtual void drawRect(jint, jint, jint, jint); + virtual void fillRect(jint, jint, jint, jint); + virtual void drawArc(jint, jint, jint, jint, jint, jint); + virtual void fillArc(jint, jint, jint, jint, jint, jint); + virtual void drawPolyline(JArray< jint > *, JArray< jint > *, jint); + virtual void drawPolygon(JArray< jint > *, JArray< jint > *, jint); + virtual void fillPolygon(JArray< jint > *, JArray< jint > *, jint, jint, jint); + virtual void drawString(::java::lang::String *, jint, jint); + virtual jboolean drawImage(::java::awt::Image *, jint, jint, ::java::awt::image::ImageObserver *); + virtual ::gnu::awt::j2d::MappedRaster * mapRaster(::java::awt::Rectangle *); + virtual void unmapRaster(::gnu::awt::j2d::MappedRaster *); +public: // actually package-private + ::gnu::gcj::xlib::GC * __attribute__((aligned(__alignof__( ::java::lang::Object)))) context; + ::gnu::awt::xlib::XGraphicsConfiguration * config; + ::java::awt::Rectangle * clipBounds; + ::gnu::awt::xlib::XFontMetrics * metrics; +public: + static ::java::lang::Class class$; +}; + +#endif // __gnu_awt_xlib_XGraphics__ diff --git a/libjava/gnu/awt/xlib/XGraphics.java b/libjava/gnu/awt/xlib/XGraphics.java new file mode 100644 index 000000000..215c04dc1 --- /dev/null +++ b/libjava/gnu/awt/xlib/XGraphics.java @@ -0,0 +1,305 @@ +/* Copyright (C) 2000, 2003, 2004 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.awt.xlib; + +import java.awt.*; +import java.awt.image.WritableRaster; +import java.awt.image.Raster; +import java.awt.image.DataBuffer; +import java.awt.image.ColorModel; +import java.awt.image.ImageObserver; +import java.awt.image.BufferedImage; +import gnu.gcj.xlib.GC; +import gnu.gcj.xlib.XImage; +import gnu.gcj.xlib.Drawable; +import gnu.gcj.xlib.Window; +import gnu.gcj.xlib.Drawable; +import gnu.gcj.xlib.Pixmap; +import gnu.gcj.xlib.Visual; +import gnu.awt.j2d.DirectRasterGraphics; +import gnu.awt.j2d.MappedRaster; + +public class XGraphics implements Cloneable, DirectRasterGraphics +{ + static class XRaster extends MappedRaster + { + XImage ximage; + + public XRaster(WritableRaster raster, XImage ximage, ColorModel cm) + { + super(raster, cm); + this.ximage = ximage; + } + } + + GC context; + XGraphicsConfiguration config; + Rectangle clipBounds; + + XFontMetrics metrics; + + + public Object clone() + { + try + { + XGraphics gfxCopy = (XGraphics) super.clone(); + gfxCopy.context = context.create(); + + return gfxCopy; + } + catch (CloneNotSupportedException ex) + { + // This should never happen. + throw new InternalError (); + } + } + + public void dispose() + { + GC lContext = context; + context = null; + config = null; + clipBounds = null; + metrics = null; + + if (lContext != null) + { + lContext.dispose(); + } + } + + public XGraphics(Drawable drawable, XGraphicsConfiguration config) + { + context = GC.create(drawable); + this.config = config; + } + + public void setColor(Color color) + { + if (color != null) + context.setForeground(config.getPixel(color)); + } + + public void setPaintMode() + { + throw new UnsupportedOperationException("not implemented"); + } + + public void setXORMode(Color c1) + { + throw new UnsupportedOperationException("not implemented"); + } + + public void setFont(Font font) + { + if (font == null) + return; + if ((metrics != null) && font.equals(metrics.getFont())) + return; + metrics = config.getXFontMetrics(font); + if (metrics != null) + context.setFont(metrics.xfont); + } + + public FontMetrics getFontMetrics(Font font) + { + if ((metrics != null) && font.equals(metrics.getFont())) + return metrics; + + return config.getXFontMetrics(font); + } + + public void setClip(int x, int y, int width, int height) + { + Rectangle[] rects = { new Rectangle(x, y, width, height) }; + context.setClipRectangles(rects); + } + + public void setClip(Shape clip) + { + /* TODO: create a special RectangleUnion shape that can be + used to draw advantage of the GCs ability to set multiple + rectangles. + */ + + /* FIXME: creating all these objects is wasteful and can be + costly in the long run, since this code is run at every + expose. */ + Rectangle newClipBounds = clip.getBounds(); + + /* FIXME: decide whether this test code is worth anything + * (as of 2004-01-29, it prints frequently) + if ((clipBounds != null) && !clipBounds.contains(newClipBounds)) + { + System.err.println("warning: old clip ("+ clipBounds +") does " + + "not fully contain new clip (" + + newClipBounds + ")"); + } + */ + clipBounds = newClipBounds; + Rectangle[] rects = { clipBounds }; + context.setClipRectangles(rects); + } + + public void copyArea(int x, int y, int width, int height, int + dx, int dy) + { + throw new UnsupportedOperationException("not implemented"); + } + + public void drawLine(int x1, int y1, int x2, int y2) + { + context.drawLine(x1, y1, x2, y2); + } + + public void drawRect(int x, int y, int width, int height) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public void fillRect(int x, int y, int width, int height) + { + context.fillRectangle(x, y, width, height); + } + + public void drawArc(int x, int y, int width, int height, int + startAngle, int arcAngle) + { + context.drawArc (x, y, width, height, startAngle, arcAngle); + } + + public void fillArc(int x, int y, int width, int height, int + startAngle, int arcAngle) + { + context.fillArc (x, y, width, height, startAngle, arcAngle); + } + + public void drawPolyline(int[] xPoints, int[] yPoints, int + nPoints) + { + throw new UnsupportedOperationException("not implemented"); + } + + public void drawPolygon(int[] xPoints, int[] yPoints, int + nPoints) + { + throw new UnsupportedOperationException("not implemented"); + } + + public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints, + int translateX, int translateY) + { + context.fillPolygon(xPoints, yPoints, nPoints, translateX, translateY); + } + + public void drawString(String str, int x, int y) + { + context.drawString(str, x, y); + } + + public boolean drawImage(Image img, int x, int y, + ImageObserver observer) + { + if (img instanceof XOffScreenImage) + { + // FIXME: have to enforce clip, or is it OK as-is? + XOffScreenImage offScreenImage = (XOffScreenImage) img; + Pixmap pixmap = offScreenImage.getPixmap (); + context.copyArea (pixmap, 0, 0, x, y, + offScreenImage.getWidth (), offScreenImage.getHeight ()); + return true; + } + if (clipBounds == null) + return false; // ***FIXME*** + + if (!(img instanceof BufferedImage)) + { + throw new AWTError("unknown image class"); + } + + BufferedImage bimg = (BufferedImage) img; + + XImage ximg = (XImage) bimg.getProperty("gnu.gcj.xlib.XImage"); + if (ximg == null) + { + System.err.println("FIXME: skipping null XImage, should " + + "really do on the spot conversion"); + return false; + } + + /* + +------------------ + | clip + | +---------+ + | img | | + | +--+-------+ | + | | | | | + | | | | | + | | +-------+-+ + | | | + | +----------+ + */ + + int iLeft = Math.max(x, clipBounds.x); + int iTop = Math.max(y, clipBounds.y); + int iRight = Math.min(x + bimg.getWidth(), + clipBounds.x + clipBounds.width); + int iBottom = Math.min(y + bimg.getHeight(), + clipBounds.y + clipBounds.height); + + int srcX = iLeft - x; + int srcY = iTop - y; + + int width = iRight - iLeft; + int height = iBottom - iTop; + + if ((width > 0) && (height > 0)) + context.putImage(ximg, srcX, srcY, iLeft, iTop, width, height); + + return true; + } + + public MappedRaster mapRaster(Rectangle bounds) + { + Visual visual = config.getVisual(); + XImage ximage = new XImage(visual, bounds.width, bounds.height, + false // do not auto allocate memory + ); + + WritableRaster raster = + config.createRasterForXImage(ximage, + new Point(bounds.x, bounds.y)); + + DataBuffer dataB = raster.getDataBuffer(); + XGraphicsConfiguration.attachData(ximage, dataB, 0); + + Drawable drawable = context.getDrawable(); + + // TODO: restrict to clipping + + Rectangle mBounds = drawable.copyIntoXImage(ximage, bounds, 0, 0); + + return new XRaster(raster, ximage, config.imageCM); + } + + + public void unmapRaster(MappedRaster mappedRaster) + { + XRaster xraster = (XRaster) mappedRaster; + XImage ximage = xraster.ximage; + Raster raster = xraster.getRaster(); + int x = raster.getMinX(); + int y = raster.getMinY(); + int width = raster.getWidth(); + int height = raster.getHeight(); + + context.putImage(ximage, 0, 0, x, y, width, height); + } +} diff --git a/libjava/gnu/awt/xlib/XGraphicsConfiguration$FontMetricsCache$PerDisplayCache$CacheEntry.h b/libjava/gnu/awt/xlib/XGraphicsConfiguration$FontMetricsCache$PerDisplayCache$CacheEntry.h new file mode 100644 index 000000000..42e3c8dbf --- /dev/null +++ b/libjava/gnu/awt/xlib/XGraphicsConfiguration$FontMetricsCache$PerDisplayCache$CacheEntry.h @@ -0,0 +1,46 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __gnu_awt_xlib_XGraphicsConfiguration$FontMetricsCache$PerDisplayCache$CacheEntry__ +#define __gnu_awt_xlib_XGraphicsConfiguration$FontMetricsCache$PerDisplayCache$CacheEntry__ + +#pragma interface + +#include +extern "Java" +{ + namespace gnu + { + namespace awt + { + namespace xlib + { + class XFontMetrics; + class XGraphicsConfiguration$FontMetricsCache$PerDisplayCache; + class XGraphicsConfiguration$FontMetricsCache$PerDisplayCache$CacheEntry; + } + } + } + namespace java + { + namespace awt + { + class Font; + } + } +} + +class gnu::awt::xlib::XGraphicsConfiguration$FontMetricsCache$PerDisplayCache$CacheEntry : public ::java::lang::Object +{ + +public: // actually package-private + XGraphicsConfiguration$FontMetricsCache$PerDisplayCache$CacheEntry(::gnu::awt::xlib::XGraphicsConfiguration$FontMetricsCache$PerDisplayCache *); + jint __attribute__((aligned(__alignof__( ::java::lang::Object)))) lruOrder; + ::gnu::awt::xlib::XFontMetrics * fm; + ::java::awt::Font * font; + ::gnu::awt::xlib::XGraphicsConfiguration$FontMetricsCache$PerDisplayCache * this$2; +public: + static ::java::lang::Class class$; +}; + +#endif // __gnu_awt_xlib_XGraphicsConfiguration$FontMetricsCache$PerDisplayCache$CacheEntry__ diff --git a/libjava/gnu/awt/xlib/XGraphicsConfiguration$FontMetricsCache$PerDisplayCache.h b/libjava/gnu/awt/xlib/XGraphicsConfiguration$FontMetricsCache$PerDisplayCache.h new file mode 100644 index 000000000..8a236d670 --- /dev/null +++ b/libjava/gnu/awt/xlib/XGraphicsConfiguration$FontMetricsCache$PerDisplayCache.h @@ -0,0 +1,49 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __gnu_awt_xlib_XGraphicsConfiguration$FontMetricsCache$PerDisplayCache__ +#define __gnu_awt_xlib_XGraphicsConfiguration$FontMetricsCache$PerDisplayCache__ + +#pragma interface + +#include +extern "Java" +{ + namespace gnu + { + namespace awt + { + namespace xlib + { + class XFontMetrics; + class XGraphicsConfiguration$FontMetricsCache; + class XGraphicsConfiguration$FontMetricsCache$PerDisplayCache; + } + } + } + namespace java + { + namespace awt + { + class Font; + } + } +} + +class gnu::awt::xlib::XGraphicsConfiguration$FontMetricsCache$PerDisplayCache : public ::java::lang::Object +{ + +public: // actually package-private + XGraphicsConfiguration$FontMetricsCache$PerDisplayCache(::gnu::awt::xlib::XGraphicsConfiguration$FontMetricsCache *); + virtual ::gnu::awt::xlib::XFontMetrics * get(::java::awt::Font *); + virtual void put(::java::awt::Font *, ::gnu::awt::xlib::XFontMetrics *); +private: + jint __attribute__((aligned(__alignof__( ::java::lang::Object)))) lruCount; + ::java::util::Hashtable * entries; +public: // actually package-private + ::gnu::awt::xlib::XGraphicsConfiguration$FontMetricsCache * this$1; +public: + static ::java::lang::Class class$; +}; + +#endif // __gnu_awt_xlib_XGraphicsConfiguration$FontMetricsCache$PerDisplayCache__ diff --git a/libjava/gnu/awt/xlib/XGraphicsConfiguration$FontMetricsCache.h b/libjava/gnu/awt/xlib/XGraphicsConfiguration$FontMetricsCache.h new file mode 100644 index 000000000..53935f518 --- /dev/null +++ b/libjava/gnu/awt/xlib/XGraphicsConfiguration$FontMetricsCache.h @@ -0,0 +1,52 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __gnu_awt_xlib_XGraphicsConfiguration$FontMetricsCache__ +#define __gnu_awt_xlib_XGraphicsConfiguration$FontMetricsCache__ + +#pragma interface + +#include +extern "Java" +{ + namespace gnu + { + namespace awt + { + namespace xlib + { + class XFontMetrics; + class XGraphicsConfiguration$FontMetricsCache; + } + } + namespace gcj + { + namespace xlib + { + class Display; + } + } + } + namespace java + { + namespace awt + { + class Font; + } + } +} + +class gnu::awt::xlib::XGraphicsConfiguration$FontMetricsCache : public ::java::lang::Object +{ + +public: // actually package-private + XGraphicsConfiguration$FontMetricsCache(); + virtual ::gnu::awt::xlib::XFontMetrics * get(::java::awt::Font *, ::gnu::gcj::xlib::Display *); + virtual void put(::java::awt::Font *, ::gnu::gcj::xlib::Display *, ::gnu::awt::xlib::XFontMetrics *); +private: + ::java::util::Hashtable * __attribute__((aligned(__alignof__( ::java::lang::Object)))) displays; +public: + static ::java::lang::Class class$; +}; + +#endif // __gnu_awt_xlib_XGraphicsConfiguration$FontMetricsCache__ diff --git a/libjava/gnu/awt/xlib/XGraphicsConfiguration.h b/libjava/gnu/awt/xlib/XGraphicsConfiguration.h new file mode 100644 index 000000000..b7f53eff9 --- /dev/null +++ b/libjava/gnu/awt/xlib/XGraphicsConfiguration.h @@ -0,0 +1,103 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __gnu_awt_xlib_XGraphicsConfiguration__ +#define __gnu_awt_xlib_XGraphicsConfiguration__ + +#pragma interface + +#include +extern "Java" +{ + namespace gnu + { + namespace awt + { + namespace xlib + { + class XFontMetrics; + class XGraphicsConfiguration; + class XGraphicsConfiguration$FontMetricsCache; + } + } + namespace gcj + { + namespace xlib + { + class Colormap; + class Visual; + class XImage; + } + } + } + namespace java + { + namespace awt + { + class Color; + class Font; + class GraphicsDevice; + class Point; + class Rectangle; + namespace geom + { + class AffineTransform; + } + namespace image + { + class BufferedImage; + class ColorModel; + class DataBuffer; + class VolatileImage; + class WritableRaster; + } + } + } +} + +class gnu::awt::xlib::XGraphicsConfiguration : public ::java::awt::GraphicsConfiguration +{ + +public: + XGraphicsConfiguration(::gnu::gcj::xlib::Visual *); + virtual ::java::awt::image::BufferedImage * createCompatibleImage(jint, jint); +public: // actually package-private + virtual ::java::awt::image::WritableRaster * createRasterForXImage(::gnu::gcj::xlib::XImage *, ::java::awt::Point *); + static void attachData(::gnu::gcj::xlib::XImage *, ::java::awt::image::DataBuffer *, jint); + virtual void prepareColorModel(::gnu::gcj::xlib::XImage *); + virtual void calcZPixmapModels(jint); + virtual void calcDecomposedRGBModels(jint); + virtual void calcPseudoColorModels(jint); +public: + virtual ::java::awt::GraphicsDevice * getDevice(); + virtual ::java::awt::image::BufferedImage * createCompatibleImage(jint, jint, jint); + virtual ::java::awt::image::VolatileImage * createCompatibleVolatileImage(jint, jint); + virtual ::java::awt::image::ColorModel * getColorModel(); +public: // actually package-private + virtual void preparePixelCM(); +public: + virtual ::java::awt::image::ColorModel * getColorModel(jint); + virtual ::java::awt::geom::AffineTransform * getDefaultTransform(); + virtual ::java::awt::geom::AffineTransform * getNormalizingTransform(); + virtual ::java::awt::Rectangle * getBounds(); +public: // actually package-private + virtual ::gnu::gcj::xlib::Visual * getVisual(); + virtual ::gnu::awt::xlib::XFontMetrics * getXFontMetrics(::java::awt::Font *); + virtual jint getPixel(::java::awt::Color *); +public: + virtual ::java::awt::image::VolatileImage * createCompatibleVolatileImage(jint, jint, jint); +public: // actually package-private + ::gnu::gcj::xlib::Visual * __attribute__((aligned(__alignof__( ::java::awt::GraphicsConfiguration)))) visual; + jint format; + ::gnu::gcj::xlib::Colormap * colormap; + ::java::awt::image::ColorModel * imageCM; + ::java::awt::image::ColorModel * pixelCM; +private: + static const jint CACHE_SIZE_PER_DISPLAY = 10; +public: // actually package-private + static ::gnu::awt::xlib::XGraphicsConfiguration$FontMetricsCache * fontMetricsCache; +public: + static ::java::lang::Class class$; +}; + +#endif // __gnu_awt_xlib_XGraphicsConfiguration__ diff --git a/libjava/gnu/awt/xlib/XGraphicsConfiguration.java b/libjava/gnu/awt/xlib/XGraphicsConfiguration.java new file mode 100644 index 000000000..7d527116d --- /dev/null +++ b/libjava/gnu/awt/xlib/XGraphicsConfiguration.java @@ -0,0 +1,550 @@ +/* Copyright (C) 2000, 2003 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.awt.xlib; + +import java.awt.GraphicsConfiguration; +import java.awt.Rectangle; +import java.awt.Graphics2D; +import java.awt.Graphics; +import java.awt.GraphicsDevice; +import java.awt.Point; +import java.awt.Color; +import java.awt.color.ColorSpace; +import java.awt.Font; +import java.awt.image.*; +import java.awt.geom.AffineTransform; +import gnu.gcj.xlib.GC; +import gnu.gcj.xlib.Drawable; +import gnu.gcj.xlib.Window; +import gnu.gcj.xlib.XImage; +import gnu.gcj.xlib.Visual; +import gnu.gcj.xlib.Colormap; +import gnu.gcj.xlib.XColor; +import gnu.gcj.xlib.Screen; +import gnu.gcj.xlib.Display; +import gnu.gcj.xlib.XException; +import gnu.java.awt.Buffers; +import java.util.Enumeration; +import java.util.Hashtable; + +public class XGraphicsConfiguration extends GraphicsConfiguration +{ + //public abstract GraphicsDevice getDevice(); + + Visual visual; + int format; + Colormap colormap; + ColorModel imageCM; + ColorModel pixelCM; + private static final int CACHE_SIZE_PER_DISPLAY = 10; + static FontMetricsCache fontMetricsCache = new FontMetricsCache (); + + /** Font metrics cache class. Caches at most CACHE_SIZE_PER_DISPLAY + * XFontMetrics objects for each display device. When a display's cache + * gets full, the least-recently used entry is overwritten. + * XXX: lruOrder rolls over after a few billion operations, so it might + * on very rare occasions misinterpret which is the oldest entry + */ + static class FontMetricsCache + { + private java.util.Hashtable displays = new java.util.Hashtable (); + + /** Font metrics cache for a display device + */ + class PerDisplayCache + { + private int lruCount = 0; + private java.util.Hashtable entries = new java.util.Hashtable (); + + class CacheEntry + { + int lruOrder; + XFontMetrics fm; + Font font; + } + + /** Get an entry (null if not there) and update LRU ordering + */ + XFontMetrics get (Font font) + { + CacheEntry entry = (CacheEntry)entries.get (font); + if (entry != null) + { + entry.lruOrder = lruCount++; + } + return (entry==null) ? null : entry.fm; + } + + /** Put an entry in the cache, eliminating the oldest entry if + * the cache is at capacity. + */ + void put (Font font, XFontMetrics fontMetrics) + { + if (entries.size () >= CACHE_SIZE_PER_DISPLAY) + { + // cache is full -- eliminate the oldest entry + // slow operation, but shouldn't happen very often + int maxAge = 0; + CacheEntry oldestEntry = null; + int referenceCount = lruCount; + for (Enumeration e = entries.elements (); e.hasMoreElements ();) + { + CacheEntry entry = (CacheEntry)e.nextElement (); + if ((referenceCount-entry.lruOrder) > maxAge) + { + maxAge = referenceCount-entry.lruOrder; + oldestEntry = entry; + } + } + if (oldestEntry != null) + entries.remove (oldestEntry.font); + } + CacheEntry newEntry = new CacheEntry (); + newEntry.lruOrder = lruCount++; + newEntry.fm = fontMetrics; + newEntry.font = font; + entries.put (font,newEntry); + } + } + + /** Get the font metrics for a font, if it is present in the cache. + * @param font The AWT font for which to find the font metrics + * @param display The display, to select the cached entries for that display + * @return The font metrics, or null if not cached + */ + XFontMetrics get (Font font, Display display) + { + PerDisplayCache cache = (PerDisplayCache)displays.get (display); + return (cache==null) ? null : cache.get (font); + } + + /** Put a font in the cache + * @param font The font + * @param display The display + * @param fontMetrics The font metrics + */ + void put (Font font, Display display, XFontMetrics fontMetrics) + { + PerDisplayCache cache = (PerDisplayCache)displays.get (display); + if (cache == null) + { + cache = new PerDisplayCache (); + displays.put (display,cache); + } + cache.put (font,fontMetrics); + } + } + + public XGraphicsConfiguration(Visual visual) + { + this.visual = visual; + } + + public BufferedImage createCompatibleImage(int width, int height) + { + XImage ximg = new XImage(visual, width, height, + false // do not auto allocate memory + ); + + Point origin = new Point(0, 0); + WritableRaster raster = createRasterForXImage(ximg, origin); + + /* This is not a good way of doing this. Multiple toolkits may + want to share the BufferedImage. */ + Hashtable props = new Hashtable(); + props.put("gnu.gcj.xlib.XImage", ximg); + props.put("java.awt.GraphicsConfiguration", this); + + BufferedImage bimg = new BufferedImage(imageCM,raster, false, props); + + DataBuffer dataB = raster.getDataBuffer(); + attachData(ximg, dataB, 0); + return bimg; + } + + WritableRaster createRasterForXImage(XImage ximage, Point origin) + { + if (imageCM == null) prepareColorModel(ximage); + + /* + This will not work, since it creates a sample model that + does not necessarily match the format of the XImage. + + WritableRaster raster = + imageCM.createCompatibleWritableRaster(width, height); */ + + // Create a sample model matching the XImage: + + SampleModel imageSM = null; + + int width = ximage.getWidth(); + int height = ximage.getHeight(); + int bitsPerPixel = ximage.getBitsPerPixel(); + int dataType = + Buffers.smallestAppropriateTransferType(bitsPerPixel); + int bitsPerDataElement = DataBuffer.getDataTypeSize(dataType); + int scanlineStride = ximage.getBytesPerLine()*8/bitsPerDataElement; + + if (imageCM instanceof IndexColorModel) + { + int[] bandOffsets = {0}; + imageSM = new ComponentSampleModel(dataType, + width, height, + 1, // pixel stride + scanlineStride, + bandOffsets); + } + else if (imageCM instanceof PackedColorModel) + { + PackedColorModel pcm = (PackedColorModel) imageCM; + int[] masks = pcm.getMasks(); + + imageSM = new SinglePixelPackedSampleModel(dataType, + width, height, + scanlineStride, + masks); + } + + if (imageSM == null) + { + throw new UnsupportedOperationException("creating sample model " + + "for " + imageCM + + " not implemented"); + } + + WritableRaster raster = Raster.createWritableRaster(imageSM, origin); + return raster; + } + + + + /** + * Attach a the memory of a data buffer to an XImage + * structure. [This method is not gnu.awt.xlib specific, and should + * maybe be moved to a different location.] + * + * @param offset Offset to data. The given offset does not include + * data buffer offset, which will also be added. + */ + static void attachData(XImage ximage, DataBuffer dataB, int offset) + { + offset += dataB.getOffset(); + switch (dataB.getDataType()) + { + case DataBuffer.TYPE_BYTE: + ximage.setData(((DataBufferByte) dataB).getData(), offset); + break; + case DataBuffer.TYPE_USHORT: + ximage.setData(((DataBufferUShort) dataB).getData(), offset); + break; + case DataBuffer.TYPE_INT: + ximage.setData(((DataBufferInt) dataB).getData(), offset); + break; + default: + throw + new UnsupportedOperationException("Do not know how to " + + "set data for data " + + "type " + + dataB.getDataType()); + } + } + + void prepareColorModel(XImage ximage) + { + format = ximage.getFormat(); + int bitsPerPixel = ximage.getBitsPerPixel(); + switch (format) { + case XImage.ZPIXMAP_FORMAT: + calcZPixmapModels(bitsPerPixel); + break; + + default: + throw new UnsupportedOperationException("unimplemented format"); + } + } + + void calcZPixmapModels(int bitsPerPixel) + { + switch (visual.getVisualClass()) + { + case Visual.VC_TRUE_COLOR: + calcDecomposedRGBModels(bitsPerPixel); + break; + case Visual.VC_PSEUDO_COLOR: + calcPseudoColorModels(bitsPerPixel); + break; + default: + String msg = "unimplemented visual class"; + throw new UnsupportedOperationException(msg); + } + } + + void calcDecomposedRGBModels(int bitsPerPixel) + { + int dataType = Buffers.smallestAppropriateTransferType(bitsPerPixel); + + + if (DataBuffer.getDataTypeSize(dataType) == bitsPerPixel) + { + ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB); + + imageCM = new DirectColorModel(cs, + visual.getDepth(), + visual.getRedMask(), + visual.getGreenMask(), + visual.getBlueMask(), + 0, // no alpha + false, + dataType); + } + else + { + throw new + UnsupportedOperationException("unimplemented bits per pixel"); + } + } + + void calcPseudoColorModels(int bitsPerPixel) + { + if (colormap == null) + colormap = visual.getScreen().getDefaultColormap(); + + XColor[] colArray = colormap.getXColors(); + + int numCol = colArray.length; + byte[] rmap = new byte[numCol]; + byte[] gmap = new byte[numCol]; + byte[] bmap = new byte[numCol]; + byte[] amap = new byte[numCol]; + + for (int i=0; i < numCol; i++) + { + XColor color = colArray[i]; + if (color.getFlags() == Colormap.FLAG_SHARED) + { + rmap[i] = (byte) (color.getRed() >> 8); + gmap[i] = (byte) (color.getGreen() >> 8); + bmap[i] = (byte) (color.getBlue() >> 8); + amap[i] = (byte) 0xff; + } // else, leave default zero values... + } + + imageCM = new IndexColorModel(visual.getDepth(), numCol, + rmap, gmap, bmap, amap); + } + + /** + * Gets the associated device that this configuration describes. + * + * @return the device + */ + public GraphicsDevice getDevice() + { + throw new UnsupportedOperationException("not implemented"); + } + + /** + * Returns a buffered image optimized to this device, so that blitting can + * be supported in the buffered image. + * + * @param w the width of the buffer + * @param h the height of the buffer + * @return the buffered image, or null if none is supported + */ + public BufferedImage createCompatibleImage(int width, + int height, + int transparency) + { + throw new UnsupportedOperationException("not implemented"); + } + + /** + * Returns a buffered volatile image optimized to this device, so that + * blitting can be supported in the buffered image. Because the buffer is + * volatile, it can be optimized by native graphics accelerators. + * + * @param w the width of the buffer + * @param h the height of the buffer + * @return the buffered image, or null if none is supported + * @see Component#createVolatileImage(int, int) + * @since 1.4 + */ + public VolatileImage createCompatibleVolatileImage(int w, int h) + { + throw new UnsupportedOperationException("not implemented"); + } + + /** + * FIXME: I'm not sure which color model that should be returned here. + */ + public ColorModel getColorModel() + { + if (pixelCM == null) + preparePixelCM(); + return pixelCM; + } + + void preparePixelCM() + { + switch (visual.getVisualClass()) + { + case Visual.VC_TRUE_COLOR: + pixelCM = new DirectColorModel(visual.getDepth(), + visual.getRedMask(), + visual.getGreenMask(), + visual.getBlueMask()); + break; + case Visual.VC_PSEUDO_COLOR: + + if (colormap == null) + colormap = visual.getScreen().getDefaultColormap(); + + XColor[] colArray = colormap.getXColors(); + + int numCol = colArray.length; + byte[] rmap = new byte[numCol]; + byte[] gmap = new byte[numCol]; + byte[] bmap = new byte[numCol]; + byte[] amap = new byte[numCol]; + + for (int i=0; i < numCol; i++) + { + XColor color = colArray[i]; + if (color.getFlags() == Colormap.FLAG_SHARED) { + rmap[i] = (byte) (color.getRed() >> 8); + gmap[i] = (byte) (color.getGreen() >> 8); + bmap[i] = (byte) (color.getBlue() >> 8); + amap[i] = (byte) 0xff; + } // else, leave default zero values... + + } + + pixelCM = new IndexColorModel(visual.getDepth(), numCol, + rmap, gmap, bmap, amap); + break; + default: + throw new UnsupportedOperationException("not implemented"); + } + } + + public ColorModel getColorModel(int transparency) + { + throw new UnsupportedOperationException("not implemented"); + } + + public AffineTransform getDefaultTransform() + { + throw new UnsupportedOperationException("not implemented"); + } + + public AffineTransform getNormalizingTransform() + { + throw new UnsupportedOperationException("not implemented"); + } + + public Rectangle getBounds() + { + throw new UnsupportedOperationException("not implemented"); + } + + Visual getVisual() + { + return visual; + } + + /* FIXME: This should be moved to XGraphicsDevice... */ + XFontMetrics getXFontMetrics (java.awt.Font awtFont) + { + // If the metrics object for this font is already cached, use it. + // Otherwise create and cache it. + Display display = visual.getScreen ().getDisplay (); + XFontMetrics fm = fontMetricsCache.get (awtFont,display); + if (fm == null) + { + String foundry = "*"; + String family = awtFont.getName (); + String weight = awtFont.isBold () ? "bold" : "medium"; + String slant = awtFont.isItalic () ? "i" : "r"; + String sWidth = "*"; + String addStyle = ""; + String pixelSize = "*"; + String pointSize = awtFont.getSize () + "0"; + String xres = "*"; + String yres = "*"; + String spacing = "*"; + String averageWidth = "*"; + String charset = "iso10646-1"; // because we use functions like XDrawString16 + + String logicalFontDescription = + "-" + // FontNameRegistry prefix + foundry + "-" + family + "-" + weight + "-" + + slant + "-" + sWidth + "-" + addStyle + "-" + + pixelSize + "-" + pointSize + "-" + xres + "-" + + yres + "-" + spacing + "-" + averageWidth + "-"; + + // Try to load a Unicode font. If that doesn't work, try again, without + // specifying the character set. + try + { + gnu.gcj.xlib.Font xfont = new gnu.gcj.xlib.Font (display, logicalFontDescription + charset); + fm = new XFontMetrics (xfont, awtFont); + } + catch (XException e) + { + gnu.gcj.xlib.Font xfont = new gnu.gcj.xlib.Font (display, logicalFontDescription + "*-*"); + fm = new XFontMetrics (xfont, awtFont); + } + fontMetricsCache.put (awtFont,display,fm); + } + return fm; + } + + int getPixel(Color color) + { + /* FIXME: consider an integer technique whenever + * the ColorModel is 8 bits per color. + * The problem with using integers is that it doesn't work unless + * the colors are 8 bits each (as in the array), since ColorModel.getDataElement(int[],int) + * expects non-normalized values. For example, in a 16-bit display mode, you + * would typically have 5 bits each for red and blue, and 6 bits for green. + int[] components = + { + color.getRed (), + color.getGreen (), + color.getBlue (), + 0xff + }; + */ + + int[] unnormalizedComponents = { 0, 0, 0, 0xff }; + ColorModel cm = getColorModel (); + if (color != null) + { + float[] normalizedComponents = + { + ((float)color.getRed ()) / 255F, + ((float)color.getGreen ()) / 255F, + ((float)color.getBlue ()) / 255F, + 1 + }; + cm.getUnnormalizedComponents(normalizedComponents, 0, + unnormalizedComponents, 0); + } + return cm.getDataElement (unnormalizedComponents, 0); + } + + /** + * @since 1.5 + */ + public VolatileImage createCompatibleVolatileImage (int width, int height, + int transparency) + { + return null; + } +} diff --git a/libjava/gnu/awt/xlib/XGraphicsDevice.h b/libjava/gnu/awt/xlib/XGraphicsDevice.h new file mode 100644 index 000000000..d5dc2f128 --- /dev/null +++ b/libjava/gnu/awt/xlib/XGraphicsDevice.h @@ -0,0 +1,53 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __gnu_awt_xlib_XGraphicsDevice__ +#define __gnu_awt_xlib_XGraphicsDevice__ + +#pragma interface + +#include +#include + +extern "Java" +{ + namespace gnu + { + namespace awt + { + namespace xlib + { + class XGraphicsDevice; + class XToolkit; + } + } + } + namespace java + { + namespace awt + { + class GraphicsConfiguration; + } + } +} + +class gnu::awt::xlib::XGraphicsDevice : public ::java::awt::GraphicsDevice +{ + +public: + virtual jint getType(); + XGraphicsDevice(jint, ::gnu::awt::xlib::XToolkit *); + virtual ::java::lang::String * getIDstring(); + virtual JArray< ::java::awt::GraphicsConfiguration * > * getConfigurations(); + virtual ::java::awt::GraphicsConfiguration * getDefaultConfiguration(); + virtual jboolean isDisplayChangeSupported(); + virtual jboolean isFullScreenSupported(); +private: + jint __attribute__((aligned(__alignof__( ::java::awt::GraphicsDevice)))) id; + ::java::lang::String * IDstring; + JArray< ::java::awt::GraphicsConfiguration * > * configs; +public: + static ::java::lang::Class class$; +}; + +#endif // __gnu_awt_xlib_XGraphicsDevice__ diff --git a/libjava/gnu/awt/xlib/XGraphicsDevice.java b/libjava/gnu/awt/xlib/XGraphicsDevice.java new file mode 100755 index 000000000..4fe1c2387 --- /dev/null +++ b/libjava/gnu/awt/xlib/XGraphicsDevice.java @@ -0,0 +1,58 @@ +/* Copyright (C) 2005 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.awt.xlib; + +import java.awt.GraphicsDevice; +import java.awt.GraphicsConfiguration; + +public class XGraphicsDevice extends GraphicsDevice +{ + private int id; + private String IDstring; + private GraphicsConfiguration[] configs; + + public int getType() + { + return TYPE_RASTER_SCREEN; + } + + public XGraphicsDevice(int id, XToolkit toolkit) + { + this.id = id; + IDstring = "XGraphicsDevice " + id; + configs = new GraphicsConfiguration [1]; + configs[0] = toolkit.getDefaultXGraphicsConfiguration(); + } + + public String getIDstring() + { + return IDstring; + } + + public GraphicsConfiguration[] getConfigurations() + { + return configs; + } + + public GraphicsConfiguration getDefaultConfiguration() + { + return configs[0]; + } + + public boolean isDisplayChangeSupported() + { + return false; + } + + public boolean isFullScreenSupported() + { + return false; + } +} + diff --git a/libjava/gnu/awt/xlib/XGraphicsEnvironment.h b/libjava/gnu/awt/xlib/XGraphicsEnvironment.h new file mode 100644 index 000000000..0f09087ae --- /dev/null +++ b/libjava/gnu/awt/xlib/XGraphicsEnvironment.h @@ -0,0 +1,60 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __gnu_awt_xlib_XGraphicsEnvironment__ +#define __gnu_awt_xlib_XGraphicsEnvironment__ + +#pragma interface + +#include +#include + +extern "Java" +{ + namespace gnu + { + namespace awt + { + namespace xlib + { + class XGraphicsDevice; + class XGraphicsEnvironment; + class XToolkit; + } + } + } + namespace java + { + namespace awt + { + class Font; + class Graphics2D; + class GraphicsDevice; + namespace image + { + class BufferedImage; + } + } + } +} + +class gnu::awt::xlib::XGraphicsEnvironment : public ::java::awt::GraphicsEnvironment +{ + +public: // actually package-private + XGraphicsEnvironment(::gnu::awt::xlib::XToolkit *); +public: + virtual JArray< ::java::awt::GraphicsDevice * > * getScreenDevices(); + virtual ::java::awt::GraphicsDevice * getDefaultScreenDevice(); + virtual ::java::awt::Graphics2D * createGraphics(::java::awt::image::BufferedImage *); + virtual JArray< ::java::awt::Font * > * getAllFonts(); + virtual JArray< ::java::lang::String * > * getAvailableFontFamilyNames(::java::util::Locale *); + virtual JArray< ::java::lang::String * > * getAvailableFontFamilyNames(); +private: + ::gnu::awt::xlib::XToolkit * __attribute__((aligned(__alignof__( ::java::awt::GraphicsEnvironment)))) toolkit; + JArray< ::gnu::awt::xlib::XGraphicsDevice * > * devices; +public: + static ::java::lang::Class class$; +}; + +#endif // __gnu_awt_xlib_XGraphicsEnvironment__ diff --git a/libjava/gnu/awt/xlib/XGraphicsEnvironment.java b/libjava/gnu/awt/xlib/XGraphicsEnvironment.java new file mode 100755 index 000000000..64c799017 --- /dev/null +++ b/libjava/gnu/awt/xlib/XGraphicsEnvironment.java @@ -0,0 +1,59 @@ +/* Copyright (C) 2005 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.awt.xlib; + +import java.awt.GraphicsEnvironment; +import java.awt.GraphicsDevice; +import java.awt.Graphics2D; +import java.awt.Font; +import java.awt.image.BufferedImage; +import java.util.Locale; + +public class XGraphicsEnvironment extends GraphicsEnvironment +{ + private XToolkit toolkit; + private XGraphicsDevice [] devices; + + XGraphicsEnvironment (XToolkit toolkit) + { + this.toolkit = toolkit; + devices = new XGraphicsDevice [1]; + devices [0] = new XGraphicsDevice (0,toolkit); + } + + public GraphicsDevice[] getScreenDevices () + { + return devices; + } + + public GraphicsDevice getDefaultScreenDevice () + { + return devices [0]; + } + + public Graphics2D createGraphics (BufferedImage image) + { + throw new UnsupportedOperationException ("createGraphics not implemented yet in " + this.getClass ().getName ()); + } + + public Font[] getAllFonts() + { + throw new UnsupportedOperationException ("getAllFonts not implemented yet in " + this.getClass ().getName ()); + } + + public String[] getAvailableFontFamilyNames (Locale l) + { + throw new UnsupportedOperationException ("getAvailableFontFamilyNames not implemented yet in " + this.getClass ().getName ()); + } + + public String[] getAvailableFontFamilyNames () + { + throw new UnsupportedOperationException ("getAvailableFontFamilyNames not implemented yet in " + this.getClass ().getName ()); + } +} diff --git a/libjava/gnu/awt/xlib/XOffScreenImage.h b/libjava/gnu/awt/xlib/XOffScreenImage.h new file mode 100644 index 000000000..73ca8bfbc --- /dev/null +++ b/libjava/gnu/awt/xlib/XOffScreenImage.h @@ -0,0 +1,87 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __gnu_awt_xlib_XOffScreenImage__ +#define __gnu_awt_xlib_XOffScreenImage__ + +#pragma interface + +#include +#include + +extern "Java" +{ + namespace gnu + { + namespace awt + { + namespace xlib + { + class XGraphicsConfiguration; + class XOffScreenImage; + } + } + namespace gcj + { + namespace xlib + { + class Drawable; + class GC; + class Pixmap; + } + } + } + namespace java + { + namespace awt + { + class Graphics; + class GraphicsConfiguration; + namespace image + { + class ColorModel; + class ImageObserver; + class ImageProducer; + } + } + } +} + +class gnu::awt::xlib::XOffScreenImage : public ::java::awt::Image +{ + +public: // actually package-private + XOffScreenImage(::gnu::awt::xlib::XGraphicsConfiguration *, ::gnu::gcj::xlib::Drawable *, jint, jint, ::java::awt::image::ColorModel *); + XOffScreenImage(::gnu::awt::xlib::XGraphicsConfiguration *, ::gnu::gcj::xlib::Drawable *, ::java::awt::image::ImageProducer *, ::java::awt::image::ColorModel *); +public: + virtual ::gnu::gcj::xlib::Pixmap * getPixmap(); + virtual void flush(); + virtual ::java::awt::Graphics * getGraphics(); + virtual jint getHeight(::java::awt::image::ImageObserver *); + virtual jint getHeight(); + virtual ::java::awt::image::ImageProducer * getSource(); + virtual jint getWidth(::java::awt::image::ImageObserver *); + virtual jint getWidth(); + virtual ::java::lang::Object * getProperty(::java::lang::String *, ::java::awt::image::ImageObserver *); + virtual ::java::awt::GraphicsConfiguration * getGraphicsConfiguration(); + virtual void imageComplete(jint); + virtual void setColorModel(::java::awt::image::ColorModel *); + virtual void setDimensions(jint, jint); + virtual void setHints(jint); + virtual void setPixels(jint, jint, jint, jint, ::java::awt::image::ColorModel *, JArray< jint > *, jint, jint); + virtual void setPixels(jint, jint, jint, jint, ::java::awt::image::ColorModel *, JArray< jbyte > *, jint, jint); + virtual void setProperties(::java::util::Hashtable *); +private: + ::gnu::gcj::xlib::Pixmap * __attribute__((aligned(__alignof__( ::java::awt::Image)))) pixmap; + ::gnu::awt::xlib::XGraphicsConfiguration * config; + jint width; + jint height; + ::gnu::gcj::xlib::Drawable * drawable; + ::java::awt::image::ImageProducer * prod; + ::gnu::gcj::xlib::GC * gc; + ::java::awt::image::ColorModel * pixmapColorModel; +public: + static ::java::lang::Class class$; +}; + +#endif // __gnu_awt_xlib_XOffScreenImage__ diff --git a/libjava/gnu/awt/xlib/XOffScreenImage.java b/libjava/gnu/awt/xlib/XOffScreenImage.java new file mode 100644 index 000000000..0ea6c1b3a --- /dev/null +++ b/libjava/gnu/awt/xlib/XOffScreenImage.java @@ -0,0 +1,280 @@ +/* Copyright (C) 2000, 2003 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.awt.xlib; + +import java.awt.Image; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GraphicsConfiguration; +import java.awt.image.ColorModel; +import java.awt.image.ImageObserver; +import java.awt.image.ImageProducer; +import java.awt.image.ImageConsumer; +import java.util.Hashtable; +import gnu.awt.j2d.DirectRasterGraphics; +import gnu.awt.j2d.Graphics2DImpl; +import gnu.awt.j2d.IntegerGraphicsState; +import gnu.gcj.xlib.Drawable; +import gnu.gcj.xlib.Pixmap; +import gnu.gcj.xlib.Screen; +import gnu.gcj.xlib.Visual; +import gnu.gcj.xlib.GC; + +/** Image class for xlib off-screen buffers. + * The image is stored in a server-side pixmap for best performance. + * This class supports getGraphics, so you can draw on the pixmap, and is + * specially handled when doing drawImage, so that the image copy is done + * entirely in the X server. + * This class does not support rasterization, for which you'd need an XImage. + * + * @author scott gilbertson + */ +public class XOffScreenImage extends Image + implements IntegerGraphicsState.ScreenCoupledImage, + ImageConsumer +{ + private Pixmap pixmap; + private XGraphicsConfiguration config; + private int width; + private int height; + private Drawable drawable; + private ImageProducer prod; + private GC gc; + private ColorModel pixmapColorModel; + + /** Create a new XOffScreenImage + * @param config Graphics configuration, to compare against on-screen + * components and to create the appropriate Graphics + * @param drawable The drawable with which the image is compatible + * @param width The width of the image + * @param height The height of the image + * @param cm The ColorModel associated with drawable + */ + XOffScreenImage (XGraphicsConfiguration config, Drawable drawable, int width, int height, ColorModel cm) + { + this.config = config; + this.width = width; + this.height = height; + this.drawable = drawable; + pixmapColorModel = cm; + pixmap = new Pixmap (drawable, width, height, drawable.getDepth ()); + gc = GC.create (pixmap); + } + + /** Create a new XOffScreenImage and obtain image data from an ImageProducer + * @param config Graphics configuration, to compare against on-screen + * components and to create the appropriate Graphics + * @param drawable The drawable with which the image is compatible + * @param prod The source of image data for this image + * @param cm The ColorModel associated with drawable + */ + XOffScreenImage (XGraphicsConfiguration config, Drawable drawable, ImageProducer prod, ColorModel cm) + { + this.config = config; + this.width = 0; // size will be overridden in a moment + this.height = 0; + this.drawable = drawable; + this.prod = prod; + pixmapColorModel = cm; + prod.startProduction (this); + } + + /** Get the pixmap which contains this image + * @return The pixmap + */ + public Pixmap getPixmap () + { + return pixmap; + } + + /** Flushes (that is, destroys) any resources used for this image. This + * includes the actual image data. + */ + public void flush () + { + // FIXME: should dispose pixmap + pixmap = null; + } + + /** Returns a graphics context object for drawing an off-screen object. + * This method is only valid for off-screen objects. + * + * @return a graphics context object for an off-screen object + * @see Graphics#createImage(int, int) + */ + public Graphics getGraphics () + { + DirectRasterGraphics gfxDevice = new XGraphics (pixmap, config); + IntegerGraphicsState igState = new IntegerGraphicsState (gfxDevice); + Graphics2DImpl gfx2d = new Graphics2DImpl (config); + gfx2d.setState (igState); + return gfx2d; + } + + /** Returns the height of the image, or -1 if it is unknown. If the + * image height is unknown, the observer object will be notified when + * the value is known. + * + * @param observer the image observer for this object + * @return the height in pixels + * @see #getWidth(ImageObserver) + */ + public int getHeight (ImageObserver observer) + { + return height; + } + + /** Returns the height of the image, or -1 if it is unknown. If the + * image height is unknown, the observer object will be notified when + * the value is known. + * + * @return the height in pixels + * @see #getWidth() + */ + public int getHeight () + { + return height; + } + + /** Returns the image producer object for this object. The producer is the + * object which generates pixels for this image. + * + * @return the image producer for this object + */ + public ImageProducer getSource () + { + if (prod == null) + throw new UnsupportedOperationException ("getSource not supported"); + else + return prod; + } + + /** Returns the width of the image, or -1 if it is unknown. If the + * image width is unknown, the observer object will be notified when + * the value is known. + * + * @param observer the image observer for this object + * @return the width in pixels + * @see #getHeight(ImageObserver) + */ + public int getWidth (ImageObserver observer) + { + return width; + } + + /** Returns the width of the image, or -1 if it is unknown. If the + * image width is unknown, the observer object will be notified when + * the value is known. + * + * @return the width in pixels + * @see #getHeight() + */ + public int getWidth () + { + return width; + } + + /** This method requests a named property for an object. The value of the + * property is returned. The value UndefinedProperty is + * returned if there is no property with the specified name. The value + * null is returned if the properties for the object are + * not yet known. In this case, the specified image observer is notified + * when the properties are known. + * + * @param name the requested property name + * @param observer the image observer for this object + * @return the named property, if available + * @see #UndefinedProperty + */ + public Object getProperty (String name, ImageObserver observer) + { + return null; + } + + /** Get the GraphicsConfiguration to which this image is coupled + * @return the GraphicsConfiguration + */ + public GraphicsConfiguration getGraphicsConfiguration () + { + return config; + } + + public void imageComplete (int status) + { + } + + public void setColorModel (ColorModel model) + { + } + + public void setDimensions (int width, int height) + { + this.width = width; + this.height = height; + pixmap = new Pixmap (drawable, width, height, drawable.getDepth ()); + gc = GC.create (pixmap); + } + + public void setHints (int flags) + { + } + + public void setPixels (int x, int y, int w, int h, ColorModel model, int[] pixels, int offset, int scansize) + { + int idx = 0; + float[] normalizedComponents = new float [4]; + int[] unnormalizedComponents = { 0, 0, 0, 0xff }; + normalizedComponents[3] = 1; + for (int yp=y; yp < (y + h); yp++) + { + for (int xp=x; xp < (x + w); xp++) + { + int p = (yp - y) * scansize + (xp - x) + offset; + // FIXME: there HAS to be a more efficient mechanism for color mapping + normalizedComponents[0] = (float)model.getRed (pixels[p]) / 255F; + normalizedComponents[1] = (float)model.getGreen (pixels[p]) / 255F; + normalizedComponents[2] = (float)model.getBlue (pixels[p]) / 255F; + pixmapColorModel.getUnnormalizedComponents (normalizedComponents, 0, + unnormalizedComponents, 0); + int pixelColor = pixmapColorModel.getDataElement (unnormalizedComponents, 0); + gc.setForeground (pixelColor); + gc.drawPoint (xp, yp); + } + } + } + + public void setPixels (int x, int y, int w, int h, ColorModel model, byte[] pixels, int offset, int scansize) + { + int idx = 0; + float[] normalizedComponents = new float [4]; + int[] unnormalizedComponents = { 0, 0, 0, 0xff }; + normalizedComponents[3] = 1; + for (int yp=y; yp < (y + h); yp++) + { + for (int xp=x; xp < (x + w); xp++) + { + // FIXME: there HAS to be a more efficient mechanism for color mapping + int p = (yp - y) * scansize + (xp - x) + offset; + normalizedComponents[0] = (float)model.getRed (pixels[p]) / 255F; + normalizedComponents[1] = (float)model.getGreen (pixels[p]) / 255F; + normalizedComponents[2] = (float)model.getBlue (pixels[p]) / 255F; + pixmapColorModel.getUnnormalizedComponents (normalizedComponents, 0, + unnormalizedComponents, 0); + int pixelColor = pixmapColorModel.getDataElement (unnormalizedComponents, 0); + gc.setForeground (pixelColor); + gc.drawPoint (xp, yp); + } + } + } + + public void setProperties (Hashtable props) + { + } + +} diff --git a/libjava/gnu/awt/xlib/XPanelPeer.h b/libjava/gnu/awt/xlib/XPanelPeer.h new file mode 100644 index 000000000..4fcc0c7ee --- /dev/null +++ b/libjava/gnu/awt/xlib/XPanelPeer.h @@ -0,0 +1,50 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __gnu_awt_xlib_XPanelPeer__ +#define __gnu_awt_xlib_XPanelPeer__ + +#pragma interface + +#include +extern "Java" +{ + namespace gnu + { + namespace awt + { + namespace xlib + { + class XPanelPeer; + } + } + } + namespace java + { + namespace awt + { + class Insets; + class Panel; + } + } +} + +class gnu::awt::xlib::XPanelPeer : public ::gnu::awt::xlib::XCanvasPeer +{ + +public: + XPanelPeer(::java::awt::Panel *); + virtual ::java::awt::Insets * getInsets(); + virtual ::java::awt::Insets * insets(); + virtual void beginValidate(); + virtual void endValidate(); + virtual void beginLayout(); + virtual void endLayout(); + virtual jboolean isPaintPending(); +public: // actually package-private + static ::java::awt::Insets * INSETS_0_PROTOTYPE; +public: + static ::java::lang::Class class$; +}; + +#endif // __gnu_awt_xlib_XPanelPeer__ diff --git a/libjava/gnu/awt/xlib/XPanelPeer.java b/libjava/gnu/awt/xlib/XPanelPeer.java new file mode 100644 index 000000000..0b775f872 --- /dev/null +++ b/libjava/gnu/awt/xlib/XPanelPeer.java @@ -0,0 +1,61 @@ +/* Copyright (C) 2000, 2002, 2003 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.awt.xlib; + +import java.awt.*; +import java.awt.peer.*; +import java.awt.image.*; +import gnu.gcj.xlib.WMSizeHints; +import gnu.gcj.xlib.WindowAttributes; +import gnu.gcj.xlib.Display; +import gnu.gcj.xlib.Visual; +import gnu.gcj.xlib.Screen; + +public class XPanelPeer extends XCanvasPeer implements PanelPeer +{ + + public XPanelPeer(Panel panel) + { + super(panel); + } + + // no reason to override yet + //void initWindowProperties(); + //gnu.gcj.xlib.Window getParentWindow(); + + + // Implementing ContainerPeer: + + // Default is no insets... + static final Insets INSETS_0_PROTOTYPE = new Insets(0, 0, 0, 0); + + public Insets getInsets() + { + return (Insets) INSETS_0_PROTOTYPE.clone(); + } + + public Insets insets() + { + return getInsets(); + } + + public void beginValidate() + { + // NOP + } + + public void endValidate() + { + // NOP + } + + public void beginLayout () { } + public void endLayout () { } + public boolean isPaintPending () { return false; } +} diff --git a/libjava/gnu/awt/xlib/XToolkit.h b/libjava/gnu/awt/xlib/XToolkit.h new file mode 100644 index 000000000..e4e35dbd2 --- /dev/null +++ b/libjava/gnu/awt/xlib/XToolkit.h @@ -0,0 +1,214 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __gnu_awt_xlib_XToolkit__ +#define __gnu_awt_xlib_XToolkit__ + +#pragma interface + +#include +#include + +extern "Java" +{ + namespace gnu + { + namespace awt + { + namespace xlib + { + class XEventLoop; + class XGraphicsConfiguration; + class XToolkit; + } + } + namespace gcj + { + namespace xlib + { + class Display; + } + } + namespace java + { + namespace awt + { + class EmbeddedWindow; + namespace peer + { + class ClasspathFontPeer; + class EmbeddedWindowPeer; + } + } + } + } + namespace java + { + namespace awt + { + class Button; + class Canvas; + class Checkbox; + class CheckboxMenuItem; + class Choice; + class Component; + class Dialog; + class Dialog$ModalExclusionType; + class Dialog$ModalityType; + class Dimension; + class EventQueue; + class FileDialog; + class Font; + class FontMetrics; + class Frame; + class GraphicsDevice; + class GraphicsEnvironment; + class Image; + class Label; + class List; + class Menu; + class MenuBar; + class MenuItem; + class Panel; + class PopupMenu; + class PrintJob; + class ScrollPane; + class Scrollbar; + class TextArea; + class TextField; + class Window; + namespace datatransfer + { + class Clipboard; + } + namespace dnd + { + class DragGestureEvent; + class DragGestureListener; + class DragGestureRecognizer; + class DragSource; + namespace peer + { + class DragSourceContextPeer; + } + } + namespace im + { + class InputMethodHighlight; + } + namespace image + { + class ColorModel; + class ImageObserver; + class ImageProducer; + } + namespace peer + { + class ButtonPeer; + class CanvasPeer; + class CheckboxMenuItemPeer; + class CheckboxPeer; + class ChoicePeer; + class DialogPeer; + class FileDialogPeer; + class FontPeer; + class FramePeer; + class LabelPeer; + class ListPeer; + class MenuBarPeer; + class MenuItemPeer; + class MenuPeer; + class PanelPeer; + class PopupMenuPeer; + class RobotPeer; + class ScrollPanePeer; + class ScrollbarPeer; + class TextAreaPeer; + class TextFieldPeer; + class WindowPeer; + } + } + namespace net + { + class URL; + } + } +} + +class gnu::awt::xlib::XToolkit : public ::gnu::java::awt::ClasspathToolkit +{ + +public: + XToolkit(); + virtual void flushIfIdle(); +public: // actually protected + virtual ::java::awt::peer::ButtonPeer * createButton(::java::awt::Button *); + virtual ::java::awt::peer::TextFieldPeer * createTextField(::java::awt::TextField *); + virtual ::java::awt::peer::LabelPeer * createLabel(::java::awt::Label *); + virtual ::java::awt::peer::ListPeer * createList(::java::awt::List *); + virtual ::java::awt::peer::CheckboxPeer * createCheckbox(::java::awt::Checkbox *); + virtual ::java::awt::peer::ScrollbarPeer * createScrollbar(::java::awt::Scrollbar *); + virtual ::java::awt::peer::ScrollPanePeer * createScrollPane(::java::awt::ScrollPane *); + virtual ::java::awt::peer::TextAreaPeer * createTextArea(::java::awt::TextArea *); + virtual ::java::awt::peer::ChoicePeer * createChoice(::java::awt::Choice *); + virtual ::java::awt::peer::FramePeer * createFrame(::java::awt::Frame *); + virtual ::java::awt::peer::CanvasPeer * createCanvas(::java::awt::Canvas *); + virtual ::java::awt::peer::PanelPeer * createPanel(::java::awt::Panel *); + virtual ::java::awt::peer::WindowPeer * createWindow(::java::awt::Window *); + virtual ::java::awt::peer::DialogPeer * createDialog(::java::awt::Dialog *); + virtual ::java::awt::peer::MenuBarPeer * createMenuBar(::java::awt::MenuBar *); + virtual ::java::awt::peer::MenuPeer * createMenu(::java::awt::Menu *); + virtual ::java::awt::peer::PopupMenuPeer * createPopupMenu(::java::awt::PopupMenu *); + virtual ::java::awt::peer::MenuItemPeer * createMenuItem(::java::awt::MenuItem *); + virtual ::java::awt::peer::FileDialogPeer * createFileDialog(::java::awt::FileDialog *); + virtual ::java::awt::peer::CheckboxMenuItemPeer * createCheckboxMenuItem(::java::awt::CheckboxMenuItem *); + virtual ::java::awt::peer::FontPeer * getFontPeer(::java::lang::String *, jint); +public: + virtual ::java::awt::Dimension * getScreenSize(); + virtual jint getScreenResolution(); + virtual ::java::awt::image::ColorModel * getColorModel(); + virtual JArray< ::java::lang::String * > * getFontList(); + virtual ::java::awt::FontMetrics * getFontMetrics(::java::awt::Font *); + virtual void sync(); + virtual ::java::awt::Image * getImage(::java::lang::String *); + virtual ::java::awt::Image * getImage(::java::net::URL *); + virtual ::java::awt::Image * createImage(::java::lang::String *); + virtual ::java::awt::Image * createImage(::java::net::URL *); + virtual jboolean prepareImage(::java::awt::Image *, jint, jint, ::java::awt::image::ImageObserver *); + virtual jint checkImage(::java::awt::Image *, jint, jint, ::java::awt::image::ImageObserver *); + virtual ::java::awt::Image * createImage(::java::awt::image::ImageProducer *); + virtual ::java::awt::Image * createImage(JArray< jbyte > *, jint, jint); + virtual void beep(); + virtual ::java::awt::datatransfer::Clipboard * getSystemClipboard(); +public: // actually protected + virtual ::java::awt::EventQueue * getSystemEventQueueImpl(); +public: + virtual ::java::awt::PrintJob * getPrintJob(::java::awt::Frame *, ::java::lang::String *, ::java::util::Properties *); +public: // actually package-private + virtual ::gnu::awt::xlib::XGraphicsConfiguration * getDefaultXGraphicsConfiguration(); +public: + virtual ::java::awt::dnd::peer::DragSourceContextPeer * createDragSourceContextPeer(::java::awt::dnd::DragGestureEvent *); + virtual ::java::awt::dnd::DragGestureRecognizer * createDragGestureRecognizer(::java::lang::Class *, ::java::awt::dnd::DragSource *, ::java::awt::Component *, jint, ::java::awt::dnd::DragGestureListener *); + virtual ::java::util::Map * mapInputMethodHighlight(::java::awt::im::InputMethodHighlight *); + virtual ::java::awt::GraphicsEnvironment * getLocalGraphicsEnvironment(); + virtual ::gnu::java::awt::peer::ClasspathFontPeer * getClasspathFontPeer(::java::lang::String *, ::java::util::Map *); + virtual ::java::awt::Font * createFont(jint, ::java::io::InputStream *); + virtual ::java::awt::peer::RobotPeer * createRobot(::java::awt::GraphicsDevice *); + virtual ::gnu::java::awt::peer::EmbeddedWindowPeer * createEmbeddedWindow(::gnu::java::awt::EmbeddedWindow *); + virtual jboolean nativeQueueEmpty(); + virtual void wakeNativeQueue(); + virtual void iterateNativeQueue(::java::awt::EventQueue *, jboolean); + virtual void setAlwaysOnTop(jboolean); + virtual jboolean isModalExclusionTypeSupported(::java::awt::Dialog$ModalExclusionType *); + virtual jboolean isModalityTypeSupported(::java::awt::Dialog$ModalityType *); +public: // actually package-private + static ::gnu::awt::xlib::XToolkit * INSTANCE; + ::gnu::gcj::xlib::Display * __attribute__((aligned(__alignof__( ::gnu::java::awt::ClasspathToolkit)))) display; + ::java::awt::EventQueue * queue; + ::gnu::awt::xlib::XEventLoop * eventLoop; + ::gnu::awt::xlib::XGraphicsConfiguration * defaultConfig; +public: + static ::java::lang::Class class$; +}; + +#endif // __gnu_awt_xlib_XToolkit__ diff --git a/libjava/gnu/awt/xlib/XToolkit.java b/libjava/gnu/awt/xlib/XToolkit.java new file mode 100644 index 000000000..681aad6d2 --- /dev/null +++ b/libjava/gnu/awt/xlib/XToolkit.java @@ -0,0 +1,502 @@ +/* Copyright (C) 2000, 2002, 2003, 2005 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.awt.xlib; + +import java.awt.*; +import java.awt.dnd.*; +import java.awt.dnd.peer.*; +import java.awt.font.*; +import java.awt.im.*; +import java.awt.peer.*; +import java.awt.image.ImageProducer; +import java.awt.image.ImageObserver; +import java.net.*; +import java.awt.datatransfer.Clipboard; +import java.io.InputStream; +import java.text.AttributedString; +import java.util.Map; +import java.util.Properties; +import gnu.gcj.xlib.Display; +import gnu.gcj.xlib.Screen; +import gnu.gcj.xlib.Visual; +import gnu.java.awt.ClasspathToolkit; +import gnu.java.awt.EmbeddedWindow; +import gnu.java.awt.peer.ClasspathFontPeer; +import gnu.java.awt.peer.EmbeddedWindowPeer; + +public class XToolkit extends ClasspathToolkit +{ + static XToolkit INSTANCE; + + Display display; + + EventQueue queue; + XEventLoop eventLoop; + + XGraphicsConfiguration defaultConfig; + + public XToolkit() + { + INSTANCE = this; + display = new Display(); + synchronized (display) + { + queue = new XEventQueue(display); + eventLoop = new XEventLoop(display, queue); + } + } + + public void flushIfIdle() + { + eventLoop.flushIfIdle(); + } + + protected ButtonPeer createButton(Button frontend) + { + // FIXME: Stubbed out, needs Swing: + /* + XCanvasPeer realPeer = new XCanvasPeer(frontend); + SButtonPeer sbPeer = new SButtonPeer(frontend, realPeer); + return sbPeer; + */ + return null; + } + + protected TextFieldPeer createTextField(TextField frontend) + { + return null; // FIXME + } + + protected LabelPeer createLabel(Label frontend) + { + return null; // FIXME + } + + protected ListPeer createList(List frontend) + { + return null; // FIXME + } + + protected CheckboxPeer createCheckbox(Checkbox frontend) + { + return null; // FIXME + } + + protected ScrollbarPeer createScrollbar(Scrollbar frontend) + { + return null; // FIXME + } + + protected ScrollPanePeer createScrollPane(ScrollPane frontend) + { + return null; // FIXME + } + + protected TextAreaPeer createTextArea(TextArea frontend) + { + return null; // FIXME + } + + protected ChoicePeer createChoice(Choice frontend) + { + return null; // FIXME + } + + protected FramePeer createFrame(Frame frontend) { + return new XFramePeer(frontend); + } + + protected CanvasPeer createCanvas(Canvas frontend) { + XCanvasPeer peer = new XCanvasPeer(frontend); + return peer; + } + + protected PanelPeer createPanel(Panel frontend) { + return new XPanelPeer(frontend); + } + + protected WindowPeer createWindow(Window frontend) + { + return null; // FIXME + } + + protected DialogPeer createDialog(Dialog frontend) + { + return null; // FIXME + } + + protected MenuBarPeer createMenuBar(MenuBar frontend) + { + return null; // FIXME + } + + protected MenuPeer createMenu(Menu frontend) + { + return null; // FIXME + } + + protected PopupMenuPeer createPopupMenu(PopupMenu frontend) + { + return null; // FIXME + } + + protected MenuItemPeer createMenuItem(MenuItem frontend) + { + return null; // FIXME + } + + protected FileDialogPeer createFileDialog(FileDialog frontend) + { + return null; // FIXME + } + + protected CheckboxMenuItemPeer + createCheckboxMenuItem(CheckboxMenuItem frontend) + { + return null; // FIXME + } + + protected java.awt.peer.FontPeer getFontPeer(String name, int style) + { + return new XFontPeer (name,style); + } + + public Dimension getScreenSize() + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public int getScreenResolution() + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public java.awt.image.ColorModel getColorModel() + { + return getDefaultXGraphicsConfiguration().getColorModel(); + } + + public String[] getFontList() + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public FontMetrics getFontMetrics(Font font) + { + return getDefaultXGraphicsConfiguration().getXFontMetrics(font); + } + + public void sync() + { + flushIfIdle (); + // FIXME: should instead wait for eventLoop to go idle + // (perhaps send a dummy event there and block till it makes + // it through the queue) + } + + public Image getImage(String filename) + { + return createImage(filename); + } + + public Image getImage(URL url) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public Image createImage(String filename) + { + // FIXME: Stubbed out. We need a proper image I/O API. + + /* + BufferedImage jpeg; + FileInputStream fis = openFile(filename); + if (fis == null) + return null; + + BasicRasterImageConsumer consumer = new BasicRasterImageConsumer(); + JPEGImageDecoder jid = new JPEGImageDecoder(fis); + + jid.startProduction(consumer); + jpeg = consumer.getImage(); + + int w = jpeg.getWidth(); + int h = jpeg.getHeight(); + + BufferedImage img = + getDefaultXGraphicsConfiguration().createCompatibleImage(w, h); + + Renderers renderers = Renderers.getInstance(); + + RasterOp renderer = renderers.createRenderer(jpeg.getColorModel(), + jpeg.getSampleModel(), + img.getColorModel(), + img.getSampleModel()); + + if (renderer == null) + { + throw new UnsupportedOperationException("couldn't find renderer"); + } + + renderer.filter(jpeg.getRaster(), img.getRaster()); + + return img; + */ + + return null; + } + + public Image createImage(URL url) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public boolean prepareImage(Image image, + int width, + int height, + ImageObserver observer) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public int checkImage(Image image, + int width, + int height, + ImageObserver observer) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public Image createImage(ImageProducer producer) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public Image createImage(byte[] imagedata, + int imageoffset, + int imagelength) + { + throw new UnsupportedOperationException("not implemented yet"); + } + + /* + public PrintJob getPrintJob(Frame frame, + String jobtitle, + Properties props); + */ + + public void beep() + { + throw new UnsupportedOperationException("not implemented yet"); + } + + public Clipboard getSystemClipboard() + { + return null; // FIXME + } + + protected EventQueue getSystemEventQueueImpl() + { + return queue; + } + + public PrintJob getPrintJob (Frame frame, String title, Properties props) + { + return null; // FIXME + } + + XGraphicsConfiguration getDefaultXGraphicsConfiguration() + { + if (defaultConfig == null) + { + Screen screen = display.getDefaultScreen(); + Visual visual = screen.getRootVisual(); + defaultConfig = new XGraphicsConfiguration(visual); + + // ASSERT: + if (!defaultConfig.getVisual().getScreen().equals(screen)) + { + String msg = "screen of graphics configuration is not " + + "default screen"; + throw new Error(msg); + } + } + + return defaultConfig; + } + + public DragSourceContextPeer + createDragSourceContextPeer(DragGestureEvent dge) + throws InvalidDnDOperationException + { + throw new UnsupportedOperationException("not implemented"); + } + + public DragGestureRecognizer + createDragGestureRecognizer(Class abstractRecognizerClass, + DragSource ds, Component c, + int srcActions, DragGestureListener dgl) + { + throw new UnsupportedOperationException("not implemented"); + } + + + public Map mapInputMethodHighlight(InputMethodHighlight highlight) + { + throw new UnsupportedOperationException("not implemented"); + } + + /** Returns a shared instance of the local, platform-specific + * graphics environment. + * + *

This method is specific to GNU Classpath. It gets called by + * the Classpath implementation of {@link + * GraphicsEnvironment.getLocalGraphcisEnvironment()}. + */ + public GraphicsEnvironment getLocalGraphicsEnvironment () + { + return new XGraphicsEnvironment (this); + } + + /** Acquires an appropriate {@link ClasspathFontPeer}, for use in + * classpath's implementation of {@link java.awt.Font}. + * + * @param name The logical name of the font. This may be either a face + * name or a logical font name, or may even be null. A default + * implementation of name decoding is provided in + * {@link ClasspathFontPeer}, but may be overridden in other toolkits. + * + * @param attrs Any extra {@link java.awt.font.TextAttribute} attributes + * this font peer should have, such as size, weight, family name, or + * transformation. + */ + public ClasspathFontPeer getClasspathFontPeer (String name, Map attrs) + { + int style = Font.PLAIN; + float size = 12; + + if (attrs.containsKey (TextAttribute.WEIGHT)) + { + Float weight = (Float) attrs.get (TextAttribute.WEIGHT); + if (weight.floatValue () >= TextAttribute.WEIGHT_BOLD.floatValue ()) + style += Font.BOLD; + } + + if (attrs.containsKey (TextAttribute.POSTURE)) + { + Float posture = (Float) attrs.get (TextAttribute.POSTURE); + if (posture.floatValue () >= TextAttribute.POSTURE_OBLIQUE.floatValue ()) + style += Font.ITALIC; + } + + if (attrs.containsKey (TextAttribute.SIZE)) + { + Float fsize = (Float) attrs.get (TextAttribute.SIZE); + size = fsize.floatValue (); + } + + return new XFontPeer (name,style,size); + } + + /** Creates a font, reading the glyph definitions from a stream. + * + *

This method provides the platform-specific implementation for + * the static factory method {@link Font#createFont(int, + * java.io.InputStream)}. + * + * @param format the format of the font data, such as {@link + * Font#TRUETYPE_FONT}. An implementation may ignore this argument + * if it is able to automatically recognize the font format from the + * provided data. + * + * @param stream an input stream from where the font data is read + * in. The stream will be advanced to the position after the font + * data, but not closed. + * + * @throws IllegalArgumentException if format is + * not supported. + * + * @throws FontFormatException if stream does not + * contain data in the expected format, or if required tables are + * missing from a font. + * + * @throws IOException if a problem occurs while reading in the + * contents of stream. + */ + public Font createFont (int format, InputStream stream) + { + throw new java.lang.UnsupportedOperationException (); + } + + public RobotPeer createRobot (GraphicsDevice screen) throws AWTException + { + throw new java.lang.UnsupportedOperationException (); + } + + public EmbeddedWindowPeer createEmbeddedWindow (EmbeddedWindow w) + { + throw new java.lang.UnsupportedOperationException (); + } + + public boolean nativeQueueEmpty() + { + // Tell EventQueue the native queue is empty, because XEventLoop + // separately ensures that native events are posted to AWT. + return true; + } + + public void wakeNativeQueue() + { + // Not implemented, because the native queue is always awake. + // (i.e. it's polled in a thread separate from the AWT dispatch thread) + } + + /** Checks the native event queue for events. If blocking, waits until an + * event is available before returning, unless interrupted by + * wakeNativeQueue. If non-blocking, returns immediately even if no + * event is available. + * + * @param locked The calling EventQueue + * @param block If true, waits for a native event before returning + */ + public void iterateNativeQueue(java.awt.EventQueue locked, boolean block) + { + // There is nothing to do here except block, because XEventLoop + // iterates the queue in a dedicated thread. + if (block) + { + try + { + queue.wait (); + } + catch (InterruptedException ie) + { + // InterruptedException intentionally ignored + } + } + } + + public void setAlwaysOnTop(boolean b) + { + // TODO: Implement properly. + } + + public boolean isModalExclusionTypeSupported + (Dialog.ModalExclusionType modalExclusionType) + { + // TODO: Implement properly. + return false; + } + + public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) + { + // TODO: Implement properly. + return false; + } +} -- cgit v1.2.3