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. From-SVN: r75442
This commit is contained in:
parent
216bb6e1f7
commit
b17fc9eb25
@ -1,3 +1,16 @@
|
||||
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.
|
||||
|
||||
2004-01-05 Sascha Brawer <brawer@dandelis.ch>
|
||||
|
||||
Thanks to Brian Gough <bjg@network-theory.com>
|
||||
|
@ -84,8 +84,9 @@ public class GtkComponentPeer extends GtkGenericPeer
|
||||
native int[] gtkWidgetGetForeground ();
|
||||
native int[] gtkWidgetGetBackground ();
|
||||
native void gtkWidgetSetVisible (boolean b);
|
||||
native void gtkWidgetGetDimensions(int[] dim);
|
||||
native void gtkWidgetGetLocationOnScreen(int[] point);
|
||||
native void gtkWidgetGetDimensions (int[] dim);
|
||||
native void gtkWidgetGetPreferredDimensions (int[] dim);
|
||||
native void gtkWidgetGetLocationOnScreen (int[] point);
|
||||
native void gtkWidgetSetCursor (int type);
|
||||
native void gtkWidgetSetBackground (int red, int green, int blue);
|
||||
native void gtkWidgetSetForeground (int red, int green, int blue);
|
||||
@ -196,18 +197,12 @@ public class GtkComponentPeer extends GtkGenericPeer
|
||||
|
||||
public Dimension getMinimumSize ()
|
||||
{
|
||||
int dim[]=new int[2];
|
||||
gtkWidgetGetDimensions (dim);
|
||||
Dimension d = new Dimension (dim[0],dim[1]);
|
||||
return (d);
|
||||
return minimumSize ();
|
||||
}
|
||||
|
||||
public Dimension getPreferredSize ()
|
||||
{
|
||||
int dim[]=new int[2];
|
||||
gtkWidgetGetDimensions (dim);
|
||||
Dimension d = new Dimension (dim[0],dim[1]);
|
||||
return (d);
|
||||
return preferredSize ();
|
||||
}
|
||||
|
||||
public Toolkit getToolkit ()
|
||||
@ -226,7 +221,11 @@ public class GtkComponentPeer extends GtkGenericPeer
|
||||
|
||||
public Dimension minimumSize ()
|
||||
{
|
||||
return getMinimumSize();
|
||||
int dim[] = new int[2];
|
||||
|
||||
gtkWidgetGetPreferredDimensions (dim);
|
||||
|
||||
return new Dimension (dim[0], dim[1]);
|
||||
}
|
||||
|
||||
public void paint (Graphics g)
|
||||
@ -234,9 +233,13 @@ public class GtkComponentPeer extends GtkGenericPeer
|
||||
awtComponent.paint (g);
|
||||
}
|
||||
|
||||
public Dimension preferredSize()
|
||||
public Dimension preferredSize ()
|
||||
{
|
||||
return getPreferredSize();
|
||||
int dim[] = new int[2];
|
||||
|
||||
gtkWidgetGetPreferredDimensions (dim);
|
||||
|
||||
return new Dimension (dim[0], dim[1]);
|
||||
}
|
||||
|
||||
public boolean prepareImage (Image image, int width, int height,
|
||||
|
@ -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);
|
||||
ptr = NSA_GET_PTR (env, obj);
|
||||
|
||||
gdk_threads_enter ();
|
||||
dims = (*env)->GetIntArrayElements (env, jdims, 0);
|
||||
dims[0] = dims[1] = 0;
|
||||
|
||||
gtk_signal_emit_by_name (GTK_OBJECT (ptr), "size_request", &req);
|
||||
gdk_threads_enter ();
|
||||
|
||||
dims[0] = req.width;
|
||||
dims[1] = req.height;
|
||||
gtk_widget_size_request (GTK_WIDGET (ptr), &requisition);
|
||||
|
||||
gdk_threads_leave ();
|
||||
dims[0] = requisition.width;
|
||||
dims[1] = requisition.height;
|
||||
|
||||
(*env)->ReleaseIntArrayElements(env, jdims, dims, 0);
|
||||
gdk_threads_leave ();
|
||||
|
||||
(*env)->ReleaseIntArrayElements (env, jdims, dims, 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);
|
||||
|
||||
/* 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);
|
||||
|
||||
/* Reset the widget's size request. */
|
||||
gtk_widget_set_size_request (GTK_WIDGET (ptr),
|
||||
current_req.width, current_req.height);
|
||||
|
||||
dims[0] = natural_req.width;
|
||||
dims[1] = natural_req.height;
|
||||
|
||||
gdk_threads_leave ();
|
||||
|
||||
(*env)->ReleaseIntArrayElements (env, jdims, dims, 0);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
|
Loading…
Reference in New Issue
Block a user