diff options
author | Thomas Fitzsimmons <fitzsim@redhat.com> | 2003-11-11 17:04:47 +0000 |
---|---|---|
committer | Thomas Fitzsimmons <fitzsim@gcc.gnu.org> | 2003-11-11 17:04:47 +0000 |
commit | 009ed5cc5c6a9a79925f4cd0a554844f0c6bc6e3 (patch) | |
tree | 82d5b8444072702a1116203427aa9591bd53130c /libjava/jni | |
parent | 4d595e43423f86afa558ee8238d37c64ad6b475e (diff) | |
download | gcc-009ed5cc5c6a9a79925f4cd0a554844f0c6bc6e3.zip gcc-009ed5cc5c6a9a79925f4cd0a554844f0c6bc6e3.tar.gz gcc-009ed5cc5c6a9a79925f4cd0a554844f0c6bc6e3.tar.bz2 |
GtkLabelPeer.java (create()): Call new create.
2003-11-11 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/gtk/GtkLabelPeer.java (create()): Call new create.
(create(String, float)): New method.
(setText): Make native.
(nativeSetAlignment): New method.
(setAlignment): Call nativeSetAlignment.
(getArgs): Remove method.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
(find_fg_color_widget, find_bg_color_widget): New functions.
(gtkWidgetSetForeground): Call find_fg_color_widget.
(gtkWidgetSetBackground): Call find_bg_color_widget. Modify active and
prelight colors.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c (create): Wrap label
widget in event box.
(setText, setAlignment): Implement new native methods.
From-SVN: r73453
Diffstat (limited to 'libjava/jni')
-rw-r--r-- | libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c | 45 | ||||
-rw-r--r-- | libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c | 59 |
2 files changed, 99 insertions, 5 deletions
diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c index 98e8e8c..70aabf0 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c @@ -40,6 +40,9 @@ exception statement from your version. */ #include "gnu_java_awt_peer_gtk_GtkComponentPeer.h" #include <gtk/gtkprivate.h> +static GtkWidget *find_fg_color_widget (GtkWidget *widget); +static GtkWidget *find_bg_color_widget (GtkWidget *widget); + JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkGenericPeer_dispose (JNIEnv *env, jobject obj) { @@ -299,7 +302,7 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetBackground gdk_threads_enter (); - widget = GTK_WIDGET (ptr); + widget = find_bg_color_widget (GTK_WIDGET (ptr)); gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, &normal_color); gtk_widget_modify_bg (widget, GTK_STATE_ACTIVE, &active_color); @@ -324,9 +327,11 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetForeground gdk_threads_enter (); - widget = GTK_WIDGET (ptr); + widget = find_fg_color_widget (GTK_WIDGET (ptr)); gtk_widget_modify_fg (widget, GTK_STATE_NORMAL, &color); + gtk_widget_modify_fg (widget, GTK_STATE_ACTIVE, &color); + gtk_widget_modify_fg (widget, GTK_STATE_PRELIGHT, &color); gdk_threads_leave (); } @@ -542,3 +547,39 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_connectHooks connect_awt_hook (env, obj, 1, GTK_WIDGET (ptr)->window); gdk_threads_leave (); } + +static GtkWidget * +find_fg_color_widget (GtkWidget *widget) +{ + GtkWidget *fg_color_widget; + + if (GTK_IS_EVENT_BOX (widget)) + fg_color_widget = gtk_bin_get_child (GTK_BIN(widget)); + else + fg_color_widget = widget; + + return fg_color_widget; +} + +static GtkWidget * +find_bg_color_widget (GtkWidget *widget) +{ + GtkWidget *bg_color_widget; + + if (GTK_IS_WINDOW (widget)) + { + GtkWidget *vbox; + GList* children; + + children = gtk_container_get_children(GTK_CONTAINER(widget)); + vbox = children->data; + + children = gtk_container_get_children(GTK_CONTAINER(vbox)); + bg_color_widget = children->data; + } + else + bg_color_widget = widget; + + return bg_color_widget; +} + diff --git a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c index 7bddc33..38a45d8 100644 --- a/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c +++ b/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c @@ -41,15 +41,68 @@ exception statement from your version. */ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkLabelPeer_create - (JNIEnv *env, jobject obj) + (JNIEnv *env, jobject obj, jstring text, jfloat xalign) { GtkWidget *label; + GtkWidget *ebox; + GtkContainer *ebox_container; + const char *str; + + str = (*env)->GetStringUTFChars (env, text, 0); + + gdk_threads_enter (); + + ebox = gtk_event_box_new (); + ebox_container = GTK_CONTAINER (ebox); + label = gtk_label_new (str); + gtk_misc_set_alignment (GTK_MISC (label), xalign, 0.5); + gtk_container_add (ebox_container, label); + gtk_widget_show (label); + + gdk_threads_leave (); + + (*env)->ReleaseStringUTFChars (env, text, str); + + NSA_SET_PTR (env, obj, ebox); +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkLabelPeer_setText + (JNIEnv *env, jobject obj, jstring text) +{ + const char *str; + void *ptr; + GtkWidget *label; + + ptr = NSA_GET_PTR (env, obj); + + str = (*env)->GetStringUTFChars (env, text, 0); gdk_threads_enter (); - label = gtk_label_new (NULL); + label = gtk_bin_get_child (GTK_BIN(ptr)); + + gtk_label_set_label (GTK_LABEL (label), str); gdk_threads_leave (); - NSA_SET_PTR (env, obj, label); + (*env)->ReleaseStringUTFChars (env, text, str); +} + +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkLabelPeer_setAlignment + (JNIEnv *env, jobject obj, jfloat xalign) +{ + void *ptr; + GtkWidget *label; + + ptr = NSA_GET_PTR (env, obj); + + gdk_threads_enter (); + + label = gtk_bin_get_child (GTK_BIN(ptr)); + + gtk_misc_set_alignment (GTK_MISC (label), xalign, 0.5); + + gdk_threads_leave (); } |