Merge from mainline (gomp-merge-2005-02-26).
[official-gcc.git] / libjava / gnu / java / awt / peer / gtk / GtkContainerPeer.java
blob61551835ec705c0bf273c4f0744fce09206471ae
1 /* GtkContainerPeer.java -- Implements ContainerPeer with GTK
2 Copyright (C) 1998, 1999 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 package gnu.java.awt.peer.gtk;
41 import java.awt.Color;
42 import java.awt.Component;
43 import java.awt.Container;
44 import java.awt.Font;
45 import java.awt.Graphics;
46 import java.awt.Insets;
47 import java.awt.Window;
48 import java.awt.peer.ComponentPeer;
49 import java.awt.peer.ContainerPeer;
51 public class GtkContainerPeer extends GtkComponentPeer
52 implements ContainerPeer
54 Container c;
55 boolean isValidating;
57 public GtkContainerPeer(Container c)
59 super (c);
60 this.c = c;
63 public void beginValidate ()
65 isValidating = true;
68 public void endValidate ()
70 Component parent = awtComponent.getParent ();
72 // Only set our parent on the GTK side if our parent on the AWT
73 // side is not showing. Otherwise the gtk peer will be shown
74 // before we've had a chance to position and size it properly.
75 if (parent != null && parent.isShowing ())
77 Component[] components = ((Container) awtComponent).getComponents ();
78 int ncomponents = components.length;
80 for (int i = 0; i < ncomponents; i++)
82 ComponentPeer peer = components[i].getPeer ();
84 // Skip lightweight peers.
85 if (peer instanceof GtkComponentPeer)
86 ((GtkComponentPeer) peer).setParentAndBounds ();
89 // GTK windows don't have parents.
90 if (!(awtComponent instanceof Window))
91 setParentAndBounds ();
94 isValidating = false;
97 public Insets getInsets()
99 return insets;
102 public Insets insets()
104 return getInsets ();
107 public void setBounds (int x, int y, int width, int height)
109 super.setBounds (x, y, width, height);
112 public void setFont(Font f)
114 super.setFont(f);
115 Component[] components = ((Container) awtComponent).getComponents();
116 for (int i = 0; i < components.length; i++)
118 GtkComponentPeer peer = (GtkComponentPeer) components[i].getPeer();
119 if (peer != null && ! peer.awtComponent.isFontSet())
120 peer.setFont(f);
124 public Graphics getGraphics ()
126 return super.getGraphics();
129 public void beginLayout () { }
130 public void endLayout () { }
131 public boolean isPaintPending () { return false; }
133 public void setBackground (Color c)
135 super.setBackground(c);
137 Object components[] = ((Container) awtComponent).getComponents();
138 for (int i = 0; i < components.length; i++)
140 Component comp = (Component) components[i];
142 // If the child's background has not been explicitly set yet,
143 // it should inherit this container's background. This makes the
144 // child component appear as if it has a transparent background.
145 // Note that we do not alter the background property of the child,
146 // but only repaint the child with the parent's background color.
147 if (!comp.isBackgroundSet() && comp.getPeer() != null)
148 comp.getPeer().setBackground(c);