From 8be067eae8acc9a035663489bc25f3bb87bd4f3b Mon Sep 17 00:00:00 2001 From: tromey Date: Fri, 12 Jan 2001 23:08:23 +0000 Subject: [PATCH] * gnu/awt/gtk/natGtkComponentPeer.cc (getLocationOnScreen): Wrote. (setCursor): Wrote. Include Cursor.h. * gnu/awt/gtk/natGtkLabelPeer.cc: New file. * gnu/awt/gtk/natGtkButtonPeer.cc: New file. * gnu/awt/gtk/gtkcommon.h (class _Jv_GdkThreadLock): New class. * gnu/awt/gtk/GtkLabelPeer.java: New file. * gnu/awt/gtk/GtkButtonPeer.java: New file. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@38967 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/ChangeLog | 15 ++++++ libjava/gnu/awt/gtk/GtkButtonPeer.java | 61 ++++++++++++++++++++++ libjava/gnu/awt/gtk/GtkLabelPeer.java | 37 ++++++++++++++ libjava/gnu/awt/gtk/gtkcommon.h | 14 +++++ libjava/gnu/awt/gtk/natGtkButtonPeer.cc | 52 +++++++++++++++++++ libjava/gnu/awt/gtk/natGtkComponentPeer.cc | 82 ++++++++++++++++++++++++++---- libjava/gnu/awt/gtk/natGtkLabelPeer.cc | 59 +++++++++++++++++++++ 7 files changed, 309 insertions(+), 11 deletions(-) create mode 100644 libjava/gnu/awt/gtk/GtkButtonPeer.java create mode 100644 libjava/gnu/awt/gtk/GtkLabelPeer.java create mode 100644 libjava/gnu/awt/gtk/natGtkButtonPeer.cc create mode 100644 libjava/gnu/awt/gtk/natGtkLabelPeer.cc diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 72a94b6..a5b1503 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,5 +1,20 @@ 2001-01-12 Tom Tromey + * gnu/awt/gtk/natGtkComponentPeer.cc (getLocationOnScreen): + Wrote. + (setCursor): Wrote. + Include Cursor.h. + * gnu/awt/gtk/natGtkLabelPeer.cc: New file. + * gnu/awt/gtk/natGtkButtonPeer.cc: New file. + * gnu/awt/gtk/gtkcommon.h (class _Jv_GdkThreadLock): New class. + * gnu/awt/gtk/GtkLabelPeer.java: New file. + * gnu/awt/gtk/GtkButtonPeer.java: New file. + + * java/awt/dnd/DropTargetListener.java: New file. + * java/awt/dnd/DragSourceListener.java: New file. + * java/awt/dnd/DragGestureListener.java: New file. + * java/awt/dnd/AutoScroll.java: New file. + * java/lang/natSystem.cc: Include locale.h if it exists. * configure: Rebuilt. * configure.in: Check for locale.h. diff --git a/libjava/gnu/awt/gtk/GtkButtonPeer.java b/libjava/gnu/awt/gtk/GtkButtonPeer.java new file mode 100644 index 0000000..c369ba5 --- /dev/null +++ b/libjava/gnu/awt/gtk/GtkButtonPeer.java @@ -0,0 +1,61 @@ +/* GtkButtonPeer.java -- Implements ButtonPeer with GTK + Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. + +This file is part of the peer AWT libraries of GNU Classpath. + +This library is free software; you can redistribute it and/or modify +it under the terms of the GNU Library General Public License as published +by the Free Software Foundation, either version 2 of the License, or +(at your option) any later verion. + +This library 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 Library General Public License for more details. + +You should have received a copy of the GNU Library General Public License +along with this library; if not, write to the Free Software Foundation +Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA. */ + + +package gnu.awt.gtk; + +import java.awt.*; +import java.awt.event.MouseEvent; +import java.awt.event.KeyEvent; +import java.awt.peer.*; + +public class GtkButtonPeer extends GtkComponentPeer + implements ButtonPeer +{ + protected native void create (); + public native void setLabel (String label); + + public GtkButtonPeer (Button b) + { + super (b); + } + + public void handleEvent (AWTEvent e) + { +// if (e.getID () == MouseEvent.MOUSE_CLICKED && isEnabled () +// && !modalHasGrab ()) +// { +// MouseEvent me = (MouseEvent) e; +// if (!me.isConsumed () +// && (me.getModifiers () & MouseEvent.BUTTON1_MASK) != 0) +// postActionEvent (((Button)awtComponent).getActionCommand (), +// me.getModifiers ()); +// } + +// if (e.getID () == KeyEvent.KEY_PRESSED) +// { +// KeyEvent ke = (KeyEvent) e; +// if (!ke.isConsumed () && ke.getKeyCode () == KeyEvent.VK_SPACE) +// postActionEvent (((Button)awtComponent).getActionCommand (), +// ke.getModifiers ()); +// } + + super.handleEvent (e); + } +} diff --git a/libjava/gnu/awt/gtk/GtkLabelPeer.java b/libjava/gnu/awt/gtk/GtkLabelPeer.java new file mode 100644 index 0000000..23876f9 --- /dev/null +++ b/libjava/gnu/awt/gtk/GtkLabelPeer.java @@ -0,0 +1,37 @@ +/* GtkLabelPeer.java -- Implements LabelPeer with GTK + Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. + +This file is part of the peer AWT libraries of GNU Classpath. + +This library is free software; you can redistribute it and/or modify +it under the terms of the GNU Library General Public License as published +by the Free Software Foundation, either version 2 of the License, or +(at your option) any later verion. + +This library 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 Library General Public License for more details. + +You should have received a copy of the GNU Library General Public License +along with this library; if not, write to the Free Software Foundation +Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA. */ + + +package gnu.awt.gtk; + +import java.awt.*; +import java.awt.peer.*; + +public class GtkLabelPeer extends GtkComponentPeer + implements LabelPeer +{ + public GtkLabelPeer (Label l) + { + super (l); + } + + public native void setText (String text); + public native void setAlignment (int alignment); + protected native void create (); +} diff --git a/libjava/gnu/awt/gtk/gtkcommon.h b/libjava/gnu/awt/gtk/gtkcommon.h index 4e9c430..207d2cf 100644 --- a/libjava/gnu/awt/gtk/gtkcommon.h +++ b/libjava/gnu/awt/gtk/gtkcommon.h @@ -17,6 +17,20 @@ details. */ #include +class _Jv_GdkThreadLock +{ +public: + _Jv_GdkThreadLock () + { + GDK_THREADS_ENTER (); + } + + ~_Jv_GdkThreadLock () + { + GDK_THREADS_LEAVE (); + } +}; + // Convert AWT Color to gdk color value. static inline void _Jv_ConvertAwtColor(java::awt::Color* awtcolor, GdkColor* gdkcolor) diff --git a/libjava/gnu/awt/gtk/natGtkButtonPeer.cc b/libjava/gnu/awt/gtk/natGtkButtonPeer.cc new file mode 100644 index 0000000..1608616 --- /dev/null +++ b/libjava/gnu/awt/gtk/natGtkButtonPeer.cc @@ -0,0 +1,52 @@ +// Native Gtk AWT button code + +#include + +#include + +#include "gtkcommon.h" +#include +#include + +void +gnu::awt::gtk::GtkButtonPeer::setLabel (java::lang::String *label) +{ + _Jv_GdkThreadLock sync; + jsize len = 0; + if (label) + len = JvGetStringUTFLength (label); + char buf[len + 1]; + // FIXME: this can allocate an unbounded amount. Should use heap + // even though it is slower. + if (label) + JvGetStringUTFRegion (label, 0, len, buf); + buf[len] = '\0'; + // The button child is a label. + GtkBin *bin = GTK_BIN (ptr); + gtk_label_set_text (GTK_LABEL (bin->child), buf); +} + +void +gnu::awt::gtk::GtkButtonPeer::create () +{ + if (! ptr) + { + _Jv_GdkThreadLock sync; + // This is a little inefficient. + ptr = (gnu::gcj::RawData *) gtk_button_new_with_label (""); + + using namespace ::java::awt; + Button *button = reinterpret_cast