Imported GNU Classpath 0.90
Imported GNU Classpath 0.90
* scripts/makemake.tcl: LocaleData.java moved to gnu/java/locale.
* sources.am: Regenerated.
* gcj/javaprims.h: Regenerated.
* Makefile.in: Regenerated.
* gcj/Makefile.in: Regenerated.
* include/Makefile.in: Regenerated.
* testsuite/Makefile.in: Regenerated.
* gnu/java/lang/VMInstrumentationImpl.java: New override.
* gnu/java/net/local/LocalSocketImpl.java: Likewise.
* gnu/classpath/jdwp/VMMethod.java: Likewise.
* gnu/classpath/jdwp/VMVirtualMachine.java: Update to latest
interface.
* java/lang/Thread.java: Add UncaughtExceptionHandler.
* java/lang/reflect/Method.java: Implements GenericDeclaration and
isSynthetic(),
* java/lang/reflect/Field.java: Likewise.
* java/lang/reflect/Constructor.java
* java/lang/Class.java: Implements Type, GenericDeclaration,
getSimpleName() and getEnclosing*() methods.
* java/lang/Class.h: Add new public methods.
* java/lang/Math.java: Add signum(), ulp() and log10().
* java/lang/natMath.cc (log10): New function.
* java/security/VMSecureRandom.java: New override.
* java/util/logging/Logger.java: Updated to latest classpath
version.
* java/util/logging/LogManager.java: New override.
From-SVN: r113887
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/* GtkWindowPeer.java -- Implements WindowPeer with GTK
|
||||
Copyright (C) 1998, 1999, 2002, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999, 2002, 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -42,7 +42,9 @@ import java.awt.AWTEvent;
|
||||
import java.awt.Component;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.PaintEvent;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.peer.WindowPeer;
|
||||
@@ -62,20 +64,37 @@ public class GtkWindowPeer extends GtkContainerPeer
|
||||
private boolean hasBeenShown = false;
|
||||
private int oldState = Frame.NORMAL;
|
||||
|
||||
// Cached awt window component location, width and height.
|
||||
private int x, y, width, height;
|
||||
|
||||
native void gtkWindowSetTitle (String title);
|
||||
native void gtkWindowSetResizable (boolean resizable);
|
||||
native void gtkWindowSetModal (boolean modal);
|
||||
|
||||
native void realize ();
|
||||
|
||||
int getWidth ()
|
||||
/** Returns the cached width of the AWT window component. */
|
||||
int getX ()
|
||||
{
|
||||
return awtComponent.getWidth();
|
||||
return x;
|
||||
}
|
||||
|
||||
/** Returns the cached width of the AWT window component. */
|
||||
int getY ()
|
||||
{
|
||||
return y;
|
||||
}
|
||||
|
||||
/** Returns the cached width of the AWT window component. */
|
||||
int getWidth ()
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
/** Returns the cached height of the AWT window component. */
|
||||
int getHeight ()
|
||||
{
|
||||
return awtComponent.getHeight();
|
||||
return height;
|
||||
}
|
||||
|
||||
native void create (int type, boolean decorated, GtkWindowPeer parent);
|
||||
@@ -85,6 +104,10 @@ public class GtkWindowPeer extends GtkContainerPeer
|
||||
Window window = (Window) awtComponent;
|
||||
GtkWindowPeer parent_peer = null;
|
||||
Component parent = awtComponent.getParent();
|
||||
x = awtComponent.getX();
|
||||
y = awtComponent.getY();
|
||||
height = awtComponent.getHeight();
|
||||
width = awtComponent.getWidth();
|
||||
|
||||
if (!window.isFocusableWindow())
|
||||
type = GDK_WINDOW_TYPE_HINT_MENU;
|
||||
@@ -129,37 +152,28 @@ public class GtkWindowPeer extends GtkContainerPeer
|
||||
native void nativeSetLocation (int x, int y);
|
||||
native void nativeSetLocationUnlocked (int x, int y);
|
||||
|
||||
public void setLocation (int x, int y)
|
||||
// Called from show.
|
||||
protected void setLocation (int x, int y)
|
||||
{
|
||||
// prevent window_configure_cb -> awtComponent.setSize ->
|
||||
// peer.setBounds -> nativeSetBounds self-deadlock on GDK lock.
|
||||
if (Thread.currentThread() == GtkToolkit.mainThread)
|
||||
return;
|
||||
nativeSetLocation (x, y);
|
||||
}
|
||||
|
||||
public void setLocationUnlocked (int x, int y)
|
||||
{
|
||||
nativeSetLocationUnlocked (x, y);
|
||||
}
|
||||
|
||||
public void setBounds (int x, int y, int width, int height)
|
||||
{
|
||||
// prevent window_configure_cb -> awtComponent.setSize ->
|
||||
// peer.setBounds -> nativeSetBounds self-deadlock on GDK lock.
|
||||
if (Thread.currentThread() == GtkToolkit.mainThread)
|
||||
return;
|
||||
|
||||
nativeSetBounds (x, y,
|
||||
width - insets.left - insets.right,
|
||||
height - insets.top - insets.bottom);
|
||||
}
|
||||
|
||||
public void setBoundsUnlocked (int x, int y, int width, int height)
|
||||
{
|
||||
nativeSetBoundsUnlocked (x, y,
|
||||
width - insets.left - insets.right,
|
||||
height - insets.top - insets.bottom);
|
||||
if (x != getX()
|
||||
|| y != getY()
|
||||
|| width != getWidth()
|
||||
|| height != getHeight())
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
nativeSetBounds (x, y,
|
||||
width - insets.left - insets.right,
|
||||
height - insets.top - insets.bottom);
|
||||
}
|
||||
}
|
||||
|
||||
public void setTitle (String title)
|
||||
@@ -167,15 +181,25 @@ public class GtkWindowPeer extends GtkContainerPeer
|
||||
gtkWindowSetTitle (title);
|
||||
}
|
||||
|
||||
native void setSize (int width, int height);
|
||||
|
||||
// Called from setResizable
|
||||
protected native void setSize (int width, int height);
|
||||
|
||||
/**
|
||||
* Needed by both GtkFramePeer and GtkDialogPeer subclasses, so
|
||||
* implemented here. But never actually called on a GtkWindowPeer
|
||||
* itself.
|
||||
*/
|
||||
public void setResizable (boolean resizable)
|
||||
{
|
||||
// Call setSize; otherwise when resizable is changed from true to
|
||||
// false the window will shrink to the dimensions it had before it
|
||||
// was resizable.
|
||||
setSize (awtComponent.getWidth() - insets.left - insets.right,
|
||||
awtComponent.getHeight() - insets.top - insets.bottom);
|
||||
x = awtComponent.getX();
|
||||
y = awtComponent.getY();
|
||||
width = awtComponent.getWidth();
|
||||
height = awtComponent.getHeight();
|
||||
setSize (width - insets.left - insets.right,
|
||||
height - insets.top - insets.bottom);
|
||||
gtkWindowSetResizable (resizable);
|
||||
}
|
||||
|
||||
@@ -195,23 +219,35 @@ public class GtkWindowPeer extends GtkContainerPeer
|
||||
int frame_width = width + insets.left + insets.right;
|
||||
int frame_height = height + insets.top + insets.bottom;
|
||||
|
||||
if (frame_width != awtComponent.getWidth()
|
||||
|| frame_height != awtComponent.getHeight())
|
||||
awtComponent.setSize(frame_width, frame_height);
|
||||
if (frame_width != getWidth()
|
||||
|| frame_height != getHeight())
|
||||
{
|
||||
this.width = frame_width;
|
||||
this.height = frame_height;
|
||||
q().postEvent(new ComponentEvent(awtComponent,
|
||||
ComponentEvent.COMPONENT_RESIZED));
|
||||
}
|
||||
|
||||
int frame_x = x - insets.left;
|
||||
int frame_y = y - insets.top;
|
||||
|
||||
if (frame_x != awtComponent.getX()
|
||||
|| frame_y != awtComponent.getY())
|
||||
if (frame_x != getX()
|
||||
|| frame_y != getY())
|
||||
{
|
||||
// awtComponent.setLocation(frame_x, frame_y);
|
||||
this.x = frame_x;
|
||||
this.y = frame_y;
|
||||
q().postEvent(new ComponentEvent(awtComponent,
|
||||
ComponentEvent.COMPONENT_MOVED));
|
||||
}
|
||||
}
|
||||
|
||||
public void show ()
|
||||
{
|
||||
setLocation(awtComponent.getX(), awtComponent.getY());
|
||||
x = awtComponent.getX();
|
||||
y = awtComponent.getY();
|
||||
width = awtComponent.getWidth();
|
||||
height = awtComponent.getHeight();
|
||||
setLocation(x, y);
|
||||
setVisible (true);
|
||||
}
|
||||
|
||||
@@ -244,37 +280,62 @@ public class GtkWindowPeer extends GtkContainerPeer
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
protected void postExposeEvent (int x, int y, int width, int height)
|
||||
{
|
||||
// Translate GTK co-ordinates, which do not include a window
|
||||
// frame's insets, to AWT co-ordinates, which do include a window
|
||||
// frame's insets. GtkWindowPeer should always have all-zero
|
||||
// insets but GtkFramePeer and GtkDialogPeer insets will be
|
||||
// non-zero.
|
||||
q().postEvent (new PaintEvent (awtComponent, PaintEvent.PAINT,
|
||||
new Rectangle (x + insets.left,
|
||||
y + insets.top,
|
||||
width, height)));
|
||||
}
|
||||
|
||||
public boolean requestWindowFocus()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
public void handleEvent(AWTEvent event)
|
||||
public Graphics getGraphics ()
|
||||
{
|
||||
int id = event.getID();
|
||||
if (id == PaintEvent.UPDATE || id == PaintEvent.PAINT)
|
||||
{
|
||||
try
|
||||
{
|
||||
Graphics g = getGraphics();
|
||||
if (! awtComponent.isShowing() || awtComponent.getWidth() < 1
|
||||
|| awtComponent.getHeight() < 1 || g == null)
|
||||
return;
|
||||
Graphics g = super.getGraphics ();
|
||||
// Translate AWT co-ordinates, which include a window frame's
|
||||
// insets, to GTK co-ordinates, which do not include a window
|
||||
// frame's insets. GtkWindowPeer should always have all-zero
|
||||
// insets but GtkFramePeer and GtkDialogPeer insets will be
|
||||
// non-zero.
|
||||
g.translate (-insets.left, -insets.top);
|
||||
return g;
|
||||
}
|
||||
|
||||
g.setClip(((PaintEvent) event).getUpdateRect());
|
||||
protected void updateComponent (PaintEvent event)
|
||||
{
|
||||
// Do not clear anything before painting. Sun never calls
|
||||
// Window.update, only Window.paint.
|
||||
paintComponent(event);
|
||||
}
|
||||
|
||||
// Do not want to clear anything before painting.
|
||||
awtComponent.paint(g);
|
||||
protected void postMouseEvent(int id, long when, int mods, int x, int y,
|
||||
int clickCount, boolean popupTrigger)
|
||||
{
|
||||
// Translate AWT co-ordinates, which include a window frame's
|
||||
// insets, to GTK co-ordinates, which do not include a window
|
||||
// frame's insets. GtkWindowPeer should always have all-zero
|
||||
// insets but GtkFramePeer and GtkDialogPeer insets will be
|
||||
// non-zero.
|
||||
super.postMouseEvent (id, when, mods,
|
||||
x + insets.left, y + insets.top,
|
||||
clickCount, popupTrigger);
|
||||
}
|
||||
|
||||
g.dispose();
|
||||
return;
|
||||
}
|
||||
catch (InternalError e)
|
||||
{
|
||||
System.err.println(e);
|
||||
}
|
||||
}
|
||||
super.handleEvent(event);
|
||||
// We override this to keep it in sync with our internal
|
||||
// representation.
|
||||
public Rectangle getBounds()
|
||||
{
|
||||
return new Rectangle(x, y, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user