1:
8:
9: package ;
10:
11: import ;
12: import ;
13: import ;
14: import ;
15: import ;
16: import ;
17: import ;
18: import ;
19: import ;
20: import ;
21: import ;
22: import ;
23: import ;
24: import ;
25: import ;
26: import ;
27: import ;
28: import ;
29: import ;
30: import ;
31: import ;
32: import ;
33:
34: public class XToolkit extends ClasspathToolkit
35: {
36: static XToolkit INSTANCE;
37:
38: Display display;
39:
40: EventQueue queue;
41: XEventLoop eventLoop;
42:
43: XGraphicsConfiguration defaultConfig;
44:
45: public XToolkit()
46: {
47: INSTANCE = this;
48: display = new Display();
49: synchronized (display)
50: {
51: queue = new XEventQueue(display);
52: eventLoop = new XEventLoop(display, queue);
53: }
54: }
55:
56: public void flushIfIdle()
57: {
58: eventLoop.flushIfIdle();
59: }
60:
61: protected ButtonPeer createButton(Button frontend)
62: {
63:
64:
69: return null;
70: }
71:
72: protected TextFieldPeer createTextField(TextField frontend)
73: {
74: return null;
75: }
76:
77: protected LabelPeer createLabel(Label frontend)
78: {
79: return null;
80: }
81:
82: protected ListPeer createList(List frontend)
83: {
84: return null;
85: }
86:
87: protected CheckboxPeer createCheckbox(Checkbox frontend)
88: {
89: return null;
90: }
91:
92: protected ScrollbarPeer createScrollbar(Scrollbar frontend)
93: {
94: return null;
95: }
96:
97: protected ScrollPanePeer createScrollPane(ScrollPane frontend)
98: {
99: return null;
100: }
101:
102: protected TextAreaPeer createTextArea(TextArea frontend)
103: {
104: return null;
105: }
106:
107: protected ChoicePeer createChoice(Choice frontend)
108: {
109: return null;
110: }
111:
112: protected FramePeer createFrame(Frame frontend) {
113: return new XFramePeer(frontend);
114: }
115:
116: protected CanvasPeer createCanvas(Canvas frontend) {
117: XCanvasPeer peer = new XCanvasPeer(frontend);
118: return peer;
119: }
120:
121: protected PanelPeer createPanel(Panel frontend) {
122: return new XPanelPeer(frontend);
123: }
124:
125: protected WindowPeer createWindow(Window frontend)
126: {
127: return null;
128: }
129:
130: protected DialogPeer createDialog(Dialog frontend)
131: {
132: return null;
133: }
134:
135: protected MenuBarPeer createMenuBar(MenuBar frontend)
136: {
137: return null;
138: }
139:
140: protected MenuPeer createMenu(Menu frontend)
141: {
142: return null;
143: }
144:
145: protected PopupMenuPeer createPopupMenu(PopupMenu frontend)
146: {
147: return null;
148: }
149:
150: protected MenuItemPeer createMenuItem(MenuItem frontend)
151: {
152: return null;
153: }
154:
155: protected FileDialogPeer createFileDialog(FileDialog frontend)
156: {
157: return null;
158: }
159:
160: protected CheckboxMenuItemPeer
161: createCheckboxMenuItem(CheckboxMenuItem frontend)
162: {
163: return null;
164: }
165:
166: protected java.awt.peer.FontPeer getFontPeer(String name, int style)
167: {
168: return new XFontPeer (name,style);
169: }
170:
171: public Dimension getScreenSize()
172: {
173: throw new UnsupportedOperationException("not implemented yet");
174: }
175:
176: public int getScreenResolution()
177: {
178: throw new UnsupportedOperationException("not implemented yet");
179: }
180:
181: public java.awt.image.ColorModel getColorModel()
182: {
183: return getDefaultXGraphicsConfiguration().getColorModel();
184: }
185:
186: public String[] getFontList()
187: {
188: throw new UnsupportedOperationException("not implemented yet");
189: }
190:
191: public FontMetrics getFontMetrics(Font font)
192: {
193: return getDefaultXGraphicsConfiguration().getXFontMetrics(font);
194: }
195:
196: public void sync()
197: {
198: flushIfIdle ();
199:
200:
201:
202: }
203:
204: public Image getImage(String filename)
205: {
206: return createImage(filename);
207: }
208:
209: public Image getImage(URL url)
210: {
211: throw new UnsupportedOperationException("not implemented yet");
212: }
213:
214: public Image createImage(String filename)
215: {
216:
217:
218:
252:
253: return null;
254: }
255:
256: public Image createImage(URL url)
257: {
258: throw new UnsupportedOperationException("not implemented yet");
259: }
260:
261: public boolean prepareImage(Image image,
262: int width,
263: int height,
264: ImageObserver observer)
265: {
266: throw new UnsupportedOperationException("not implemented yet");
267: }
268:
269: public int checkImage(Image image,
270: int width,
271: int height,
272: ImageObserver observer)
273: {
274: throw new UnsupportedOperationException("not implemented yet");
275: }
276:
277: public Image createImage(ImageProducer producer)
278: {
279: throw new UnsupportedOperationException("not implemented yet");
280: }
281:
282: public Image createImage(byte[] imagedata,
283: int imageoffset,
284: int imagelength)
285: {
286: throw new UnsupportedOperationException("not implemented yet");
287: }
288:
289:
294:
295: public void beep()
296: {
297: throw new UnsupportedOperationException("not implemented yet");
298: }
299:
300: public Clipboard getSystemClipboard()
301: {
302: return null;
303: }
304:
305: protected EventQueue getSystemEventQueueImpl()
306: {
307: return queue;
308: }
309:
310: public PrintJob getPrintJob (Frame frame, String title, Properties props)
311: {
312: return null;
313: }
314:
315: XGraphicsConfiguration getDefaultXGraphicsConfiguration()
316: {
317: if (defaultConfig == null)
318: {
319: Screen screen = display.getDefaultScreen();
320: Visual visual = screen.getRootVisual();
321: defaultConfig = new XGraphicsConfiguration(visual);
322:
323:
324: if (!defaultConfig.getVisual().getScreen().equals(screen))
325: {
326: String msg = "screen of graphics configuration is not " +
327: "default screen";
328: throw new Error(msg);
329: }
330: }
331:
332: return defaultConfig;
333: }
334:
335: public DragSourceContextPeer
336: createDragSourceContextPeer(DragGestureEvent dge)
337: throws InvalidDnDOperationException
338: {
339: throw new UnsupportedOperationException("not implemented");
340: }
341:
342: public DragGestureRecognizer
343: createDragGestureRecognizer(Class abstractRecognizerClass,
344: DragSource ds, Component c,
345: int srcActions, DragGestureListener dgl)
346: {
347: throw new UnsupportedOperationException("not implemented");
348: }
349:
350:
351: public Map mapInputMethodHighlight(InputMethodHighlight highlight)
352: {
353: throw new UnsupportedOperationException("not implemented");
354: }
355:
356:
363: public GraphicsEnvironment getLocalGraphicsEnvironment ()
364: {
365: return new XGraphicsEnvironment (this);
366: }
367:
368:
380: public ClasspathFontPeer getClasspathFontPeer (String name, Map attrs)
381: {
382: int style = Font.PLAIN;
383: float size = 12;
384:
385: if (attrs.containsKey (TextAttribute.WEIGHT))
386: {
387: Float weight = (Float) attrs.get (TextAttribute.WEIGHT);
388: if (weight.floatValue () >= TextAttribute.WEIGHT_BOLD.floatValue ())
389: style += Font.BOLD;
390: }
391:
392: if (attrs.containsKey (TextAttribute.POSTURE))
393: {
394: Float posture = (Float) attrs.get (TextAttribute.POSTURE);
395: if (posture.floatValue () >= TextAttribute.POSTURE_OBLIQUE.floatValue ())
396: style += Font.ITALIC;
397: }
398:
399: if (attrs.containsKey (TextAttribute.SIZE))
400: {
401: Float fsize = (Float) attrs.get (TextAttribute.SIZE);
402: size = fsize.floatValue ();
403: }
404:
405: return new XFontPeer (name,style,size);
406: }
407:
408: public ClasspathTextLayoutPeer
409: getClasspathTextLayoutPeer (AttributedString str, FontRenderContext frc)
410: {
411: throw new Error("not implemented");
412: }
413:
414:
439: public Font createFont (int format, InputStream stream)
440: {
441: throw new java.lang.UnsupportedOperationException ();
442: }
443:
444: public RobotPeer createRobot (GraphicsDevice screen) throws AWTException
445: {
446: throw new java.lang.UnsupportedOperationException ();
447: }
448:
449: public EmbeddedWindowPeer createEmbeddedWindow (EmbeddedWindow w)
450: {
451: throw new java.lang.UnsupportedOperationException ();
452: }
453:
454: public boolean nativeQueueEmpty()
455: {
456:
457:
458: return true;
459: }
460:
461: public void wakeNativeQueue()
462: {
463:
464:
465: }
466:
467:
475: public void iterateNativeQueue(java.awt.EventQueue locked, boolean block)
476: {
477:
478:
479: if (block)
480: {
481: try
482: {
483: queue.wait ();
484: }
485: catch (InterruptedException ie)
486: {
487:
488: }
489: }
490: };
491: }