示例#1
0
  public void uimsg(String msg, Object... args) {
    if (msg == "tabfocus") {
      setfocustab(((Integer) args[0] != 0));
    } else if (msg == "act") {
      canactivate = (Integer) args[0] != 0;
    } else if (msg == "cancel") {
      cancancel = (Integer) args[0] != 0;
    } else if (msg == "autofocus") {
      autofocus = (Integer) args[0] != 0;
    } else if (msg == "focus") {
      Widget w = ui.widgets.get((Integer) args[0]);
      if (w != null) {
        if (w.canfocus) setfocus(w);
      }
    } else if (msg == "curs") {
      if (args.length == 0) cursor = null;
      else cursor = Resource.remote().load((String) args[0], (Integer) args[1]);
    } else if (msg == "tip") {
      int a = 0;
      Object tt = args[a++];
      if (tt instanceof String) {
        tooltip = Text.render((String) tt);
      } else if (tt instanceof Integer) {
        final Indir<Resource> tres = ui.sess.getres((Integer) tt);
        tooltip =
            new Indir<Tex>() {
              Text t = null;

              public Tex get() {
                if (t == null) {
                  Resource.Pagina pag;
                  try {
                    pag = tres.get().layer(Resource.pagina);
                  } catch (Loading e) {
                    return (null);
                  }
                  t = RichText.render(pag.text, 300);
                }
                return (t.tex());
              }
            };
      }
    } else {
      System.err.println("Unhandled widget message: " + msg);
    }
  }
示例#2
0
 public static Factory gettype2(String name) throws InterruptedException {
   if (name.indexOf('/') < 0) {
     synchronized (types) {
       return (types.get(name));
     }
   } else {
     int ver = -1, p;
     if ((p = name.indexOf(':')) > 0) {
       ver = Integer.parseInt(name.substring(p + 1));
       name = name.substring(0, p);
     }
     Indir<Resource> res = Resource.remote().load(name, ver);
     while (true) {
       try {
         return (res.get().getcode(Factory.class, true));
       } catch (Loading l) {
         l.waitfor();
       }
     }
   }
 }