本文整理了Java中org.eclipse.swt.widgets.Shell.getMonitor()
方法的一些代码示例,展示了Shell.getMonitor()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Shell.getMonitor()
方法的具体详情如下:
包路径:org.eclipse.swt.widgets.Shell
类名称:Shell
方法名:getMonitor
暂无
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples
/**
* Sets the size of the shell to it's "packed" size,
* unless that makes it larger than the monitor it is being displayed on,
* in which case just set the shell size to be slightly smaller than the monitor.
*/
static void setShellSize(ControlExample instance, Shell shell) {
Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
Rectangle monitorArea = shell.getMonitor().getClientArea();
shell.setSize(Math.min(size.x, monitorArea.width), Math.min(size.y, monitorArea.height));
}
}
代码示例来源:origin: org.eclipse.pde/org.eclipse.pde.runtime
@Override
protected Point getInitialLocation(Point size) {
if (fAnchor == null) {
return super.getInitialLocation(size);
}
Point point = fAnchor;
Rectangle monitor = getShell().getMonitor().getClientArea();
if (monitor.width < point.x + size.x) {
point.x = Math.max(0, point.x - size.x);
}
if (monitor.height < point.y + size.y) {
point.y = Math.max(0, point.y - size.y);
}
return point;
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.debug.ui
/**
* Increase the size of this dialog's <code>Shell</code> by the specified amounts.
* Do not increase the size of the Shell beyond the bounds of the Display.
*/
protected void setShellSize(int width, int height) {
Rectangle bounds = getShell().getMonitor().getBounds();
getShell().setSize(Math.min(width, bounds.width), Math.min(height, bounds.height));
}
代码示例来源:origin: org.eclipse.pde/org.eclipse.pde.runtime
@Override
protected Point getInitialLocation(Point size) {
if (fAnchor == null) {
return super.getInitialLocation(size);
}
Point point = fAnchor;
Rectangle monitor = getShell().getMonitor().getClientArea();
if (monitor.width < point.x + size.x) {
point.x = Math.max(0, point.x - size.x);
}
if (monitor.height < point.y + size.y) {
point.y = Math.max(0, point.y - size.y);
}
return point;
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.debug.ui
/**
* Returns the initial location to use for the shell based upon the
* current selection in the viewer. Bottom is preferred to top, and
* right is preferred to left, therefore if possible the popup will
* be located below and to the right of the selection.
*
* @param initialSize
* the initial size of the shell, as returned by
* <code>getInitialSize</code>.
* @return the initial location of the shell
*/
@Override
protected Point getInitialLocation(Point initialSize) {
if (fAnchor == null) {
return super.getInitialLocation(initialSize);
}
Point point = fAnchor;
Rectangle monitor = getShell().getMonitor().getClientArea();
if (monitor.width < point.x + initialSize.x) {
point.x = Math.max(0, point.x - initialSize.x);
}
if (monitor.height < point.y + initialSize.y) {
point.y = Math.max(0, point.y - initialSize.y);
}
return point;
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.ppc
label.setText(text);
GridData data = new GridData();
Monitor monitor = parent.getMonitor();
int maxWidth = monitor.getBounds().width * 2 / 3;
int width = label.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.s390x
label.setText(text);
GridData data = new GridData();
Monitor monitor = parent.getMonitor();
int maxWidth = monitor.getBounds().width * 2 / 3;
int width = label.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
代码示例来源:origin: org.eclipse.swt.cocoa.macosx/x86_64
label.setText(text);
GridData data = new GridData();
Monitor monitor = parent.getMonitor();
int maxWidth = monitor.getBounds().width * 2 / 3;
int width = label.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.swt.win32.win32.x86
label.setText(text);
GridData data = new GridData();
Monitor monitor = parent.getMonitor();
int maxWidth = monitor.getBounds().width * 2 / 3;
int width = label.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
代码示例来源:origin: org.eclipse/org.eclipse.ltk.ui.refactoring
Shell shell= getShell();
Rectangle rect= shell.getBounds();
Rectangle clientRect= shell.getMonitor().getClientArea();
rect.x= Math.max(clientRect.x, rect.x - dx);
rect.y= Math.max(clientRect.y, rect.y - dy);
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.swt.win32.win32.x86
Monitor monitor = parent.getMonitor ();
int maxWidth = monitor.getBounds().width * 2 / 3;
int width = label.computeSize (SWT.DEFAULT, SWT.DEFAULT).x;
代码示例来源:origin: org.eclipse.swt.cocoa.macosx/x86_64
void updateSystemUIMode () {
if ((window.collectionBehavior() & OS.NSWindowCollectionBehaviorFullScreenPrimary) != 0) return;
if (!getMonitor ().equals (display.getPrimaryMonitor ())) return;
int mode = display.systemUIMode, options = display.systemUIOptions;
if (fullScreen) {
mode = OS.kUIModeAllHidden;
if (menuBar != null) {
mode = OS.kUIModeContentHidden;
}
options = 0;
}
int[] uiMode = new int[1], uiOptions = new int[1];
OS.GetSystemUIMode(uiMode, uiOptions);
if (uiMode[0] != mode || uiOptions[0] != options) OS.SetSystemUIMode (mode, options);
if (fullScreen) window.setFrame(fullScreenFrame, true);
}
代码示例来源:origin: BiglySoftware/BiglyBT
displayBounds = shell.getMonitor().getBounds();
代码示例来源:origin: BiglySoftware/BiglyBT
public static void centreWindow(Shell shell, boolean shrink_if_needed) {
Rectangle centerInArea; // area to center in
Rectangle displayArea;
try {
displayArea = shell.getMonitor().getClientArea();
} catch (NoSuchMethodError e) {
displayArea = shell.getDisplay().getClientArea();
}
if (shell.getParent() != null) {
centerInArea = shell.getParent().getBounds();
} else {
centerInArea = displayArea;
}
Rectangle shellRect = shell.getBounds();
if ( shrink_if_needed ){
if (shellRect.height > displayArea.height) {
shellRect.height = displayArea.height;
}
if (shellRect.width > displayArea.width - 50) {
shellRect.width = displayArea.width;
}
}
shellRect.x = centerInArea.x + (centerInArea.width - shellRect.width) / 2;
shellRect.y = centerInArea.y + (centerInArea.height - shellRect.height) / 2;
shell.setBounds(shellRect);
}
代码示例来源:origin: BiglySoftware/BiglyBT
displayArea = parent_shell.getMonitor().getClientArea();
代码示例来源:origin: org.eclipse.mylyn.commons/workbench
.getActiveWorkbenchWindow()
.getShell()
.getMonitor()
.getClientArea();
Rectangle bounds = getShell().getBounds();
代码示例来源:origin: org.xworker/xworker_swt
/**
* 根据一个控件的位置和大小设置弹出窗口的位置。
*
* @param shell 要弹出的窗口
* @param relateLocation 控件的location
* @param relateSize 控件的大小
*/
public static void setShellRelateLocation(Shell shell, Point relateLocation, Point relateSize){
Point point = relateLocation;
Rectangle shellRect = shell.getBounds();
Monitor monitor = shell.getMonitor();
int clientHeight = monitor.getClientArea().height;
int clientWidth = monitor.getClientArea().width;
int width = shellRect.width;
int height = shellRect.height;
Point x = getRelateWidth(width, clientWidth, point.x, point.x + relateSize.x);
Point y = getRelateHeight(height, clientHeight, point.y, point.y + relateSize.y);
shell.setLocation(x.y, y.y);
shell.setSize(x.x, y.x);
}
代码示例来源:origin: infinitest/infinitest
private void sizeDialog(final Shell dialog) {
dialog.pack();
Monitor monitor = dialog.getShell().getMonitor();
if (monitor != null) {
if (dialog.getSize().x > monitor.getClientArea().width) {
dialog.setSize(monitor.getClientArea().width, dialog.getSize().y);
}
if (dialog.getSize().y > monitor.getClientArea().height) {
dialog.setSize(dialog.getSize().x, monitor.getClientArea().height);
}
}
dialog.layout();
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
private void adjustHeight(StyledText text) {
int lineCount = text.getLineCount();
int lineHeight = text.getLineHeight();
int startPos = text.getLocation().y;
Composite c = text.getParent();
while (c != null) {
startPos += c.getLocation().y;
c = c.getParent();
}
// the text is not positioned yet, we assume that it will appear
// on the bottom of the dialog
startPos += text.getShell().getBounds().height;
int screenHeight = text.getShell().getMonitor().getBounds().height;
int availableScreenForText = screenHeight - startPos;
if (availableScreenForText <= MINIMUM_HEIGHT) {
// should not happen. But in that case nothing can improve user
// experience.
return;
}
int desiredHeight = lineCount * lineHeight;
if (desiredHeight > availableScreenForText * 0.75) {
((GridData) text.getLayoutData()).heightHint = (int) (availableScreenForText * 0.75);
}
}
代码示例来源:origin: BiglySoftware/BiglyBT
Rectangle monitorClientArea = shell.getMonitor().getClientArea();
Rectangle trimmedShellBounds = shellBounds.intersection(monitorClientArea);
内容来源于网络,如有侵权,请联系作者删除!