private boolean noIntersections(Rectangle bounds) {
   Window owner = SwingUtilities.getWindowAncestor(myComponent);
   Window popup = SwingUtilities.getWindowAncestor(myTipComponent);
   Window focus = WindowManagerEx.getInstanceEx().getMostRecentFocusedWindow();
   if (focus == owner.getOwner()) {
     focus = null; // do not check intersection with parent
   }
   boolean focused = SystemInfo.isWindows || owner.isFocused();
   for (Window other : owner.getOwnedWindows()) {
     if (!focused && !SystemInfo.isWindows) {
       focused = other.isFocused();
     }
     if (popup != other
         && other.isVisible()
         && bounds.x + 10 >= other.getX()
         && bounds.intersects(other.getBounds())) {
       return false;
     }
     if (focus == other) {
       focus = null; // already checked
     }
   }
   return focused
       && (focus == owner || focus == null || !owner.getBounds().intersects(focus.getBounds()));
 }
Esempio n. 2
0
  @IMEventHandler(IMEventType.SHOW_MSG_HISTORY_WINDOW)
  protected void processIMShowWindow(IMEvent event) {
    namedObject = (UINamedObject) event.getTarget();
    setTitle(namedObject.getName() + " - Message History.");

    Window win = event.getData("view");
    Rectangle rect = win.getBounds();
    setLocation(rect.x + rect.width - 50, rect.y);
    setSize(getWidth(), rect.height);
    validate();
    setVisible(true);

    currentPage = 0;
    totalPage = 0;

    // 显示消息
    IMEvent imEvent = new IMEvent(IMEventType.MSG_HISTORY_FIND, namedObject.getEntity());
    imEvent.putData("limit", limit);
    IMEventService events = getContext().getSerivce(IMService.Type.EVENT);
    events.broadcast(imEvent);

    win.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentMoved(ComponentEvent e) {
            int x = e.getComponent().getX() + e.getComponent().getWidth() - 50;
            int y = e.getComponent().getY();
            if (isPtInRect(getBounds(), new Point(x, y))) {
              setLocation(x, y);
              setSize(getWidth(), e.getComponent().getHeight());
            }
          }
        });
  }
  @IMEventHandler(IMEventType.SHOW_MEMBERS_WINDOW)
  protected void showMembersWindow(IMEvent event) {
    UINamedObject named = (UINamedObject) event.getTarget();
    Window win = event.getData("view");
    Rectangle rect = win.getBounds();
    setLocation(rect.x + rect.width - 30, rect.y + 25);

    setIconImage(named.getIcon());
    setTitle(named.getName());
    this.namedObject = named;

    progressOverlay.setShowLoad(true);
    setVisible(true);

    isLoadFace = true; // 设置允许下载头像

    checkReloadMembers(namedObject); // 显示成员

    win.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentMoved(ComponentEvent e) {
            int x = e.getComponent().getX() + e.getComponent().getWidth() - 30;
            int y = e.getComponent().getY() + 25;
            if (isPtInRect(getBounds(), new Point(x, y))) {
              setLocation(x, y);
            }
          }
        });
  }
Esempio n. 4
0
 private void refresh() {
   if (_window != null) {
     if (_bounds == null) {
       _bounds = new RectangleWrapper();
     }
     _bounds.setFrom(_window.getBounds());
   }
 }
  @Override
  public void moveToFitScreen() {
    if (myPopup == null) return;

    final Window popupWindow = SwingUtilities.windowForComponent(myContent);
    Rectangle bounds = popupWindow.getBounds();

    ScreenUtil.moveRectangleToFitTheScreen(bounds);
    setLocation(bounds.getLocation());
    setSize(bounds.getSize(), false);
  }
  public boolean isInsideHint(RelativePoint target) {
    if (myComponent == null || !myComponent.isShowing()) return false;

    if (myIsRealPopup) {
      Window wnd = SwingUtilities.getWindowAncestor(myComponent);
      return wnd.getBounds().contains(target.getScreenPoint());
    } else if (myCurrentIdeTooltip != null) {
      return myCurrentIdeTooltip.isInside(target);
    } else {
      return new Rectangle(myComponent.getLocationOnScreen(), myComponent.getSize())
          .contains(target.getScreenPoint());
    }
  }
  /**
   * Positions the specified frame at a relative position in the screen, where 50% is considered to
   * be the center of the screen.
   *
   * @param frame the frame.
   * @param horizontalPercent the relative horizontal position of the frame (0.0 to 1.0, where 0.5
   *     is the center of the screen).
   * @param verticalPercent the relative vertical position of the frame (0.0 to 1.0, where 0.5 is
   *     the center of the screen).
   */
  public static void positionFrameOnScreen(
      final Window frame, final double horizontalPercent, final double verticalPercent) {

    final Rectangle s = frame.getGraphicsConfiguration().getBounds();
    final Dimension f = frame.getSize();

    final int spaceOnX = Math.max(s.width - f.width, 0);
    final int spaceOnY = Math.max(s.height - f.height, 0);
    final int x = (int) (horizontalPercent * spaceOnX) + s.x;
    final int y = (int) (verticalPercent * spaceOnY) + s.y;
    frame.setBounds(x, y, f.width, f.height);
    frame.setBounds(s.intersection(frame.getBounds()));
  }
Esempio n. 8
0
 /**
  * 获得Screen的画面边界
  *
  * @return
  */
 public Rectangle getBounds() {
   if (handler == null) {
     return null;
   }
   Window window = handler.getScene().getWindow();
   Rectangle bounds = window.getBounds();
   Insets insets = window.getInsets();
   return new Rectangle(
       bounds.x + insets.left,
       bounds.y + insets.top,
       bounds.width - (insets.left + insets.top),
       bounds.height - (insets.top + insets.bottom));
 }
Esempio n. 9
0
  /**
   * Set the value of the attribute to match the location of the specified component.
   *
   * @param component The component whose location is to be recorded.
   */
  public void recordLocation(Window component) {
    try {
      Rectangle location = component.getBounds();
      int[][] locationMatrix = new int[1][2];
      locationMatrix[0][0] = location.x;
      locationMatrix[0][1] = location.y;

      IntMatrixToken token = new IntMatrixToken(locationMatrix);
      setToken(token);
    } catch (IllegalActionException ex) {
      throw new InternalErrorException("Can't set bounds value!");
    }
  }
Esempio n. 10
0
  /*
   * Delegate initialization (create native window and all the
   * related resources).
   */
  @Override // PlatformWindow
  public void initialize(Window _target, LWWindowPeer _peer, PlatformWindow _owner) {
    initializeBase(_target, _peer, _owner, new CPlatformView());

    final int styleBits = getInitialStyleBits();

    responder = createPlatformResponder();
    contentView = createContentView();
    contentView.initialize(peer, responder);

    final long ownerPtr = owner != null ? owner.getNSWindowPtr() : 0L;
    Rectangle bounds;
    if (!IS(DECORATED, styleBits)) {
      // For undecorated frames the move/resize event does not come if the frame is centered on the
      // screen
      // so we need to set a stub location to force an initial move/resize. Real bounds would be set
      // later.
      bounds = new Rectangle(0, 0, 1, 1);
    } else {
      bounds = _peer.constrainBounds(_target.getBounds());
    }
    final long nativeWindowPtr =
        nativeCreateNSWindow(
            contentView.getAWTView(),
            ownerPtr,
            styleBits,
            bounds.x,
            bounds.y,
            bounds.width,
            bounds.height);
    setPtr(nativeWindowPtr);

    if (target instanceof javax.swing.RootPaneContainer) {
      final javax.swing.JRootPane rootpane = ((javax.swing.RootPaneContainer) target).getRootPane();
      if (rootpane != null)
        rootpane.addPropertyChangeListener(
            "ancestor",
            new PropertyChangeListener() {
              public void propertyChange(final PropertyChangeEvent evt) {
                CLIENT_PROPERTY_APPLICATOR.attachAndApplyClientProperties(rootpane);
                rootpane.removePropertyChangeListener("ancestor", this);
              }
            });
    }

    validateSurface();
  }
Esempio n. 11
0
    boolean overlappedByOwnedWindow() {
      Component component = getComponent();
      if (owner != null && component != null) {
        Window w = SwingUtilities.getWindowAncestor(owner);
        if (w == null) {
          return false;
        }
        Window[] ownedWindows = w.getOwnedWindows();
        if (ownedWindows != null) {
          Rectangle bnd = component.getBounds();
          for (Window window : ownedWindows) {
            if (window.isVisible() && bnd.intersects(window.getBounds())) {

              return true;
            }
          }
        }
      }
      return false;
    }
Esempio n. 12
0
    public void mouseDragged(MouseEvent ev) {
      Window w = (Window) ev.getSource();
      Point pt = ev.getPoint();

      if (isMovingWindow) {
        Point windowPt;
        try {
          windowPt = (Point) AccessController.doPrivileged(getLocationAction);
          windowPt.x = windowPt.x - dragOffsetX;
          windowPt.y = windowPt.y - dragOffsetY;
          w.setLocation(windowPt);
        } catch (PrivilegedActionException e) {
        }
      } else if (dragCursor != 0) {
        Rectangle r = w.getBounds();
        Rectangle startBounds = new Rectangle(r);
        Dimension min = w.getMinimumSize();

        switch (dragCursor) {
          case Cursor.E_RESIZE_CURSOR:
            adjust(r, min, 0, 0, pt.x + (dragWidth - dragOffsetX) - r.width, 0);
            break;
          case Cursor.S_RESIZE_CURSOR:
            adjust(r, min, 0, 0, 0, pt.y + (dragHeight - dragOffsetY) - r.height);
            break;
          case Cursor.N_RESIZE_CURSOR:
            adjust(r, min, 0, pt.y - dragOffsetY, 0, -(pt.y - dragOffsetY));
            break;
          case Cursor.W_RESIZE_CURSOR:
            adjust(r, min, pt.x - dragOffsetX, 0, -(pt.x - dragOffsetX), 0);
            break;
          case Cursor.NE_RESIZE_CURSOR:
            adjust(
                r,
                min,
                0,
                pt.y - dragOffsetY,
                pt.x + (dragWidth - dragOffsetX) - r.width,
                -(pt.y - dragOffsetY));
            break;
          case Cursor.SE_RESIZE_CURSOR:
            adjust(
                r,
                min,
                0,
                0,
                pt.x + (dragWidth - dragOffsetX) - r.width,
                pt.y + (dragHeight - dragOffsetY) - r.height);
            break;
          case Cursor.NW_RESIZE_CURSOR:
            adjust(
                r,
                min,
                pt.x - dragOffsetX,
                pt.y - dragOffsetY,
                -(pt.x - dragOffsetX),
                -(pt.y - dragOffsetY));
            break;
          case Cursor.SW_RESIZE_CURSOR:
            adjust(
                r,
                min,
                pt.x - dragOffsetX,
                0,
                -(pt.x - dragOffsetX),
                pt.y + (dragHeight - dragOffsetY) - r.height);
            break;
          default:
            break;
        }
        if (!r.equals(startBounds)) {
          w.setBounds(r);
          // Defer repaint/validate on mouseReleased unless dynamic
          // layout is active.
          if (Toolkit.getDefaultToolkit().isDynamicLayoutActive()) {
            w.validate();
            getRootPane().repaint();
          }
        }
      }
    }