This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH]: FileDialog default sizes


Hi,

This patch gives file dialogs default sizes of gtk size request + insets
(if no size is set for them - current defaults to 0x0).

Cheers,

Kim

2004-01-14  Kim Ho  <kho@redhat.com>

       * gnu/java/awt/peer/gtk/GtkComponentPeer.java (Constructor): If
       it is a FileDialog and has dimensions of 0 by 0, then the initial
       size is set to size request plus insets.
       * gnu/java/awt/peer/gtk/GtkFileDialogPeer.java (getTotalSize):
       New method.
       * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
       (getTotalSize): New method. Takes size request and adds insets.

Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.2555
diff -u -r1.2555 ChangeLog
--- ChangeLog	14 Jan 2004 19:45:09 -0000	1.2555
+++ ChangeLog	14 Jan 2004 22:07:27 -0000
@@ -1,3 +1,13 @@
+2004-01-14  Kim Ho  <kho@redhat.com>
+
+       * gnu/java/awt/peer/gtk/GtkComponentPeer.java (Constructor): If
+       it is a FileDialog and has dimensions of 0 by 0, then the initial size
+       is set to size request plus insets.
+       * gnu/java/awt/peer/gtk/GtkFileDialogPeer.java (getTotalSize): New
+       method.
+       * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c (getTotalSize):
+       New method. Takes size request and adds insets.
+
 2004-01-14  Michael Koch  <konqueror@gmx.de>
 
 	* java/text/MessageFormat.java:
Index: gnu/java/awt/peer/gtk/GtkComponentPeer.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java,v
retrieving revision 1.13
diff -u -r1.13 GtkComponentPeer.java
--- gnu/java/awt/peer/gtk/GtkComponentPeer.java	13 Jan 2004 20:54:46 -0000	1.13
+++ gnu/java/awt/peer/gtk/GtkComponentPeer.java	14 Jan 2004 22:07:27 -0000
@@ -1,5 +1,5 @@
 /* GtkComponentPeer.java -- Implements ComponentPeer with GTK
-   Copyright (C) 1998, 1999, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2002, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -124,6 +124,16 @@
 	setFont(awtComponent.getFont());
 
       setCursor (awtComponent.getCursor ());
+      if (this instanceof GtkFileDialogPeer && awtComponent.getHeight() == 0
+          && awtComponent.getWidth() == 0)
+      {
+        int[] dims = new int[2];
+        gtkWidgetGetDimensions(dims);
+        ((GtkFileDialogPeer) this).setBoundsCallback((Window)awtComponent, 
+                                                     awtComponent.getX(), 
+                                                     awtComponent.getY(),
+                                                     dims[0], dims[1]);
+      }      
       Rectangle bounds = awtComponent.getBounds ();
       setBounds (bounds.x, bounds.y, bounds.width, bounds.height);
 
Index: gnu/java/awt/peer/gtk/GtkFileDialogPeer.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java,v
retrieving revision 1.4
diff -u -r1.4 GtkFileDialogPeer.java
--- gnu/java/awt/peer/gtk/GtkFileDialogPeer.java	8 Jan 2004 21:12:25 -0000	1.4
+++ gnu/java/awt/peer/gtk/GtkFileDialogPeer.java	14 Jan 2004 22:07:27 -0000
@@ -1,5 +1,5 @@
 /* GtkFileDialogPeer.java -- Implements FileDialogPeer with GTK
-   Copyright (C) 1998, 1999, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2002, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -63,6 +63,7 @@
   native void connectJObject ();
   native void connectSignals ();
   native void nativeSetFile (String file);
+  native void gtkWidgetGetDimensions (int[] dims);
 
   public void setFile (String fileName)
   {
Index: jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
===================================================================
RCS file: /cvs/gcc/gcc/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c,v
retrieving revision 1.12
diff -u -r1.12 gnu_java_awt_peer_gtk_GtkWindowPeer.c
--- jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c	13 Jan 2004 20:54:46 -0000	1.12
+++ jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c	14 Jan 2004 22:07:31 -0000
@@ -1,5 +1,5 @@
 /* gtkwindowpeer.c -- Native implementation of GtkWindowPeer
-   Copyright (C) 1998, 1999, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2002, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -399,6 +399,33 @@
 
   return height;
 }
+
+JNIEXPORT jint JNICALL
+Java_gnu_java_awt_peer_gtk_GtkFileDialogPeer_gtkWidgetGetDimensions
+  (JNIEnv *env, jobject obj, jintArray jdims)
+{
+  void *ptr;
+  jint *dims;
+  int top, left, bottom, right;
+  GtkRequisition req;
+  
+  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), &req);
+  
+  window_get_frame_extents (GTK_WIDGET (ptr), &top, &left, &bottom, &right);
+
+  dims[0] = req.width + left + right;
+  dims[1] = req.height + top + bottom;
+
+  gdk_threads_leave ();
+    
+  (*env)->ReleaseIntArrayElements (env, jdims, dims, 0);
+} 
 
 static void
 window_get_frame_extents (GtkWidget *window,

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]