Exemplo n.º 1
0
  public WPopupMenuPeer(PopupMenu target) {
    this.target = target;
    MenuContainer parent = null;
    boolean isTrayIconPopup = false;
    isTrayIconPopup = AWTAccessor.getPopupMenuAccessor().isTrayIconPopup(target);
    if (isTrayIconPopup) {
      parent = AWTAccessor.getMenuComponentAccessor().getParent(target);
    } else {
      parent = target.getParent();
    }

    if (parent instanceof Component) {
      WComponentPeer parentPeer = (WComponentPeer) WToolkit.targetToPeer(parent);
      if (parentPeer == null) {
        // because the menu isn't a component (sigh) we first have to wait
        // for a failure to map the peer which should only happen for a
        // lightweight container, then find the actual native parent from
        // that component.
        parent = WToolkit.getNativeContainer((Component) parent);
        parentPeer = (WComponentPeer) WToolkit.targetToPeer(parent);
      }
      createMenu(parentPeer);
      // fix for 5088782: check if menu object is created successfully
      checkMenuCreation();
    } else {
      throw new IllegalArgumentException("illegal popup menu container class");
    }
  }
Exemplo n.º 2
0
 // Toolkit & peer internals
 WMenuBarPeer(MenuBar target) {
   this.target = target;
   WFramePeer framePeer = (WFramePeer) WToolkit.targetToPeer(target.getParent());
   create(framePeer);
   // fix for 5088782: check if menu object is created successfully
   checkMenuCreation();
 }
Exemplo n.º 3
0
 // Note: Because this method calls resize(), which may be overridden
 // by client code, this method must not be executed on the toolkit
 // thread.
 @Override
 public void setMenuBar(MenuBar mb) {
   WMenuBarPeer mbPeer = (WMenuBarPeer) WToolkit.targetToPeer(mb);
   if (mbPeer != null) {
     if (mbPeer.framePeer != this) {
       mb.removeNotify();
       mb.addNotify();
       mbPeer = (WMenuBarPeer) WToolkit.targetToPeer(mb);
       if (mbPeer != null && mbPeer.framePeer != this) {
         throw new IllegalStateException("Wrong parent peer");
       }
     }
     if (mbPeer != null) {
       addChildPeer(mbPeer);
     }
   }
   setMenuBar0(mbPeer);
   updateInsets(insets_);
 }
Exemplo n.º 4
0
 /*
  * This overloaded method is for TrayIcon.
  * Its popup has special parent.
  */
 void show(Component origin, Point p) {
   WComponentPeer peer = (WComponentPeer) WToolkit.targetToPeer(origin);
   Event e = new Event(origin, 0, Event.MOUSE_DOWN, p.x, p.y, 0, 0);
   if (peer == null) {
     Component nativeOrigin = WToolkit.getNativeContainer(origin);
     e.target = nativeOrigin;
   }
   e.x = p.x;
   e.y = p.y;
   _show(e);
 }
Exemplo n.º 5
0
  public void show(Event e) {
    Component origin = (Component) e.target;
    WComponentPeer peer = (WComponentPeer) WToolkit.targetToPeer(origin);
    if (peer == null) {
      // A failure to map the peer should only happen for a
      // lightweight component, then find the actual native parent from
      // that component.  The event coorinates are going to have to be
      // remapped as well.
      Component nativeOrigin = WToolkit.getNativeContainer(origin);
      e.target = nativeOrigin;

      // remove the event coordinates
      for (Component c = origin; c != nativeOrigin; c = c.getParent()) {
        Point p = c.getLocation();
        e.x += p.x;
        e.y += p.y;
      }
    }
    _show(e);
  }
Exemplo n.º 6
0
 @Override
 final WComponentPeer getNativeParent() {
   final Container owner = ((Window) target).getOwner();
   return (WComponentPeer) WToolkit.targetToPeer(owner);
 }