Пример #1
0
  public void cset(Interp ip, Object target, String optname, Thing optval) throws HeclException {
    HeclCanvas c = (HeclCanvas) target;

    if (optname.equals("-fullscreen")) {
      c.setFullScreenMode(HeclUtils.thing2bool(optval));
      return;
    }
    if (optname.equals("-autoflush")) {
      c.setAutoFlushMode(HeclUtils.thing2bool(optval));
      return;
    }
    if (optname.equals("-cmdbg")) {
      c.setCmdBgColor(new Color(WidgetInfo.toColor(optval)));
      return;
    }
    if (optname.equals("-cmdfg")) {
      c.setCmdFgColor(new Color(WidgetInfo.toColor(optval)));
      return;
    }
    if (optname.equals("-eventhandler")) {
      EventHandler h = null;
      if (optval.toString().length() > 0) h = new WidgetListener(ip, optval, c);
      c.setEventHandler(h);
      return;
    }
    super.cset(ip, target, optname, optval);
  }
Пример #2
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);
  }
Пример #3
0
  public Thing cget(Interp ip, Object target, String optname) throws HeclException {
    HeclCanvas c = (HeclCanvas) target;

    if (optname.equals(WidgetInfo.NWIDTH)) return IntThing.create(c.getWidth());
    if (optname.equals("-drawwidth")) return IntThing.create(c.getDrawWidth());
    if (optname.equals(WidgetInfo.NHEIGHT)) return IntThing.create(c.getHeight());
    if (optname.equals("-drawheight")) return IntThing.create(c.getDrawHeight());
    if (optname.equals("-fullwidth")) return IntThing.create(c.getFullWidth());
    if (optname.equals("-fullheight")) return IntThing.create(c.getFullHeight());
    if (optname.equals("-fullscreen")) return IntThing.create(c.getFullScreenMode());
    if (optname.equals("-doublebuffered")) return IntThing.create(c.isDoubleBuffered());
    if (optname.equals("-pointerevents")) return IntThing.create(c.hasPointerEvents());
    if (optname.equals("-pointermotionevents")) return IntThing.create(c.hasPointerMotionEvents());
    if (optname.equals("-repeatevents")) return IntThing.create(c.hasRepeatEvents());
    if (optname.equals("-autoflush")) return IntThing.create(c.getAutoFlushMode());
    if (optname.equals("-cmdbg")) return WidgetInfo.fromColor(c.getCmdBgColor());
    if (optname.equals("-cmdfg")) return WidgetInfo.fromColor(c.getCmdFgColor());
    // #ifdef notdef
    GraphicsCmd gcmd = c.getGraphicsCmd();
    if (gcmd != null) {
      return gcmd.cget(ip, target, optname);
    }
    // #endif
    return super.cget(ip, target, optname);
  }