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
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; |
} |
} |
/* 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; } |
} |
|
// 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__ |
/* 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) |
{ |
} |
|
} |
/* 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; |
} |
} |
|
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
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