Ejemplo n.º 1
0
 @SuppressWarnings("deprecation")
 private void replaceSurfaceDataRecursively(Component c) {
   if (c instanceof Container) {
     for (Component child : ((Container) c).getComponents()) {
       replaceSurfaceDataRecursively(child);
     }
   }
   ComponentPeer cp = c.getPeer();
   if (cp instanceof WComponentPeer) {
     ((WComponentPeer) cp).replaceSurfaceDataLater();
   }
 }
Ejemplo n.º 2
0
 public void dispatchEvent(AWTEvent e) {
   if (e instanceof ComponentEvent) {
     Component comp = ((ComponentEvent) e).getComponent();
     if (comp == awtFocussedComponent) {
       if (awtFocussedComponentPeer == null || awtFocussedComponentPeer.isDisposed()) {
         awtFocussedComponentPeer = getNearestNativePeer(comp);
       }
       if (awtFocussedComponentPeer != null) {
         handleNativeIMEEvent(awtFocussedComponentPeer, e);
       }
     }
   }
 }
Ejemplo n.º 3
0
  void initialize() {
    List li = (List) target;

    fm = getFontMetrics(li.getFont());

    Font font = li.getFont();
    if (font != null) setFont(font);

    // add any items that were already inserted in the target.
    int nitems = li.countItems();
    if (nitems > 0) {
      String[] items = new String[nitems];
      int maxWidth = 0;
      int width = 0;
      for (int i = 0; i < nitems; i++) {
        items[i] = li.getItem(i);
        width = fm.stringWidth(items[i]);
        if (width > maxWidth) {
          maxWidth = width;
        }
      }
      addItems(items, 0, maxWidth);
    }

    // set whether this list should allow multiple selections.
    setMultipleSelections(li.allowsMultipleSelections());

    // select the item if necessary.
    int sel[] = li.getSelectedIndexes();
    for (int i = 0; i < sel.length; i++) {
      select(sel[i]);
    }

    // make the visible position visible.
    // fix for 4676536 by [email protected]
    // we should call makeVisible() after we call select()
    // because of a bug in Windows which is manifested by
    // incorrect scrolling of the selected item if the list
    // height is less than an item height of the list.
    int index = li.getVisibleIndex();
    if (index < 0 && sel.length > 0) {
      index = sel[0];
    }
    if (index >= 0) {
      makeVisible(index);
    }

    super.initialize();
  }
Ejemplo n.º 4
0
 // update the fontmetrics when the font changes
 public synchronized void setFont(Font f) {
   super.setFont(f);
   fm = getFontMetrics(((List) target).getFont());
   updateMaxItemWidth();
 }
Ejemplo n.º 5
0
    public void run() {
      if (getScrollChild() == null) {
        return;
      }
      ScrollPane sp = (ScrollPane) WScrollPanePeer.this.target;
      ScrollPaneAdjustable adj = null;

      // ScrollPaneAdjustable made public in 1.4, but
      // get[HV]Adjustable can't be declared to return
      // ScrollPaneAdjustable because it would break backward
      // compatibility -- hence the cast

      if (orient == Adjustable.VERTICAL) {
        adj = (ScrollPaneAdjustable) sp.getVAdjustable();
      } else if (orient == Adjustable.HORIZONTAL) {
        adj = (ScrollPaneAdjustable) sp.getHAdjustable();
      } else {
        if (dbg.on) dbg.assertion(false);
      }

      if (adj == null) {
        return;
      }

      int newpos = adj.getValue();
      switch (type) {
        case AdjustmentEvent.UNIT_DECREMENT:
          newpos -= adj.getUnitIncrement();
          break;
        case AdjustmentEvent.UNIT_INCREMENT:
          newpos += adj.getUnitIncrement();
          break;
        case AdjustmentEvent.BLOCK_DECREMENT:
          newpos -= adj.getBlockIncrement();
          break;
        case AdjustmentEvent.BLOCK_INCREMENT:
          newpos += adj.getBlockIncrement();
          break;
        case AdjustmentEvent.TRACK:
          newpos = this.pos;
          break;
        default:
          if (dbg.on) dbg.assertion(false);
          return;
      }

      // keep scroll position in acceptable range
      newpos = Math.max(adj.getMinimum(), newpos);
      newpos = Math.min(adj.getMaximum(), newpos);

      // set value, this will synchronously fire an AdjustmentEvent
      adj.setValueIsAdjusting(isAdjusting);

      // Fix for 4075484 - consider type information when creating AdjustmentEvent
      // We can't just call adj.setValue() because it creates AdjustmentEvent with type=TRACK
      // Instead, we call private method setTypedValue of ScrollPaneAdjustable.
      // Because ScrollPaneAdjustable is in another package we should call it through native code.
      setTypedValue(adj, newpos, type);

      // Paint the exposed area right away.  To do this - find
      // the heavyweight ancestor of the scroll child.
      Component hwAncestor = getScrollChild();
      while (hwAncestor != null && !(hwAncestor.getPeer() instanceof WComponentPeer)) {
        hwAncestor = hwAncestor.getParent();
      }
      if (dbg.on) {
        dbg.assertion(
            hwAncestor != null, "couldn't find heavyweight ancestor of scroll pane child");
      }
      WComponentPeer hwPeer = (WComponentPeer) hwAncestor.getPeer();
      hwPeer.paintDamagedAreaImmediately();
    }