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;
17 import gnu.gcj.awt.GLightweightPeer;
19 /* A very incomplete placeholder. */
21 public abstract class Toolkit
23 static Toolkit defaultToolkit;
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.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)
75 return GLightweightPeer.INSTANCE;
78 /* @deprecated Use GraphicsEnvironment.getAllFonts() */
79 protected abstract java.awt.peer.FontPeer getFontPeer(String name, int style);
82 public abstract DragSourceContextPeer
83 createDragSourceContextPeer(DragGestureEvent dge)
84 throws InvalidDnDOperationException;
87 protected void loadSystemColors(int[] systemColors)
92 public abstract Dimension getScreenSize();
93 public abstract int getScreenResolution();
94 public abstract ColorModel getColorModel();
95 /* @deprecated Use GraphicsEnvironment.getAvailableFontFamilyNames() */
96 public abstract String[] getFontList();
97 public abstract FontMetrics getFontMetrics(Font font);
98 public abstract void sync();
99 public abstract Image getImage(String filename);
100 public abstract Image getImage(URL url);
101 public abstract Image createImage(String filename);
102 public abstract Image createImage(URL url);
103 public abstract boolean prepareImage(Image image, int width, int height,
104 ImageObserver observer);
105 public abstract int checkImage(Image image, int width, int height,
106 ImageObserver observer);
107 public abstract Image createImage(ImageProducer producer);
109 public Image createImage(byte[] imagedata)
111 return createImage (imagedata, 0, imagedata.length);
114 public abstract Image createImage(byte[] imagedata, int imageoffset,
117 public abstract PrintJob getPrintJob(Frame frame, String jobtitle,
119 public PrintJob getPrintJob(Frame frame, String jobtitle,
120 JobAttributes jobAttributes,
121 PageAttributes pageAttributes)
127 public abstract void beep();
128 public abstract Clipboard getSystemClipboard();
130 public int getMenuShortcutKeyMask()
132 return InputEvent.CTRL_MASK;
135 public boolean getLockingKeyState(int keyCode)
137 if (keyCode != KeyEvent.VK_CAPS_LOCK
138 && keyCode != KeyEvent.VK_NUM_LOCK
139 && keyCode != KeyEvent.VK_SCROLL_LOCK)
140 throw new IllegalArgumentException();
142 throw new UnsupportedOperationException();
145 public void setLockingKeyState(int keyCode, boolean on)
147 if (keyCode != KeyEvent.VK_CAPS_LOCK
148 && keyCode != KeyEvent.VK_NUM_LOCK
149 && keyCode != KeyEvent.VK_SCROLL_LOCK)
150 throw new IllegalArgumentException();
152 throw new UnsupportedOperationException();
155 protected static Container getNativeContainer(Component c)
159 if (!c.isLightweight ())
160 return (Container) c;
167 public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
168 throws IndexOutOfBoundsException
170 // Presumably the only reason this isn't abstract is for backwards
171 // compatibility? FIXME?
175 public Dimension getBestCursorSize(int preferredWidth, int preferredHeight)
177 return new Dimension (0,0);
180 public int getMaximumCursorColors()
185 public static String getProperty(String key, String defaultValue)
191 public final EventQueue getSystemEventQueue()
193 return getSystemEventQueueImpl();
196 protected abstract EventQueue getSystemEventQueueImpl();
199 public DragGestureRecognizer
200 createDragGestureRecognizer(Class abstractRecognizerClass, DragSource ds,
201 Component c, int srcActions,
202 DragGestureListener dgl)
209 public final Object getDesktopProperty(String propertyName)
211 return desktopProperties.get(propertyName);
214 protected final void setDesktopProperty(String name, Object newValue)
216 Object oldValue = getDesktopProperty(name);
217 desktopProperties.put(name, newValue);
218 changeSupport.firePropertyChange(name, oldValue, newValue);
221 protected Object lazilyLoadDesktopProperty(String name)
223 // FIXME - what is this??
227 protected void initializeDesktopProperties()
229 // Overridden by toolkit implementation?
232 public void addPropertyChangeListener(String name,
233 PropertyChangeListener pcl)
235 changeSupport.addPropertyChangeListener(name, pcl);
238 public void removePropertyChangeListener(String name,
239 PropertyChangeListener pcl)
241 changeSupport.removePropertyChangeListener(name, pcl);
244 public void addAWTEventListener(AWTEventListener listener, long eventMask)
246 // SecurityManager s = System.getSecurityManager();
248 // s.checkPermission(AWTPermission("listenToAllAWTEvents"));
253 public void removeAWTEventListener(AWTEventListener listener)
259 public abstract Map mapInputMethodHighlight(InputMethodHighlight highlight)