01: // Copyright (c) 2002 Per M.A. Bothner.
02: // This is free software; for terms and warranty disclaimer see ./COPYING.
03:
04: package gnu.jemacs.buffer;
05:
06: import gnu.lists.LList;
07: import gnu.mapping.WrappedException;
08: import java.awt.Color;
09:
10: public abstract class EToolkit {
11: public static final String swingToolkit = "gnu.jemacs.swing.SwingToolkit";
12: public static final String swtToolkit = "gnu.jemacs.swt.SwtToolkit";
13: public static String defaultToolkit = swingToolkit;
14: static EToolkit instance;
15: static Class toolkitClass;
16:
17: public static EToolkit getInstance() {
18: EToolkit inst = instance;
19: if (inst != null)
20: return inst;
21: String name = System.getProperty("gnu.jemacs.toolkit");
22: if (name == null)
23: name = defaultToolkit;
24: else if (name.equals("swing"))
25: name = swingToolkit;
26: else if (name.equals("swt"))
27: name = swtToolkit;
28: return getInstance(name);
29: }
30:
31: public static synchronized EToolkit getInstance(
32: String toolkitClassname) {
33: if (instance == null) {
34: try {
35: if (toolkitClass == null)
36: toolkitClass = Class.forName(toolkitClassname);
37: instance = (EToolkit) toolkitClass.newInstance();
38: } catch (Exception ex) {
39: throw new WrappedException(ex);
40: }
41: }
42: return instance;
43: }
44:
45: public abstract Buffer newBuffer(String name);
46:
47: public abstract EFrame newFrame(Buffer buffer);
48:
49: public abstract EMenu getMenu(LList menubar);
50:
51: /** Get a face with the given name. */
52: public abstract Object getFace(String name, boolean create);
53:
54: public void setUnderline(Object face, boolean underline) {
55: // Default is to ignore.
56: }
57:
58: public void setBold(Object face, boolean bold) {
59: // Default is to ignore.
60: }
61:
62: public void setForeground(Object face, Color foreground) {
63: // Default is to ignore.
64: }
65:
66: public void setBackground(Object face, Color background) {
67: // Default is to ignore.
68: }
69:
70: public abstract Object getIgnoreAction();
71: }
|