1:
8:
9: package ;
10:
11: import ;
12: import ;
13: import ;
14: import ;
15: import ;
16: import ;
17: import ;
18: import ;
19: import ;
20:
21:
22:
23: public class XFramePeer extends XCanvasPeer implements FramePeer
24: {
25: private boolean processingConfigureNotify = false;
26:
27: public XFramePeer(Frame frame)
28: {
29: super(frame);
30:
31:
32: if (frame.getFont() == null)
33: frame.setFont(new Font("helvetica", Font.PLAIN, 12));
34:
35: if (frame.getBackground() == null)
36: frame.setBackground(Color.lightGray);
37:
38: if (frame.getForeground() == null)
39: frame.setForeground(Color.black);
40: }
41:
42:
44: gnu.gcj.xlib.Window locateParentWindow(Rectangle bounds)
45: {
46: Screen screen = config.getVisual().getScreen();
47: return screen.getRootWindow();
48: }
49:
50: void initWindowProperties()
51: {
52: Frame frame = (Frame) component;
53: setResizable(frame.isResizable());
54: String title = frame.getTitle();
55: if (!title.equals("")) setTitle(title);
56: }
57:
58: long getBasicEventMask()
59: {
60: return super.getBasicEventMask() |
61: WindowAttributes.MASK_STRUCTURE_NOTIFY;
62: }
63:
64: void configureNotify(XConfigureEvent configEvent)
65: {
66: processingConfigureNotify = true;
67: component.setBounds(configEvent.getBounds());
68: processingConfigureNotify = false;
69: }
70:
71:
78: public void setBounds(int x, int y, int width, int height)
79: {
80: if (!processingConfigureNotify)
81: super.setBounds(x, y, width, height);
82: }
83:
84:
85:
86: static final Insets INSETS_0_PROTOTYPE = new Insets(0, 0, 0, 0);
87:
88: public Insets getInsets()
89: {
90: return (Insets) INSETS_0_PROTOTYPE.clone();
91: }
92:
93: public Insets insets ()
94: {
95: return getInsets ();
96: }
97:
98: public void beginValidate()
99: {
100: }
101:
102: public void endValidate()
103: {
104:
105: Frame frame = (Frame) component;
106: setResizable(frame.isResizable());
107: }
108:
109:
110:
111:
112: public void toBack()
113: {
114: window.toBack ();
115: }
116:
117: public void toFront()
118: {
119: window.toFront ();
120: }
121:
122:
123:
124:
125: public void setIconImage(Image image)
126: {
127: throw new UnsupportedOperationException("not implemented yet");
128: }
129:
130: public void setMenuBar(MenuBar mb)
131: {
132: throw new UnsupportedOperationException("not implemented yet");
133: }
134:
135:
136: public void setTitle(String title)
137: {
138: synchronized (window.getDisplay())
139: {
140:
141: window.setProperty("WM_NAME", "STRING", title);
142:
143: ensureFlush();
144: }
145: }
146:
147: public void setResizable(boolean resizable)
148: {
149: Frame frame = (Frame) component;
150:
151: WMSizeHints sizeHints = new WMSizeHints();
152: if (resizable)
153: {
154: Dimension minSize = frame.getMinimumSize();
155: sizeHints.setMinSize(minSize.width, minSize.height);
156:
157: Dimension maxSize = frame.getMaximumSize();
158:
159: if ((maxSize.width < Short.MAX_VALUE) ||
160: (maxSize.height < Short.MAX_VALUE))
161: {
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);
165: }
166: }
167: else
168: {
169:
170: Dimension size = frame.getSize();
171: sizeHints.setMinSize(size.width, size.height);
172: sizeHints.setMaxSize(size.width, size.height);
173: }
174: sizeHints.applyNormalHints(window);
175: }
176:
177: public int getState ()
178: {
179: return 0;
180: }
181:
182: public void setState (int state)
183: {
184: }
185:
186: public void setMaximizedBounds (Rectangle r)
187: {
188: }
189:
190: public void beginLayout () { }
191: public void endLayout () { }
192: public boolean isPaintPending () { return false; }
193:
194:
197: public void setBoundsPrivate (int x, int y, int width, int height)
198: {
199:
200: throw new UnsupportedOperationException("Not yet implemented.");
201: }
202:
203: public Rectangle getBoundsPrivate()
204: {
205:
206: throw new UnsupportedOperationException("Not yet implemented.");
207: }
208:
209:
212: public void updateAlwaysOnTop()
213: {
214: }
215:
216:
219: public boolean requestWindowFocus ()
220: {
221: return false;
222: }
223:
224: public void setAlwaysOnTop(boolean alwaysOnTop)
225: {
226: throw new UnsupportedOperationException("not implemented yet");
227: }
228:
229: public void updateFocusableWindowState()
230: {
231: throw new UnsupportedOperationException("not implemented yet");
232: }
233:
234: public void setModalBlocked(Dialog blocker, boolean blocked)
235: {
236: throw new UnsupportedOperationException("not implemented yet");
237: }
238:
239: public void updateMinimumSize()
240: {
241: throw new UnsupportedOperationException("not implemented yet");
242: }
243:
244: public void updateIconImages()
245: {
246: throw new UnsupportedOperationException("not implemented yet");
247: }
248: }