diff options
author | fitzsim <fitzsim@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-01-05 21:13:46 +0000 |
---|---|---|
committer | fitzsim <fitzsim@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-01-05 21:13:46 +0000 |
commit | c7ed85c9040308feec4bb428ddc6657a6d0c068e (patch) | |
tree | 2be5b938e65b9fca201b98f7e8575f3a4a0b6bb5 /libjava/jni | |
parent | e1a6bbd7a8c230062538ce819ee89ceed8f657eb (diff) | |
download | gcc-c7ed85c9040308feec4bb428ddc6657a6d0c068e.tar.gz |
2004-01-05 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/gtk/GtkComponentPeer.java,
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
(getPreferredSize): Call preferredSize.
(preferredSize): Call gtkWidgetGetPreferredDimensions.
(getMinimumSize): Call minimumSize.
(minimumSize): Call gtkWidgetGetPreferredDimensions.
(gtkWidgetGetDimensions): Return the peer widget's current size
request.
(gtkWidgetGetPreferredDimensions): Return the peer widget's
natural size request.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@75442 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/jni')
-rw-r--r-- | libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c | 66 |
1 files changed, 53 insertions, 13 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 6336636ec11..b244fd7d59d 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 @@ -169,29 +169,69 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetLocationOnScreen } /* - * Find the preferred size of a widget. + * Find this widget's current size. */ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetDimensions - (JNIEnv *env, jobject obj, jintArray jdims) + (JNIEnv *env, jobject obj, jintArray jdims) { - void *ptr; - jint *dims; - GtkRequisition req; + void *ptr; + jint *dims; + GtkRequisition requisition; + + ptr = NSA_GET_PTR (env, obj); + + dims = (*env)->GetIntArrayElements (env, jdims, 0); + dims[0] = dims[1] = 0; + + gdk_threads_enter (); + + gtk_widget_size_request (GTK_WIDGET (ptr), &requisition); + + dims[0] = requisition.width; + dims[1] = requisition.height; + + gdk_threads_leave (); + + (*env)->ReleaseIntArrayElements (env, jdims, dims, 0); +} - ptr = NSA_GET_PTR (env, obj); - dims = (*env)->GetIntArrayElements (env, jdims, 0); +/* + * Find this widget's preferred size. + */ +JNIEXPORT void JNICALL +Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetPreferredDimensions + (JNIEnv *env, jobject obj, jintArray jdims) +{ + void *ptr; + jint *dims; + GtkRequisition current_req; + GtkRequisition natural_req; + + ptr = NSA_GET_PTR (env, obj); + + dims = (*env)->GetIntArrayElements (env, jdims, 0); + dims[0] = dims[1] = 0; + + gdk_threads_enter (); + + /* Save the widget's current size request. */ + gtk_widget_size_request (GTK_WIDGET (ptr), ¤t_req); - gdk_threads_enter (); + /* Get the widget's "natural" size request. */ + gtk_widget_set_size_request (GTK_WIDGET (ptr), -1, -1); + gtk_widget_size_request (GTK_WIDGET (ptr), &natural_req); - gtk_signal_emit_by_name (GTK_OBJECT (ptr), "size_request", &req); + /* Reset the widget's size request. */ + gtk_widget_set_size_request (GTK_WIDGET (ptr), + current_req.width, current_req.height); - dims[0] = req.width; - dims[1] = req.height; + dims[0] = natural_req.width; + dims[1] = natural_req.height; - gdk_threads_leave (); + gdk_threads_leave (); - (*env)->ReleaseIntArrayElements(env, jdims, dims, 0); + (*env)->ReleaseIntArrayElements (env, jdims, dims, 0); } JNIEXPORT void JNICALL |