OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openrisc/tags/gnu-dev/fsf-gcc-snapshot-1-mar-12/or1k-gcc/libjava/gnu/awt/xlib
    from Rev 756 to Rev 783
    Reverse comparison

Rev 756 → Rev 783

/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;
}
}
/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; }
}
/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 <gnu/awt/xlib/XCanvasPeer.h>
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__
/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 <scottg@mantatest.com> <sgilbertson@cogeco.ca>
*/
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 <code>UndefinedProperty</code> is
* returned if there is no property with the specified name. The value
* <code>null</code> 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)
{
}
}
/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;
}
}
 
XGraphicsDevice.java Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: XEventLoop.h =================================================================== --- XEventLoop.h (nonexistent) +++ XEventLoop.h (revision 783) @@ -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__ Index: XPanelPeer.h =================================================================== --- XPanelPeer.h (nonexistent) +++ XPanelPeer.h (revision 783) @@ -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__ Index: XCanvasPeer$DoMap.h =================================================================== --- XCanvasPeer$DoMap.h (nonexistent) +++ XCanvasPeer$DoMap.h (revision 783) @@ -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__ Index: XFontPeer.java =================================================================== --- XFontPeer.java (nonexistent) +++ XFontPeer.java (revision 783) @@ -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 (); + } +} Index: XGraphics$XRaster.h =================================================================== --- XGraphics$XRaster.h (nonexistent) +++ XGraphics$XRaster.h (revision 783) @@ -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__ Index: XOffScreenImage.h =================================================================== --- XOffScreenImage.h (nonexistent) +++ XOffScreenImage.h (revision 783) @@ -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__ Index: XGraphicsEnvironment.java =================================================================== --- XGraphicsEnvironment.java (nonexistent) +++ XGraphicsEnvironment.java (revision 783) @@ -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 ()); + } +}

XGraphicsEnvironment.java Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: XToolkit.java =================================================================== --- XToolkit.java (nonexistent) +++ XToolkit.java (revision 783) @@ -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; + } +} Index: XEventQueue.java =================================================================== --- XEventQueue.java (nonexistent) +++ XEventQueue.java (revision 783) @@ -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; + } +} Index: XGraphicsDevice.h =================================================================== --- XGraphicsDevice.h (nonexistent) +++ XGraphicsDevice.h (revision 783) @@ -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__ Index: XCanvasPeer.java =================================================================== --- XCanvasPeer.java (nonexistent) +++ XCanvasPeer.java (revision 783) @@ -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 () + { + } +} Index: XFontPeer.h =================================================================== --- XFontPeer.h (nonexistent) +++ XFontPeer.h (revision 783) @@ -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__ Index: XGraphicsConfiguration.java =================================================================== --- XGraphicsConfiguration.java (nonexistent) +++ XGraphicsConfiguration.java (revision 783) @@ -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; + } +} Index: XGraphicsConfiguration$FontMetricsCache$PerDisplayCache.h =================================================================== --- XGraphicsConfiguration$FontMetricsCache$PerDisplayCache.h (nonexistent) +++ XGraphicsConfiguration$FontMetricsCache$PerDisplayCache.h (revision 783) @@ -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__ Index: XGraphicsEnvironment.h =================================================================== --- XGraphicsEnvironment.h (nonexistent) +++ XGraphicsEnvironment.h (revision 783) @@ -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__ Index: XToolkit.h =================================================================== --- XToolkit.h (nonexistent) +++ XToolkit.h (revision 783) @@ -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__ Index: XEventQueue.h =================================================================== --- XEventQueue.h (nonexistent) +++ XEventQueue.h (revision 783) @@ -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__ Index: XFontMetrics.java =================================================================== --- XFontMetrics.java (nonexistent) +++ XFontMetrics.java (revision 783) @@ -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); + } +} Index: XCanvasPeer.h =================================================================== --- XCanvasPeer.h (nonexistent) +++ XCanvasPeer.h (revision 783) @@ -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__ Index: XGraphicsConfiguration.h =================================================================== --- XGraphicsConfiguration.h (nonexistent) +++ XGraphicsConfiguration.h (revision 783) @@ -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__ Index: XGraphics.java =================================================================== --- XGraphics.java (nonexistent) +++ XGraphics.java (revision 783) @@ -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); + } +} Index: XFontMetrics.h =================================================================== --- XFontMetrics.h (nonexistent) +++ XFontMetrics.h (revision 783) @@ -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__ Index: XGraphicsConfiguration$FontMetricsCache$PerDisplayCache$CacheEntry.h =================================================================== --- XGraphicsConfiguration$FontMetricsCache$PerDisplayCache$CacheEntry.h (nonexistent) +++ XGraphicsConfiguration$FontMetricsCache$PerDisplayCache$CacheEntry.h (revision 783) @@ -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__ Index: XGraphicsConfiguration$FontMetricsCache.h =================================================================== --- XGraphicsConfiguration$FontMetricsCache.h (nonexistent) +++ XGraphicsConfiguration$FontMetricsCache.h (revision 783) @@ -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__ Index: XGraphics.h =================================================================== --- XGraphics.h (nonexistent) +++ XGraphics.h (revision 783) @@ -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__ Index: XFramePeer.java =================================================================== --- XFramePeer.java (nonexistent) +++ XFramePeer.java (revision 783) @@ -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"); + } +}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.