示例#1
0
 public void mousemove(Coord c) {
   for (Widget wdg = lchild; wdg != null; wdg = wdg.prev) {
     if (!wdg.visible) continue;
     Coord cc = xlate(wdg.c, true);
     wdg.mousemove(c.add(cc.inv()));
   }
 }
示例#2
0
 public void unlink() {
   if (next != null) next.prev = prev;
   if (prev != null) prev.next = next;
   if (parent.child == this) parent.child = next;
   if (parent.lchild == this) parent.lchild = prev;
   next = null;
   prev = null;
 }
示例#3
0
 @Deprecated
 public <T extends Widget> T findchild(Class<T> cl) {
   for (Widget wdg = child; wdg != null; wdg = wdg.next) {
     if (cl.isInstance(wdg)) return (cl.cast(wdg));
     T ret = wdg.findchild(cl);
     if (ret != null) return (ret);
   }
   return (null);
 }
示例#4
0
 public void delfocusable(Widget w) {
   if (focusctl) {
     if ((focused != null) && focused.hasparent(w)) {
       findfocus();
     }
   } else {
     if (parent != null) parent.delfocusable(w);
   }
 }
示例#5
0
 public void setcanfocus(boolean canfocus) {
   this.autofocus = this.canfocus = canfocus;
   if (parent != null) {
     if (canfocus) {
       parent.newfocusable(this);
     } else {
       parent.delfocusable(this);
     }
   }
 }
示例#6
0
 public boolean mousewheel(Coord c, int amount) {
   for (Widget wdg = lchild; wdg != null; wdg = wdg.prev) {
     if (!wdg.visible) continue;
     Coord cc = xlate(wdg.c, true);
     if (c.isect(cc, wdg.sz)) {
       if (wdg.mousewheel(c.add(cc.inv()), amount)) {
         return (true);
       }
     }
   }
   return (false);
 }
示例#7
0
  public void draw(GOut g, boolean strict) {
    Widget next;

    for (Widget wdg = child; wdg != null; wdg = next) {
      next = wdg.next;
      if (!wdg.visible) continue;
      Coord cc = xlate(wdg.c, true);
      GOut g2;
      if (strict) g2 = g.reclip(cc, wdg.sz);
      else g2 = g.reclipl(cc, wdg.sz);
      wdg.draw(g2);
    }
  }
示例#8
0
 private void findfocus() {
   /* XXX: Might need to check subwidgets recursively */
   focused = null;
   for (Widget w = lchild; w != null; w = w.prev) {
     if (w.visible && w.autofocus) {
       focused = w;
       if (hasfocus) {
         focused.hasfocus = true;
         w.gotfocus();
       }
       break;
     }
   }
 }
示例#9
0
 public boolean type(char key, KeyEvent ev) {
   if (canactivate) {
     if (key == 10) {
       wdgmsg("activate");
       return (true);
     }
   }
   if (cancancel) {
     if (key == 27) {
       wdgmsg("cancel");
       return (true);
     }
   }
   if (focusctl) {
     if (focused != null) {
       if (focused.type(key, ev)) return (true);
       if (focustab) {
         if (key == '\t' && !Config.agroclosest) {
           Widget f = focused;
           while (true) {
             if ((ev.getModifiers() & InputEvent.SHIFT_MASK) == 0) {
               Widget n = f.rnext();
               f = ((n == null) || !n.hasparent(this)) ? child : n;
             } else {
               Widget p = f.rprev();
               f = ((p == null) || !p.hasparent(this)) ? lchild : p;
             }
             if (f.canfocus) break;
           }
           setfocus(f);
           return (true);
         } else {
           return (false);
         }
       } else {
         return (false);
       }
     } else {
       return (false);
     }
   } else {
     for (Widget wdg = child; wdg != null; wdg = wdg.next) {
       if (wdg.visible) {
         if (wdg.type(key, ev)) return (true);
       }
     }
     return (false);
   }
 }
示例#10
0
  public Resource getcurs(Coord c) {
    Resource ret;

    for (Widget wdg = lchild; wdg != null; wdg = wdg.prev) {
      if (!wdg.visible) continue;
      Coord cc = xlate(wdg.c, true);
      if (c.isect(cc, wdg.sz)) {
        if ((ret = wdg.getcurs(c.add(cc.inv()))) != null) return (ret);
      }
    }
    try {
      return ((cursor == null) ? null : cursor.get());
    } catch (Loading l) {
      return (null);
    }
  }
示例#11
0
 public void newfocusable(Widget w) {
   if (focusctl) {
     if (focused == null) setfocus(w);
   } else {
     if (parent != null) parent.newfocusable(w);
   }
 }
示例#12
0
  public void tick(double dt) throws InterruptedException {
    Widget next;

    for (Widget wdg = child; wdg != null; wdg = next) {
      next = wdg.next;
      wdg.tick(dt);
    }
    /* It would be very nice to do these things in harmless mix-in
     * classes, but alas, this is Java. */
    anims.addAll(nanims);
    nanims.clear();
    for (Iterator<Anim> i = anims.iterator(); i.hasNext(); ) {
      Anim anim = i.next();
      if (anim.tick(dt)) i.remove();
    }
  }
示例#13
0
 private <T extends Widget> T add0(T child) {
   if (this.ui != null) ((Widget) child).attach(this.ui);
   child.parent = this;
   child.link();
   child.added();
   if (((Widget) child).canfocus && child.visible) newfocusable(child);
   return (child);
 }
示例#14
0
 public boolean keyup(KeyEvent ev) {
   if (focusctl) {
     if (focused != null) {
       if (focused.keyup(ev)) return (true);
       return (false);
     } else {
       return (false);
     }
   } else {
     for (Widget wdg = child; wdg != null; wdg = wdg.next) {
       if (wdg.visible) {
         if (wdg.keyup(ev)) return (true);
       }
     }
   }
   return (false);
 }
示例#15
0
 public Object tooltip(Coord c, Widget prev) {
   if (prev != this) prevtt = null;
   if (tooltip != null) {
     prevtt = null;
     return (tooltip);
   }
   for (Widget wdg = lchild; wdg != null; wdg = wdg.prev) {
     if (!wdg.visible) continue;
     Coord cc = xlate(wdg.c, true);
     if (c.isect(cc, wdg.sz)) {
       Object ret = wdg.tooltip(c.add(cc.inv()), prevtt);
       if (ret != null) {
         prevtt = wdg;
         return (ret);
       }
     }
   }
   prevtt = null;
   return (tooltip(c, prev == this));
 }
示例#16
0
 public void setfocus(Widget w) {
   if (focusctl) {
     if (w != focused) {
       Widget last = focused;
       focused = w;
       if (hasfocus) {
         if (last != null) last.hasfocus = false;
         w.hasfocus = true;
         if (last != null) last.lostfocus();
         w.gotfocus();
       } else if ((last != null) && last.hasfocus) {
         /* Bug, but ah well. */
         last.hasfocus = false;
         last.lostfocus();
       }
       if ((ui != null) && ui.rwidgets.containsKey(w) && ui.rwidgets.containsKey(this))
         wdgmsg("focus", ui.rwidgets.get(w));
     }
     if ((parent != null) && visible && canfocus) parent.setfocus(this);
   } else {
     parent.setfocus(w);
   }
 }
示例#17
0
 public void resize(Coord sz) {
   this.sz = sz;
   for (Widget ch = child; ch != null; ch = ch.next) ch.presize();
   if (parent != null) parent.cresize(this);
 }
示例#18
0
 public boolean globtype(char key, KeyEvent ev) {
   for (Widget wdg = lchild; wdg != null; wdg = wdg.prev) {
     if (wdg.globtype(key, ev)) return (true);
   }
   return (false);
 }
示例#19
0
 public void linkfirst() {
   if (parent.child != null) parent.child.prev = this;
   if (parent.lchild == null) parent.lchild = this;
   this.next = parent.child;
   parent.child = this;
 }
示例#20
0
 public void link() {
   if (parent.lchild != null) parent.lchild.next = this;
   if (parent.child == null) parent.child = this;
   this.prev = parent.lchild;
   parent.lchild = this;
 }
示例#21
0
 public void lostfocus() {
   if (focusctl && (focused != null)) {
     focused.hasfocus = false;
     focused.lostfocus();
   }
 }
示例#22
0
 public void gotfocus() {
   if (focusctl && (focused != null)) {
     focused.hasfocus = true;
     focused.gotfocus();
   }
 }
示例#23
0
 public void wdgmsg(Widget sender, String msg, Object... args) {
   if (parent == null) ui.wdgmsg(sender, msg, args);
   else parent.wdgmsg(sender, msg, args);
 }
示例#24
0
 protected void attach(UI ui) {
   this.ui = ui;
   for (Widget ch = child; ch != null; ch = ch.next) ch.attach(ui);
 }
示例#25
0
 public void hide() {
   visible = false;
   if (canfocus && (parent != null)) parent.delfocusable(this);
 }
示例#26
0
 public Coord parentpos(Widget in) {
   if (in == this) return (new Coord(0, 0));
   return (xlate(parent.parentpos(in).add(c), true));
 }
示例#27
0
 public void destroy() {
   if (canfocus) setcanfocus(false);
   unlink();
   parent.cdestroy(this);
 }
示例#28
0
 public void show() {
   visible = true;
   if (canfocus && (parent != null)) parent.newfocusable(this);
 }
示例#29
0
 public <T extends Widget> T add(T child) {
   super.add(child);
   pack();
   if (parent != null) presize();
   return (child);
 }