private void mklogin() {
   synchronized (ui) {
     btn =
         new IButton(
             CustomConfig.windowCenter.add(-27, 160),
             this,
             Resource.loadimg("gfx/hud/buttons/loginu"),
             Resource.loadimg("gfx/hud/buttons/logind"));
     progress(null);
   }
 }
Example #2
0
public class MinimapPanel extends Window {

  static final BufferedImage grip = Resource.loadimg("gfx/hud/gripbr");
  static final Coord gzsz = new Coord(16, 17);
  static final Coord minsz = new Coord(150, 125);
  public IButton vcl;
  public IButton pcl;

  boolean rsm = false;
  MiniMap mm;
  IButton btncave;

  public MinimapPanel(Coord c, Coord sz, Widget parent) {
    super(c, sz, parent, "Minimap");
    mrgn = Coord.z;
    fbtn.visible = true;
    cbtn.visible = false;
    {
      vcl =
          new IButton(
              new Coord(0, -2),
              this,
              Resource.loadimg("gfx/hud/slen/dispauth"),
              Resource.loadimg("gfx/hud/slen/dispauthd")) {
            private boolean v = false;

            public void click() {
              MapView mv = ui.mapview;
              BufferedImage tmp = down;
              down = up;
              up = tmp;
              hover = tmp;
              if (v) {
                mv.disol(2, 3);
                v = false;
              } else {
                mv.enol(2, 3);
                v = true;
              }
            }
          };
      vcl.tooltip = "Show village authority";
    }
    {
      pcl =
          new IButton(
              new Coord(0, 4),
              this,
              Resource.loadimg("gfx/hud/slen/dispclaim"),
              Resource.loadimg("gfx/hud/slen/dispclaimd")) {
            private boolean v = false;

            public void click() {
              MapView mv = ui.mapview;
              BufferedImage tmp = down;
              down = up;
              up = tmp;
              hover = tmp;
              if (v) {
                mv.disol(0, 1);
                v = false;
              } else {
                mv.enol(0, 1);
                v = true;
              }
            }
          };
      pcl.tooltip = "Show claims";
    }

    ui.minimappanel = this;
    mm = new MiniMap(new Coord(0, 32), minsz, this, ui.mapview);

    /*(new CheckBox(new Coord(110, 15), this, "Use simple map") {
          public void changed(boolean val) {
        Config.useSimpleMap = val;
        this.setfocus(this);
        Config.saveOptions();
    }
       }).a = Config.useSimpleMap;*/

    new IButton(
            new Coord(45, 8),
            this,
            Resource.loadimg("gfx/hud/buttons/gridu"),
            Resource.loadimg("gfx/hud/buttons/gridd")) {
          public void click() {
            BufferedImage tmp = down;
            down = up;
            up = tmp;
            hover = tmp;
            mm.grid = !mm.grid;
          }
        }.tooltip =
        "Show minimap grid";

    new IButton(
            new Coord(65, 8),
            this,
            Resource.loadimg("gfx/hud/buttons/centeru"),
            Resource.loadimg("gfx/hud/buttons/centerd")) {
          public void click() {
            mm.off = new Coord();
            UI.instance.mapview.resetcam(); // Kerrigan
          }
        }.tooltip =
        "Focus minimap and character";

    new IButton(
        new Coord(88, 12),
        this,
        Resource.loadimg("gfx/hud/charsh/plusup"),
        Resource.loadimg("gfx/hud/charsh/plusdown")) {
      public void click() {
        mm.setScale(mm.scale + 1);
      }
    };

    new IButton(
        new Coord(103, 12),
        this,
        Resource.loadimg("gfx/hud/charsh/minusup"),
        Resource.loadimg("gfx/hud/charsh/minusdown")) {
      public void click() {
        mm.setScale(mm.scale - 1);
      }
    };

    btncave =
        new IButton(
            new Coord(121, 8),
            this,
            Resource.loadimg("gfx/hud/buttons/saveu"),
            Resource.loadimg("gfx/hud/buttons/saved")) {
          public void click() {
            mm.saveCaveMaps();
          }
        };

    btncave.tooltip = "Save cave minimaps";

    KerriUtils.makeButtonSC();
    KerriUtils.makeButtonOP();
    KerriUtils.makeButtonVR();
    KerriUtils.makeButtonOH();

    pack();
    this.c = new Coord(MainFrame.getInnerSize().x - this.sz.x, 7);
    loadpos();
  }

  private void loadpos() {
    synchronized (Config.window_props) {
      c = new Coord(Config.window_props.getProperty("minimap_pos", c.toString()));
      mm.sz = new Coord(Config.window_props.getProperty("minimap_sz", mm.sz.toString()));
      pack();
    }
  }

  protected void placecbtn() {
    fbtn.c =
        new Coord(wsz.x - 3 - Utils.imgsz(cbtni[0]).x, 3).add(mrgn.inv().add(wbox.tloff().inv()));
    // fbtn.c = new Coord(cbtn.c.x - 1 - Utils.imgsz(fbtni[0]).x, cbtn.c.y);
  }

  public void draw(GOut g) {
    super.draw(g);
    btncave.visible = !folded && mm.isCave();
    if (!folded) g.image(grip, sz.sub(gzsz));
  }

  public boolean mousedown(Coord c, int button) {
    if (folded) {
      return super.mousedown(c, button);
    }
    parent.setfocus(this);
    raise();
    if (button == 1) {
      ui.grabmouse(this);
      doff = c;
      if (c.isect(sz.sub(gzsz), gzsz)) {
        rsm = true;
        return true;
      }
    }
    return super.mousedown(c, button);
  }

  public boolean mouseup(Coord c, int button) {
    if (dm) {
      Config.setWindowOpt("minimap_pos", this.c.toString());
    }
    if (rsm) {
      ui.grabmouse(null);
      rsm = false;
      Config.setWindowOpt("minimap_sz", mm.sz.toString());
    } else {
      super.mouseup(c, button);
    }
    return (true);
  }

  public void mousemove(Coord c) {
    if (rsm) {
      Coord d = c.sub(doff);
      mm.sz = mm.sz.add(d);
      mm.sz.x = Math.max(minsz.x, mm.sz.x);
      mm.sz.y = Math.max(minsz.y, mm.sz.y);
      doff = c;
      pack();
    } else {
      super.mousemove(c);
    }
  }

  public boolean type(char key, java.awt.event.KeyEvent ev) {
    if (key == 27) {
      wdgmsg(fbtn, "click");
      return (true);
    }
    return (super.type(key, ev));
  }
}
Example #3
0
  public MinimapPanel(Coord c, Coord sz, Widget parent) {
    super(c, sz, parent, "Minimap");
    mrgn = Coord.z;
    fbtn.visible = true;
    cbtn.visible = false;
    {
      vcl =
          new IButton(
              new Coord(0, -2),
              this,
              Resource.loadimg("gfx/hud/slen/dispauth"),
              Resource.loadimg("gfx/hud/slen/dispauthd")) {
            private boolean v = false;

            public void click() {
              MapView mv = ui.mapview;
              BufferedImage tmp = down;
              down = up;
              up = tmp;
              hover = tmp;
              if (v) {
                mv.disol(2, 3);
                v = false;
              } else {
                mv.enol(2, 3);
                v = true;
              }
            }
          };
      vcl.tooltip = "Show village authority";
    }
    {
      pcl =
          new IButton(
              new Coord(0, 4),
              this,
              Resource.loadimg("gfx/hud/slen/dispclaim"),
              Resource.loadimg("gfx/hud/slen/dispclaimd")) {
            private boolean v = false;

            public void click() {
              MapView mv = ui.mapview;
              BufferedImage tmp = down;
              down = up;
              up = tmp;
              hover = tmp;
              if (v) {
                mv.disol(0, 1);
                v = false;
              } else {
                mv.enol(0, 1);
                v = true;
              }
            }
          };
      pcl.tooltip = "Show claims";
    }

    ui.minimappanel = this;
    mm = new MiniMap(new Coord(0, 32), minsz, this, ui.mapview);

    /*(new CheckBox(new Coord(110, 15), this, "Use simple map") {
          public void changed(boolean val) {
        Config.useSimpleMap = val;
        this.setfocus(this);
        Config.saveOptions();
    }
       }).a = Config.useSimpleMap;*/

    new IButton(
            new Coord(45, 8),
            this,
            Resource.loadimg("gfx/hud/buttons/gridu"),
            Resource.loadimg("gfx/hud/buttons/gridd")) {
          public void click() {
            BufferedImage tmp = down;
            down = up;
            up = tmp;
            hover = tmp;
            mm.grid = !mm.grid;
          }
        }.tooltip =
        "Show minimap grid";

    new IButton(
            new Coord(65, 8),
            this,
            Resource.loadimg("gfx/hud/buttons/centeru"),
            Resource.loadimg("gfx/hud/buttons/centerd")) {
          public void click() {
            mm.off = new Coord();
            UI.instance.mapview.resetcam(); // Kerrigan
          }
        }.tooltip =
        "Focus minimap and character";

    new IButton(
        new Coord(88, 12),
        this,
        Resource.loadimg("gfx/hud/charsh/plusup"),
        Resource.loadimg("gfx/hud/charsh/plusdown")) {
      public void click() {
        mm.setScale(mm.scale + 1);
      }
    };

    new IButton(
        new Coord(103, 12),
        this,
        Resource.loadimg("gfx/hud/charsh/minusup"),
        Resource.loadimg("gfx/hud/charsh/minusdown")) {
      public void click() {
        mm.setScale(mm.scale - 1);
      }
    };

    btncave =
        new IButton(
            new Coord(121, 8),
            this,
            Resource.loadimg("gfx/hud/buttons/saveu"),
            Resource.loadimg("gfx/hud/buttons/saved")) {
          public void click() {
            mm.saveCaveMaps();
          }
        };

    btncave.tooltip = "Save cave minimaps";

    KerriUtils.makeButtonSC();
    KerriUtils.makeButtonOP();
    KerriUtils.makeButtonVR();
    KerriUtils.makeButtonOH();

    pack();
    this.c = new Coord(MainFrame.getInnerSize().x - this.sz.x, 7);
    loadpos();
  }
Example #4
0
public class Gobble extends SIWidget {
  public static final BufferedImage bg = Resource.loadimg("gfx/hud/tempers/gbg");
  static Text.Foundry tnf =
      new Text.Foundry(new java.awt.Font("serif", java.awt.Font.BOLD, 16)).aa(true);
  public int[] lev = new int[4];
  public List<TypeMod> mods = new ArrayList<TypeMod>();
  static final Color loc = new Color(0, 128, 255);
  static final Color hic = new Color(0, 128, 64);
  static final BufferedImage[] lobars, hibars;
  private boolean updt = true;
  private TypeList typelist;
  private int[] lmax = new int[4];
  private int max;
  private Tex lvlmask;
  private long lvltime;
  private Tex levels;

  static {
    int n = bars.length;
    BufferedImage[] l = new BufferedImage[n];
    BufferedImage[] h = new BufferedImage[n];
    for (int i = 0; i < n; i++) {
      l[i] = monochromize(bars[i], loc);
      h[i] = monochromize(bars[i], hic);
    }
    lobars = l;
    hibars = h;
  }

  public static class TypeMod {
    public final Indir<Resource> t;
    public double a;
    private Tex rn, rh, ra;

    public TypeMod(Indir<Resource> t, double a) {
      this.t = t;
      this.a = a;
    }
  }

  private class TypeList extends Widget {
    private int nw;

    private TypeList(Coord c, Widget parent) {
      super(c, Coord.z, parent);
    }

    public void tick(double dt) {
      if (updt) {
        nw = 0;
        int aw = 0;
        for (TypeMod m : mods) {
          if (m.rn == null) {
            try {
              BufferedImage img = m.t.get().layer(Resource.imgc).img;
              String nm = m.t.get().layer(Resource.tooltip).t;
              Text rt = tnf.render(nm);
              int h = Inventory.sqsz.y;
              BufferedImage buf = TexI.mkbuf(new Coord(img.getWidth() + 10 + rt.sz().x, h));
              Graphics g = buf.getGraphics();
              g.drawImage(img, 0, (h - img.getHeight()) / 2, null);
              g.drawImage(rt.img, img.getWidth() + 10, (h - rt.sz().y) / 2, null);
              g.dispose();
              m.rn = new TexI(rasterimg(blurmask2(buf.getRaster(), 2, 1, new Color(32, 0, 0))));
              m.rh = new TexI(rasterimg(blurmask2(buf.getRaster(), 2, 1, new Color(192, 128, 0))));
            } catch (Loading l) {
            }
          }
          if (m.ra == null) {
            Text rt =
                tnf.render(
                    (int) Math.round(m.a * 100) + "%",
                    new Color(255, (int) (255 * m.a), (int) (255 * m.a)));
            m.ra = new TexI(rasterimg(blurmask2(rt.img.getRaster(), 2, 1, new Color(0, 0, 0))));
          }
          nw = Math.max(nw, m.rn.sz().x);
          aw = Math.max(aw, m.ra.sz().x);
        }
        int h = (Inventory.sqsz.y + 5) * mods.size();
        h += levels.sz().y + 20;
        resize(new Coord(Math.max(nw + 20 + aw, boxsz.x), h));
        this.c = Gobble.this.parentpos(parent).add(boxc).add(0, boxsz.y + 5);
        updt = false;
      }
    }

    public void draw(GOut g) {
      int tn = 0;
      int y = 0;
      int h = Inventory.sqsz.y;
      boolean[] hl = new boolean[mods.size()];
      if (lfood != null) {
        for (int t : lfood.types) hl[t] = true;
      }
      g.aimage(levels, new Coord(sz.x / 2, y), 0.5, 0);
      y += levels.sz().y + 20;
      for (TypeMod m : mods) {
        if (m.rn != null) g.image(hl[tn] ? m.rh : m.rn, new Coord(0, y));
        if (m.ra != null) g.image(m.ra, new Coord(nw + 20, y + ((h - m.ra.sz().y) / 2)));
        tn++;
        y += h + 5;
      }
    }
  }

  public Gobble(Coord c, Widget parent) {
    super(c, Utils.imgsz(Tempers.bg), parent);
    lcount(0, Color.WHITE);
    typelist = new TypeList(Coord.z, getparent(GameUI.class));
  }

  public void destroy() {
    typelist.destroy();
    super.destroy();
  }

  private GobbleInfo lfood;

  public void tick(double dt) {
    int max = 0;
    int[] lmax = new int[4];
    for (int i = 0; i < 4; i++) {
      lmax[i] = ui.sess.glob.cattr.get(Tempers.anm[i]).base;
      if (lmax[i] == 0) return;
      if (lmax[i] != this.lmax[i]) redraw();
      max = Math.max(max, lmax[i]);
    }
    this.lmax = lmax;
    this.max = max;

    GobbleInfo food = null;
    Alchemy ch = null;
    if (ui.lasttip instanceof WItem.ItemTip) {
      try {
        food = ItemInfo.find(GobbleInfo.class, ((WItem.ItemTip) ui.lasttip).item().info());
        ch = ItemInfo.find(Alchemy.class, ((WItem.ItemTip) ui.lasttip).item().info());
      } catch (Loading e) {
      }
    }
    if (lfood != food) {
      lfood = food;
      redraw();
    }
  }

  private double foodeff(GobbleInfo food) {
    double ret = 1.0;
    for (int t : lfood.types) ret *= mods.get(t).a;
    return (ret);
  }

  private WritableRaster rgmeter(GobbleInfo food, double e, int t) {
    return (alphablit(
        rmeter(hibars[t].getRaster(), lev[t] + (int) (e * food.h[t]), max),
        rmeter(lobars[t].getRaster(), lev[t] + (int) (e * food.l[t]), max),
        Coord.z));
  }

  private WritableRaster lgmeter(GobbleInfo food, double e, int t) {
    return (alphablit(
        lmeter(hibars[t].getRaster(), lev[t] + (int) (e * food.h[t]), max),
        lmeter(lobars[t].getRaster(), lev[t] + (int) (e * food.l[t]), max),
        Coord.z));
  }

  public void draw(BufferedImage buf) {
    WritableRaster dst = buf.getRaster();
    blit(dst, bg.getRaster(), Coord.z);

    alphablit(dst, rmeter(sbars[0].getRaster(), lmax[0], max), mc[0]);
    alphablit(
        dst, lmeter(sbars[1].getRaster(), lmax[1], max), mc[1].sub(bars[1].getWidth() - 1, 0));
    alphablit(
        dst, lmeter(sbars[2].getRaster(), lmax[2], max), mc[2].sub(bars[2].getWidth() - 1, 0));
    alphablit(dst, rmeter(sbars[3].getRaster(), lmax[3], max), mc[3]);

    if (lfood != null) {
      double e = foodeff(lfood);
      alphablit(dst, rgmeter(lfood, e, 0), mc[0]);
      alphablit(dst, lgmeter(lfood, e, 1), mc[1].sub(bars[1].getWidth() - 1, 0));
      alphablit(dst, lgmeter(lfood, e, 2), mc[2].sub(bars[1].getWidth() - 1, 0));
      alphablit(dst, rgmeter(lfood, e, 3), mc[3]);
    }

    alphablit(dst, rmeter(bars[0].getRaster(), lev[0], max), mc[0]);
    alphablit(dst, lmeter(bars[1].getRaster(), lev[1], max), mc[1].sub(bars[1].getWidth() - 1, 0));
    alphablit(dst, lmeter(bars[2].getRaster(), lev[2], max), mc[2].sub(bars[2].getWidth() - 1, 0));
    alphablit(dst, rmeter(bars[3].getRaster(), lev[3], max), mc[3]);

    StringBuilder tbuf = new StringBuilder();
    for (int i = 0; i < 4; i++)
      tbuf.append(
          String.format(
              "%s: %s/%s\n", rnm[i], Utils.fpformat(lev[i], 3, 1), Utils.fpformat(lmax[i], 3, 1)));
    tooltip = RichText.render(tbuf.toString(), 0).tex();
  }

  public void draw(GOut g) {
    super.draw(g);
    if (lvlmask != null) {
      long now = System.currentTimeMillis();
      if (now - lvltime > 1000) {
        lvlmask.dispose();
        lvlmask = null;
      } else {
        g.chcolor(255, 255, 255, 255 - (int) ((255 * (now - lvltime)) / 1000));
        g.image(lvlmask, Coord.z);
      }
    }
  }

  public void updt(int[] n) {
    this.lev = n;
    redraw();
  }

  public void lvlup(int a) {
    WritableRaster buf = imgraster(imgsz(bg));
    if ((a == 0) || (a == 3)) alphablit(buf, rmeter(bars[a].getRaster(), 1, 1), mc[a]);
    else alphablit(buf, lmeter(bars[a].getRaster(), 1, 1), mc[a].sub(bars[a].getWidth() - 1, 0));
    imgblur(buf, 2, 2);
    lvlmask = new TexI(rasterimg(buf));
    lvltime = System.currentTimeMillis();
  }

  public void lcount(int n, Color c) {
    Text rt = tnf.render(String.format("Gobble Points: %d", n), c);
    levels = new TexI(rasterimg(blurmask2(rt.img.getRaster(), 2, 1, new Color(0, 0, 0))));
  }

  public void typemod(Indir<Resource> t, double a) {
    updt = true;
    for (TypeMod m : mods) {
      if (m.t == t) {
        m.a = a;
        m.ra = null;
        return;
      }
    }
    mods.add(new TypeMod(t, a));
  }

  public Object tooltip(Coord c, Widget prev) {
    if (!c.isect(boxc, boxsz)) return (null);
    return (super.tooltip(c, prev));
  }
}
 public IButton(String base, String up, String down, String hover) {
   this(
       Resource.loadimg(base + up),
       Resource.loadimg(base + down),
       Resource.loadimg(base + (hover == null ? up : hover)));
 }
 public Widget create(Widget parent, Object[] args) {
   return (new IButton(Resource.loadimg((String) args[0]), Resource.loadimg((String) args[1])));
 }
Example #7
0
public class Window extends Widget implements DTarget {
  private static final Tex tleft = Resource.loadtex("gfx/hud/wnd/tleft");
  private static final Tex tmain = Resource.loadtex("gfx/hud/wnd/tmain");
  private static final Tex tright = Resource.loadtex("gfx/hud/wnd/tright");
  public static final BufferedImage[] cbtni =
      new BufferedImage[] {
        Resource.loadimg("gfx/hud/wnd/cbtn"),
        Resource.loadimg("gfx/hud/wnd/cbtnd"),
        Resource.loadimg("gfx/hud/wnd/cbtnh")
      };
  public static final BufferedImage[] lbtni =
      new BufferedImage[] {
        Resource.loadimg("gfx/hud/wnd/lbtn"),
        Resource.loadimg("gfx/hud/wnd/lbtnd"),
        Resource.loadimg("gfx/hud/wnd/lbtnh")
      };
  public static final BufferedImage[] rbtni =
      new BufferedImage[] {
        Resource.loadimg("gfx/hud/wnd/rbtn"),
        Resource.loadimg("gfx/hud/wnd/rbtnd"),
        Resource.loadimg("gfx/hud/wnd/rbtnh")
      };
  public static final Color cc = new Color(248, 230, 190);
  public static final Text.Furnace cf =
      new Text.Imager(new Text.Foundry(new Font("Serif", Font.BOLD, 15), cc).aa(true)) {
        protected BufferedImage proc(Text text) {
          return (rasterimg(blurmask2(text.img.getRaster(), 1, 1, Color.BLACK)));
        }
      };
  public static final IBox fbox =
      new IBox("gfx/hud", "ftl", "ftr", "fbl", "fbr", "fl", "fr", "ft", "fb");
  public static final IBox swbox =
      new IBox("gfx/hud", "stl", "str", "sbl", "sbr", "sl", "sr", "st", "sb");
  public static final IBox wbox =
      new IBox("gfx/hud/wnd", "tl", "tr", "bl", "br", "vl", "vr", "ht", "hb");
  private static final IBox topless =
      new IBox(Tex.empty, Tex.empty, wbox.cbl, wbox.cbr, wbox.bl, wbox.br, Tex.empty, wbox.bb);
  private static final int th = tleft.sz().y, tdh = th - tmain.sz().y, tc = tdh + 18;
  private static final Coord capc = new Coord(20, th - 3);
  public Coord mrgn = new Coord(5, 5);
  protected Text cap;
  private boolean dt = false;
  protected boolean dm = false;
  public Coord ctl, csz, atl, asz, ac;
  protected Coord doff;
  protected final IButton cbtn;
  private final Collection<Widget> twdgs = new LinkedList<Widget>();

  // ******************************
  private static final String OPT_POS = "_pos";
  //    static Tex bg = Resource.loadtex("gfx/hud/bgtex");
  //    static Tex cl = Resource.loadtex("gfx/hud/cleft");
  //    static Tex cm = Resource.loadtex("gfx/hud/cmain");
  //    static Tex cr = Resource.loadtex("gfx/hud/cright");
  public Coord tlo, rbo;
  public boolean justclose = false;
  protected final String name;

  @RName("wnd")
  public static class $_ implements Factory {
    public Widget create(Coord c, Widget parent, Object[] args) {
      if (args.length < 2) return (new Window(c, (Coord) args[0], parent, null));
      else return (new Window(c, (Coord) args[0], parent, (String) args[1]));
    }
  }

  public Window(Coord c, Coord sz, Widget parent, String cap) {
    super(c, new Coord(0, 0), parent);
    if (cap != null) {
      this.cap = cf.render(cap);
      name = cap;
    } else {
      this.cap = null;
      name = null;
    }
    resize(sz);
    setfocustab(true);
    parent.setfocus(this);
    cbtn = new IButton(Coord.z, this, cbtni[0], cbtni[1], cbtni[2]);
    cbtn.recthit = true;
    addtwdg(cbtn);
    loadOpts();
  }

  public Coord contentsz() {
    Coord max = new Coord(0, 0);
    for (Widget wdg = child; wdg != null; wdg = wdg.next) {
      if (twdgs.contains(wdg)) continue;
      if (!wdg.visible) continue;
      Coord br = wdg.c.add(wdg.sz);
      if (br.x > max.x) max.x = br.x;
      if (br.y > max.y) max.y = br.y;
    }
    return (max.sub(1, 1));
  }

  protected void placetwdgs() {
    int x = sz.x - 5;
    for (Widget ch : twdgs) ch.c = xlate(new Coord(x -= ch.sz.x + 5, tc - (ch.sz.y / 2)), false);
  }

  public void addtwdg(Widget wdg) {
    twdgs.add(wdg);
    placetwdgs();
  }

  public void resize(Coord sz) {
    IBox box;
    int th;
    if (cap == null) {
      box = wbox;
      th = 0;
    } else {
      box = topless;
      th = Window.th;
    }
    sz = sz.add(box.bisz()).add(0, th).add(mrgn.mul(2));
    this.sz = sz;
    ctl = box.btloff().add(0, th);
    csz = sz.sub(box.bisz()).sub(0, th);
    atl = ctl.add(mrgn);
    asz = csz.sub(mrgn.mul(2));
    ac = new Coord();
    // ac = tlo.add(wbox.btloff()).add(mrgn);
    placetwdgs();
    for (Widget ch = child; ch != null; ch = ch.next) ch.presize();
  }

  public Coord xlate(Coord c, boolean in) {
    if (in) return (c.add(atl));
    else return (c.sub(atl));
  }

  public void cdraw(GOut g) {}

  public void draw(GOut g) {
    g.chcolor(0, 0, 0, 160);
    if (ctl == null || csz == null) {
      return;
    }
    g.frect(ctl, csz);
    g.chcolor();
    cdraw(g.reclip(xlate(Coord.z, true), asz));
    if (cap != null) {
      topless.draw(g, new Coord(0, th), sz.sub(0, th));
      g.image(tleft, Coord.z);
      Coord tmul = new Coord(tleft.sz().x, tdh);
      Coord tmbr = new Coord(sz.x - tright.sz().x, th);
      for (int x = tmul.x; x < tmbr.x; x += tmain.sz().x) {
        g.image(tmain, new Coord(x, tdh), tmul, tmbr);
      }
      g.image(tright, new Coord(sz.x - tright.sz().x, tdh));
      g.image(cap.tex(), capc.sub(0, cap.sz().y));
    } else {
      wbox.draw(g, Coord.z, sz);
    }
    /*
    if(cap != null) {
        GOut cg = og.reclip(new Coord(0, -7), sz.add(0, 7));
        int w = cap.tex().sz().x;
        cg.image(cl, new Coord((sz.x / 2) - (w / 2) - cl.sz().x, 0));
        cg.image(cm, new Coord((sz.x / 2) - (w / 2), 0), new Coord(w, cm.sz().y));
        cg.image(cr, new Coord((sz.x / 2) + (w / 2), 0));
        cg.image(cap.tex(), new Coord((sz.x / 2) - (w / 2), 0));
    }
    */
    super.draw(g);
  }

  public void uimsg(String msg, Object... args) {
    if (msg == "pack") {
      pack();
    } else if (msg == "dt") {
      dt = (Integer) args[0] != 0;
    } else {
      super.uimsg(msg, args);
    }
  }

  public boolean mousedown(Coord c, int button) {
    parent.setfocus(this);
    raise();
    if (super.mousedown(c, button)) return (true);
    if (c.y < tdh && cap != null) return (false);
    if (button == 1) {
      ui.grabmouse(this);
      dm = true;
      doff = c;
    }
    return (true);
  }

  public boolean mouseup(Coord c, int button) {
    if (dm) {
      canceldm();
      storeOpt(OPT_POS, this.c);
    } else {
      super.mouseup(c, button);
    }
    return (true);
  }

  public void canceldm() {
    if (dm) ui.grabmouse(null);
    dm = false;
  }

  public void mousemove(Coord c) {
    if (dm) {
      this.c = this.c.add(c.add(doff.inv()));
    } else {
      super.mousemove(c);
    }
  }

  public void wdgmsg(Widget sender, String msg, Object... args) {
    if (sender == cbtn) {
      if (justclose) ui.destroy(this);
      else wdgmsg("close");
    } else {
      super.wdgmsg(sender, msg, args);
    }
  }

  public boolean type(char key, java.awt.event.KeyEvent ev) {
    if (super.type(key, ev)) return (true);
    if (key == 27) {
      if (justclose) ui.destroy(this);
      else wdgmsg("close");
      return (true);
    }
    return (false);
  }

  public boolean drop(Coord cc, Coord ul) {
    if (dt) {
      wdgmsg("drop", cc);
      return (true);
    }
    return (false);
  }

  public boolean iteminteract(Coord cc, Coord ul) {
    return (false);
  }

  public Object tooltip(Coord c, Widget prev) {
    Object ret = super.tooltip(c, prev);
    if (ret != null) return (ret);
    else return ("");
  }

  protected void storeOpt(String opt, String value) {
    if (name == null) {
      return;
    }
    Config.setWindowOpt(name + opt, value);
  }

  protected void storeOpt(String opt, Coord value) {
    storeOpt(opt, value.toString());
  }

  protected void storeOpt(String opt, boolean value) {
    if (name == null) {
      return;
    }
    Config.setWindowOpt(name + opt, value);
  }

  protected Coord getOptCoord(String opt, Coord def) {
    synchronized (Config.window_props) {
      try {
        return new Coord(Config.window_props.getProperty(name + opt, def.toString()));
      } catch (Exception e) {
        return def;
      }
    }
  }

  protected boolean getOptBool(String opt, boolean def) {
    synchronized (Config.window_props) {
      try {
        return Config.window_props.getProperty(name + opt, null).equals("true");
      } catch (Exception e) {
        return def;
      }
    }
  }

  protected void loadOpts() {
    if (name == null) {
      return;
    }
    c = getOptCoord(OPT_POS, c);
  }
}