Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libjava / gnu / awt / xlib / XFramePeer.java
blobe7fdc83c7ec798b61ef770d0b635a9fa64393628
1 /* Copyright (C) 2000, 2002, 2003 Free Software Foundation
3 This file is part of libgcj.
5 This software is copyrighted work licensed under the terms of the
6 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
7 details. */
9 package gnu.awt.xlib;
11 import java.awt.*;
12 import java.awt.peer.*;
13 import java.awt.image.*;
14 import gnu.gcj.xlib.WMSizeHints;
15 import gnu.gcj.xlib.WindowAttributes;
16 import gnu.gcj.xlib.Display;
17 import gnu.gcj.xlib.Visual;
18 import gnu.gcj.xlib.Screen;
19 import gnu.gcj.xlib.XConfigureEvent;
21 /** FIXME: a lot of the code here should be moved down to XWindowPeer. */
23 public class XFramePeer extends XCanvasPeer implements FramePeer
25 private boolean processingConfigureNotify = false;
27 public XFramePeer(Frame frame)
29 super(frame);
31 // Set some defaults for a toplevel component:
32 if (frame.getFont() == null)
33 frame.setFont(new Font("helvetica", Font.PLAIN, 12));
35 if (frame.getBackground() == null)
36 frame.setBackground(Color.lightGray);
38 if (frame.getForeground() == null)
39 frame.setForeground(Color.black);
42 /** Find parent window for toplevel window, ie. root window of
43 selected screen. Bounds are not changed. */
44 gnu.gcj.xlib.Window locateParentWindow(Rectangle bounds)
46 Screen screen = config.getVisual().getScreen();
47 return screen.getRootWindow();
50 void initWindowProperties()
52 Frame frame = (Frame) component;
53 setResizable(frame.isResizable());
54 String title = frame.getTitle();
55 if (!title.equals("")) setTitle(title);
58 long getBasicEventMask()
60 return super.getBasicEventMask() |
61 WindowAttributes.MASK_STRUCTURE_NOTIFY;
64 void configureNotify(XConfigureEvent configEvent)
66 processingConfigureNotify = true; // to avoid setBounds flood
67 component.setBounds(configEvent.getBounds());
68 processingConfigureNotify = false;
71 /* Overridden to ignore request to set bounds if the request occurs
72 while processing an XConfigureNotify event, in which case the X
73 window already has the desired bounds.
74 That's what java.awt.Window.setBoundsCallback is for, but it's
75 package-private, and using our own flag eliminates the need to
76 circumvent java security.
78 public void setBounds(int x, int y, int width, int height)
80 if (!processingConfigureNotify)
81 super.setBounds(x, y, width, height);
84 // Implementing ContainerPeer:
86 static final Insets INSETS_0_PROTOTYPE = new Insets(0, 0, 0, 0);
88 public Insets getInsets()
90 return (Insets) INSETS_0_PROTOTYPE.clone();
93 public Insets insets ()
95 return getInsets ();
98 public void beginValidate()
102 public void endValidate()
104 // reassert sizing hints
105 Frame frame = (Frame) component;
106 setResizable(frame.isResizable());
110 // Implementing WindowPeer:
112 public void toBack()
114 window.toBack ();
117 public void toFront()
119 window.toFront ();
123 // Implementing FramePeer:
125 public void setIconImage(Image image)
127 throw new UnsupportedOperationException("not implemented yet");
130 public void setMenuBar(MenuBar mb)
132 throw new UnsupportedOperationException("not implemented yet");
136 public void setTitle(String title)
138 synchronized (window.getDisplay())
140 // Oh, what a nice implementation :-)
141 window.setProperty("WM_NAME", "STRING", title);
143 ensureFlush();
147 public void setResizable(boolean resizable)
149 Frame frame = (Frame) component;
151 WMSizeHints sizeHints = new WMSizeHints();
152 if (resizable)
154 Dimension minSize = frame.getMinimumSize();
155 sizeHints.setMinSize(minSize.width, minSize.height);
157 Dimension maxSize = frame.getMaximumSize();
159 if ((maxSize.width < Short.MAX_VALUE) ||
160 (maxSize.height < Short.MAX_VALUE))
162 maxSize.width = Math.min(maxSize.width, Short.MAX_VALUE);
163 maxSize.height = Math.min(maxSize.height, Short.MAX_VALUE);
164 sizeHints.setMaxSize(maxSize.width, maxSize.height);
167 else
169 // lock resizing to current bounds
170 Dimension size = frame.getSize();
171 sizeHints.setMinSize(size.width, size.height);
172 sizeHints.setMaxSize(size.width, size.height);
174 sizeHints.applyNormalHints(window);
177 public int getState ()
179 return 0;
182 public void setState (int state)
186 public void setMaximizedBounds (Rectangle r)
190 public void beginLayout () { }
191 public void endLayout () { }
192 public boolean isPaintPending () { return false; }
195 * @since 1.5
197 public void setBoundsPrivate (int x, int y, int width, int height)
202 * @since 1.5
204 public void updateAlwaysOnTop()
209 * @since 1.5
211 public boolean requestWindowFocus ()
213 return false;