1 | /* Toolkit.java -- AWT Toolkit superclass
|
---|
2 | Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
|
---|
3 |
|
---|
4 | This file is part of GNU Classpath.
|
---|
5 |
|
---|
6 | GNU Classpath is free software; you can redistribute it and/or modify
|
---|
7 | it under the terms of the GNU General Public License as published by
|
---|
8 | the Free Software Foundation; either version 2, or (at your option)
|
---|
9 | any later version.
|
---|
10 |
|
---|
11 | GNU Classpath is distributed in the hope that it will be useful, but
|
---|
12 | WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
14 | General Public License for more details.
|
---|
15 |
|
---|
16 | You should have received a copy of the GNU General Public License
|
---|
17 | along with GNU Classpath; see the file COPYING. If not, write to the
|
---|
18 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
---|
19 | 02111-1307 USA.
|
---|
20 |
|
---|
21 | Linking this library statically or dynamically with other modules is
|
---|
22 | making a combined work based on this library. Thus, the terms and
|
---|
23 | conditions of the GNU General Public License cover the whole
|
---|
24 | combination.
|
---|
25 |
|
---|
26 | As a special exception, the copyright holders of this library give you
|
---|
27 | permission to link this library with independent modules to produce an
|
---|
28 | executable, regardless of the license terms of these independent
|
---|
29 | modules, and to copy and distribute the resulting executable under
|
---|
30 | terms of your choice, provided that you also meet, for each linked
|
---|
31 | independent module, the terms and conditions of the license of that
|
---|
32 | module. An independent module is a module which is not derived from
|
---|
33 | or based on this library. If you modify this library, you may extend
|
---|
34 | this exception to your version of the library, but you are not
|
---|
35 | obligated to do so. If you do not wish to do so, delete this
|
---|
36 | exception statement from your version. */
|
---|
37 |
|
---|
38 |
|
---|
39 | package java.awt;
|
---|
40 |
|
---|
41 | import java.awt.datatransfer.Clipboard;
|
---|
42 | import java.awt.dnd.DragGestureEvent;
|
---|
43 | import java.awt.dnd.DragGestureListener;
|
---|
44 | import java.awt.dnd.DragGestureRecognizer;
|
---|
45 | import java.awt.dnd.DragSource;
|
---|
46 | import java.awt.dnd.peer.DragSourceContextPeer;
|
---|
47 | import java.awt.event.AWTEventListener;
|
---|
48 | import java.awt.event.KeyEvent;
|
---|
49 | import java.awt.im.InputMethodHighlight;
|
---|
50 | import java.awt.image.ColorModel;
|
---|
51 | import java.awt.image.ImageObserver;
|
---|
52 | import java.awt.image.ImageProducer;
|
---|
53 | import java.awt.peer.ButtonPeer;
|
---|
54 | import java.awt.peer.CanvasPeer;
|
---|
55 | import java.awt.peer.CheckboxPeer;
|
---|
56 | import java.awt.peer.CheckboxMenuItemPeer;
|
---|
57 | import java.awt.peer.ChoicePeer;
|
---|
58 | import java.awt.peer.DialogPeer;
|
---|
59 | import java.awt.peer.FileDialogPeer;
|
---|
60 | import java.awt.peer.FontPeer;
|
---|
61 | import java.awt.peer.FramePeer;
|
---|
62 | import java.awt.peer.LabelPeer;
|
---|
63 | import java.awt.peer.LightweightPeer;
|
---|
64 | import java.awt.peer.ListPeer;
|
---|
65 | import java.awt.peer.MenuPeer;
|
---|
66 | import java.awt.peer.MenuBarPeer;
|
---|
67 | import java.awt.peer.MenuItemPeer;
|
---|
68 | import java.awt.peer.PanelPeer;
|
---|
69 | import java.awt.peer.PopupMenuPeer;
|
---|
70 | import java.awt.peer.ScrollbarPeer;
|
---|
71 | import java.awt.peer.ScrollPanePeer;
|
---|
72 | import java.awt.peer.TextAreaPeer;
|
---|
73 | import java.awt.peer.TextFieldPeer;
|
---|
74 | import java.awt.peer.WindowPeer;
|
---|
75 | import java.beans.PropertyChangeListener;
|
---|
76 | import java.beans.PropertyChangeSupport;
|
---|
77 | import java.net.URL;
|
---|
78 | import java.util.Map;
|
---|
79 | import java.util.Properties;
|
---|
80 |
|
---|
81 | /**
|
---|
82 | * The AWT system uses a set of native peer objects to implement its
|
---|
83 | * widgets. These peers are provided by a peer toolkit, that is accessed
|
---|
84 | * via a subclass of this superclass. The system toolkit is retrieved
|
---|
85 | * by the static methods <code>getDefaultToolkit</code>. This method
|
---|
86 | * determines the system toolkit by examining the system property
|
---|
87 | * <code>awt.toolkit</code>. That property is set to the name of the
|
---|
88 | * <code>Toolkit</code> subclass for the specified peer set. If the
|
---|
89 | * <code>awt.toolkit</code> property is not set, then the default
|
---|
90 | * toolkit <code>gnu.java.awt.peer.gtk.GtkToolkit</code> is used. This
|
---|
91 | * toolkit creates its peers using the GTK+ toolkit.
|
---|
92 | *
|
---|
93 | * @author Aaron M. Renn <arenn@urbanophile.com>
|
---|
94 | */
|
---|
95 | public abstract class Toolkit
|
---|
96 | {
|
---|
97 | /** The default toolkit name. */
|
---|
98 | private static String default_toolkit_name
|
---|
99 | = "gnu.awt.gtk.GtkToolkit";
|
---|
100 |
|
---|
101 | /**
|
---|
102 | * The toolkit in use. Once we load it, we don't ever change it
|
---|
103 | * if the awt.toolkit property is set.
|
---|
104 | */
|
---|
105 | private static Toolkit toolkit;
|
---|
106 |
|
---|
107 | /** The toolkit properties. */
|
---|
108 | private static Properties props = new Properties();
|
---|
109 |
|
---|
110 | protected final Map desktopProperties = new Properties();
|
---|
111 |
|
---|
112 | protected final PropertyChangeSupport desktopPropsSupport
|
---|
113 | = new PropertyChangeSupport(this);
|
---|
114 |
|
---|
115 | /**
|
---|
116 | * Default constructor for subclasses.
|
---|
117 | */
|
---|
118 | public Toolkit()
|
---|
119 | {
|
---|
120 | }
|
---|
121 |
|
---|
122 | /**
|
---|
123 | * Creates a peer object for the specified <code>Button</code>.
|
---|
124 | *
|
---|
125 | * @param target The <code>Button</code> to create the peer for.
|
---|
126 | *
|
---|
127 | * @return The peer for the specified <code>Button</code> object.
|
---|
128 | *
|
---|
129 | * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
---|
130 | */
|
---|
131 | protected abstract ButtonPeer createButton(Button target);
|
---|
132 |
|
---|
133 | /**
|
---|
134 | * Creates a peer object for the specified <code>TextField</code>.
|
---|
135 | *
|
---|
136 | * @param target The <code>TextField</code> to create the peer for.
|
---|
137 | * @return The peer for the specified <code>TextField</code> object.
|
---|
138 | *
|
---|
139 | * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
---|
140 | */
|
---|
141 | protected abstract TextFieldPeer createTextField(TextField target);
|
---|
142 |
|
---|
143 | /**
|
---|
144 | * Creates a peer object for the specified <code>Label</code>.
|
---|
145 | *
|
---|
146 | * @param target The <code>Label</code> to create the peer for.
|
---|
147 | * @return The peer for the specified <code>Label</code> object.
|
---|
148 | *
|
---|
149 | * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
---|
150 | */
|
---|
151 | protected abstract LabelPeer createLabel(Label target);
|
---|
152 |
|
---|
153 | /**
|
---|
154 | * Creates a peer object for the specified <code>List</code>.
|
---|
155 | *
|
---|
156 | * @param target The <code>List</code> to create the peer for.
|
---|
157 | * @return The peer for the specified <code>List</code> object.
|
---|
158 | *
|
---|
159 | * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
---|
160 | */
|
---|
161 | protected abstract ListPeer createList(List target);
|
---|
162 |
|
---|
163 | /**
|
---|
164 | * Creates a peer object for the specified <code>Checkbox</code>.
|
---|
165 | *
|
---|
166 | * @param target The <code>Checkbox</code> to create the peer for.
|
---|
167 | * @return The peer for the specified <code>Checkbox</code> object.
|
---|
168 | *
|
---|
169 | * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
---|
170 | */
|
---|
171 | protected abstract CheckboxPeer createCheckbox(Checkbox target);
|
---|
172 |
|
---|
173 | /**
|
---|
174 | * Creates a peer object for the specified <code>Scrollbar</code>.
|
---|
175 | *
|
---|
176 | * @param target The <code>Scrollbar</code> to create the peer for.
|
---|
177 | * @return The peer for the specified <code>Scrollbar</code> object.
|
---|
178 | *
|
---|
179 | * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
---|
180 | */
|
---|
181 | protected abstract ScrollbarPeer createScrollbar(Scrollbar target);
|
---|
182 |
|
---|
183 | /**
|
---|
184 | * Creates a peer object for the specified <code>ScrollPane</code>.
|
---|
185 | *
|
---|
186 | * @param target The <code>ScrollPane</code> to create the peer for.
|
---|
187 | * @return The peer for the specified <code>ScrollPane</code> object.
|
---|
188 | *
|
---|
189 | * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
---|
190 | */
|
---|
191 | protected abstract ScrollPanePeer createScrollPane(ScrollPane target);
|
---|
192 |
|
---|
193 | /**
|
---|
194 | * Creates a peer object for the specified <code>TextArea</code>.
|
---|
195 | *
|
---|
196 | * @param target The <code>TextArea</code> to create the peer for.
|
---|
197 | * @return The peer for the specified <code>TextArea</code> object.
|
---|
198 | *
|
---|
199 | * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
---|
200 | */
|
---|
201 | protected abstract TextAreaPeer createTextArea(TextArea target);
|
---|
202 |
|
---|
203 | /**
|
---|
204 | * Creates a peer object for the specified <code>Choice</code>.
|
---|
205 | *
|
---|
206 | * @param target The <code>Choice</code> to create the peer for.
|
---|
207 | * @return The peer for the specified <code>Choice</code> object.
|
---|
208 | *
|
---|
209 | * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
---|
210 | */
|
---|
211 | protected abstract ChoicePeer createChoice(Choice target);
|
---|
212 |
|
---|
213 | /**
|
---|
214 | * Creates a peer object for the specified <code>Frame</code>.
|
---|
215 | *
|
---|
216 | * @param target The <code>Frame</code> to create the peer for.
|
---|
217 | * @return The peer for the specified <code>Frame</code> object.
|
---|
218 | *
|
---|
219 | * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
---|
220 | */
|
---|
221 | protected abstract FramePeer createFrame(Frame target);
|
---|
222 |
|
---|
223 | /**
|
---|
224 | * Creates a peer object for the specified <code>Canvas</code>.
|
---|
225 | *
|
---|
226 | * @param target The <code>Canvas</code> to create the peer for.
|
---|
227 | * @return The peer for the specified <code>Canvas</code> object.
|
---|
228 | */
|
---|
229 | protected abstract CanvasPeer createCanvas(Canvas target);
|
---|
230 |
|
---|
231 | /**
|
---|
232 | * Creates a peer object for the specified <code>Panel</code>.
|
---|
233 | *
|
---|
234 | * @param target The <code>Panel</code> to create the peer for.
|
---|
235 | * @return The peer for the specified <code>Panel</code> object.
|
---|
236 | */
|
---|
237 | protected abstract PanelPeer createPanel(Panel target);
|
---|
238 |
|
---|
239 | /**
|
---|
240 | * Creates a peer object for the specified <code>Window</code>.
|
---|
241 | *
|
---|
242 | * @param target The <code>Window</code> to create the peer for.
|
---|
243 | * @return The peer for the specified <code>Window</code> object.
|
---|
244 | *
|
---|
245 | * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
---|
246 | */
|
---|
247 | protected abstract WindowPeer createWindow(Window target);
|
---|
248 |
|
---|
249 | /**
|
---|
250 | * Creates a peer object for the specified <code>Dialog</code>.
|
---|
251 | *
|
---|
252 | * @param target The dialog to create the peer for
|
---|
253 | * @return The peer for the specified font name.
|
---|
254 | *
|
---|
255 | * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
---|
256 | */
|
---|
257 | protected abstract DialogPeer createDialog(Dialog target);
|
---|
258 |
|
---|
259 | /**
|
---|
260 | * Creates a peer object for the specified <code>MenuBar</code>.
|
---|
261 | *
|
---|
262 | * @param target The <code>MenuBar</code> to create the peer for.
|
---|
263 | * @return The peer for the specified <code>MenuBar</code> object.
|
---|
264 | *
|
---|
265 | * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
---|
266 | */
|
---|
267 | protected abstract MenuBarPeer createMenuBar(MenuBar target);
|
---|
268 |
|
---|
269 | /**
|
---|
270 | * Creates a peer object for the specified <code>Menu</code>.
|
---|
271 | *
|
---|
272 | * @param target The <code>Menu</code> to create the peer for.
|
---|
273 | * @return The peer for the specified <code>Menu</code> object.
|
---|
274 | *
|
---|
275 | * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
---|
276 | */
|
---|
277 | protected abstract MenuPeer createMenu(Menu target);
|
---|
278 |
|
---|
279 | /**
|
---|
280 | * Creates a peer object for the specified <code>PopupMenu</code>.
|
---|
281 | *
|
---|
282 | * @param target The <code>PopupMenu</code> to create the peer for.
|
---|
283 | * @return The peer for the specified <code>PopupMenu</code> object.
|
---|
284 | *
|
---|
285 | * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
---|
286 | */
|
---|
287 | protected abstract PopupMenuPeer createPopupMenu(PopupMenu target);
|
---|
288 |
|
---|
289 | /**
|
---|
290 | * Creates a peer object for the specified <code>MenuItem</code>.
|
---|
291 | *
|
---|
292 | * @param target The <code>MenuItem</code> to create the peer for.
|
---|
293 | * @return The peer for the specified <code>MenuItem</code> object.
|
---|
294 | *
|
---|
295 | * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
---|
296 | */
|
---|
297 | protected abstract MenuItemPeer createMenuItem(MenuItem target);
|
---|
298 |
|
---|
299 | /**
|
---|
300 | * Creates a peer object for the specified <code>FileDialog</code>.
|
---|
301 | *
|
---|
302 | * @param target The <code>FileDialog</code> to create the peer for.
|
---|
303 | * @return The peer for the specified <code>FileDialog</code> object.
|
---|
304 | *
|
---|
305 | * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
---|
306 | */
|
---|
307 | protected abstract FileDialogPeer createFileDialog(FileDialog target);
|
---|
308 |
|
---|
309 | /**
|
---|
310 | * Creates a peer object for the specified <code>CheckboxMenuItem</code>.
|
---|
311 | *
|
---|
312 | * @param target The <code>CheckboxMenuItem</code> to create the peer for.
|
---|
313 | * @return The peer for the specified <code>CheckboxMenuItem</code> object.
|
---|
314 | *
|
---|
315 | * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
---|
316 | */
|
---|
317 | protected abstract CheckboxMenuItemPeer
|
---|
318 | createCheckboxMenuItem(CheckboxMenuItem target);
|
---|
319 |
|
---|
320 | /**
|
---|
321 | * Creates a peer object for the specified <code>Component</code>. The
|
---|
322 | * peer returned by this method is not a native windowing system peer
|
---|
323 | * with its own native window. Instead, this method allows the component
|
---|
324 | * to draw on its parent window as a "lightweight" widget.
|
---|
325 | *
|
---|
326 | * XXX: FIXME
|
---|
327 | *
|
---|
328 | * @param target The <code>Component</code> to create the peer for.
|
---|
329 | * @return The peer for the specified <code>Component</code> object.
|
---|
330 | */
|
---|
331 | protected LightweightPeer createComponent(Component target)
|
---|
332 | {
|
---|
333 | return null;
|
---|
334 | }
|
---|
335 |
|
---|
336 | /**
|
---|
337 | * Creates a peer object for the specified font name.
|
---|
338 | *
|
---|
339 | * @param name The font to create the peer for.
|
---|
340 | * @param style The font style to create the peer for.
|
---|
341 | * @return The peer for the specified font name.
|
---|
342 | */
|
---|
343 | protected abstract FontPeer getFontPeer(String name, int style);
|
---|
344 |
|
---|
345 | /**
|
---|
346 | * Copies the current system colors into the specified array. This is
|
---|
347 | * the interface used by the <code>SystemColors</code> class.
|
---|
348 | *
|
---|
349 | * @param colors The array to copy the system colors into.
|
---|
350 | *
|
---|
351 | * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
---|
352 | */
|
---|
353 | protected void loadSystemColors(int systemColors[])
|
---|
354 | {
|
---|
355 | // XXX Implement.
|
---|
356 | }
|
---|
357 |
|
---|
358 | /**
|
---|
359 | * @since 1.4
|
---|
360 | *
|
---|
361 | * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
---|
362 | */
|
---|
363 | public void setDynamicLayout(boolean dynamic)
|
---|
364 | {
|
---|
365 | }
|
---|
366 |
|
---|
367 | /**
|
---|
368 | * @since 1.4
|
---|
369 | *
|
---|
370 | * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
---|
371 | */
|
---|
372 | protected boolean isDynamicLayoutSet()
|
---|
373 | {
|
---|
374 | return false;
|
---|
375 | }
|
---|
376 |
|
---|
377 | /**
|
---|
378 | * @since 1.4
|
---|
379 | *
|
---|
380 | * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
---|
381 | */
|
---|
382 | public boolean isDynamicLayoutActive()
|
---|
383 | {
|
---|
384 | return false;
|
---|
385 | }
|
---|
386 |
|
---|
387 | /**
|
---|
388 | * Returns the dimensions of the screen in pixels.
|
---|
389 | *
|
---|
390 | * @return The dimensions of the screen in pixels.
|
---|
391 | *
|
---|
392 | * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
---|
393 | */
|
---|
394 | public abstract Dimension getScreenSize();
|
---|
395 |
|
---|
396 | /**
|
---|
397 | * Returns the screen resolution in dots per square inch.
|
---|
398 | *
|
---|
399 | * @return The screen resolution in dots per square inch.
|
---|
400 | *
|
---|
401 | * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
---|
402 | */
|
---|
403 | public abstract int getScreenResolution();
|
---|
404 |
|
---|
405 | /**
|
---|
406 | * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
---|
407 | *
|
---|
408 | * @since 1.4
|
---|
409 | */
|
---|
410 | public Insets getScreenInsets(GraphicsConfiguration gc)
|
---|
411 | {
|
---|
412 | return null;
|
---|
413 | }
|
---|
414 |
|
---|
415 | /**
|
---|
416 | * Returns the color model of the screen.
|
---|
417 | *
|
---|
418 | * @return The color model of the screen.
|
---|
419 | */
|
---|
420 | public abstract ColorModel getColorModel();
|
---|
421 |
|
---|
422 | /**
|
---|
423 | * Returns the names of the available fonts.
|
---|
424 | *
|
---|
425 | * @return The names of the available fonts.
|
---|
426 | */
|
---|
427 | public abstract String[] getFontList();
|
---|
428 |
|
---|
429 | /**
|
---|
430 | * Return the font metrics for the specified font
|
---|
431 | *
|
---|
432 | * @param name The name of the font to return metrics for.
|
---|
433 | * @return The requested font metrics.
|
---|
434 | */
|
---|
435 | public abstract FontMetrics getFontMetrics(Font name);
|
---|
436 |
|
---|
437 | /**
|
---|
438 | * Flushes any buffered data to the screen so that it is in sync with
|
---|
439 | * what the AWT system has drawn to it.
|
---|
440 | */
|
---|
441 | public abstract void sync();
|
---|
442 |
|
---|
443 | /**
|
---|
444 | * Returns an instance of the default toolkit. The default toolkit is
|
---|
445 | * the subclass of <code>Toolkit</code> specified in the system property
|
---|
446 | * <code>awt.toolkit</code>, or <code>gnu.java.awt.peer.gtk.GtkToolkit</code>
|
---|
447 | * if the property is not set.
|
---|
448 | *
|
---|
449 | * @return An instance of the system default toolkit.
|
---|
450 | *
|
---|
451 | * @throws AWTError If the toolkit cannot be loaded.
|
---|
452 | */
|
---|
453 | public static Toolkit getDefaultToolkit()
|
---|
454 | {
|
---|
455 | if (toolkit != null)
|
---|
456 | return toolkit;
|
---|
457 | String toolkit_name = System.getProperty("awt.toolkit",
|
---|
458 | default_toolkit_name);
|
---|
459 | try
|
---|
460 | {
|
---|
461 | Class cls = Class.forName(toolkit_name);
|
---|
462 | Object obj = cls.newInstance();
|
---|
463 | if (!(obj instanceof Toolkit))
|
---|
464 | throw new AWTError(toolkit_name + " is not a subclass of " +
|
---|
465 | "java.awt.Toolkit");
|
---|
466 | toolkit = (Toolkit) obj;
|
---|
467 | return toolkit;
|
---|
468 | }
|
---|
469 | catch (Exception e)
|
---|
470 | {
|
---|
471 | throw new AWTError("Cannot load AWT toolkit: " + e.getMessage());
|
---|
472 | }
|
---|
473 | }
|
---|
474 |
|
---|
475 | /**
|
---|
476 | * Returns an image from the specified file, which must be in a
|
---|
477 | * recognized format. Supported formats vary from toolkit to toolkit.
|
---|
478 | *
|
---|
479 | * @return name The name of the file to read the image from.
|
---|
480 | */
|
---|
481 | public abstract Image getImage(String name);
|
---|
482 |
|
---|
483 | /**
|
---|
484 | * Returns an image from the specified URL, which must be in a
|
---|
485 | * recognized format. Supported formats vary from toolkit to toolkit.
|
---|
486 | *
|
---|
487 | * @return url The URl to read the image from.
|
---|
488 | */
|
---|
489 | public abstract Image getImage(URL url);
|
---|
490 |
|
---|
491 | public abstract Image createImage(String filename);
|
---|
492 |
|
---|
493 | public abstract Image createImage(URL url);
|
---|
494 |
|
---|
495 | /**
|
---|
496 | * Readies an image to be rendered on the screen. The width and height
|
---|
497 | * values can be set to the default sizes for the image by passing -1
|
---|
498 | * in those parameters.
|
---|
499 | *
|
---|
500 | * @param image The image to prepare for rendering.
|
---|
501 | * @param width The width of the image.
|
---|
502 | * @param height The height of the image.
|
---|
503 | * @param observer The observer to receive events about the preparation
|
---|
504 | * process.
|
---|
505 | *
|
---|
506 | * @return <code>true</code> if the image is already prepared for rendering,
|
---|
507 | * <code>false</code> otherwise.
|
---|
508 | */
|
---|
509 | public abstract boolean prepareImage(Image image, int width, int height,
|
---|
510 | ImageObserver observer);
|
---|
511 |
|
---|
512 | /**
|
---|
513 | * Checks the status of specified image as it is being readied for
|
---|
514 | * rendering.
|
---|
515 | *
|
---|
516 | * @param image The image to prepare for rendering.
|
---|
517 | * @param width The width of the image.
|
---|
518 | * @param height The height of the image.
|
---|
519 | * @param observer The observer to receive events about the preparation
|
---|
520 | * process.
|
---|
521 | *
|
---|
522 | * @return A union of the bitmasks from
|
---|
523 | * <code>java.awt.image.ImageObserver</code> that indicates the current
|
---|
524 | * state of the imaging readying process.
|
---|
525 | */
|
---|
526 | public abstract int checkImage(Image image, int width, int height,
|
---|
527 | ImageObserver observer);
|
---|
528 |
|
---|
529 | /**
|
---|
530 | * Creates an image using the specified <code>ImageProducer</code>
|
---|
531 | *
|
---|
532 | * @param producer The <code>ImageProducer</code> to create the image from.
|
---|
533 | *
|
---|
534 | * @return The created image.
|
---|
535 | */
|
---|
536 | public abstract Image createImage(ImageProducer producer);
|
---|
537 |
|
---|
538 | /**
|
---|
539 | * Creates an image from the specified byte array. The array must be in
|
---|
540 | * a recognized format. Supported formats vary from toolkit to toolkit.
|
---|
541 | *
|
---|
542 | * @param data The raw image data.
|
---|
543 | *
|
---|
544 | * @return The created image.
|
---|
545 | */
|
---|
546 | public Image createImage(byte[] data)
|
---|
547 | {
|
---|
548 | return createImage(data, 0, data.length);
|
---|
549 | }
|
---|
550 |
|
---|
551 | /**
|
---|
552 | * Creates an image from the specified portion of the byte array passed.
|
---|
553 | * The array must be in a recognized format. Supported formats vary from
|
---|
554 | * toolkit to toolkit.
|
---|
555 | *
|
---|
556 | * @param data The raw image data.
|
---|
557 | * @param offset The offset into the data where the image data starts.
|
---|
558 | * @param len The length of the image data.
|
---|
559 | *
|
---|
560 | * @return The created image.
|
---|
561 | */
|
---|
562 | public abstract Image createImage(byte[] data, int offset, int len);
|
---|
563 |
|
---|
564 | /**
|
---|
565 | * Returns a instance of <code>PrintJob</code> for the specified
|
---|
566 | * arguments.
|
---|
567 | *
|
---|
568 | * @param frame The window initiating the print job.
|
---|
569 | * @param title The print job title.
|
---|
570 | * @param props The print job properties.
|
---|
571 | *
|
---|
572 | * @return The requested print job, or <code>null</code> if the job
|
---|
573 | * was cancelled.
|
---|
574 | */
|
---|
575 | public abstract PrintJob getPrintJob(Frame frame, String title,
|
---|
576 | Properties props);
|
---|
577 |
|
---|
578 |
|
---|
579 | /**
|
---|
580 | * @since 1.3
|
---|
581 | */
|
---|
582 | public PrintJob getPrintJob(Frame frame, String title,
|
---|
583 | JobAttributes jobAttr, PageAttributes pageAttr)
|
---|
584 | {
|
---|
585 | return null;
|
---|
586 | }
|
---|
587 |
|
---|
588 | /**
|
---|
589 | * Causes a "beep" tone to be generated.
|
---|
590 | */
|
---|
591 | public abstract void beep();
|
---|
592 |
|
---|
593 | /**
|
---|
594 | * Returns the system clipboard.
|
---|
595 | *
|
---|
596 | * @return THe system clipboard.
|
---|
597 | *
|
---|
598 | * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
---|
599 | */
|
---|
600 | public abstract Clipboard getSystemClipboard();
|
---|
601 |
|
---|
602 | /**
|
---|
603 | * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
---|
604 | *
|
---|
605 | * @since 1.4
|
---|
606 | */
|
---|
607 | public Clipboard getSystemSelection()
|
---|
608 | {
|
---|
609 | return null;
|
---|
610 | }
|
---|
611 |
|
---|
612 | /**
|
---|
613 | * Returns the accelerator key mask for menu shortcuts. The default is
|
---|
614 | * <code>Event.CTRL_MASK</code>. A toolkit must override this method
|
---|
615 | * to change the default.
|
---|
616 | *
|
---|
617 | * @return The key mask for the menu accelerator key.
|
---|
618 | *
|
---|
619 | * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
---|
620 | */
|
---|
621 | public int getMenuShortcutKeyMask()
|
---|
622 | {
|
---|
623 | return Event.CTRL_MASK;
|
---|
624 | }
|
---|
625 |
|
---|
626 | public boolean getLockingKeyState(int keyCode)
|
---|
627 | {
|
---|
628 | if (keyCode != KeyEvent.VK_CAPS_LOCK
|
---|
629 | && keyCode != KeyEvent.VK_NUM_LOCK
|
---|
630 | && keyCode != KeyEvent.VK_SCROLL_LOCK)
|
---|
631 | throw new IllegalArgumentException();
|
---|
632 | throw new UnsupportedOperationException();
|
---|
633 | }
|
---|
634 |
|
---|
635 | public void setLockingKeyState(int keyCode, boolean on)
|
---|
636 | {
|
---|
637 | if (keyCode != KeyEvent.VK_CAPS_LOCK
|
---|
638 | && keyCode != KeyEvent.VK_NUM_LOCK
|
---|
639 | && keyCode != KeyEvent.VK_SCROLL_LOCK)
|
---|
640 | throw new IllegalArgumentException();
|
---|
641 | throw new UnsupportedOperationException();
|
---|
642 | }
|
---|
643 |
|
---|
644 | /**
|
---|
645 | * Returns the native container object of the specified component. This
|
---|
646 | * method is necessary because the parent component might be a lightweight
|
---|
647 | * component.
|
---|
648 | *
|
---|
649 | * @param component The component to fetch the native container for.
|
---|
650 | * @return The native container object for this component.
|
---|
651 | */
|
---|
652 | protected static Container getNativeContainer(Component component)
|
---|
653 | {
|
---|
654 | component = component.getParent();
|
---|
655 | while (true)
|
---|
656 | {
|
---|
657 | if (component == null)
|
---|
658 | return null;
|
---|
659 | if (! (component instanceof Container))
|
---|
660 | {
|
---|
661 | component = component.getParent();
|
---|
662 | continue;
|
---|
663 | }
|
---|
664 | if (component.getPeer() instanceof LightweightPeer)
|
---|
665 | {
|
---|
666 | component = component.getParent();
|
---|
667 | continue;
|
---|
668 | }
|
---|
669 | return (Container) component;
|
---|
670 | }
|
---|
671 | }
|
---|
672 |
|
---|
673 | public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
|
---|
674 | {
|
---|
675 | // Presumably the only reason this isn't abstract is for backwards
|
---|
676 | // compatibility? FIXME?
|
---|
677 | return null;
|
---|
678 | }
|
---|
679 |
|
---|
680 | public Dimension getBestCursorSize(int preferredWidth, int preferredHeight)
|
---|
681 | {
|
---|
682 | return new Dimension (0,0);
|
---|
683 | }
|
---|
684 |
|
---|
685 | public int getMaximumCursorColors()
|
---|
686 | {
|
---|
687 | return 0;
|
---|
688 | }
|
---|
689 |
|
---|
690 | /**
|
---|
691 | * @since 1.4
|
---|
692 | */
|
---|
693 | public boolean isFrameStateSupported(int state)
|
---|
694 | {
|
---|
695 | return false;
|
---|
696 | }
|
---|
697 |
|
---|
698 | /**
|
---|
699 | * Returns the value of the property with the specified name, or the
|
---|
700 | * default value if the property does not exist.
|
---|
701 | *
|
---|
702 | * @param key The name of the property to retrieve.
|
---|
703 | * @param defThe default value of the property.
|
---|
704 | */
|
---|
705 | public static String getProperty(String key, String def)
|
---|
706 | {
|
---|
707 | return props.getProperty(key, def);
|
---|
708 | }
|
---|
709 |
|
---|
710 | /**
|
---|
711 | * Returns the event queue for the applet. Despite the word "System"
|
---|
712 | * in the name of this method, there is no guarantee that the same queue
|
---|
713 | * is shared system wide.
|
---|
714 | *
|
---|
715 | * @return The event queue for this applet (or application)
|
---|
716 | */
|
---|
717 | public final EventQueue getSystemEventQueue()
|
---|
718 | {
|
---|
719 | return getSystemEventQueueImpl();
|
---|
720 | }
|
---|
721 |
|
---|
722 | /**
|
---|
723 | * // FIXME: What does this do?
|
---|
724 | */
|
---|
725 | protected abstract EventQueue getSystemEventQueueImpl();
|
---|
726 |
|
---|
727 | /**
|
---|
728 | * @since 1.3
|
---|
729 | */
|
---|
730 | public abstract DragSourceContextPeer
|
---|
731 | createDragSourceContextPeer(DragGestureEvent e);
|
---|
732 |
|
---|
733 | /**
|
---|
734 | * @since 1.3
|
---|
735 | */
|
---|
736 | public DragGestureRecognizer
|
---|
737 | createDragGestureRecognizer(Class recognizer, DragSource ds,
|
---|
738 | Component comp, int actions,
|
---|
739 | DragGestureListener l)
|
---|
740 | {
|
---|
741 | return null;
|
---|
742 | }
|
---|
743 |
|
---|
744 | public final Object getDesktopProperty(String propertyName)
|
---|
745 | {
|
---|
746 | return desktopProperties.get(propertyName);
|
---|
747 | }
|
---|
748 |
|
---|
749 | protected final void setDesktopProperty(String name, Object newValue)
|
---|
750 | {
|
---|
751 | Object oldValue = getDesktopProperty(name);
|
---|
752 | desktopProperties.put(name, newValue);
|
---|
753 | desktopPropsSupport.firePropertyChange(name, oldValue, newValue);
|
---|
754 | }
|
---|
755 |
|
---|
756 | protected Object lazilyLoadDesktopProperty(String name)
|
---|
757 | {
|
---|
758 | // FIXME - what is this??
|
---|
759 | return null;
|
---|
760 | }
|
---|
761 |
|
---|
762 | protected void initializeDesktopProperties()
|
---|
763 | {
|
---|
764 | // Overridden by toolkit implementation?
|
---|
765 | }
|
---|
766 |
|
---|
767 | public void addPropertyChangeListener(String name,
|
---|
768 | PropertyChangeListener pcl)
|
---|
769 | {
|
---|
770 | desktopPropsSupport.addPropertyChangeListener(name, pcl);
|
---|
771 | }
|
---|
772 |
|
---|
773 | public void removePropertyChangeListener(String name,
|
---|
774 | PropertyChangeListener pcl)
|
---|
775 | {
|
---|
776 | desktopPropsSupport.removePropertyChangeListener(name, pcl);
|
---|
777 | }
|
---|
778 |
|
---|
779 | /**
|
---|
780 | * @since 1.4
|
---|
781 | */
|
---|
782 | public PropertyChangeListener[] getPropertyChangeListeners()
|
---|
783 | {
|
---|
784 | return desktopPropsSupport.getPropertyChangeListeners();
|
---|
785 | }
|
---|
786 |
|
---|
787 | /**
|
---|
788 | * @since 1.4
|
---|
789 | */
|
---|
790 | public PropertyChangeListener[] getPropertyChangeListeners(String name)
|
---|
791 | {
|
---|
792 | return desktopPropsSupport.getPropertyChangeListeners(name);
|
---|
793 | }
|
---|
794 |
|
---|
795 | public void addAWTEventListener(AWTEventListener listener, long eventMask)
|
---|
796 | {
|
---|
797 | // SecurityManager s = System.getSecurityManager();
|
---|
798 | // if (s != null)
|
---|
799 | // s.checkPermission(AWTPermission("listenToAllAWTEvents"));
|
---|
800 | // FIXME
|
---|
801 | }
|
---|
802 |
|
---|
803 | public void removeAWTEventListener(AWTEventListener listener)
|
---|
804 | {
|
---|
805 | // FIXME
|
---|
806 | }
|
---|
807 |
|
---|
808 | /**
|
---|
809 | * @since 1.4
|
---|
810 | */
|
---|
811 | public AWTEventListener[] getAWTEventListeners()
|
---|
812 | {
|
---|
813 | return null;
|
---|
814 | }
|
---|
815 |
|
---|
816 | /**
|
---|
817 | * @since 1.4
|
---|
818 | */
|
---|
819 | public AWTEventListener[] getAWTEventListeners(long mask)
|
---|
820 | {
|
---|
821 | return null;
|
---|
822 | }
|
---|
823 |
|
---|
824 | /**
|
---|
825 | * @since 1.3
|
---|
826 | */
|
---|
827 | public abstract Map mapInputMethodHighlight(InputMethodHighlight highlight);
|
---|
828 | } // class Toolkit
|
---|