source: trunk/src/gcc/libjava/gnu/awt/xlib/XToolkit.java@ 2

Last change on this file since 2 was 2, checked in by bird, 23 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 7.2 KB
Line 
1/* Copyright (C) 2000, 2002 Free Software Foundation
2
3 This file is part of libgcj.
4
5This software is copyrighted work licensed under the terms of the
6Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
7details. */
8
9package gnu.awt.xlib;
10
11import java.awt.*;
12import java.awt.peer.*;
13import java.awt.image.ImageProducer;
14import java.awt.image.ImageObserver;
15import java.net.*;
16import java.awt.datatransfer.Clipboard;
17import java.util.Properties;
18
19import gnu.gcj.xlib.Display;
20import gnu.gcj.xlib.Screen;
21import gnu.gcj.xlib.Visual;
22
23public class XToolkit extends Toolkit
24{
25 static XToolkit INSTANCE;
26
27 Display display;
28
29 EventQueue queue;
30 XEventLoop eventLoop;
31
32 XGraphicsConfiguration defaultConfig;
33
34 public XToolkit()
35 {
36 INSTANCE = this;
37 display = new Display();
38 synchronized (display)
39 {
40 queue = new XEventQueue(display);
41 eventLoop = new XEventLoop(display, queue);
42 }
43 }
44
45 public void flushIfIdle()
46 {
47 eventLoop.flushIfIdle();
48 }
49
50 protected ButtonPeer createButton(Button frontend)
51 {
52 // FIXME: Stubbed out, needs Swing:
53 /*
54 XCanvasPeer realPeer = new XCanvasPeer(frontend);
55 SButtonPeer sbPeer = new SButtonPeer(frontend, realPeer);
56 return sbPeer;
57 */
58 return null;
59 }
60
61 protected TextFieldPeer createTextField(TextField frontend)
62 {
63 return null; // FIXME
64 }
65
66 protected LabelPeer createLabel(Label frontend)
67 {
68 return null; // FIXME
69 }
70
71 protected ListPeer createList(List frontend)
72 {
73 return null; // FIXME
74 }
75
76 protected CheckboxPeer createCheckbox(Checkbox frontend)
77 {
78 return null; // FIXME
79 }
80
81 protected ScrollbarPeer createScrollbar(Scrollbar frontend)
82 {
83 return null; // FIXME
84 }
85
86 protected ScrollPanePeer createScrollPane(ScrollPane frontend)
87 {
88 return null; // FIXME
89 }
90
91 protected TextAreaPeer createTextArea(TextArea frontend)
92 {
93 return null; // FIXME
94 }
95
96 protected ChoicePeer createChoice(Choice frontend)
97 {
98 return null; // FIXME
99 }
100
101 protected FramePeer createFrame(Frame frontend) {
102 return new XFramePeer(frontend);
103 }
104
105 protected CanvasPeer createCanvas(Canvas frontend) {
106 XCanvasPeer peer = new XCanvasPeer(frontend);
107 return peer;
108 }
109
110 protected PanelPeer createPanel(Panel frontend) {
111 return new XPanelPeer(frontend);
112 }
113
114 protected WindowPeer createWindow(Window frontend)
115 {
116 return null; // FIXME
117 }
118
119 protected DialogPeer createDialog(Dialog frontend)
120 {
121 return null; // FIXME
122 }
123
124 protected MenuBarPeer createMenuBar(MenuBar frontend)
125 {
126 return null; // FIXME
127 }
128
129 protected MenuPeer createMenu(Menu frontend)
130 {
131 return null; // FIXME
132 }
133
134 protected PopupMenuPeer createPopupMenu(PopupMenu frontend)
135 {
136 return null; // FIXME
137 }
138
139 protected MenuItemPeer createMenuItem(MenuItem frontend)
140 {
141 return null; // FIXME
142 }
143
144 protected FileDialogPeer createFileDialog(FileDialog frontend)
145 {
146 return null; // FIXME
147 }
148
149 protected CheckboxMenuItemPeer
150 createCheckboxMenuItem(CheckboxMenuItem frontend)
151 {
152 return null; // FIXME
153 }
154
155 protected java.awt.peer.FontPeer getFontPeer(String name, int style)
156 {
157 return null;
158 }
159
160 public Dimension getScreenSize()
161 {
162 throw new UnsupportedOperationException("not implemented yet");
163 }
164
165 public int getScreenResolution()
166 {
167 throw new UnsupportedOperationException("not implemented yet");
168 }
169
170 public java.awt.image.ColorModel getColorModel()
171 {
172 throw new UnsupportedOperationException("not implemented yet");
173 }
174
175 public String[] getFontList()
176 {
177 throw new UnsupportedOperationException("not implemented yet");
178 }
179
180 public FontMetrics getFontMetrics(Font font)
181 {
182 return defaultConfig.getXFontMetrics(font);
183 }
184
185 public void sync()
186 {
187 throw new UnsupportedOperationException("not implemented yet");
188 }
189
190 public Image getImage(String filename)
191 {
192 return createImage(filename);
193 }
194
195 public Image getImage(URL url)
196 {
197 throw new UnsupportedOperationException("not implemented yet");
198 }
199
200 public Image createImage(String filename)
201 {
202 // FIXME: Stubbed out. We need a proper image I/O API.
203
204 /*
205 BufferedImage jpeg;
206 FileInputStream fis = openFile(filename);
207 if (fis == null)
208 return null;
209
210 BasicRasterImageConsumer consumer = new BasicRasterImageConsumer();
211 JPEGImageDecoder jid = new JPEGImageDecoder(fis);
212
213 jid.startProduction(consumer);
214 jpeg = consumer.getImage();
215
216 int w = jpeg.getWidth();
217 int h = jpeg.getHeight();
218
219 BufferedImage img =
220 getDefaultXGraphicsConfiguration().createCompatibleImage(w, h);
221
222 Renderers renderers = Renderers.getInstance();
223
224 RasterOp renderer = renderers.createRenderer(jpeg.getColorModel(),
225 jpeg.getSampleModel(),
226 img.getColorModel(),
227 img.getSampleModel());
228
229 if (renderer == null)
230 {
231 throw new UnsupportedOperationException("couldn't find renderer");
232 }
233
234 renderer.filter(jpeg.getRaster(), img.getRaster());
235
236 return img;
237 */
238
239 return null;
240 }
241
242 public Image createImage(URL url)
243 {
244 throw new UnsupportedOperationException("not implemented yet");
245 }
246
247 public boolean prepareImage(Image image,
248 int width,
249 int height,
250 ImageObserver observer)
251 {
252 throw new UnsupportedOperationException("not implemented yet");
253 }
254
255 public int checkImage(Image image,
256 int width,
257 int height,
258 ImageObserver observer)
259 {
260 throw new UnsupportedOperationException("not implemented yet");
261 }
262
263 public Image createImage(ImageProducer producer)
264 {
265 throw new UnsupportedOperationException("not implemented yet");
266 }
267
268 public Image createImage(byte[] imagedata,
269 int imageoffset,
270 int imagelength)
271 {
272 throw new UnsupportedOperationException("not implemented yet");
273 }
274
275 /*
276 public PrintJob getPrintJob(Frame frame,
277 String jobtitle,
278 Properties props);
279 */
280
281 public void beep()
282 {
283 throw new UnsupportedOperationException("not implemented yet");
284 }
285
286 public Clipboard getSystemClipboard()
287 {
288 return null; // FIXME
289 }
290
291 protected EventQueue getSystemEventQueueImpl()
292 {
293 return queue;
294 }
295
296 public PrintJob getPrintJob (Frame frame, String title, Properties props)
297 {
298 return null; // FIXME
299 }
300
301 XGraphicsConfiguration getDefaultXGraphicsConfiguration()
302 {
303 if (defaultConfig == null)
304 {
305 Screen screen = display.getDefaultScreen();
306 Visual visual = screen.getRootVisual();
307 defaultConfig = new XGraphicsConfiguration(visual);
308
309 // ASSERT:
310 if (!defaultConfig.getVisual().getScreen().equals(screen))
311 {
312 String msg = "screen of graphics configuration is not " +
313 "default screen";
314 throw new Error(msg);
315 }
316 }
317
318 return defaultConfig;
319 }
320
321
322 /*
323 public DragSourceContextPeer
324 createDragSourceContextPeer(DragGestureEvent dge)
325 throws InvalidDnDOperationException;
326
327 public DragGestureRecognizer
328 createDragGestureRecognizer(Class abstractRecognizerClass,
329 DragSource ds, Component c,
330 int srcActions, DragGestureListener dgl) {
331 throw new UnsupportedOperationException("not implemented");
332 }
333 */
334
335
336 /*
337 public Map mapInputMethodHighlight(InputMethodHighlight highlight);
338 */
339}
Note: See TracBrowser for help on using the repository browser.