OSDN Git Service

2004-01-26 Kim Ho <kho@redhat.com>
authorkho <kho@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 26 Jan 2004 13:56:59 +0000 (13:56 +0000)
committerkho <kho@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 26 Jan 2004 13:56:59 +0000 (13:56 +0000)
        * gnu/java/awt/peer/gtk/GtkFramePeer.java (menuBarHeight): Mark
        private.
        (setMenuBar): Grab MenuBar height and change insets.
        (setBounds): Account for MenuBar height.
        (postInsetsChangedEvent): Ditto.
        (postSizeAllocateEvent): Remove.
        * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
        (menubar_resize_cb): Remove
        (setMenuBarPeer): Remove callback.
        (getMenuBarHeight): Use size requisition instead of
        allocation.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@76633 138bc75d-0d04-0410-961f-82ee72b054a4

libjava/ChangeLog
libjava/gnu/java/awt/peer/gtk/GtkFramePeer.java
libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c

index fc7ee9c..f59d55f 100644 (file)
@@ -1,3 +1,17 @@
+2004-01-26  Kim Ho  <kho@redhat.com>
+
+       * gnu/java/awt/peer/gtk/GtkFramePeer.java (menuBarHeight): Mark
+       private.
+       (setMenuBar): Grab MenuBar height and change insets.
+       (setBounds): Account for MenuBar height.
+       (postInsetsChangedEvent): Ditto.
+       (postSizeAllocateEvent): Remove.
+       * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
+       (menubar_resize_cb): Remove
+       (setMenuBarPeer): Remove callback.
+       (getMenuBarHeight): Use size requisition instead of
+       allocation.
+
 2004-01-25  Thomas Fitzsimmons  <fitzsim@redhat.com>
 
        * java/awt/TextArea.java: Fix indentation.  Flesh out javadocs.
index 6c59847..3b69b02 100644 (file)
@@ -53,7 +53,7 @@ import java.awt.peer.MenuBarPeer;
 public class GtkFramePeer extends GtkWindowPeer
     implements FramePeer
 {
-  int menuBarHeight = 0;
+  private int menuBarHeight;
   private MenuBarPeer menuBar;
   native int getMenuBarHeight (MenuBarPeer bar);
 
@@ -76,9 +76,20 @@ public class GtkFramePeer extends GtkWindowPeer
         removeMenuBarPeer(menuBar);
       menuBar = (MenuBarPeer) ((MenuBar) bar).getPeer();
       setMenuBarPeer(menuBar);      
+      menuBarHeight = getMenuBarHeight (menuBar);
+      insets.top += menuBarHeight;
+      awtComponent.doLayout();
     }
   }
 
+  public void setBounds (int x, int y, int width, int height)
+  {
+    nativeSetBounds (x, y,
+                    width - insets.left - insets.right,
+                    height - insets.top - insets.bottom
+                    + menuBarHeight);
+  }  
+  
   public void setResizable (boolean resizable)
   {
     // Call setSize; otherwise when resizable is changed from true to
@@ -89,18 +100,15 @@ public class GtkFramePeer extends GtkWindowPeer
              + menuBarHeight);
     set ("allow_shrink", resizable);
     set ("allow_grow", resizable);
-  }
-
-  protected void postSizeAllocateEvent()
+  }  
+  
+  protected void postInsetsChangedEvent (int top, int left,
+                                        int bottom, int right)
   {
-    if (menuBar != null)
-    {
-      if (menuBarHeight != 0)
-        insets.top -= menuBarHeight;
-      menuBarHeight = getMenuBarHeight(menuBar);
-      insets.top += menuBarHeight;
-    }
-    awtComponent.doLayout();
+    insets.top = top + menuBarHeight;
+    insets.left = left;
+    insets.bottom = bottom;
+    insets.right = right;
   }
 
   public GtkFramePeer (Frame frame)
index 4d808e3..610fc14 100644 (file)
@@ -72,8 +72,6 @@ static jint window_get_new_state (GtkWidget *widget);
 static gboolean window_property_changed_cb (GtkWidget *widget,
                                            GdkEventProperty *event,
                                            jobject peer);
-static void menubar_resize_cb (GtkWidget *widget, GtkAllocation *alloc, 
-                               jobject peer);                                      
 
 /*
  * Make a new window.
@@ -402,15 +400,12 @@ Java_gnu_java_awt_peer_gtk_GtkFramePeer_setMenuBarPeer
   void *wptr;
   GtkWidget *mptr;
   GtkWidget *box;
-  jobject *gref = NSA_GET_GLOBAL_REF (env, obj);
-  
+
   wptr = NSA_GET_PTR (env, obj);
   mptr = NSA_GET_PTR (env, menubar);
   
   gdk_threads_enter ();
 
-  g_signal_connect (G_OBJECT (mptr), "size-allocate", 
-                    G_CALLBACK (menubar_resize_cb), *gref);    
   box = GTK_BIN (wptr)->child;             
   gtk_box_pack_start (GTK_BOX (box), mptr, 0, 0, 0);
  
@@ -426,11 +421,14 @@ Java_gnu_java_awt_peer_gtk_GtkFramePeer_getMenuBarHeight
 {
   GtkWidget *ptr;
   jint height;
+  GtkRequisition gtkreq;
   
   ptr = NSA_GET_PTR (env, menubar);
 
   gdk_threads_enter ();
-  height = ptr->allocation.height;
+  gtk_widget_size_request (ptr, &gtkreq);
+
+  height = gtkreq.height;
   gdk_threads_leave ();
   return height;
 }
@@ -733,26 +731,3 @@ window_property_changed_cb (GtkWidget *widget __attribute__((unused)),
 
   return FALSE;
 }
-
-static void menubar_resize_cb (GtkWidget *widget __attribute__((unused)), 
-                               GtkAllocation *alloc __attribute__((unused)), 
-                               jobject peer)
-{
-  static int id_set = 0;
-  static jmethodID postSizeAllocateEventID;
-  
-  if (!id_set)
-    {
-      jclass gtkframepeer = (*gdk_env)->FindClass (gdk_env,
-                                "gnu/java/awt/peer/gtk/GtkFramePeer");
-      postSizeAllocateEventID = (*gdk_env)->GetMethodID (gdk_env,
-                                                     gtkframepeer,
-                                                     "postSizeAllocateEvent",
-                                                     "()V");
-      id_set = 1;
-    }
-  gdk_threads_leave();
-  (*gdk_env)->CallVoidMethod (gdk_env, peer,
-                              postSizeAllocateEventID);
-  gdk_threads_enter();
-}