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
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
)
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 ()
98 public void beginValidate()
102 public void endValidate()
104 // reassert sizing hints
105 Frame frame
= (Frame
) component
;
106 setResizable(frame
.isResizable());
110 // Implementing WindowPeer:
117 public void 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
);
147 public void setResizable(boolean resizable
)
149 Frame frame
= (Frame
) component
;
151 WMSizeHints sizeHints
= new WMSizeHints();
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
);
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 ()
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; }
197 public void setBoundsPrivate (int x
, int y
, int width
, int height
)
199 // TODO: Implement this.
200 throw new UnsupportedOperationException("Not yet implemented.");
203 public Rectangle
getBoundsPrivate()
205 // TODO: Implement this.
206 throw new UnsupportedOperationException("Not yet implemented.");
212 public void updateAlwaysOnTop()
219 public boolean requestWindowFocus ()
224 public void setAlwaysOnTop(boolean alwaysOnTop
)
226 throw new UnsupportedOperationException("not implemented yet");
229 public void updateFocusableWindowState()
231 throw new UnsupportedOperationException("not implemented yet");
234 public void setModalBlocked(Dialog blocker
, boolean blocked
)
236 throw new UnsupportedOperationException("not implemented yet");
239 public void updateMinimumSize()
241 throw new UnsupportedOperationException("not implemented yet");
244 public void updateIconImages()
246 throw new UnsupportedOperationException("not implemented yet");