1 /* Copyright (C) 1999, 2000 Free Software Foundation
3 This file is part of libjava.
5 This software is copyrighted work licensed under the terms of the
6 Libjava License. Please consult the file "LIBJAVA_LICENSE" for
10 import java.awt.peer.*;
11 import java.awt.event.*;
14 import java.awt.image.*;
15 import java.awt.datatransfer.Clipboard;
16 import java.util.Hashtable;
18 /* A very incomplete placeholder. */
20 public abstract class Toolkit
22 static Toolkit defaultToolkit;
23 static EventQueue systemEventQueue = new EventQueue();
24 PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
25 Hashtable desktopProperties = new Hashtable();
27 public static Toolkit getDefaultToolkit()
29 if (defaultToolkit != null)
30 return defaultToolkit;
33 String tk_class_name = System.getProperty("awt.toolkit");
34 if (tk_class_name == null)
35 tk_class_name = "gnu.awt.peer.gtk.GTKToolkit";
39 toolkit_class = Class.forName(tk_class_name);
40 defaultToolkit = (Toolkit) toolkit_class.newInstance();
44 throw new AWTError("Toolkit class " + tk_class_name +
45 " could not be initialized:\n " + x);
48 return defaultToolkit;
51 protected abstract ButtonPeer createButton(Button target);
52 protected abstract TextFieldPeer createTextField(TextField target);
53 protected abstract LabelPeer createLabel(Label target);
54 protected abstract ListPeer createList(List target);
55 protected abstract CheckboxPeer createCheckbox(Checkbox target);
56 protected abstract ScrollbarPeer createScrollbar(Scrollbar target);
57 protected abstract ScrollPanePeer createScrollPane(ScrollPane target);
58 protected abstract TextAreaPeer createTextArea(TextArea target);
59 protected abstract ChoicePeer createChoice(Choice target);
60 protected abstract FramePeer createFrame(Frame target);
61 protected abstract CanvasPeer createCanvas(Canvas target);
62 protected abstract PanelPeer createPanel(Panel target);
63 protected abstract WindowPeer createWindow(Window target);
64 protected abstract DialogPeer createDialog(Dialog target);
65 protected abstract MenuBarPeer createMenuBar(MenuBar target);
66 protected abstract MenuPeer createMenu(Menu target);
67 protected abstract PopupMenuPeer createPopupMenu(PopupMenu target);
68 protected abstract MenuItemPeer createMenuItem(MenuItem target);
69 protected abstract FileDialogPeer createFileDialog(FileDialog target);
70 protected abstract CheckboxMenuItemPeer
71 createCheckboxMenuItem(CheckboxMenuItem target);
73 protected LightweightPeer createComponent(Component target)
79 /* @deprecated Use GraphicsEnvironment.getAllFonts() */
80 protected abstract java.awt.peer.FontPeer getFontPeer(String name, int style);
83 public abstract DragSourceContextPeer
84 createDragSourceContextPeer(DragGestureEvent dge)
85 throws InvalidDnDOperationException;
88 protected void loadSystemColors(int[] systemColors)
93 public abstract Dimension getScreenSize();
94 public abstract int getScreenResolution();
95 public abstract ColorModel getColorModel();
96 /* @deprecated Use GraphicsEnvironment.getAvailableFontFamilyNames() */
97 public abstract String[] getFontList();
98 public abstract FontMetrics getFontMetrics(Font font);
99 public abstract void sync();
100 public abstract Image getImage(String filename);
101 public abstract Image getImage(URL url);
102 public abstract Image createImage(String filename);
103 public abstract Image createImage(URL url);
104 public abstract boolean prepareImage(Image image, int width, int height,
105 ImageObserver observer);
106 public abstract int checkImage(Image image, int width, int height,
107 ImageObserver observer);
108 public abstract Image createImage(ImageProducer producer);
110 public Image createImage(byte[] imagedata)
112 return createImage (imagedata, 0, imagedata.length);
115 public abstract Image createImage(byte[] imagedata, int imageoffset,
118 public abstract PrintJob getPrintJob(Frame frame, String jobtitle,
120 public PrintJob getPrintJob(Frame frame, String jobtitle,
121 JobAttributes jobAttributes,
122 PageAttributes pageAttributes)
128 public abstract void beep();
129 public abstract Clipboard getSystemClipboard();
131 public int getMenuShortcutKeyMask()
133 return InputEvent.CTRL_MASK;
136 public boolean getLockingKeyState(int keyCode)
138 if (keyCode != KeyEvent.VK_CAPS_LOCK
139 && keyCode != KeyEvent.VK_NUM_LOCK
140 && keyCode != KeyEvent.VK_SCROLL_LOCK)
141 throw new IllegalArgumentException();
143 throw new UnsupportedOperationException();
146 public void setLockingKeyState(int keyCode, boolean on)
148 if (keyCode != KeyEvent.VK_CAPS_LOCK
149 && keyCode != KeyEvent.VK_NUM_LOCK
150 && keyCode != KeyEvent.VK_SCROLL_LOCK)
151 throw new IllegalArgumentException();
153 throw new UnsupportedOperationException();
156 protected static Container getNativeContainer(Component c)
160 if (!c.isLightweight ())
161 return (Container) c;
168 public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
169 throws IndexOutOfBoundsException
171 // Presumably the only reason this isn't abstract is for backwards
172 // compatibility? FIXME?
176 public Dimension getBestCursorSize(int preferredWidth, int preferredHeight)
178 return new Dimension (0,0);
181 public int getMaximumCursorColors()
186 public static String getProperty(String key, String defaultValue)
192 public final EventQueue getSystemEventQueue()
194 return systemEventQueue;
197 protected abstract EventQueue getSystemEventQueueImpl();
200 public DragGestureRecognizer
201 createDragGestureRecognizer(Class abstractRecognizerClass, DragSource ds,
202 Component c, int srcActions,
203 DragGestureListener dgl)
210 public final Object getDesktopProperty(String propertyName)
212 return desktopProperties.get(propertyName);
215 protected final void setDesktopProperty(String name, Object newValue)
217 Object oldValue = getDesktopProperty(name);
218 desktopProperties.put(name, newValue);
219 changeSupport.firePropertyChange(name, oldValue, newValue);
222 protected Object lazilyLoadDesktopProperty(String name)
224 // FIXME - what is this??
228 protected void initializeDesktopProperties()
230 // Overridden by toolkit implementation?
233 public void addPropertyChangeListener(String name,
234 PropertyChangeListener pcl)
236 changeSupport.addPropertyChangeListener(name, pcl);
239 public void removePropertyChangeListener(String name,
240 PropertyChangeListener pcl)
242 changeSupport.removePropertyChangeListener(name, pcl);
245 public void addAWTEventListener(AWTEventListener listener, long eventMask)
247 // SecurityManager s = System.getSecurityManager();
249 // s.checkPermission(AWTPermission("listenToAllAWTEvents"));
254 public void removeAWTEventListener(AWTEventListener listener)
260 public abstract Map mapInputMethodHighlight(InputMethodHighlight highlight)