summaryrefslogtreecommitdiff
path: root/libjava/classpath/native/jni/qt-peer
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libjava/classpath/native/jni/qt-peer
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'libjava/classpath/native/jni/qt-peer')
-rw-r--r--libjava/classpath/native/jni/qt-peer/.cvsignore9
-rw-r--r--libjava/classpath/native/jni/qt-peer/Makefile.am85
-rw-r--r--libjava/classpath/native/jni/qt-peer/Makefile.in703
-rw-r--r--libjava/classpath/native/jni/qt-peer/buttonevent.h27
-rw-r--r--libjava/classpath/native/jni/qt-peer/componentevent.cpp223
-rw-r--r--libjava/classpath/native/jni/qt-peer/componentevent.h203
-rw-r--r--libjava/classpath/native/jni/qt-peer/containers.h10
-rw-r--r--libjava/classpath/native/jni/qt-peer/eventmethods.h245
-rw-r--r--libjava/classpath/native/jni/qt-peer/keybindings.cpp600
-rw-r--r--libjava/classpath/native/jni/qt-peer/keybindings.h20
-rw-r--r--libjava/classpath/native/jni/qt-peer/mainqtthread.cpp104
-rw-r--r--libjava/classpath/native/jni/qt-peer/mainthreadinterface.cpp69
-rw-r--r--libjava/classpath/native/jni/qt-peer/mainthreadinterface.h36
-rw-r--r--libjava/classpath/native/jni/qt-peer/nativewrapper.cpp64
-rw-r--r--libjava/classpath/native/jni/qt-peer/nativewrapper.h10
-rw-r--r--libjava/classpath/native/jni/qt-peer/qmatrix.cpp96
-rw-r--r--libjava/classpath/native/jni/qt-peer/qpainterpath.cpp239
-rw-r--r--libjava/classpath/native/jni/qt-peer/qpen.cpp108
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtaudioclip.cpp114
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtbuttonpeer.cpp94
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtcanvaspeer.cpp75
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtcheckboxpeer.cpp164
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtchoicepeer.cpp142
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtcomponent.cpp122
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtcomponent.h16
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtcomponentpeer.cpp384
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtdialogpeer.cpp164
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtembeddedwindowpeer.cpp113
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtfiledialogpeer.cpp101
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtfont.h8
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtfontmetrics.cpp233
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtfontpeer.cpp92
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtframepeer.cpp205
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtgraphics.cpp475
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtgraphics.h26
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtimage.cpp401
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtimage.h10
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtlabelpeer.cpp151
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtlistpeer.cpp210
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtmenubarpeer.cpp150
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtmenucomponentpeer.cpp66
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtmenuitempeer.cpp182
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtmenupeer.cpp254
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtpanelpeer.cpp77
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtpopupmenupeer.cpp76
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtscreendevice.cpp123
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtscrollbarpeer.cpp142
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtscrollpanepeer.cpp214
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtstrings.cpp54
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtstrings.h10
-rw-r--r--libjava/classpath/native/jni/qt-peer/qttextareapeer.cpp197
-rw-r--r--libjava/classpath/native/jni/qt-peer/qttextfieldpeer.cpp290
-rw-r--r--libjava/classpath/native/jni/qt-peer/qttoolkit.cpp156
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtvolatileimage.cpp347
-rw-r--r--libjava/classpath/native/jni/qt-peer/qtwindowpeer.cpp157
-rw-r--r--libjava/classpath/native/jni/qt-peer/slotcallbacks.cpp256
-rw-r--r--libjava/classpath/native/jni/qt-peer/slotcallbacks.h24
57 files changed, 8926 insertions, 0 deletions
diff --git a/libjava/classpath/native/jni/qt-peer/.cvsignore b/libjava/classpath/native/jni/qt-peer/.cvsignore
new file mode 100644
index 000000000..369a52a2a
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/.cvsignore
@@ -0,0 +1,9 @@
+*.o
+*.a
+*.lo
+*.la
+.libs
+.deps
+Makefile
+Makefile.in
+slotcallbacks.moc.h
diff --git a/libjava/classpath/native/jni/qt-peer/Makefile.am b/libjava/classpath/native/jni/qt-peer/Makefile.am
new file mode 100644
index 000000000..03dcd9629
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/Makefile.am
@@ -0,0 +1,85 @@
+# Qt AWT backend for Classpath
+#
+
+## GCJ LOCAL: don't install this library
+noinst_LTLIBRARIES = libqtpeer.la
+
+AM_LDFLAGS = @CLASSPATH_MODULE@ @QT_LIBS@
+AM_CPPFLAGS = @CLASSPATH_INCLUDES@
+
+## GCJ LOCAL: add libstdc++-v3 include directories
+AM_CXXFLAGS = @QT_CFLAGS@ \
+ -I$(top_builddir)/../../libstdc++-v3/include/$(target_alias) \
+ -I$(top_builddir)/../../libstdc++-v3/include \
+ -I$(top_srcdir)/../../libstdc++-v3/include \
+ -I$(top_srcdir)/../../libstdc++-v3/libsupc++
+
+libqtpeer_la_MOC = \
+ slotcallbacks.moc.h
+
+slotcallbacks.moc.h: slotcallbacks.cpp
+ $(MOC) -o slotcallbacks.moc.h $(srcdir)/slotcallbacks.cpp
+
+nodist_libqtpeer_la_SOURCES = \
+ $(libqtpeer_la_MOC)
+
+libqtpeer_la_SOURCES = \
+ buttonevent.h \
+ componentevent.cpp \
+ componentevent.h \
+ containers.h \
+ eventmethods.h \
+ keybindings.cpp \
+ keybindings.h \
+ mainqtthread.cpp \
+ mainthreadinterface.cpp \
+ mainthreadinterface.h \
+ nativewrapper.cpp \
+ nativewrapper.h \
+ qmatrix.cpp \
+ qpainterpath.cpp \
+ qpen.cpp \
+ qtaudioclip.cpp \
+ qtbuttonpeer.cpp \
+ qtcanvaspeer.cpp \
+ qtcheckboxpeer.cpp \
+ qtchoicepeer.cpp \
+ qtcomponent.cpp \
+ qtcomponent.h \
+ qtcomponentpeer.cpp \
+ qtdialogpeer.cpp \
+ qtembeddedwindowpeer.cpp \
+ qtfiledialogpeer.cpp \
+ qtfont.h \
+ qtfontmetrics.cpp \
+ qtfontpeer.cpp \
+ qtframepeer.cpp \
+ qtgraphics.cpp \
+ qtgraphics.h \
+ qtimage.cpp \
+ qtimage.h \
+ qtlabelpeer.cpp \
+ qtlistpeer.cpp \
+ qtmenubarpeer.cpp \
+ qtmenucomponentpeer.cpp \
+ qtmenuitempeer.cpp \
+ qtmenupeer.cpp \
+ qtpanelpeer.cpp \
+ qtpopupmenupeer.cpp \
+ qtscreendevice.cpp \
+ qtscrollbarpeer.cpp \
+ qtscrollpanepeer.cpp \
+ qtstrings.cpp \
+ qtstrings.h \
+ qttextareapeer.cpp \
+ qttextfieldpeer.cpp \
+ qttoolkit.cpp \
+ qtvolatileimage.cpp \
+ qtwindowpeer.cpp \
+ slotcallbacks.cpp \
+ slotcallbacks.h
+libqtpeer_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
+
+BUILT_SOURCES = $(libqtpeer_la_MOC)
+
+CLEANFILES = so_locations $(BUILT_SOURCES)
diff --git a/libjava/classpath/native/jni/qt-peer/Makefile.in b/libjava/classpath/native/jni/qt-peer/Makefile.in
new file mode 100644
index 000000000..d65474e7b
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/Makefile.in
@@ -0,0 +1,703 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Qt AWT backend for Classpath
+#
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = native/jni/qt-peer
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/../../config/depstand.m4 \
+ $(top_srcdir)/../../config/lead-dot.m4 \
+ $(top_srcdir)/../../config/lib-ld.m4 \
+ $(top_srcdir)/../../config/lib-link.m4 \
+ $(top_srcdir)/../../config/lib-prefix.m4 \
+ $(top_srcdir)/../../config/multi.m4 \
+ $(top_srcdir)/../../config/no-executables.m4 \
+ $(top_srcdir)/../../config/override.m4 \
+ $(top_srcdir)/../../libtool.m4 \
+ $(top_srcdir)/../../ltoptions.m4 \
+ $(top_srcdir)/../../ltsugar.m4 \
+ $(top_srcdir)/../../ltversion.m4 \
+ $(top_srcdir)/../../lt~obsolete.m4 \
+ $(top_srcdir)/m4/ac_prog_antlr.m4 \
+ $(top_srcdir)/m4/ac_prog_java.m4 \
+ $(top_srcdir)/m4/ac_prog_java_works.m4 \
+ $(top_srcdir)/m4/ac_prog_javac.m4 \
+ $(top_srcdir)/m4/ac_prog_javac_works.m4 \
+ $(top_srcdir)/m4/acattribute.m4 $(top_srcdir)/m4/accross.m4 \
+ $(top_srcdir)/m4/acinclude.m4 \
+ $(top_srcdir)/m4/ax_create_stdint_h.m4 \
+ $(top_srcdir)/m4/ax_func_which_gethostbyname_r.m4 \
+ $(top_srcdir)/m4/gcc_attribute.m4 $(top_srcdir)/m4/iconv.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/../../mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libqtpeer_la_LIBADD =
+am_libqtpeer_la_OBJECTS = componentevent.lo keybindings.lo \
+ mainqtthread.lo mainthreadinterface.lo nativewrapper.lo \
+ qmatrix.lo qpainterpath.lo qpen.lo qtaudioclip.lo \
+ qtbuttonpeer.lo qtcanvaspeer.lo qtcheckboxpeer.lo \
+ qtchoicepeer.lo qtcomponent.lo qtcomponentpeer.lo \
+ qtdialogpeer.lo qtembeddedwindowpeer.lo qtfiledialogpeer.lo \
+ qtfontmetrics.lo qtfontpeer.lo qtframepeer.lo qtgraphics.lo \
+ qtimage.lo qtlabelpeer.lo qtlistpeer.lo qtmenubarpeer.lo \
+ qtmenucomponentpeer.lo qtmenuitempeer.lo qtmenupeer.lo \
+ qtpanelpeer.lo qtpopupmenupeer.lo qtscreendevice.lo \
+ qtscrollbarpeer.lo qtscrollpanepeer.lo qtstrings.lo \
+ qttextareapeer.lo qttextfieldpeer.lo qttoolkit.lo \
+ qtvolatileimage.lo qtwindowpeer.lo slotcallbacks.lo
+am__objects_1 =
+nodist_libqtpeer_la_OBJECTS = $(am__objects_1)
+libqtpeer_la_OBJECTS = $(am_libqtpeer_la_OBJECTS) \
+ $(nodist_libqtpeer_la_OBJECTS)
+libqtpeer_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+ $(CXXFLAGS) $(libqtpeer_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/../../depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libqtpeer_la_SOURCES) $(nodist_libqtpeer_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+ANTLR = @ANTLR@
+ANTLR_JAR = @ANTLR_JAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CLASSPATH_CONVENIENCE = @CLASSPATH_CONVENIENCE@
+CLASSPATH_INCLUDES = @CLASSPATH_INCLUDES@
+CLASSPATH_MODULE = @CLASSPATH_MODULE@
+COLLECTIONS_PREFIX = @COLLECTIONS_PREFIX@
+CP = @CP@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DATE = @DATE@
+DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+ECJ_JAR = @ECJ_JAR@
+EGREP = @EGREP@
+ERROR_CFLAGS = @ERROR_CFLAGS@
+EXAMPLESDIR = @EXAMPLESDIR@
+EXEEXT = @EXEEXT@
+EXTRA_CFLAGS = @EXTRA_CFLAGS@
+FGREP = @FGREP@
+FIND = @FIND@
+FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
+FREETYPE2_LIBS = @FREETYPE2_LIBS@
+GCONF_CFLAGS = @GCONF_CFLAGS@
+GCONF_LIBS = @GCONF_LIBS@
+GDK_CFLAGS = @GDK_CFLAGS@
+GDK_LIBS = @GDK_LIBS@
+GJDOC = @GJDOC@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
+GMP_CFLAGS = @GMP_CFLAGS@
+GMP_LIBS = @GMP_LIBS@
+GREP = @GREP@
+GSTREAMER_BASE_CFLAGS = @GSTREAMER_BASE_CFLAGS@
+GSTREAMER_BASE_LIBS = @GSTREAMER_BASE_LIBS@
+GSTREAMER_CFLAGS = @GSTREAMER_CFLAGS@
+GSTREAMER_FILE_READER = @GSTREAMER_FILE_READER@
+GSTREAMER_LIBS = @GSTREAMER_LIBS@
+GSTREAMER_MIXER_PROVIDER = @GSTREAMER_MIXER_PROVIDER@
+GSTREAMER_PLUGINS_BASE_CFLAGS = @GSTREAMER_PLUGINS_BASE_CFLAGS@
+GSTREAMER_PLUGINS_BASE_LIBS = @GSTREAMER_PLUGINS_BASE_LIBS@
+GST_PLUGIN_LDFLAGS = @GST_PLUGIN_LDFLAGS@
+GTK_CFLAGS = @GTK_CFLAGS@
+GTK_LIBS = @GTK_LIBS@
+INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+JAR = @JAR@
+JAVA = @JAVA@
+JAVAC = @JAVAC@
+JAVAC_IS_GCJ = @JAVAC_IS_GCJ@
+JAVAC_MEM_OPT = @JAVAC_MEM_OPT@
+JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION = @JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION@
+JAY = @JAY@
+JAY_SKELETON = @JAY_SKELETON@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBDEBUG = @LIBDEBUG@
+LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBVERSION = @LIBVERSION@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBICONV = @LTLIBICONV@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR = @MKDIR@
+MKDIR_P = @MKDIR_P@
+MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
+PANGOFT2_LIBS = @PANGOFT2_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_ESCHER = @PATH_TO_ESCHER@
+PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
+QT_CFLAGS = @QT_CFLAGS@
+QT_LIBS = @QT_LIBS@
+RANLIB = @RANLIB@
+REMOVE = @REMOVE@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRICT_WARNING_CFLAGS = @STRICT_WARNING_CFLAGS@
+STRIP = @STRIP@
+TOOLSDIR = @TOOLSDIR@
+USER_JAVAH = @USER_JAVAH@
+VERSION = @VERSION@
+WANT_NATIVE_BIG_INTEGER = @WANT_NATIVE_BIG_INTEGER@
+WARNING_CFLAGS = @WARNING_CFLAGS@
+XMKMF = @XMKMF@
+XML_CFLAGS = @XML_CFLAGS@
+XML_LIBS = @XML_LIBS@
+XSLT_CFLAGS = @XSLT_CFLAGS@
+XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
+X_CFLAGS = @X_CFLAGS@
+X_EXTRA_LIBS = @X_EXTRA_LIBS@
+X_LIBS = @X_LIBS@
+X_PRE_LIBS = @X_PRE_LIBS@
+ZIP = @ZIP@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_ANTLR = @ac_ct_ANTLR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+default_toolkit = @default_toolkit@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+glibjdir = @glibjdir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+multi_basedir = @multi_basedir@
+nativeexeclibdir = @nativeexeclibdir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+toolexeclibdir = @toolexeclibdir@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+uudecode = @uudecode@
+vm_classes = @vm_classes@
+noinst_LTLIBRARIES = libqtpeer.la
+AM_LDFLAGS = @CLASSPATH_MODULE@ @QT_LIBS@
+AM_CPPFLAGS = @CLASSPATH_INCLUDES@
+AM_CXXFLAGS = @QT_CFLAGS@ \
+ -I$(top_builddir)/../../libstdc++-v3/include/$(target_alias) \
+ -I$(top_builddir)/../../libstdc++-v3/include \
+ -I$(top_srcdir)/../../libstdc++-v3/include \
+ -I$(top_srcdir)/../../libstdc++-v3/libsupc++
+
+libqtpeer_la_MOC = \
+ slotcallbacks.moc.h
+
+nodist_libqtpeer_la_SOURCES = \
+ $(libqtpeer_la_MOC)
+
+libqtpeer_la_SOURCES = \
+ buttonevent.h \
+ componentevent.cpp \
+ componentevent.h \
+ containers.h \
+ eventmethods.h \
+ keybindings.cpp \
+ keybindings.h \
+ mainqtthread.cpp \
+ mainthreadinterface.cpp \
+ mainthreadinterface.h \
+ nativewrapper.cpp \
+ nativewrapper.h \
+ qmatrix.cpp \
+ qpainterpath.cpp \
+ qpen.cpp \
+ qtaudioclip.cpp \
+ qtbuttonpeer.cpp \
+ qtcanvaspeer.cpp \
+ qtcheckboxpeer.cpp \
+ qtchoicepeer.cpp \
+ qtcomponent.cpp \
+ qtcomponent.h \
+ qtcomponentpeer.cpp \
+ qtdialogpeer.cpp \
+ qtembeddedwindowpeer.cpp \
+ qtfiledialogpeer.cpp \
+ qtfont.h \
+ qtfontmetrics.cpp \
+ qtfontpeer.cpp \
+ qtframepeer.cpp \
+ qtgraphics.cpp \
+ qtgraphics.h \
+ qtimage.cpp \
+ qtimage.h \
+ qtlabelpeer.cpp \
+ qtlistpeer.cpp \
+ qtmenubarpeer.cpp \
+ qtmenucomponentpeer.cpp \
+ qtmenuitempeer.cpp \
+ qtmenupeer.cpp \
+ qtpanelpeer.cpp \
+ qtpopupmenupeer.cpp \
+ qtscreendevice.cpp \
+ qtscrollbarpeer.cpp \
+ qtscrollpanepeer.cpp \
+ qtstrings.cpp \
+ qtstrings.h \
+ qttextareapeer.cpp \
+ qttextfieldpeer.cpp \
+ qttoolkit.cpp \
+ qtvolatileimage.cpp \
+ qtwindowpeer.cpp \
+ slotcallbacks.cpp \
+ slotcallbacks.h
+
+libqtpeer_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
+BUILT_SOURCES = $(libqtpeer_la_MOC)
+CLEANFILES = so_locations $(BUILT_SOURCES)
+all: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu native/jni/qt-peer/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu native/jni/qt-peer/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libqtpeer.la: $(libqtpeer_la_OBJECTS) $(libqtpeer_la_DEPENDENCIES)
+ $(libqtpeer_la_LINK) $(libqtpeer_la_OBJECTS) $(libqtpeer_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/componentevent.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keybindings.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mainqtthread.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mainthreadinterface.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nativewrapper.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qmatrix.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qpainterpath.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qpen.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtaudioclip.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtbuttonpeer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtcanvaspeer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtcheckboxpeer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtchoicepeer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtcomponent.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtcomponentpeer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtdialogpeer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtembeddedwindowpeer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtfiledialogpeer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtfontmetrics.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtfontpeer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtframepeer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtgraphics.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtimage.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtlabelpeer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtlistpeer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtmenubarpeer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtmenucomponentpeer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtmenuitempeer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtmenupeer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtpanelpeer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtpopupmenupeer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtscreendevice.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtscrollbarpeer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtscrollpanepeer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtstrings.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qttextareapeer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qttextfieldpeer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qttoolkit.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtvolatileimage.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/qtwindowpeer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slotcallbacks.Plo@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+check-am: all-am
+check: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+ -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: all check install install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags dvi dvi-am html html-am info info-am install \
+ install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am
+
+
+slotcallbacks.moc.h: slotcallbacks.cpp
+ $(MOC) -o slotcallbacks.moc.h $(srcdir)/slotcallbacks.cpp
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/libjava/classpath/native/jni/qt-peer/buttonevent.h b/libjava/classpath/native/jni/qt-peer/buttonevent.h
new file mode 100644
index 000000000..aab11dd03
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/buttonevent.h
@@ -0,0 +1,27 @@
+#ifndef BUTTONEVENT_H
+#define BUTTONEVENT_H
+
+#include <QAbstractButton>
+#include "mainthreadinterface.h"
+
+class AWTLabelEvent : public AWTEvent {
+
+ private:
+ QAbstractButton *widget;
+ QString *string;
+
+ public:
+ AWTLabelEvent(QAbstractButton *w, QString *s) : AWTEvent()
+ {
+ widget = w;
+ string = s;
+ }
+
+ void runEvent()
+ {
+ widget->setText( *string );
+ delete string;
+ }
+};
+
+#endif
diff --git a/libjava/classpath/native/jni/qt-peer/componentevent.cpp b/libjava/classpath/native/jni/qt-peer/componentevent.cpp
new file mode 100644
index 000000000..ae88af019
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/componentevent.cpp
@@ -0,0 +1,223 @@
+/* componentevent.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <QWidget>
+#include <QPoint>
+
+#include "componentevent.h"
+
+AWTInitEvent::AWTInitEvent(JNIEnv *env, jobject obj) : AWTEvent()
+{
+ env->GetJavaVM( &vm );
+ target = env->NewGlobalRef( obj );
+}
+
+void AWTInitEvent::runEvent()
+{
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ jclass targetCls = env->GetObjectClass( target );
+ // call init()
+ jmethodID mID = env->GetMethodID( targetCls,
+ "init",
+ "()V" );
+ env->CallVoidMethod( target, mID );
+
+ // call notify()
+ mID = env->GetMethodID( targetCls,
+ "notify",
+ "()V" );
+ assert(mID != NULL);
+ env->MonitorEnter( target );
+ env->CallVoidMethod( target, mID );
+ env->MonitorExit( target );
+
+ env->DeleteGlobalRef( target );
+}
+
+AWTShowEvent::AWTShowEvent(QWidget *w, bool v) : AWTEvent()
+{
+ widget = w;
+ visible = v;
+}
+
+void AWTShowEvent::runEvent()
+{
+ widget->setVisible( visible );
+}
+
+AWTEnableEvent::AWTEnableEvent(QWidget *w, bool v) : AWTEvent()
+{
+ widget = w;
+ enabled = v;
+}
+
+void AWTEnableEvent::runEvent()
+{
+ widget->setEnabled( enabled );
+}
+
+AWTCursorEvent::AWTCursorEvent(QWidget *w, Qt::CursorShape s) : AWTEvent()
+{
+ widget = w;
+ shape = s;
+}
+
+void AWTCursorEvent::runEvent()
+{
+ QCursor *s = new QCursor(shape);
+ widget->setCursor( *s );
+}
+
+AWTResizeEvent::AWTResizeEvent(QWidget *wid, int x0, int y0, int w0, int h0)
+{
+ widget = wid;
+ x = x0; y = y0;
+ w = w0; h = h0;
+ if(w == 0 && h == 0) w = h = 10;
+}
+
+void AWTResizeEvent::runEvent()
+{
+ QRect g = widget->geometry();
+ if(g.x() != x || g.y() != y || g.width() != w || g.height() != h)
+ widget->setGeometry( x, y, w, h );
+}
+
+AWTBackgroundEvent::AWTBackgroundEvent(QWidget *wid, bool fg, QColor *clr)
+{
+ widget = wid;
+ foreground = fg;
+ color = clr;
+}
+
+void AWTBackgroundEvent::runEvent()
+{
+ QPalette p = widget->palette();
+ if (foreground)
+ {
+ p.setColor(QPalette::Active, QPalette::Foreground, *color);
+ p.setColor(QPalette::Active, QPalette::Text, *color);
+ }
+ else
+ {
+ p.setColor(QPalette::Active, QPalette::Background, *color);
+ p.setColor(QPalette::Active, QPalette::Button, *color);
+ p.setColor(QPalette::Active, QPalette::Base, *color);
+ p.setColor(QPalette::Active, QPalette::AlternateBase, *color);
+ }
+ widget->setPalette(p);
+ widget->repaint();
+ delete color;
+}
+
+AWTGetOriginEvent::AWTGetOriginEvent(QWidget *w, JNIEnv *env, jobject obj) : AWTEvent()
+{
+ widget = w;
+ env->GetJavaVM( &vm );
+ target = env->NewGlobalRef( obj );
+}
+
+void AWTGetOriginEvent::runEvent()
+{
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ jclass targetCls = env->GetObjectClass( target );
+
+ QPoint *p = new QPoint( widget->mapToGlobal( QPoint(0, 0) ) );
+ // call init()
+ jmethodID mID = env->GetMethodID( targetCls,
+ "setLocation",
+ "(II)V" );
+ env->CallVoidMethod( target, mID, p->x(), p->y() );
+ delete p;
+
+ // call notify()
+ mID = env->GetMethodID( targetCls,
+ "notify",
+ "()V" );
+ assert(mID != NULL);
+ env->MonitorEnter( target );
+ env->CallVoidMethod( target, mID );
+ env->MonitorExit( target );
+
+ env->DeleteGlobalRef( target );
+}
+
+GetSizeEvent::GetSizeEvent(QWidget *w, JNIEnv *env, jobject obj, bool p) : AWTEvent()
+{
+ widget = w;
+ env->GetJavaVM( &vm );
+ target = env->NewGlobalRef( obj );
+ pref = p;
+}
+
+void GetSizeEvent::runEvent()
+{
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ jclass targetCls = env->GetObjectClass( target );
+
+ QPoint *p = new QPoint( widget->mapToGlobal( QPoint(0, 0) ) );
+ QSize s;
+ if( pref )
+ s = widget->sizeHint();
+ else
+ s = widget->minimumSizeHint();
+
+ // call init()
+ jmethodID mID = env->GetMethodID( targetCls,
+ "setSize",
+ "(II)V" );
+ env->CallVoidMethod( target, mID, s.width(), s.height() );
+
+ // call notify()
+ mID = env->GetMethodID( targetCls,
+ "notify",
+ "()V" );
+ assert(mID != NULL);
+ env->MonitorEnter( target );
+ env->CallVoidMethod( target, mID );
+ env->MonitorExit( target );
+
+ env->DeleteGlobalRef( target );
+}
+
+
+
+
diff --git a/libjava/classpath/native/jni/qt-peer/componentevent.h b/libjava/classpath/native/jni/qt-peer/componentevent.h
new file mode 100644
index 000000000..7cf2f2eac
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/componentevent.h
@@ -0,0 +1,203 @@
+#ifndef CALLBACKEVENT_H
+#define CALLBACKEVENT_H
+
+#include <jni.h>
+#include <QWidget>
+#include <QEvent>
+#include <QColor>
+#include <QCursor>
+#include <QFont>
+#include <QPoint>
+#include <QWidget>
+#include <QSize>
+
+#include "mainthreadinterface.h"
+
+class AWTInitEvent : public AWTEvent {
+
+ private:
+ JavaVM* vm;
+ jobject target;
+
+ public:
+ AWTInitEvent(JNIEnv *env, jobject obj);
+ void runEvent();
+};
+
+class AWTDestroyEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+
+ public:
+ AWTDestroyEvent(QWidget *w)
+ {
+ widget = w;
+ }
+
+ void runEvent()
+ {
+ if( widget != NULL )
+ delete widget;
+ }
+};
+
+class AWTFontEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ QFont *font;
+
+ public:
+ AWTFontEvent(QWidget *w, QFont *f)
+ {
+ widget = w;
+ font = f;
+ }
+
+ void runEvent()
+ {
+ widget->setFont( *font );
+ }
+};
+
+class AWTUpdateEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ int x,y,w,h;
+ bool updateAll;
+
+ public:
+ AWTUpdateEvent(QWidget *src, bool all, int x0, int y0, int w0, int h0)
+ {
+ widget = src;
+ updateAll = all;
+ x = x0; y = y0; w = w0; h = h0;
+ }
+
+ void runEvent()
+ {
+ if(updateAll)
+ widget->update();
+ else
+ widget->update(x,y,w,h);
+ }
+};
+
+class AWTShowEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ bool visible;
+
+ public:
+ AWTShowEvent(QWidget *w, bool v);
+ void runEvent();
+};
+
+class AWTEnableEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ bool enabled;
+
+ public:
+ AWTEnableEvent(QWidget *w, bool v);
+ void runEvent();
+};
+
+class AWTCursorEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ Qt::CursorShape shape;
+
+ public:
+ AWTCursorEvent(QWidget *w, Qt::CursorShape s);
+ void runEvent();
+};
+
+class AWTResizeEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ int x, y, w, h;
+
+ public:
+ AWTResizeEvent(QWidget *wid, int x0, int y0, int w0, int h0);
+ void runEvent();
+};
+
+class AWTBackgroundEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ bool foreground;
+ QColor *color;
+
+ public:
+ AWTBackgroundEvent(QWidget *wid, bool fg, QColor *clr);
+ void runEvent();
+};
+
+class AWTReqFocusEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+
+ public:
+ AWTReqFocusEvent(QWidget *w) : AWTEvent()
+ {
+ widget = w;
+ }
+ void runEvent()
+ {
+ widget->setFocus();
+ }
+};
+
+class AWTGetOriginEvent : public AWTEvent {
+
+ private:
+ JavaVM* vm;
+ jobject target;
+ QWidget *widget;
+
+ public:
+ AWTGetOriginEvent(QWidget *w, JNIEnv *env, jobject obj);
+ void runEvent();
+};
+
+class GetSizeEvent : public AWTEvent {
+
+ private:
+ JavaVM* vm;
+ jobject target;
+ QWidget *widget;
+ bool pref;
+
+ public:
+ GetSizeEvent(QWidget *w, JNIEnv *env, jobject obj, bool p);
+ void runEvent();
+};
+
+class AWTReparent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ QWidget *parent;
+
+ public:
+ AWTReparent(QWidget *w, QWidget *p) : AWTEvent()
+ {
+ widget = w;
+ parent = p;
+ }
+ void runEvent()
+ {
+ widget->setParent( parent );
+ }
+};
+
+#endif
diff --git a/libjava/classpath/native/jni/qt-peer/containers.h b/libjava/classpath/native/jni/qt-peer/containers.h
new file mode 100644
index 000000000..a2ae76af0
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/containers.h
@@ -0,0 +1,10 @@
+#ifndef QTFRAME_H
+#define QTFRAME_H
+
+#include <jni.h>
+#include <QWidget>
+
+QWidget *frameChildWidget( JNIEnv *env, jobject component );
+QWidget *scrollPaneChildWidget( JNIEnv *env, jobject component);
+
+#endif
diff --git a/libjava/classpath/native/jni/qt-peer/eventmethods.h b/libjava/classpath/native/jni/qt-peer/eventmethods.h
new file mode 100644
index 000000000..ae56da8e7
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/eventmethods.h
@@ -0,0 +1,245 @@
+/* eventmethods.cpp --
+ Copyright (C) 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. */
+
+#ifdef I_KNOW_WHAT_IM_DOING
+
+bool draw;
+
+private:
+ JavaVM* vm;
+ jobject target;
+ jclass componentCls;
+
+ void setup(JNIEnv *env, jobject obj)
+ {
+ env->GetJavaVM(&vm);
+ componentCls = NULL;
+ target = env->NewGlobalRef(obj);
+ componentCls = (jclass)env->NewGlobalRef(env->GetObjectClass( target ));
+ setMouseTracking( true );
+ draw = true;
+ }
+
+ void destroy()
+ {
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ env->DeleteGlobalRef(target);
+ env->DeleteGlobalRef(componentCls);
+ }
+
+ void callVoidMethod(const char *methodName)
+ {
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ jmethodID fireEventID = env->GetMethodID( componentCls,
+ methodName,
+ "()V" );
+ env->CallVoidMethod( target, fireEventID );
+ }
+
+ void callMouseMethod(const char *methodName,
+ int modifiers, int x, int y, int clickCount)
+ {
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ jmethodID fireEventID = env->GetMethodID( componentCls,
+ methodName,
+ "(IIII)V" );
+ env->CallVoidMethod( target, fireEventID, modifiers, x, y, clickCount );
+ }
+
+protected:
+
+ void closeEvent( QCloseEvent *e )
+ {
+ PARENT::closeEvent(e);
+ callVoidMethod("closeEvent");
+ }
+
+ void focusInEvent( QFocusEvent *e )
+ {
+ PARENT::focusInEvent(e);
+ callVoidMethod("focusInEvent");
+ }
+
+ void focusOutEvent( QFocusEvent *e )
+ {
+ PARENT::focusOutEvent(e);
+ callVoidMethod("focusOutEvent");
+ }
+
+ void enterEvent( QEvent *e )
+ {
+ PARENT::enterEvent(e);
+ QPoint p = mapFromGlobal( QCursor::pos() );
+ int modifiers = getKeyModifiers( QApplication::keyboardModifiers() );
+ callMouseMethod("enterEvent", modifiers, p.x(), p.y(), 0);
+ }
+
+ void keyPressEvent( QKeyEvent *e )
+ {
+ PARENT::keyPressEvent(e);
+ int modifiers, x, y;
+ modifiers = getKeyModifiers(e->modifiers());
+ x = mapKeyCode(e);
+ y = getUnicode(e);
+ callMouseMethod("keyPressEvent", modifiers, x, y, 0);
+ }
+
+ void keyReleaseEvent( QKeyEvent *e )
+ {
+ PARENT::keyReleaseEvent(e);
+ int modifiers, x, y;
+ modifiers = getKeyModifiers(e->modifiers());
+ x = mapKeyCode(e);
+ y = getUnicode(e);
+ callMouseMethod("keyReleaseEvent", modifiers, x, y, 0);
+ }
+
+ void leaveEvent( QEvent *e )
+ {
+ PARENT::leaveEvent(e);
+ QPoint p = mapFromGlobal( QCursor::pos() );
+ int modifiers = getKeyModifiers( QApplication::keyboardModifiers() );
+ callMouseMethod("leaveEvent", modifiers, p.x(), p.y(), 0);
+ }
+
+ void mouseDoubleClickEvent( QMouseEvent *e )
+ {
+ PARENT::mouseDoubleClickEvent(e);
+ int modifiers, x, y, clickCount;
+ clickCount = 2;
+ modifiers = getMouseModifiers(e);
+ x = e->x();
+ y = e->y();
+ callMouseMethod("mouseDoubleClickEvent", modifiers, x, y, clickCount);
+ }
+
+ void mouseMoveEvent( QMouseEvent *e )
+ {
+ PARENT::mouseMoveEvent(e);
+ int modifiers, x, y, clickCount;
+ clickCount = 0;
+ modifiers = getMouseModifiers(e);
+ x = e->x();
+ y = e->y();
+ callMouseMethod("mouseMoveEvent", modifiers, x, y, clickCount);
+ }
+
+ void mousePressEvent( QMouseEvent *e )
+ {
+ PARENT::mousePressEvent(e);
+ int modifiers, x, y, clickCount;
+ clickCount = 0;
+ modifiers = getMouseModifiers(e);
+ x = e->x();
+ y = e->y();
+ callMouseMethod("mousePressEvent", modifiers, x, y, clickCount);
+ }
+
+ void mouseReleaseEvent( QMouseEvent *e )
+ {
+ PARENT::mouseReleaseEvent(e);
+ int modifiers, x, y, clickCount;
+ modifiers = 0;
+
+ modifiers |= getReleaseModifiers( e );
+ x = e->x();
+ y = e->y();
+ callMouseMethod("mouseReleaseEvent", modifiers, x, y, 0);
+ }
+
+ void moveEvent( QMoveEvent *e )
+ {
+ PARENT::moveEvent(e);
+ callMouseMethod("moveEvent", e->pos().x(), e->pos().y(),
+ e->oldPos().x(), e->oldPos().y());
+ }
+
+ void resizeEvent( QResizeEvent *e )
+ {
+ PARENT::resizeEvent(e);
+ callMouseMethod("resizeEvent",
+ e->oldSize().width(), e->oldSize().height(),
+ e->size().width(), e->size().height());
+ }
+
+ void hideEvent( QHideEvent *e )
+ {
+ PARENT::hideEvent(e);
+ callVoidMethod("hideEvent");
+ }
+
+ void showEvent( QShowEvent *e )
+ {
+ PARENT::showEvent(e);
+ callVoidMethod("showEvent");
+ }
+
+ void paintEvent ( QPaintEvent * e )
+ {
+ PARENT::paintEvent( e );
+ if ( draw )
+ {
+ // Create a QPainter
+ GraphicsPainter painter( this );
+ int x, y, w, h;
+ e->rect().getRect ( &x, &y, &w, &h );
+
+ // Get the environment.
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+
+ // create a QtGraphics wrapper for the QPainter
+ jclass cls = env->FindClass( "gnu/java/awt/peer/qt/QtComponentGraphics" );
+ jmethodID mid = env->GetMethodID(cls, "<init>", "(JLgnu/java/awt/peer/qt/QtComponentPeer;IIII)V");
+ jobject graphics = env->NewObject(cls, mid, (jlong)&painter, target,
+ (jint)x, (jint)y, (jint)w, (jint)h);
+
+ // call QtComponentPeer.paintEvent()
+ jmethodID paintEventID = env->GetMethodID( componentCls,
+ "paint",
+ "(Ljava/awt/Graphics;)V" );
+ env->CallVoidMethod( target, paintEventID, graphics );
+ env->DeleteLocalRef( cls );
+ env->DeleteLocalRef( graphics );
+ painter.end();
+ }
+ }
+
+#endif
diff --git a/libjava/classpath/native/jni/qt-peer/keybindings.cpp b/libjava/classpath/native/jni/qt-peer/keybindings.cpp
new file mode 100644
index 000000000..f18616689
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/keybindings.cpp
@@ -0,0 +1,600 @@
+/* keybindings.cpp --
+ Copyright (C) 2005 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. */
+
+#include "keybindings.h"
+
+/* InputEvent key modifiers */
+#define SHIFT_MASK 1
+#define CTRL_MASK 2
+#define META_MASK 4
+#define ALT_MASK 8
+#define ALT_GRAPH_MASK 0x20
+#define BUTTON1_MASK 0x10
+#define BUTTON2_MASK 8
+#define BUTTON3_MASK 4
+
+#define SHIFT_DOWN_MASK 0x0040
+#define CTRL_DOWN_MASK 0x0080
+#define META_DOWN_MASK 0x0100
+#define ALT_DOWN_MASK 0x0200
+#define BUTTON1_DOWN_MASK 0x0400
+#define BUTTON2_DOWN_MASK 0x0800
+#define BUTTON3_DOWN_MASK 0x1000
+#define ALT_GRAPH_DOWN_MASK 0x2000
+
+/* Virtual Keys */
+/* This list should be kept in the same order as the VK_ field
+ declarations in KeyEvent.java. */
+#define VK_ENTER '\n'
+#define VK_BACK_SPACE '\b'
+#define VK_TAB '\t'
+#define VK_CANCEL 3
+#define VK_CLEAR 12
+#define VK_SHIFT 16
+#define VK_CONTROL 17
+#define VK_ALT 18
+#define VK_PAUSE 19
+#define VK_CAPS_LOCK 20
+#define VK_ESCAPE 27
+#define VK_SPACE ' '
+#define VK_PAGE_UP 33
+#define VK_PAGE_DOWN 34
+#define VK_END 35
+#define VK_HOME 36
+#define VK_LEFT 37
+#define VK_UP 38
+#define VK_RIGHT 39
+#define VK_DOWN 40
+#define VK_COMMA ','
+#define VK_MINUS '-'
+#define VK_PERIOD '.'
+#define VK_SLASH '/'
+#define VK_0 '0'
+#define VK_1 '1'
+#define VK_2 '2'
+#define VK_3 '3'
+#define VK_4 '4'
+#define VK_5 '5'
+#define VK_6 '6'
+#define VK_7 '7'
+#define VK_8 '8'
+#define VK_9 '9'
+#define VK_SEMICOLON ';'
+#define VK_EQUALS '='
+#define VK_A 'A'
+#define VK_B 'B'
+#define VK_C 'C'
+#define VK_D 'D'
+#define VK_E 'E'
+#define VK_F 'F'
+#define VK_G 'G'
+#define VK_H 'H'
+#define VK_I 'I'
+#define VK_J 'J'
+#define VK_K 'K'
+#define VK_L 'L'
+#define VK_M 'M'
+#define VK_N 'N'
+#define VK_O 'O'
+#define VK_P 'P'
+#define VK_Q 'Q'
+#define VK_R 'R'
+#define VK_S 'S'
+#define VK_T 'T'
+#define VK_U 'U'
+#define VK_V 'V'
+#define VK_W 'W'
+#define VK_X 'X'
+#define VK_Y 'Y'
+#define VK_Z 'Z'
+#define VK_OPEN_BRACKET '['
+#define VK_BACK_SLASH '\\'
+#define VK_CLOSE_BRACKET ']'
+#define VK_NUMPAD0 96
+#define VK_NUMPAD1 97
+#define VK_NUMPAD2 98
+#define VK_NUMPAD3 99
+#define VK_NUMPAD4 100
+#define VK_NUMPAD5 101
+#define VK_NUMPAD6 102
+#define VK_NUMPAD7 103
+#define VK_NUMPAD8 104
+#define VK_NUMPAD9 105
+#define VK_MULTIPLY 106
+#define VK_ADD 107
+#define VK_SEPARATER 108
+#define VK_SEPARATOR 108
+#define VK_SUBTRACT 109
+#define VK_DECIMAL 110
+#define VK_DIVIDE 111
+#define VK_DELETE 127
+#define VK_NUM_LOCK 144
+#define VK_SCROLL_LOCK 145
+#define VK_F1 112
+#define VK_F2 113
+#define VK_F3 114
+#define VK_F4 115
+#define VK_F5 116
+#define VK_F6 117
+#define VK_F7 118
+#define VK_F8 119
+#define VK_F9 120
+#define VK_F10 121
+#define VK_F11 122
+#define VK_F12 123
+#define VK_F13 61440
+#define VK_F14 61441
+#define VK_F15 61442
+#define VK_F16 61443
+#define VK_F17 61444
+#define VK_F18 61445
+#define VK_F19 61446
+#define VK_F20 61447
+#define VK_F21 61448
+#define VK_F22 61449
+#define VK_F23 61450
+#define VK_F24 61451
+#define VK_PRINTSCREEN 154
+#define VK_INSERT 155
+#define VK_HELP 156
+#define VK_META 157
+#define VK_BACK_QUOTE 192
+#define VK_QUOTE 222
+#define VK_KP_UP 224
+#define VK_KP_DOWN 225
+#define VK_KP_LEFT 226
+#define VK_KP_RIGHT 227
+#define VK_DEAD_GRAVE 128
+#define VK_DEAD_ACUTE 129
+#define VK_DEAD_CIRCUMFLEX 130
+#define VK_DEAD_TILDE 131
+#define VK_DEAD_MACRON 132
+#define VK_DEAD_BREVE 133
+#define VK_DEAD_ABOVEDOT 134
+#define VK_DEAD_DIAERESIS 135
+#define VK_DEAD_ABOVERING 136
+#define VK_DEAD_DOUBLEACUTE 137
+#define VK_DEAD_CARON 138
+#define VK_DEAD_CEDILLA 139
+#define VK_DEAD_OGONEK 140
+#define VK_DEAD_IOTA 141
+#define VK_DEAD_VOICED_SOUND 142
+#define VK_DEAD_SEMIVOICED_SOUND 143
+#define VK_AMPERSAND 150
+#define VK_ASTERISK 151
+#define VK_QUOTEDBL 152
+#define VK_LESS 153
+#define VK_GREATER 160
+#define VK_BRACELEFT 161
+#define VK_BRACERIGHT 162
+#define VK_AT 512
+#define VK_COLON 513
+#define VK_CIRCUMFLEX 514
+#define VK_DOLLAR 515
+#define VK_EURO_SIGN 516
+#define VK_EXCLAMATION_MARK 517
+#define VK_INVERTED_EXCLAMATION_MARK 518
+#define VK_LEFT_PARENTHESIS 519
+#define VK_NUMBER_SIGN 520
+#define VK_PLUS 521
+#define VK_RIGHT_PARENTHESIS 522
+#define VK_UNDERSCORE 523
+#define VK_FINAL 24
+#define VK_CONVERT 28
+#define VK_NONCONVERT 29
+#define VK_ACCEPT 30
+#define VK_MODECHANGE 31
+#define VK_KANA 21
+#define VK_KANJI 25
+#define VK_ALPHANUMERIC 240
+#define VK_KATAKANA 241
+#define VK_HIRAGANA 242
+#define VK_FULL_WIDTH 243
+#define VK_HALF_WIDTH 244
+#define VK_ROMAN_CHARACTERS 245
+#define VK_ALL_CANDIDATES 256
+#define VK_PREVIOUS_CANDIDATE 257
+#define VK_CODE_INPUT 258
+#define VK_JAPANESE_KATAKANA 259
+#define VK_JAPANESE_HIRAGANA 260
+#define VK_JAPANESE_ROMAN 261
+#define VK_KANA_LOCK 262
+#define VK_INPUT_METHOD_ON_OFF 263
+#define VK_CUT 65489
+#define VK_COPY 65485
+#define VK_PASTE 65487
+#define VK_UNDO 65483
+#define VK_AGAIN 65481
+#define VK_FIND 65488
+#define VK_PROPS 65482
+#define VK_STOP 65480
+#define VK_COMPOSE 65312
+#define VK_ALT_GRAPH 65406
+#define VK_UNDEFINED 0
+
+
+int mapKeyCode(QKeyEvent *key)
+{
+ switch(key->key())
+ {
+ case Qt::Key_Escape:
+ return VK_ESCAPE;
+ case Qt::Key_Tab:
+ return VK_TAB;
+ case Qt::Key_Backspace:
+ return VK_BACK_SPACE;
+ case Qt::Key_Return:
+ case Qt::Key_Enter:
+ return VK_ENTER;
+ case Qt::Key_Insert:
+ return VK_INSERT;
+ case Qt::Key_Delete:
+ return VK_DELETE;
+ case Qt::Key_Pause:
+ return VK_PAUSE;
+ case Qt::Key_Print:
+ case Qt::Key_SysReq:
+ return VK_PRINTSCREEN;
+ case Qt::Key_Home:
+ return VK_HOME;
+ case Qt::Key_End:
+ return VK_END;
+ case Qt::Key_Left:
+ return VK_LEFT;
+ case Qt::Key_Up:
+ return VK_UP;
+ case Qt::Key_Right:
+ return VK_RIGHT;
+ case Qt::Key_Down:
+ return VK_DOWN;
+ case Qt::Key_PageUp:
+ return VK_PAGE_UP;
+ case Qt::Key_PageDown:
+ return VK_PAGE_DOWN;
+ case Qt::Key_Shift:
+ return VK_SHIFT;
+ case Qt::Key_Control:
+ return VK_CONTROL;
+ case Qt::Key_Meta:
+ return VK_META;
+ case Qt::Key_Alt:
+ return VK_ALT;
+ case Qt::Key_CapsLock:
+ return VK_CAPS_LOCK;
+ case Qt::Key_NumLock:
+ return VK_NUM_LOCK;
+ case Qt::Key_ScrollLock:
+ return VK_SCROLL_LOCK;
+ case Qt::Key_Clear:
+ return VK_CLEAR;
+ case Qt::Key_F1:
+ return VK_F1;
+ case Qt::Key_F2:
+ return VK_F2;
+ case Qt::Key_F3:
+ return VK_F3;
+ case Qt::Key_F4:
+ return VK_F4;
+ case Qt::Key_F5:
+ return VK_F5;
+ case Qt::Key_F6:
+ return VK_F6;
+ case Qt::Key_F7:
+ return VK_F7;
+ case Qt::Key_F8:
+ return VK_F8;
+ case Qt::Key_F9:
+ return VK_F9;
+ case Qt::Key_F10:
+ return VK_F10;
+ case Qt::Key_F11:
+ return VK_F11;
+ case Qt::Key_F12:
+ return VK_F12;
+ case Qt::Key_F13:
+ return VK_F13;
+ case Qt::Key_F14:
+ return VK_F14;
+ case Qt::Key_F15:
+ return VK_F15;
+ case Qt::Key_F16:
+ return VK_F16;
+ case Qt::Key_F17:
+ return VK_F17;
+ case Qt::Key_F18:
+ return VK_F18;
+ case Qt::Key_F19:
+ return VK_F19;
+ case Qt::Key_F20:
+ return VK_F20;
+ case Qt::Key_F21:
+ return VK_F21;
+ case Qt::Key_F22:
+ return VK_F22;
+ case Qt::Key_F23:
+ return VK_F23;
+ case Qt::Key_F24:
+ return VK_F24;
+ case Qt::Key_Help:
+ return VK_HELP;
+
+ case Qt::Key_Space:
+ return VK_SPACE;
+
+ case Qt::Key_Exclam:
+ return VK_EXCLAMATION_MARK;
+ case Qt::Key_QuoteDbl:
+ return VK_QUOTEDBL;
+ case Qt::Key_NumberSign:
+ return VK_NUMBER_SIGN;
+
+ case Qt::Key_Dollar:
+ return VK_DOLLAR;
+
+
+ case Qt::Key_Ampersand:
+ return VK_AMPERSAND;
+
+ case Qt::Key_ParenLeft:
+ return VK_LEFT_PARENTHESIS;
+ case Qt::Key_ParenRight:
+ return VK_RIGHT_PARENTHESIS;
+ case Qt::Key_Asterisk:
+ return VK_ASTERISK;
+ case Qt::Key_Plus:
+ return VK_PLUS;
+ case Qt::Key_Comma:
+ return VK_COMMA;
+ case Qt::Key_Minus:
+ return VK_MINUS;
+ case Qt::Key_Period:
+ return VK_PERIOD;
+ case Qt::Key_Slash:
+ return VK_SLASH;
+
+ case Qt::Key_0:
+ return VK_0;
+ case Qt::Key_1:
+ return VK_1;
+ case Qt::Key_2:
+ return VK_2;
+ case Qt::Key_3:
+ return VK_3;
+ case Qt::Key_4:
+ return VK_4;
+ case Qt::Key_5:
+ return VK_5 ;
+ case Qt::Key_6:
+ return VK_6;
+ case Qt::Key_7:
+ return VK_7;
+ case Qt::Key_8:
+ return VK_8;
+ case Qt::Key_9:
+ return VK_9;
+
+ case Qt::Key_Colon:
+ return VK_COLON;
+ case Qt::Key_Semicolon:
+ return VK_SEMICOLON;
+ case Qt::Key_Less:
+ return VK_LESS;
+ case Qt::Key_Equal:
+ return VK_EQUALS;
+ case Qt::Key_Greater:
+ return VK_GREATER;
+ case Qt::Key_Question:
+ case Qt::Key_At:
+
+ case Qt::Key_A:
+ return VK_A;
+ case Qt::Key_B:
+ return VK_B;
+ case Qt::Key_C:
+ return VK_C;
+ case Qt::Key_D:
+ return VK_D;
+ case Qt::Key_E:
+ return VK_E;
+ case Qt::Key_F:
+ return VK_F;
+ case Qt::Key_G:
+ return VK_G;
+ case Qt::Key_H:
+ return VK_H;
+ case Qt::Key_I:
+ return VK_I;
+ case Qt::Key_J:
+ return VK_J;
+ case Qt::Key_K:
+ return VK_K;
+ case Qt::Key_L:
+ return VK_L;
+ case Qt::Key_M:
+ return VK_M;
+ case Qt::Key_N:
+ return VK_N;
+ case Qt::Key_O:
+ return VK_O;
+ case Qt::Key_P:
+ return VK_P;
+ case Qt::Key_Q:
+ return VK_Q;
+ case Qt::Key_R:
+ return VK_R;
+ case Qt::Key_S:
+ return VK_S;
+ case Qt::Key_T:
+ return VK_T;
+ case Qt::Key_U:
+ return VK_U;
+ case Qt::Key_V:
+ return VK_V;
+ case Qt::Key_W:
+ return VK_W;
+ case Qt::Key_X:
+ return VK_X;
+ case Qt::Key_Y:
+ return VK_Y;
+ case Qt::Key_Z:
+ return VK_Z;
+ case Qt::Key_division:
+ return VK_DIVIDE;
+ case Qt::Key_BracketLeft:
+ return VK_OPEN_BRACKET;
+ case Qt::Key_Backslash:
+ return VK_BACK_SLASH;
+ case Qt::Key_BracketRight:
+ return VK_CLOSE_BRACKET;
+ case Qt::Key_BraceLeft:
+ return VK_BRACELEFT;
+ case Qt::Key_BraceRight:
+ return VK_BRACERIGHT;
+ case Qt::Key_brokenbar:
+ return VK_SEPARATOR; // correct?
+
+ default:
+ return VK_UNDEFINED;
+ }
+}
+
+int getUnicode(QKeyEvent *key)
+{
+ QString s = key->text();
+ if(s.isEmpty())
+ return 0; // CHAR_UNDEFINED
+ QChar c = s.at(0);
+ return (int)c.unicode();
+}
+
+/**
+ * Returns the key modifiers in KeyEvent format
+ */
+int getKeyModifiers(Qt::KeyboardModifiers state)
+{
+ int modifier = 0;
+ if( state & Qt::ShiftModifier )
+ modifier |= SHIFT_DOWN_MASK;
+ if( state & Qt::ControlModifier )
+ modifier |= CTRL_DOWN_MASK;
+ if( state & Qt::AltModifier )
+ modifier |= ALT_DOWN_MASK;
+ if( state & Qt::MetaModifier )
+ modifier |= META_DOWN_MASK;
+
+ return modifier;
+}
+
+/**
+ * Returns the key modifiers in ActionEvent format
+ */
+int getAEKeyModifiers(Qt::KeyboardModifiers state)
+{
+ int modifier = 0;
+ if( state & Qt::ShiftModifier )
+ modifier |= SHIFT_MASK;
+ if( state & Qt::ControlModifier )
+ modifier |= CTRL_MASK;
+ if( state & Qt::AltModifier )
+ modifier |= ALT_MASK;
+ if( state & Qt::MetaModifier )
+ modifier |= META_MASK;
+
+ return modifier;
+}
+
+/**
+ * Returns the mouse modifiers in InputEvent format
+ */
+int getMouseModifiers(QMouseEvent *e)
+{
+ int modifier = 0;
+ int buttons = e->buttons();
+ int state = e->modifiers();
+
+ if( buttons & Qt::LeftButton )
+ modifier |= BUTTON1_DOWN_MASK;
+ if( buttons & Qt::MidButton )
+ modifier |= BUTTON2_DOWN_MASK;
+ if( buttons & Qt::RightButton )
+ modifier |= BUTTON3_DOWN_MASK;
+
+ if( state & Qt::ShiftModifier )
+ modifier |= SHIFT_DOWN_MASK;
+ if( state & Qt::ControlModifier )
+ modifier |= CTRL_DOWN_MASK;
+ if( state & Qt::AltModifier )
+ modifier |= ALT_DOWN_MASK;
+ if( state & Qt::MetaModifier )
+ modifier |= META_DOWN_MASK;
+
+ // FIXME: Alt Gr?
+ return modifier;
+}
+
+/**
+ * Returns the mouse modifiers in InputEvent format
+ * We need a different method here because e->buttons() doesn't work for,
+ * mouseReleased events. (But strangely enough it does for pressed ones)
+ */
+int getReleaseModifiers(QMouseEvent *e)
+{
+ int modifier = 0;
+ int button = e->button();
+ int state = e->modifiers();
+
+ if( button & Qt::LeftButton )
+ modifier |= BUTTON1_DOWN_MASK;
+ if( button & Qt::MidButton )
+ modifier |= BUTTON2_DOWN_MASK;
+ if( button & Qt::RightButton )
+ modifier |= BUTTON3_DOWN_MASK;
+
+ if( state & Qt::ShiftModifier )
+ modifier |= SHIFT_DOWN_MASK;
+ if( state & Qt::ControlModifier )
+ modifier |= CTRL_DOWN_MASK;
+ if( state & Qt::AltModifier )
+ modifier |= ALT_DOWN_MASK;
+ if( state & Qt::MetaModifier )
+ modifier |= META_DOWN_MASK;
+
+ // FIXME: Alt Gr?
+ return modifier;
+}
+
+
diff --git a/libjava/classpath/native/jni/qt-peer/keybindings.h b/libjava/classpath/native/jni/qt-peer/keybindings.h
new file mode 100644
index 000000000..cdf761f61
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/keybindings.h
@@ -0,0 +1,20 @@
+#ifndef KEYBINDINGS_H
+#define KEYBINDINGS_H
+
+#include <QApplication>
+#include <QKeyEvent>
+#include <QMouseEvent>
+#include <QPainter>
+#include <QPoint>
+#include <qwidget.h>
+#include <qstring.h>
+#include "qtgraphics.h"
+
+int mapKeyCode(QKeyEvent *key);
+int getUnicode(QKeyEvent *key);
+int getKeyModifiers(Qt::KeyboardModifiers state);
+int getAEKeyModifiers(Qt::KeyboardModifiers state);
+int getMouseModifiers(QMouseEvent *event);
+int getReleaseModifiers(QMouseEvent *e);
+
+#endif
diff --git a/libjava/classpath/native/jni/qt-peer/mainqtthread.cpp b/libjava/classpath/native/jni/qt-peer/mainqtthread.cpp
new file mode 100644
index 000000000..19566c63b
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/mainqtthread.cpp
@@ -0,0 +1,104 @@
+/* mainqtthread.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <jni.h>
+#include <QApplication>
+#include <QThread>
+#include <gnu_java_awt_peer_qt_MainQtThread.h>
+#include "mainthreadinterface.h"
+
+MainThreadInterface *mainThread;
+QApplication *qApplication;
+
+
+/**
+ * Starts up a QApplication
+ */
+JNIEXPORT jlong JNICALL Java_gnu_java_awt_peer_qt_MainQtThread_init
+(JNIEnv *env, jobject obj, jstring theme, jboolean doublebuffer)
+{
+ int *argc;
+ char **argv;
+
+ if(theme != NULL)
+ {
+ argc = (int*)malloc(sizeof(int));
+ *argc = 3;
+ argv = (char **)malloc( 3 * sizeof(char *) );
+ argv[0] = (char *)malloc(10 * sizeof(char));
+ argv[1] = (char *)malloc(10 * sizeof(char));
+ argv[2] = (char *)malloc(100 * sizeof(char));
+ strncpy(argv[0], "\0", 2);
+ strncpy(argv[1], "-style\0", 8);
+ strncpy(argv[2], (char *)env->GetStringUTFChars( theme, NULL ), 100);
+ }
+ else
+ {
+ argc = (int*)malloc(sizeof(int));
+ *argc = 1;
+ argv = (char **)malloc( 3 * sizeof(char *) );
+ argv[0] = (char *)malloc(10 * sizeof(char));
+ strncpy(argv[0], " \0", 3);
+ }
+ QApplication *qtApp = new QApplication( *argc, argv );
+ assert( qtApp );
+
+ qApplication = qtApp;
+
+ if( theme != NULL)
+ env->ReleaseStringUTFChars( theme, argv[1] );
+
+ mainThread = new MainThreadInterface( qtApp );
+
+ jclass cls = env->GetObjectClass(obj);
+ jfieldID nofid = env->GetFieldID( cls, "mainThreadInterface", "J" );
+ env->SetLongField( obj, nofid, (jlong)mainThread );
+
+ return (jlong)qtApp;
+}
+
+/*
+ * Calls QApplication::exec()
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_MainQtThread_exec
+(JNIEnv *env, jobject obj, jlong ptr)
+{
+ QApplication *app = (QApplication *)ptr;
+ if(app)
+ app->exec();
+}
diff --git a/libjava/classpath/native/jni/qt-peer/mainthreadinterface.cpp b/libjava/classpath/native/jni/qt-peer/mainthreadinterface.cpp
new file mode 100644
index 000000000..3c197ad19
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/mainthreadinterface.cpp
@@ -0,0 +1,69 @@
+/* mainthreadinterface.cpp --
+ Copyright (C) 2005 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. */
+
+#include <QWidget>
+#include <QThread>
+#include "mainthreadinterface.h"
+
+MainThreadInterface::MainThreadInterface(QApplication *parent) : QObject( parent )
+{
+ mainApp = parent;
+}
+
+/**
+ * This is called from the main Qt event loop, and delegates the work to
+ * the AWTEvent runEvent method.
+ */
+bool MainThreadInterface::event ( QEvent * e )
+{
+ QObject::event( e );
+ if( e->type() == QEvent::User)
+ {
+ AWTEvent *fe = (AWTEvent *)e;
+ fe->runEvent();
+ }
+ return true;
+}
+
+/**
+ * Posts the event to the main Qt event loop for execution.
+ */
+void MainThreadInterface::postEventToMain(AWTEvent *event)
+{
+ mainApp->postEvent(this, event);
+}
+
diff --git a/libjava/classpath/native/jni/qt-peer/mainthreadinterface.h b/libjava/classpath/native/jni/qt-peer/mainthreadinterface.h
new file mode 100644
index 000000000..e17b78652
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/mainthreadinterface.h
@@ -0,0 +1,36 @@
+#ifndef MAINTHREADINTERFACE_H
+#define MAINTHREADINTERFACE_H
+
+#include <jni.h>
+#include <QApplication>
+#include <QObject>
+#include <QWidget>
+#include <QEvent>
+
+class AWTEvent : public QEvent {
+
+ public:
+ AWTEvent() : QEvent( QEvent::User )
+ {
+ }
+
+ virtual void runEvent()
+ {
+ }
+
+};
+
+class MainThreadInterface : public QObject {
+
+ private:
+ QApplication *mainApp;
+
+ public:
+ MainThreadInterface(QApplication *parent);
+ bool event ( QEvent * e );
+ void postEventToMain(AWTEvent *event);
+};
+
+extern MainThreadInterface *mainThread;
+
+#endif
diff --git a/libjava/classpath/native/jni/qt-peer/nativewrapper.cpp b/libjava/classpath/native/jni/qt-peer/nativewrapper.cpp
new file mode 100644
index 000000000..0dec02c96
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/nativewrapper.cpp
@@ -0,0 +1,64 @@
+/* nativewrapper.cpp --
+ Copyright (C) 2005 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. */
+
+#include "nativewrapper.h"
+
+#define WRAPPER_CLASS "gnu/java/awt/peer/qt/NativeWrapper"
+
+/*
+ * Sets the native object field.
+ */
+void setNativeObject( JNIEnv *env, jobject qtcomponent, void *ptr )
+{
+ jclass cls = env->GetObjectClass( qtcomponent );
+ jlong value = (jlong) ptr;
+ jfieldID nofid = env->GetFieldID( cls, "nativeObject", "J" );
+ env->SetLongField( qtcomponent, nofid, value );
+ env->DeleteLocalRef( cls );
+}
+
+/**
+ * Gets the native object field.
+ */
+void *getNativeObject( JNIEnv *env, jobject qtcomponent )
+{
+ jclass cls = env->GetObjectClass( qtcomponent );
+ jfieldID nofid = env->GetFieldID( cls, "nativeObject", "J" );
+ jlong value = env->GetLongField( qtcomponent, nofid );
+ env->DeleteLocalRef( cls );
+ return (void *) value;
+}
diff --git a/libjava/classpath/native/jni/qt-peer/nativewrapper.h b/libjava/classpath/native/jni/qt-peer/nativewrapper.h
new file mode 100644
index 000000000..1207aa1d3
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/nativewrapper.h
@@ -0,0 +1,10 @@
+#ifndef NATIVEWRAPPER_H
+#define NATIVEWRAPPER_H
+
+#include <jni.h>
+
+void *getNativeObject( JNIEnv *env, jobject qtcomponent );
+
+void setNativeObject( JNIEnv *env, jobject qtcomponent, void *ptr );
+
+#endif
diff --git a/libjava/classpath/native/jni/qt-peer/qmatrix.cpp b/libjava/classpath/native/jni/qt-peer/qmatrix.cpp
new file mode 100644
index 000000000..4b99ae7ab
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qmatrix.cpp
@@ -0,0 +1,96 @@
+/* qmatrix.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <QMatrix>
+#include <gnu_java_awt_peer_qt_QMatrix.h>
+#include "nativewrapper.h"
+
+/*
+ * Creates a QMatrix
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QMatrix_init
+(JNIEnv *env, jobject obj, jdouble m00, jdouble m10, jdouble m01, jdouble m11,
+ jdouble m02, jdouble m12 )
+{
+ QMatrix *matrix = new QMatrix( (qreal) m00, (qreal) m10,
+ (qreal) m01, (qreal) m11,
+ (qreal) m02, (qreal) m12 );
+ assert( matrix );
+ setNativeObject(env, obj, matrix);
+}
+
+/*
+ * Returns the matrix a java array of doubles,
+ * in m00, m10, m01, m11, m02, m12 (java notation) format.
+ * Note that qt has different notations for the array elements.
+ */
+JNIEXPORT jdoubleArray JNICALL Java_gnu_java_awt_peer_qt_QMatrix_getMatrix
+(JNIEnv *env, jobject obj)
+{
+ QMatrix *matrix = (QMatrix *)getNativeObject(env, obj);
+ assert( matrix );
+
+ jdoubleArray result_array;
+ jdouble *dst;
+
+ result_array = env->NewDoubleArray( 6 );
+ dst = env->GetDoubleArrayElements(result_array, NULL);
+
+ dst[0] = (jdouble)matrix->m11(); // qt m11 = java m00
+ dst[1] = (jdouble)matrix->m12(); // qt m12 = java m10
+ dst[2] = (jdouble)matrix->m21(); // qt m21 = java m01
+ dst[3] = (jdouble)matrix->m22(); // qt m22 = java m11
+ dst[4] = (jdouble)matrix->dx(); // qt dx = java m02
+ dst[5] = (jdouble)matrix->dy(); // qt dy = java m12
+
+ env->ReleaseDoubleArrayElements (result_array, dst, 0);
+ return result_array;
+}
+
+/*
+ * Dispose of the thing.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QMatrix_dispose
+(JNIEnv *env, jobject obj)
+{
+ QMatrix *matrix = (QMatrix *)getNativeObject(env, obj);
+ if( matrix )
+ delete matrix;
+ setNativeObject(env, obj, NULL);
+}
+
diff --git a/libjava/classpath/native/jni/qt-peer/qpainterpath.cpp b/libjava/classpath/native/jni/qt-peer/qpainterpath.cpp
new file mode 100644
index 000000000..cfe9eeae9
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qpainterpath.cpp
@@ -0,0 +1,239 @@
+/* qpainterpath.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <QPainterPath>
+#include <gnu_java_awt_peer_qt_QPainterPath.h>
+#include "nativewrapper.h"
+
+// java.awt.geom.PathIterator constants.
+#define WIND_EVEN_ODD 0
+#define WIND_NON_ZERO 1
+
+
+/*
+ * Creates an empty QPainterPath.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_init
+(JNIEnv *env, jobject obj, jint windingRule)
+{
+ QPainterPath *path = new QPainterPath();
+ assert( path );
+ path->setFillRule( (windingRule == WIND_EVEN_ODD) ?
+ Qt::OddEvenFill : Qt::WindingFill );
+ setNativeObject(env, obj, path);
+}
+
+/*
+ * MoveTo
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_moveTo
+(JNIEnv *env, jobject obj, jdouble x, jdouble y)
+{
+ QPainterPath *path = (QPainterPath *)getNativeObject(env, obj);
+ assert( path );
+ path->moveTo( (qreal)x, (qreal)y );
+}
+
+/*
+ * Closes the subpath.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_close
+(JNIEnv *env, jobject obj)
+{
+ QPainterPath *path = (QPainterPath *)getNativeObject(env, obj);
+ assert( path );
+ path->closeSubpath();
+}
+
+/*
+ * LineTo
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_lineTo
+(JNIEnv *env, jobject obj, jdouble x, jdouble y)
+{
+ QPainterPath *path = (QPainterPath *)getNativeObject(env, obj);
+ assert( path );
+ path->lineTo( (qreal)x, (qreal)y );
+}
+
+/*
+ * QuadraticTo
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_quadTo
+(JNIEnv *env, jobject obj, jdouble x, jdouble y, jdouble x2, jdouble y2)
+{
+ QPainterPath *path = (QPainterPath *)getNativeObject(env, obj);
+ assert( path );
+ path->quadTo( (qreal)x, (qreal)y, (qreal)x2, (qreal)y2 );
+}
+
+/*
+ * CubicTo
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_cubicTo
+(JNIEnv *env, jobject obj, jdouble x, jdouble y, jdouble x2, jdouble y2,
+ jdouble x3, jdouble y3)
+{
+ QPainterPath *path = (QPainterPath *)getNativeObject(env, obj);
+ assert( path );
+ path->cubicTo( (qreal)x, (qreal)y,
+ (qreal)x2, (qreal)y2,
+ (qreal)x3, (qreal)y3 );
+}
+
+/*
+ * Delete the native object
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_dispose
+ (JNIEnv *env, jobject obj)
+{
+ QPainterPath *path = (QPainterPath *)getNativeObject(env, obj);
+ if ( path )
+ delete path;
+}
+
+/********* GeneralPath functions *****************************/
+
+// FIXME : Cache method ids.
+
+static void gp_moveTo( JNIEnv *env,
+ jobject gp,
+ jclass cls,
+ double x1,
+ double y1 )
+{
+ jmethodID method;
+ jvalue values[2];
+
+ values[0].f = (jfloat) x1;
+ values[1].f = (jfloat) y1;
+
+ method = env->GetMethodID(cls, "moveTo", "(FF)V");
+ env->CallVoidMethodA( gp, method, values );
+}
+
+static void gp_lineTo( JNIEnv *env,
+ jobject gp,
+ jclass cls,
+ double x1,
+ double y1 )
+{
+ jmethodID method;
+ jvalue values[2];
+
+ values[0].f = (jfloat) x1;
+ values[1].f = (jfloat) y1;
+
+ method = env->GetMethodID(cls, "lineTo", "(FF)V");
+ env->CallVoidMethodA( gp, method, values );
+}
+
+static void gp_curveTo( JNIEnv *env,
+ jobject gp,
+ jclass cls,
+ double x1,
+ double y1,
+ double x2,
+ double y2,
+ double x3,
+ double y3 )
+{
+ jmethodID method;
+ jvalue values[6];
+
+ values[0].f = (jfloat) x1;
+ values[1].f = (jfloat) y1;
+ values[2].f = (jfloat) x2;
+ values[3].f = (jfloat) y2;
+ values[4].f = (jfloat) x3;
+ values[5].f = (jfloat) y3;
+
+ method = env->GetMethodID(cls, "curveTo", "(FFFFFF)V");
+ env->CallVoidMethodA( gp, method, values );
+}
+
+/**
+ * Returns the QPainterPath obj as a java.awt.geom.GeneralPath.
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QPainterPath_getPath
+(JNIEnv *env, jobject obj)
+{
+ jclass cls;
+ jmethodID method;
+ jobject gp;
+ QPainterPath::Element currElement;
+ int windingRule;
+
+ QPainterPath *path = new QPainterPath();
+ assert( path );
+
+ windingRule = (path->fillRule() == Qt::OddEvenFill) ?
+ WIND_EVEN_ODD : WIND_NON_ZERO;
+
+ cls = env->FindClass("java/awt/geom/GeneralPath");
+ method = env->GetMethodID(cls, "<init>", "(I)V");
+ gp = env->NewObject(cls, method, windingRule);
+
+ for( int i = 0; i < path->elementCount(); i++)
+ {
+ currElement = path->elementAt( i );
+ switch(currElement.type)
+ {
+ case QPainterPath::MoveToElement:
+ gp_moveTo(env, gp, cls, currElement.x, currElement.y);
+ break;
+ case QPainterPath::LineToElement:
+ gp_lineTo(env, gp, cls, currElement.x, currElement.y);
+ break;
+ case QPainterPath::CurveToElement:
+ if( i + 2 >= path->elementCount() )
+ break;
+ if(path->elementAt(i + 1).type != QPainterPath::CurveToDataElement ||
+ path->elementAt(i + 2).type != QPainterPath::CurveToDataElement)
+ break;
+ gp_curveTo(env, gp, cls, currElement.x, currElement.y,
+ path->elementAt(i + 1).x, path->elementAt(i + 1).y,
+ path->elementAt(i + 2).x, path->elementAt(i + 2).y );
+ i += 2;
+ break;
+ }
+ }
+ env->DeleteLocalRef( cls );
+ return gp;
+}
+
diff --git a/libjava/classpath/native/jni/qt-peer/qpen.cpp b/libjava/classpath/native/jni/qt-peer/qpen.cpp
new file mode 100644
index 000000000..353826f6b
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qpen.cpp
@@ -0,0 +1,108 @@
+/* qpen.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <QColor>
+#include <QPen>
+#include <gnu_java_awt_peer_qt_QPen.h>
+#include "nativewrapper.h"
+
+/*
+ * java.awt.geom.BasicStroke constants.
+ */
+#define JOIN_MITER 0
+#define JOIN_ROUND 1
+#define JOIN_BEVEL 2
+#define CAP_BUTT 0
+#define CAP_ROUND 1
+#define CAP_SQUARE 2
+
+/**
+ * Create a QPen object
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPen_init
+(JNIEnv *env, jobject obj , jdouble width, jint cap, jint join, jdouble miterlimit)
+{
+ Qt::PenCapStyle qtCap;
+ Qt::PenJoinStyle qtJoin;
+
+ switch(cap)
+ {
+ case CAP_BUTT:
+ qtCap = Qt::FlatCap;
+ break;
+ case CAP_ROUND:
+ qtCap = Qt::RoundCap;
+ break;
+ case CAP_SQUARE:
+ qtCap = Qt::SquareCap;
+ break;
+ }
+
+ switch(join)
+ {
+ case JOIN_MITER:
+ qtJoin = Qt::MiterJoin;
+ break;
+ case JOIN_ROUND:
+ qtJoin = Qt::RoundJoin;
+ break;
+ case JOIN_BEVEL:
+ qtJoin = Qt::BevelJoin;
+ break;
+ }
+
+ QPen *pen = new QPen();
+ assert( pen );
+ pen->setWidthF( (qreal)width );
+ pen->setCapStyle( qtCap );
+ pen->setJoinStyle( qtJoin );
+
+ setNativeObject(env, obj, pen);
+}
+
+/**
+ * Dispose of the QPen object
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QPen_dispose
+(JNIEnv *env, jobject obj)
+{
+ QPen *pen = (QPen *)getNativeObject(env, obj);
+ if ( pen )
+ delete pen;
+}
+
diff --git a/libjava/classpath/native/jni/qt-peer/qtaudioclip.cpp b/libjava/classpath/native/jni/qt-peer/qtaudioclip.cpp
new file mode 100644
index 000000000..d5689b26d
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtaudioclip.cpp
@@ -0,0 +1,114 @@
+/* qtaudioclip.cpp --
+ Copyright (C) 2005 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. */
+
+#include <jni.h>
+#include <assert.h>
+#include <QString>
+#include <QSound>
+#include <gnu_java_awt_peer_qt_QtAudioClip.h>
+#include "qtstrings.h"
+#include "nativewrapper.h"
+
+/*
+ * Loads an audio clip. Returns JNI_TRUE if the load succeded,
+ * JNI_FALSE otherwise.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtAudioClip_loadClip
+(JNIEnv *env, jobject obj, jstring filename)
+{
+ QString *qStr = getQString(env, filename);
+
+ QSound *sound = new QSound( *qStr );
+
+ delete qStr;
+
+ setNativeObject( env, obj, sound );
+}
+
+/*
+ * Plays the audio clip, plays looped if loop equals JNI_TRUE.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtAudioClip_play
+(JNIEnv *env, jobject obj, jboolean loop)
+{
+ QSound *sound = (QSound *)getNativeObject(env, obj);
+ if( sound != NULL )
+ {
+ sound->setLoops( (loop == JNI_TRUE) ? -1 : 1 );
+ sound->play();
+ }
+}
+
+/*
+ * Stops the audio playback.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtAudioClip_stop
+(JNIEnv *env, jobject obj)
+{
+ QSound *sound = (QSound *)getNativeObject(env, obj);
+ if( sound != NULL )
+ sound->stop();
+}
+
+/**
+ * Disposes the audio clip
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtAudioClip_dispose
+(JNIEnv *env, jobject obj)
+{
+ QSound *sound = (QSound *)getNativeObject(env, obj);
+ if( sound != NULL )
+ {
+ setNativeObject( env, obj, NULL );
+ if( !sound->isFinished() )
+ sound->stop();
+ delete sound;
+ }
+}
+
+/**
+ * Returns whether sound is available.
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_qt_QtAudioClip_isAvailable
+(JNIEnv *env, jobject obj)
+{
+ if( QSound::isAvailable() )
+ return JNI_TRUE;
+ else
+ return JNI_FALSE;
+}
+
diff --git a/libjava/classpath/native/jni/qt-peer/qtbuttonpeer.cpp b/libjava/classpath/native/jni/qt-peer/qtbuttonpeer.cpp
new file mode 100644
index 000000000..b807ed466
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtbuttonpeer.cpp
@@ -0,0 +1,94 @@
+/* qtbuttonpeer.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <QMainWindow>
+#include <QPushButton>
+#include <QFont>
+#include <gnu_java_awt_peer_qt_QtButtonPeer.h>
+#include "qtcomponent.h"
+#include "qtstrings.h"
+#include "keybindings.h"
+#include "buttonevent.h"
+#include "slotcallbacks.h"
+
+
+class MyButton : public QPushButton
+{
+public:
+ MyButton(JNIEnv *env, jobject obj, QWidget *parent) : QPushButton(parent)
+ {
+ setup(env, obj);
+ }
+
+ ~MyButton()
+ {
+ destroy();
+ }
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QPushButton
+#include "eventmethods.h"
+};
+
+/**
+ * Init method
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtButtonPeer_init
+(JNIEnv *env, jobject obj)
+{
+
+ QWidget *parentWidget = (QWidget *) getParentWidget( env, obj );
+ MyButton *button = new MyButton( env, obj, parentWidget );
+ assert( button );
+ setNativeObject( env, obj, button );
+ connectButton(button, env, obj); // connect the fireClick method.
+}
+
+/**
+ * Sets the button label.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtButtonPeer_setLabel
+(JNIEnv *env, jobject obj, jstring str)
+{
+ QPushButton *button = (QPushButton *) getNativeObject( env, obj );
+ assert( button );
+
+ QString *qStr = getQString(env, str); // AWTLabelEvent takes care of disposal.
+ mainThread->postEventToMain( new AWTLabelEvent( button, qStr ) );
+}
+
+
diff --git a/libjava/classpath/native/jni/qt-peer/qtcanvaspeer.cpp b/libjava/classpath/native/jni/qt-peer/qtcanvaspeer.cpp
new file mode 100644
index 000000000..9cdbaef8a
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtcanvaspeer.cpp
@@ -0,0 +1,75 @@
+/* qtcanvaspeer.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <QMainWindow>
+#include <QWidget>
+#include <gnu_java_awt_peer_qt_QtCanvasPeer.h>
+#include "qtcomponent.h"
+#include "keybindings.h"
+
+class MyCanvas : public QWidget
+{
+public:
+ MyCanvas(JNIEnv *env, jobject obj, QWidget *parent) : QWidget( parent )
+ {
+ setup(env, obj);
+ }
+
+ ~MyCanvas()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QWidget
+#include "eventmethods.h"
+};
+
+/*
+ * Construct a QWidget object
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtCanvasPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *)getParentWidget(env, obj);
+ // QWidget *canvas = new QWidget( parentWidget );
+ QWidget *canvas = new MyCanvas( env, obj, parentWidget );
+ assert( canvas );
+
+ setNativeObject( env, obj, canvas );
+}
diff --git a/libjava/classpath/native/jni/qt-peer/qtcheckboxpeer.cpp b/libjava/classpath/native/jni/qt-peer/qtcheckboxpeer.cpp
new file mode 100644
index 000000000..c7bbe5511
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtcheckboxpeer.cpp
@@ -0,0 +1,164 @@
+/* qtcheckboxpeer.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <QAbstractButton>
+#include <QCheckBox>
+#include <QRadioButton>
+#include <gnu_java_awt_peer_qt_QtCheckboxPeer.h>
+#include "qtstrings.h"
+#include "qtcomponent.h"
+#include "keybindings.h"
+#include "buttonevent.h"
+#include "slotcallbacks.h"
+
+class CheckboxCheckEvent : public AWTEvent {
+
+ private:
+ QAbstractButton *widget;
+ bool checked;
+
+ public:
+ CheckboxCheckEvent(QAbstractButton *w, bool c)
+ {
+ widget = w;
+ checked = c;
+ }
+
+ void runEvent()
+ {
+ if (checked != widget->isChecked())
+ widget->setChecked( checked );
+ }
+};
+
+class MyCheckBox : public QCheckBox
+{
+public:
+ MyCheckBox(JNIEnv *env, jobject obj, QWidget *parent) : QCheckBox( parent )
+ {
+ setup(env, obj);
+ }
+
+ ~MyCheckBox()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QCheckBox
+#include "eventmethods.h"
+};
+
+/**
+ * Determines whether the darn native object should be a radio button or not
+ */
+static bool isRadioButton( JNIEnv *env, jobject obj )
+{
+ jclass cls = env->FindClass( "gnu/java/awt/peer/qt/QtCheckboxPeer" );
+ jfieldID field = env->GetFieldID( cls, "group", "Ljava/awt/CheckboxGroup;" );
+ if (env->GetObjectField( obj, field ) != NULL)
+ return true;
+ return false;
+}
+
+/**
+ * Construct the native object.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtCheckboxPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *)getParentWidget(env, obj);
+
+ QAbstractButton *cb = (QAbstractButton *) getNativeObject( env, obj );
+ if (cb)
+ delete cb;
+
+ bool radioButton;
+ {
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "owner", "Ljava/awt/Component;" );
+ assert(field != NULL);
+ jobject owner = env->GetObjectField( obj, field );
+ assert(owner != NULL);
+ cls = env->GetObjectClass( owner );
+ jmethodID method = env->GetMethodID( cls,
+ "getCheckboxGroup",
+ "()Ljava/awt/CheckboxGroup;" );
+ assert(method != NULL);
+ jobject group = env->CallObjectMethod( owner, method, 0);
+ radioButton = (group != NULL);
+ }
+
+ if(radioButton)
+ cb = new QRadioButton( parentWidget );
+ else
+ cb = new QCheckBox( parentWidget );
+ // cb = new MyCheckBox( env, obj, parentWidget );
+ assert( cb );
+
+ connectToggle(cb, env, obj); // connect the native event.
+
+ setNativeObject( env, obj, cb );
+}
+
+/*
+ * Sets the checkbox label.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtCheckboxPeer_setLabel
+(JNIEnv *env, jobject obj, jstring label)
+{
+ /* Both QCheckbox and QRadioButton inherit QAbstractButton */
+ QAbstractButton *cb = (QAbstractButton *) getNativeObject( env, obj );
+ assert( cb );
+
+ QString *qStr = getQString(env, label);
+ mainThread->postEventToMain( new AWTLabelEvent( cb, qStr ) );
+ // AWTLabelEvent takes care of disposal of qStr
+}
+
+/*
+ * Sets the checkbox state.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtCheckboxPeer_setState
+(JNIEnv *env, jobject obj, jboolean state)
+{
+ QAbstractButton *cb = (QAbstractButton *) getNativeObject( env, obj );
+ assert( cb );
+ mainThread->postEventToMain( new CheckboxCheckEvent( cb, (state == JNI_TRUE) ) );
+}
+
diff --git a/libjava/classpath/native/jni/qt-peer/qtchoicepeer.cpp b/libjava/classpath/native/jni/qt-peer/qtchoicepeer.cpp
new file mode 100644
index 000000000..f77d3a0cf
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtchoicepeer.cpp
@@ -0,0 +1,142 @@
+/* qtchoicepeer.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <QComboBox>
+#include <gnu_java_awt_peer_qt_QtChoicePeer.h>
+#include "qtcomponent.h"
+#include "qtstrings.h"
+#include "mainthreadinterface.h"
+#include "slotcallbacks.h"
+
+class InsertEvent : public AWTEvent {
+
+ private:
+ QComboBox *widget;
+ QString *string;
+ int index;
+
+ public:
+ InsertEvent(QComboBox *w, QString *s, int i) : AWTEvent()
+ {
+ widget = w;
+ string = s;
+ index = i;
+ }
+
+ void runEvent()
+ {
+ widget->insertItem( index, *string );
+ delete string;
+ }
+};
+
+class RemoveSelectEvent : public AWTEvent {
+
+ private:
+ QComboBox *widget;
+ int index;
+ bool remove;
+
+ public:
+ RemoveSelectEvent(QComboBox *w, int i, bool r) : AWTEvent()
+ {
+ widget = w;
+ index = i;
+ remove = r;
+ }
+
+ void runEvent()
+ {
+ if (remove)
+ widget->removeItem( index );
+ else
+ widget->setCurrentIndex( index );
+ }
+};
+
+/*
+ * Constructs tha QComboBox object
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtChoicePeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *)getParentWidget(env, obj);
+
+ QComboBox *box = new QComboBox( parentWidget );
+ assert( box );
+
+ setNativeObject( env, obj, box );
+
+ connectChoice(box, env, obj); // connect the fireChoice method.
+}
+
+/*
+ * Inserts a choice box item at index.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtChoicePeer_add
+(JNIEnv *env, jobject obj, jstring itemLabel, jint index)
+{
+ QComboBox *box = (QComboBox *) getNativeObject( env, obj );
+ assert( box );
+
+ QString *qStr = getQString( env, itemLabel );
+ mainThread->postEventToMain( new InsertEvent( box, qStr, index ) );
+}
+
+/*
+ * Removes a choice box item at index.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtChoicePeer_remove
+(JNIEnv *env, jobject obj, jint index)
+{
+ QComboBox *box = (QComboBox *) getNativeObject( env, obj );
+ assert( box );
+ mainThread->postEventToMain( new RemoveSelectEvent( box, index, true ) );
+}
+
+/**
+ * Selects a choice box item.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtChoicePeer_select
+(JNIEnv *env, jobject obj, jint index)
+{
+ QComboBox *box = (QComboBox *) getNativeObject( env, obj );
+ assert( box );
+ mainThread->postEventToMain( new RemoveSelectEvent( box, index, false ) );
+}
+
diff --git a/libjava/classpath/native/jni/qt-peer/qtcomponent.cpp b/libjava/classpath/native/jni/qt-peer/qtcomponent.cpp
new file mode 100644
index 000000000..fc7480091
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtcomponent.cpp
@@ -0,0 +1,122 @@
+/* qtcomponent.cpp --
+ Copyright (C) 2005 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. */
+
+#include <jni.h>
+#include <assert.h>
+#include <qmainwindow.h>
+#include <qwidget.h>
+#include "qtcomponent.h"
+#include "containers.h"
+
+#define COMPONENT_CLASS "gnu/java/awt/peer/qt/QtComponentPeer"
+
+/*
+ * Returns the parent widget for a QtComponentPeer
+ */
+void *getParentWidget( JNIEnv *env, jobject qtcomponentpeer )
+{
+ jclass componentCls = env->GetObjectClass( qtcomponentpeer );
+ jfieldID ownerField = env->GetFieldID( componentCls,
+ "owner", "Ljava/awt/Component;" );
+ assert( ownerField );
+ jobject owner = env->GetObjectField( qtcomponentpeer, ownerField );
+ if (owner == NULL)
+ return NULL;
+
+ jclass ownerCls = env->GetObjectClass( owner );
+ jmethodID getParentMID = env->GetMethodID( ownerCls,
+ "getParent",
+ "()Ljava/awt/Container;" );
+ assert(getParentMID);
+
+ jobject parent = env->CallObjectMethod( owner, getParentMID, 0);
+ assert(parent);
+
+ // Get the parents peer
+ jclass parentCls = env->GetObjectClass( parent );
+ {
+ jclass frameCls = env->FindClass( "java/awt/Frame" );
+ if(env->IsInstanceOf( parent, frameCls ) == JNI_TRUE)
+ return frameChildWidget( env, parent );
+ }
+ {
+ jclass scrollpaneCls = env->FindClass( "java/awt/ScrollPane" );
+ if(env->IsInstanceOf( parent, scrollpaneCls ) == JNI_TRUE)
+ return scrollPaneChildWidget( env, parent );
+ }
+
+ jmethodID getPeerMID = env->GetMethodID( parentCls,
+ "getPeer",
+ "()Ljava/awt/peer/ComponentPeer;" );
+ assert(getPeerMID);
+ return getNativeObject(env, env->CallObjectMethod( parent, getPeerMID, 0));
+}
+
+/*
+ * Creates a java.awt.Dimension object from a QSize.
+ */
+jobject makeDimension(JNIEnv *env, QSize *size)
+{
+ if( size == NULL )
+ return NULL;
+ if( size->isNull() || !size->isValid() )
+ return NULL;
+ jclass cls = env->FindClass("java/awt/Dimension");
+ jmethodID mid = env->GetMethodID(cls, "<init>", "(II)V");
+ jvalue values[2];
+
+ values[0].i = (jint) size->width();
+ values[1].i = (jint) size->height();
+
+ return env->NewObjectA(cls, mid, values);
+}
+
+/*
+ * Creates a java.awt.Point object from a QPoint.
+ */
+jobject makePoint(JNIEnv *env, QPoint &p)
+{
+ jclass cls = env->FindClass("java/awt/Point");
+ jmethodID mid = env->GetMethodID(cls, "<init>", "(II)V");
+ jvalue values[2];
+
+ values[0].i = (jint) p.x();
+ values[1].i = (jint) p.y();
+
+ return env->NewObjectA(cls, mid, values);
+}
+
diff --git a/libjava/classpath/native/jni/qt-peer/qtcomponent.h b/libjava/classpath/native/jni/qt-peer/qtcomponent.h
new file mode 100644
index 000000000..3188f03f5
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtcomponent.h
@@ -0,0 +1,16 @@
+#ifndef QTCOMPONENT_H
+#define QTCOMPONENT_H
+
+#include <QSize>
+#include <QPoint>
+//#include <cassert.h>
+#include <jni.h>
+#include "nativewrapper.h"
+
+void *getParentWidget( JNIEnv *env, jobject qtcomponentpeer );
+
+jobject makeDimension(JNIEnv *env, QSize *size);
+
+jobject makePoint(JNIEnv *env, QPoint &p);
+
+#endif
diff --git a/libjava/classpath/native/jni/qt-peer/qtcomponentpeer.cpp b/libjava/classpath/native/jni/qt-peer/qtcomponentpeer.cpp
new file mode 100644
index 000000000..0399dd8fd
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtcomponentpeer.cpp
@@ -0,0 +1,384 @@
+/* qtcomponentpeer.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <QApplication>
+#include <QDesktopWidget>
+#include <QShowEvent>
+#include <QHideEvent>
+#include <QColor>
+#include <QCursor>
+#include <QWidget>
+#include <gnu_java_awt_peer_qt_QtComponentPeer.h>
+#include "qtcomponent.h"
+#include "componentevent.h"
+#include "qtfont.h"
+
+extern QApplication *qApplication;
+
+// Java Cursor types.
+#define DEFAULT_CURSOR 0
+#define CROSSHAIR_CURSOR 1
+#define TEXT_CURSOR 2
+#define WAIT_CURSOR 3
+#define SW_RESIZE_CURSOR 4
+#define SE_RESIZE_CURSOR 5
+#define NW_RESIZE_CURSOR 6
+#define NE_RESIZE_CURSOR 7
+#define N_RESIZE_CURSOR 8
+#define S_RESIZE_CURSOR 9
+#define W_RESIZE_CURSOR 10
+#define E_RESIZE_CURSOR 11
+#define HAND_CURSOR 12
+#define MOVE_CURSOR 13
+
+/**
+ * Call back the init() method from the main thread.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_callInit
+(JNIEnv *env, jobject obj)
+{
+ mainThread->postEventToMain( new AWTInitEvent( env, obj ) );
+}
+
+/*
+ * Generic disposal.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_disposeNative
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ setNativeObject(env, obj, NULL);
+ mainThread->postEventToMain( new AWTDestroyEvent( widget ) );
+}
+
+/**
+ * Returns the on-screen location of the component.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_getLocationOnScreenNative
+(JNIEnv *env, jobject obj, jobject point)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+ mainThread->postEventToMain( new AWTGetOriginEvent( widget, env, point) );
+}
+
+/*
+ * Get the preferred/minimum size of the widget
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_getSizeNative
+(JNIEnv *env, jobject obj, jobject size, jboolean preferred)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+
+ mainThread->postEventToMain
+ (new GetSizeEvent( widget, env, size, (preferred == JNI_TRUE)));
+}
+
+/*
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_isObscured
+(JNIEnv *env, jobject obj)
+{
+ jboolean retVal;
+
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+
+ retVal = (widget->isVisible() == TRUE) ? JNI_TRUE : JNI_FALSE;
+
+ return retVal;
+}
+
+/*
+ * Returns whether the widget is focusable or not.
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_isFocusable
+(JNIEnv *env, jobject obj)
+{
+ jboolean retVal;
+
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+
+ retVal = (widget->focusPolicy() != Qt::NoFocus) ? JNI_TRUE : JNI_FALSE;
+
+ return retVal;
+}
+
+/**
+ * Requests the focus
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_requestFocus
+ (JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+ mainThread->postEventToMain( new AWTReqFocusEvent( widget ) );
+}
+
+/*
+ * Sets the size and position. Important.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_setBoundsNative
+(JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+ mainThread->postEventToMain
+ (new AWTResizeEvent( widget, x, y, width, height ) );
+}
+
+/*
+ * Sets the mouse cursor
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_setCursor
+ (JNIEnv *env, jobject obj, jint cursortype)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+
+ Qt::CursorShape shape;
+ switch(cursortype)
+ {
+ case CROSSHAIR_CURSOR:
+ shape = Qt::CrossCursor;
+ break;
+
+ case W_RESIZE_CURSOR:
+ case E_RESIZE_CURSOR:
+ shape = Qt::SizeHorCursor;
+ break;
+ case N_RESIZE_CURSOR:
+ case S_RESIZE_CURSOR:
+ shape = Qt::SizeVerCursor;
+ break;
+ case HAND_CURSOR:
+ shape = Qt::PointingHandCursor;
+ break;
+ case MOVE_CURSOR:
+ shape = Qt::SizeAllCursor;
+ break;
+
+ case NE_RESIZE_CURSOR:
+ case SW_RESIZE_CURSOR:
+ shape = Qt::SizeBDiagCursor;
+ break;
+ case NW_RESIZE_CURSOR:
+ case SE_RESIZE_CURSOR:
+ shape = Qt::SizeFDiagCursor;
+ break;
+ case TEXT_CURSOR:
+ shape = Qt::IBeamCursor;
+ break;
+ case WAIT_CURSOR:
+ shape = Qt::WaitCursor;
+ break;
+
+ case DEFAULT_CURSOR:
+ default:
+ shape = Qt::ArrowCursor;
+ break;
+ }
+
+ mainThread->postEventToMain( new AWTCursorEvent( widget, shape ) );
+}
+
+/*
+ * Enable, disable.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_setEnabled
+(JNIEnv *env, jobject obj, jboolean state)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert(widget != NULL);
+
+ mainThread->postEventToMain( new AWTEnableEvent( widget, (state == JNI_TRUE) ) );
+}
+
+/**
+ * Set the font
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_setFontNative
+(JNIEnv *env, jobject obj, jobject fontpeer)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+ QFont *font = (QFont *) getFont( env, fontpeer );
+ assert( font );
+
+ mainThread->postEventToMain( new AWTFontEvent(widget, font) );
+}
+
+/*
+ * Sets the back- or foreground color.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_setGround
+(JNIEnv *env, jobject obj, jint r, jint g, jint b, jboolean isForeground)
+{
+ QColor *color = new QColor(r, g, b);
+
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert(widget);
+ mainThread->postEventToMain( new AWTBackgroundEvent(widget,
+ (isForeground == JNI_TRUE),
+ color) );
+}
+
+/*
+ * Sets the visibility.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_setVisible
+(JNIEnv *env, jobject obj, jboolean state)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert(widget != NULL);
+ mainThread->postEventToMain( new AWTShowEvent( widget, (state == JNI_TRUE) ) );
+}
+
+/*
+ * Returns whether the widget handles wheel scrolling.
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_handlesWheelScrolling
+(JNIEnv *env, jobject obj)
+{
+ jboolean handles = JNI_FALSE;
+
+ QWidget *cb = (QWidget *) getNativeObject( env, obj );
+ if( cb )
+ if( cb->focusPolicy() & Qt::WheelFocus )
+ handles = JNI_TRUE;
+
+ return handles;
+}
+
+/**
+ * calls qwidget::update on the compnent.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_QtUpdateArea
+(JNIEnv *env, jobject obj, jint x, jint y, jint w, jint h)
+{
+ QWidget *cb = (QWidget *) getNativeObject( env, obj );
+ if( cb )
+ mainThread->postEventToMain( new AWTUpdateEvent
+ (cb, false, x, y, w, h ) );
+}
+
+/*
+ * calls qwidget::update on the compnent.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_QtUpdate
+(JNIEnv *env, jobject obj)
+{
+ QWidget *cb = (QWidget *) getNativeObject( env, obj );
+ if( cb )
+ mainThread->postEventToMain( new AWTUpdateEvent
+ ( cb, true, 0, 0, 0, 0 ) );
+}
+
+/*
+ * Returns the native background color.
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_getNativeBackground
+(JNIEnv *env, jobject obj)
+{
+ QWidget *cb = (QWidget *) getNativeObject( env, obj );
+ assert(cb);
+ QColor c = cb->palette().background().color().toRgb();
+
+ jclass cls = env->FindClass("java/awt/Color");
+ jmethodID mid = env->GetMethodID(cls, "<init>", "(III)V");
+ jvalue values[3];
+
+ values[0].i = (jint) c.red();
+ values[1].i = (jint) c.green();
+ values[2].i = (jint) c.blue();
+
+ return env->NewObjectA(cls, mid, values);
+}
+
+/*
+ * Returns which screen the component is on.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_whichScreen
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+ return (jint) qApplication->desktop()->screenNumber( widget );
+}
+
+/*
+ * Reparents the widget.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_reparentNative
+(JNIEnv *env, jobject obj, jobject newparent)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+ QWidget *parentWidget = (QWidget *) getNativeObject( env, newparent );
+ assert( parentWidget );
+ mainThread->postEventToMain( new AWTReparent(widget, parentWidget ) );
+}
+
+/*
+ * Get the preferred size of the widget
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_getBounds
+
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+
+ int x, y, w, h;
+ widget->geometry().getRect(&x, &y, &w, &h);
+
+ jclass cls = env->FindClass("java/awt/Rectangle");
+ assert( cls != NULL);
+ jmethodID mid = env->GetMethodID(cls, "<init>", "(IIII)V");
+ assert( mid != NULL);
+ jvalue values[4];
+
+ values[0].i = (jint) x;
+ values[1].i = (jint) y;
+ values[2].i = (jint) w;
+ values[3].i = (jint) h;
+
+ return env->NewObjectA(cls, mid, values);
+}
diff --git a/libjava/classpath/native/jni/qt-peer/qtdialogpeer.cpp b/libjava/classpath/native/jni/qt-peer/qtdialogpeer.cpp
new file mode 100644
index 000000000..0eb709443
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtdialogpeer.cpp
@@ -0,0 +1,164 @@
+/* qtdialogpeer.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <qdialog.h>
+#include <gnu_java_awt_peer_qt_QtDialogPeer.h>
+#include "qtcomponent.h"
+#include "containers.h"
+#include "qtstrings.h"
+#include "keybindings.h"
+#include "mainthreadinterface.h"
+
+class MyDialog : public QDialog
+{
+public:
+ MyDialog(JNIEnv *env, jobject obj, QWidget *parent) : QDialog(parent)
+ {
+ setup(env, obj);
+ }
+
+ ~MyDialog()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QDialog
+#include "eventmethods.h"
+};
+
+class DialogSettingsEvent : public AWTEvent {
+
+ private:
+ QDialog *widget;
+ bool modal;
+ bool value;
+
+ public:
+ DialogSettingsEvent(QDialog *w, bool m, bool v) : AWTEvent()
+ {
+ widget = w;
+ modal = m;
+ value = v;
+ }
+
+ void runEvent()
+ {
+ if( modal )
+ widget->setModal( value );
+ else
+ widget->setSizeGripEnabled( value );
+ }
+};
+
+class DialogResizeEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ bool fixed;
+ int x, y, w, h;
+
+ public:
+ DialogResizeEvent(QWidget *wid, int x0, int y0, int w0, int h0, bool f)
+ {
+ widget = wid;
+ fixed = f;
+ x = x0; y = y0;
+ w = w0; h = h0;
+ if(w == 0 && h == 0) w = h = 10;
+ }
+
+ void runEvent()
+ {
+ if( fixed )
+ widget->setFixedSize( w, h );
+ widget->setGeometry( x, y, w, h );
+ }
+};
+
+/*
+ * Constructs a QDialog native object.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtDialogPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *) getParentWidget( env, obj );
+ // QDialog *dialog = new QDialog(parentWidget);
+ MyDialog *dialog = new MyDialog(env, obj, parentWidget);
+ assert( dialog );
+ setNativeObject( env, obj, dialog );
+}
+
+
+/*
+ * Sets the modality of the dialog.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtDialogPeer_setModal
+(JNIEnv *env, jobject obj, jboolean flag)
+{
+ QDialog *dialog = (QDialog *) getNativeObject( env, obj );
+ assert( dialog );
+ mainThread->postEventToMain( new DialogSettingsEvent(dialog, true, (flag == JNI_TRUE)));
+}
+
+
+/*
+ * Set resizeable.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtDialogPeer_setResizable
+(JNIEnv *env, jobject obj, jboolean flag)
+{
+ QDialog *dialog = (QDialog *) getNativeObject( env, obj );
+ assert( dialog );
+ mainThread->postEventToMain( new DialogSettingsEvent(dialog, false, (flag == JNI_TRUE)));
+}
+
+/*
+ * Overloaded to allow for size locking.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtDialogPeer_setBoundsNative
+(JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height, jboolean fixed)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+
+ QRect g = widget->geometry();
+ if(g.x() != x || g.y() != y ||
+ g.width() != width || g.height() != height)
+ mainThread->postEventToMain( new DialogResizeEvent( widget, x, y, width, height, (fixed == JNI_TRUE) ) );
+}
diff --git a/libjava/classpath/native/jni/qt-peer/qtembeddedwindowpeer.cpp b/libjava/classpath/native/jni/qt-peer/qtembeddedwindowpeer.cpp
new file mode 100644
index 000000000..dbbf87ea4
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtembeddedwindowpeer.cpp
@@ -0,0 +1,113 @@
+/* qtembeddedwindowpeer.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <QWidget>
+#include <QX11EmbedWidget>
+#include <gnu_java_awt_peer_qt_QtEmbeddedWindowPeer.h>
+#include "qtcomponent.h"
+#include "keybindings.h"
+#include "mainthreadinterface.h"
+
+/**
+ * Event wrapper for embedding.
+ */
+class EmbedEvent : public AWTEvent {
+
+ private:
+ QX11EmbedWidget *widget;
+ WId id;
+
+ public:
+ EmbedEvent(QX11EmbedWidget *w, WId i) : AWTEvent()
+ {
+ widget = w;
+ id = i;
+ }
+
+ void runEvent()
+ {
+ widget->embedInto( id );
+ }
+};
+
+
+class MyEmbeddedPanel : public QX11EmbedWidget
+{
+public:
+ MyEmbeddedPanel(JNIEnv *env, jobject obj, QWidget *parent) : QX11EmbedWidget( parent )
+ {
+ setup(env, obj);
+ }
+
+ ~MyEmbeddedPanel()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QX11EmbedWidget
+#include "eventmethods.h"
+#undef I_KNOW_WHAT_IM_DOING
+#undef PARENT
+};
+
+/**
+ * Init
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtEmbeddedWindowPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *) getParentWidget( env, obj );
+ QWidget *panel = new MyEmbeddedPanel( env, obj, parentWidget );
+ assert( panel );
+
+ setNativeObject( env, obj, panel );
+}
+
+/**
+ * Embed the thing.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtEmbeddedWindowPeer_embed
+(JNIEnv *env, jobject obj, jlong wid)
+{
+ MyEmbeddedPanel *panel = (MyEmbeddedPanel *)getNativeObject( env, obj );
+ assert( panel );
+
+ mainThread->postEventToMain( new EmbedEvent( panel, (WId)wid ) );
+}
+
diff --git a/libjava/classpath/native/jni/qt-peer/qtfiledialogpeer.cpp b/libjava/classpath/native/jni/qt-peer/qtfiledialogpeer.cpp
new file mode 100644
index 000000000..bd6ab3f08
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtfiledialogpeer.cpp
@@ -0,0 +1,101 @@
+/* qtfiledialogpeer.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <QFileDialog>
+#include <QDialog>
+#include <gnu_java_awt_peer_qt_QtFileDialogPeer.h>
+#include "qtcomponent.h"
+#include "qtstrings.h"
+#include "mainthreadinterface.h"
+
+// Constants from FileDialog
+#define LOAD 0
+#define SAVE 1
+
+class FileDialogMode : public AWTEvent {
+
+ private:
+ QFileDialog *widget;
+ bool open;
+
+ public:
+ FileDialogMode(QFileDialog *w, bool o) : AWTEvent()
+ {
+ widget = w;
+ open = o;
+ }
+
+ void runEvent()
+ {
+ if( open )
+ {
+ widget->setAcceptMode( QFileDialog::AcceptOpen );
+ widget->setFileMode( QFileDialog::ExistingFile );
+ }
+ else
+ {
+ widget->setAcceptMode( QFileDialog::AcceptSave );
+ widget->setFileMode( QFileDialog::AnyFile );
+ }
+ }
+};
+
+
+/*
+ * Constructs a QDialog native object.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFileDialogPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *) getParentWidget( env, obj );
+ QFileDialog *dialog = new QFileDialog(parentWidget);
+ assert( dialog );
+ setNativeObject( env, obj, dialog );
+}
+
+/**
+ * Sets the mode (LOAD or SAVE)
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFileDialogPeer_setMode
+(JNIEnv *env, jobject obj, jint mode)
+{
+ QFileDialog *filedialog = (QFileDialog *) getNativeObject( env, obj );
+ assert( filedialog );
+
+ mainThread->postEventToMain( new FileDialogMode( filedialog, (mode != SAVE) ) );
+}
diff --git a/libjava/classpath/native/jni/qt-peer/qtfont.h b/libjava/classpath/native/jni/qt-peer/qtfont.h
new file mode 100644
index 000000000..d13b8e098
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtfont.h
@@ -0,0 +1,8 @@
+#ifndef QTFONT_H
+#define QTFONT_H
+
+#include <jni.h>
+
+QFont *getFont( JNIEnv *env, jobject obj );
+
+#endif
diff --git a/libjava/classpath/native/jni/qt-peer/qtfontmetrics.cpp b/libjava/classpath/native/jni/qt-peer/qtfontmetrics.cpp
new file mode 100644
index 000000000..f2f61822d
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtfontmetrics.cpp
@@ -0,0 +1,233 @@
+/* qtfontmetrics.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <QChar>
+#include <QFont>
+#include <QFontMetrics>
+#include <QString>
+#include <QPainter>
+#include <QStringList>
+#include <QFontDatabase>
+#include <gnu_java_awt_peer_qt_QtFontMetrics.h>
+#include "qtfont.h"
+#include "qtstrings.h"
+#include "qtgraphics.h"
+
+QFontMetrics *getFontMetrics( JNIEnv *env, jobject obj )
+{
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ return (QFontMetrics *)env->GetLongField( obj, field );
+}
+
+static void setNativePtr( JNIEnv *env, jobject obj, void *value )
+{
+ jlong longValue = (jlong) value;
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ env->SetLongField( obj, field, longValue );
+}
+
+static jobject makeRectangle(JNIEnv *env, QRect *rect)
+{
+ if( rect == NULL )
+ return NULL;
+ if( rect->isNull() || !rect->isValid() )
+ return NULL;
+ jclass cls = env->FindClass("java/awt/Rectangle");
+ jmethodID mid = env->GetMethodID(cls, "<init>", "(IIII)V");
+ jvalue values[4];
+
+ int x,y,w,h;
+ rect->getRect(&x, &y, &w, &h);
+ values[0].i = (jint) x;
+ values[1].i = (jint) y;
+ values[2].i = (jint) w;
+ values[3].i = (jint) h;
+
+ return env->NewObjectA(cls, mid, values);
+}
+
+/*
+ * Create font metrics from a font.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_init
+(JNIEnv *env, jobject obj, jobject fontPeer)
+{
+ QFont *f = getFont(env, fontPeer);
+ assert( f );
+ QFontMetrics *fm = new QFontMetrics( *f );
+ assert( fm );
+ setNativePtr( env, obj, fm );
+}
+
+/*
+ * Create font metrics from a font.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_initGraphics
+(JNIEnv *env, jobject obj, jobject fontPeer, jobject graphics)
+{
+ QFont *f = getFont(env, fontPeer);
+ assert( f );
+ QPainter *painter = getPainter( env, graphics );
+ assert( painter );
+ QFontMetrics *fm = new QFontMetrics( *f , painter->device());
+ assert( fm );
+ setNativePtr( env, obj, fm );
+}
+
+/*
+ * Dispose
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_dispose
+(JNIEnv *env, jobject obj)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ if ( fm )
+ delete fm;
+ setNativePtr( env, obj, NULL );
+}
+
+/*
+ * Returns JNI_TRUE if a character is displayable.
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_canDisplay
+(JNIEnv *env, jobject obj, jint c)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ assert( fm );
+ bool result = fm->inFont( QChar( (unsigned int) c ) );
+ return (result ? JNI_TRUE : JNI_FALSE);
+}
+
+/*
+ * Returns the ascent.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_getAscent
+(JNIEnv *env, jobject obj)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ assert( fm );
+ return fm->ascent();
+}
+
+/*
+ * Returns the descent
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_getDescent
+(JNIEnv *env, jobject obj)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ assert( fm );
+ return fm->descent();
+}
+
+/*
+ * Returns the height.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_getHeight
+(JNIEnv *env, jobject obj)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ assert( fm );
+ return fm->height();
+}
+
+/*
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_getLeading
+(JNIEnv *env, jobject obj)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ assert( fm );
+ return fm->leading();
+}
+
+/*
+ * getStringBounds
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_getStringBounds
+(JNIEnv *env, jobject obj, jstring str)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ assert( fm );
+ QString *qStr = getQString(env, str);
+ QRect r = fm->boundingRect( *qStr );
+ delete qStr;
+
+ return makeRectangle( env, &r );
+}
+
+/*
+ * Returns the width of the widest character.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_getMaxAdvance
+(JNIEnv *env, jobject obj)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ assert( fm );
+ return fm->maxWidth();
+}
+
+/*
+ * Returns the width of a given character.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_charWidth
+(JNIEnv *env, jobject obj, jchar c)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ assert( fm );
+ return fm->width( QChar( (unsigned short)c ) );
+}
+
+/*
+ * Returns the width of a string.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFontMetrics_stringWidth
+(JNIEnv *env, jobject obj, jstring str)
+{
+ QFontMetrics *fm = getFontMetrics( env, obj );
+ assert( fm );
+ QString *qStr = getQString(env, str);
+ int width = fm->width( *qStr );
+ delete qStr;
+ return width;
+}
+
+
+
diff --git a/libjava/classpath/native/jni/qt-peer/qtfontpeer.cpp b/libjava/classpath/native/jni/qt-peer/qtfontpeer.cpp
new file mode 100644
index 000000000..7859f6234
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtfontpeer.cpp
@@ -0,0 +1,92 @@
+/* qtfontpeer.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <QFont>
+#include <QString>
+#include <gnu_java_awt_peer_qt_QtFontPeer.h>
+#include "qtfont.h"
+#include "qtstrings.h"
+
+// java.awt.Font constants
+#define PLAIN 0
+#define BOLD 1
+#define ITALIC 2
+
+QFont *getFont( JNIEnv *env, jobject obj )
+{
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ return (QFont *)env->GetLongField( obj, field );
+}
+
+static void setNativePtr( JNIEnv *env, jobject obj, void *value )
+{
+ jlong longValue = (jlong) value;
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ env->SetLongField( obj, field, longValue );
+}
+
+/*
+ * Creates a font.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFontPeer_create
+(JNIEnv *env, jobject obj, jstring name, jint style, jint size)
+{
+ QString *str = getQString(env, name);
+ QFont *font = NULL;
+ font = new QFont( *str, size,
+ ((style & BOLD) != 0) ? QFont::Bold : QFont::Normal,
+ ((style & ITALIC) != 0) );
+ assert( font );
+ delete str;
+ setNativePtr( env, obj, font );
+}
+
+/*
+ * Destroys a font.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFontPeer_dispose
+(JNIEnv *env, jobject obj)
+{
+ QFont *font = getFont( env, obj );
+ if( font )
+ delete font;
+ setNativePtr( env, obj, NULL );
+}
+
diff --git a/libjava/classpath/native/jni/qt-peer/qtframepeer.cpp b/libjava/classpath/native/jni/qt-peer/qtframepeer.cpp
new file mode 100644
index 000000000..85059ab1a
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtframepeer.cpp
@@ -0,0 +1,205 @@
+/* qtframepeer.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <QApplication>
+#include <QIcon>
+#include <QMainWindow>
+#include <QMenuBar>
+#include <QPixmap>
+#include <QToolBar>
+#include <QThread>
+#include <gnu_java_awt_peer_qt_QtFramePeer.h>
+#include "qtcomponent.h"
+#include "qtstrings.h"
+#include "qtimage.h"
+#include "containers.h"
+#include "keybindings.h"
+#include "mainthreadinterface.h"
+
+#define MenuSizeDefault 5
+
+/*
+ * Our QMainWindow subclass
+ */
+class MyFrame : public QMainWindow
+{
+public:
+ MyFrame(JNIEnv *env, jobject obj) : QMainWindow(0, Qt::Window )
+ {
+ setup(env, obj);
+ }
+
+ ~MyFrame()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QMainWindow
+#include "eventmethods.h"
+};
+
+/**
+ * Event wrapper for adding a menu bar to the frame
+ * if the QMenuBar pointer is NULL, the current menu bar is removed.
+ */
+class FrameMenuEvent : public AWTEvent {
+
+ private:
+ QMainWindow *widget;
+ QMenuBar *menu;
+
+ public:
+ FrameMenuEvent(QMainWindow *w, QMenuBar *mb) : AWTEvent()
+ {
+ widget = w;
+ menu = mb;
+ }
+
+ void runEvent()
+ {
+ if( menu != NULL)
+ widget->setMenuBar( menu );
+ else
+ delete widget->menuBar();
+ }
+};
+
+/**
+ * Returns the child widget for the frame (the centralWidget in qt terms)
+ */
+QWidget *frameChildWidget( JNIEnv *env, jobject component )
+{
+ jclass frameCls = env->FindClass( "java/awt/Frame" );
+ assert( frameCls );
+ jmethodID getPeerMID = env->GetMethodID( frameCls,
+ "getPeer",
+ "()Ljava/awt/peer/ComponentPeer;" );
+ assert(getPeerMID);
+
+ jobject framepeerobj = env->CallObjectMethod( component, getPeerMID, 0);
+ if( framepeerobj == NULL )
+ return (QWidget *)NULL;
+
+ MyFrame *window = (MyFrame *)getNativeObject(env, framepeerobj);
+ assert( window );
+ return window;
+}
+
+/*
+ * Constructs a QMainWindow native object.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFramePeer_init
+(JNIEnv *env, jobject obj)
+{
+ MyFrame *frame = new MyFrame(env, obj);
+ assert( frame );
+ frame->addToolBarBreak ( Qt::BottomToolBarArea );
+ setNativeObject( env, obj, frame );
+}
+
+/**
+ * Sets the icon image.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFramePeer_setIcon
+(JNIEnv *env, jobject obj, jobject image)
+{
+ QMainWindow *frame = (QMainWindow *) getNativeObject( env, obj );
+ assert( frame );
+
+ QIcon *i;
+ if( image == NULL )
+ {
+ // remove icon
+ i = new QIcon();
+ }
+ else
+ {
+ // set icon
+ QImage *img = getQtImage( env, image );
+ assert( img );
+ i = new QIcon( QPixmap::fromImage( *img ) );
+ }
+ frame->setWindowIcon( *i );
+ delete i;
+}
+
+/**
+ * Returns the menu bar height for insets.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtFramePeer_menuBarHeight
+(JNIEnv *env, jobject obj)
+{
+ QMainWindow *frame = (QMainWindow *) getNativeObject( env, obj );
+ assert( frame );
+
+ QMenuBar *mb = frame->menuBar();
+
+ return ( mb != NULL ) ? mb->sizeHint().height() : 0 ;
+}
+
+/*
+ * set Menu bar.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFramePeer_setMenu
+(JNIEnv *env, jobject obj, jobject mbPeer)
+{
+ QMainWindow *frame = (QMainWindow *) getNativeObject( env, obj );
+ assert( frame );
+
+ QMenuBar *menubar = NULL;
+
+ if( mbPeer != NULL )
+ {
+ menubar = (QMenuBar *) getNativeObject( env, mbPeer );
+ assert( menubar );
+ }
+
+ mainThread->postEventToMain( new FrameMenuEvent( frame, menubar ) );
+}
+
+/**
+ * Set the bounds of the maximized frame
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFramePeer_setMaximizedBounds (JNIEnv *env, jobject obj, jint w, jint h)
+{
+ QMainWindow *frame = (QMainWindow *) getNativeObject( env, obj );
+ assert( frame );
+ // FIXME
+}
+
diff --git a/libjava/classpath/native/jni/qt-peer/qtgraphics.cpp b/libjava/classpath/native/jni/qt-peer/qtgraphics.cpp
new file mode 100644
index 000000000..efd334292
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtgraphics.cpp
@@ -0,0 +1,475 @@
+/* qtgraphics.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <jni.h>
+#include <QPainter>
+#include <QBrush>
+#include <QLinearGradient>
+#include <QPen>
+#include <QPaintDevice>
+#include <QPainterPath>
+#include <QImage>
+#include <QColor>
+#include <gnu_java_awt_peer_qt_QtGraphics.h>
+#include "nativewrapper.h"
+#include "qtimage.h"
+#include "qtstrings.h"
+#include "qtcomponent.h"
+#include "qtgraphics.h"
+#include "qtfont.h"
+
+// Constants from java.awt.AlphaComposite
+#define CLEAR 1
+#define SRC 2
+#define DST 9
+#define SRC_OVER 3
+#define DST_OVER 4
+#define SRC_IN 5
+#define DST_IN 6
+#define SRC_OUT 7
+#define DST_OUT 8
+#define SRC_ATOP 10
+#define DST_ATOP 11
+#define XOR 12
+
+GraphicsPainter *getPainter( JNIEnv *env, jobject obj )
+{
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ return (GraphicsPainter *)env->GetLongField( obj, field );
+}
+
+static void setNativePtr( JNIEnv *env, jobject obj, void *value )
+{
+ jlong longValue = (jlong) value;
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ env->SetLongField( obj, field, longValue );
+}
+
+static jobject getToolkit( JNIEnv *env, jobject obj )
+{
+ jclass cls = env->FindClass( "gnu/java/awt/peer/qt/QtGraphics" );
+
+ jfieldID field = env->GetFieldID( cls, "toolkit",
+ "Lgnu/java/awt/peer/qt/QtToolkit;" );
+ return env->GetObjectField( obj, field );
+}
+
+///////////////////////// JNI methods ////////////////////////////////
+
+/**
+ * Clones the parent QPainter object.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_cloneNativeContext
+(JNIEnv *env, jobject obj, jobject parent)
+{
+ GraphicsPainter *painter = (GraphicsPainter *)getPainter( env, parent );
+ assert( painter );
+ QPainter *newPainter = new GraphicsPainter( painter->device() );
+ assert( newPainter );
+ setNativePtr(env, obj, newPainter);
+}
+
+/*
+ * Start of JNI methods
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_initImage
+(JNIEnv *env, jobject obj, jobject image)
+{
+ QImage *im = getQtImage( env, image );
+ assert( im );
+ QPainter *painter = new GraphicsPainter( im );
+ assert( painter );
+ setNativePtr(env, obj, painter);
+ painter->setRenderHint(QPainter::TextAntialiasing);
+ painter->setRenderHint(QPainter::Antialiasing);
+ painter->setRenderHint(QPainter::SmoothPixmapTransform);
+}
+
+/*
+ * Start of JNI methods
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_initVolatileImage
+(JNIEnv *env, jobject obj, jobject image)
+{
+ QPixmap *im = getQtVolatileImage( env, image );
+ assert( im );
+ QPainter *painter = new GraphicsPainter( im );
+ assert( painter );
+ setNativePtr(env, obj, painter);
+ painter->setRenderHint(QPainter::TextAntialiasing);
+ painter->setRenderHint(QPainter::Antialiasing);
+ painter->setRenderHint(QPainter::SmoothPixmapTransform);
+}
+
+/**
+ * Deletes the QPainter
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_delete
+(JNIEnv *env, jobject obj)
+{
+ GraphicsPainter *painter = (GraphicsPainter *)getPainter( env, obj );
+ setNativePtr( env, obj, NULL );
+ if( painter )
+ {
+ if( painter->isActive() )
+ painter->end();
+ delete painter;
+ }
+}
+
+///////////////////////////////////////////////////////////
+/*
+ * Sets the clip to a path.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setClipNative
+(JNIEnv *env, jobject obj, jobject path)
+{
+ QPainter *painter = getPainter( env, obj );
+ assert( painter );
+ QPainterPath *pp = (QPainterPath *)getNativeObject( env, path );
+ assert( pp );
+ painter->setClipPath( *pp );
+}
+
+/*
+ * Sets the clip to a rectangle.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setClipRectNative
+(JNIEnv *env, jobject obj, jint x, jint y, jint w, jint h)
+{
+ QPainter *painter = getPainter( env, obj );
+ assert( painter );
+ painter->setClipRect( x, y, w, h );
+}
+
+/*
+ * Intersects a shape with the current clip.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_intersectClipNative
+(JNIEnv *env, jobject obj, jobject path)
+{
+ QPainter *painter = getPainter( env, obj );
+ assert( painter );
+ QPainterPath *pp = (QPainterPath *)getNativeObject( env, path );
+ assert( pp );
+ painter->setClipPath( *pp, Qt::IntersectClip );
+}
+
+/*
+ * Intersect a rectangle with the current clip.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_intersectClipRectNative
+(JNIEnv *env, jobject obj, jint x, jint y, jint w, jint h)
+{
+ QPainter *painter = getPainter( env, obj );
+ assert( painter );
+ painter->setClipRect( x, y, w, h, Qt::IntersectClip );
+}
+
+/*
+ * Returns a QPainterPath object with the clip path of this painter.
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_getClipNative
+(JNIEnv *env, jobject obj)
+{
+ QPainter *painter = getPainter( env, obj );
+ assert( painter );
+ jclass cls = env->FindClass("gnu/java/awt/peer/qt/QPainterPath");
+ jmethodID method = env->GetMethodID(cls, "<init>", "()V");
+
+ jobject ppo = env->NewObject(cls, method);
+ QPainterPath qpp = painter->clipPath();
+ setNativeObject(env, ppo, &qpp);
+
+ env->DeleteLocalRef( cls );
+ return ppo;
+}
+
+/*
+ * Returns a Rectangle with the bounds of this painters clip path.
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_getClipBounds
+(JNIEnv *env, jobject obj)
+{
+ QPainter *painter = getPainter( env, obj );
+ assert( painter );
+ qreal x, y, w, h;
+ painter->clipPath().boundingRect().getRect(&x, &y, &w, &h);
+
+ jclass cls = env->FindClass("java/awt/Rectangle");
+ assert( cls != NULL);
+ jmethodID mid = env->GetMethodID(cls, "<init>", "(IIII)V");
+ assert( mid != NULL);
+ jvalue values[4];
+
+ values[0].i = (jint) x;
+ values[1].i = (jint) y;
+ values[2].i = (jint) w;
+ values[3].i = (jint) h;
+
+ return env->NewObjectA(cls, mid, values);
+}
+
+///////////////////////// Color stuff ////////////////////////
+/**
+ *
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setColor
+(JNIEnv *env, jobject obj, jint r, jint g, jint b, jint alpha)
+{
+ GraphicsPainter *painter = (GraphicsPainter *)getPainter( env, obj );
+ assert( painter );
+ painter->currentPen->setColor( QColor(r, g, b, alpha) );
+ painter->setPen( *painter->currentPen );
+ painter->currentBrush = new QBrush( QColor(r, g, b, alpha) );
+ painter->setBrush( *painter->currentBrush );
+ painter->currentColor = new QColor(r, g, b, alpha);
+}
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setAlphaNative
+ (JNIEnv *env, jobject obj, jdouble alpha)
+{
+ GraphicsPainter *painter = (GraphicsPainter *)getPainter( env, obj );
+ assert( painter );
+
+ QColor c = painter->currentPen->color();
+ c.setAlphaF( (qreal)alpha );
+ painter->currentPen->setColor(c);
+
+ c = painter->currentBrush->color();
+ c.setAlphaF( (qreal)alpha );
+ painter->currentBrush->setColor( c );
+}
+
+/*
+ * Class: gnu_java_awt_peer_qt_QtGraphics
+ * Method: drawNative
+ * Signature: (Lgnu/java/awt/peer/qt/QPainterPath;)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_drawNative
+(JNIEnv *env, jobject obj, jobject path)
+{
+ GraphicsPainter *painter = (GraphicsPainter *)getPainter( env, obj );
+ assert( painter );
+ QPainterPath *pp = (QPainterPath *)getNativeObject( env, path );
+ assert( pp );
+ painter->setPen( *painter->currentPen );
+ painter->setBrush( Qt::NoBrush );
+ painter->drawPath( *pp );
+}
+
+/*
+ * Class: gnu_java_awt_peer_qt_QtGraphics
+ * Method: fillNative
+ * Signature: (Lgnu/java/awt/peer/qt/QPainterPath;)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_fillNative
+(JNIEnv *env, jobject obj, jobject path)
+{
+ GraphicsPainter *painter = (GraphicsPainter *)getPainter( env, obj );
+ assert( painter );
+ QPainterPath *pp = (QPainterPath *)getNativeObject( env, path );
+ assert( pp );
+
+ painter->setPen(Qt::NoPen);
+ painter->setBrush( *painter->currentBrush );
+ painter->drawPath( *pp );
+}
+
+/**
+ * Draws a string.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_drawStringNative
+(JNIEnv *env, jobject obj, jstring str, jdouble x, jdouble y)
+{
+ GraphicsPainter *painter = getPainter( env, obj );
+ assert( painter );
+ QString *qStr = getQString(env, str);
+ painter->setBrush( Qt::NoBrush );
+ painter->setPen( *painter->currentPen );
+ painter->drawText(QPointF( (qreal)x, (qreal)y ), *qStr);
+ delete qStr;
+}
+
+/*
+ * Sets the native stroke
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setNativeStroke
+(JNIEnv *env, jobject obj, jobject stroke)
+{
+ GraphicsPainter *painter = (GraphicsPainter *)getPainter( env, obj );
+ assert( painter );
+ QPen *pen = (QPen *)getNativeObject(env, stroke);
+ assert( pen );
+ painter->currentPen = new QPen( *pen );
+ painter->setPen( *painter->currentPen );
+}
+
+/*
+ * Sets the transform
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setQtTransform
+(JNIEnv *env, jobject obj, jobject matrix)
+{
+ QPainter *painter = getPainter( env, obj );
+ assert( painter );
+ QMatrix *m = (QMatrix *)getNativeObject( env, matrix );
+ assert( m );
+ painter->setMatrix( *m );
+}
+
+/**
+ * Set the font
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setFontNative
+(JNIEnv *env, jobject obj, jobject fontpeer)
+{
+ QPainter *painter = getPainter( env, obj );
+ assert( painter );
+ QFont *font = (QFont *) getFont( env, fontpeer );
+ assert( font );
+ painter->setFont( *font );
+}
+
+/*
+ * Sets Porter-Duff compositing.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setNativeComposite
+(JNIEnv *env, jobject obj, jint compositeMode)
+{
+ QPainter *painter = getPainter( env, obj );
+ assert( painter );
+ QPainter::CompositionMode mode;
+
+ switch( compositeMode )
+ {
+ case CLEAR:
+ mode = QPainter::CompositionMode_Clear;
+ break;
+ case SRC:
+ mode = QPainter::CompositionMode_Source;
+ break;
+ case DST:
+ mode = QPainter::CompositionMode_Destination;
+ break;
+ case SRC_OVER:
+ mode = QPainter::CompositionMode_SourceOver;
+ break;
+ case DST_OVER:
+ mode = QPainter::CompositionMode_DestinationOver;
+ break;
+ case SRC_IN:
+ mode = QPainter::CompositionMode_SourceIn;
+ break;
+ case DST_IN:
+ mode = QPainter::CompositionMode_DestinationIn;
+ break;
+ case SRC_OUT:
+ mode = QPainter::CompositionMode_SourceOut;
+ break;
+ case DST_OUT:
+ mode = QPainter::CompositionMode_DestinationOut;
+ break;
+ case SRC_ATOP:
+ mode = QPainter::CompositionMode_SourceAtop;
+ break;
+ case DST_ATOP:
+ mode = QPainter::CompositionMode_DestinationAtop;
+ break;
+ case XOR:
+ mode = QPainter::CompositionMode_Xor;
+ break;
+ }
+ painter->setCompositionMode( mode );
+}
+
+/**
+ * Sets the current brush to a linear gradient.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_setLinearGradient
+(JNIEnv *env, jobject obj, jint r1, jint g1, jint b1, jint r2, jint g2,
+jint b2, jdouble x1, jdouble y1, jdouble x2, jdouble y2, jboolean cyclic)
+{
+ GraphicsPainter *painter = getPainter( env, obj );
+ assert( painter );
+ QLinearGradient *lg = new QLinearGradient(QPointF( (qreal)x1, (qreal)y1 ),
+ QPointF( (qreal)x2, (qreal)y2 ) );
+ lg->setColorAt( (qreal)0.0, QColor(r1, g1, b1) );
+ lg->setColorAt( (qreal)1.0, QColor(r2, g2, b2) );
+ if( cyclic == JNI_TRUE )
+ lg->setSpread( QGradient::ReflectSpread );
+ else
+ lg->setSpread( QGradient::PadSpread );
+ painter->currentBrush = new QBrush( *lg );
+ delete lg;
+}
+
+/*
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_fill3DRect
+(JNIEnv *env, jobject obj, jint x, jint y, jint w, jint h, jboolean raised)
+{
+ GraphicsPainter *painter = getPainter( env, obj );
+ assert( painter );
+ // FIXME: Adjust colors
+ painter->fillRect ( x, y, w, h, QBrush( *painter->currentColor) );
+ QPen *p = new QPen( *painter->currentColor );
+ p->setWidth( 1 );
+ painter->setPen( *p );
+ painter->drawLine( x + w, y, x + w, y + h);
+ painter->drawLine( x, y + h, x + w, y + h);
+}
+
+/*
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtGraphics_draw3DRect
+(JNIEnv *env, jobject obj, jint x, jint y, jint w, jint h, jboolean raised)
+{
+ GraphicsPainter *painter = getPainter( env, obj );
+ assert( painter );
+ // FIXME: Adjust colors
+ QPen *p = new QPen( *painter->currentColor );
+ p->setWidth( 1 );
+ painter->setPen( *p );
+ painter->drawLine( x, y, x + w, y );
+ painter->drawLine( x, y, x, y + h);
+ painter->drawLine( x + w, y, x + w, y + h);
+ painter->drawLine( x, y + h, x + w, y + h);
+}
diff --git a/libjava/classpath/native/jni/qt-peer/qtgraphics.h b/libjava/classpath/native/jni/qt-peer/qtgraphics.h
new file mode 100644
index 000000000..5252897db
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtgraphics.h
@@ -0,0 +1,26 @@
+#ifndef QTGRAPHICS_H
+#define QTGRAPHICS_H
+
+#include <jni.h>
+#include <QPainter>
+#include <QPaintDevice>
+#include <QPen>
+#include <QBrush>
+
+class GraphicsPainter : public QPainter
+{
+public:
+ QPen *currentPen;
+ QBrush *currentBrush;
+ QColor *currentColor;
+ GraphicsPainter(QPaintDevice *dev) : QPainter( dev )
+ {
+ currentPen = new QPen();
+ currentBrush = new QBrush();
+ currentColor = new QColor();
+ }
+};
+
+GraphicsPainter *getPainter( JNIEnv *env, jobject obj );
+
+#endif
diff --git a/libjava/classpath/native/jni/qt-peer/qtimage.cpp b/libjava/classpath/native/jni/qt-peer/qtimage.cpp
new file mode 100644
index 000000000..4d2b5b90a
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtimage.cpp
@@ -0,0 +1,401 @@
+/* qtimage.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <QImage>
+#include <QColor>
+#include <QMatrix>
+#include <QPainter>
+#include <gnu_java_awt_peer_qt_QtImage.h>
+#include "qtimage.h"
+#include "qtstrings.h"
+#include "qtgraphics.h"
+#include "nativewrapper.h"
+
+/* The constant fields in java.awt.Image */
+#define SCALE_DEFAULT 1
+#define SCALE_FAST 2
+#define SCALE_SMOOTH 4
+#define SCALE_REPLICATE 8
+#define SCALE_AREA_AVERAGING 16
+
+QImage *getQtImage( JNIEnv *env, jobject obj )
+{
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ return (QImage *)env->GetLongField( obj, field );
+}
+
+static void setNativePtr( JNIEnv *env, jobject obj, void *value )
+{
+ jlong longValue = (jlong) value;
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ env->SetLongField( obj, field, longValue );
+}
+
+/*
+ * Creates a QImage.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_createImage
+(JNIEnv *env, jobject obj)
+{
+ int width, height;
+ jclass cls;
+ jfieldID field;
+
+ cls = env->GetObjectClass( obj );
+ field = env->GetFieldID (cls, "width", "I");
+ assert (field != 0);
+ width = env->GetIntField(obj, field);
+
+ field = env->GetFieldID(cls, "height", "I");
+ assert (field != 0);
+ height = env->GetIntField(obj, field);
+
+ QImage *image = new QImage ( width, height,
+ QImage::Format_ARGB32_Premultiplied );
+ setNativePtr(env, obj, image);
+}
+
+/*
+ * Frees the image data.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_freeImage
+(JNIEnv *env, jobject obj)
+{
+ QImage *image = getQtImage(env, obj);
+ setNativePtr(env, obj, NULL);
+ if ( image )
+ delete image;
+}
+
+/*
+ * Clears the image to zero.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_clear
+(JNIEnv *env, jobject obj)
+{
+ QImage *image = getQtImage(env, obj);
+ assert( image );
+ image->fill(0);
+}
+
+/*
+ * Returns the pixel data in an int array.
+ */
+JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_qt_QtImage_getPixels
+(JNIEnv *env, jobject obj)
+{
+ QImage *image = getQtImage(env, obj);
+ jintArray result_array;
+ jint *result_array_ptr, *dst;
+ int x, y;
+ jint pixel;
+ QRgb current;
+
+ assert( image );
+
+ result_array = env->NewIntArray (image->width() * image->height());
+ dst = result_array_ptr =
+ env->GetIntArrayElements(result_array, NULL);
+
+ // A bit inefficient.
+ for ( y = 0; y < image->height(); y++)
+ for ( x = 0; x < image->width(); x++)
+ {
+ current = image->pixel(x, y);
+ pixel = 0;
+ pixel = (qAlpha(current) & 0xFF) << 24 |
+ (qRed(current) & 0xFF) << 16 |
+ (qGreen(current) & 0xFF) << 8 |
+ (qBlue(current) & 0xFF);
+ *dst = pixel;
+ dst++;
+ }
+
+ env->ReleaseIntArrayElements (result_array, result_array_ptr, 0);
+ return result_array;
+}
+
+/*
+ * Sets the pixel data.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_setPixels
+(JNIEnv *env, jobject obj, jintArray pixels)
+{
+ QImage *image = getQtImage(env, obj);
+ assert( image );
+
+ int width, height;
+ jint *src_array, *src;
+
+ width = image->width();
+ height = image->height();
+
+ src = src_array =
+ env->GetIntArrayElements(pixels, NULL);
+
+ for(int i = 0 ; i < height; i++)
+ {
+ uchar *scanline = image->scanLine( i );
+ memcpy((void *)scanline, (void *)src, width * 4);
+ src += width;
+ }
+
+ env->ReleaseIntArrayElements(pixels, src_array, 0);
+}
+
+
+/*
+ * Loads an image from a file,
+ * returns true on success, false on failure.
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_qt_QtImage_loadImage
+(JNIEnv *env, jobject obj, jstring fn)
+{
+ QString *filename = getQString(env, fn);
+
+ QImage *image = new QImage();
+ bool retVal = image->load( *filename );
+ delete filename;
+
+ if(image->isNull() && !retVal)
+ {
+ setNativePtr(env, obj, NULL);
+ return JNI_FALSE;
+ }
+
+ setNativePtr(env, obj, image);
+
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "width", "I" );
+ env->SetIntField( obj, field, image->width() );
+ field = env->GetFieldID( cls, "height", "I" );
+ env->SetIntField( obj, field, image->height() );
+
+ return JNI_TRUE;
+}
+
+/*
+ * Creates the image from an array of java bytes.
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_qt_QtImage_loadImageFromData
+(JNIEnv *env, jobject obj, jbyteArray data)
+{
+ jbyte *src_array, *src;
+ bool retVal;
+
+ src = env->GetByteArrayElements(data, NULL);
+ int len = env->GetArrayLength( data );
+
+ QImage *image = new QImage();
+ retVal = image->loadFromData( (uchar *) src, len);
+ env->ReleaseByteArrayElements(data, src, 0);
+
+ if(image->isNull() || retVal == false)
+ {
+ setNativePtr(env, obj, NULL);
+ return JNI_FALSE;
+ }
+
+ setNativePtr(env, obj, image);
+
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "width", "I" );
+ env->SetIntField( obj, field, image->width() );
+ field = env->GetFieldID( cls, "height", "I" );
+ env->SetIntField( obj, field, image->height() );
+
+ return JNI_TRUE;
+}
+
+
+/*
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_createScaledImage
+(JNIEnv *env, jobject obj, jobject src, jint hints)
+{
+ int w,h;
+ jclass cls;
+ jfieldID field;
+
+ cls = env->GetObjectClass( obj );
+ field = env->GetFieldID(cls, "width", "I");
+ assert (field != 0);
+ w = env->GetIntField(obj, field);
+
+ field = env->GetFieldID(cls, "height", "I");
+ assert (field != 0);
+ h = env->GetIntField(obj, field);
+
+ QImage *image = getQtImage(env, src);
+ assert( image );
+ QImage imageScaled;
+
+ if (hints == SCALE_SMOOTH || hints == SCALE_AREA_AVERAGING)
+ imageScaled = image->scaled(w, h,
+ Qt::IgnoreAspectRatio,
+ Qt::SmoothTransformation);
+ else
+ imageScaled = image->scaled(w, h,
+ Qt::IgnoreAspectRatio,
+ Qt::FastTransformation);
+ QImage *scaledPtr = new QImage( imageScaled );
+
+ // create new QtImage object
+ setNativePtr( env, obj, scaledPtr );
+}
+
+/*
+ * Simple draw without scaling.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_drawPixels
+(JNIEnv *env, jobject obj, jobject graphics, jint bg_red, jint bg_green,
+ jint bg_blue, jint x, jint y, jboolean composite)
+{
+ QImage *image = getQtImage(env, obj);
+ assert( image );
+ QPainter *painter = getPainter( env, graphics );
+ assert( painter );
+ if(composite == JNI_TRUE)
+ painter->fillRect ( x, y, image->width(), image->height(),
+ QColor(bg_red, bg_green, bg_blue ) );
+ painter->drawImage ( QPoint(x, y), *image );
+}
+
+/*
+ * Draw the image with scaling.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_drawPixelsScaled
+(JNIEnv *env, jobject obj, jobject graphics,
+ jint bg_red, jint bg_green, jint bg_blue,
+ jint x, jint y, jint w, jint h, jboolean composite)
+{
+ QImage *image = getQtImage(env, obj);
+ assert( image );
+ QPainter *painter = getPainter( env, graphics );
+ assert( painter );
+
+ if(composite == JNI_TRUE)
+ painter->fillRect ( x, y, w, h, QColor(bg_red, bg_green, bg_blue ) );
+
+ QRectF *srcRect = new QRectF((qreal)0, (qreal)0,
+ (qreal)image->width(), (qreal)image->height());
+ QRectF *dstRect = new QRectF((qreal)x, (qreal)y,
+ (qreal)w, (qreal)h);
+
+ if(composite == JNI_TRUE)
+ painter->fillRect( *dstRect, QColor(bg_red, bg_green, bg_blue ) );
+
+ painter->drawImage( *dstRect, *image, *srcRect);
+
+ delete srcRect;
+ delete dstRect;
+}
+
+/*
+ * Draws a transformed image.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_drawPixelsTransformed
+(JNIEnv *env, jobject obj, jobject graphics, jobject transform)
+{
+ QImage *originalImage = getQtImage(env, obj);
+ assert( originalImage );
+ QPainter *painter = getPainter( env, graphics );
+ assert( painter );
+ QMatrix *matrix = (QMatrix *)getNativeObject(env, transform);
+ assert( matrix );
+
+ // FIXME : Add rendering hint support here.
+ QPoint p = matrix->map( QPoint(0,0) );
+ QImage image = originalImage->transformed ( *matrix, Qt::FastTransformation );
+ painter->drawImage(p, image);
+}
+
+/**
+ * Draws the pixbuf at x, y, scaled to width and height and
+ * optionally composited and/or flipped with a given background color.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_qt_QtImage_drawPixelsScaledFlipped
+(JNIEnv *env, jobject obj, jobject graphics,
+ jint bg_red, jint bg_green, jint bg_blue,
+ jboolean flipx, jboolean flipy,
+ jint srcx, jint srcy, jint srcwidth, jint srcheight,
+ jint dstx, jint dsty, jint dstwidth, jint dstheight,
+ jboolean composite)
+{
+ QImage *originalImage = getQtImage(env, obj);
+ assert( originalImage );
+ QPainter *painter = getPainter( env, graphics );
+ assert( painter );
+
+ QRectF *srcRect = new QRectF((qreal)srcx, (qreal)srcy,
+ (qreal)srcwidth, (qreal)srcheight);
+ QRectF *dstRect = new QRectF((qreal)dstx, (qreal)dsty,
+ (qreal)dstwidth, (qreal)dstheight);
+
+ QImage image;
+ if( flipx == JNI_TRUE || flipy == JNI_TRUE)
+ image = originalImage->mirrored ( (flipx == JNI_TRUE),
+ (flipy == JNI_TRUE) );
+ else
+ image = *originalImage;
+
+ if(composite == JNI_TRUE)
+ painter->fillRect( *dstRect, QColor(bg_red, bg_green, bg_blue ) );
+
+ painter->drawImage( *dstRect, image, *srcRect);
+
+ delete srcRect;
+ delete dstRect;
+}
+
+/**
+ * Copies an area of the image (used by Graphics)
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtImage_copyArea
+(JNIEnv *env, jobject obj , jint x, jint y, jint w, jint h, jint dx, jint dy)
+{
+ QImage *image = getQtImage(env, obj);
+ assert( image );
+ QImage area = image->copy(x, y, w, h);
+ QPainter *p = new QPainter( image );
+ p->drawImage( x + dx, y + dy, area );
+ delete p;
+}
diff --git a/libjava/classpath/native/jni/qt-peer/qtimage.h b/libjava/classpath/native/jni/qt-peer/qtimage.h
new file mode 100644
index 000000000..8772086ce
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtimage.h
@@ -0,0 +1,10 @@
+#ifndef QTIMAGE_H
+#define QTIMAGE_H
+
+#include <QImage>
+#include <QPixmap>
+
+QImage *getQtImage( JNIEnv *env, jobject obj );
+QPixmap *getQtVolatileImage( JNIEnv *env, jobject obj );
+
+#endif
diff --git a/libjava/classpath/native/jni/qt-peer/qtlabelpeer.cpp b/libjava/classpath/native/jni/qt-peer/qtlabelpeer.cpp
new file mode 100644
index 000000000..6cbadece6
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtlabelpeer.cpp
@@ -0,0 +1,151 @@
+/* qtlabelpeer.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <QLabel>
+#include <QString>
+#include <gnu_java_awt_peer_qt_QtLabelPeer.h>
+#include "qtcomponent.h"
+#include "qtstrings.h"
+#include "mainthreadinterface.h"
+#include "keybindings.h"
+
+// java.awt.Label justification fields
+#define LEFT 0
+#define CENTER 1
+#define RIGHT 2
+
+class MyLabel : public QLabel
+{
+public:
+ MyLabel(JNIEnv *env, jobject obj, QWidget *parent) : QLabel( parent )
+ {
+ setup(env, obj);
+ }
+
+ ~MyLabel()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QLabel
+#include "eventmethods.h"
+};
+
+class LabelTitle : public AWTEvent {
+
+ private:
+ QLabel *widget;
+ QString *string;
+ Qt::Alignment alignment;
+
+ public:
+ LabelTitle(QLabel *w, QString *s, Qt::Alignment a) : AWTEvent()
+ {
+ widget = w;
+ string = s;
+ alignment = a;
+ }
+
+ void runEvent()
+ {
+ if( string != NULL)
+ {
+ widget->setText( *string );
+ delete string;
+ }
+ else
+ {
+ widget->setAlignment( alignment );
+ }
+ }
+};
+
+/*
+ * Init a QLabel
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtLabelPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *) getParentWidget( env, obj );
+ QLabel *label = new MyLabel( env, obj, parentWidget );
+ assert( label );
+ setNativeObject( env, obj, label );
+}
+
+/*
+ * Sets the text
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtLabelPeer_setText
+(JNIEnv *env, jobject obj, jstring str)
+{
+ QLabel *label = (QLabel *) getNativeObject( env, obj );
+ assert( label );
+
+ QString *qStr = getQString(env, str);
+ mainThread->postEventToMain( new LabelTitle( label, qStr, 0 ) );
+}
+
+/*
+ * Sets the alignment
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtLabelPeer_setAlignment
+(JNIEnv *env, jobject obj, jint align)
+{
+ Qt::Alignment alignment = Qt::AlignVCenter;
+
+ QLabel *label = (QLabel *) getNativeObject( env, obj );
+ assert( label );
+
+ switch(align)
+ {
+ case LEFT:
+ alignment |= Qt::AlignLeft;
+ break;
+
+ case RIGHT:
+ alignment |= Qt::AlignRight;
+ break;
+
+ default:
+ case CENTER:
+ alignment |= Qt::AlignHCenter;
+ break;
+ }
+ mainThread->postEventToMain( new LabelTitle( label, NULL, alignment ) );
+}
diff --git a/libjava/classpath/native/jni/qt-peer/qtlistpeer.cpp b/libjava/classpath/native/jni/qt-peer/qtlistpeer.cpp
new file mode 100644
index 000000000..027d47880
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtlistpeer.cpp
@@ -0,0 +1,210 @@
+/* qtlistpeer.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <QWidget>
+#include <QListWidget>
+#include <gnu_java_awt_peer_qt_QtListPeer.h>
+#include "qtcomponent.h"
+#include "qtstrings.h"
+#include "mainthreadinterface.h"
+#include "slotcallbacks.h"
+
+class ListInsert : public AWTEvent {
+
+ private:
+ QListWidget *widget;
+ QString *string;
+ int index;
+
+ public:
+ ListInsert(QListWidget *w, QString *s, int i) : AWTEvent()
+ {
+ widget = w;
+ string = s;
+ index = i;
+ }
+
+ void runEvent()
+ {
+ widget->insertItem( index, *string );
+ delete string;
+ }
+};
+
+class SelectEvent : public AWTEvent {
+
+ private:
+ QListWidget *widget;
+ int index;
+ bool selected;
+
+ public:
+ SelectEvent(QListWidget *w, int i, bool s) : AWTEvent()
+ {
+ widget = w;
+ index = i;
+ selected = s;
+ }
+
+ void runEvent()
+ {
+ widget->setItemSelected ( widget->item(index), selected );
+ }
+};
+
+class ListDelete : public AWTEvent {
+
+ private:
+ QListWidget *widget;
+ int startIndex, endIndex;
+
+ public:
+ ListDelete(QListWidget *w, int starti, int endi) : AWTEvent()
+ {
+ widget = w;
+ startIndex = starti;
+ endIndex = endi;
+ }
+
+ void runEvent()
+ {
+ for (int i = endIndex; i >= startIndex; i--)
+ delete widget->takeItem(i);
+ }
+};
+
+/*
+ * Construct a QListWidget object
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *)getParentWidget(env, obj);
+ assert( parentWidget );
+ QListWidget *list = new QListWidget( parentWidget );
+ assert( list );
+
+ setNativeObject( env, obj, list );
+ connectList(list, env, obj);
+}
+
+/*
+ * Adds an element.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_add
+(JNIEnv *env, jobject obj, jstring str, jint index)
+{
+ QListWidget *list = (QListWidget *) getNativeObject( env, obj );
+ assert( list );
+ QString *qStr = getQString(env, str);
+ mainThread->postEventToMain( new ListInsert(list, qStr, index) );
+}
+
+/*
+ * Delete items
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_delItems
+(JNIEnv *env, jobject obj, jint startindex, jint endindex)
+{
+ QListWidget *list = (QListWidget *) getNativeObject( env, obj );
+ assert( list );
+ mainThread->postEventToMain( new ListDelete(list, startindex, endindex) );
+}
+
+/*
+ * (De)select an element.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_select
+(JNIEnv *env, jobject obj, jint index, jboolean sel)
+{
+ QListWidget *list = (QListWidget *) getNativeObject( env, obj );
+ assert( list );
+
+ mainThread->postEventToMain( new SelectEvent(list, index,
+ (sel == JNI_TRUE)) );
+}
+
+/**
+ * Returns the indices of the selected items.
+ */
+JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_getSelectedIndexes
+ (JNIEnv *env, jobject obj)
+{
+ jintArray retArray;
+ jint *arr;
+
+ QListWidget *list = (QListWidget *) getNativeObject( env, obj );
+ assert( list );
+
+ QList<QListWidgetItem *> items = list->selectedItems();
+ retArray = env->NewIntArray( items.count() );
+ arr = env->GetIntArrayElements( retArray, NULL );
+
+ for(int i = 0; i < items.count(); i++)
+ arr[i] = list->row(items.at(i));
+
+ env->ReleaseIntArrayElements( retArray, arr, 0 );
+ return retArray;
+}
+
+/*
+ * Sets the current item and makes it visible.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_makeVisible
+ (JNIEnv *env, jobject obj, jint index)
+{
+
+ QListWidget *list = (QListWidget *) getNativeObject( env, obj );
+ assert( list );
+
+ list->scrollToItem( list->item(index) );
+}
+
+/*
+ * Set multiple selection mode.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtListPeer_setMultipleMode
+(JNIEnv *env, jobject obj, jboolean allow)
+{
+ QListWidget *list = (QListWidget *) getNativeObject( env, obj );
+ assert( list );
+
+ // FIXME: Multiple selection is buggy in Qt4. Workaround needed.
+ list->setSelectionMode( ((allow == JNI_TRUE) ? QAbstractItemView::MultiSelection : QAbstractItemView::SingleSelection) );
+}
+
diff --git a/libjava/classpath/native/jni/qt-peer/qtmenubarpeer.cpp b/libjava/classpath/native/jni/qt-peer/qtmenubarpeer.cpp
new file mode 100644
index 000000000..2c855773e
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtmenubarpeer.cpp
@@ -0,0 +1,150 @@
+/* qtmenubarpeer.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <QMenuBar>
+#include <QToolBar>
+#include <QMenu>
+#include <QList>
+#include <QThread>
+#include <gnu_java_awt_peer_qt_QtMenuBarPeer.h>
+#include "nativewrapper.h"
+#include "qtstrings.h"
+#include "mainthreadinterface.h"
+
+/*
+ * Event wrapper to add a menu to a menu bar
+ */
+class MenuBarAdd : public AWTEvent {
+
+ private:
+ QMenuBar *widget;
+ QMenu *menu;
+ bool isHelp;
+
+ public:
+ MenuBarAdd(QMenuBar *w, QMenu *m, bool help) : AWTEvent()
+ {
+ widget = w;
+ menu = m;
+ isHelp = help;
+ }
+
+ void runEvent()
+ {
+ if ( isHelp )
+ widget->addSeparator();
+ QAction *ptr = widget->addMenu( menu );
+ }
+};
+
+/**
+ * Event wrapper to remove a menu from a menu bar.
+ */
+class MenuBarRemove : public AWTEvent {
+
+ private:
+ QMenuBar *widget;
+ QMenu *menu;
+
+ public:
+ MenuBarRemove(QMenuBar *w, QMenu *m) : AWTEvent()
+ {
+ widget = w;
+ menu = m;
+ }
+
+ void runEvent()
+ {
+ // FIXME
+ }
+};
+
+
+/*
+ * Constructs a QMenuBar object.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuBarPeer_init
+ (JNIEnv *env, jobject obj)
+{
+ QMenuBar *menubar = new QMenuBar();
+ assert( menubar );
+ setNativeObject( env, obj, menubar );
+}
+
+/*
+ * Adds a menu item.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuBarPeer_addMenu
+(JNIEnv *env, jobject obj, jobject menuPeer)
+{
+ QMenuBar *menubar = (QMenuBar *)getNativeObject(env, obj);
+ assert( menubar );
+ QMenu *menu = (QMenu *)getNativeObject(env, menuPeer);
+ assert( menu );
+ mainThread->postEventToMain( new MenuBarAdd( menubar, menu, false ) );
+}
+
+/*
+ * Add a help menu.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuBarPeer_addHelpMenu
+(JNIEnv *env, jobject obj, jobject menuPeer)
+{
+ QMenuBar *menubar = (QMenuBar *)getNativeObject(env, obj);
+ assert( menubar );
+ QMenu *menu = (QMenu *)getNativeObject(env, menuPeer);
+ assert( menu );
+
+ mainThread->postEventToMain( new MenuBarAdd( menubar, menu, true ) );
+}
+
+/*
+ * Delete a menu.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuBarPeer_delMenu
+(JNIEnv *env, jobject obj, jobject menuPeer)
+{
+ QMenuBar *menubar = (QMenuBar *)getNativeObject(env, obj);
+ assert( menubar );
+ QMenu *menu = (QMenu *)getNativeObject(env, menuPeer);
+ assert( menu );
+
+ // FIXME
+
+}
+
diff --git a/libjava/classpath/native/jni/qt-peer/qtmenucomponentpeer.cpp b/libjava/classpath/native/jni/qt-peer/qtmenucomponentpeer.cpp
new file mode 100644
index 000000000..c924bcc91
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtmenucomponentpeer.cpp
@@ -0,0 +1,66 @@
+/* qtmenucomponentpeer.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <QWidget>
+#include <gnu_java_awt_peer_qt_QtMenuComponentPeer.h>
+#include "nativewrapper.h"
+#include "componentevent.h"
+
+
+/**
+ * Calls back init() from the main thread.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuComponentPeer_callInit
+(JNIEnv *env, jobject obj)
+{
+ mainThread->postEventToMain( new AWTInitEvent( env, obj ) );
+ // wait for the thing to be created.
+}
+
+/*
+ * Generic disposal.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuComponentPeer_dispose
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *) getNativeObject( env, obj );
+ assert( widget );
+
+ setNativeObject(env, obj, NULL);
+ mainThread->postEventToMain( new AWTDestroyEvent( widget ) );
+}
diff --git a/libjava/classpath/native/jni/qt-peer/qtmenuitempeer.cpp b/libjava/classpath/native/jni/qt-peer/qtmenuitempeer.cpp
new file mode 100644
index 000000000..0d0b92e19
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtmenuitempeer.cpp
@@ -0,0 +1,182 @@
+/* qtmenuitempeer.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <QMenu>
+#include <QAction>
+#include <QThread>
+#include <gnu_java_awt_peer_qt_QtMenuItemPeer.h>
+#include "nativewrapper.h"
+#include "qtstrings.h"
+#include "mainthreadinterface.h"
+
+class MenuItemDestroyEvent : public AWTEvent {
+
+ private:
+ QAction *widget;
+
+ public:
+ MenuItemDestroyEvent(QAction *w)
+ {
+ widget = w;
+ }
+
+ void runEvent()
+ {
+ delete widget;
+ }
+};
+
+class MenuItemLabelEvent : public AWTEvent {
+
+ private:
+ QAction *widget;
+ QString *string;
+
+ public:
+ MenuItemLabelEvent(QAction *w, QString *s) : AWTEvent()
+ {
+ widget = w;
+ string = s;
+ }
+
+ void runEvent()
+ {
+ widget->setText( *string );
+ delete string;
+ }
+};
+
+class MenuItemStatusEvent : public AWTEvent {
+
+ private:
+ QAction *widget;
+ bool enabled;
+ bool value;
+
+ public:
+ MenuItemStatusEvent(QAction *w, bool e, bool v) : AWTEvent()
+ {
+ widget = w;
+ enabled = e;
+ value = v;
+ }
+
+ void runEvent()
+ {
+ if( enabled )
+ widget->setEnabled( value );
+ else
+ widget->setChecked( value );
+ }
+};
+
+/*
+ * Creates a QAction object
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuItemPeer_create
+(JNIEnv *env, jobject obj, jstring label, jboolean isSeperator, jboolean isCheckable)
+{
+ QAction *action;
+ if(label == NULL || isSeperator == JNI_TRUE)
+ {
+ action = new QAction(NULL);
+ action->setSeparator(true);
+ assert( action );
+ }
+ else
+ {
+ QString *qStr = getQString(env, label);
+ action = new QAction(*qStr, NULL);
+ delete qStr;
+ assert( action );
+ action->setCheckable( (isCheckable == JNI_TRUE) );
+ }
+
+ setNativeObject( env, obj, action );
+}
+
+/**
+ * Disposal.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuItemPeer_dispose
+(JNIEnv *env, jobject obj)
+{
+ QAction *action = (QAction *)getNativeObject( env, obj );
+ assert( action );
+ mainThread->postEventToMain( new MenuItemDestroyEvent( action ) );
+}
+
+/*
+ * Enables/disables the item
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuItemPeer_setEnabled
+(JNIEnv *env, jobject obj, jboolean enabled)
+{
+ QAction *action = (QAction *)getNativeObject( env, obj );
+ assert( action );
+ mainThread->postEventToMain(new MenuItemStatusEvent(action, true,
+ (enabled == JNI_TRUE)));
+}
+
+/*
+ * Sets the item label.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuItemPeer_setLabel
+(JNIEnv *env, jobject obj, jstring label)
+{
+ QAction *action = (QAction *)getNativeObject( env, obj );
+ assert( action );
+
+ QString *qStr = getQString(env, label);
+ mainThread->postEventToMain( new MenuItemLabelEvent( action, qStr ) );
+}
+
+/*
+ * Sets the checkbox state.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuItemPeer_setState
+(JNIEnv *env, jobject obj, jboolean state)
+{
+ QAction *action = (QAction *)getNativeObject( env, obj );
+ assert( action );
+ mainThread->postEventToMain(new MenuItemStatusEvent(action, false,
+ (state == JNI_TRUE)));
+}
+
+
+
diff --git a/libjava/classpath/native/jni/qt-peer/qtmenupeer.cpp b/libjava/classpath/native/jni/qt-peer/qtmenupeer.cpp
new file mode 100644
index 000000000..6f35c89b9
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtmenupeer.cpp
@@ -0,0 +1,254 @@
+/* qtmenupeer.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <QMenu>
+#include <gnu_java_awt_peer_qt_QtMenuPeer.h>
+#include "nativewrapper.h"
+#include "qtstrings.h"
+#include "mainthreadinterface.h"
+#include "slotcallbacks.h"
+#include "componentevent.h"
+
+typedef enum ActionType {
+ ActionMenu,
+ ActionItem,
+ ActionSeparator
+} ActionType;
+
+// Sets the title, but also tear-off.
+class MenuTitleEvent : public AWTEvent {
+
+ private:
+ QMenu *widget;
+ QString *string;
+ bool tearOff;
+
+ public:
+ MenuTitleEvent(QMenu *w, QString *s, bool tear) : AWTEvent()
+ {
+ widget = w;
+ string = s;
+ tearOff = tear;
+ }
+
+ void runEvent()
+ {
+ if (tearOff)
+ widget->setTearOffEnabled( true );
+ else
+ {
+ widget->setTitle( *string );
+ delete string;
+ }
+ }
+};
+
+class MenuAction : public AWTEvent {
+
+ private:
+ QMenu *menu;
+ QAction *action;
+ ActionType actionType; // type of action to add
+ JavaVM *vm;
+ jobject menuPeer;
+ jobject itemPeer;
+
+public:
+ MenuAction(JNIEnv *env, jobject mp, jobject ip, QMenu *m, QAction *a,
+ ActionType actionType) : AWTEvent()
+ {
+ menu = m;
+ action = a;
+ this->actionType = actionType;
+ env->GetJavaVM( &vm );
+ menuPeer = env->NewGlobalRef( mp );
+ if( ip != NULL )
+ itemPeer = env->NewGlobalRef( ip );
+ else
+ itemPeer = NULL;
+ }
+
+ void runEvent()
+ {
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ if (actionType == ActionMenu)
+ menu->addMenu ((QMenu *) action);
+ else
+ menu->addAction (action);
+
+ jclass menuCls = env->GetObjectClass( menuPeer );
+ jmethodID mid = env->GetMethodID(menuCls, "add", "(J)V");
+ env->DeleteLocalRef(menuCls);
+ env->CallVoidMethod( menuPeer, mid, (jlong)action );
+
+ env->DeleteGlobalRef( menuPeer );
+ if( itemPeer != NULL )
+ {
+ setNativeObject( env, itemPeer, action );
+ connectAction(action, env, itemPeer);
+ env->DeleteGlobalRef( itemPeer );
+ }
+ }
+};
+
+class MenuRemoveAction : public AWTEvent {
+
+ private:
+ QMenu *menu;
+ QAction *action;
+
+public:
+ MenuRemoveAction(QMenu *m, QAction *a) : AWTEvent()
+ {
+ menu = m;
+ action = a;
+ }
+
+ void runEvent()
+ {
+ if (action)
+ menu->removeAction(action);
+ }
+};
+
+/*
+ * Constructs a QMenu item
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QMenu *menu = new QMenu();
+ assert( menu );
+
+ setNativeObject( env, obj, menu );
+}
+
+/**
+ * Allows tear-off: Only called once, if ever.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_allowTearOff
+(JNIEnv *env, jobject obj)
+{
+ QMenu *menu = (QMenu *)getNativeObject( env, obj );
+ assert( menu );
+ mainThread->postEventToMain( new MenuTitleEvent( menu, NULL, true ) );
+}
+
+/*
+ * Inserts a seperator.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_insertSeperator
+(JNIEnv *env, jobject obj)
+{
+ QMenu *menu = (QMenu *)getNativeObject( env, obj );
+ assert( menu );
+ mainThread->postEventToMain( new MenuAction( env, obj, NULL,
+ menu, NULL, ActionSeparator ) );
+}
+
+/*
+ * Inserts an item.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_insertItem
+(JNIEnv *env, jobject obj, jobject item)
+{
+ QMenu *menu = (QMenu *)getNativeObject( env, obj );
+ assert( menu );
+
+ QAction *action = (QAction *)getNativeObject( env, item );
+ assert( action );
+
+ mainThread->postEventToMain( new MenuAction( env, obj, item, menu, action, ActionItem ));
+}
+
+/*
+ * Inserts a sub-menu
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_insertMenu
+(JNIEnv *env, jobject obj, jobject menu)
+{
+ assert( menu );
+ QMenu *thisMenu = (QMenu *)getNativeObject( env, obj );
+ assert( thisMenu );
+ QMenu *insMenu = (QMenu *)getNativeObject(env, menu);
+ assert( insMenu );
+
+ mainThread->postEventToMain( new MenuAction( env, obj, menu, thisMenu, (QAction *)insMenu, ActionMenu ) );
+}
+
+/*
+ * Removes an item at index.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_delItem
+(JNIEnv *env, jobject obj, jlong ptr)
+{
+ QMenu *menu = (QMenu *)getNativeObject( env, obj );
+ assert( menu );
+ QAction *action = (QAction *)ptr;
+
+ mainThread->postEventToMain( new MenuRemoveAction( menu, action ) );
+}
+
+/*
+ * Enables/Disables the menu.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_setEnabled
+(JNIEnv *env, jobject obj, jboolean enabled)
+{
+ QMenu *menu = (QMenu *)getNativeObject( env, obj );
+ assert( menu );
+
+ mainThread->postEventToMain(new AWTEnableEvent(menu, (enabled == JNI_TRUE)));
+}
+
+/*
+ * Sets the menu title.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_setLabel
+(JNIEnv *env, jobject obj, jstring label)
+{
+ if(label == NULL)
+ return;
+
+ QMenu *menu = (QMenu *)getNativeObject( env, obj );
+ assert( menu );
+ QString *qStr = getQString(env, label);
+ mainThread->postEventToMain( new MenuTitleEvent( menu, qStr, false ) );
+}
+
diff --git a/libjava/classpath/native/jni/qt-peer/qtpanelpeer.cpp b/libjava/classpath/native/jni/qt-peer/qtpanelpeer.cpp
new file mode 100644
index 000000000..68aef4864
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtpanelpeer.cpp
@@ -0,0 +1,77 @@
+/* qtpanelpeer.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <qwidget.h>
+#include <gnu_java_awt_peer_qt_QtPanelPeer.h>
+#include "qtcomponent.h"
+#include "keybindings.h"
+
+class MyPanel : public QWidget
+{
+public:
+ MyPanel(JNIEnv *env, jobject obj, QWidget *parent) : QWidget( parent )
+ {
+ setup(env, obj);
+ }
+
+ ~MyPanel()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QWidget
+#include "eventmethods.h"
+#undef I_KNOW_WHAT_IM_DOING
+#undef PARENT
+};
+
+/**
+ * Init
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtPanelPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *) getParentWidget( env, obj );
+ QWidget *canvas = new MyPanel( env, obj, parentWidget );
+ assert( canvas );
+
+ setNativeObject( env, obj, canvas );
+}
+
+
diff --git a/libjava/classpath/native/jni/qt-peer/qtpopupmenupeer.cpp b/libjava/classpath/native/jni/qt-peer/qtpopupmenupeer.cpp
new file mode 100644
index 000000000..56784a591
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtpopupmenupeer.cpp
@@ -0,0 +1,76 @@
+/* qtpopupmenupeer.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <QMenu>
+#include <QPoint>
+#include <QWidget>
+#include <gnu_java_awt_peer_qt_QtPopupMenuPeer.h>
+#include "nativewrapper.h"
+#include "qtstrings.h"
+#include "mainthreadinterface.h"
+
+class PopupMenuShowEvent : public AWTEvent {
+
+ private:
+ QMenu *menu;
+ int x, y;
+
+ public:
+ PopupMenuShowEvent(QMenu *m, int x0, int y0) : AWTEvent()
+ {
+ menu = m;
+ x = x0;
+ y = y0;
+ }
+
+ void runEvent()
+ {
+ menu->exec( QPoint( x, y ) );
+ }
+};
+
+/*
+ * Shows the menu.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtPopupMenuPeer_showNative
+(JNIEnv *env, jobject obj, jint x, jint y)
+{
+ QMenu *menu = (QMenu *)getNativeObject( env, obj );
+ assert( menu );
+ mainThread->postEventToMain( new PopupMenuShowEvent(menu, x, y ) );
+}
diff --git a/libjava/classpath/native/jni/qt-peer/qtscreendevice.cpp b/libjava/classpath/native/jni/qt-peer/qtscreendevice.cpp
new file mode 100644
index 000000000..c5cc2fe37
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtscreendevice.cpp
@@ -0,0 +1,123 @@
+/* qtscreendevice.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <QApplication>
+#include <QDesktopWidget>
+#include <gnu_java_awt_peer_qt_QtScreenDevice.h>
+#include "nativewrapper.h"
+
+extern QApplication *qApplication;
+
+/*
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScreenDevice_init
+(JNIEnv *env, jobject obj, jint id)
+{
+ QWidget *widget = qApplication->desktop()->screen( id );
+ assert( widget );
+ setNativeObject(env, obj, widget);
+}
+
+/*
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScreenDevice_dispose
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *)getNativeObject(env, obj);
+ setNativeObject(env, obj, NULL);
+ if( widget )
+ delete widget;
+}
+
+/*
+ * Returns the bounds
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtScreenDevice_getBounds
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *)getNativeObject(env, obj);
+ assert( widget );
+
+ jclass cls = env->FindClass("java/awt/Rectangle");
+ jmethodID mid = env->GetMethodID(cls, "<init>", "(IIII)V");
+ jvalue values[4];
+
+ int x,y,w,h;
+ widget->geometry().getRect( &x, &y, &w, &h );
+
+ values[0].i = (jint) x;
+ values[1].i = (jint) y;
+ values[2].i = (jint) w;
+ values[3].i = (jint) h;
+
+ return env->NewObjectA(cls, mid, values);
+}
+
+/*
+ * Returns the X DPI
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtScreenDevice_getDpiX
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *)getNativeObject(env, obj);
+ assert( widget );
+ return widget->logicalDpiX();
+}
+
+/*
+ * Returns the Y DPI
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtScreenDevice_getDpiY
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *)getNativeObject(env, obj);
+ assert( widget );
+ return widget->logicalDpiY();
+}
+
+/*
+ * Returns the bitplane depth
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtScreenDevice_depth
+(JNIEnv *env, jobject obj)
+{
+ QWidget *widget = (QWidget *)getNativeObject(env, obj);
+ assert( widget );
+ return widget->depth();
+}
+
diff --git a/libjava/classpath/native/jni/qt-peer/qtscrollbarpeer.cpp b/libjava/classpath/native/jni/qt-peer/qtscrollbarpeer.cpp
new file mode 100644
index 000000000..0649ebd17
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtscrollbarpeer.cpp
@@ -0,0 +1,142 @@
+/* qtscrollbarpeer.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <QScrollBar>
+#include <gnu_java_awt_peer_qt_QtScrollbarPeer.h>
+#include "keybindings.h"
+#include "slotcallbacks.h"
+#include "qtcomponent.h"
+
+// Constant fields from java.awt.Scrollbar
+#define HORIZONTAL 0
+#define VERTICAL 1
+
+class MyScrollBar : public QScrollBar
+{
+public:
+ MyScrollBar(JNIEnv *env, jobject obj, QWidget *parent) : QScrollBar( parent )
+ {
+ setup(env, obj);
+ }
+
+ ~MyScrollBar()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QScrollBar
+#include "eventmethods.h"
+};
+
+/*
+ * Construct a QScrollbar object
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollbarPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *)getParentWidget( env, obj );
+ assert( parentWidget );
+ // QScrollBar *scrollbar = new QScrollBar( parentWidget );
+ MyScrollBar *scrollbar = new MyScrollBar( env, obj, parentWidget );
+ assert( scrollbar );
+
+ setNativeObject( env, obj, scrollbar );
+ connectScrollBar(scrollbar, env, obj);
+}
+
+/*
+ * Set the line increment.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollbarPeer_setLineIncrement
+(JNIEnv *env, jobject obj, jint inc)
+{
+ QScrollBar *bar = (QScrollBar *) getNativeObject( env, obj );
+ assert( bar );
+
+ bar->setSingleStep(inc);
+}
+
+/**
+ * Sets the orientation of the scrollbar
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollbarPeer_setOrientation
+(JNIEnv *env, jobject obj, jint orientation)
+{
+ QScrollBar *bar = (QScrollBar *) getNativeObject( env, obj );
+ assert( bar );
+
+ switch(orientation)
+ {
+ case HORIZONTAL:
+ bar->setOrientation ( Qt::Horizontal );
+ break;
+
+ default:
+ case VERTICAL:
+ bar->setOrientation ( Qt::Vertical );
+ break;
+ }
+}
+
+/**
+ * Sets the page increment (equivalent to slider size)
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollbarPeer_setPageIncrement
+(JNIEnv *env, jobject obj, jint inc)
+{
+ QScrollBar *bar = (QScrollBar *) getNativeObject( env, obj );
+ assert( bar );
+
+ bar->setPageStep( inc );
+}
+
+/*
+ * Setvalues.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollbarPeer_setValues
+(JNIEnv *env, jobject obj, jint value, jint visible, jint min, jint max)
+{
+ QScrollBar *bar = (QScrollBar *) getNativeObject( env, obj );
+ assert( bar );
+
+ bar->setValue(value);
+ bar->setPageStep( visible ); // page step and slider size are the same in Qt
+ bar->setRange( min , max );
+}
+
diff --git a/libjava/classpath/native/jni/qt-peer/qtscrollpanepeer.cpp b/libjava/classpath/native/jni/qt-peer/qtscrollpanepeer.cpp
new file mode 100644
index 000000000..b7bf64a90
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtscrollpanepeer.cpp
@@ -0,0 +1,214 @@
+/* qtscrollpanepeer.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <QScrollArea>
+#include <QScrollBar>
+#include <gnu_java_awt_peer_qt_QtScrollPanePeer.h>
+#include "qtcomponent.h"
+#include "containers.h"
+#include "mainthreadinterface.h"
+#include "componentevent.h"
+#include "keybindings.h"
+
+// Constants in java.awt.ScrollPane
+#define SCROLLBARS_AS_NEEDED 0
+#define SCROLLBARS_ALWAYS 1
+#define SCROLLBARS_NEVER 2
+
+
+class MyScrollArea : public QScrollArea
+{
+public:
+ MyScrollArea(JNIEnv *env, jobject obj, QWidget *parent) : QScrollArea( parent )
+ {
+ setup(env, obj);
+ }
+
+ ~MyScrollArea()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QScrollArea
+#include "eventmethods.h"
+};
+
+
+class ScrollPanePolicy : public AWTEvent {
+
+ private:
+ QScrollArea *widget;
+ Qt::ScrollBarPolicy policy;
+
+ public:
+ ScrollPanePolicy(QScrollArea *w, Qt::ScrollBarPolicy p) : AWTEvent()
+ {
+ widget = w;
+ policy = p;
+ }
+
+ void runEvent()
+ {
+ widget->setHorizontalScrollBarPolicy(policy);
+ widget->setVerticalScrollBarPolicy(policy);
+ }
+};
+
+/**
+ * Returns the child widget, given the owner Component.
+ */
+QWidget *scrollPaneChildWidget( JNIEnv *env, jobject component )
+{
+ jclass scrollpaneCls = env->FindClass( "java/awt/ScrollPane" );
+ jmethodID getPeerMID = env->GetMethodID( scrollpaneCls,
+ "getPeer",
+ "()Ljava/awt/peer/ComponentPeer;");
+ assert(getPeerMID != 0);
+ jobject scrollpanepeerobj = env->CallObjectMethod( component, getPeerMID, NULL );
+ QScrollArea *view = (QScrollArea *) getNativeObject( env, scrollpanepeerobj );
+ assert(view != 0);
+ return view->viewport();
+}
+
+/*
+ * Creates a QScrollArea object.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *) getParentWidget( env, obj );
+ assert( parentWidget );
+ // QScrollArea *pane = new MyScrollArea( env, obj, parentWidget );
+ QScrollArea *pane = new QScrollArea( parentWidget );
+ assert( pane );
+ setNativeObject( env, obj, pane );
+}
+
+/*
+ * Resize the child.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_childResized
+(JNIEnv *env, jobject obj, jint w, jint h)
+{
+ QScrollArea *view = (QScrollArea *) getNativeObject( env, obj );
+ assert( view );
+
+ QWidget *child = view->viewport();
+ assert( child );
+ // child->setGeometry( 0, 0, w, h );
+// child->update();
+ mainThread->postEventToMain( new AWTResizeEvent(child, 0, 0, w, h) );
+}
+
+/*
+ * Returns the horizontal scrollbar height.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_getHScrollbarHeight
+(JNIEnv *env, jobject obj)
+{
+ QScrollArea *pane = (QScrollArea *) getNativeObject( env, obj );
+ assert( pane );
+ QScrollBar *hbar = pane->horizontalScrollBar();
+ if(hbar == NULL)
+ return 0;
+ if(!hbar->isVisible())
+ return 0;
+ int height = hbar->height();
+
+ return height;
+}
+
+/*
+ * Returns the vertical scrollbar width.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_getVScrollbarWidth
+(JNIEnv *env, jobject obj)
+{
+ QScrollArea *pane = (QScrollArea *) getNativeObject( env, obj );
+ assert( pane );
+ QScrollBar *vbar = pane->verticalScrollBar();
+ if(vbar == NULL)
+ return 0;
+ if(!vbar->isVisible())
+ return 0;
+ int width = vbar->width();
+
+ return width;
+}
+
+/*
+ * Sets the current upper-left corner to x, y.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_setScrollPosition
+(JNIEnv *env, jobject obj, jint x, jint y)
+{
+ QScrollArea *pane = (QScrollArea *) getNativeObject( env, obj );
+ assert( pane );
+ // pane->scrollContentsBy( x, y );
+}
+
+/*
+ * Sets the scrollbar policy
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_setPolicy
+(JNIEnv *env, jobject obj, jint policy)
+{
+ QScrollArea *pane = (QScrollArea *) getNativeObject( env, obj );
+ assert( pane );
+
+ Qt::ScrollBarPolicy qtpolicy;
+ switch( policy )
+ {
+ case SCROLLBARS_ALWAYS:
+ qtpolicy = Qt::ScrollBarAlwaysOn;
+ break;
+
+ case SCROLLBARS_NEVER:
+ qtpolicy = Qt::ScrollBarAlwaysOff;
+ break;
+
+ default:
+ case SCROLLBARS_AS_NEEDED:
+ qtpolicy = Qt::ScrollBarAsNeeded;
+ break;
+ }
+
+ mainThread->postEventToMain( new ScrollPanePolicy( pane, qtpolicy ) );
+}
+
diff --git a/libjava/classpath/native/jni/qt-peer/qtstrings.cpp b/libjava/classpath/native/jni/qt-peer/qtstrings.cpp
new file mode 100644
index 000000000..c343c6331
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtstrings.cpp
@@ -0,0 +1,54 @@
+/* qtstrings.cpp --
+ Copyright (C) 2005 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. */
+
+#include "qtstrings.h"
+
+QString *getQString(JNIEnv *env, jstring str)
+{
+ QString qStr;
+ {
+ const char *chars = env->GetStringUTFChars( str, NULL );
+ qStr = QString::fromUtf8( chars, env->GetStringLength( str ) );
+ env->ReleaseStringUTFChars( str, chars );
+ }
+ return new QString(qStr);
+}
+
+jstring getJavaString(JNIEnv *env, QString *qstring)
+{
+ return env->NewStringUTF(qstring->toUtf8());
+}
diff --git a/libjava/classpath/native/jni/qt-peer/qtstrings.h b/libjava/classpath/native/jni/qt-peer/qtstrings.h
new file mode 100644
index 000000000..ba5ab8c99
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtstrings.h
@@ -0,0 +1,10 @@
+#ifndef QTSTRINGS_H
+#define QTSTRINGS_H
+
+#include <jni.h>
+#include <QString>
+
+QString *getQString(JNIEnv *env, jstring str);
+jstring getJavaString(JNIEnv *env, QString *qstring);
+
+#endif
diff --git a/libjava/classpath/native/jni/qt-peer/qttextareapeer.cpp b/libjava/classpath/native/jni/qt-peer/qttextareapeer.cpp
new file mode 100644
index 000000000..50f85b861
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qttextareapeer.cpp
@@ -0,0 +1,197 @@
+/* qttextareapeer.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <time.h>
+#include <QTextEdit>
+#include <QTextCursor>
+#include <gnu_java_awt_peer_qt_QtTextAreaPeer.h>
+#include "mainthreadinterface.h"
+#include "componentevent.h"
+#include "slotcallbacks.h"
+#include "qtcomponent.h"
+#include "qtstrings.h"
+
+class TASetText : public AWTEvent {
+ private:
+ QTextEdit *area;
+ QString *text;
+
+ public:
+ TASetText(QTextEdit *w, QString *t) : AWTEvent()
+ {
+ area = w;
+ text = t;
+ }
+
+ void runEvent()
+ {
+ area->setPlainText( *text );
+ delete text;
+ }
+};
+
+/*
+ * Construct a QTextEdit object
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *)getParentWidget( env, obj );
+ assert( parentWidget );
+ QTextEdit *editor = new QTextEdit( parentWidget );
+ editor->setGeometry( 0, 0, 400, 400 );
+ assert( editor );
+
+ // setLineWrapColumnOrWidth ( int w );
+ setNativeObject( env, obj, editor );
+
+ // Connect TextChanged events.
+ connectTextEdit(editor, env, obj);
+}
+
+/*
+ * Returns the cursor position.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_getCaretPosition
+(JNIEnv *env, jobject obj)
+{
+ int index;
+
+ QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );
+ assert( editor );
+
+ index = editor->textCursor().position();;
+
+ return (jint)index;
+}
+
+/*
+ * Returns the char index at a given screen point
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_getIndexAtPoint
+(JNIEnv *env, jobject obj, jint x, jint y)
+{
+ QPoint *p = new QPoint(x,y);
+
+ QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );
+ assert( editor );
+ QTextCursor curs = editor->cursorForPosition( *p );
+ delete p;
+
+ return curs.position();
+}
+
+/*
+ * Returns the start (start = true) or end (start = false) of the selection.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_getSelection
+(JNIEnv *env, jobject obj, jboolean isStart)
+{
+ int start, end;
+
+ QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );
+ assert( editor );
+ start = editor->textCursor().selectionStart();
+ end = editor->textCursor().selectionEnd();
+
+ return ((isStart == JNI_TRUE) ? start : end);
+}
+
+/*
+ * Returns the text.
+ */
+JNIEXPORT jstring JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_getText
+(JNIEnv *env, jobject obj)
+{
+ QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );
+ assert( editor );
+ QString text = editor->toPlainText();
+
+ return getJavaString(env, &text);
+}
+
+/*
+ * Sets the editor text.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_setText
+(JNIEnv *env, jobject obj, jstring str)
+{
+ QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );
+ assert( editor );
+
+ QString *qStr = getQString(env, str);
+ mainThread->postEventToMain( new TASetText( editor, qStr ) );
+}
+
+/*
+ * Sets the selection.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_select
+(JNIEnv *env, jobject obj, jint startpos, jint endpos)
+{
+ QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );
+ assert( editor );
+
+ QTextCursor curs(editor->document());
+ curs.setPosition(startpos);
+ curs.setPosition(endpos, QTextCursor::KeepAnchor);
+ editor->setTextCursor( curs );
+}
+
+/*
+ * Allow or disallow editing.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_setEditable
+(JNIEnv *env, jobject obj, jboolean editable)
+{
+ QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );
+ assert( editor );
+ editor->setReadOnly( (editable != JNI_TRUE) );
+}
+
+/*
+ * Sets the cursor position
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_setCaretPosition
+(JNIEnv *env, jobject obj, jint index)
+{
+ QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );
+ assert( editor );
+
+ editor->textCursor().setPosition( index );
+}
diff --git a/libjava/classpath/native/jni/qt-peer/qttextfieldpeer.cpp b/libjava/classpath/native/jni/qt-peer/qttextfieldpeer.cpp
new file mode 100644
index 000000000..5c7113379
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qttextfieldpeer.cpp
@@ -0,0 +1,290 @@
+/* qttextfieldpeer.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <QLineEdit>
+#include <QWidget>
+#include <gnu_java_awt_peer_qt_QtTextFieldPeer.h>
+#include "qtcomponent.h"
+#include "qtstrings.h"
+#include "slotcallbacks.h"
+#include "mainthreadinterface.h"
+
+class TFEchoChar : public AWTEvent {
+ private:
+ QLineEdit *line;
+ jchar c;
+
+ public:
+ TFEchoChar(QLineEdit *w, jchar ch) : AWTEvent()
+ {
+ line = w;
+ c = ch;
+ }
+
+ void runEvent()
+ {
+ line->setEchoMode( (c) ? QLineEdit::Password : QLineEdit::Normal );
+ }
+};
+
+class TFEditable : public AWTEvent {
+ private:
+ QLineEdit *line;
+ bool editable;
+
+ public:
+ TFEditable(QLineEdit *w, bool e) : AWTEvent()
+ {
+ line = w;
+ editable = e;
+ }
+
+ void runEvent()
+ {
+ line->setReadOnly( editable );
+ }
+};
+
+class TFSetText : public AWTEvent {
+ private:
+ QLineEdit *line;
+ QString *text;
+
+ public:
+ TFSetText(QLineEdit *w, QString *t) : AWTEvent()
+ {
+ line = w;
+ text = t;
+ }
+
+ void runEvent()
+ {
+ line->setText( *text );
+ delete text;
+ }
+};
+
+class TFSetCursorPos : public AWTEvent {
+ private:
+ QLineEdit *line;
+ int pos;
+
+ public:
+ TFSetCursorPos(QLineEdit *w, int p) : AWTEvent()
+ {
+ line = w;
+ pos = p;
+ }
+
+ void runEvent()
+ {
+ line->setCursorPosition(pos);
+ }
+};
+
+class TFSelect : public AWTEvent {
+ private:
+ QLineEdit *line;
+ int start,end;
+
+ public:
+ TFSelect(QLineEdit *w, int s, int e) : AWTEvent()
+ {
+ line = w;
+ start = s;
+ end = e;
+ }
+
+ void runEvent()
+ {
+ line->setSelection(start, end - start);
+ }
+};
+
+
+/*
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *parentWidget = (QWidget *)getParentWidget(env, obj);
+ assert( parentWidget );
+ QLineEdit *line = new QLineEdit( parentWidget );
+ assert( line );
+
+ setNativeObject( env, obj, line );
+ connectLineEdit(line, env, obj);
+}
+
+
+/*
+ * Sets the echo char.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_setEchoChar
+(JNIEnv *env, jobject obj, jchar echo)
+{
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+ mainThread->postEventToMain( new TFEchoChar( line, echo ) );
+}
+
+/*
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_getMinimumSizeNative
+(JNIEnv *env, jobject obj, jint columns)
+{
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+
+ // FIXME does this work?
+ int old = line->maxLength();
+ line->setMaxLength(columns);
+ QSize size = line->minimumSizeHint();
+ line->setMaxLength(old);
+
+ return makeDimension(env, &size);
+}
+
+/*
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_getPreferredSizeNative
+(JNIEnv *env, jobject obj, jint columns)
+{
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+
+ int old = line->maxLength();
+ line->setMaxLength(columns);
+ QSize size = line->sizeHint();
+ line->setMaxLength(old);
+
+ return makeDimension(env, &size);
+}
+
+/*
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_setEditable
+(JNIEnv *env, jobject obj, jboolean edit)
+{
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+
+ mainThread->postEventToMain( new TFEditable( line, (edit != JNI_TRUE) ) );
+}
+
+/*
+ * Gets the text.
+ */
+JNIEXPORT jstring JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_getText
+(JNIEnv *env, jobject obj)
+{
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+ QString text = line->text();
+
+ return getJavaString(env, &text);
+}
+
+/*
+ * Sets the text
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_setText
+(JNIEnv *env, jobject obj, jstring text)
+{
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+
+ QString *qStr = getQString(env, text);
+ mainThread->postEventToMain( new TFSetText( line, qStr ) );
+}
+
+/*
+ * Returns the start (start = true) or end (start = false) of the selection.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_getSelection
+(JNIEnv *env, jobject obj, jboolean start)
+{
+ int index, length;
+
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+ index = line->selectionStart();
+
+ if(start == JNI_TRUE)
+ return index;
+
+ length = (line->selectedText()).length();
+
+ return index + length;
+}
+
+/*
+ * Sets the selection.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_select
+(JNIEnv *env, jobject obj, jint start, jint end)
+{
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+
+ mainThread->postEventToMain( new TFSelect( line, start, end ) );
+}
+
+/*
+ * Sets the cursor position.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_setCaretPosition
+(JNIEnv *env, jobject obj, jint pos)
+{
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+ mainThread->postEventToMain( new TFSetCursorPos( line, (int)pos ) );
+}
+
+/*
+ * Returns the caret position.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_getCaretPosition
+(JNIEnv *env, jobject obj)
+{
+ QLineEdit *line = (QLineEdit *) getNativeObject( env, obj );
+ assert( line );
+
+ return line->cursorPosition();
+}
+
diff --git a/libjava/classpath/native/jni/qt-peer/qttoolkit.cpp b/libjava/classpath/native/jni/qt-peer/qttoolkit.cpp
new file mode 100644
index 000000000..222b32344
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qttoolkit.cpp
@@ -0,0 +1,156 @@
+/* qttoolkit.cpp --
+ Copyright (C) 2005 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. */
+
+#include <QApplication>
+#include <QDesktopWidget>
+#include <QString>
+#include <QStringList>
+#include <QFontDatabase>
+#include <gnu_java_awt_peer_qt_QtToolkit.h>
+#include "qtcomponent.h"
+#include "mainthreadinterface.h"
+#include "qtstrings.h"
+
+extern QApplication *qApplication;
+
+/**
+ * Calls syncX();
+ */
+class AWTSyncEvent : public AWTEvent {
+
+ private:
+ QApplication *application;
+
+ public:
+ AWTSyncEvent(QApplication *app) : AWTEvent()
+ {
+ application = app;
+ }
+
+ void runEvent()
+ {
+ application->syncX();
+ }
+};
+
+/*
+ * Causes your machine to beep. Wow.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_beep
+(JNIEnv *env, jobject obj)
+{
+ qApplication->beep();
+}
+
+/**
+ * Returns the # of the default screen.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_defaultScreen
+(JNIEnv *env, jobject obj)
+{
+ return (jint) qApplication->desktop()->primaryScreen();
+}
+
+/**
+ * Returns the # of screens.
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_numScreens
+(JNIEnv *env, jobject obj)
+{
+ return (jint) qApplication->desktop()->numScreens();
+}
+
+/*
+ * Returns the screen size.
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_getScreenSize
+(JNIEnv *env, jobject obj)
+{
+ QDesktopWidget *d = QApplication::desktop();
+ QSize s = d->size();
+ return makeDimension( env, &s );
+}
+
+/*
+ * Returns the available fonts
+ */
+JNIEXPORT jobjectArray JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_nativeFontFamilies
+(JNIEnv *env, jobject obj)
+{
+ jobjectArray result_array;
+ jobject *result_array_ptr;
+ QFontDatabase db;
+ QStringList fonts = db.families();
+
+ result_array = env->NewObjectArray(fonts.size(),
+ env->FindClass("java/lang/String"),
+ env->NewStringUTF(""));
+ for (int i = 0; i < fonts.size(); i++)
+ {
+ QString qstr = fonts.at(i);
+ jstring jstr = getJavaString(env, &qstr);
+ env->SetObjectArrayElement( result_array, i, jstr );
+ }
+ return result_array;
+}
+
+
+/*
+ * Returns the screen resolution
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_getScreenResolution
+(JNIEnv *env, jobject obj)
+{
+ QDesktopWidget *d = qApplication->desktop();
+
+ // Java assumes square pixels. Qt, more intelligently, does not.
+ // What to do? Well.. Average them?
+ // FIXME: Weird values?
+ int dpi = (d->logicalDpiX() + d->logicalDpiY()) >> 1;
+
+ return (jint)dpi;
+}
+
+/*
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtToolkit_sync
+(JNIEnv *env, jobject obj)
+{
+ // SyncX needs to be called from the main thread.
+ mainThread->postEventToMain( new AWTSyncEvent( qApplication ) );
+}
+
diff --git a/libjava/classpath/native/jni/qt-peer/qtvolatileimage.cpp b/libjava/classpath/native/jni/qt-peer/qtvolatileimage.cpp
new file mode 100644
index 000000000..9c28db6d1
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtvolatileimage.cpp
@@ -0,0 +1,347 @@
+/* qtvolatileimage.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <QPixmap>
+#include <QImage>
+#include <QColor>
+#include <QMatrix>
+#include <QPainter>
+#include <gnu_java_awt_peer_qt_QtVolatileImage.h>
+#include "qtimage.h"
+#include "qtstrings.h"
+#include "qtgraphics.h"
+#include "nativewrapper.h"
+
+/* The constant fields in java.awt.Image */
+#define SCALE_DEFAULT 1
+#define SCALE_FAST 2
+#define SCALE_SMOOTH 4
+#define SCALE_REPLICATE 8
+#define SCALE_AREA_AVERAGING 16
+
+QPixmap *getQtVolatileImage( JNIEnv *env, jobject obj )
+{
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ return (QPixmap *)env->GetLongField( obj, field );
+}
+
+static void setNativePtr( JNIEnv *env, jobject obj, void *value )
+{
+ jlong longValue = (jlong) value;
+ jclass cls = env->GetObjectClass( obj );
+ jfieldID field = env->GetFieldID( cls, "nativeObject", "J" );
+ env->SetLongField( obj, field, longValue );
+}
+
+/*
+ * Clears the image to zero.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_clear
+(JNIEnv *env, jobject obj)
+{
+ QPixmap *image = getQtVolatileImage(env, obj);
+ assert( image );
+ image->fill();
+}
+
+/*
+ * Returns the pixel data in an int array.
+ */
+JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_getPixels
+(JNIEnv *env, jobject obj)
+{
+ QPixmap *image = getQtVolatileImage(env, obj);
+ jintArray result_array;
+ jint *result_array_ptr, *dst;
+ int x, y;
+ jint pixel;
+ QRgb current;
+
+ assert( image );
+ QImage im = image->toImage();
+
+ result_array = env->NewIntArray (image->width() * image->height());
+ dst = result_array_ptr =
+ env->GetIntArrayElements(result_array, NULL);
+
+ // A bit inefficient.
+ for ( y = 0; y < image->height(); y++)
+ for ( x = 0; x < image->width(); x++)
+ {
+ current = im.pixel(x, y);
+ pixel = 0;
+ pixel = (qAlpha(current) & 0xFF) << 24 |
+ (qRed(current) & 0xFF) << 16 |
+ (qGreen(current) & 0xFF) << 8 |
+ (qBlue(current) & 0xFF);
+ *dst = pixel;
+ dst++;
+ }
+
+ env->ReleaseIntArrayElements (result_array, result_array_ptr, 0);
+ return result_array;
+}
+
+/*
+ * Creates a QImage.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_createImage
+(JNIEnv *env, jobject obj)
+{
+ int width, height;
+ jclass cls;
+ jfieldID field;
+
+ cls = env->GetObjectClass( obj );
+ field = env->GetFieldID (cls, "width", "I");
+ assert (field != 0);
+ width = env->GetIntField(obj, field);
+
+ field = env->GetFieldID(cls, "height", "I");
+ assert (field != 0);
+ height = env->GetIntField(obj, field);
+
+ QPixmap *image = new QPixmap ( width, height );
+ setNativePtr(env, obj, image);
+}
+
+/*
+ * Frees the image data.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_freeImage
+(JNIEnv *env, jobject obj)
+{
+ QPixmap *image = getQtVolatileImage(env, obj);
+ if ( image )
+ delete image;
+ setNativePtr(env, obj, NULL);
+}
+
+/*
+ * Blits a QImage
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_blit__Lgnu_java_awt_peer_qt_QtImage_2
+(JNIEnv *env, jobject obj, jobject i2)
+{
+ QPixmap *image = getQtVolatileImage(env, obj);
+ assert( image );
+
+ QImage *blit = getQtImage(env, i2);
+ assert( blit );
+
+ QPainter *p = new QPainter( image );
+ assert( p );
+ p->drawImage( 0, 0, *blit );
+
+ delete p;
+}
+
+/*
+ * Blits a QImage
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_blit__Lgnu_java_awt_peer_qt_QtImage_2IIII
+(JNIEnv *env, jobject obj, jobject i2, jint x, jint y, jint w, jint h)
+{
+ QPixmap *image = getQtVolatileImage(env, obj);
+ assert( image );
+
+ QImage *blit = getQtImage(env, i2);
+ assert( blit );
+
+ QPainter *p = new QPainter( image );
+ assert( p );
+ p->drawImage( x, y, *blit, x, y, w, h);
+
+ delete p;
+}
+
+/*
+ * Creates a scaled version.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_createScaledImage
+(JNIEnv *env, jobject obj, jobject src, jint hints)
+{
+ int w,h;
+ jclass cls;
+ jfieldID field;
+
+ cls = env->GetObjectClass( obj );
+ field = env->GetFieldID(cls, "width", "I");
+ assert (field != 0);
+ w = env->GetIntField(obj, field);
+
+ field = env->GetFieldID(cls, "height", "I");
+ assert (field != 0);
+ h = env->GetIntField(obj, field);
+
+ QPixmap *ip = getQtVolatileImage(env, src);
+ assert( ip );
+ QImage image = ip->toImage();
+ QImage imageScaled;
+
+ if (hints == SCALE_SMOOTH || hints == SCALE_AREA_AVERAGING)
+ imageScaled = image.scaled(w, h,
+ Qt::IgnoreAspectRatio,
+ Qt::SmoothTransformation);
+ else
+ imageScaled = image.scaled(w, h,
+ Qt::IgnoreAspectRatio,
+ Qt::FastTransformation);
+ QImage *scaledPtr = new QImage( imageScaled );
+
+ // create new QtImage object
+ setNativePtr( env, obj, scaledPtr );
+}
+
+/*
+ * DrawPixels.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_drawPixels
+(JNIEnv *env, jobject obj, jobject graphics, jint bg_red, jint bg_green,
+ jint bg_blue, jint x, jint y, jboolean composite)
+{
+ QPixmap *image = getQtVolatileImage(env, obj);
+ assert( image );
+ QPainter *painter = getPainter( env, graphics );
+ assert( painter );
+
+ if(composite == JNI_TRUE)
+ painter->fillRect ( x, y, image->width(), image->height(),
+ QColor(bg_red, bg_green, bg_blue ) );
+ painter->drawPixmap ( QPoint(x, y), *image );
+}
+
+/*
+ * DrawPixels scaled.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_drawPixelsScaled
+(JNIEnv *env, jobject obj, jobject graphics,
+ jint bg_red, jint bg_green, jint bg_blue,
+ jint x, jint y, jint w, jint h, jboolean composite)
+{
+ QPixmap *image = getQtVolatileImage(env, obj);
+ assert( image );
+ QPainter *painter = getPainter( env, graphics );
+ assert( painter );
+
+ if(composite == JNI_TRUE)
+ painter->fillRect ( x, y, w, h, QColor(bg_red, bg_green, bg_blue ) );
+
+ QRectF *srcRect = new QRectF((qreal)0, (qreal)0,
+ (qreal)image->width(), (qreal)image->height());
+ QRectF *dstRect = new QRectF((qreal)x, (qreal)y,
+ (qreal)w, (qreal)h);
+
+ if(composite == JNI_TRUE)
+ painter->fillRect( *dstRect, QColor(bg_red, bg_green, bg_blue ) );
+
+ painter->drawPixmap( *dstRect, *image, *srcRect);
+
+ delete srcRect;
+ delete dstRect;
+}
+
+/*
+ * Draw pixels transformed.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_drawPixelsTransformed
+(JNIEnv *env, jobject obj, jobject graphics, jobject transform)
+{
+ QPixmap *originalImage = getQtVolatileImage(env, obj);
+ assert( originalImage );
+ QPainter *painter = getPainter( env, graphics );
+ assert( painter );
+ QMatrix *matrix = (QMatrix *)getNativeObject(env, transform);
+ assert( matrix );
+
+ // FIXME : Add rendering hint support here.
+ QPoint p = matrix->map( QPoint(0,0) );
+ QImage image = originalImage->toImage().transformed ( *matrix, Qt::FastTransformation );
+ painter->drawImage(p, image);
+}
+
+
+/**
+ * Draw pixels scaled and flipped
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_drawPixelsScaledFlipped
+(JNIEnv *env, jobject obj, jobject graphics,
+ jint bg_red, jint bg_green, jint bg_blue,
+ jboolean flipx, jboolean flipy,
+ jint srcx, jint srcy, jint srcwidth, jint srcheight,
+ jint dstx, jint dsty, jint dstwidth, jint dstheight,
+ jboolean composite)
+{
+ QPixmap *originalImage = getQtVolatileImage(env, obj);
+ assert( originalImage );
+ QPainter *painter = getPainter( env, graphics );
+ assert( painter );
+
+ QRectF *srcRect = new QRectF((qreal)srcx, (qreal)srcy,
+ (qreal)srcwidth, (qreal)srcheight);
+ QRectF *dstRect = new QRectF((qreal)dstx, (qreal)dsty,
+ (qreal)dstwidth, (qreal)dstheight);
+
+ if(composite == JNI_TRUE)
+ painter->fillRect( *dstRect, QColor(bg_red, bg_green, bg_blue ) );
+
+ if( flipx == JNI_TRUE || flipy == JNI_TRUE )
+ {
+ QImage im = originalImage->toImage().mirrored ( (flipx == JNI_TRUE),
+ (flipy == JNI_TRUE) );
+ painter->drawImage ( *dstRect, im, *srcRect);
+ }
+ else
+ painter->drawPixmap ( *dstRect, *originalImage, *srcRect);
+
+ delete srcRect;
+ delete dstRect;
+}
+
+/**
+ * Copies an area of the image (used by Graphics)
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtVolatileImage_copyArea
+(JNIEnv *env, jobject obj , jint x, jint y, jint w, jint h, jint dx, jint dy)
+{
+ QPixmap *image = getQtVolatileImage(env, obj);
+ assert( image );
+
+ // FIXME
+}
diff --git a/libjava/classpath/native/jni/qt-peer/qtwindowpeer.cpp b/libjava/classpath/native/jni/qt-peer/qtwindowpeer.cpp
new file mode 100644
index 000000000..decb64f9a
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/qtwindowpeer.cpp
@@ -0,0 +1,157 @@
+/* qtwindowpeer.cpp --
+ Copyright (C) 2005 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. */
+
+#include <assert.h>
+#include <QWidget>
+#include <qstyle.h>
+#include <gnu_java_awt_peer_qt_QtWindowPeer.h>
+#include "qtcomponent.h"
+#include "keybindings.h"
+#include "qtstrings.h"
+#include "containers.h"
+#include "mainthreadinterface.h"
+
+/*
+ * Our QMainWindow subclass
+ */
+class MyWindow : public QWidget
+{
+public:
+ MyWindow(JNIEnv *env, jobject obj) : QWidget(0, (Qt::Window | Qt::FramelessWindowHint))
+ {
+ setup(env, obj);
+ }
+
+ ~MyWindow()
+ {
+ destroy();
+ }
+
+#define I_KNOW_WHAT_IM_DOING
+#define PARENT QWidget
+#include "eventmethods.h"
+};
+
+
+class RaiseLower : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ bool raise;
+
+ public:
+ RaiseLower(QWidget *w, bool r) : AWTEvent()
+ {
+ widget = w;
+ raise = r;
+ }
+
+ void runEvent()
+ {
+ if (raise)
+ widget->raise();
+ else
+ widget->lower();
+ }
+};
+
+class FrameTitleEvent : public AWTEvent {
+
+ private:
+ QWidget *widget;
+ QString *string;
+
+ public:
+ FrameTitleEvent(QWidget *w, QString *s) : AWTEvent()
+ {
+ widget = w;
+ string = s;
+ }
+
+ void runEvent()
+ {
+ widget->setWindowTitle( *string );
+ delete string;
+ }
+};
+
+/*
+ * Constructs a top-level QWidget native object.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtWindowPeer_init
+(JNIEnv *env, jobject obj)
+{
+ QWidget *window = new MyWindow(env, obj);
+ assert( window );
+ // Qt::WStyle_StaysOnTop
+ setNativeObject( env, obj, window );
+}
+
+/*
+ * Lower the window.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtWindowPeer_toBack
+(JNIEnv *env, jobject obj)
+{
+ QWidget *window = (QWidget *) getNativeObject( env, obj );
+ assert( window );
+ mainThread->postEventToMain( new RaiseLower( window, false ) );
+}
+
+/*
+ * Raise the window.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtWindowPeer_toFront
+(JNIEnv *env, jobject obj)
+{
+ QWidget *window = (QWidget *) getNativeObject( env, obj );
+ assert( window );
+ mainThread->postEventToMain( new RaiseLower( window, true ) );
+}
+
+/*
+ * Title.
+ */
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtWindowPeer_setTitle
+(JNIEnv *env, jobject obj, jstring string)
+{
+ QWidget *frame = (QWidget *) getNativeObject( env, obj );
+ assert( frame );
+ QString *qStr = getQString(env, string);
+ mainThread->postEventToMain( new FrameTitleEvent( frame, qStr ) );
+}
+
diff --git a/libjava/classpath/native/jni/qt-peer/slotcallbacks.cpp b/libjava/classpath/native/jni/qt-peer/slotcallbacks.cpp
new file mode 100644
index 000000000..3e0820477
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/slotcallbacks.cpp
@@ -0,0 +1,256 @@
+/* slotcallbacks.cpp --
+ Copyright (C) 2005 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. */
+
+#include <QObject>
+#include <QAbstractButton>
+#include <QAbstractSlider>
+#include <QAction>
+#include <QComboBox>
+#include <QListWidget>
+#include <QLineEdit>
+#include <QPushButton>
+#include <QTextEdit>
+#include <gnu_java_awt_peer_qt_QtButtonPeer.h>
+#include "qtcomponent.h"
+#include "qtstrings.h"
+#include "keybindings.h"
+#include "buttonevent.h"
+#include "slotcallbacks.h"
+
+// AdjustmentEvent constants
+#define UNIT_INCREMENT 1
+#define UNIT_DECREMENT 2
+#define BLOCK_DECREMENT 3
+#define BLOCK_INCREMENT 4
+#define TRACK 5
+
+
+class SlotCallback : public QObject {
+ Q_OBJECT;
+
+private:
+ JavaVM* vm;
+ jobject target;
+ jclass componentCls;
+ jmethodID fireEventID;
+
+public:
+ QScrollBar *sb; // used only by the scrollbar method.
+ QListWidget *lw; // used only by the listitemclicked method
+
+ SlotCallback(JNIEnv *env, jobject t)
+ {
+ env->GetJavaVM(&vm);
+ target = t;
+ target = env->NewGlobalRef(t);
+ }
+
+ ~SlotCallback()
+ {
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ env->DeleteGlobalRef(target);
+ }
+
+ public slots:
+
+ void buttonClicked()
+ {
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ componentCls = env->GetObjectClass( target );
+ fireEventID = env->GetMethodID( componentCls,
+ "fireClick",
+ "(I)V" );
+ int modifiers = getAEKeyModifiers( QApplication::keyboardModifiers() );
+ env->CallVoidMethod( target, fireEventID, modifiers );
+ env->DeleteLocalRef( componentCls );
+ }
+
+ void buttonToggled(bool checked)
+ {
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ componentCls = env->GetObjectClass( target );
+ fireEventID = env->GetMethodID( componentCls,
+ "fireToggle",
+ "(Z)V" );
+ if(checked)
+ env->CallVoidMethod( target, fireEventID, JNI_TRUE );
+ else
+ env->CallVoidMethod( target, fireEventID, JNI_FALSE );
+ env->DeleteLocalRef( componentCls );
+ }
+
+ // Used for List and Choice
+ void choiceActivated( int index )
+ {
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ componentCls = env->GetObjectClass( target );
+ fireEventID = env->GetMethodID( componentCls,
+ "fireChoice",
+ "(I)V" );
+ env->CallVoidMethod( target, fireEventID, (jint)index );
+ env->DeleteLocalRef( componentCls );
+ }
+
+ void textChanged()
+ {
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ componentCls = env->GetObjectClass( target );
+ fireEventID = env->GetMethodID( componentCls,
+ "textChanged",
+ "()V" );
+ env->CallVoidMethod( target, fireEventID );
+ env->DeleteLocalRef( componentCls );
+ }
+
+ void scrollBarAction( int action )
+ {
+ JNIEnv *env;
+ int type;
+ int index;
+ switch(action)
+ {
+ case QAbstractSlider::SliderNoAction:
+ return;
+ case QAbstractSlider::SliderSingleStepAdd:
+ type = UNIT_INCREMENT;
+ break;
+ case QAbstractSlider::SliderSingleStepSub:
+ type = UNIT_DECREMENT;
+ break;
+ case QAbstractSlider::SliderPageStepAdd:
+ type = BLOCK_INCREMENT;
+ break;
+ case QAbstractSlider::SliderPageStepSub:
+ type = BLOCK_DECREMENT;
+ break;
+ case QAbstractSlider::SliderToMinimum:
+ type = TRACK;
+ break;
+ case QAbstractSlider::SliderToMaximum:
+ type = TRACK;
+ break;
+ case QAbstractSlider::SliderMove:
+ type = TRACK;
+ break;
+ }
+ index = sb->value();
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ componentCls = env->GetObjectClass( target );
+ fireEventID = env->GetMethodID( componentCls,
+ "fireMoved",
+ "(II)V" );
+ env->CallVoidMethod( target, fireEventID, (jint)type, (jint)index );
+ env->DeleteLocalRef( componentCls );
+ }
+
+ void listItemClicked( QListWidgetItem * item )
+ {
+ int index = lw->row( item );
+ JNIEnv *env;
+ vm->GetEnv((void **)&env, JNI_VERSION_1_1);
+ componentCls = env->GetObjectClass( target );
+ fireEventID = env->GetMethodID( componentCls,
+ "itemDoubleClicked",
+ "(II)V" );
+ int modifiers = getAEKeyModifiers( QApplication::keyboardModifiers() );
+ env->CallVoidMethod( target, fireEventID, index, modifiers );
+ env->DeleteLocalRef( componentCls );
+ }
+};
+
+#include "slotcallbacks.moc.h"
+
+void connectButton(QPushButton *button, JNIEnv *env, jobject buttonobj)
+{
+ SlotCallback *scb = new SlotCallback(env, buttonobj);
+ QObject::connect( button, SIGNAL( clicked() ), scb, SLOT( buttonClicked() ) );
+}
+
+void connectChoice(QComboBox *choice, JNIEnv *env, jobject choiceobj)
+{
+ SlotCallback *scb = new SlotCallback(env, choiceobj);
+ QObject::connect( choice, SIGNAL( activated(int) ), scb, SLOT( choiceActivated(int) ) );
+}
+
+void connectList(QListWidget *list, JNIEnv *env, jobject listobj)
+{
+ SlotCallback *scb = new SlotCallback(env, listobj);
+ scb->lw = list;
+ QObject::connect( list, SIGNAL( currentRowChanged(int) ),
+ scb, SLOT( choiceActivated(int) ) );
+ QObject::connect( list, SIGNAL( itemDoubleClicked( QListWidgetItem * )),
+ scb, SLOT( listItemClicked( QListWidgetItem * )));
+}
+
+void connectAction(QAction *action, JNIEnv *env, jobject obj)
+{
+ SlotCallback *scb = new SlotCallback(env, obj);
+ QObject::connect( action, SIGNAL( triggered() ), scb, SLOT( buttonClicked() ) );
+}
+
+void connectToggle(QAbstractButton *action, JNIEnv *env, jobject obj)
+{
+ SlotCallback *scb = new SlotCallback(env, obj);
+ QObject::connect( action, SIGNAL( toggled(bool) ), scb, SLOT( buttonToggled(bool) ) );
+}
+
+void connectScrollBar(QScrollBar *scroll, JNIEnv *env, jobject obj)
+{
+ SlotCallback *scb = new SlotCallback(env, obj);
+ scb->sb = scroll;
+ QObject::connect( scroll, SIGNAL( actionTriggered(int) ), scb, SLOT( scrollBarAction(int) ) );
+}
+
+void connectTextEdit(QTextEdit *edit, JNIEnv *env, jobject obj)
+{
+ SlotCallback *scb = new SlotCallback(env, obj);
+ QObject::connect( edit, SIGNAL( textChanged() ),
+ scb, SLOT( textChanged() ) );
+}
+
+void connectLineEdit(QLineEdit *edit, JNIEnv *env, jobject obj)
+{
+ SlotCallback *scb = new SlotCallback(env, obj);
+ QObject::connect( edit, SIGNAL(textChanged( QString ) ),
+ scb, SLOT( textChanged() ) );
+}
+
diff --git a/libjava/classpath/native/jni/qt-peer/slotcallbacks.h b/libjava/classpath/native/jni/qt-peer/slotcallbacks.h
new file mode 100644
index 000000000..88c292ce7
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/slotcallbacks.h
@@ -0,0 +1,24 @@
+#ifndef SLOTCALLBACKS_H
+#define SLOTCALLBACKS_H
+
+#include <QAbstractButton>
+#include <QAbstractSlider>
+#include <QAction>
+#include <QComboBox>
+#include <QListWidget>
+#include <QLineEdit>
+#include <QPushButton>
+#include <QScrollBar>
+#include <QTextEdit>
+#include <jni.h>
+
+void connectButton(QPushButton *button, JNIEnv *env, jobject buttonobj);
+void connectChoice(QComboBox *choice, JNIEnv *env, jobject choiceobj);
+void connectAction(QAction *action, JNIEnv *env, jobject obj);
+void connectToggle(QAbstractButton *action, JNIEnv *env, jobject obj);
+void connectScrollBar(QScrollBar *scroll, JNIEnv *env, jobject obj);
+void connectList(QListWidget *list, JNIEnv *env, jobject choiceobj);
+void connectTextEdit(QTextEdit *edit, JNIEnv *env, jobject obj);
+void connectLineEdit(QLineEdit *edit, JNIEnv *env, jobject obj);
+
+#endif