Imported GNU Classpath 0.92
2006-08-14 Mark Wielaard <mark@klomp.org> Imported GNU Classpath 0.92 * HACKING: Add more importing hints. Update automake version requirement. * configure.ac (gconf-peer): New enable AC argument. Add --disable-gconf-peer and --enable-default-preferences-peer to classpath configure when gconf is disabled. * scripts/makemake.tcl: Set gnu/java/util/prefs/gconf and gnu/java/awt/dnd/peer/gtk to bc. Classify gnu/java/security/Configuration.java as generated source file. * gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java, gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java, gnu/java/lang/management/VMClassLoadingMXBeanImpl.java, gnu/java/lang/management/VMRuntimeMXBeanImpl.java, gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java, gnu/java/lang/management/VMThreadMXBeanImpl.java, gnu/java/lang/management/VMMemoryMXBeanImpl.java, gnu/java/lang/management/VMCompilationMXBeanImpl.java: New VM stub classes. * java/lang/management/VMManagementFactory.java: Likewise. * java/net/VMURLConnection.java: Likewise. * gnu/java/nio/VMChannel.java: Likewise. * java/lang/Thread.java (getState): Add stub implementation. * java/lang/Class.java (isEnum): Likewise. * java/lang/Class.h (isEnum): Likewise. * gnu/awt/xlib/XToolkit.java (getClasspathTextLayoutPeer): Removed. * javax/naming/spi/NamingManager.java: New override for StackWalker functionality. * configure, sources.am, Makefile.in, gcj/Makefile.in, include/Makefile.in, testsuite/Makefile.in: Regenerated. From-SVN: r116139
This commit is contained in:
@@ -61,11 +61,6 @@ import org.omg.PortableServer.ForwardRequest;
|
||||
*/
|
||||
public abstract class ForwardRequestHelper
|
||||
{
|
||||
/**
|
||||
* The cached typecode value, computed only once.
|
||||
*/
|
||||
private static TypeCode typeCode;
|
||||
|
||||
/**
|
||||
* Extract the ForwardRequest from given Any.
|
||||
* This method uses the ForwardRequestHolder.
|
||||
@@ -132,18 +127,14 @@ public abstract class ForwardRequestHelper
|
||||
*/
|
||||
public static TypeCode type()
|
||||
{
|
||||
if (typeCode == null)
|
||||
{
|
||||
ORB orb = ORB.init();
|
||||
StructMember[] members = new StructMember[ 1 ];
|
||||
|
||||
TypeCode field;
|
||||
|
||||
field = ObjectHelper.type();
|
||||
members [ 0 ] = new StructMember("forward_reference", field, null);
|
||||
typeCode = orb.create_exception_tc(id(), "ForwardRequest", members);
|
||||
}
|
||||
return typeCode;
|
||||
ORB orb = OrbRestricted.Singleton;
|
||||
StructMember[] members = new StructMember[ 1 ];
|
||||
|
||||
TypeCode field;
|
||||
|
||||
field = ObjectHelper.type();
|
||||
members [ 0 ] = new StructMember("forward_reference", field, null);
|
||||
return orb.create_exception_tc(id(), "ForwardRequest", members);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,10 +38,11 @@ exception statement from your version. */
|
||||
|
||||
package gnu.classpath.debug;
|
||||
|
||||
import gnu.classpath.SystemProperties;
|
||||
import gnu.java.security.action.GetPropertyAction;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.security.AccessController;
|
||||
import java.text.DateFormat;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
@@ -91,20 +92,27 @@ public class Simple1LineFormatter
|
||||
extends Formatter
|
||||
{
|
||||
private static final String DAT_PATTERN = "yyyy-MM-dd HH:mm:ss.SSSS Z ";
|
||||
private static final DateFormat DAT_FORMAT = new SimpleDateFormat(DAT_PATTERN);
|
||||
private static final String THREAD_PATTERN = " #########0;-#########0";
|
||||
private static final NumberFormat THREAD_FORMAT = new DecimalFormat(THREAD_PATTERN);
|
||||
private static final String SPACES_32 = " ";
|
||||
private static final String SPACES_6 = " ";
|
||||
private static final String LS = SystemProperties.getProperty("line.separator");
|
||||
private static final String LS = (String) AccessController.doPrivileged
|
||||
(new GetPropertyAction("line.separator"));
|
||||
private DateFormat dateFormat;
|
||||
private NumberFormat threadFormat;
|
||||
|
||||
// default 0-arguments constructor
|
||||
|
||||
public String format(LogRecord record)
|
||||
{
|
||||
StringBuffer sb = new StringBuffer(180)
|
||||
.append(DAT_FORMAT.format(new Date(record.getMillis())))
|
||||
.append(THREAD_FORMAT.format(record.getThreadID()))
|
||||
if (dateFormat == null)
|
||||
dateFormat = new SimpleDateFormat(DAT_PATTERN);
|
||||
|
||||
if (threadFormat == null)
|
||||
threadFormat = new DecimalFormat(THREAD_PATTERN);
|
||||
|
||||
StringBuilder sb = new StringBuilder(180)
|
||||
.append(dateFormat.format(new Date(record.getMillis())))
|
||||
.append(threadFormat.format(record.getThreadID()))
|
||||
.append(" ");
|
||||
String s = record.getSourceClassName();
|
||||
if (s == null)
|
||||
|
||||
@@ -38,7 +38,9 @@ version. */
|
||||
|
||||
package gnu.classpath.debug;
|
||||
|
||||
import gnu.classpath.SystemProperties;
|
||||
import gnu.java.security.action.GetPropertyAction;
|
||||
|
||||
import java.security.AccessController;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -49,8 +51,8 @@ public final class SystemLogger
|
||||
static
|
||||
{
|
||||
SYSTEM.setFilter (PreciseFilter.GLOBAL);
|
||||
|
||||
String defaults = SystemProperties.getProperty ("gnu.classpath.debug.components");
|
||||
String defaults = (String) AccessController.doPrivileged
|
||||
(new GetPropertyAction("gnu.classpath.debug.components"));
|
||||
|
||||
if (defaults != null)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
/* TeeInputStream.java
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is a part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or (at
|
||||
your option) any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under terms
|
||||
of your choice, provided that you also meet, for each linked independent
|
||||
module, the terms and conditions of the license of that module. An
|
||||
independent module is a module which is not derived from or based on
|
||||
this library. If you modify this library, you may extend this exception
|
||||
to your version of the library, but you are not obligated to do so. If
|
||||
you do not wish to do so, delete this exception statement from your
|
||||
version. */
|
||||
|
||||
package gnu.classpath.debug;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* An input stream that copies all its input to a byte sink.
|
||||
*
|
||||
* @author Chris Burdess
|
||||
*/
|
||||
public class TeeInputStream
|
||||
extends InputStream
|
||||
{
|
||||
|
||||
private final InputStream in;
|
||||
private final OutputStream out;
|
||||
|
||||
/**
|
||||
* Constructs a tee input stream.
|
||||
* @param in the underlying input stream
|
||||
* @param out the output sink
|
||||
*/
|
||||
public TeeInputStream(InputStream in, OutputStream out)
|
||||
{
|
||||
this.in = in;
|
||||
this.out = out;
|
||||
}
|
||||
|
||||
public int read()
|
||||
throws IOException
|
||||
{
|
||||
int ret = in.read();
|
||||
out.write(ret);
|
||||
out.flush();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int read(byte[] b, int off, int len)
|
||||
throws IOException
|
||||
{
|
||||
int ret = in.read(b, off, len);
|
||||
if (ret != -1)
|
||||
{
|
||||
out.write(b, off, ret);
|
||||
out.flush();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void close()
|
||||
throws IOException
|
||||
{
|
||||
in.close();
|
||||
out.close();
|
||||
}
|
||||
|
||||
public final boolean markSupported()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/* TeeOutputStream.java
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is a part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or (at
|
||||
your option) any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under terms
|
||||
of your choice, provided that you also meet, for each linked independent
|
||||
module, the terms and conditions of the license of that module. An
|
||||
independent module is a module which is not derived from or based on
|
||||
this library. If you modify this library, you may extend this exception
|
||||
to your version of the library, but you are not obligated to do so. If
|
||||
you do not wish to do so, delete this exception statement from your
|
||||
version. */
|
||||
|
||||
package gnu.classpath.debug;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* An output stream that copies all its output to an additional byte sink.
|
||||
*
|
||||
* @author Chris Burdess
|
||||
*/
|
||||
public class TeeOutputStream
|
||||
extends OutputStream
|
||||
{
|
||||
|
||||
private final OutputStream out;
|
||||
private final OutputStream sink;
|
||||
|
||||
/**
|
||||
* Constructs a tee output stream.
|
||||
* @param out the underlying output stream
|
||||
* @param sink the output sink
|
||||
*/
|
||||
public TeeOutputStream(OutputStream out, OutputStream sink)
|
||||
{
|
||||
this.out = out;
|
||||
this.sink = sink;
|
||||
}
|
||||
|
||||
public void write(int c)
|
||||
throws IOException
|
||||
{
|
||||
out.write(c);
|
||||
sink.write(c);
|
||||
}
|
||||
|
||||
public void write(byte[] b, int off, int len)
|
||||
throws IOException
|
||||
{
|
||||
out.write(b, off, len);
|
||||
sink.write(b, off, len);
|
||||
}
|
||||
|
||||
public void flush()
|
||||
throws IOException
|
||||
{
|
||||
out.flush();
|
||||
sink.flush();
|
||||
}
|
||||
|
||||
public void close()
|
||||
throws IOException
|
||||
{
|
||||
out.close();
|
||||
sink.close();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/* TeeReader.java
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is a part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or (at
|
||||
your option) any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under terms
|
||||
of your choice, provided that you also meet, for each linked independent
|
||||
module, the terms and conditions of the license of that module. An
|
||||
independent module is a module which is not derived from or based on
|
||||
this library. If you modify this library, you may extend this exception
|
||||
to your version of the library, but you are not obligated to do so. If
|
||||
you do not wish to do so, delete this exception statement from your
|
||||
version. */
|
||||
|
||||
package gnu.classpath.debug;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* A reader that copies all characters read to an output sink.
|
||||
*
|
||||
* @author Chris Burdess
|
||||
*/
|
||||
public class TeeReader
|
||||
extends Reader
|
||||
{
|
||||
|
||||
private final Reader in;
|
||||
private final Writer out;
|
||||
|
||||
/**
|
||||
* Constructs a tee reader.
|
||||
* @param in the input
|
||||
* @param out the output sink
|
||||
*/
|
||||
public TeeReader(Reader in, Writer out)
|
||||
{
|
||||
this.in = in;
|
||||
this.out = out;
|
||||
}
|
||||
|
||||
public int read()
|
||||
throws IOException
|
||||
{
|
||||
int ret = in.read();
|
||||
out.write(ret);
|
||||
out.flush();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int read(char[] b, int off, int len)
|
||||
throws IOException
|
||||
{
|
||||
int ret = in.read(b, off, len);
|
||||
if (ret != -1)
|
||||
{
|
||||
out.write(b, off, ret);
|
||||
out.flush();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void close()
|
||||
throws IOException
|
||||
{
|
||||
in.close();
|
||||
out.close();
|
||||
}
|
||||
|
||||
public final boolean markSupported()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/* TeeWriter.java
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is a part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or (at
|
||||
your option) any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under terms
|
||||
of your choice, provided that you also meet, for each linked independent
|
||||
module, the terms and conditions of the license of that module. An
|
||||
independent module is a module which is not derived from or based on
|
||||
this library. If you modify this library, you may extend this exception
|
||||
to your version of the library, but you are not obligated to do so. If
|
||||
you do not wish to do so, delete this exception statement from your
|
||||
version. */
|
||||
|
||||
package gnu.classpath.debug;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* A writer that copies all its output to an additional character sink.
|
||||
*
|
||||
* @author Chris Burdess
|
||||
*/
|
||||
public class TeeWriter
|
||||
extends Writer
|
||||
{
|
||||
|
||||
private final Writer out;
|
||||
private final Writer sink;
|
||||
|
||||
/**
|
||||
* Constructs a tee writer.
|
||||
* @param out the underlying writer
|
||||
* @param sink the output sink
|
||||
*/
|
||||
public TeeWriter(Writer out, Writer sink)
|
||||
{
|
||||
this.out = out;
|
||||
this.sink = sink;
|
||||
}
|
||||
|
||||
public void write(int c)
|
||||
throws IOException
|
||||
{
|
||||
out.write(c);
|
||||
sink.write(c);
|
||||
}
|
||||
|
||||
public void write(char[] b, int off, int len)
|
||||
throws IOException
|
||||
{
|
||||
out.write(b, off, len);
|
||||
sink.write(b, off, len);
|
||||
}
|
||||
|
||||
public void flush()
|
||||
throws IOException
|
||||
{
|
||||
out.flush();
|
||||
sink.flush();
|
||||
}
|
||||
|
||||
public void close()
|
||||
throws IOException
|
||||
{
|
||||
out.close();
|
||||
sink.close();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -56,6 +56,9 @@ import java.util.HashMap;
|
||||
/**
|
||||
* Main interface from the virtual machine to the JDWP back-end.
|
||||
*
|
||||
* The thread created by this class is only used for initialization.
|
||||
* Once it exits, the JDWP backend is fully initialized.
|
||||
*
|
||||
* @author Keith Seitz (keiths@redhat.com)
|
||||
*/
|
||||
public class Jdwp
|
||||
@@ -65,7 +68,8 @@ public class Jdwp
|
||||
private static Jdwp _instance = null;
|
||||
|
||||
/**
|
||||
* Are we debugging?
|
||||
* Are we debugging? Only true if debugging
|
||||
* *and* initialized.
|
||||
*/
|
||||
public static boolean isDebugging = false;
|
||||
|
||||
@@ -89,13 +93,16 @@ public class Jdwp
|
||||
// A thread group for the JDWP threads
|
||||
private ThreadGroup _group;
|
||||
|
||||
// Initialization synchronization
|
||||
private Object _initLock = new Object ();
|
||||
private int _initCount = 0;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*/
|
||||
public Jdwp ()
|
||||
{
|
||||
_shutdown = false;
|
||||
isDebugging = true;
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
@@ -271,17 +278,52 @@ public class Jdwp
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows subcomponents to specify that they are
|
||||
* initialized.
|
||||
*
|
||||
* Subcomponents include JdwpConnection and PacketProcessor.
|
||||
*/
|
||||
public void subcomponentInitialized ()
|
||||
{
|
||||
synchronized (_initLock)
|
||||
{
|
||||
++_initCount;
|
||||
_initLock.notify ();
|
||||
}
|
||||
}
|
||||
|
||||
public void run ()
|
||||
{
|
||||
try
|
||||
{
|
||||
_doInitialization ();
|
||||
|
||||
/* We need a little internal synchronization here, so that
|
||||
when this thread dies, the back-end will be fully initialized,
|
||||
ready to start servicing the VM and debugger. */
|
||||
synchronized (_initLock)
|
||||
{
|
||||
while (_initCount != 2)
|
||||
_initLock.wait ();
|
||||
}
|
||||
_initLock = null;
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
System.out.println ("Exception in JDWP back-end: " + t);
|
||||
System.exit (1);
|
||||
}
|
||||
|
||||
/* Force creation of the EventManager. If the event manager
|
||||
has not been created when isDebugging is set, it is possible
|
||||
that the VM will call Jdwp.notify (which uses EventManager)
|
||||
while the EventManager is being created (or at least this is
|
||||
a problem with gcj/gij). */
|
||||
EventManager.getDefault();
|
||||
|
||||
// Now we are finally ready and initialized
|
||||
isDebugging = true;
|
||||
}
|
||||
|
||||
// A helper function to process the configure string "-Xrunjdwp:..."
|
||||
|
||||
@@ -62,18 +62,23 @@ public class BreakpointEvent
|
||||
|
||||
// Location where breakpoint occurred
|
||||
private Location _location;
|
||||
|
||||
//object instance
|
||||
private Object _instance;
|
||||
|
||||
/**
|
||||
* Constructs a new BreakpointEvent
|
||||
*
|
||||
* @param thread thread in which event occurred
|
||||
* @param loc location where breakpoint occurred
|
||||
* @param instance object instance
|
||||
*/
|
||||
public BreakpointEvent(Thread thread, Location loc)
|
||||
public BreakpointEvent(Thread thread, Location loc, Object instance)
|
||||
{
|
||||
super(JdwpConstants.EventKind.BREAKPOINT);
|
||||
_thread = thread;
|
||||
_location = loc;
|
||||
_instance = instance;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,12 +88,14 @@ public class BreakpointEvent
|
||||
* @param type the type of parameter desired
|
||||
* @returns the desired parameter or null
|
||||
*/
|
||||
public Object getParameter(Class type)
|
||||
public Object getParameter(int type)
|
||||
{
|
||||
if (type == ThreadId.class)
|
||||
if (type == EVENT_THREAD)
|
||||
return _thread;
|
||||
else if (type == Location.class)
|
||||
else if (type == EVENT_LOCATION)
|
||||
return _location;
|
||||
else if (type == EVENT_INSTANCE)
|
||||
return _instance;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -116,11 +116,11 @@ public class ClassPrepareEvent
|
||||
* @param type the type of parameter desired
|
||||
* @returns the desired parameter or <code>null</code>
|
||||
*/
|
||||
public Object getParameter (Class type)
|
||||
public Object getParameter (int type)
|
||||
{
|
||||
if (type == ThreadId.class)
|
||||
if (type == EVENT_THREAD)
|
||||
return _thread;
|
||||
else if (type == ReferenceTypeId.class)
|
||||
else if (type == EVENT_CLASS)
|
||||
return _class;
|
||||
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/* ClassUnloadEvent.java -- event generated when a class is unloaded
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.classpath.jdwp.event;
|
||||
|
||||
import gnu.classpath.jdwp.JdwpConstants;
|
||||
import gnu.classpath.jdwp.VMIdManager;
|
||||
import gnu.classpath.jdwp.util.JdwpString;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* "Notification of a class unload in the target VM" -- JDWP 1.4.2
|
||||
*
|
||||
* @author Kyle Galloway (kgallowa@redhat.com)
|
||||
*/
|
||||
public class ClassUnloadEvent
|
||||
extends Event
|
||||
{
|
||||
//signature directly from VM
|
||||
private String _signature;
|
||||
|
||||
/**
|
||||
* Constructs a new <code>ClassUnloadEvent</code>
|
||||
*
|
||||
* @param signature the signature reported from the VM
|
||||
*/
|
||||
public ClassUnloadEvent(String signature)
|
||||
{
|
||||
super(JdwpConstants.EventKind.CLASS_UNLOAD);
|
||||
_signature = signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a specific filtering parameter for this event. Class is the only
|
||||
* valid type.
|
||||
*
|
||||
* @param type the type of parameter desired
|
||||
* @returns the desired parameter or <code>null</code>
|
||||
*/
|
||||
public Object getParameter(int type)
|
||||
{
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the event to the given stream
|
||||
*
|
||||
* @param outStream the output stream to write the event to
|
||||
*/
|
||||
protected void _writeData(DataOutputStream outStream)
|
||||
throws IOException
|
||||
{
|
||||
VMIdManager idm = VMIdManager.getDefault();
|
||||
|
||||
JdwpString.writeString(outStream, _signature);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -54,6 +54,41 @@ import java.io.IOException;
|
||||
*/
|
||||
public abstract class Event
|
||||
{
|
||||
/**
|
||||
* The class of the object in which the event occurred
|
||||
*/
|
||||
public static final int EVENT_CLASS = 1;
|
||||
|
||||
/**
|
||||
* The thread where the event occurred
|
||||
*/
|
||||
public static final int EVENT_THREAD = 2;
|
||||
|
||||
/**
|
||||
* The location where an event occurred
|
||||
*/
|
||||
public static final int EVENT_LOCATION = 3;
|
||||
|
||||
/**
|
||||
* The instance of the class where the event occurred
|
||||
*/
|
||||
public static final int EVENT_INSTANCE = 4;
|
||||
|
||||
/**
|
||||
* The field acted on by an event
|
||||
*/
|
||||
public static final int EVENT_FIELD = 5;
|
||||
|
||||
/**
|
||||
* The class of the exception for ExceptionEvent
|
||||
*/
|
||||
public static final int EVENT_EXCEPTION_CLASS = 6;
|
||||
|
||||
/**
|
||||
* Whether this exception was caught (only valid for ExceptionEvents)
|
||||
*/
|
||||
public static final int EVENT_EXCEPTION_CAUGHT = 7;
|
||||
|
||||
// The kind of event represented by this event
|
||||
private byte _eventKind;
|
||||
|
||||
@@ -97,7 +132,7 @@ public abstract class Event
|
||||
* @returns the parameter (not the ID) or <code>null</code> if none is
|
||||
* is defined for this event
|
||||
*/
|
||||
public abstract Object getParameter (Class type);
|
||||
public abstract Object getParameter (int type);
|
||||
|
||||
/**
|
||||
* Converts this event into to a JDWP packet
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* EventManager.java -- event management and notification infrastructure
|
||||
Copyright (C) 2005 Free Software Foundation
|
||||
Copyright (C) 2005, 2006 Free Software Foundation
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -69,7 +69,7 @@ import java.util.Iterator;
|
||||
public class EventManager
|
||||
{
|
||||
// Single instance
|
||||
private static EventManager _instance = new EventManager ();
|
||||
private static EventManager _instance = null;
|
||||
|
||||
// maps event (EVENT_*) to lists of EventRequests
|
||||
private Hashtable _requests = null;
|
||||
@@ -79,8 +79,11 @@ public class EventManager
|
||||
*
|
||||
* @return the event manager
|
||||
*/
|
||||
public static EventManager getDefault ()
|
||||
public static EventManager getDefault()
|
||||
{
|
||||
if (_instance == null)
|
||||
_instance = new EventManager();
|
||||
|
||||
return _instance;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
/* ExceptionEvent.java -- an event specifying an exception has been thrown
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.classpath.jdwp.event;
|
||||
|
||||
import gnu.classpath.jdwp.JdwpConstants;
|
||||
import gnu.classpath.jdwp.VMIdManager;
|
||||
import gnu.classpath.jdwp.id.ObjectId;
|
||||
import gnu.classpath.jdwp.id.ThreadId;
|
||||
import gnu.classpath.jdwp.util.Location;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Notification from the VM that an exception has occurred along with where it
|
||||
* occurred, and if and where it was caught.
|
||||
*
|
||||
* @author Kyle Galloway (kgallowa@redhat.com)
|
||||
*/
|
||||
public class ExceptionEvent
|
||||
extends Event
|
||||
{
|
||||
//object instance
|
||||
private Object _instance;
|
||||
|
||||
// the exception thrown
|
||||
private Throwable _exception;
|
||||
|
||||
// the thread in which the exception occurred
|
||||
private Thread _thread;
|
||||
|
||||
// the location where the exception was thrown
|
||||
private Location _location;
|
||||
|
||||
//the location where the exception was caught
|
||||
private Location _catchLocation;
|
||||
|
||||
//the class where the exeption was thrown
|
||||
private Class _klass;
|
||||
|
||||
/**
|
||||
* Constructs a new <code>ExceptionEvent</code> where the exception was
|
||||
* caught.
|
||||
*
|
||||
* @param exception the throwable object that generated the event
|
||||
* @param thread the thread where the exception occurred
|
||||
* @param location the location where the exception was thrown
|
||||
* @param catchLocation the location where the exception was caught
|
||||
* @param instance the instance that threw the exception
|
||||
*/
|
||||
public ExceptionEvent(Throwable exception, Thread thread, Location location,
|
||||
Location catchLocation, Class clazz, Object instance)
|
||||
{
|
||||
super(JdwpConstants.EventKind.EXCEPTION);
|
||||
_exception = exception;
|
||||
_thread = thread;
|
||||
_location = location;
|
||||
_catchLocation = catchLocation;
|
||||
_klass = clazz;
|
||||
_instance = instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a specific filtering parameter for this event. Valid types are
|
||||
* thread, location, and catchLocation.
|
||||
*
|
||||
* @param type the type of parameter desired
|
||||
* @returns the desired parameter or null
|
||||
*/
|
||||
public Object getParameter(int type)
|
||||
{
|
||||
if (type == EVENT_THREAD)
|
||||
return _thread;
|
||||
else if (type == EVENT_LOCATION)
|
||||
return _location;
|
||||
else if (type == EVENT_INSTANCE)
|
||||
return _instance;
|
||||
else if (type == EVENT_CLASS)
|
||||
return _klass;
|
||||
else if (type == EVENT_EXCEPTION_CLASS)
|
||||
return _exception.getClass();
|
||||
else if (type == EVENT_EXCEPTION_CAUGHT)
|
||||
if (_catchLocation.getMethod() != null)
|
||||
return new Boolean(true);
|
||||
else
|
||||
return new Boolean(false);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the catchLocation, used for exceptions that are caught in different
|
||||
* stack frames from where they are thrown.
|
||||
*
|
||||
* @param catchLoc the location of the catch
|
||||
*/
|
||||
public void setCatchLoc(Location catchLoc)
|
||||
{
|
||||
_catchLocation = catchLoc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the event to the given stream
|
||||
*
|
||||
* @param outStream the output stream to write the event to
|
||||
* @throws IOException
|
||||
*/
|
||||
protected void _writeData(DataOutputStream outStream)
|
||||
throws IOException
|
||||
{
|
||||
VMIdManager idm = VMIdManager.getDefault();
|
||||
ThreadId tid = (ThreadId) idm.getObjectId(_thread);
|
||||
ObjectId oid = idm.getObjectId(_exception);
|
||||
|
||||
tid.write(outStream);
|
||||
_location.write(outStream);
|
||||
oid.writeTagged(outStream);
|
||||
_catchLocation.write(outStream);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
/* MethodEntryEvent.java -- an event specifying that a method has been invoked
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.classpath.jdwp.event;
|
||||
|
||||
import gnu.classpath.jdwp.JdwpConstants;
|
||||
import gnu.classpath.jdwp.VMIdManager;
|
||||
import gnu.classpath.jdwp.id.ThreadId;
|
||||
import gnu.classpath.jdwp.util.Location;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Notification from the VM that that a method has been invoked
|
||||
*
|
||||
* @author Kyle Galloway (kgallowa@redhat.com)
|
||||
*/
|
||||
public class MethodEntryEvent
|
||||
extends Event
|
||||
{
|
||||
// The thread where the event occurred
|
||||
private Thread _thread;
|
||||
|
||||
// the location where the event occurred
|
||||
private Location _location;
|
||||
|
||||
//object instance
|
||||
private Object _instance;
|
||||
|
||||
/**
|
||||
* Constructs a new <code>MethodEntryEvent</code>
|
||||
*
|
||||
* @param thread the thread where the exception occurred
|
||||
* @param location the location single stepped to
|
||||
* @param instance instance from which the method was called
|
||||
*/
|
||||
public MethodEntryEvent(Thread thread, Location location, Object instance)
|
||||
{
|
||||
super(JdwpConstants.EventKind.METHOD_ENTRY);
|
||||
_thread = thread;
|
||||
_location = location;
|
||||
_instance = instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a specific filtering parameter for this event. Valid types are
|
||||
* thread and location
|
||||
*
|
||||
* @param type the type of parameter desired
|
||||
* @returns the desired parameter or null
|
||||
*/
|
||||
public Object getParameter(int type)
|
||||
{
|
||||
if (type == EVENT_THREAD)
|
||||
return _thread;
|
||||
else if (type == EVENT_LOCATION)
|
||||
return _location;
|
||||
else if (type == EVENT_INSTANCE)
|
||||
return _instance;
|
||||
else if (type == EVENT_CLASS)
|
||||
return _instance.getClass();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the event to the given stream
|
||||
*
|
||||
* @param outStream the output stream to write the event to
|
||||
* @throws IOException
|
||||
*/
|
||||
protected void _writeData(DataOutputStream outStream)
|
||||
throws IOException
|
||||
{
|
||||
VMIdManager idm = VMIdManager.getDefault();
|
||||
ThreadId tid = (ThreadId) idm.getObjectId(_thread);
|
||||
|
||||
tid.write(outStream);
|
||||
_location.write(outStream);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
/* MethodExitEvent.java -- an event specifying that a method has returned
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.classpath.jdwp.event;
|
||||
|
||||
import gnu.classpath.jdwp.JdwpConstants;
|
||||
import gnu.classpath.jdwp.VMIdManager;
|
||||
import gnu.classpath.jdwp.id.ThreadId;
|
||||
import gnu.classpath.jdwp.util.Location;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Notification from the VM that that a method has returned
|
||||
*
|
||||
* @author Kyle Galloway (kgallowa@redhat.com)
|
||||
*/
|
||||
public class MethodExitEvent
|
||||
extends Event
|
||||
{
|
||||
// The thread where the event occurred
|
||||
private Thread _thread;
|
||||
|
||||
// the location where the event occurred
|
||||
private Location _location;
|
||||
|
||||
// object instance
|
||||
private Object _instance;
|
||||
|
||||
/**
|
||||
* Constructs a new <code>MethodExitEvent</code>
|
||||
*
|
||||
* @param thread the thread where the exception occurred
|
||||
* @param location the location single stepped to
|
||||
* @param instance the instance from which the method was called
|
||||
*/
|
||||
public MethodExitEvent(Thread thread, Location location, Object instance)
|
||||
{
|
||||
super(JdwpConstants.EventKind.METHOD_EXIT);
|
||||
_thread = thread;
|
||||
_location = location;
|
||||
_instance = instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a specific filtering parameter for this event. Valid types are
|
||||
* thread and location
|
||||
*
|
||||
* @param type the type of parameter desired
|
||||
* @returns the desired parameter or null
|
||||
*/
|
||||
public Object getParameter(int type)
|
||||
{
|
||||
if (type == EVENT_THREAD)
|
||||
return _thread;
|
||||
else if (type == EVENT_LOCATION)
|
||||
return _location;
|
||||
else if (type == EVENT_CLASS)
|
||||
return _instance.getClass();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the event to the given stream
|
||||
*
|
||||
* @param outStream the output stream to write the event to
|
||||
* @throws IOException
|
||||
*/
|
||||
protected void _writeData(DataOutputStream outStream)
|
||||
throws IOException
|
||||
{
|
||||
VMIdManager idm = VMIdManager.getDefault();
|
||||
ThreadId tid = (ThreadId) idm.getObjectId(_thread);
|
||||
|
||||
tid.write(outStream);
|
||||
_location.write(outStream);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
/* SingleStepEvent.java -- an event specifying that a single step has
|
||||
compleated
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.classpath.jdwp.event;
|
||||
|
||||
import gnu.classpath.jdwp.JdwpConstants;
|
||||
import gnu.classpath.jdwp.VMIdManager;
|
||||
import gnu.classpath.jdwp.id.ThreadId;
|
||||
import gnu.classpath.jdwp.util.Location;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Notification from the VM that a single step has compleated including the
|
||||
* thread and location stepped to
|
||||
*
|
||||
* @author Kyle Galloway (kgallowa@redhat.com)
|
||||
*/
|
||||
public class SingleStepEvent
|
||||
extends Event
|
||||
{
|
||||
// the thread where the event occurred
|
||||
private Thread _thread;
|
||||
|
||||
// the location where the event occurred
|
||||
private Location _location;
|
||||
|
||||
//object instance
|
||||
private Object _instance;
|
||||
|
||||
/**
|
||||
* Constructs a new <code>SingleStepEvent</code>
|
||||
*
|
||||
* @param thread the thread where the exception occurred
|
||||
* @param location the location single stepped to
|
||||
* @param instance the instance in which the single step occurred
|
||||
*/
|
||||
public SingleStepEvent(Thread thread, Location location, Object instance)
|
||||
{
|
||||
super(JdwpConstants.EventKind.SINGLE_STEP);
|
||||
_thread = thread;
|
||||
_location = location;
|
||||
_instance = instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a specific filtering parameter for this event. Valid types are
|
||||
* thread and location
|
||||
*
|
||||
* @param type the type of parameter desired
|
||||
* @returns the desired parameter or null
|
||||
*/
|
||||
public Object getParameter(int type)
|
||||
{
|
||||
if (type == EVENT_THREAD)
|
||||
return _thread;
|
||||
else if (type == EVENT_LOCATION)
|
||||
return _location;
|
||||
else if (type == EVENT_INSTANCE)
|
||||
return _instance;
|
||||
else if (type == EVENT_CLASS)
|
||||
return _instance.getClass();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the event to the given stream
|
||||
*
|
||||
* @param outStream the output stream to write the event to
|
||||
* @throws IOException
|
||||
*/
|
||||
protected void _writeData(DataOutputStream outStream)
|
||||
throws IOException
|
||||
{
|
||||
VMIdManager idm = VMIdManager.getDefault();
|
||||
ThreadId tid = (ThreadId) idm.getObjectId(_thread);
|
||||
|
||||
tid.write(outStream);
|
||||
_location.write(outStream);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -81,9 +81,9 @@ public class ThreadEndEvent
|
||||
* @param type the type of parameter desired
|
||||
* @returns the desired parameter or <code>null</code>
|
||||
*/
|
||||
public Object getParameter (Class type)
|
||||
public Object getParameter (int type)
|
||||
{
|
||||
if (type == ThreadId.class)
|
||||
if (type == EVENT_THREAD)
|
||||
return _thread;
|
||||
|
||||
return null;
|
||||
|
||||
@@ -86,9 +86,9 @@ public class ThreadStartEvent
|
||||
* @param type the type of parameter desired
|
||||
* @returns the desired parameter or <code>null</code>
|
||||
*/
|
||||
public Object getParameter (Class type)
|
||||
public Object getParameter (int type)
|
||||
{
|
||||
if (type == ThreadId.class)
|
||||
if (type == EVENT_THREAD)
|
||||
return _thread;
|
||||
|
||||
return null;
|
||||
|
||||
@@ -67,7 +67,7 @@ public class VmDeathEvent
|
||||
* @param type the type of parameter desired
|
||||
* @returns the desired parameter or <code>null</code>
|
||||
*/
|
||||
public Object getParameter (Class type)
|
||||
public Object getParameter (int type)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class VmInitEvent
|
||||
* @param type the type of parameter desired
|
||||
* @returns the desired parameter or <code>null</code>
|
||||
*/
|
||||
public Object getParameter (Class type)
|
||||
public Object getParameter (int type)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ package gnu.classpath.jdwp.event.filters;
|
||||
|
||||
import gnu.classpath.jdwp.event.Event;
|
||||
import gnu.classpath.jdwp.exception.InvalidStringException;
|
||||
import gnu.classpath.jdwp.id.ReferenceTypeId;
|
||||
|
||||
/**
|
||||
* An event filter which includes events matching a
|
||||
@@ -91,7 +90,7 @@ public class ClassMatchFilter
|
||||
*/
|
||||
public boolean matches (Event event)
|
||||
{
|
||||
Object type = event.getParameter (ReferenceTypeId.class);
|
||||
Object type = event.getParameter (Event.EVENT_CLASS);
|
||||
if (type != null)
|
||||
{
|
||||
Class eventClass = (Class) type;
|
||||
|
||||
@@ -87,7 +87,7 @@ public class ClassOnlyFilter
|
||||
*/
|
||||
public boolean matches (Event event)
|
||||
{
|
||||
Object type = event.getParameter (ReferenceTypeId.class);
|
||||
Object type = event.getParameter (Event.EVENT_CLASS);
|
||||
if (type != null)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* ExceptionOnlyFilter.java --
|
||||
Copyright (C) 2005 Free Software Foundation
|
||||
/* ExceptionOnlyFilter.java -- filter for excetions by caught/uncaught and type
|
||||
Copyright (C) 2005, 2006 Free Software Foundation
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ExceptionOnlyFilter
|
||||
/**
|
||||
* Constructs a new ExceptionOnlyFilter
|
||||
*
|
||||
* @param refId ID of the exception to report
|
||||
* @param refId ID of the exception to report(null for all exceptions)
|
||||
* @param caught Report caught exceptions
|
||||
* @param uncaught Report uncaught exceptions
|
||||
* @throws InvalidClassException if refid is invalid
|
||||
@@ -70,8 +70,8 @@ public class ExceptionOnlyFilter
|
||||
boolean uncaught)
|
||||
throws InvalidClassException
|
||||
{
|
||||
if (refId == null || refId.getReference().get () == null)
|
||||
throw new InvalidClassException (refId.getId ());
|
||||
if (refId != null && refId.getReference().get() == null)
|
||||
throw new InvalidClassException(refId.getId());
|
||||
|
||||
_refId = refId;
|
||||
_caught = caught;
|
||||
@@ -88,34 +88,36 @@ public class ExceptionOnlyFilter
|
||||
return _refId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Report caught exceptions?
|
||||
*
|
||||
* @return whether to report caught exceptions
|
||||
*/
|
||||
public boolean forCaught ()
|
||||
{
|
||||
return _caught;
|
||||
}
|
||||
|
||||
/**
|
||||
* Report uncaught exceptions?
|
||||
*
|
||||
* @return whether to report uncaught exceptions
|
||||
*/
|
||||
public boolean forUncaught ()
|
||||
{
|
||||
return _uncaught;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Does the given event match the filter?
|
||||
*
|
||||
* @param event the <code>Event</code> to scrutinize
|
||||
*
|
||||
* @param event the <code>Event</code> to scrutinize
|
||||
*/
|
||||
public boolean matches (Event event)
|
||||
public boolean matches(Event event)
|
||||
{
|
||||
// FIXME
|
||||
throw new RuntimeException ("ExceptionOnlyFilter.matches not implemented");
|
||||
boolean classMatch = true;
|
||||
|
||||
// if not allowing all exceptions check if the exception matches
|
||||
if (_refId != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
Class klass
|
||||
= (Class) event.getParameter(Event.EVENT_EXCEPTION_CLASS);
|
||||
classMatch = klass == _refId.getType();
|
||||
}
|
||||
catch (InvalidClassException ex)
|
||||
{
|
||||
classMatch = false;
|
||||
}
|
||||
}
|
||||
|
||||
// check against the caught and uncaught options
|
||||
Boolean caught
|
||||
= (Boolean) event.getParameter(Event.EVENT_EXCEPTION_CAUGHT);
|
||||
|
||||
return classMatch && ((caught.booleanValue()) ? _caught : _uncaught);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public class InstanceOnlyFilter
|
||||
*/
|
||||
public boolean matches (Event event)
|
||||
{
|
||||
Object eventInstance = event.getParameter (ObjectId.class);
|
||||
Object eventInstance = event.getParameter (Event.EVENT_INSTANCE);
|
||||
if (eventInstance != null)
|
||||
{
|
||||
Object myInstance = _instance.getReference().get ();
|
||||
|
||||
@@ -65,7 +65,7 @@ public class ThreadOnlyFilter
|
||||
public ThreadOnlyFilter (ThreadId tid)
|
||||
throws InvalidThreadException
|
||||
{
|
||||
if (tid.getReference().get () == null)
|
||||
if (tid == null || tid.getReference().get () == null)
|
||||
throw new InvalidThreadException (tid.getId ());
|
||||
|
||||
_tid = tid;
|
||||
@@ -88,7 +88,7 @@ public class ThreadOnlyFilter
|
||||
*/
|
||||
public boolean matches (Event event)
|
||||
{
|
||||
Object thread = event.getParameter (ThreadId.class);
|
||||
Object thread = event.getParameter (Event.EVENT_THREAD);
|
||||
if (thread != null)
|
||||
{
|
||||
Thread eventThread = (Thread) thread;
|
||||
|
||||
@@ -106,8 +106,12 @@ public class ClassTypeCommandSet
|
||||
Class clazz = refId.getType();
|
||||
Class superClazz = clazz.getSuperclass();
|
||||
|
||||
ReferenceTypeId clazzId = idMan.getReferenceTypeId(superClazz);
|
||||
clazzId.write(os);
|
||||
if (superClazz == null) {
|
||||
os.writeLong(0L);
|
||||
} else {
|
||||
ReferenceTypeId clazzId = idMan.getReferenceTypeId(superClazz);
|
||||
clazzId.write(os);
|
||||
}
|
||||
}
|
||||
|
||||
private void executeSetValues(ByteBuffer bb, DataOutputStream os)
|
||||
|
||||
@@ -147,7 +147,7 @@ public class EventRequestCommandSet
|
||||
if (id == 0)
|
||||
refId = null;
|
||||
else
|
||||
refId = idMan.readReferenceTypeId(bb);
|
||||
refId = idMan.getReferenceType(id);
|
||||
boolean caught = (bb.get() == 0) ? false : true;
|
||||
boolean unCaught = (bb.get() == 0) ? false : true;
|
||||
filter = new ExceptionOnlyFilter(refId, caught, unCaught);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* PacketProcessor.java -- a thread which processes command packets
|
||||
from the debugger
|
||||
Copyright (C) 2005 Free Software Foundation
|
||||
Copyright (C) 2005, 2006 Free Software Foundation
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -137,6 +137,10 @@ public class PacketProcessor
|
||||
*/
|
||||
public Object run ()
|
||||
{
|
||||
// Notify initialization thread (gnu.classpath.jdwp.Jdwp) that
|
||||
// the PacketProcessor thread is ready.
|
||||
Jdwp.getDefault().subcomponentInitialized ();
|
||||
|
||||
try
|
||||
{
|
||||
while (!_shutdown)
|
||||
@@ -144,7 +148,7 @@ public class PacketProcessor
|
||||
_processOnePacket ();
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -103,8 +103,12 @@ public class ThreadGroupReferenceCommandSet
|
||||
ObjectId oid = idMan.readObjectId(bb);
|
||||
ThreadGroup group = (ThreadGroup) oid.getObject();
|
||||
ThreadGroup parent = group.getParent();
|
||||
ObjectId parentId = idMan.getObjectId(parent);
|
||||
parentId.write(os);
|
||||
if (parent == null) {
|
||||
os.writeLong(0L);
|
||||
} else {
|
||||
ObjectId parentId = idMan.getObjectId(parent);
|
||||
parentId.write(os);
|
||||
}
|
||||
}
|
||||
|
||||
private void executeChildren(ByteBuffer bb, DataOutputStream os)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* JdwpConnection.java -- A JDWP-speaking connection
|
||||
Copyright (C) 2005 Free Software Foundation
|
||||
Copyright (C) 2005, 2006 Free Software Foundation
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -165,6 +165,10 @@ public class JdwpConnection
|
||||
*/
|
||||
public void run ()
|
||||
{
|
||||
// Notify initialization thread (gnu.classpath.jdwp.Jdwp) that
|
||||
// the JdwpConnection thread is ready.
|
||||
Jdwp.getDefault().subcomponentInitialized ();
|
||||
|
||||
while (!_shutdown)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -94,18 +94,40 @@ public class Location
|
||||
* @param os stream to write to
|
||||
* @throws IOException when an error occurs writing to the stream
|
||||
*/
|
||||
public void write(DataOutputStream os)
|
||||
public void write(DataOutputStream os)
|
||||
throws IOException
|
||||
{
|
||||
VMIdManager idm = VMIdManager.getDefault();
|
||||
ClassReferenceTypeId crti = (ClassReferenceTypeId)
|
||||
idm.getReferenceTypeId(method.getDeclaringClass());
|
||||
// check if this is an empty location
|
||||
if (method != null)
|
||||
{
|
||||
VMIdManager idm = VMIdManager.getDefault();
|
||||
ClassReferenceTypeId crti =
|
||||
(ClassReferenceTypeId)
|
||||
idm.getReferenceTypeId(method.getDeclaringClass());
|
||||
|
||||
crti.writeTagged(os);
|
||||
method.writeId(os);
|
||||
os.writeLong(index);
|
||||
crti.writeTagged(os);
|
||||
method.writeId(os);
|
||||
os.writeLong(index);
|
||||
}
|
||||
else
|
||||
{
|
||||
os.writeByte(1);
|
||||
os.writeLong((long) 0);
|
||||
os.writeLong((long) 0);
|
||||
os.writeLong((long) 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets up an empty location
|
||||
*
|
||||
* @return new Location (setup as empty)
|
||||
*/
|
||||
public static Location getEmptyLocation()
|
||||
{
|
||||
return new Location(null, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the method of this location
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* ClasspathToolkit.java -- Abstract superclass for Classpath toolkits.
|
||||
Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -41,7 +41,6 @@ package gnu.java.awt;
|
||||
import gnu.java.awt.EmbeddedWindow;
|
||||
import gnu.java.awt.peer.ClasspathFontPeer;
|
||||
import gnu.java.awt.peer.EmbeddedWindowPeer;
|
||||
import gnu.java.awt.peer.ClasspathTextLayoutPeer;
|
||||
import gnu.java.security.action.SetAccessibleAction;
|
||||
|
||||
import java.awt.AWTException;
|
||||
@@ -53,6 +52,7 @@ import java.awt.FontMetrics;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.font.FontRenderContext;
|
||||
import java.awt.image.ColorModel;
|
||||
@@ -120,10 +120,6 @@ public abstract class ClasspathToolkit
|
||||
*/
|
||||
public abstract ClasspathFontPeer getClasspathFontPeer (String name, Map attrs);
|
||||
|
||||
public abstract ClasspathTextLayoutPeer
|
||||
getClasspathTextLayoutPeer (AttributedString str, FontRenderContext frc);
|
||||
|
||||
|
||||
/**
|
||||
* Creates a {@link Font}, in a platform-specific manner.
|
||||
*
|
||||
@@ -193,6 +189,9 @@ public abstract class ClasspathToolkit
|
||||
*/
|
||||
public abstract Font createFont(int format, InputStream stream);
|
||||
|
||||
/**
|
||||
* Creates a RobotPeer on a given GraphicsDevice.
|
||||
*/
|
||||
public abstract RobotPeer createRobot (GraphicsDevice screen)
|
||||
throws AWTException;
|
||||
|
||||
@@ -206,8 +205,24 @@ public abstract class ClasspathToolkit
|
||||
|
||||
/**
|
||||
* Used to register ImageIO SPIs provided by the toolkit.
|
||||
*
|
||||
* Our default implementation does nothing.
|
||||
*/
|
||||
public void registerImageIOSpis(IIORegistry reg)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of mouse buttons.
|
||||
* (used by java.awt.MouseInfo).
|
||||
*
|
||||
* This dummy implementation returns -1 (no mouse).
|
||||
* toolkit implementors should overload this method if possible.
|
||||
* @since 1.5
|
||||
*/
|
||||
public int getMouseNumberOfButtons()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
/* GtkMouseDragGestureRecognizer.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.awt.dnd;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Point;
|
||||
import java.awt.dnd.DnDConstants;
|
||||
import java.awt.dnd.DragGestureListener;
|
||||
import java.awt.dnd.DragSource;
|
||||
import java.awt.dnd.MouseDragGestureRecognizer;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class GtkMouseDragGestureRecognizer
|
||||
extends MouseDragGestureRecognizer
|
||||
{
|
||||
|
||||
public GtkMouseDragGestureRecognizer (DragSource ds)
|
||||
{
|
||||
this(ds, null, 0, null);
|
||||
}
|
||||
|
||||
public GtkMouseDragGestureRecognizer (DragSource ds, Component c)
|
||||
{
|
||||
this (ds, c, 0, null);
|
||||
}
|
||||
|
||||
public GtkMouseDragGestureRecognizer (DragSource ds, Component c, int act)
|
||||
{
|
||||
this(ds, c, act, null);
|
||||
}
|
||||
|
||||
public GtkMouseDragGestureRecognizer (DragSource ds, Component c, int act,
|
||||
DragGestureListener dgl)
|
||||
{
|
||||
super(ds, c, act, dgl);
|
||||
}
|
||||
|
||||
public void registerListeners ()
|
||||
{
|
||||
super.registerListeners();
|
||||
}
|
||||
|
||||
public void unregisterListeners ()
|
||||
{
|
||||
super.unregisterListeners();
|
||||
}
|
||||
|
||||
public void mouseClicked (MouseEvent e)
|
||||
{
|
||||
// Nothing to do here.
|
||||
}
|
||||
|
||||
public void mousePressed (MouseEvent e)
|
||||
{
|
||||
events.clear();
|
||||
if (getDropActionFromEvent(e) != DnDConstants.ACTION_NONE)
|
||||
appendEvent(e);
|
||||
}
|
||||
|
||||
public void mouseReleased (MouseEvent e)
|
||||
{
|
||||
events.clear();
|
||||
}
|
||||
|
||||
public void mouseEntered (MouseEvent e)
|
||||
{
|
||||
events.clear();
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent e)
|
||||
{
|
||||
if (!events.isEmpty())
|
||||
if (getDropActionFromEvent(e) == DnDConstants.ACTION_NONE)
|
||||
events.clear();
|
||||
}
|
||||
|
||||
public void mouseDragged(MouseEvent e)
|
||||
{
|
||||
if (!events.isEmpty())
|
||||
{
|
||||
int act = getDropActionFromEvent(e);
|
||||
|
||||
if (act == DnDConstants.ACTION_NONE)
|
||||
return;
|
||||
|
||||
Point origin = ((MouseEvent) events.get(0)).getPoint();
|
||||
Point current = e.getPoint();
|
||||
int dx = Math.abs(origin.x - current.x);
|
||||
int dy = Math.abs(origin.y - current.y);
|
||||
int threshold = DragSource.getDragThreshold();
|
||||
|
||||
if (dx > threshold || dy > threshold)
|
||||
fireDragGestureRecognized(act, origin);
|
||||
else
|
||||
appendEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseMoved (MouseEvent e)
|
||||
{
|
||||
// Nothing to do here.
|
||||
}
|
||||
|
||||
private int getDropActionFromEvent(MouseEvent e)
|
||||
{
|
||||
int modEx = e.getModifiersEx();
|
||||
int buttons = modEx & (MouseEvent.BUTTON1_DOWN_MASK
|
||||
| MouseEvent.BUTTON2_DOWN_MASK | MouseEvent.BUTTON3_DOWN_MASK);
|
||||
if (!(buttons == MouseEvent.BUTTON1_DOWN_MASK ||
|
||||
buttons == MouseEvent.BUTTON2_DOWN_MASK))
|
||||
return DnDConstants.ACTION_NONE;
|
||||
|
||||
// Convert modifier to a drop action
|
||||
int sourceActions = getSourceActions();
|
||||
int mod = modEx
|
||||
& (MouseEvent.SHIFT_DOWN_MASK | MouseEvent.CTRL_DOWN_MASK);
|
||||
switch (mod)
|
||||
{
|
||||
case MouseEvent.SHIFT_DOWN_MASK | MouseEvent.CTRL_DOWN_MASK:
|
||||
return DnDConstants.ACTION_LINK & sourceActions;
|
||||
case MouseEvent.CTRL_DOWN_MASK:
|
||||
return DnDConstants.ACTION_COPY & sourceActions;
|
||||
case MouseEvent.SHIFT_DOWN_MASK:
|
||||
return DnDConstants.ACTION_MOVE & sourceActions;
|
||||
default:
|
||||
if ((sourceActions & DnDConstants.ACTION_MOVE) != 0)
|
||||
return DnDConstants.ACTION_MOVE & sourceActions;
|
||||
else if ((sourceActions & DnDConstants.ACTION_COPY) != 0)
|
||||
return DnDConstants.ACTION_COPY & sourceActions;
|
||||
else if ((sourceActions & DnDConstants.ACTION_LINK) != 0)
|
||||
return DnDConstants.ACTION_LINK & sourceActions;
|
||||
}
|
||||
|
||||
return DnDConstants.ACTION_NONE & sourceActions;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
/* GtkDragSourceContextPeer.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.awt.dnd.peer.gtk;
|
||||
|
||||
import gnu.java.awt.peer.gtk.GtkGenericPeer;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.dnd.DragGestureEvent;
|
||||
import java.awt.dnd.DragSourceContext;
|
||||
import java.awt.dnd.DragSourceDragEvent;
|
||||
import java.awt.dnd.DragSourceDropEvent;
|
||||
import java.awt.dnd.DragSourceEvent;
|
||||
import java.awt.dnd.InvalidDnDOperationException;
|
||||
import java.awt.dnd.peer.DragSourceContextPeer;
|
||||
import java.awt.peer.ComponentPeer;
|
||||
import java.awt.peer.LightweightPeer;
|
||||
|
||||
public class GtkDragSourceContextPeer
|
||||
extends GtkGenericPeer
|
||||
implements DragSourceContextPeer
|
||||
{
|
||||
private ComponentPeer peer;
|
||||
private Cursor cursor;
|
||||
private DragSourceContext context;
|
||||
|
||||
native void nativeStartDrag(Image i, int x, int y, int action, String target);
|
||||
native void connectSignals(ComponentPeer comp);
|
||||
native void create(ComponentPeer comp);
|
||||
native void nativeSetCursor(int cursor);
|
||||
|
||||
public GtkDragSourceContextPeer(DragGestureEvent e)
|
||||
{
|
||||
super(e.getComponent());
|
||||
Component comp = e.getComponent();
|
||||
peer = getComponentPeer(comp);
|
||||
|
||||
create(peer);
|
||||
connectSignals(peer);
|
||||
cursor = comp.getCursor();
|
||||
}
|
||||
|
||||
ComponentPeer getComponentPeer(Component c)
|
||||
{
|
||||
Component curr = c;
|
||||
while (curr.getPeer() instanceof LightweightPeer)
|
||||
curr = curr.getParent();
|
||||
|
||||
if (curr != null)
|
||||
return curr.getPeer();
|
||||
return null;
|
||||
}
|
||||
|
||||
public void startDrag(DragSourceContext context, Cursor c, Image i, Point p)
|
||||
throws InvalidDnDOperationException
|
||||
{
|
||||
this.context = context;
|
||||
|
||||
if (p == null)
|
||||
p = new Point();
|
||||
|
||||
// FIXME: use proper DataFlavor, not "text/plain".
|
||||
// Also, add check to determine if dragging.
|
||||
|
||||
setCursor(c);
|
||||
nativeStartDrag(i, p.x, p.y, context.getTrigger().getDragAction(),
|
||||
"text/plain");
|
||||
}
|
||||
|
||||
public Cursor getCursor()
|
||||
{
|
||||
return cursor;
|
||||
}
|
||||
|
||||
public void setCursor(Cursor c) throws InvalidDnDOperationException
|
||||
{
|
||||
if (c != null)
|
||||
{
|
||||
nativeSetCursor(c.getType());
|
||||
cursor = c;
|
||||
}
|
||||
}
|
||||
|
||||
public void transferablesFlavorsChanged()
|
||||
{
|
||||
// Nothing to do here.
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from native code.
|
||||
*/
|
||||
|
||||
public void dragEnter(int action, int modifiers)
|
||||
{
|
||||
context.dragEnter(new DragSourceDragEvent(context, action,
|
||||
action
|
||||
& context.getSourceActions(),
|
||||
modifiers));
|
||||
}
|
||||
|
||||
public void dragExit(int action, int x, int y)
|
||||
{
|
||||
context.dragExit(new DragSourceEvent(context, x, y));
|
||||
}
|
||||
|
||||
public void dragDropEnd(int action, boolean success, int x, int y)
|
||||
{
|
||||
context.dragDropEnd(new DragSourceDropEvent(context, action, success, x, y));
|
||||
}
|
||||
|
||||
public void dragMouseMoved(int action, int modifiers)
|
||||
{
|
||||
context.dragMouseMoved(new DragSourceDragEvent(context,
|
||||
action,
|
||||
action
|
||||
& context.getSourceActions(),
|
||||
modifiers));
|
||||
}
|
||||
|
||||
public void dragOver(int action, int modifiers)
|
||||
{
|
||||
context.dragOver(new DragSourceDragEvent(context, action,
|
||||
action
|
||||
& context.getSourceActions(),
|
||||
modifiers));
|
||||
}
|
||||
|
||||
public void dragActionChanged(int newAction, int modifiers)
|
||||
{
|
||||
context.dropActionChanged(new DragSourceDragEvent(context,
|
||||
newAction,
|
||||
newAction
|
||||
& context.getSourceActions(),
|
||||
modifiers));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/* GtkDropTargetContextPeer.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.awt.dnd.peer.gtk;
|
||||
|
||||
import gnu.java.awt.peer.gtk.GtkGenericPeer;
|
||||
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.dnd.DropTarget;
|
||||
import java.awt.dnd.InvalidDnDOperationException;
|
||||
import java.awt.dnd.peer.DropTargetContextPeer;
|
||||
|
||||
public class GtkDropTargetContextPeer
|
||||
extends GtkGenericPeer
|
||||
implements DropTargetContextPeer
|
||||
{
|
||||
|
||||
public GtkDropTargetContextPeer()
|
||||
{
|
||||
super(null);
|
||||
}
|
||||
|
||||
public void setTargetActions(int actions)
|
||||
{
|
||||
// FIXME: Not Implemented
|
||||
|
||||
}
|
||||
|
||||
public int getTargetActions()
|
||||
{
|
||||
// FIXME: Not Implemented
|
||||
return 0;
|
||||
}
|
||||
|
||||
public DropTarget getDropTarget()
|
||||
{
|
||||
// FIXME: Not Implemented
|
||||
return null;
|
||||
}
|
||||
|
||||
public DataFlavor[] getTransferDataFlavors()
|
||||
{
|
||||
// FIXME: Not Implemented
|
||||
return null;
|
||||
}
|
||||
|
||||
public Transferable getTransferable() throws InvalidDnDOperationException
|
||||
{
|
||||
// FIXME: Not Implemented
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isTransferableJVMLocal()
|
||||
{
|
||||
// FIXME: Not Implemented
|
||||
return false;
|
||||
}
|
||||
|
||||
public void acceptDrag(int dragAction)
|
||||
{
|
||||
// FIXME: Not Implemented
|
||||
|
||||
}
|
||||
|
||||
public void rejectDrag()
|
||||
{
|
||||
// FIXME: Not Implemented
|
||||
|
||||
}
|
||||
|
||||
public void acceptDrop(int dropAction)
|
||||
{
|
||||
// FIXME: Not Implemented
|
||||
|
||||
}
|
||||
|
||||
public void rejectDrop()
|
||||
{
|
||||
// FIXME: Not Implemented
|
||||
|
||||
}
|
||||
|
||||
public void dropComplete(boolean success)
|
||||
{
|
||||
// FIXME: Not Implemented
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/* GtkDropTargetPeer.java --
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.awt.dnd.peer.gtk;
|
||||
|
||||
import gnu.java.awt.peer.gtk.GtkGenericPeer;
|
||||
|
||||
import java.awt.dnd.DropTarget;
|
||||
import java.awt.dnd.peer.DropTargetPeer;
|
||||
|
||||
public class GtkDropTargetPeer
|
||||
extends GtkGenericPeer
|
||||
implements DropTargetPeer
|
||||
{
|
||||
|
||||
public GtkDropTargetPeer()
|
||||
{
|
||||
super(null);
|
||||
}
|
||||
|
||||
public void addDropTarget(DropTarget target)
|
||||
{
|
||||
// FIXME: Not Implemented
|
||||
|
||||
}
|
||||
|
||||
public void removeDropTarget(DropTarget target)
|
||||
{
|
||||
// FIXME: Not Implemented
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -39,6 +39,7 @@ package gnu.java.awt.java2d;
|
||||
|
||||
import java.awt.AWTError;
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.AWTPermission;
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Composite;
|
||||
@@ -72,6 +73,7 @@ import java.awt.geom.RoundRectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.BufferedImageOp;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.awt.image.DataBuffer;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.awt.image.Raster;
|
||||
import java.awt.image.RenderedImage;
|
||||
@@ -144,7 +146,7 @@ public abstract class AbstractGraphics2D
|
||||
/**
|
||||
* The transformation for this Graphics2D instance
|
||||
*/
|
||||
private AffineTransform transform;
|
||||
protected AffineTransform transform;
|
||||
|
||||
/**
|
||||
* The foreground.
|
||||
@@ -539,6 +541,15 @@ public abstract class AbstractGraphics2D
|
||||
*/
|
||||
public void setComposite(Composite comp)
|
||||
{
|
||||
if (! (comp instanceof AlphaComposite))
|
||||
{
|
||||
// FIXME: this check is only required "if this Graphics2D
|
||||
// context is drawing to a Component on the display screen".
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null)
|
||||
sm.checkPermission(new AWTPermission("readDisplayPixels"));
|
||||
}
|
||||
|
||||
composite = comp;
|
||||
if (! (comp.equals(AlphaComposite.SrcOver)))
|
||||
isOptimized = false;
|
||||
@@ -2054,7 +2065,34 @@ public abstract class AbstractGraphics2D
|
||||
*
|
||||
* @return the destination raster
|
||||
*/
|
||||
protected abstract WritableRaster getDestinationRaster();
|
||||
protected WritableRaster getDestinationRaster()
|
||||
{
|
||||
// TODO: Ideally we would fetch the xdrawable's surface pixels for
|
||||
// initialization of the raster.
|
||||
Rectangle db = getDeviceBounds();
|
||||
if (destinationRaster == null)
|
||||
{
|
||||
int[] bandMasks = new int[]{ 0xFF0000, 0xFF00, 0xFF };
|
||||
destinationRaster = Raster.createPackedRaster(DataBuffer.TYPE_INT,
|
||||
db.width, db.height,
|
||||
bandMasks, null);
|
||||
// Initialize raster with white.
|
||||
int x0 = destinationRaster.getMinX();
|
||||
int x1 = destinationRaster.getWidth() + x0;
|
||||
int y0 = destinationRaster.getMinY();
|
||||
int y1 = destinationRaster.getHeight() + y0;
|
||||
int numBands = destinationRaster.getNumBands();
|
||||
for (int y = y0; y < y1; y++)
|
||||
{
|
||||
for (int x = x0; x < x1; x++)
|
||||
{
|
||||
for (int b = 0; b < numBands; b++)
|
||||
destinationRaster.setSample(x, y, b, 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
return destinationRaster;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies the backend that the raster has changed in the specified
|
||||
|
||||
@@ -39,6 +39,7 @@ exception statement from your version. */
|
||||
package gnu.java.awt.java2d;
|
||||
|
||||
|
||||
import java.awt.geom.CubicCurve2D;
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
/**
|
||||
@@ -78,34 +79,89 @@ public class CubicSegment extends Segment
|
||||
*/
|
||||
public Object clone()
|
||||
{
|
||||
return new CubicSegment(P1.getX(), P1.getY(), cp1.getX(), cp1.getY(),
|
||||
cp2.getX(), cp2.getY(), P2.getX(), P2.getY());
|
||||
CubicSegment segment = null;
|
||||
|
||||
try
|
||||
{
|
||||
segment = (CubicSegment) super.clone();
|
||||
|
||||
segment.P1 = (Point2D) P1.clone();
|
||||
segment.P2 = (Point2D) P2.clone();
|
||||
segment.cp1 = (Point2D) cp1.clone();
|
||||
segment.cp2 = (Point2D) cp2.clone();
|
||||
}
|
||||
catch (CloneNotSupportedException cnse)
|
||||
{
|
||||
InternalError ie = new InternalError();
|
||||
ie.initCause(cnse);
|
||||
throw ie;
|
||||
}
|
||||
|
||||
return segment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the "top" and "bottom" segments of this segment.
|
||||
* First array element is p0 + normal, second is p0 - normal.
|
||||
* Get the "top" and "bottom" segments of this segment. First array element is
|
||||
* p0 + normal, second is p0 - normal.
|
||||
*/
|
||||
public Segment[] getDisplacedSegments(double radius)
|
||||
{
|
||||
// It is, apparently, impossible to derive a curve parallel to a bezier
|
||||
// curve (unless it's a straight line), so we have no choice but to
|
||||
// approximate the displaced segments. Similar to FlattenPathIterator.
|
||||
|
||||
Segment segmentTop = null;
|
||||
Segment segmentBottom = null;
|
||||
this.radius = radius;
|
||||
double x0 = P1.getX();
|
||||
double y0 = P1.getY();
|
||||
double x1 = cp1.getX();
|
||||
double y1 = cp1.getY();
|
||||
double x2 = cp2.getX();
|
||||
double y2 = cp2.getY();
|
||||
double x3 = P2.getX();
|
||||
double y3 = P2.getY();
|
||||
double[] p1 = normal(x0, y0, x1, y1);
|
||||
double[] p2 = normal(x2, y2, x3, y3);
|
||||
|
||||
|
||||
// FIXME: Doesn't compile.
|
||||
// return new Segment[]{s1, s2};
|
||||
return new Segment[0];
|
||||
CubicCurve2D[] curves = new CubicCurve2D[10];
|
||||
curves[0] = new CubicCurve2D.Double(P1.getX(), P1.getY(), cp1.getX(),
|
||||
cp1.getY(), cp2.getX(), cp2.getY(),
|
||||
P2.getX(), P2.getY());
|
||||
int numCurves = 1;
|
||||
|
||||
// Hard-coded a recursion limit of 10 and flatness of 1... should we make
|
||||
// this an option somewhere?
|
||||
while (numCurves > 0)
|
||||
{
|
||||
// The curve is flat enough, or we've reached our recursion limit,
|
||||
// so take the current start/end points and add it as a line segment
|
||||
// to our final approximated curves
|
||||
if (curves[numCurves - 1].getFlatnessSq() <= (radius / 3) || numCurves == 10)
|
||||
{
|
||||
Segment[] displaced = new LineSegment(
|
||||
curves[numCurves - 1].getP1(),
|
||||
curves[numCurves - 1].getP2()).getDisplacedSegments(radius);
|
||||
if (segmentTop == null)
|
||||
{
|
||||
segmentTop = displaced[0];
|
||||
segmentBottom = displaced[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
segmentTop.add(displaced[0]);
|
||||
segmentBottom.add(displaced[1]);
|
||||
}
|
||||
numCurves--;
|
||||
}
|
||||
|
||||
// Otherwise, subdivide again and continue
|
||||
else
|
||||
{
|
||||
CubicCurve2D left = new CubicCurve2D.Double();
|
||||
CubicCurve2D right = new CubicCurve2D.Double();
|
||||
curves[numCurves - 1].subdivide(left, right);
|
||||
curves[numCurves - 1] = right;
|
||||
curves[numCurves] = left;
|
||||
curves[numCurves - 1] = right;
|
||||
curves[numCurves] = left;
|
||||
numCurves++;
|
||||
}
|
||||
}
|
||||
|
||||
return new Segment[] { segmentTop, segmentBottom };
|
||||
}
|
||||
|
||||
|
||||
public void reverse()
|
||||
{
|
||||
Point2D temp = P1;
|
||||
@@ -116,12 +172,12 @@ public class CubicSegment extends Segment
|
||||
cp2 = temp;
|
||||
}
|
||||
|
||||
public double[] first()
|
||||
public double[] cp1()
|
||||
{
|
||||
return new double[]{cp1.getX(), cp1.getY()};
|
||||
}
|
||||
|
||||
public double[] last()
|
||||
public double[] cp2()
|
||||
{
|
||||
return new double[]{cp2.getX(), cp2.getY()};
|
||||
}
|
||||
|
||||
@@ -62,7 +62,22 @@ public class LineSegment extends Segment
|
||||
*/
|
||||
public Object clone()
|
||||
{
|
||||
return new LineSegment(P1, P2);
|
||||
LineSegment segment = null;
|
||||
|
||||
try
|
||||
{
|
||||
segment = (LineSegment) super.clone();
|
||||
segment.P1 = (Point2D) P1.clone();
|
||||
segment.P2 = (Point2D) P2.clone();
|
||||
}
|
||||
catch (CloneNotSupportedException cnse)
|
||||
{
|
||||
InternalError ie = new InternalError();
|
||||
ie.initCause(cnse);
|
||||
throw ie;
|
||||
}
|
||||
|
||||
return segment;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,12 +106,12 @@ public class LineSegment extends Segment
|
||||
P2 = p;
|
||||
}
|
||||
|
||||
public double[] first()
|
||||
public double[] cp1()
|
||||
{
|
||||
return new double[]{P2.getX(), P2.getY()};
|
||||
}
|
||||
|
||||
public double[] last()
|
||||
public double[] cp2()
|
||||
{
|
||||
return new double[]{P1.getX(), P1.getY()};
|
||||
}
|
||||
|
||||
@@ -88,8 +88,24 @@ public class QuadSegment extends Segment
|
||||
*/
|
||||
public Object clone()
|
||||
{
|
||||
return new QuadSegment(P1.getX(), P1.getY(), cp.getX(), cp.getY(),
|
||||
P2.getX(), P2.getY());
|
||||
QuadSegment segment = null;
|
||||
|
||||
try
|
||||
{
|
||||
segment = (QuadSegment) super.clone();
|
||||
|
||||
segment.P1 = (Point2D) P1.clone();
|
||||
segment.P2 = (Point2D) P2.clone();
|
||||
segment.cp = (Point2D) cp.clone();
|
||||
}
|
||||
catch (CloneNotSupportedException cnse)
|
||||
{
|
||||
InternalError ie = new InternalError();
|
||||
ie.initCause(cnse);
|
||||
throw ie;
|
||||
}
|
||||
|
||||
return segment;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,12 +217,12 @@ public class QuadSegment extends Segment
|
||||
P2 = p;
|
||||
}
|
||||
|
||||
public double[] first()
|
||||
public double[] cp1()
|
||||
{
|
||||
return new double[]{cp.getX(), cp.getY()};
|
||||
}
|
||||
|
||||
public double[] last()
|
||||
public double[] cp2()
|
||||
{
|
||||
return new double[]{cp.getX(), cp.getY()};
|
||||
}
|
||||
|
||||
@@ -42,24 +42,38 @@ import java.awt.geom.Point2D;
|
||||
|
||||
public abstract class Segment implements Cloneable
|
||||
{
|
||||
// segment type, PathIterator segment types are used.
|
||||
// Start and end points of THIS segment
|
||||
public Point2D P1;
|
||||
public Point2D P2;
|
||||
|
||||
// Segments can be linked together internally as a linked list
|
||||
public Segment first;
|
||||
public Segment next;
|
||||
public Segment last;
|
||||
|
||||
// Half the stroke width
|
||||
protected double radius;
|
||||
|
||||
/**
|
||||
* Create a new, empty segment
|
||||
*/
|
||||
public Segment()
|
||||
{
|
||||
P1 = P2 = null;
|
||||
first = this;
|
||||
next = null;
|
||||
last = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a segment to the polygon
|
||||
* @param newsegment segment to add
|
||||
*/
|
||||
public void add(Segment newsegment)
|
||||
{
|
||||
newsegment.first = first;
|
||||
last.next = newsegment;
|
||||
last = last.next;
|
||||
last = last.next.last;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,6 +82,7 @@ public abstract class Segment implements Cloneable
|
||||
public void reverseAll()
|
||||
{
|
||||
reverse();
|
||||
first = last;
|
||||
Segment v = next;
|
||||
Segment former = this;
|
||||
next = null;
|
||||
@@ -91,7 +106,7 @@ public abstract class Segment implements Cloneable
|
||||
|
||||
/**
|
||||
* Get the normal vector to the slope of the line.
|
||||
* Returns: 0.5*width*(norm of derivative of the (x0,y0)-(x1,y1) vector)
|
||||
* @return vector of length radius, normal to the (x0,y0)-(x1,y1) vector)
|
||||
*/
|
||||
protected double[] normal(double x0, double y0, double x1, double y1)
|
||||
{
|
||||
@@ -117,6 +132,9 @@ public abstract class Segment implements Cloneable
|
||||
return new double[]{ dx, dy };
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the current segment
|
||||
*/
|
||||
public abstract void reverse();
|
||||
|
||||
/**
|
||||
@@ -125,7 +143,16 @@ public abstract class Segment implements Cloneable
|
||||
*/
|
||||
public abstract Segment[] getDisplacedSegments(double radius);
|
||||
|
||||
public abstract double[] first();
|
||||
public abstract double[] last();
|
||||
/**
|
||||
* Returns the coordinates of the first control point, or the start point
|
||||
* for a line segment.
|
||||
*/
|
||||
public abstract double[] cp1();
|
||||
|
||||
/**
|
||||
* Returns the coordinates of the second control point, or the end point
|
||||
* for a line segment.
|
||||
*/
|
||||
public abstract double[] cp2();
|
||||
|
||||
}
|
||||
|
||||
@@ -145,7 +145,8 @@ public abstract class ClasspathFontPeer
|
||||
uname.equals ("SERIF") ||
|
||||
uname.equals ("MONOSPACED") ||
|
||||
uname.equals ("DIALOG") ||
|
||||
uname.equals ("DIALOGINPUT"));
|
||||
uname.equals ("DIALOGINPUT") ||
|
||||
uname.equals ("DEFAULT"));
|
||||
}
|
||||
|
||||
protected static String logicalFontNameToFaceName (String name)
|
||||
@@ -161,6 +162,8 @@ public abstract class ClasspathFontPeer
|
||||
return "Helvetica";
|
||||
else if (uname.equals ("DIALOGINPUT"))
|
||||
return "Helvetica";
|
||||
else if (uname.equals ("DEFAULT"))
|
||||
return "Dialog.plain";
|
||||
else
|
||||
return "Helvetica";
|
||||
}
|
||||
@@ -233,7 +236,7 @@ public abstract class ClasspathFontPeer
|
||||
family = (String) attribs.get (TextAttribute.FAMILY);
|
||||
|
||||
if (name == null)
|
||||
name = "SansSerif";
|
||||
name = "Default";
|
||||
|
||||
if (attribs.containsKey (TextAttribute.WEIGHT))
|
||||
{
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
/* ClasspathTextLayoutPeer.java
|
||||
Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.awt.peer;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Shape;
|
||||
import java.awt.font.TextHitInfo;
|
||||
import java.awt.font.TextLayout;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
/**
|
||||
* @author Graydon Hoare
|
||||
*/
|
||||
|
||||
public interface ClasspathTextLayoutPeer
|
||||
{
|
||||
TextHitInfo getStrongCaret (TextHitInfo hit1,
|
||||
TextHitInfo hit2);
|
||||
|
||||
void draw (Graphics2D g2, float x, float y);
|
||||
|
||||
byte getBaseline ();
|
||||
|
||||
boolean isLeftToRight ();
|
||||
boolean isVertical ();
|
||||
|
||||
float getAdvance ();
|
||||
float getAscent ();
|
||||
float getDescent ();
|
||||
float getLeading ();
|
||||
|
||||
int getCharacterCount ();
|
||||
byte getCharacterLevel (int index);
|
||||
|
||||
float[] getBaselineOffsets ();
|
||||
Shape getBlackBoxBounds (int firstEndpoint, int secondEndpoint);
|
||||
Rectangle2D getBounds ();
|
||||
|
||||
float[] getCaretInfo (TextHitInfo hit, Rectangle2D bounds);
|
||||
Shape getCaretShape (TextHitInfo hit, Rectangle2D bounds);
|
||||
Shape[] getCaretShapes (int offset, Rectangle2D bounds,
|
||||
TextLayout.CaretPolicy policy);
|
||||
|
||||
Shape getLogicalHighlightShape (int firstEndpoint, int secondEndpoint,
|
||||
Rectangle2D bounds);
|
||||
int[] getLogicalRangesForVisualSelection (TextHitInfo firstEndpoint,
|
||||
TextHitInfo secondEndpoint);
|
||||
|
||||
TextHitInfo getNextLeftHit (int offset, TextLayout.CaretPolicy policy);
|
||||
TextHitInfo getNextRightHit (int offset, TextLayout.CaretPolicy policy);
|
||||
TextHitInfo hitTestChar (float x, float y, Rectangle2D bounds);
|
||||
TextHitInfo getVisualOtherHit (TextHitInfo hit);
|
||||
|
||||
float getVisibleAdvance ();
|
||||
Shape getOutline (AffineTransform tx);
|
||||
Shape getVisualHighlightShape (TextHitInfo firstEndpoint,
|
||||
TextHitInfo secondEndpoint,
|
||||
Rectangle2D bounds);
|
||||
|
||||
TextLayout getJustifiedLayout (float justificationWidth);
|
||||
void handleJustify (float justificationWidth);
|
||||
|
||||
Object clone ();
|
||||
int hashCode ();
|
||||
boolean equals (ClasspathTextLayoutPeer tl);
|
||||
String toString ();
|
||||
}
|
||||
@@ -40,10 +40,8 @@ package gnu.java.awt.peer.gtk;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Shape;
|
||||
import java.awt.font.GlyphVector;
|
||||
|
||||
@@ -40,6 +40,7 @@ package gnu.java.awt.peer.gtk;
|
||||
|
||||
import gnu.java.awt.ClasspathToolkit;
|
||||
|
||||
import java.awt.AWTPermission;
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
@@ -52,11 +53,11 @@ import java.awt.Graphics2D;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.Image;
|
||||
import java.awt.Paint;
|
||||
import java.awt.Polygon;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.Shape;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.Polygon;
|
||||
import java.awt.TexturePaint;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.font.FontRenderContext;
|
||||
@@ -65,8 +66,8 @@ import java.awt.font.TextLayout;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Arc2D;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.GeneralPath;
|
||||
import java.awt.geom.Line2D;
|
||||
import java.awt.geom.NoninvertibleTransformException;
|
||||
import java.awt.geom.PathIterator;
|
||||
import java.awt.geom.Point2D;
|
||||
@@ -322,6 +323,11 @@ public abstract class CairoGraphics2D extends Graphics2D
|
||||
* Set the current transform matrix
|
||||
*/
|
||||
private native void cairoSetMatrix(long pointer, double[] m);
|
||||
|
||||
/**
|
||||
* Scaling method
|
||||
*/
|
||||
private native void cairoScale(long pointer, double x, double y);
|
||||
|
||||
/**
|
||||
* Set the compositing operator
|
||||
@@ -369,6 +375,18 @@ public abstract class CairoGraphics2D extends Graphics2D
|
||||
*/
|
||||
private native void cairoRectangle(long pointer, double x, double y,
|
||||
double width, double height);
|
||||
|
||||
/**
|
||||
* Appends an arc to the current path
|
||||
*/
|
||||
private native void cairoArc(long pointer, double x, double y,
|
||||
double radius, double angle1, double angle2);
|
||||
|
||||
/**
|
||||
* Save / restore a cairo path
|
||||
*/
|
||||
private native void cairoSave(long pointer);
|
||||
private native void cairoRestore(long pointer);
|
||||
|
||||
/**
|
||||
* New current path
|
||||
@@ -427,6 +445,46 @@ public abstract class CairoGraphics2D extends Graphics2D
|
||||
*/
|
||||
private native void cairoSurfaceSetFilter(long pointer, int filter);
|
||||
|
||||
/**
|
||||
* Draws a line from (x1,y1) to (x2,y2).
|
||||
*
|
||||
* @param pointer the native pointer
|
||||
*
|
||||
* @param x1 the x coordinate of the starting point
|
||||
* @param y1 the y coordinate of the starting point
|
||||
* @param x2 the x coordinate of the end point
|
||||
* @param y2 the y coordinate of the end point
|
||||
*/
|
||||
private native void cairoDrawLine(long pointer, double x1, double y1,
|
||||
double x2, double y2);
|
||||
|
||||
/**
|
||||
* Draws a rectangle at starting point (x,y) and with the specified width
|
||||
* and height.
|
||||
*
|
||||
* @param pointer the native pointer
|
||||
* @param x the x coordinate of the upper left corner
|
||||
* @param y the y coordinate of the upper left corner
|
||||
* @param w the width of the rectangle
|
||||
* @param h the height of the rectangle
|
||||
*/
|
||||
private native void cairoDrawRect(long pointer, double x, double y, double w,
|
||||
double h);
|
||||
|
||||
/**
|
||||
* Fills a rectangle at starting point (x,y) and with the specified width
|
||||
* and height.
|
||||
*
|
||||
* @param pointer the native pointer
|
||||
* @param x the x coordinate of the upper left corner
|
||||
* @param y the y coordinate of the upper left corner
|
||||
* @param w the width of the rectangle
|
||||
* @param h the height of the rectangle
|
||||
*/
|
||||
private native void cairoFillRect(long pointer, double x, double y, double w,
|
||||
double h);
|
||||
|
||||
|
||||
///////////////////////// TRANSFORMS ///////////////////////////////////
|
||||
/**
|
||||
* Set the current transform
|
||||
@@ -625,8 +683,8 @@ public abstract class CairoGraphics2D extends Graphics2D
|
||||
int width = (int) tp.getAnchorRect().getWidth();
|
||||
int height = (int) tp.getAnchorRect().getHeight();
|
||||
|
||||
double scaleX = (width+1) / (double) img.getWidth();
|
||||
double scaleY = (height+1) / (double) img.getHeight();
|
||||
double scaleX = width / (double) img.getWidth();
|
||||
double scaleY = height / (double) img.getHeight();
|
||||
|
||||
AffineTransform at = new AffineTransform(scaleX, 0, 0, scaleY, 0, 0);
|
||||
AffineTransformOp op = new AffineTransformOp(at, getRenderingHints());
|
||||
@@ -737,7 +795,7 @@ public abstract class CairoGraphics2D extends Graphics2D
|
||||
else
|
||||
{
|
||||
GeneralPath p = new GeneralPath();
|
||||
PathIterator pi = clip.getPathIterator(new AffineTransform());
|
||||
PathIterator pi = clip.getPathIterator(null);
|
||||
p.append(pi, false);
|
||||
return p;
|
||||
}
|
||||
@@ -847,6 +905,12 @@ public abstract class CairoGraphics2D extends Graphics2D
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME: this check is only required "if this Graphics2D
|
||||
// context is drawing to a Component on the display screen".
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null)
|
||||
sm.checkPermission(new AWTPermission("readDisplayPixels"));
|
||||
|
||||
// FIXME: implement general Composite support
|
||||
throw new java.lang.UnsupportedOperationException();
|
||||
}
|
||||
@@ -857,49 +921,21 @@ public abstract class CairoGraphics2D extends Graphics2D
|
||||
public void draw(Shape s)
|
||||
{
|
||||
if ((stroke != null && ! (stroke instanceof BasicStroke))
|
||||
|| (comp instanceof AlphaComposite
|
||||
&& ((AlphaComposite) comp).getAlpha() != 1.0))
|
||||
|| (comp instanceof AlphaComposite && ((AlphaComposite) comp).getAlpha() != 1.0))
|
||||
{
|
||||
// FIXME: This is a hack to work around BasicStrokes's current
|
||||
// limitations wrt cubic curves.
|
||||
// See CubicSegment.getDisplacedSegments().
|
||||
if (stroke instanceof BasicStroke)
|
||||
{
|
||||
PathIterator flatten = s.getPathIterator(new AffineTransform(),
|
||||
1.0);
|
||||
GeneralPath p = new GeneralPath();
|
||||
p.append(flatten, false);
|
||||
s = p;
|
||||
}
|
||||
fill(stroke.createStrokedShape(s));
|
||||
return;
|
||||
// Cairo doesn't support stroking with alpha, so we create the stroked
|
||||
// shape and fill with alpha instead
|
||||
fill(stroke.createStrokedShape(s));
|
||||
return;
|
||||
}
|
||||
|
||||
cairoNewPath(nativePointer);
|
||||
|
||||
if (s instanceof Rectangle2D)
|
||||
{
|
||||
Rectangle2D r = (Rectangle2D) s;
|
||||
cairoRectangle(nativePointer, shifted(r.getX(), shiftDrawCalls),
|
||||
shifted(r.getY(), shiftDrawCalls), r.getWidth(),
|
||||
r.getHeight());
|
||||
}
|
||||
else
|
||||
walkPath(s.getPathIterator(null), shiftDrawCalls);
|
||||
createPath(s);
|
||||
cairoStroke(nativePointer);
|
||||
}
|
||||
|
||||
public void fill(Shape s)
|
||||
{
|
||||
cairoNewPath(nativePointer);
|
||||
if (s instanceof Rectangle2D)
|
||||
{
|
||||
Rectangle2D r = (Rectangle2D) s;
|
||||
cairoRectangle(nativePointer, r.getX(), r.getY(), r.getWidth(),
|
||||
r.getHeight());
|
||||
}
|
||||
else
|
||||
walkPath(s.getPathIterator(null), false);
|
||||
createPath(s);
|
||||
|
||||
double alpha = 1.0;
|
||||
if (comp instanceof AlphaComposite)
|
||||
@@ -907,6 +943,59 @@ public abstract class CairoGraphics2D extends Graphics2D
|
||||
cairoFill(nativePointer, alpha);
|
||||
}
|
||||
|
||||
private void createPath(Shape s)
|
||||
{
|
||||
cairoNewPath(nativePointer);
|
||||
|
||||
// Optimize rectangles, since there is a direct Cairo function
|
||||
if (s instanceof Rectangle2D)
|
||||
{
|
||||
Rectangle2D r = (Rectangle2D) s;
|
||||
cairoRectangle(nativePointer, shifted(r.getX(), shiftDrawCalls),
|
||||
shifted(r.getY(), shiftDrawCalls), r.getWidth(),
|
||||
r.getHeight());
|
||||
}
|
||||
|
||||
// We can optimize ellipses too; however we don't bother optimizing arcs:
|
||||
// the iterator is fast enough (an ellipse requires 5 steps using the
|
||||
// iterator, while most arcs are only 2-3)
|
||||
else if (s instanceof Ellipse2D)
|
||||
{
|
||||
Ellipse2D e = (Ellipse2D) s;
|
||||
|
||||
double radius = Math.min(e.getHeight(), e.getWidth()) / 2;
|
||||
|
||||
// Cairo only draws circular shapes, but we can use a stretch to make
|
||||
// them into ellipses
|
||||
double xscale = 1, yscale = 1;
|
||||
if (e.getHeight() != e.getWidth())
|
||||
{
|
||||
cairoSave(nativePointer);
|
||||
|
||||
if (e.getHeight() < e.getWidth())
|
||||
xscale = e.getWidth() / (radius * 2);
|
||||
else
|
||||
yscale = e.getHeight() / (radius * 2);
|
||||
|
||||
if (xscale != 1 || yscale != 1)
|
||||
cairoScale(nativePointer, xscale, yscale);
|
||||
}
|
||||
|
||||
cairoArc(nativePointer,
|
||||
shifted(e.getCenterX() / xscale, shiftDrawCalls),
|
||||
shifted(e.getCenterY() / yscale, shiftDrawCalls), radius, 0,
|
||||
Math.PI * 2);
|
||||
|
||||
if (xscale != 1 || yscale != 1)
|
||||
cairoRestore(nativePointer);
|
||||
}
|
||||
|
||||
// All other shapes are broken down and drawn in steps using the
|
||||
// PathIterator
|
||||
else
|
||||
walkPath(s.getPathIterator(null), shiftDrawCalls);
|
||||
}
|
||||
|
||||
/**
|
||||
* Note that the rest of the drawing methods go via fill() or draw() for the drawing,
|
||||
* although subclasses may with to overload these methods where context-specific
|
||||
@@ -940,12 +1029,19 @@ public abstract class CairoGraphics2D extends Graphics2D
|
||||
|
||||
public void drawLine(int x1, int y1, int x2, int y2)
|
||||
{
|
||||
draw(new Line2D.Double(x1, y1, x2, y2));
|
||||
// The coordinates being pairwise identical means one wants
|
||||
// to draw a single pixel. This is emulated by drawing
|
||||
// a one pixel sized rectangle.
|
||||
if (x1 == x2 && y1 == y2)
|
||||
cairoFillRect(nativePointer, x1, y1, 1, 1);
|
||||
else
|
||||
cairoDrawLine(nativePointer, x1 + 0.5, y1 + 0.5, x2 + 0.5, y2 + 0.5);
|
||||
}
|
||||
|
||||
public void drawRect(int x, int y, int width, int height)
|
||||
{
|
||||
draw(new Rectangle(x, y, width, height));
|
||||
cairoDrawRect(nativePointer, shifted(x, shiftDrawCalls),
|
||||
shifted(y, shiftDrawCalls), width, height);
|
||||
}
|
||||
|
||||
public void fillArc(int x, int y, int width, int height, int startAngle,
|
||||
@@ -958,7 +1054,7 @@ public abstract class CairoGraphics2D extends Graphics2D
|
||||
|
||||
public void fillRect(int x, int y, int width, int height)
|
||||
{
|
||||
fill(new Rectangle(x, y, width, height));
|
||||
cairoFillRect(nativePointer, x, y, width, height);
|
||||
}
|
||||
|
||||
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
|
||||
@@ -1137,6 +1233,9 @@ public abstract class CairoGraphics2D extends Graphics2D
|
||||
if (img == null)
|
||||
return false;
|
||||
|
||||
if (xform == null)
|
||||
xform = new AffineTransform();
|
||||
|
||||
// In this case, xform is an AffineTransform that transforms bounding
|
||||
// box of the specified image from image space to user space. However
|
||||
// when we pass this transform to cairo, cairo will use this transform
|
||||
@@ -1160,6 +1259,7 @@ public abstract class CairoGraphics2D extends Graphics2D
|
||||
// Note - this can get us in trouble when the gdk lock is re-acquired.
|
||||
// for example by VolatileImage. See ComponentGraphics for how we work
|
||||
// around this.
|
||||
|
||||
if( !(img instanceof BufferedImage) )
|
||||
{
|
||||
ImageProducer source = img.getSource();
|
||||
@@ -1176,6 +1276,7 @@ public abstract class CairoGraphics2D extends Graphics2D
|
||||
|
||||
// If this BufferedImage has a BufferedImageGraphics object,
|
||||
// use the cached CairoSurface that BIG is drawing onto
|
||||
|
||||
if( BufferedImageGraphics.bufferedImages.get( b ) != null )
|
||||
db = (DataBuffer)BufferedImageGraphics.bufferedImages.get( b );
|
||||
else
|
||||
@@ -1190,6 +1291,7 @@ public abstract class CairoGraphics2D extends Graphics2D
|
||||
if(db instanceof CairoSurface)
|
||||
{
|
||||
((CairoSurface)db).drawSurface(nativePointer, i2u, alpha);
|
||||
updateColor();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1206,24 +1308,7 @@ public abstract class CairoGraphics2D extends Graphics2D
|
||||
setPaint( oldPaint );
|
||||
}
|
||||
|
||||
int[] pixels;
|
||||
|
||||
// Shortcut for easy color models.
|
||||
if( b.getColorModel().equals(rgb32) )
|
||||
{
|
||||
pixels = ((DataBufferInt)db).getData();
|
||||
for(int i = 0; i < pixels.length; i++)
|
||||
pixels[i] |= 0xFF000000;
|
||||
}
|
||||
else if( b.getColorModel().equals(argb32) )
|
||||
{
|
||||
pixels = ((DataBufferInt)db).getData();
|
||||
}
|
||||
else
|
||||
{
|
||||
pixels = b.getRGB(0, 0, width, height,
|
||||
null, 0, width);
|
||||
}
|
||||
int[] pixels = b.getRGB(0, 0, width, height, null, 0, width);
|
||||
|
||||
drawPixels(nativePointer, pixels, width, height, width, i2u, alpha);
|
||||
|
||||
@@ -1249,7 +1334,9 @@ public abstract class CairoGraphics2D extends Graphics2D
|
||||
|
||||
public void drawImage(BufferedImage image, BufferedImageOp op, int x, int y)
|
||||
{
|
||||
Image filtered = op.filter(image, null);
|
||||
Image filtered = image;
|
||||
if (op != null)
|
||||
filtered = op.filter(image, null);
|
||||
drawImage(filtered, new AffineTransform(1f, 0f, 0f, 1f, x, y), null, null);
|
||||
}
|
||||
|
||||
@@ -1317,7 +1404,7 @@ public abstract class CairoGraphics2D extends Graphics2D
|
||||
else
|
||||
{ cy = dy2; ch = dy1 - dy2; }
|
||||
|
||||
setClip( cx, cy, cw, ch );
|
||||
clipRect( cx, cy, cw, ch );
|
||||
|
||||
AffineTransform tx = new AffineTransform();
|
||||
tx.translate( dx1 - sx1*scaleX, dy1 - sy1*scaleY );
|
||||
@@ -1358,6 +1445,10 @@ public abstract class CairoGraphics2D extends Graphics2D
|
||||
public void drawGlyphVector(GlyphVector gv, float x, float y)
|
||||
{
|
||||
double alpha = 1.0;
|
||||
|
||||
if( gv.getNumGlyphs() <= 0 )
|
||||
return;
|
||||
|
||||
if (comp instanceof AlphaComposite)
|
||||
alpha = ((AlphaComposite) comp).getAlpha();
|
||||
if (gv instanceof FreetypeGlyphVector && alpha == 1.0)
|
||||
@@ -1367,8 +1458,11 @@ public abstract class CairoGraphics2D extends Graphics2D
|
||||
float[] positions = gv.getGlyphPositions (0, n, null);
|
||||
|
||||
setFont (gv.getFont ());
|
||||
cairoDrawGlyphVector(nativePointer, (GdkFontPeer)getFont().getPeer(),
|
||||
x, y, n, codes, positions);
|
||||
synchronized( this.font )
|
||||
{
|
||||
cairoDrawGlyphVector(nativePointer, (GdkFontPeer)getFont().getPeer(),
|
||||
x, y, n, codes, positions);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -38,26 +38,16 @@ exception statement from your version. */
|
||||
|
||||
package gnu.java.awt.peer.gtk;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Color;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.image.DataBuffer;
|
||||
import java.awt.image.Raster;
|
||||
import java.awt.image.WritableRaster;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.awt.image.DirectColorModel;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.net.URL;
|
||||
import gnu.classpath.Pointer;
|
||||
|
||||
/**
|
||||
* CairoSurface - wraps a Cairo surface.
|
||||
@@ -79,10 +69,10 @@ public class CairoSurface extends DataBuffer
|
||||
long bufferPointer;
|
||||
|
||||
|
||||
static ColorModel nativeModel = new DirectColorModel(32,
|
||||
0x000000FF,
|
||||
0x0000FF00,
|
||||
static ColorModel nativeModel = new DirectColorModel(32,
|
||||
0x00FF0000,
|
||||
0x0000FF00,
|
||||
0x000000FF,
|
||||
0xFF000000);
|
||||
|
||||
/**
|
||||
@@ -177,28 +167,45 @@ public class CairoSurface extends DataBuffer
|
||||
height = image.height;
|
||||
|
||||
create(width, height, width);
|
||||
|
||||
|
||||
if(surfacePointer == 0 || bufferPointer == 0)
|
||||
throw new Error("Could not allocate bitmap.");
|
||||
|
||||
|
||||
// Copy the pixel data from the GtkImage.
|
||||
int[] data = image.getPixels();
|
||||
|
||||
// Swap ordering from GdkPixbuf to Cairo
|
||||
for(int i = 0; i < data.length; i++ )
|
||||
if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN)
|
||||
{
|
||||
int alpha = (data[i] & 0xFF000000) >> 24;
|
||||
if( alpha == 0 ) // I do not know why we need this, but it works.
|
||||
data[i] = 0;
|
||||
else
|
||||
for (int i = 0; i < data.length; i++ )
|
||||
{
|
||||
int r = (((data[i] & 0x00FF0000) >> 16) );
|
||||
int g = (((data[i] & 0x0000FF00) >> 8) );
|
||||
int b = ((data[i] & 0x000000FF) );
|
||||
data[i] = (( alpha << 24 ) & 0xFF000000)
|
||||
| (( b << 16 ) & 0x00FF0000)
|
||||
| (( g << 8 ) & 0x0000FF00)
|
||||
| ( r & 0x000000FF);
|
||||
// On a big endian system we get a RRGGBBAA data array.
|
||||
int alpha = data[i] & 0xFF;
|
||||
if( alpha == 0 ) // I do not know why we need this, but it works.
|
||||
data[i] = 0;
|
||||
else
|
||||
{
|
||||
// Cairo needs a ARGB32 native array.
|
||||
data[i] = (data[i] >>> 8) | (alpha << 24);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < data.length; i++ )
|
||||
{
|
||||
// On a little endian system we get a AABBGGRR data array.
|
||||
int alpha = data[i] & 0xFF000000;
|
||||
if( alpha == 0 ) // I do not know why we need this, but it works.
|
||||
data[i] = 0;
|
||||
else
|
||||
{
|
||||
int b = (data[i] & 0xFF0000) >> 16;
|
||||
int g = (data[i] & 0xFF00);
|
||||
int r = (data[i] & 0xFF) << 16;
|
||||
// Cairo needs a ARGB32 native array.
|
||||
data[i] = alpha | r | g | b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,14 +39,9 @@ exception statement from your version. */
|
||||
package gnu.java.awt.peer.gtk;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Color;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.*;
|
||||
|
||||
/**
|
||||
* Implementation of Graphics2D on a Cairo surface.
|
||||
|
||||
@@ -39,7 +39,6 @@ exception statement from your version. */
|
||||
package gnu.java.awt.peer.gtk;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
@@ -47,16 +46,14 @@ import java.awt.Image;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Shape;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.Point;
|
||||
import java.awt.font.FontRenderContext;
|
||||
import java.awt.font.GlyphVector;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.awt.image.ImageProducer;
|
||||
import java.awt.image.ImagingOpException;
|
||||
import java.awt.image.RenderedImage;
|
||||
import gnu.classpath.Pointer;
|
||||
|
||||
/**
|
||||
* ComponentGraphics - context for drawing directly to a component,
|
||||
@@ -66,6 +63,8 @@ import java.awt.image.RenderedImage;
|
||||
*/
|
||||
public class ComponentGraphics extends CairoGraphics2D
|
||||
{
|
||||
private static final boolean hasXRenderExtension = hasXRender();
|
||||
|
||||
private GtkComponentPeer component;
|
||||
protected long cairo_t;
|
||||
|
||||
@@ -164,13 +163,27 @@ public class ComponentGraphics extends CairoGraphics2D
|
||||
*/
|
||||
public static native boolean hasXRender();
|
||||
|
||||
/**
|
||||
* This is a utility method (used by GtkComponentPeer) for grabbing the
|
||||
* image of a component.
|
||||
*/
|
||||
private static native Pointer nativeGrab(GtkComponentPeer component);
|
||||
|
||||
private native void copyAreaNative(GtkComponentPeer component, int x, int y,
|
||||
int width, int height, int dx, int dy);
|
||||
|
||||
private native void drawVolatile(GtkComponentPeer component,
|
||||
long vimg, int x, int y,
|
||||
int width, int height);
|
||||
int width, int height, int cx, int cy,
|
||||
int cw, int ch);
|
||||
|
||||
/**
|
||||
* Not really related (moveme?). Utility method used by GtkComponent.
|
||||
*/
|
||||
public static GtkImage grab( GtkComponentPeer component )
|
||||
{
|
||||
return new GtkImage( nativeGrab( component ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Graphics2D object for a component, either an instance of this
|
||||
@@ -178,7 +191,7 @@ public class ComponentGraphics extends CairoGraphics2D
|
||||
*/
|
||||
public static Graphics2D getComponentGraphics(GtkComponentPeer component)
|
||||
{
|
||||
if( hasXRender() )
|
||||
if( hasXRenderExtension )
|
||||
return new ComponentGraphics(component);
|
||||
|
||||
Rectangle r = component.awtComponent.getBounds();
|
||||
@@ -285,21 +298,24 @@ public class ComponentGraphics extends CairoGraphics2D
|
||||
if (img instanceof GtkVolatileImage)
|
||||
{
|
||||
GtkVolatileImage vimg = (GtkVolatileImage) img;
|
||||
int type = transform.getType();
|
||||
if (type == AffineTransform.TYPE_IDENTITY)
|
||||
{
|
||||
drawVolatile(component, vimg.nativePointer,
|
||||
x, y, vimg.width, vimg.height);
|
||||
return true;
|
||||
}
|
||||
else if (type == AffineTransform.TYPE_TRANSLATION)
|
||||
{
|
||||
x += transform.getTranslateX();
|
||||
y += transform.getTranslateY();
|
||||
drawVolatile(component, vimg.nativePointer,
|
||||
x, y, vimg.width, vimg.height);
|
||||
return true;
|
||||
}
|
||||
int type = transform.getType();
|
||||
if ((type == AffineTransform.TYPE_IDENTITY
|
||||
|| type == AffineTransform.TYPE_TRANSLATION)
|
||||
&& (clip == null || clip instanceof Rectangle2D))
|
||||
{
|
||||
Rectangle2D r = (Rectangle2D) clip;
|
||||
if (r == null)
|
||||
r = getRealBounds();
|
||||
x += transform.getTranslateX();
|
||||
y += transform.getTranslateY();
|
||||
drawVolatile(component, vimg.nativePointer,
|
||||
x, y, vimg.width, vimg.height,
|
||||
(int) (r.getX() + transform.getTranslateX()),
|
||||
(int) (r.getY() + transform.getTranslateY()),
|
||||
(int) r.getWidth(),
|
||||
(int) r.getHeight());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return super.drawImage(vimg.getSnapshot(), x, y, observer);
|
||||
}
|
||||
@@ -323,24 +339,28 @@ public class ComponentGraphics extends CairoGraphics2D
|
||||
// If it is a GtkVolatileImage with an "easy" transform then
|
||||
// draw directly. Always pass a BufferedImage to super to avoid
|
||||
// deadlock (see Note in CairoGraphics.drawImage()).
|
||||
if (img instanceof GtkVolatileImage)
|
||||
if (img instanceof GtkVolatileImage
|
||||
&& (clip == null || clip instanceof Rectangle2D))
|
||||
{
|
||||
GtkVolatileImage vimg = (GtkVolatileImage) img;
|
||||
int type = transform.getType();
|
||||
if (type == AffineTransform.TYPE_IDENTITY)
|
||||
{
|
||||
drawVolatile(component, vimg.nativePointer,
|
||||
x, y, width, height);
|
||||
return true;
|
||||
}
|
||||
else if (type == AffineTransform.TYPE_TRANSLATION)
|
||||
{
|
||||
x += transform.getTranslateX();
|
||||
y += transform.getTranslateY();
|
||||
drawVolatile(component, vimg.nativePointer,
|
||||
x, y, width, height);
|
||||
return true;
|
||||
}
|
||||
int type = transform.getType();
|
||||
if ((type == AffineTransform.TYPE_IDENTITY
|
||||
|| type == AffineTransform.TYPE_TRANSLATION)
|
||||
&& (clip == null || clip instanceof Rectangle2D))
|
||||
{
|
||||
Rectangle2D r = (Rectangle2D) clip;
|
||||
if (r == null)
|
||||
r = getRealBounds();
|
||||
x += transform.getTranslateX();
|
||||
y += transform.getTranslateY();
|
||||
drawVolatile(component, vimg.nativePointer,
|
||||
x, y, width, height,
|
||||
(int) (r.getX() + transform.getTranslateX()),
|
||||
(int) (r.getY() + transform.getTranslateY()),
|
||||
(int) r.getWidth(),
|
||||
(int) r.getHeight());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return super.drawImage(vimg.getSnapshot(), x, y,
|
||||
width, height, observer);
|
||||
@@ -359,5 +379,57 @@ public class ComponentGraphics extends CairoGraphics2D
|
||||
return super.drawImage(bimg, x, y, width, height, observer);
|
||||
}
|
||||
|
||||
public void drawLine(int x1, int y1, int x2, int y2)
|
||||
{
|
||||
lock();
|
||||
try
|
||||
{
|
||||
super.drawLine(x1, y1, x2, y2);
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void drawRect(int x, int y, int width, int height)
|
||||
{
|
||||
lock();
|
||||
try
|
||||
{
|
||||
super.drawRect(x, y, width, height);
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void fillRect(int x, int y, int width, int height)
|
||||
{
|
||||
lock();
|
||||
try
|
||||
{
|
||||
super.fillRect(x, y, width, height);
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void setClip(Shape s)
|
||||
{
|
||||
lock();
|
||||
try
|
||||
{
|
||||
super.setClip(s);
|
||||
}
|
||||
finally
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -39,17 +39,11 @@ exception statement from your version. */
|
||||
package gnu.java.awt.peer.gtk;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Shape;
|
||||
import java.awt.font.GlyphVector;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBuffer;
|
||||
import java.awt.image.RenderedImage;
|
||||
import java.awt.image.ImageObserver;
|
||||
|
||||
|
||||
@@ -136,6 +136,35 @@ public class FreetypeGlyphVector extends GlyphVector
|
||||
performDefaultLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Cloning constructor
|
||||
*/
|
||||
private FreetypeGlyphVector( FreetypeGlyphVector gv )
|
||||
{
|
||||
font = gv.font;
|
||||
peer = gv.peer;
|
||||
frc = gv.frc;
|
||||
s = gv.s;
|
||||
nGlyphs = gv.nGlyphs;
|
||||
logicalBounds = gv.logicalBounds.getBounds2D();
|
||||
|
||||
if( gv.metricsCache != null )
|
||||
{
|
||||
metricsCache = new GlyphMetrics[ nGlyphs ];
|
||||
System.arraycopy(gv.metricsCache, 0, metricsCache, 0, nGlyphs);
|
||||
}
|
||||
|
||||
glyphCodes = new int[ nGlyphs ];
|
||||
glyphPositions = new float[ nGlyphs ];
|
||||
glyphTransforms = new AffineTransform[ nGlyphs ];
|
||||
for(int i = 0; i < nGlyphs; i++ )
|
||||
{
|
||||
glyphTransforms[ i ] = new AffineTransform( gv.glyphTransforms[ i ] );
|
||||
glyphCodes[i] = gv.glyphCodes[ i ];
|
||||
glyphPositions[i] = gv.glyphPositions[ i ];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the array of glyph codes.
|
||||
*/
|
||||
@@ -172,6 +201,12 @@ public class FreetypeGlyphVector extends GlyphVector
|
||||
|
||||
private native GeneralPath getGlyphOutlineNative(int glyphIndex);
|
||||
|
||||
|
||||
public Object clone()
|
||||
{
|
||||
return new FreetypeGlyphVector( this );
|
||||
}
|
||||
|
||||
/**
|
||||
* Duh, compares two instances.
|
||||
*/
|
||||
@@ -260,8 +295,11 @@ public class FreetypeGlyphVector extends GlyphVector
|
||||
if( gm == null )
|
||||
return null;
|
||||
Rectangle2D r = gm.getBounds2D();
|
||||
return new Rectangle2D.Double( r.getX() - gm.getLSB(), r.getY(),
|
||||
gm.getAdvanceX(), r.getHeight() );
|
||||
Point2D p = getGlyphPosition( glyphIndex );
|
||||
return new Rectangle2D.Double( p.getX() + r.getX() - gm.getLSB(),
|
||||
p.getY() + r.getY(),
|
||||
gm.getAdvanceX(),
|
||||
r.getHeight() );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -385,8 +423,6 @@ public class FreetypeGlyphVector extends GlyphVector
|
||||
for( int i = 1; i < nGlyphs; i++ )
|
||||
{
|
||||
Rectangle2D r2 = (Rectangle2D)getGlyphLogicalBounds( i );
|
||||
Point2D p = getGlyphPosition( i );
|
||||
r2.setRect( p.getX(), p.getY(), r2.getWidth(), r2.getHeight() );
|
||||
rect = rect.createUnion( r2 );
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ exception statement from your version. */
|
||||
|
||||
package gnu.java.awt.peer.gtk;
|
||||
|
||||
import gnu.classpath.Configuration;
|
||||
import gnu.java.awt.peer.ClasspathFontPeer;
|
||||
import gnu.java.awt.font.opentype.NameDecoder;
|
||||
|
||||
@@ -50,9 +49,7 @@ import java.awt.font.GlyphVector;
|
||||
import java.awt.font.GlyphMetrics;
|
||||
import java.awt.font.LineMetrics;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.text.CharacterIterator;
|
||||
import java.text.StringCharacterIterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
@@ -134,5 +134,9 @@ public class GdkGraphicsEnvironment extends GraphicsEnvironment
|
||||
{
|
||||
throw new java.lang.UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used by GtkMouseInfoPeer.
|
||||
*/
|
||||
native int[] getMouseCoordinates();
|
||||
}
|
||||
|
||||
@@ -38,13 +38,10 @@ exception statement from your version. */
|
||||
|
||||
package gnu.java.awt.peer.gtk;
|
||||
|
||||
import gnu.classpath.Configuration;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.awt.image.DirectColorModel;
|
||||
import java.awt.image.ImageConsumer;
|
||||
import java.awt.image.ImageProducer;
|
||||
import java.awt.image.Raster;
|
||||
import java.awt.image.RenderedImage;
|
||||
import java.io.DataInput;
|
||||
|
||||
@@ -1,393 +0,0 @@
|
||||
/* GdkTextLayout.java
|
||||
Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.awt.peer.gtk;
|
||||
|
||||
import gnu.classpath.Configuration;
|
||||
import gnu.java.awt.peer.ClasspathTextLayoutPeer;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Shape;
|
||||
import java.awt.font.FontRenderContext;
|
||||
import java.awt.font.GlyphMetrics;
|
||||
import java.awt.font.GlyphVector;
|
||||
import java.awt.font.TextAttribute;
|
||||
import java.awt.font.TextHitInfo;
|
||||
import java.awt.font.TextLayout;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.GeneralPath;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.text.AttributedCharacterIterator;
|
||||
import java.text.AttributedString;
|
||||
import java.text.CharacterIterator;
|
||||
|
||||
/**
|
||||
* This is an implementation of the text layout peer interface which
|
||||
* delegates all the hard work to pango.
|
||||
*
|
||||
* @author Graydon Hoare
|
||||
*/
|
||||
|
||||
public class GdkTextLayout
|
||||
implements ClasspathTextLayoutPeer
|
||||
{
|
||||
// native side, plumbing, etc.
|
||||
static
|
||||
{
|
||||
System.loadLibrary("gtkpeer");
|
||||
|
||||
initStaticState ();
|
||||
}
|
||||
private native void setText(String str);
|
||||
private native void setFont(GdkFontPeer font);
|
||||
private native void getExtents(double[] inkExtents,
|
||||
double[] logExtents);
|
||||
private native void indexToPos(int idx, double[] pos);
|
||||
|
||||
private native void initState ();
|
||||
|
||||
private native void dispose ();
|
||||
|
||||
private native void cairoDrawGdkTextLayout(long cg2d, float x, float y);
|
||||
|
||||
static native void initStaticState();
|
||||
|
||||
private final int native_state = GtkGenericPeer.getUniqueInteger ();
|
||||
|
||||
protected void finalize ()
|
||||
{
|
||||
dispose ();
|
||||
}
|
||||
|
||||
// we hold on to these to make sure we can render when presented
|
||||
// with non-GdkGraphics2D paint targets
|
||||
private AttributedString attributedString;
|
||||
private FontRenderContext fontRenderContext;
|
||||
|
||||
public GdkTextLayout(AttributedString str, FontRenderContext frc)
|
||||
{
|
||||
initState();
|
||||
attributedString = str;
|
||||
fontRenderContext = frc;
|
||||
AttributedCharacterIterator aci = str.getIterator();
|
||||
char[] chars = new char[aci.getEndIndex() - aci.getBeginIndex()];
|
||||
for(int i = aci.getBeginIndex(); i < aci.getEndIndex(); i++)
|
||||
chars[i] = aci.setIndex(i);
|
||||
setText(new String(chars));
|
||||
|
||||
Object fnt = aci.getAttribute(TextAttribute.FONT);
|
||||
if (fnt != null && fnt instanceof Font)
|
||||
setFont( (GdkFontPeer) ((Font)fnt).getPeer() );
|
||||
}
|
||||
|
||||
protected class CharacterIteratorProxy
|
||||
implements CharacterIterator
|
||||
{
|
||||
public CharacterIterator target;
|
||||
public int begin;
|
||||
public int limit;
|
||||
public int index;
|
||||
|
||||
public CharacterIteratorProxy (CharacterIterator ci)
|
||||
{
|
||||
target = ci;
|
||||
}
|
||||
|
||||
public int getBeginIndex ()
|
||||
{
|
||||
return begin;
|
||||
}
|
||||
|
||||
public int getEndIndex ()
|
||||
{
|
||||
return limit;
|
||||
}
|
||||
|
||||
public int getIndex ()
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
public char setIndex (int idx)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
if (idx < begin || idx >= limit)
|
||||
throw new IllegalArgumentException ();
|
||||
char ch = target.setIndex (idx);
|
||||
index = idx;
|
||||
return ch;
|
||||
}
|
||||
|
||||
public char first ()
|
||||
{
|
||||
int save = target.getIndex ();
|
||||
char ch = target.setIndex (begin);
|
||||
target.setIndex (save);
|
||||
return ch;
|
||||
}
|
||||
|
||||
public char last ()
|
||||
{
|
||||
if (begin == limit)
|
||||
return this.first ();
|
||||
|
||||
int save = target.getIndex ();
|
||||
char ch = target.setIndex (limit - 1);
|
||||
target.setIndex (save);
|
||||
return ch;
|
||||
}
|
||||
|
||||
public char current ()
|
||||
{
|
||||
return target.current();
|
||||
}
|
||||
|
||||
public char next ()
|
||||
{
|
||||
if (index >= limit - 1)
|
||||
return CharacterIterator.DONE;
|
||||
else
|
||||
{
|
||||
index++;
|
||||
return target.next();
|
||||
}
|
||||
}
|
||||
|
||||
public char previous ()
|
||||
{
|
||||
if (index <= begin)
|
||||
return CharacterIterator.DONE;
|
||||
else
|
||||
{
|
||||
index--;
|
||||
return target.previous ();
|
||||
}
|
||||
}
|
||||
|
||||
public Object clone ()
|
||||
{
|
||||
CharacterIteratorProxy cip = new CharacterIteratorProxy (this.target);
|
||||
cip.begin = this.begin;
|
||||
cip.limit = this.limit;
|
||||
cip.index = this.index;
|
||||
return cip;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// public side
|
||||
|
||||
public void draw (Graphics2D g2, float x, float y)
|
||||
{
|
||||
cairoDrawGdkTextLayout(((CairoGraphics2D) g2).nativePointer, x, y);
|
||||
}
|
||||
|
||||
public TextHitInfo getStrongCaret (TextHitInfo hit1,
|
||||
TextHitInfo hit2)
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
public byte getBaseline ()
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
public boolean isLeftToRight ()
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
public boolean isVertical ()
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
public float getAdvance ()
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
public float getAscent ()
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
public float getDescent ()
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
public float getLeading ()
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
public int getCharacterCount ()
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
public byte getCharacterLevel (int index)
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
public float[] getBaselineOffsets ()
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
public Shape getBlackBoxBounds (int firstEndpoint, int secondEndpoint)
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
public Rectangle2D getBounds ()
|
||||
{
|
||||
double[] inkExtents = new double[4];
|
||||
double[] logExtents = new double[4];
|
||||
getExtents(inkExtents, logExtents);
|
||||
return new Rectangle2D.Double(logExtents[0], logExtents[1],
|
||||
logExtents[2], logExtents[3]);
|
||||
}
|
||||
|
||||
public float[] getCaretInfo (TextHitInfo hit, Rectangle2D bounds)
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
public Shape getCaretShape (TextHitInfo hit, Rectangle2D bounds)
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
public Shape[] getCaretShapes (int offset, Rectangle2D bounds,
|
||||
TextLayout.CaretPolicy policy)
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
public Shape getLogicalHighlightShape (int firstEndpoint, int secondEndpoint,
|
||||
Rectangle2D bounds)
|
||||
{
|
||||
AffineTransform at = new AffineTransform();
|
||||
GeneralPath gp = new GeneralPath();
|
||||
double [] rect = new double[4];
|
||||
Rectangle2D tmp = new Rectangle2D.Double();
|
||||
for (int i = firstEndpoint; i <= secondEndpoint; ++i)
|
||||
{
|
||||
indexToPos(i, rect);
|
||||
tmp.setRect(rect[0], rect[1], rect[2], rect[3]);
|
||||
Rectangle2D.intersect(tmp, bounds, tmp);
|
||||
gp.append(tmp.getPathIterator(at), false);
|
||||
}
|
||||
return gp;
|
||||
}
|
||||
|
||||
public int[] getLogicalRangesForVisualSelection (TextHitInfo firstEndpoint,
|
||||
TextHitInfo secondEndpoint)
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
public TextHitInfo getNextLeftHit (int offset, TextLayout.CaretPolicy policy)
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
public TextHitInfo getNextRightHit (int offset, TextLayout.CaretPolicy policy)
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
public TextHitInfo hitTestChar (float x, float y, Rectangle2D bounds)
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
public TextHitInfo getVisualOtherHit (TextHitInfo hit)
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
public float getVisibleAdvance ()
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
public native Shape getOutline (AffineTransform tx);
|
||||
|
||||
public Shape getVisualHighlightShape (TextHitInfo firstEndpoint,
|
||||
TextHitInfo secondEndpoint,
|
||||
Rectangle2D bounds)
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
|
||||
public TextLayout getJustifiedLayout (float justificationWidth)
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
public void handleJustify (float justificationWidth)
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
public Object clone ()
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
public int hashCode ()
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
public boolean equals (ClasspathTextLayoutPeer tl)
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
public String toString ()
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -38,13 +38,8 @@ exception statement from your version. */
|
||||
|
||||
package gnu.java.awt.peer.gtk;
|
||||
|
||||
import java.awt.AWTEvent;
|
||||
import java.awt.Button;
|
||||
import java.awt.Component;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.peer.ButtonPeer;
|
||||
|
||||
// A composite widget. GtkButtons have transparent backgrounds. An
|
||||
|
||||
@@ -53,8 +53,8 @@ public class GtkCanvasPeer extends GtkComponentPeer implements CanvasPeer
|
||||
|
||||
// Preferred size for a drawing widget is always what the user
|
||||
// requested.
|
||||
public Dimension getPreferredSize ()
|
||||
public Dimension preferredSize()
|
||||
{
|
||||
return awtComponent.getSize ();
|
||||
return awtComponent.getSize();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,20 +40,32 @@ package gnu.java.awt.peer.gtk;
|
||||
|
||||
import java.awt.Checkbox;
|
||||
import java.awt.CheckboxGroup;
|
||||
import java.awt.peer.CheckboxPeer;
|
||||
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.peer.CheckboxPeer;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
/**
|
||||
* This class wraps either a GtkCheckButton or a GtkOptionButton
|
||||
* depending on if this peer's owner belongs to a CheckboxGroup.
|
||||
*/
|
||||
public class GtkCheckboxPeer extends GtkComponentPeer
|
||||
implements CheckboxPeer
|
||||
{
|
||||
// Group from last time it was set.
|
||||
public GtkCheckboxGroupPeer old_group;
|
||||
// The CheckboxGroup to which this GtkCheckboxPeer's owner belongs.
|
||||
public CheckboxGroup current_group;
|
||||
// The current state of the GTK checkbox.
|
||||
private boolean currentState;
|
||||
private boolean currentState;
|
||||
|
||||
public native void create (GtkCheckboxGroupPeer group);
|
||||
public native void nativeSetCheckboxGroup (GtkCheckboxGroupPeer group);
|
||||
// A map from CheckboxGroup to GSList* GTK option group pointer.
|
||||
private static WeakHashMap groupMap = new WeakHashMap();
|
||||
|
||||
public native void createCheckButton ();
|
||||
public native void createRadioButton (long groupPointer);
|
||||
|
||||
public native void addToGroup (long groupPointer);
|
||||
public native void removeFromGroup ();
|
||||
public native void switchToGroup (long groupPointer);
|
||||
|
||||
public native void connectSignals ();
|
||||
|
||||
/**
|
||||
@@ -68,17 +80,47 @@ public class GtkCheckboxPeer extends GtkComponentPeer
|
||||
super (c);
|
||||
}
|
||||
|
||||
// FIXME: we must be able to switch between a checkbutton and a
|
||||
// radiobutton dynamically.
|
||||
public void create ()
|
||||
{
|
||||
Checkbox checkbox = (Checkbox) awtComponent;
|
||||
CheckboxGroup g = checkbox.getCheckboxGroup ();
|
||||
old_group = GtkCheckboxGroupPeer.getCheckboxGroupPeer (g);
|
||||
create (old_group);
|
||||
current_group = checkbox.getCheckboxGroup ();
|
||||
if (current_group == null)
|
||||
{
|
||||
// Initially we're not part of a group so we're backed by a
|
||||
// GtkCheckButton.
|
||||
createCheckButton();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Initially we're part of a group.
|
||||
|
||||
// See if this group is already stored in our map.
|
||||
Long groupPointer = null;
|
||||
synchronized (groupMap)
|
||||
{
|
||||
groupPointer = (Long) groupMap.get(current_group);
|
||||
}
|
||||
|
||||
if (groupPointer == null)
|
||||
{
|
||||
// We don't know about this group. Create a new native
|
||||
// group pointer for this group and store it in our map.
|
||||
createRadioButton(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We already know about this group. Pass the
|
||||
// corresponding native group pointer value to the native
|
||||
// create method.
|
||||
createRadioButton(groupPointer.longValue());
|
||||
}
|
||||
}
|
||||
currentState = checkbox.getState();
|
||||
gtkToggleButtonSetActive(currentState);
|
||||
gtkButtonSetLabel (checkbox.getLabel ());
|
||||
|
||||
String label = checkbox.getLabel();
|
||||
if (label != null)
|
||||
gtkButtonSetLabel(label);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,7 +129,7 @@ public class GtkCheckboxPeer extends GtkComponentPeer
|
||||
* event since events should only be posted for user initiated
|
||||
* clicks on the GtkCheckButton.
|
||||
*/
|
||||
synchronized public void setState (boolean state)
|
||||
public synchronized void setState (boolean state)
|
||||
{
|
||||
if (currentState != state)
|
||||
{
|
||||
@@ -103,21 +145,87 @@ public class GtkCheckboxPeer extends GtkComponentPeer
|
||||
|
||||
public void setCheckboxGroup (CheckboxGroup group)
|
||||
{
|
||||
GtkCheckboxGroupPeer gp
|
||||
= GtkCheckboxGroupPeer.getCheckboxGroupPeer (group);
|
||||
if (gp != old_group)
|
||||
if (current_group == null && group != null)
|
||||
{
|
||||
if (old_group != null)
|
||||
old_group.remove (this);
|
||||
nativeSetCheckboxGroup (gp);
|
||||
old_group = gp;
|
||||
// This peer's owner is currently not in a group, and now
|
||||
// we're adding it to a group. This means that the backing
|
||||
// GtkWidget will change from a GtkCheckButton to a
|
||||
// GtkRadioButton.
|
||||
|
||||
current_group = group;
|
||||
|
||||
// See if the new group is already stored in our map.
|
||||
Long groupPointer = null;
|
||||
synchronized (groupMap)
|
||||
{
|
||||
groupPointer = (Long) groupMap.get(current_group);
|
||||
}
|
||||
|
||||
if (groupPointer == null)
|
||||
{
|
||||
// We don't know about this group. Create a new native
|
||||
// group pointer for this group and store it in our map.
|
||||
addToGroup(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We already know about this group. Pass the
|
||||
// corresponding native group pointer value to the native
|
||||
// create method.
|
||||
addToGroup(groupPointer.longValue());
|
||||
}
|
||||
}
|
||||
else if (current_group != null && group == null)
|
||||
{
|
||||
// This peer's owner is currently in a group, and now we're
|
||||
// removing it from a group. This means that the backing
|
||||
// GtkWidget will change from a GtkRadioButton to a
|
||||
// GtkCheckButton.
|
||||
removeFromGroup();
|
||||
current_group = null;
|
||||
}
|
||||
else if (current_group == null && group == null)
|
||||
{
|
||||
// This peer's owner is currently not in a group, and we're
|
||||
// not adding it to a group, so simply return.
|
||||
return;
|
||||
}
|
||||
else if (current_group != group)
|
||||
{
|
||||
// This peer's owner is currently in a group, and now we're
|
||||
// putting it in another group. This means that we must
|
||||
// remove the backing GtkRadioButton from one group and add it
|
||||
// to the other group.
|
||||
|
||||
current_group = group;
|
||||
|
||||
// See if the new group is already stored in our map.
|
||||
Long groupPointer = null;
|
||||
synchronized (groupMap)
|
||||
{
|
||||
groupPointer = (Long) groupMap.get(current_group);
|
||||
}
|
||||
|
||||
if (groupPointer == null)
|
||||
{
|
||||
// We don't know about this group. Create a new native
|
||||
// group pointer for this group and store it in our map.
|
||||
switchToGroup(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We already know about this group. Pass the
|
||||
// corresponding native group pointer value to the native
|
||||
// create method.
|
||||
switchToGroup(groupPointer.longValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Override the superclass postItemEvent so that the peer doesn't
|
||||
// need information that we have.
|
||||
// called back by native side: item_toggled_cb
|
||||
synchronized public void postItemEvent(Object item, boolean state)
|
||||
public synchronized void postItemEvent(Object item, boolean state)
|
||||
{
|
||||
// Only fire event is state actually changed.
|
||||
if (currentState != state)
|
||||
@@ -127,13 +235,20 @@ public class GtkCheckboxPeer extends GtkComponentPeer
|
||||
state ? ItemEvent.SELECTED : ItemEvent.DESELECTED);
|
||||
}
|
||||
}
|
||||
|
||||
public void addToGroupMap(long groupPointer)
|
||||
{
|
||||
synchronized (groupMap)
|
||||
{
|
||||
groupMap.put(current_group, new Long (groupPointer));
|
||||
}
|
||||
}
|
||||
|
||||
public void dispose ()
|
||||
{
|
||||
// Notify the group so that the native state can be cleaned up
|
||||
// appropriately.
|
||||
if (old_group != null)
|
||||
old_group.remove (this);
|
||||
groupMap.clear();
|
||||
current_group = null;
|
||||
currentState = false;
|
||||
super.dispose ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* GtkClipboardNotifier.java -- Helper for announcing GtkSelection changes.
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -38,8 +38,6 @@ exception statement from your version. */
|
||||
|
||||
package gnu.java.awt.peer.gtk;
|
||||
|
||||
import java.awt.datatransfer.*;
|
||||
import java.util.*;
|
||||
|
||||
class GtkClipboardNotifier extends Thread
|
||||
{
|
||||
|
||||
@@ -52,9 +52,12 @@ import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Image;
|
||||
import java.awt.Insets;
|
||||
import java.awt.ItemSelectable;
|
||||
import java.awt.KeyboardFocusManager;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Toolkit;
|
||||
@@ -66,13 +69,13 @@ import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.event.PaintEvent;
|
||||
import java.awt.event.TextEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.awt.image.ImageProducer;
|
||||
import java.awt.image.VolatileImage;
|
||||
import java.awt.peer.ComponentPeer;
|
||||
import java.awt.peer.ContainerPeer;
|
||||
import java.awt.peer.LightweightPeer;
|
||||
import java.awt.peer.WindowPeer;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
@@ -109,6 +112,9 @@ public class GtkComponentPeer extends GtkGenericPeer
|
||||
native void gtkWidgetRequestFocus ();
|
||||
native void gtkWidgetDispatchKeyEvent (int id, long when, int mods,
|
||||
int keyCode, int keyLocation);
|
||||
native boolean gtkWidgetHasFocus();
|
||||
native boolean gtkWidgetCanFocus();
|
||||
|
||||
native void realize();
|
||||
native void setNativeEventMask ();
|
||||
|
||||
@@ -365,7 +371,7 @@ public class GtkComponentPeer extends GtkGenericPeer
|
||||
|
||||
public void print (Graphics g)
|
||||
{
|
||||
throw new RuntimeException ();
|
||||
g.drawImage( ComponentGraphics.grab( this ), 0, 0, null );
|
||||
}
|
||||
|
||||
public void repaint (long tm, int x, int y, int width, int height)
|
||||
@@ -414,8 +420,7 @@ public class GtkComponentPeer extends GtkGenericPeer
|
||||
|
||||
public void requestFocus ()
|
||||
{
|
||||
gtkWidgetRequestFocus();
|
||||
postFocusEvent(FocusEvent.FOCUS_GAINED, false);
|
||||
assert false: "Call new requestFocus() method instead";
|
||||
}
|
||||
|
||||
public void reshape (int x, int y, int width, int height)
|
||||
@@ -628,6 +633,12 @@ public class GtkComponentPeer extends GtkGenericPeer
|
||||
q.postEvent(keyEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Referenced from native code.
|
||||
*
|
||||
* @param id
|
||||
* @param temporary
|
||||
*/
|
||||
protected void postFocusEvent (int id, boolean temporary)
|
||||
{
|
||||
q().postEvent (new FocusEvent (awtComponent, id, temporary));
|
||||
@@ -647,8 +658,10 @@ public class GtkComponentPeer extends GtkGenericPeer
|
||||
|
||||
public GraphicsConfiguration getGraphicsConfiguration ()
|
||||
{
|
||||
// FIXME: just a stub for now.
|
||||
return null;
|
||||
// FIXME: The component might be showing on a non-default screen.
|
||||
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
GraphicsDevice dev = env.getDefaultScreenDevice();
|
||||
return dev.getDefaultConfiguration();
|
||||
}
|
||||
|
||||
public void setEventMask (long mask)
|
||||
@@ -661,10 +674,72 @@ public class GtkComponentPeer extends GtkGenericPeer
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean requestFocus (Component source, boolean b1,
|
||||
boolean b2, long x)
|
||||
public boolean requestFocus (Component request, boolean temporary,
|
||||
boolean allowWindowFocus, long time)
|
||||
{
|
||||
return false;
|
||||
assert request == awtComponent || isLightweightDescendant(request);
|
||||
boolean retval = false;
|
||||
if (gtkWidgetHasFocus())
|
||||
{
|
||||
KeyboardFocusManager kfm =
|
||||
KeyboardFocusManager.getCurrentKeyboardFocusManager();
|
||||
Component currentFocus = kfm.getFocusOwner();
|
||||
if (currentFocus == request)
|
||||
// Nothing to do in this trivial case.
|
||||
retval = true;
|
||||
else
|
||||
{
|
||||
// Requested component is a lightweight descendant of this one
|
||||
// or the actual heavyweight.
|
||||
// Since this (native) component is already focused, we simply
|
||||
// change the actual focus and be done.
|
||||
postFocusEvent(FocusEvent.FOCUS_GAINED, temporary);
|
||||
retval = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gtkWidgetCanFocus())
|
||||
{
|
||||
if (allowWindowFocus)
|
||||
{
|
||||
Window window = getWindowFor(request);
|
||||
GtkWindowPeer wPeer = (GtkWindowPeer) window.getPeer();
|
||||
if (! wPeer.gtkWindowHasFocus())
|
||||
wPeer.requestWindowFocus();
|
||||
}
|
||||
// Store requested focus component so that the corresponding
|
||||
// event is dispatched correctly.
|
||||
gtkWidgetRequestFocus();
|
||||
retval = true;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
private Window getWindowFor(Component c)
|
||||
{
|
||||
Component comp = c;
|
||||
while (! (comp instanceof Window))
|
||||
comp = comp.getParent();
|
||||
return (Window) comp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if the component is a direct (== no intermediate
|
||||
* heavyweights) lightweight descendant of this peer's component.
|
||||
*
|
||||
* @param c the component to check
|
||||
*
|
||||
* @return <code>true</code> if the component is a direct (== no intermediate
|
||||
* heavyweights) lightweight descendant of this peer's component
|
||||
*/
|
||||
protected boolean isLightweightDescendant(Component c)
|
||||
{
|
||||
Component comp = c;
|
||||
while (comp.getPeer() instanceof LightweightPeer)
|
||||
comp = comp.getParent();
|
||||
return comp == awtComponent;
|
||||
}
|
||||
|
||||
public boolean isObscured ()
|
||||
|
||||
@@ -42,10 +42,7 @@ import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Window;
|
||||
import java.awt.peer.ComponentPeer;
|
||||
import java.awt.peer.ContainerPeer;
|
||||
|
||||
public class GtkContainerPeer extends GtkComponentPeer
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* GtkDialogPeer.java -- Implements DialogPeer with GTK
|
||||
Copyright (C) 1998, 1999, 2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999, 2002, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -39,9 +39,6 @@ exception statement from your version. */
|
||||
package gnu.java.awt.peer.gtk;
|
||||
|
||||
import java.awt.Dialog;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.PaintEvent;
|
||||
import java.awt.peer.DialogPeer;
|
||||
|
||||
public class GtkDialogPeer extends GtkWindowPeer
|
||||
|
||||
@@ -39,11 +39,9 @@ exception statement from your version. */
|
||||
package gnu.java.awt.peer.gtk;
|
||||
|
||||
import java.awt.Frame;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Image;
|
||||
import java.awt.MenuBar;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.PaintEvent;
|
||||
import java.awt.peer.FramePeer;
|
||||
import java.awt.peer.MenuBarPeer;
|
||||
|
||||
@@ -218,11 +216,7 @@ public class GtkFramePeer extends GtkWindowPeer
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
public void updateAlwaysOnTop()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public boolean requestWindowFocus()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
@@ -39,12 +39,10 @@ exception statement from your version. */
|
||||
package gnu.java.awt.peer.gtk;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Color;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.awt.image.DirectColorModel;
|
||||
import java.awt.image.MemoryImageSource;
|
||||
import java.awt.image.ImageConsumer;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.awt.image.ImageProducer;
|
||||
import java.io.File;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* GtkImageConsumer.java
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -38,16 +38,11 @@ exception statement from your version. */
|
||||
|
||||
package gnu.java.awt.peer.gtk;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.awt.image.DirectColorModel;
|
||||
import java.awt.image.ImageConsumer;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.awt.image.ImageProducer;
|
||||
import java.awt.image.MemoryImageSource;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* Helper class to GtkImage. Sits and gathers pixels for a GtkImage and then
|
||||
|
||||
@@ -56,7 +56,7 @@ public class GtkLabelPeer extends GtkComponentPeer
|
||||
|
||||
native void nativeSetAlignment (float alignment);
|
||||
|
||||
public native void setText(String text);
|
||||
public native void setNativeText(String text);
|
||||
native void setNativeBounds (int x, int y, int width, int height);
|
||||
|
||||
// Because this is a composite widget, we need to retrieve the
|
||||
@@ -69,6 +69,12 @@ public class GtkLabelPeer extends GtkComponentPeer
|
||||
create (label.getText (), getGtkAlignment (label.getAlignment ()));
|
||||
}
|
||||
|
||||
public void setText(String text)
|
||||
{
|
||||
if (text != null)
|
||||
setNativeText(text);
|
||||
}
|
||||
|
||||
public GtkLabelPeer (Label l)
|
||||
{
|
||||
super (l);
|
||||
|
||||
@@ -38,12 +38,9 @@ exception statement from your version. */
|
||||
|
||||
package gnu.java.awt.peer.gtk;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.Menu;
|
||||
import java.awt.MenuBar;
|
||||
import java.awt.MenuComponent;
|
||||
import java.awt.peer.MenuBarPeer;
|
||||
import java.awt.peer.MenuPeer;
|
||||
|
||||
public class GtkMenuBarPeer extends GtkMenuComponentPeer
|
||||
implements MenuBarPeer
|
||||
|
||||
@@ -38,13 +38,8 @@ exception statement from your version. */
|
||||
|
||||
package gnu.java.awt.peer.gtk;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.Menu;
|
||||
import java.awt.MenuBar;
|
||||
import java.awt.MenuComponent;
|
||||
import java.awt.MenuItem;
|
||||
import java.awt.peer.MenuItemPeer;
|
||||
import java.awt.peer.MenuPeer;
|
||||
|
||||
public class GtkMenuItemPeer extends GtkMenuComponentPeer
|
||||
implements MenuItemPeer
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/* GtkToolkit.java -- Implements an AWT Toolkit using GTK for peers
|
||||
Copyright (C) 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.java.awt.peer.gtk;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.Window;
|
||||
import java.awt.peer.MouseInfoPeer;
|
||||
|
||||
/**
|
||||
* The MouseInfoPeer is so small, I'm including it here.
|
||||
*/
|
||||
public class GtkMouseInfoPeer implements MouseInfoPeer
|
||||
{
|
||||
private static GdkGraphicsEnvironment gde = new GdkGraphicsEnvironment();
|
||||
|
||||
public int fillPointWithCoords(Point p)
|
||||
{
|
||||
int[] coords = gde.getMouseCoordinates();
|
||||
p.x = coords[1];
|
||||
p.y = coords[2];
|
||||
return coords[0];
|
||||
}
|
||||
|
||||
public boolean isWindowUnderMouse(Window w)
|
||||
{
|
||||
int[] coords = gde.getMouseCoordinates();
|
||||
GraphicsDevice[] gds = gde.getScreenDevices();
|
||||
|
||||
// Check if the screen of the Window and the cursor match
|
||||
if( gds[ coords[0] ] != w.getGraphicsConfiguration().getDevice() )
|
||||
return false;
|
||||
|
||||
// Return the bounds-check.
|
||||
Point p = w.getLocationOnScreen();
|
||||
return (coords[1] >= p.x && coords[1] < p.x + w.getWidth() &&
|
||||
coords[2] >= p.y && coords[2] < p.y + w.getHeight() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* GtkPanelPeer.java -- Implements PanelPeer with GTK
|
||||
Copyright (C) 1998, 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -41,7 +41,6 @@ package gnu.java.awt.peer.gtk;
|
||||
import java.awt.AWTEvent;
|
||||
import java.awt.Panel;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.PaintEvent;
|
||||
import java.awt.peer.PanelPeer;
|
||||
|
||||
public class GtkPanelPeer extends GtkContainerPeer
|
||||
|
||||
@@ -40,7 +40,6 @@ package gnu.java.awt.peer.gtk;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Event;
|
||||
import java.awt.MenuItem;
|
||||
import java.awt.Point;
|
||||
import java.awt.PopupMenu;
|
||||
import java.awt.peer.PopupMenuPeer;
|
||||
|
||||
@@ -38,8 +38,6 @@ exception statement from your version. */
|
||||
|
||||
package gnu.java.awt.peer.gtk;
|
||||
|
||||
import java.awt.Adjustable;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Scrollbar;
|
||||
import java.awt.event.AdjustmentEvent;
|
||||
import java.awt.peer.ScrollbarPeer;
|
||||
|
||||
@@ -39,32 +39,83 @@ exception statement from your version. */
|
||||
|
||||
package gnu.java.awt.peer.gtk;
|
||||
|
||||
import gnu.classpath.Configuration;
|
||||
import gnu.java.awt.EmbeddedWindow;
|
||||
import gnu.java.awt.dnd.GtkMouseDragGestureRecognizer;
|
||||
import gnu.java.awt.dnd.peer.gtk.GtkDragSourceContextPeer;
|
||||
import gnu.java.awt.peer.ClasspathFontPeer;
|
||||
import gnu.java.awt.peer.ClasspathTextLayoutPeer;
|
||||
import gnu.java.awt.peer.EmbeddedWindowPeer;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.AWTException;
|
||||
import java.awt.Button;
|
||||
import java.awt.Canvas;
|
||||
import java.awt.Checkbox;
|
||||
import java.awt.CheckboxMenuItem;
|
||||
import java.awt.Choice;
|
||||
import java.awt.Component;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Dialog;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.FileDialog;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Frame;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Image;
|
||||
import java.awt.Label;
|
||||
import java.awt.List;
|
||||
import java.awt.Menu;
|
||||
import java.awt.MenuBar;
|
||||
import java.awt.MenuItem;
|
||||
import java.awt.Panel;
|
||||
import java.awt.Point;
|
||||
import java.awt.PopupMenu;
|
||||
import java.awt.PrintJob;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.ScrollPane;
|
||||
import java.awt.Scrollbar;
|
||||
import java.awt.TextArea;
|
||||
import java.awt.TextField;
|
||||
import java.awt.Window;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.dnd.DragGestureEvent;
|
||||
import java.awt.dnd.DragGestureListener;
|
||||
import java.awt.dnd.DragGestureRecognizer;
|
||||
import java.awt.dnd.DragSource;
|
||||
import java.awt.dnd.peer.DragSourceContextPeer;
|
||||
import java.awt.font.FontRenderContext;
|
||||
import java.awt.im.InputMethodHighlight;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.awt.image.DirectColorModel;
|
||||
import java.awt.image.ImageConsumer;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.awt.image.ImageProducer;
|
||||
import java.awt.peer.*;
|
||||
import java.awt.peer.ButtonPeer;
|
||||
import java.awt.peer.CanvasPeer;
|
||||
import java.awt.peer.CheckboxMenuItemPeer;
|
||||
import java.awt.peer.CheckboxPeer;
|
||||
import java.awt.peer.ChoicePeer;
|
||||
import java.awt.peer.DialogPeer;
|
||||
import java.awt.peer.FileDialogPeer;
|
||||
import java.awt.peer.FontPeer;
|
||||
import java.awt.peer.FramePeer;
|
||||
import java.awt.peer.LabelPeer;
|
||||
import java.awt.peer.ListPeer;
|
||||
import java.awt.peer.MenuBarPeer;
|
||||
import java.awt.peer.MenuItemPeer;
|
||||
import java.awt.peer.MouseInfoPeer;
|
||||
import java.awt.peer.MenuPeer;
|
||||
import java.awt.peer.PanelPeer;
|
||||
import java.awt.peer.PopupMenuPeer;
|
||||
import java.awt.peer.RobotPeer;
|
||||
import java.awt.peer.ScrollPanePeer;
|
||||
import java.awt.peer.ScrollbarPeer;
|
||||
import java.awt.peer.TextAreaPeer;
|
||||
import java.awt.peer.TextFieldPeer;
|
||||
import java.awt.peer.WindowPeer;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.text.AttributedString;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
@@ -310,6 +361,11 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
|
||||
|
||||
public PrintJob getPrintJob (Frame frame, String jobtitle, Properties props)
|
||||
{
|
||||
SecurityManager sm;
|
||||
sm = System.getSecurityManager();
|
||||
if (sm != null)
|
||||
sm.checkPrintJobAccess();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -528,12 +584,6 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
|
||||
}
|
||||
}
|
||||
|
||||
public ClasspathTextLayoutPeer getClasspathTextLayoutPeer (AttributedString str,
|
||||
FontRenderContext frc)
|
||||
{
|
||||
return new GdkTextLayout(str, frc);
|
||||
}
|
||||
|
||||
protected EventQueue getSystemEventQueueImpl()
|
||||
{
|
||||
synchronized (GtkToolkit.class)
|
||||
@@ -555,7 +605,26 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
|
||||
|
||||
public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent e)
|
||||
{
|
||||
throw new Error("not implemented");
|
||||
return new GtkDragSourceContextPeer(e);
|
||||
}
|
||||
|
||||
public DragGestureRecognizer createDragGestureRecognizer(Class recognizer,
|
||||
DragSource ds,
|
||||
Component comp,
|
||||
int actions,
|
||||
DragGestureListener l)
|
||||
{
|
||||
if (recognizer.getName().equals("java.awt.dnd.MouseDragGestureRecognizer"))
|
||||
{
|
||||
GtkMouseDragGestureRecognizer gestureRecognizer
|
||||
= new GtkMouseDragGestureRecognizer(ds, comp, actions, l);
|
||||
gestureRecognizer.registerListeners();
|
||||
return gestureRecognizer;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Map mapInputMethodHighlight(InputMethodHighlight highlight)
|
||||
@@ -593,4 +662,12 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
|
||||
}
|
||||
|
||||
public static native void gtkMain();
|
||||
|
||||
protected MouseInfoPeer getMouseInfoPeer()
|
||||
{
|
||||
return new GtkMouseInfoPeer();
|
||||
}
|
||||
|
||||
public native int getMouseNumberOfButtons();
|
||||
|
||||
} // class GtkToolkit
|
||||
|
||||
@@ -50,6 +50,8 @@ public class GtkVolatileImage extends VolatileImage
|
||||
int width, height;
|
||||
private ImageCapabilities caps;
|
||||
|
||||
final GtkComponentPeer component;
|
||||
|
||||
/**
|
||||
* Don't touch, accessed from native code.
|
||||
*/
|
||||
@@ -85,6 +87,7 @@ public class GtkVolatileImage extends VolatileImage
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.caps = caps;
|
||||
this.component = component;
|
||||
nativePointer = init( component, width, height );
|
||||
}
|
||||
|
||||
|
||||
@@ -38,13 +38,14 @@ exception statement from your version. */
|
||||
|
||||
package gnu.java.awt.peer.gtk;
|
||||
|
||||
import java.awt.AWTEvent;
|
||||
import java.awt.Component;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.KeyboardFocusManager;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.PaintEvent;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.peer.WindowPeer;
|
||||
@@ -70,7 +71,8 @@ public class GtkWindowPeer extends GtkContainerPeer
|
||||
native void gtkWindowSetTitle (String title);
|
||||
native void gtkWindowSetResizable (boolean resizable);
|
||||
native void gtkWindowSetModal (boolean modal);
|
||||
|
||||
native void gtkWindowSetAlwaysOnTop ( boolean alwaysOnTop );
|
||||
native boolean gtkWindowHasFocus();
|
||||
native void realize ();
|
||||
|
||||
/** Returns the cached width of the AWT window component. */
|
||||
@@ -275,10 +277,13 @@ public class GtkWindowPeer extends GtkContainerPeer
|
||||
else
|
||||
q().postEvent (new WindowEvent ((Window) awtComponent, id, opposite));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the always-on-top status of the native window.
|
||||
*/
|
||||
public void updateAlwaysOnTop()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
gtkWindowSetAlwaysOnTop( ((Window)awtComponent).isAlwaysOnTop() );
|
||||
}
|
||||
|
||||
protected void postExposeEvent (int x, int y, int width, int height)
|
||||
@@ -299,7 +304,40 @@ public class GtkWindowPeer extends GtkContainerPeer
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public boolean requestFocus (Component request, boolean temporary,
|
||||
boolean allowWindowFocus, long time)
|
||||
{
|
||||
assert request == awtComponent || isLightweightDescendant(request);
|
||||
boolean retval = false;
|
||||
if (gtkWindowHasFocus())
|
||||
{
|
||||
KeyboardFocusManager kfm =
|
||||
KeyboardFocusManager.getCurrentKeyboardFocusManager();
|
||||
Component currentFocus = kfm.getFocusOwner();
|
||||
if (currentFocus == request)
|
||||
// Nothing to do in this trivial case.
|
||||
retval = true;
|
||||
else
|
||||
{
|
||||
// Requested component is a lightweight descendant of this one
|
||||
// or the actual heavyweight.
|
||||
// Since this (native) component is already focused, we simply
|
||||
// change the actual focus and be done.
|
||||
postFocusEvent(FocusEvent.FOCUS_GAINED, temporary);
|
||||
retval = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (allowWindowFocus)
|
||||
{
|
||||
retval = requestWindowFocus();
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
public Graphics getGraphics ()
|
||||
{
|
||||
Graphics g = super.getGraphics ();
|
||||
|
||||
@@ -38,25 +38,11 @@ exception statement from your version. */
|
||||
|
||||
package gnu.java.awt.peer.gtk;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Shape;
|
||||
import java.awt.font.GlyphVector;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBuffer;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.awt.image.DirectColorModel;
|
||||
import java.awt.image.RenderedImage;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
public class VolatileImageGraphics extends ComponentGraphics
|
||||
{
|
||||
@@ -83,7 +69,7 @@ public class VolatileImageGraphics extends ComponentGraphics
|
||||
|
||||
public GraphicsConfiguration getDeviceConfiguration()
|
||||
{
|
||||
return null;
|
||||
return owner.component.getGraphicsConfiguration();
|
||||
}
|
||||
|
||||
public Graphics create()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* QtCheckboxPeer.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -37,7 +37,6 @@ exception statement from your version. */
|
||||
|
||||
package gnu.java.awt.peer.qt;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Checkbox;
|
||||
import java.awt.CheckboxGroup;
|
||||
import java.awt.event.ItemEvent;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* QtComponentGraphics.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -40,9 +40,7 @@ package gnu.java.awt.peer.qt;
|
||||
import java.awt.Color;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Paint;
|
||||
|
||||
/**
|
||||
* QtComponentPainter is a Graphics2D context for painting directly to AWT
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* QtComponentPeer.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -41,7 +41,6 @@ import java.awt.AWTEvent;
|
||||
import java.awt.AWTException;
|
||||
import java.awt.BufferCapabilities;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Dimension;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* QtContainerPeer.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -37,7 +37,6 @@ exception statement from your version. */
|
||||
|
||||
package gnu.java.awt.peer.qt;
|
||||
|
||||
import java.awt.Container;
|
||||
import java.awt.Component;
|
||||
import java.awt.Insets;
|
||||
import java.awt.peer.ContainerPeer;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* QtDialogPeer.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -38,8 +38,6 @@ exception statement from your version. */
|
||||
package gnu.java.awt.peer.qt;
|
||||
|
||||
import java.awt.Dialog;
|
||||
import java.awt.MenuBar;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.peer.DialogPeer;
|
||||
|
||||
public class QtDialogPeer extends QtWindowPeer implements DialogPeer
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* QtEmbeddedWindowPeer.java -- embedded window peer
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -38,7 +38,6 @@ exception statement from your version. */
|
||||
package gnu.java.awt.peer.qt;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.peer.WindowPeer;
|
||||
import gnu.java.awt.peer.EmbeddedWindowPeer;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* QtFontMetrics.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -41,9 +41,6 @@ import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.font.FontRenderContext;
|
||||
import java.awt.font.GlyphVector;
|
||||
import java.awt.font.LineMetrics;
|
||||
|
||||
public class QtFontMetrics extends FontMetrics
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* QtFontPeer.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -46,7 +46,6 @@ import java.awt.font.LineMetrics;
|
||||
import java.text.CharacterIterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.awt.peer.FontPeer;
|
||||
|
||||
import gnu.java.awt.peer.ClasspathFontPeer;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* QtGraphics.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -38,6 +38,7 @@ exception statement from your version. */
|
||||
package gnu.java.awt.peer.qt;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.AWTPermission;
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Composite;
|
||||
@@ -57,7 +58,6 @@ import java.awt.Stroke;
|
||||
import java.awt.font.FontRenderContext;
|
||||
import java.awt.font.GlyphVector;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.PathIterator;
|
||||
import java.awt.geom.Arc2D;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.Line2D;
|
||||
@@ -605,8 +605,16 @@ public abstract class QtGraphics extends Graphics2D
|
||||
composite = comp;
|
||||
}
|
||||
else
|
||||
throw new UnsupportedOperationException("We don't support custom"+
|
||||
" composites yet.");
|
||||
{
|
||||
// FIXME: this check is only required "if this Graphics2D
|
||||
// context is drawing to a Component on the display screen".
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null)
|
||||
sm.checkPermission(new AWTPermission("readDisplayPixels"));
|
||||
|
||||
throw new UnsupportedOperationException("We don't support custom"+
|
||||
" composites yet.");
|
||||
}
|
||||
}
|
||||
|
||||
public Composite getComposite()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* QtGraphicsEnvironment.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -41,7 +41,6 @@ import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.HeadlessException;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* QtImage.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -43,7 +43,6 @@ import java.awt.Image;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.awt.image.DirectColorModel;
|
||||
import java.awt.image.MemoryImageSource;
|
||||
import java.awt.image.ImageConsumer;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.awt.image.ImageProducer;
|
||||
import java.io.File;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* QtImageConsumer.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -37,15 +37,10 @@ exception statement from your version. */
|
||||
|
||||
package gnu.java.awt.peer.qt;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.awt.image.DirectColorModel;
|
||||
import java.awt.image.ImageConsumer;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.awt.image.ImageProducer;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* Helper class to QtImage. Sits and gathers pixels for a QtImage and then
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* QtImageDirectGraphics.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -38,29 +38,10 @@ exception statement from your version. */
|
||||
package gnu.java.awt.peer.qt;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.Paint;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.Stack;
|
||||
import java.awt.Shape;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.font.FontRenderContext;
|
||||
import java.awt.font.GlyphVector;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.PathIterator;
|
||||
import java.awt.geom.Arc2D;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.Line2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.BufferedImageOp;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.awt.image.RenderedImage;
|
||||
import java.awt.image.renderable.RenderableImage;
|
||||
|
||||
/**
|
||||
* A QtImagePainter that does an update after every drawing op.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* QtImageGraphics.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -40,9 +40,7 @@ package gnu.java.awt.peer.qt;
|
||||
import java.awt.Color;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.Paint;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* QtMenuBarPeer.java -- Qt peer for a menu bar.
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -40,7 +40,6 @@ package gnu.java.awt.peer.qt;
|
||||
import java.awt.Menu;
|
||||
import java.awt.MenuBar;
|
||||
import java.awt.peer.MenuBarPeer;
|
||||
import java.util.Vector;
|
||||
|
||||
public class QtMenuBarPeer extends QtMenuComponentPeer implements MenuBarPeer
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* QtMenuItemPeer.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -37,7 +37,6 @@ exception statement from your version. */
|
||||
|
||||
package gnu.java.awt.peer.qt;
|
||||
|
||||
import java.awt.Menu;
|
||||
import java.awt.MenuItem;
|
||||
import java.awt.CheckboxMenuItem;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* QtPopupMenuPeer.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -38,12 +38,9 @@ exception statement from your version. */
|
||||
package gnu.java.awt.peer.qt;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Menu;
|
||||
import java.awt.MenuItem;
|
||||
import java.awt.Point;
|
||||
import java.awt.PopupMenu;
|
||||
import java.awt.Event;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.peer.PopupMenuPeer;
|
||||
|
||||
public class QtPopupMenuPeer extends QtMenuPeer implements PopupMenuPeer
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* QtScreenDeviceConfiguration.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -37,11 +37,9 @@ exception statement from your version. */
|
||||
|
||||
package gnu.java.awt.peer.qt;
|
||||
|
||||
import java.awt.DisplayMode;
|
||||
import java.awt.ImageCapabilities;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsConfigTemplate;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ColorModel;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* QtScrollPanePeer.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -38,7 +38,6 @@ exception statement from your version. */
|
||||
package gnu.java.awt.peer.qt;
|
||||
|
||||
import java.awt.Adjustable;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Insets;
|
||||
import java.awt.ScrollPane;
|
||||
import java.awt.peer.ScrollPanePeer;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* QtToolkit.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -37,19 +37,16 @@ exception statement from your version. */
|
||||
|
||||
package gnu.java.awt.peer.qt;
|
||||
|
||||
import gnu.classpath.Configuration;
|
||||
import gnu.java.awt.EmbeddedWindow;
|
||||
import gnu.java.awt.peer.ClasspathFontPeer;
|
||||
import gnu.java.awt.peer.EmbeddedWindowPeer;
|
||||
import gnu.java.awt.peer.ClasspathTextLayoutPeer;
|
||||
import java.awt.AWTEvent;
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.Button;
|
||||
import java.awt.Canvas;
|
||||
import java.awt.Checkbox;
|
||||
import java.awt.CheckboxMenuItem;
|
||||
import java.awt.Choice;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dialog;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.EventQueue;
|
||||
@@ -68,18 +65,13 @@ import java.awt.TextField;
|
||||
import java.awt.FileDialog;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.HeadlessException;
|
||||
import java.awt.PopupMenu;
|
||||
import java.awt.PrintJob;
|
||||
import java.awt.Scrollbar;
|
||||
import java.awt.ScrollPane;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.Window;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.dnd.DragGestureEvent;
|
||||
import java.awt.dnd.DragGestureListener;
|
||||
import java.awt.dnd.DragGestureRecognizer;
|
||||
import java.awt.dnd.DragSource;
|
||||
import java.awt.dnd.peer.DragSourceContextPeer;
|
||||
import java.awt.event.AWTEventListener;
|
||||
import java.awt.image.ColorModel;
|
||||
@@ -91,37 +83,29 @@ import java.awt.peer.ButtonPeer;
|
||||
import java.awt.peer.FontPeer;
|
||||
import java.awt.peer.PanelPeer;
|
||||
import java.awt.peer.CanvasPeer;
|
||||
import java.awt.peer.FramePeer;
|
||||
import java.awt.peer.FramePeer;
|
||||
import java.awt.peer.PopupMenuPeer;
|
||||
import java.awt.peer.CheckboxMenuItemPeer;
|
||||
import java.awt.peer.LabelPeer;
|
||||
import java.awt.peer.RobotPeer;
|
||||
import java.awt.peer.CheckboxPeer;
|
||||
import java.awt.peer.LightweightPeer;
|
||||
import java.awt.peer.ScrollPanePeer;
|
||||
import java.awt.peer.ChoicePeer;
|
||||
import java.awt.peer.ChoicePeer;
|
||||
import java.awt.peer.ListPeer;
|
||||
import java.awt.peer.ScrollbarPeer;
|
||||
import java.awt.peer.ComponentPeer;
|
||||
import java.awt.peer.MenuBarPeer;
|
||||
import java.awt.peer.TextAreaPeer;
|
||||
import java.awt.peer.ContainerPeer;
|
||||
import java.awt.peer.MenuComponentPeer;
|
||||
import java.awt.peer.TextComponentPeer;
|
||||
import java.awt.peer.DialogPeer;
|
||||
import java.awt.peer.MenuItemPeer;
|
||||
import java.awt.peer.TextFieldPeer;
|
||||
import java.awt.peer.FileDialogPeer;
|
||||
import java.awt.peer.MenuPeer;
|
||||
import java.awt.peer.WindowPeer;
|
||||
import java.awt.font.FontRenderContext;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.text.AttributedString;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import javax.imageio.spi.IIORegistry;
|
||||
|
||||
import gnu.java.awt.ClasspathToolkit;
|
||||
|
||||
@@ -402,6 +386,11 @@ public class QtToolkit extends ClasspathToolkit
|
||||
String jobtitle,
|
||||
Properties props)
|
||||
{
|
||||
SecurityManager sm;
|
||||
sm = System.getSecurityManager();
|
||||
if (sm != null)
|
||||
sm.checkPrintJobAccess();
|
||||
|
||||
throw new RuntimeException("Not implemented");
|
||||
}
|
||||
|
||||
@@ -445,12 +434,6 @@ public class QtToolkit extends ClasspathToolkit
|
||||
return new QtFontPeer (name, attrs);
|
||||
}
|
||||
|
||||
public ClasspathTextLayoutPeer getClasspathTextLayoutPeer(AttributedString str,
|
||||
FontRenderContext frc)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// FIXME
|
||||
public Font createFont(int format, InputStream stream)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* QtVolatileImage.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -47,15 +47,11 @@ import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.awt.image.DirectColorModel;
|
||||
import java.awt.image.MemoryImageSource;
|
||||
import java.awt.image.ImageConsumer;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.awt.image.ImageProducer;
|
||||
import java.awt.image.VolatileImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Hashtable;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* QtVolatileImage - wraps a QImage
|
||||
|
||||
@@ -48,8 +48,6 @@ import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
@@ -101,8 +99,8 @@ public class SwingComponentPeer
|
||||
/**
|
||||
* Creates a SwingComponentPeer instance. Subclasses are expected to call
|
||||
* this constructor and thereafter call
|
||||
* {@link #init(Component, SwingComponent)} in order to setup the AWT and
|
||||
* Swing components properly.
|
||||
* {@link #init(Component,SwingComponent)}
|
||||
* in order to setup the AWT and Swing components properly.
|
||||
*/
|
||||
protected SwingComponentPeer()
|
||||
{
|
||||
@@ -167,12 +165,9 @@ public class SwingComponentPeer
|
||||
*/
|
||||
public Image createImage(int width, int height)
|
||||
{
|
||||
GraphicsEnvironment graphicsEnv =
|
||||
GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
GraphicsDevice dev = graphicsEnv.getDefaultScreenDevice();
|
||||
GraphicsConfiguration conf = dev.getDefaultConfiguration();
|
||||
Image image = conf.createCompatibleImage(width, height);
|
||||
return image;
|
||||
Component parent = awtComponent.getParent();
|
||||
ComponentPeer parentPeer = parent.getPeer();
|
||||
return parentPeer.createImage(width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -336,21 +331,24 @@ public class SwingComponentPeer
|
||||
{
|
||||
case PaintEvent.UPDATE:
|
||||
case PaintEvent.PAINT:
|
||||
Graphics g = getGraphics();
|
||||
Rectangle clip = ((PaintEvent)e).getUpdateRect();
|
||||
g.clipRect(clip.x, clip.y, clip.width, clip.height);
|
||||
//if (this instanceof LightweightPeer)
|
||||
// {
|
||||
// This only will work when the component is showing.
|
||||
if (awtComponent.isShowing())
|
||||
{
|
||||
Graphics g = getGraphics();
|
||||
Rectangle clip = ((PaintEvent)e).getUpdateRect();
|
||||
g.clipRect(clip.x, clip.y, clip.width, clip.height);
|
||||
//if (this instanceof LightweightPeer)
|
||||
// {
|
||||
if (e.getID() == PaintEvent.UPDATE)
|
||||
awtComponent.update(g);
|
||||
else
|
||||
awtComponent.paint(g);
|
||||
// }
|
||||
// We paint the 'heavyweights' at last, so that they appear on top of
|
||||
// everything else.
|
||||
peerPaint(g);
|
||||
|
||||
g.dispose();
|
||||
// }
|
||||
// We paint the 'heavyweights' at last, so that they appear on top of
|
||||
// everything else.
|
||||
peerPaint(g);
|
||||
g.dispose();
|
||||
}
|
||||
break;
|
||||
case MouseEvent.MOUSE_PRESSED:
|
||||
case MouseEvent.MOUSE_RELEASED:
|
||||
@@ -384,6 +382,11 @@ public class SwingComponentPeer
|
||||
{
|
||||
if (swingComponent != null)
|
||||
swingComponent.getJComponent().setVisible(false);
|
||||
|
||||
Component parent = awtComponent.getParent();
|
||||
if (parent != null)
|
||||
parent.repaint(awtComponent.getX(), awtComponent.getY(),
|
||||
awtComponent.getWidth(), awtComponent.getHeight());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -470,17 +473,15 @@ public class SwingComponentPeer
|
||||
public boolean prepareImage(Image img, int width, int height, ImageObserver ob)
|
||||
{
|
||||
Component parent = awtComponent.getParent();
|
||||
boolean res;
|
||||
if(parent != null)
|
||||
{
|
||||
ComponentPeer parentPeer = parent.getPeer();
|
||||
res = parentPeer.prepareImage(img, width, height, ob);
|
||||
}
|
||||
{
|
||||
ComponentPeer parentPeer = parent.getPeer();
|
||||
return parentPeer.prepareImage(img, width, height, ob);
|
||||
}
|
||||
else
|
||||
{
|
||||
res = Toolkit.getDefaultToolkit().prepareImage(img, width, height, ob);
|
||||
}
|
||||
return res;
|
||||
{
|
||||
return Toolkit.getDefaultToolkit().prepareImage(img, width, height, ob);
|
||||
}
|
||||
}
|
||||
|
||||
public void print(Graphics graphics)
|
||||
@@ -662,8 +663,10 @@ public class SwingComponentPeer
|
||||
*/
|
||||
public void setVisible(boolean visible)
|
||||
{
|
||||
if (swingComponent != null)
|
||||
swingComponent.getJComponent().setVisible(visible);
|
||||
if (visible)
|
||||
show();
|
||||
else
|
||||
hide();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -782,8 +785,13 @@ public class SwingComponentPeer
|
||||
public VolatileImage createVolatileImage(int width, int height)
|
||||
{
|
||||
Component parent = awtComponent.getParent();
|
||||
ComponentPeer parentPeer = parent.getPeer();
|
||||
return parentPeer.createVolatileImage(width, height);
|
||||
VolatileImage im = null;
|
||||
if (parent != null)
|
||||
{
|
||||
ComponentPeer parentPeer = parent.getPeer();
|
||||
im = parentPeer.createVolatileImage(width, height);
|
||||
}
|
||||
return im;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
/* GLGraphics.java -- Graphics2D impl on top of GLX
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.java.awt.peer.x;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.image.ColorModel;
|
||||
|
||||
import gnu.java.awt.java2d.AbstractGraphics2D;
|
||||
import gnu.x11.extension.glx.GL;
|
||||
|
||||
/**
|
||||
* An implementation of Graphics2D on top of the GLX extension of X.
|
||||
*
|
||||
* @author Roman Kennke (kennke@aicas.com)
|
||||
*/
|
||||
public class GLGraphics extends AbstractGraphics2D
|
||||
{
|
||||
|
||||
/**
|
||||
* The rendering context.
|
||||
*/
|
||||
private GL gl;
|
||||
|
||||
/**
|
||||
* Creates a new GLGraphics that paints on the specified GL context.
|
||||
*
|
||||
* @param g the GL context to paint to
|
||||
*/
|
||||
GLGraphics(GL g)
|
||||
{
|
||||
gl = g;
|
||||
}
|
||||
|
||||
public void setBackground(Color b)
|
||||
{
|
||||
super.setBackground(b);
|
||||
gl.clear_color(b.getRed() / 255.F, b.getGreen() / 255.F,
|
||||
b.getBlue() / 255.F, b.getAlpha() / 255.F);
|
||||
}
|
||||
|
||||
public void clearRect(int x, int y, int w, int h)
|
||||
{
|
||||
// TODO: Maybe use fillRect().
|
||||
gl.clear(GL.COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
public void drawLine(int x1, int y1, int x2, int y2)
|
||||
{
|
||||
gl.begin(GL.LINES);
|
||||
gl.vertex2i(x1, y1);
|
||||
gl.vertex2i(x2, y2);
|
||||
gl.end();
|
||||
// TODO: Maybe do:
|
||||
// gl.flush();
|
||||
}
|
||||
|
||||
public void drawRect(int x, int y, int w, int h)
|
||||
{
|
||||
gl.polygon_mode(GL.FRONT_AND_BACK, GL.LINE);
|
||||
gl.begin(GL.POLYGON);
|
||||
gl.recti(x, y, x + w, y + h);
|
||||
gl.end();
|
||||
// TODO: Maybe do:
|
||||
// gl.flush();
|
||||
}
|
||||
|
||||
public void fillRect(int x, int y, int w, int h)
|
||||
{
|
||||
gl.polygon_mode(GL.FRONT_AND_BACK, GL.FILL);
|
||||
gl.recti(x, y, x + w, y + h);
|
||||
// TODO: Maybe do:
|
||||
// gl.flush();
|
||||
}
|
||||
|
||||
protected ColorModel getColorModel()
|
||||
{
|
||||
// FIXME: Implement this.
|
||||
throw new UnsupportedOperationException("Not yet implemented");
|
||||
}
|
||||
|
||||
public GraphicsConfiguration getDeviceConfiguration()
|
||||
{
|
||||
// FIXME: Implement this.
|
||||
throw new UnsupportedOperationException("Not yet implemented");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
/* ImageConverter.java -- Convert arbitrary Image impl to XImage
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.java.awt.peer.x;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.awt.image.ImageConsumer;
|
||||
import java.util.Hashtable;
|
||||
|
||||
/**
|
||||
* Convert a non-XImage to an XImage.
|
||||
*
|
||||
* @author Roman Kennke (kennke@aicas.com)
|
||||
*/
|
||||
public class ImageConverter implements ImageConsumer
|
||||
{
|
||||
|
||||
private XImage image;
|
||||
private Graphics imageGraphics;
|
||||
|
||||
public void setDimensions(int width, int height)
|
||||
{
|
||||
image = new XImage(width, height);
|
||||
}
|
||||
|
||||
public void setProperties(Hashtable props)
|
||||
{
|
||||
// Ignore for now.
|
||||
}
|
||||
|
||||
public void setColorModel(ColorModel model)
|
||||
{
|
||||
// Ignore for now.
|
||||
}
|
||||
|
||||
public void setHints(int flags)
|
||||
{
|
||||
// Ignore for now.
|
||||
}
|
||||
|
||||
public void setPixels(int x, int y, int w, int h, ColorModel model,
|
||||
byte[] pixels, int offset, int scansize)
|
||||
{
|
||||
// FIXME: Implement this.
|
||||
throw new UnsupportedOperationException("Not yet implemented");
|
||||
}
|
||||
|
||||
public void setPixels(int x, int y, int w, int h, ColorModel model,
|
||||
int[] pixels, int offset, int scansize)
|
||||
{
|
||||
System.err.println("transferType: " + model.getTransferType());
|
||||
System.err.println("colorModel: " + model);
|
||||
if (imageGraphics == null)
|
||||
imageGraphics = image.getGraphics();
|
||||
int xend = x + w;
|
||||
int yend = y + h;
|
||||
for (int yy = y; yy < yend; yy++)
|
||||
{
|
||||
for (int xx = x; xx < xend; xx++)
|
||||
{
|
||||
int pixel = pixels[yy * scansize + xx + offset];
|
||||
imageGraphics.setColor(new Color(model.getRGB(pixel)));
|
||||
imageGraphics.fillRect(xx, yy, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void imageComplete(int status)
|
||||
{
|
||||
// Nothing to do here.
|
||||
}
|
||||
|
||||
XImage getXImage()
|
||||
{
|
||||
return image;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user