Commit 8fe7789e by Graydon Hoare

configure.in: Add --enable-gtk-cairo check.

2003-12-16  Graydon Hoare  <graydon@redhat.com>

	* configure.in: Add --enable-gtk-cairo check.
	* configure: Regenerate.
	* Makefile.am: Conditionally link against cairo.
	* Makefile.in: Regenerate.
	* acinclude.m4: Include PKG_CHECK_MODULES.
	* aclocal.m4: Regenerate.
	* gnu/java/awt/peer/gtk/GtkToolkit.java (useGraphics2D): New method.
	(getFontMetrics, getClasspathFontPeer):
	* gnu/java/awt/peer/gtk/GtkCanvasPeer.java (getGraphics):
	* gnu/java/awt/peer/gtk/GtkComponentPeer.java (createImage):
	* gnu/java/awt/peer/gtk/GtkContainerPeer.java (getGraphics):
	* gnu/java/awt/peer/gtk/GtkFramePeer.java (getGraphics):
	Switch behavior depending on GtkToolkit.useGraphics2D().
	* gnu/java/awt/peer/gtk/GtkFontPeer.java: Extend ClasspathFontPeer.
	* java/awt/Font.java: Switch to peer model.
	* jni/gtk-peer/gtkcairopeer.h: Definitions of cairo stuff.
	* jni/gtk-peer/gdkfont.h: Include gtkcairopeer.h.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c: Include gtkcairopeer.h.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetrics.c: Un-include gtkpeer.h.

From-SVN: r75260
parent 4f0c9c8a
......@@ -168,8 +168,20 @@ libgcj_la_LDFLAGS = -rpath $(toolexeclibdir) $(THREADLDFLAGS) $(THREADLIBS) \
-version-info `grep -v '^\#' $(srcdir)/libtool-version`
libgcj_la_LINK = $(LIBLINK)
# Gtk/Cairo JNI sources.
if GTK_CAIRO
gtk_cairo_c_source_files = \
jni/gtk-peer/gnu_java_awt_peer_gtk_GdkClasspathFontPeer.c \
jni/gtk-peer/gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetrics.c \
jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGlyphVector.c \
jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
else
gtk_cairo_c_source_files =
endif
## Gtk JNI sources.
gtk_c_source_files = \
$(gtk_cairo_c_source_files) \
jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontMetrics.c \
jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c \
jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c \
......@@ -207,8 +219,12 @@ jni/classpath/primlib.c
## Java sources for Gtk peers.
gtk_awt_peer_sources = \
gnu/java/awt/peer/gtk/GdkClasspathFontPeer.java \
gnu/java/awt/peer/gtk/GdkClasspathFontPeerMetrics.java \
gnu/java/awt/peer/gtk/GdkFontMetrics.java \
gnu/java/awt/peer/gtk/GdkGlyphVector.java \
gnu/java/awt/peer/gtk/GdkGraphics.java \
gnu/java/awt/peer/gtk/GdkGraphics2D.java \
gnu/java/awt/peer/gtk/GdkPixbufDecoder.java \
gnu/java/awt/peer/gtk/GtkArg.java \
gnu/java/awt/peer/gtk/GtkArgList.java \
......@@ -264,7 +280,7 @@ jni/classpath/jnilink.h \
jni/classpath/native_state.h \
jni/classpath/primlib.h
lib_gnu_java_awt_peer_gtk_la_LIBADD = $(GTK_LIBS) $(GLIB_LIBS) $(LIBART_LIBS)
lib_gnu_java_awt_peer_gtk_la_LIBADD = $(GTK_LIBS) $(GLIB_LIBS) $(LIBART_LIBS) $(CAIRO_LIBS) $(PANGOFT2_LIBS)
lib_org_w3c_dom_la_SOURCES = org/w3c/dom/Attr.java \
org/w3c/dom/CDATASection.java \
......@@ -430,7 +446,8 @@ $(c_files): java/lang/fdlibm.h java/lang/ieeefp.h java/lang/mprec.h
## FIXME: see above
$(gtk_c_files): %.lo: %.c
$(LTCOMPILE) -c -Ijniinclude -I$(srcdir)/jni/classpath -I$(srcdir)/jni/gtk-peer $(GTK_CFLAGS) $(LIBART_CFLAGS) -o $@ $<
$(LTCOMPILE) -c -Ijniinclude -I$(srcdir)/jni/classpath -I$(srcdir)/jni/gtk-peer \
$(GTK_CFLAGS) $(LIBART_CFLAGS) $(CAIRO_LIBS) $(PANGOFT2_LIBS) -o $@ $<
$(gtk_c_files): $(gtk_c_headers)
......@@ -604,7 +621,6 @@ install-data-local:
$(INSTALL_DATA) 'java/lang/reflect/Proxy$$ProxyType.h' $(DESTDIR)$(includedir)/java/lang/reflect/
$(INSTALL_DATA) 'gnu/java/net/PlainSocketImpl$$SocketInputStream.h' $(DESTDIR)$(includedir)/gnu/java/net/
$(INSTALL_DATA) 'gnu/java/net/PlainSocketImpl$$SocketOutputStream.h' $(DESTDIR)$(includedir)/gnu/java/net/
$(INSTALL_DATA) $(srcdir)/java/util/logging/logging.properties $(DESTDIR)$(propdir)/logging.properties
## ################################################################
......@@ -833,6 +849,7 @@ gnu/awt/j2d/MappedRaster.java \
gnu/java/awt/BitMaskExtent.java \
gnu/java/awt/Buffers.java \
gnu/java/awt/ComponentDataBlitOp.java \
gnu/java/awt/ClasspathToolkit.java \
gnu/java/awt/EmbeddedWindow.java \
gnu/java/awt/EmbeddedWindowSupport.java \
gnu/java/awt/EventModifier.java \
......@@ -840,6 +857,7 @@ gnu/java/awt/image/ImageDecoder.java \
gnu/java/awt/image/XBMDecoder.java \
gnu/java/awt/peer/EmbeddedWindowPeer.java \
gnu/java/awt/peer/GLightweightPeer.java \
gnu/java/awt/peer/ClasspathFontPeer.java \
gnu/java/beans/editors/ColorEditor.java \
gnu/java/beans/editors/FontEditor.java \
gnu/java/beans/editors/NativeBooleanEditor.java \
......
......@@ -268,3 +268,60 @@ else
[Indicate that linker is not able to 8-byte align static data])
fi[]dnl
])# CHECK_FOR_BROKEN_MINGW_LD
dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not)
dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
dnl also defines GSTUFF_PKG_ERRORS on error
AC_DEFUN(PKG_CHECK_MODULES, [
succeeded=no
if test -z "$PKG_CONFIG"; then
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
fi
if test "$PKG_CONFIG" = "no" ; then
echo "*** The pkg-config script could not be found. Make sure it is"
echo "*** in your path, or set the PKG_CONFIG environment variable"
echo "*** to the full path to pkg-config."
echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
else
PKG_CONFIG_MIN_VERSION=0.9.0
if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
AC_MSG_CHECKING(for $2)
if $PKG_CONFIG --exists "$2" ; then
AC_MSG_RESULT(yes)
succeeded=yes
AC_MSG_CHECKING($1_CFLAGS)
$1_CFLAGS=`$PKG_CONFIG --cflags "$2"`
AC_MSG_RESULT($$1_CFLAGS)
AC_MSG_CHECKING($1_LIBS)
$1_LIBS=`$PKG_CONFIG --libs "$2"`
AC_MSG_RESULT($$1_LIBS)
else
$1_CFLAGS=""
$1_LIBS=""
## If we have a custom action on failure, don't print errors, but
## do set a variable so people can do so.
$1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
ifelse([$4], ,echo $$1_PKG_ERRORS,)
fi
AC_SUBST($1_CFLAGS)
AC_SUBST($1_LIBS)
else
echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
echo "*** See http://www.freedesktop.org/software/pkgconfig"
fi
fi
if test $succeeded = yes; then
ifelse([$3], , :, [$3])
else
ifelse([$4], , AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.]), [$4])
fi
])
dnl aclocal.m4 generated automatically by aclocal 1.4
dnl aclocal.m4 generated automatically by aclocal 1.4-p6
dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
......@@ -281,6 +281,63 @@ else
fi[]dnl
])# CHECK_FOR_BROKEN_MINGW_LD
dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not)
dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
dnl also defines GSTUFF_PKG_ERRORS on error
AC_DEFUN(PKG_CHECK_MODULES, [
succeeded=no
if test -z "$PKG_CONFIG"; then
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
fi
if test "$PKG_CONFIG" = "no" ; then
echo "*** The pkg-config script could not be found. Make sure it is"
echo "*** in your path, or set the PKG_CONFIG environment variable"
echo "*** to the full path to pkg-config."
echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
else
PKG_CONFIG_MIN_VERSION=0.9.0
if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
AC_MSG_CHECKING(for $2)
if $PKG_CONFIG --exists "$2" ; then
AC_MSG_RESULT(yes)
succeeded=yes
AC_MSG_CHECKING($1_CFLAGS)
$1_CFLAGS=`$PKG_CONFIG --cflags "$2"`
AC_MSG_RESULT($$1_CFLAGS)
AC_MSG_CHECKING($1_LIBS)
$1_LIBS=`$PKG_CONFIG --libs "$2"`
AC_MSG_RESULT($$1_LIBS)
else
$1_CFLAGS=""
$1_LIBS=""
## If we have a custom action on failure, don't print errors, but
## do set a variable so people can do so.
$1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
ifelse([$4], ,echo $$1_PKG_ERRORS,)
fi
AC_SUBST($1_CFLAGS)
AC_SUBST($1_LIBS)
else
echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
echo "*** See http://www.freedesktop.org/software/pkgconfig"
fi
fi
if test $succeeded = yes; then
ifelse([$3], , :, [$3])
else
ifelse([$4], , AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.]), [$4])
fi
])
# Do all the work for Automake. This macro actually does too much --
# some checks are only needed if your package does certain things.
# But this isn't really a big deal.
......@@ -290,8 +347,9 @@ fi[]dnl
dnl Usage:
dnl AM_INIT_AUTOMAKE(package,version, [no-define])
AC_DEFUN(AM_INIT_AUTOMAKE,
[AC_REQUIRE([AC_PROG_INSTALL])
AC_DEFUN([AM_INIT_AUTOMAKE],
[AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
AC_REQUIRE([AC_PROG_INSTALL])
PACKAGE=[$1]
AC_SUBST(PACKAGE)
VERSION=[$2]
......@@ -307,18 +365,47 @@ AC_REQUIRE([AM_SANITY_CHECK])
AC_REQUIRE([AC_ARG_PROGRAM])
dnl FIXME This is truly gross.
missing_dir=`cd $ac_aux_dir && pwd`
AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}, $missing_dir)
AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}, $missing_dir)
AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
AC_REQUIRE([AC_PROG_MAKE_SET])])
# Copyright 2002 Free Software Foundation, Inc.
# This program 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.
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# AM_AUTOMAKE_VERSION(VERSION)
# ----------------------------
# Automake X.Y traces this macro to ensure aclocal.m4 has been
# generated from the m4 files accompanying Automake X.Y.
AC_DEFUN([AM_AUTOMAKE_VERSION],[am__api_version="1.4"])
# AM_SET_CURRENT_AUTOMAKE_VERSION
# -------------------------------
# Call AM_AUTOMAKE_VERSION so it can be traced.
# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.4-p6])])
#
# Check to make sure that the build environment is sane.
#
AC_DEFUN(AM_SANITY_CHECK,
AC_DEFUN([AM_SANITY_CHECK],
[AC_MSG_CHECKING([whether build environment is sane])
# Just in case
sleep 1
......@@ -359,7 +446,7 @@ AC_MSG_RESULT(yes)])
dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
dnl The program must properly implement --version.
AC_DEFUN(AM_MISSING_PROG,
AC_DEFUN([AM_MISSING_PROG],
[AC_MSG_CHECKING(for working $2)
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
......@@ -378,7 +465,7 @@ AC_SUBST($1)])
# serial 1
AC_DEFUN(AM_MAINTAINER_MODE,
AC_DEFUN([AM_MAINTAINER_MODE],
[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
dnl maintainer-mode is disabled by default
AC_ARG_ENABLE(maintainer-mode,
......@@ -395,7 +482,7 @@ AC_DEFUN(AM_MAINTAINER_MODE,
# Define a conditional.
AC_DEFUN(AM_CONDITIONAL,
AC_DEFUN([AM_CONDITIONAL],
[AC_SUBST($1_TRUE)
AC_SUBST($1_FALSE)
if $2; then
......@@ -408,7 +495,7 @@ fi])
# Like AC_CONFIG_HEADER, but automatically create stamp file.
AC_DEFUN(AM_CONFIG_HEADER,
AC_DEFUN([AM_CONFIG_HEADER],
[AC_PREREQ([2.12])
AC_CONFIG_HEADER([$1])
dnl When config.status generates a header, we must update the stamp-h file.
......@@ -873,10 +960,7 @@ AC_ARG_ENABLE(libarttest, [ --disable-libarttest Do not try to compile an
fi
fi
AC_PATH_PROG(LIBART_CONFIG, libart2-config, no)
if test "$LIBART_CONFIG" = "no" ; then
AC_PATH_PROG(LIBART_CONFIG, libart-config, no)
fi
AC_PATH_PROG(LIBART_CONFIG, libart-config, no)
min_libart_version=ifelse([$1], ,0.2.5,$1)
AC_MSG_CHECKING(for LIBART - version >= $min_libart_version)
no_libart=""
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -405,6 +405,18 @@ done
AM_CONDITIONAL(XLIB_AWT, test "$use_xlib_awt" = yes)
AM_CONDITIONAL(GTK_AWT, test "$use_gtk_awt" = yes)
dnl determine whether to enable the cairo GTK Graphics2D backend
AC_ARG_ENABLE(gtk-cairo, [ --enable-gtk-cairo build the cairo Graphics2D implementation on GTK])
AM_CONDITIONAL(GTK_CAIRO, test "x${enable_gtk_cairo}" = xyes)
if test "x${enable_gtk_cairo}" = xyes
then
PKG_CHECK_MODULES(CAIRO, cairo)
PKG_CHECK_MODULES(PANGOFT2, pangoft2)
fi
AC_SUBST(CAIRO_LIBS)
AC_SUBST(CAIRO_CFLAGS)
AC_SUBST(PANGOFT2_LIBS)
AC_SUBST(PANGOFT2_CFLAGS)
dnl FIXME: this should be _libs on some hosts.
libsubdir=.libs
......
......@@ -56,6 +56,9 @@ public class GtkCanvasPeer extends GtkComponentPeer implements CanvasPeer
public Graphics getGraphics ()
{
if (GtkToolkit.useGraphics2D ())
return new GdkGraphics2D (this);
else
return new GdkGraphics (this);
}
......
......@@ -48,6 +48,7 @@ import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.Image;
import java.awt.Insets;
......@@ -148,7 +149,16 @@ public class GtkComponentPeer extends GtkGenericPeer
public Image createImage (int width, int height)
{
GdkGraphics g = new GdkGraphics (width, height);
Graphics g;
if (GtkToolkit.useGraphics2D ())
{
Graphics2D g2 = new GdkGraphics2D (width, height);
g2.setBackground (getBackground ());
g = g2;
}
else
g = new GdkGraphics (width, height);
return new GtkOffScreenImage (null, g, width, height);
}
......
......@@ -92,6 +92,9 @@ public class GtkContainerPeer extends GtkComponentPeer
public Graphics getGraphics ()
{
if (GtkToolkit.useGraphics2D ())
return new GdkGraphics2D (this);
else
return new GdkGraphics (this);
}
......
......@@ -38,10 +38,15 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
import java.awt.peer.FontPeer;
import java.awt.Font;
import java.awt.*;
import java.awt.geom.*;
import java.awt.font.*;
import java.util.Locale;
import java.util.ResourceBundle;
import java.text.*;
import gnu.java.awt.peer.ClasspathFontPeer;
public class GtkFontPeer implements FontPeer
public class GtkFontPeer extends ClasspathFontPeer
{
private static ResourceBundle bundle;
......@@ -61,6 +66,8 @@ public class GtkFontPeer implements FontPeer
public GtkFontPeer (String name, int style)
{
super(name, style, 12 /* kludge */);
if (bundle != null)
Xname = bundle.getString (name.toLowerCase () + "." + style);
else
......@@ -91,4 +98,104 @@ public class GtkFontPeer implements FontPeer
{
return Xname;
}
/* remaining methods are for static compatibility with the newer
ClasspathFontPeer superclass; none of these methods ever existed or
worked on the older FontPeer interface, but we need to pretend to
support them anyways. */
public boolean canDisplay (Font font, char c)
{
throw new UnsupportedOperationException();
}
public int canDisplayUpTo (Font font, CharacterIterator i, int start, int limit)
{
throw new UnsupportedOperationException();
}
public String getSubFamilyName (Font font, Locale locale)
{
throw new UnsupportedOperationException();
}
public String getPostScriptName (Font font)
{
throw new UnsupportedOperationException();
}
public int getNumGlyphs (Font font)
{
throw new UnsupportedOperationException();
}
public int getMissingGlyphCode (Font font)
{
throw new UnsupportedOperationException();
}
public byte getBaselineFor (Font font, char c)
{
throw new UnsupportedOperationException();
}
public String getGlyphName (Font font, int glyphIndex)
{
throw new UnsupportedOperationException();
}
public GlyphVector createGlyphVector (Font font,
FontRenderContext frc,
CharacterIterator ci)
{
throw new UnsupportedOperationException();
}
public GlyphVector createGlyphVector (Font font,
FontRenderContext ctx,
int[] glyphCodes)
{
throw new UnsupportedOperationException();
}
public GlyphVector layoutGlyphVector (Font font,
FontRenderContext frc,
char[] chars, int start,
int limit, int flags)
{
throw new UnsupportedOperationException();
}
public FontMetrics getFontMetrics (Font font)
{
throw new UnsupportedOperationException();
}
public boolean hasUniformLineMetrics (Font font)
{
throw new UnsupportedOperationException();
}
public LineMetrics getLineMetrics (Font font,
CharacterIterator ci,
int begin, int limit,
FontRenderContext rc)
{
throw new UnsupportedOperationException();
}
public Rectangle2D getMaxCharBounds (Font font,
FontRenderContext rc)
{
throw new UnsupportedOperationException();
}
public Rectangle2D getStringBounds (Font font,
CharacterIterator ci,
int begin, int limit,
FontRenderContext frc)
{
throw new UnsupportedOperationException();
}
}
......@@ -41,6 +41,7 @@ package gnu.java.awt.peer.gtk;
import java.awt.Component;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Insets;
import java.awt.MenuBar;
......@@ -109,8 +110,12 @@ public class GtkFramePeer extends GtkWindowPeer
public Graphics getGraphics ()
{
GdkGraphics g = new GdkGraphics (this);
g.translateNative (-insets.left, -insets.top);
Graphics g;
if (GtkToolkit.useGraphics2D ())
g = new GdkGraphics2D (this);
else
g = new GdkGraphics (this);
g.translate (-insets.left, -insets.top);
return g;
}
......
......@@ -42,6 +42,7 @@ import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.dnd.DragGestureEvent;
import java.awt.dnd.peer.DragSourceContextPeer;
import java.awt.font.TextAttribute;
import java.awt.im.InputMethodHighlight;
import java.awt.image.ColorModel;
import java.awt.image.ImageObserver;
......@@ -55,6 +56,7 @@ import java.util.Properties;
import gnu.java.awt.EmbeddedWindow;
import gnu.java.awt.EmbeddedWindowSupport;
import gnu.java.awt.peer.EmbeddedWindowPeer;
import gnu.java.awt.peer.ClasspathFontPeer;
import gnu.classpath.Configuration;
import gnu.java.awt.peer.gtk.GdkPixbufDecoder;
......@@ -65,7 +67,15 @@ import gnu.java.awt.peer.gtk.GdkPixbufDecoder;
this class. If getPeer() ever goes away, we can implement a hash table
that will keep up with every window's peer, but for now this is faster. */
public class GtkToolkit extends Toolkit
/**
* This class accesses a system property called
* <tt>gnu.java.awt.peer.gtk.Graphics</tt>. If the property is defined and
* equal to "Graphics2D", the cairo-based GdkGraphics2D will be used in
* drawing contexts. Any other value will cause the older GdkGraphics
* object to be used.
*/
public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
implements EmbeddedWindowSupport
{
GtkMainThread main;
......@@ -73,6 +83,19 @@ public class GtkToolkit extends Toolkit
static EventQueue q = new EventQueue();
static Clipboard systemClipboard;
static boolean useGraphics2dSet;
static boolean useGraphics2d;
public static boolean useGraphics2D()
{
if (useGraphics2dSet)
return useGraphics2d;
useGraphics2d = System.getProperty("gnu.java.awt.peer.gtk.Graphics",
"Graphics").equals("Graphics2D");
useGraphics2dSet = true;
return useGraphics2d;
}
static
{
if (Configuration.INIT_LOAD_LIBRARY)
......@@ -135,7 +158,10 @@ public class GtkToolkit extends Toolkit
public FontMetrics getFontMetrics (Font font)
{
return new GdkFontMetrics (font);
if (useGraphics2D())
return new GdkClasspathFontPeerMetrics (font);
else
return new GdkFontMetrics (font);
}
public Image getImage (String filename)
......@@ -322,6 +348,11 @@ public class GtkToolkit extends Toolkit
return new GtkEmbeddedWindowPeer (w);
}
/**
* @deprecated part of the older "logical font" system in earlier AWT
* implementations. Our newer Font class uses getClasspathFontPeer.
*/
protected FontPeer getFontPeer (String name, int style)
{
try {
......@@ -332,6 +363,38 @@ public class GtkToolkit extends Toolkit
}
}
/**
* Newer method to produce a peer for a Font object, even though Sun's
* design claims Font should now be peerless, we do not agree with this
* model, hence "ClasspathFontPeer".
*/
public ClasspathFontPeer getClasspathFontPeer (String name, Map attrs)
{
if (useGraphics2D())
return new GdkClasspathFontPeer (name, attrs);
else
{
int style = Font.PLAIN;
if (attrs.containsKey (TextAttribute.WEIGHT))
{
Float weight = (Float) attrs.get (TextAttribute.WEIGHT);
if (weight.floatValue () >= TextAttribute.WEIGHT_BOLD.floatValue ())
style += Font.BOLD;
}
if (attrs.containsKey (TextAttribute.POSTURE))
{
Float posture = (Float) attrs.get (TextAttribute.POSTURE);
if (posture.floatValue () >= TextAttribute.POSTURE_OBLIQUE.floatValue ())
style += Font.ITALIC;
}
return (ClasspathFontPeer) this.getFontPeer (name, style);
}
}
protected EventQueue getSystemEventQueueImpl()
{
return q;
......@@ -350,4 +413,18 @@ public class GtkToolkit extends Toolkit
{
throw new Error("not implemented");
}
// ClasspathToolkit methods
public GraphicsEnvironment getLocalGraphicsEnvironment()
{
throw new java.lang.UnsupportedOperationException ();
}
public Font createFont(int format, java.io.InputStream stream)
{
throw new java.lang.UnsupportedOperationException ();
}
} // class GtkToolkit
......@@ -38,7 +38,7 @@
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
#include "gtkpeer.h"
#include "gtkcairopeer.h"
#include <pango/pango.h>
#include <pango/pango-context.h>
......
......@@ -37,7 +37,6 @@
#include <math.h>
#include "gtkpeer.h"
#include "gdkfont.h"
#include "gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetrics.h"
......
......@@ -35,7 +35,7 @@
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
#include "gtkpeer.h"
#include "gtkcairopeer.h"
#include "gdkfont.h"
#include "gnu_java_awt_peer_gtk_GdkGraphics2D.h"
#include <gdk/gdktypes.h>
......
#ifndef __GTKCAIROPEER_H__
#define __GTKCAIROPEER_H__
/* gtkcairopeer.h -- Some global variables and #defines
Copyright (C) 1998, 1999 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., 59 Temple Place, Suite 330, Boston, MA
02111-1307 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. */
#include "gtkpeer.h"
#include <cairo.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
/*
A graphics2d struct is both simpler and uglier than a graphics
struct.
Most of the graphics2d drawing state is held in the referenced cairo_t
and corresponding cairo_surface_t, so we can ignore it.
In addition to the cairo_t, we need to hold an extra reference to the
underlying GdkDrawable so its refcount matches the lifecycle of the java
Graphics object which is peering with us; also a reference to a byte
buffer and cairo_surface_t which contain the pattern you're drawing from
(if it exists).
Finally, it is possible that we are using a non-RENDER capable X server,
therefore we will be drawing to an cairo_surface_t which is actually a
pixbuf. When this is the case, the pointer to a GdkPixbuf will be
non-NULL and any drawing operation needs to be bracketed by pixbuf
load/save operations. If the GdkPixbuf pointer is NULL, we will treat
the cairo_surface_t as RENDER-capable.
*/
struct graphics2d
{
cairo_t *cr;
cairo_surface_t *surface;
GdkDrawable *drawable;
GdkWindow *win;
GdkPixbuf *drawbuf;
char *pattern_pixels;
cairo_surface_t *pattern;
gboolean debug;
};
#endif /* __GTKCAIROPEER_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment