当前位置: 首页>>代码示例>>Java>>正文


Java Shell.getSize方法代码示例

本文整理汇总了Java中org.eclipse.swt.widgets.Shell.getSize方法的典型用法代码示例。如果您正苦于以下问题:Java Shell.getSize方法的具体用法?Java Shell.getSize怎么用?Java Shell.getSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.swt.widgets.Shell的用法示例。


在下文中一共展示了Shell.getSize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setLocation

import org.eclipse.swt.widgets.Shell; //导入方法依赖的package包/类
/**
 * 
 */
protected void setLocation(final XCalendar popup) {
	//
	final Shell shell = popup.getShell();
	final Display display = popup.getDisplay();
	final Rectangle r1 = display.map(prevParent, null, prevBounds);
	final Rectangle r2 = popup.getMonitor().getClientArea(); // Client area
	
	//
	final int margin = 2;
	final Point size = shell.getSize();
	int x = r1.x, y = r1.y + r1.height + margin;
	if(y + size.y > r2.y + r2.height) y = r1.y - size.y - margin;
	if(x < r2.x) x = r2.x; else if(x + size.x > r2.x + r2.width) x = r2.x + r2.width - size.x;
	shell.setLocation(x, y);
}
 
开发者ID:nextopcn,项目名称:xcalendar,代码行数:19,代码来源:XCalendarDefaultLayout.java

示例2: handleAdvancedButtonSelect

import org.eclipse.swt.widgets.Shell; //导入方法依赖的package包/类
/**
 * Shows/hides the advanced option widgets.
 */
protected void handleAdvancedButtonSelect() {
	Shell shell = getShell();
	Point shellSize = shell.getSize();
	Composite composite = (Composite) getControl();

	if (linkedResourceComposite != null) {
		linkedResourceComposite.dispose();
		linkedResourceComposite = null;
		composite.layout();
		shell.setSize(shellSize.x, shellSize.y - linkedResourceGroupHeight);
		advancedButton.setText(IDEWorkbenchMessages.showAdvanced);
	} else {
		linkedResourceComposite = linkedResourceGroup
				.createContents(linkedResourceParent);
		setupLinkedResourceTarget();
		if (linkedResourceGroupHeight == -1) {
			Point groupSize = linkedResourceComposite.computeSize(
					SWT.DEFAULT, SWT.DEFAULT, true);
			linkedResourceGroupHeight = groupSize.y;
		}
		shell.setSize(shellSize.x, shellSize.y + linkedResourceGroupHeight);
		composite.layout();
		advancedButton.setText(IDEWorkbenchMessages.hideAdvanced);
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:29,代码来源:WizardNewFileCreationPage.java

示例3: center

import org.eclipse.swt.widgets.Shell; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:AppleCommander,项目名称:AppleCommander,代码行数:13,代码来源:SwtUtil.java

示例4: center

import org.eclipse.swt.widgets.Shell; //导入方法依赖的package包/类
private void center(Shell shell) {

		Shell parent = (Shell) shell.getParent();
		Rectangle bounds = parent.getBounds();
		Point size = shell.getSize();

		int x = bounds.x + bounds.width / 2 - size.x / 2;
		int y = bounds.y + bounds.height / 2 - size.y / 2;
		// System.err.println("ChoiceDialog: center: x=" + x + " y=" + y);
		shell.setLocation(x, (y < 0) ? 0 : y);
	}
 
开发者ID:sergueik,项目名称:SWET,代码行数:12,代码来源:ChoicesDialog.java

示例5: saveDialogBounds

import org.eclipse.swt.widgets.Shell; //导入方法依赖的package包/类
/**
 * 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);

		}
	}
}
 
开发者ID:sergueik,项目名称:SWET,代码行数:42,代码来源:PopupDialog.java

示例6: performPostDialogCreation

import org.eclipse.swt.widgets.Shell; //导入方法依赖的package包/类
@Override
public void performPostDialogCreation() {
	// mods jmc 26/07/2013
			
	int nWidth;
	int nHeight;
	int nLeft = 0;
	int nTop = 0;
	 
	Shell newShell = this.parentDialog.getShell();

	// mods jmc 22/10/2013
	nWidth = (int) (0.50 * newShell.getSize().x);
	nHeight = (int) (0.60 * newShell.getSize().y);
	Display display = newShell.getDisplay();
	
	Point pt = display.getCursorLocation();
    Monitor [] monitors = display.getMonitors();

    for (int i= 0; i<monitors.length; i++) {
          if (monitors[i].getBounds().contains(pt)) {
             Rectangle rect = monitors[i].getClientArea();
             
             if (rect.x < 0)
         		nLeft = ((rect.width - nWidth) / 2) + rect.x;
             else
         		nLeft = (rect.width - nWidth) / 2;

             if (rect.y < 0)
         		nTop = ((rect.height - nHeight) / 2) + rect.y;
             else
         		nTop = (rect.height - nHeight) / 2;
             
             break;
          }
    }

    newShell.setBounds(nLeft, nTop, nWidth, nHeight);
	
	super.performPostDialogCreation();
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:42,代码来源:SqlQueryEditorComposite.java

示例7: resize

import org.eclipse.swt.widgets.Shell; //导入方法依赖的package包/类
public static void resize(Shell shell, @Nullable Integer width, @Nullable Integer height) {
	final Point s = shell.getSize();
	int w = width == null ? s.x : width, h = height == null ? s.y : height; shell.setSize(new Point(w, h));
}
 
开发者ID:nextopcn,项目名称:xcalendar,代码行数:5,代码来源:SwtUtils.java


注:本文中的org.eclipse.swt.widgets.Shell.getSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。