org.eclipse.swt.widgets.Shell#getLocation ( )源码实例Demo

下面列出了org.eclipse.swt.widgets.Shell#getLocation ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: APICloud-Studio   文件: ContentAssistant.java
/**
 * getStackedLocation
 * 
 * @param shell
 * @param parent
 * @return Point
 */
protected Point getStackedLocation(Shell shell, Shell parent)
{
	Point p = parent.getLocation();
	Point parentSize = parent.getSize();
	// p.x += parentSize.x / 4;
	p.y += parentSize.y + 5;

	// p= parent.toDisplay(p);

	Rectangle shellBounds = shell.getBounds();
	Rectangle displayBounds = shell.getDisplay().getClientArea();
	shiftHorizontalLocation(p, shellBounds, displayBounds);
	shiftVerticalLocation(p, shellBounds, displayBounds, true);

	return p;
}
 
源代码2 项目: nebula   文件: Dialog.java
private void center() {
	final Point preferredSize = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);

	if (preferredSize.x < minimumWidth) {
		preferredSize.x = minimumWidth;
	}

	if (preferredSize.y < minimumHeight) {
		preferredSize.y = minimumHeight;
	}
	
	final int centerX;
	final int centerY;

	if (centerPolicy == CenterOption.CENTER_ON_SCREEN || shell.getParent() == null) {
		Shell activeShell = shell.getDisplay().getActiveShell();
		final Rectangle monitorBounds = SWTGraphicUtil.getBoundsOfMonitorOnWhichShellIsDisplayed(activeShell);
		centerX = monitorBounds.x + (monitorBounds.width - preferredSize.x) / 2;
		centerY = monitorBounds.y + (monitorBounds.height - preferredSize.y) / 2;
	} else {
		final Shell parent = (Shell) shell.getParent();
		centerX = parent.getLocation().x + (parent.getSize().x - preferredSize.x) / 2;
		centerY = parent.getLocation().y + (parent.getSize().y - preferredSize.y) / 2;
	}

	shell.setBounds(centerX, centerY, preferredSize.x, preferredSize.y);		
}
 
源代码3 项目: AppleCommander   文件: SwtUtil.java
/**
 * Center the child shell within the parent shell window.
 */
public static void center(Shell parent, Shell child) {
	int x = parent.getLocation().x + 
		(parent.getSize().x - child.getSize().x) / 2;
	int y = parent.getLocation().y +
		(parent.getSize().y - child.getSize().y) / 2;
	if (x < 0) x = 0;
	if (y < 0) y = 0;
	child.setLocation(x,y);
}
 
源代码4 项目: SWET   文件: PopupDialog.java
/**
 * Saves the bounds of the shell in the appropriate dialog settings. The
 * bounds are recorded relative to the parent shell, if there is one, or
 * display coordinates if there is no parent shell. Subclasses typically
 * need not override this method, but may extend it (calling
 * <code>super.saveDialogBounds</code> if additional bounds information
 * should be stored. Clients may also call this method to persist the bounds
 * at times other than closing the dialog.
 * 
 * @param shell
 *            The shell whose bounds are to be stored
 */
protected void saveDialogBounds(Shell shell) {
	IDialogSettings settings = getDialogSettings();
	if (settings != null) {
		Point shellLocation = shell.getLocation();
		Point shellSize = shell.getSize();
		Shell parent = getParentShell();
		if (parent != null) {
			Point parentLocation = parent.getLocation();
			shellLocation.x -= parentLocation.x;
			shellLocation.y -= parentLocation.y;
		}
		String prefix = getClass().getName();
		if (persistSize) {
			settings.put(prefix + DIALOG_WIDTH, shellSize.x);
			settings.put(prefix + DIALOG_HEIGHT, shellSize.y);
		}
		if (persistLocation) {
			settings.put(prefix + DIALOG_ORIGIN_X, shellLocation.x);
			settings.put(prefix + DIALOG_ORIGIN_Y, shellLocation.y);
		}
		if (showPersistActions && showDialogMenu) {
			settings.put(getClass().getName() + DIALOG_USE_PERSISTED_SIZE,
					persistSize);
			settings.put(getClass().getName() + DIALOG_USE_PERSISTED_LOCATION,
					persistLocation);

		}
	}
}
 
源代码5 项目: logbook   文件: LayoutLogic.java
/**
 * Shellのウインドウ位置とサイズを保存します
 * 
 * @param clazz ウインドウクラス
 * @param shell Shell
 */
public static void saveWindowLocation(Class<? extends Dialog> clazz, Shell shell) {
    Map<String, WindowLocationBean> map = AppConfig.get().getWindowLocationMap();
    Point location = shell.getLocation();
    Point size = shell.getSize();
    WindowLocationBean wlocation = new WindowLocationBean();
    wlocation.setX(location.x);
    wlocation.setY(location.y);
    wlocation.setWidth(size.x);
    wlocation.setHeight(size.y);
    synchronized (map) {
        map.put(clazz.getName(), wlocation);
    }
}
 
/**
 * Set the size of the given shell such that more content can be shown. The
 * shell size does not exceed {@link #DROP_DOWN_HIGHT} and
 * {@link #DROP_DOWN_WIDTH}.
 * 
 * @param shell the shell to resize
 */
private void resizeShell(final Shell shell) {
  Point size = shell.getSize();
  int currentWidth = size.x;
  int currentHeight = size.y;

  if (currentHeight >= DROP_DOWN_HIGHT && currentWidth >= DROP_DOWN_WIDTH)
    return;

  Point preferedSize = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);

  int newWidth;
  if (currentWidth >= DROP_DOWN_WIDTH) {
    newWidth = currentWidth;
  } else {
    newWidth = Math.min(Math.max(preferedSize.x, currentWidth),
        DROP_DOWN_WIDTH);
  }
  int newHeight;
  if (currentHeight >= DROP_DOWN_HIGHT) {
    newHeight = currentHeight;
  } else {
    newHeight = Math.min(Math.max(preferedSize.y, currentHeight),
        DROP_DOWN_HIGHT);
  }

  if (newHeight != currentHeight || newWidth != currentWidth) {
    shell.setRedraw(false);
    try {
      shell.setSize(newWidth, newHeight);
      if (!isLTR()) {
        Point location = shell.getLocation();
        shell.setLocation(location.x - (newWidth - currentWidth), location.y);
      }
    } finally {
      shell.setRedraw(true);
    }
  }
}
 
源代码7 项目: Pydev   文件: DialogMemento.java
/**
 * Stores it current configuration in the dialog store.
 */
public void writeSettings(Shell shell) {
    Point location = shell.getLocation();
    fSettings.put("x", location.x);
    fSettings.put("y", location.y);

    Point size = shell.getSize();
    fSettings.put("width", size.x);
    fSettings.put("height", size.y);
}
 
源代码8 项目: ldparteditor   文件: VertexWindow.java
/**
 * Places the vertex window on the 3D editor
 */
public static void placeVertexWindow() {
    final Composite3D lastHoveredC3d = DatFile.getLastHoveredComposite();
    if (lastHoveredC3d == null || Display.getDefault().getActiveShell() == null) return;

    final VertexWindow vertexWindow = Editor3DWindow.getWindow().getVertexWindow();
    final DatFile df = lastHoveredC3d.getLockableDatFileReference();
    final Set<Vertex> selectedVertices = df.getVertexManager().getSelectedVertices();
    final boolean singleVertexSelected = !df.isReadOnly() && selectedVertices.size() == 1;
    final boolean addingSomething = Editor3DWindow.getWindow().isAddingSomething();

    final boolean windowShouldBeDisplayed = singleVertexSelected && !addingSomething;

    Vertex newSelectedVertex = new Vertex(0,0,0);

    if (singleVertexSelected) {
        try {
            newSelectedVertex = selectedVertices.iterator().next();
        } catch (NoSuchElementException consumed) {}
    }

    if (windowShouldBeDisplayed && vertexWindow.getShell() == null) {
        vertexWindow.run();
        lastHoveredC3d.setFocus();
        Editor3DWindow.getWindow().getShell().setActive();
    } else if (!windowShouldBeDisplayed && vertexWindow.getShell() != null) {
        vertexWindow.close();
    }

    final Shell vertexWindowShell = vertexWindow.getShell();
    if (vertexWindowShell == null || vertexWindowShell.isDisposed()) {
        return;
    }

    if (singleVertexSelected) {
        vertexWindow.updateVertex(newSelectedVertex);
    }

    final Point old = vertexWindowShell.getLocation();
    final Point a = ShellHelper.absolutePositionOnShell(lastHoveredC3d);
    final Point s = vertexWindowShell.getSize();

    final int xPos = a.x - s.x + lastHoveredC3d.getSize().x;
    final int yPos = a.y;

    if (old.x != xPos || old.y != yPos) {
        vertexWindowShell.setLocation(xPos, yPos);
    }
}
 
/**
 * Set the size of the given shell such that more content can be shown. The shell size does not
 * exceed a user-configurable maximum.
 *
 * @param shell the shell to resize
 */
private void resizeShell(final Shell shell) {
	Point size= shell.getSize();
	int currentWidth= size.x;
	int currentHeight= size.y;

	int maxHeight= getMaxHeight();
	
	if (currentHeight >= maxHeight && currentWidth >= DROP_DOWN_MAX_WIDTH)
		return;

	Point preferedSize= shell.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);

	int newWidth;
	if (currentWidth >= DROP_DOWN_MAX_WIDTH) {
		newWidth= currentWidth;
	} else {
		newWidth= Math.min(Math.max(preferedSize.x, currentWidth), DROP_DOWN_MAX_WIDTH);
	}
	int newHeight;
	if (currentHeight >= maxHeight) {
		newHeight= currentHeight;
	} else {
		newHeight= Math.min(Math.max(preferedSize.y, currentHeight), maxHeight);
	}

	if (newHeight != currentHeight || newWidth != currentWidth) {
		shell.setRedraw(false);
		try {
			isResizingProgrammatically= true;
			shell.setSize(newWidth, newHeight);
			if (!isLTR()) {
				Point location= shell.getLocation();
				shell.setLocation(location.x - (newWidth - currentWidth), location.y);
			}
		} finally {
			isResizingProgrammatically= false;
			shell.setRedraw(true);
		}
	}
}
 
源代码10 项目: birt   文件: BreadcrumbItemDropDown.java
/**
 * Set the size of the given shell such that more content can be shown. The
 * shell size does not exceed {@link #DROP_DOWN_HIGHT} and
 * {@link #DROP_DOWN_WIDTH}.
 * 
 * @param shell
 *            the shell to resize
 */
private void resizeShell( final Shell shell )
{
	Point size = shell.getSize( );
	int currentWidth = size.x;
	int currentHeight = size.y;

	if ( currentHeight >= DROP_DOWN_HIGHT
			&& currentWidth >= DROP_DOWN_WIDTH )
		return;

	Point preferedSize = shell.computeSize( SWT.DEFAULT, SWT.DEFAULT, true );

	int newWidth;
	if ( currentWidth >= DROP_DOWN_WIDTH )
	{
		newWidth = currentWidth;
	}
	else
	{
		newWidth = Math.min( Math.max( preferedSize.x, currentWidth ),
				DROP_DOWN_WIDTH );
	}
	int newHeight;
	if ( currentHeight >= DROP_DOWN_HIGHT )
	{
		newHeight = currentHeight;
	}
	else
	{
		newHeight = Math.min( Math.max( preferedSize.y, currentHeight ),
				DROP_DOWN_HIGHT );
	}

	if ( newHeight != currentHeight || newWidth != currentWidth )
	{
		shell.setRedraw( false );
		try
		{
			shell.setSize( newWidth, newHeight );
			if ( !isLTR( ) )
			{
				Point location = shell.getLocation( );
				shell.setLocation( location.x - ( newWidth - currentWidth ),
						location.y );
			}
		}
		finally
		{
			shell.setRedraw( true );
		}
	}
}