FSF GCC merge 02/23/03
[official-gcc.git] / libjava / jni / gtk-peer / gnu_java_awt_peer_gtk_GtkPanelPeer.c
blobb52c75d5311cbb6578db3e8d4b9bfd80a406e538
1 /* gtkpanelpeer.c -- Native implementation of GtkPanelPeer
2 Copyright (C) 1998, 1999, 2002 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 #include "gtkpeer.h"
40 #include "gnu_java_awt_peer_gtk_GtkPanelPeer.h"
42 JNIEXPORT void JNICALL
43 Java_gnu_java_awt_peer_gtk_GtkPanelPeer_create
44 (JNIEnv *env, jobject obj)
46 gpointer widget;
48 gdk_threads_enter ();
49 widget = gtk_layout_new (NULL, NULL);
50 gdk_threads_leave ();
52 NSA_SET_PTR (env, obj, widget);
55 typedef struct _GtkLayoutChild GtkLayoutChild;
57 struct _GtkLayoutChild {
58 GtkWidget *widget;
59 gint x;
60 gint y;
63 static
64 void sr (GtkWidget *widget, GtkRequisition *requisition, gpointer user_data)
66 GtkLayout *layout;
67 GtkLayoutChild *child;
68 GList *children;
70 layout = GTK_LAYOUT (widget);
71 requisition->width = GTK_WIDGET (widget)->allocation.width;
72 requisition->height = GTK_WIDGET (widget)->allocation.height;
74 children = layout->children;
75 while (children)
77 child = children->data;
78 children = children->next;
80 if (GTK_WIDGET_VISIBLE (child->widget))
82 requisition->height = MAX (requisition->height,
83 child->y +
84 child->widget->allocation.height);
85 requisition->width = MAX (requisition->width,
86 child->x +
87 child->widget->allocation.width);
91 requisition->height += GTK_CONTAINER (layout)->border_width * 2;
92 requisition->width += GTK_CONTAINER (layout)->border_width * 2;
95 JNIEXPORT void JNICALL
96 Java_gnu_java_awt_peer_gtk_GtkPanelPeer_connectHooks
97 (JNIEnv *env, jobject obj)
99 void *ptr;
101 ptr = NSA_GET_PTR (env, obj);
103 gdk_threads_enter ();
104 gtk_widget_realize (GTK_WIDGET (ptr));
105 connect_awt_hook (env, obj, 1, GTK_LAYOUT (ptr)->bin_window);
107 /* gtk_signal_connect (GTK_OBJECT (ptr), "size_request", GTK_SIGNAL_FUNC (sr), */
108 /* NULL); */
109 gdk_threads_leave ();
113 * Make a new panel.
115 JNIEXPORT void JNICALL
116 Java_gnu_java_awt_peer_gtk_GtkPanelPeer_gtkPanelNew
117 (JNIEnv *env, jobject obj, jobject parent_obj)
119 GtkWidget *layout;
120 void *parent;
122 parent = NSA_GET_PTR (env, parent_obj);
124 gdk_threads_enter ();
125 layout = gtk_layout_new (NULL, NULL);
127 set_parent (layout, GTK_CONTAINER (parent));
129 gtk_widget_realize (layout);
130 connect_awt_hook (env, obj, 1, GTK_LAYOUT (layout)->bin_window);
131 set_visible (layout, 1);
133 NSA_SET_PTR (env, obj, layout);
134 gdk_threads_leave ();