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