Exemple #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()));
   }
 }
Exemple #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;
 }
Exemple #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);
 }
Exemple #4
0
 public void delfocusable(Widget w) {
   if (focusctl) {
     if ((focused != null) && focused.hasparent(w)) {
       findfocus();
     }
   } else {
     if (parent != null) parent.delfocusable(w);
   }
 }
Exemple #5
0
 public void setcanfocus(boolean canfocus) {
   this.autofocus = this.canfocus = canfocus;
   if (parent != null) {
     if (canfocus) {
       parent.newfocusable(this);
     } else {
       parent.delfocusable(this);
     }
   }
 }
Exemple #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);
 }
Exemple #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);
    }
  }
Exemple #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;
     }
   }
 }
Exemple #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);
   }
 }
Exemple #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);
    }
  }
Exemple #11
0
 public void newfocusable(Widget w) {
   if (focusctl) {
     if (focused == null) setfocus(w);
   } else {
     if (parent != null) parent.newfocusable(w);
   }
 }
Exemple #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();
    }
  }
Exemple #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);
 }
Exemple #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);
 }
Exemple #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));
 }
Exemple #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);
   }
 }
Exemple #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);
 }
Exemple #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);
 }
Exemple #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;
 }
Exemple #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;
 }
Exemple #21
0
 public void lostfocus() {
   if (focusctl && (focused != null)) {
     focused.hasfocus = false;
     focused.lostfocus();
   }
 }
Exemple #22
0
 public void gotfocus() {
   if (focusctl && (focused != null)) {
     focused.hasfocus = true;
     focused.gotfocus();
   }
 }
Exemple #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);
 }
Exemple #24
0
 protected void attach(UI ui) {
   this.ui = ui;
   for (Widget ch = child; ch != null; ch = ch.next) ch.attach(ui);
 }
Exemple #25
0
 public void hide() {
   visible = false;
   if (canfocus && (parent != null)) parent.delfocusable(this);
 }
Exemple #26
0
 public Coord parentpos(Widget in) {
   if (in == this) return (new Coord(0, 0));
   return (xlate(parent.parentpos(in).add(c), true));
 }
Exemple #27
0
 public void destroy() {
   if (canfocus) setcanfocus(false);
   unlink();
   parent.cdestroy(this);
 }
Exemple #28
0
 public void show() {
   visible = true;
   if (canfocus && (parent != null)) parent.newfocusable(this);
 }
Exemple #29
0
 public <T extends Widget> T add(T child) {
   super.add(child);
   pack();
   if (parent != null) presize();
   return (child);
 }