/** Singleton class that provides all functionality in the xwt.* namespace */
public final class XWT extends JS.Obj {
+ public Res resourceRoot = null;
+
public static final XWT singleton = new XWT();
private final JS xwtMath = new XWTMath();
private final JS xwtString = new XWTString();
return Res.stringToRes(args.elementAt(0).toString());
}});
- super.put("theme", new JS.Callable() { public Object call(JS.Array args) throws JS.Exn {
- if (args.length() != 2) return null;
- if (args.elementAt(0) == null || args.elementAt(1) == null) return null;
- for(int i=1; i<args.length(); i++) {
- if (args.elementAt(i) instanceof String) {
- String from = (String)args.elementAt(0);
- String to = (String)args.elementAt(i);
- if (Log.on) Log.log(this, "retheming from " + from + " to " + to);
- Resources.mapFrom.addElement(from);
- Resources.mapTo.addElement(to);
- }
- }
- JS.Callable callback = args.elementAt(args.length() - 1) instanceof JS.Callable ?
- (JS.Callable)args.elementAt(args.length() - 1) : null;
- Template.retheme(callback);
- return null;
- }});
-
super.put("println", new JS.Callable() { public Object call(JS.Array args) throws JS.Exn {
if (args.length() != 1) return null;
if (Log.on) Log.logJS(this, (args.elementAt(0) == null ? "**null**" : args.elementAt(0).toString()));
Box ret = new Box();
if (!(args.length() == 0 || args.elementAt(0) == null))
Template.getTemplate(args.elementAt(0).toString(),
- Template.defaultImportList).apply(ret, null, null, callback, 0, 1);
+ Template.defaultImportList).apply(ret, null, null, callback, 0, 1, resourceRoot);
for(int i=1; i<args.length(); i++)
if (args.elementAt(i) instanceof Box)
ret.put(ret.numChildren(), (Box)args.elementAt(i));