Exemplo n.º 1
0
  public Thing handlecmd(Interp ip, Object target, String subcmd, Thing[] argv, int startat)
      throws HeclException {
    HeclCanvas c = (HeclCanvas) target;

    if (subcmd.equals(WidgetInfo.NREPAINT)) {
      c.repaint();
      return null;
    }
    if (subcmd.equals("servicerepaints")) {
      c.serviceRepaints();
      return null;
    }
    if (subcmd.equals("flush")) {
      if (argv.length == startat) {
        // Simple case, flush whole buffer
        c.flushGraphics();
        return null;
      }

      // x, y, w, h
      if (startat + 4 != argv.length)
        throw HeclException.createWrongNumArgsException(argv, startat, "x y w h");

      c.flushGraphics(
          IntThing.get(argv[startat]),
          IntThing.get(argv[startat + 1]),
          IntThing.get(argv[startat + 2]),
          IntThing.get(argv[startat + 3]));
      return null;
    }
    if (subcmd.equals("graphics")) return ObjectThing.create(c.getDrawable());
    return super.handlecmd(ip, target, subcmd, argv, startat);
  }
Exemplo n.º 2
0
 public Thing cmdCode(Interp interp, Thing[] argv) throws HeclException {
   Properties p = WidgetInfo.defaultProps(Canvas.class);
   p.setProps(argv, 1);
   HeclCanvas w = new HeclCanvas(HeclUtils.thing2bool(p.getProp(WidgetInfo.NSUPPRESSKEYS)));
   p.delProp(WidgetInfo.NTITLE);
   p.delProp(WidgetInfo.NSUPPRESSKEYS);
   return ObjectThing.create(setInstanceProperties(interp, w, p));
 }
Exemplo n.º 3
0
 public Thing method(Interp ip, ClassCommandInfo conetxt, Thing[] argv) throws HeclException {
   if (argv.length > 1) {
     String subcmd = argv[1].toString().toLowerCase();
     Object target = ObjectThing.get(argv[0]);
     return handlecmd(ip, target, subcmd, argv, 2);
   } else {
     throw HeclException.createWrongNumArgsException(argv, 2, "Object method [arg...]");
   }
 }
Exemplo n.º 4
0
 public Thing cmdCode(Interp interp, Thing[] argv) throws HeclException {
   if (argv.length == 2) {
     Vector v = ListThing.get(argv[1]);
     int[] colors = new int[v.size()];
     for (int i = 0; i < v.size(); i++) {
       colors[i] = Integer.parseInt(((Thing) v.elementAt(i)).toString(), 16);
     }
     Skin skin = new Skin(colors);
     return ObjectThing.create(skin);
   } else if (argv.length == 3) {
     Vector v = ListThing.get(argv[1]);
     int newSize = IntThing.get(argv[2]);
     Image[] img = new Image[9];
     for (int i = 0; i < v.size(); i++) {
       img[i] = (Image) ObjectThing.get((Thing) v.elementAt(i));
     }
     return ObjectThing.create(new Skin(img, newSize));
   } else {
     throw HeclException.createWrongNumArgsException(
         argv, 2, "mwt.skin expect either <color[]> or <image[], size>");
   }
 }