summaryrefslogtreecommitdiffstats
path: root/libjava/gnu/java/awt/peer
diff options
context:
space:
mode:
authorfitzsim <fitzsim@138bc75d-0d04-0410-961f-82ee72b054a4>2004-01-20 21:24:09 +0000
committerfitzsim <fitzsim@138bc75d-0d04-0410-961f-82ee72b054a4>2004-01-20 21:24:09 +0000
commit617a361e8d2704e0a7b51aa422a4f0eed7cf665b (patch)
tree78d8ff190e6b0e72cde58a5a6f203fe2ad124fef /libjava/gnu/java/awt/peer
parentfe6e657ead0263e382d2549fc3fc9b5e6c15a8b3 (diff)
downloadppe42-gcc-617a361e8d2704e0a7b51aa422a4f0eed7cf665b.tar.gz
ppe42-gcc-617a361e8d2704e0a7b51aa422a4f0eed7cf665b.zip
2004-01-20 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/gtk/GtkComponentPeer.java (setBounds): Calculate proper offsets for heavyweight components packed in lightweight containers. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@76230 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/gnu/java/awt/peer')
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java31
1 files changed, 29 insertions, 2 deletions
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java
index ee067cedd51..9a56619e18b 100644
--- a/libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java
+++ b/libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java
@@ -42,6 +42,7 @@ import java.awt.AWTEvent;
import java.awt.BufferCapabilities;
import java.awt.Color;
import java.awt.Component;
+import java.awt.Container;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
@@ -302,8 +303,34 @@ public class GtkComponentPeer extends GtkGenericPeer
public void setBounds (int x, int y, int width, int height)
{
Component parent = awtComponent.getParent ();
-
- if (parent instanceof Window)
+
+ // Heavyweight components that are children of one or more
+ // lightweight containers have to be handled specially. Because
+ // calls to GLightweightPeer.setBounds do nothing, GTK has no
+ // knowledge of the lightweight containers' positions. So we have
+ // to add the offsets manually when placing a heavyweight
+ // component within a lightweight container. The lightweight
+ // container may itself be in a lightweight container and so on,
+ // so we need to continue adding offsets until we reach a
+ // container whose position GTK knows -- that is, the first
+ // non-lightweight.
+ boolean lightweightChild = false;
+ Insets i;
+ while (parent.isLightweight ())
+ {
+ lightweightChild = true;
+
+ i = ((Container) parent).getInsets ();
+
+ x += parent.getX () + i.left;
+ y += parent.getY () + i.top;
+
+ parent = parent.getParent ();
+ }
+
+ // We only need to convert from Java to GTK coordinates if we're
+ // placing a heavyweight component in a Window.
+ if (parent instanceof Window && !lightweightChild)
{
Insets insets = ((Window) parent).getInsets ();
// Convert from Java coordinates to GTK coordinates.
OpenPOWER on IntegriCloud