/**
* Given the desired position of the window, this method returns an adjusted
* position such that the window is no larger than its monitor, and does not
* extend beyond the edge of the monitor. This is used for computing the
* initial window position, and subclasses can use this as a utility method
* if they want to limit the region in which the window may be moved.
*
* @param preferredSize
* the preferred position of the window
* @return a rectangle as close as possible to preferredSize that does not
* extend outside the monitor
*
* @since 3.0
*/
protected Rectangle getConstrainedShellBounds(Rectangle preferredSize) {
Rectangle result = new Rectangle(preferredSize.x, preferredSize.y,
preferredSize.width, preferredSize.height);
Monitor mon = getClosestMonitor(getShell().getDisplay(), Geometry
.centerPoint(result));
Rectangle bounds = mon.getClientArea();
if (result.height > bounds.height) {
result.height = bounds.height;
}
if (result.width > bounds.width) {
result.width = bounds.width;
}
result.x = Math.max(bounds.x, Math.min(result.x, bounds.x
+ bounds.width - result.width));
result.y = Math.max(bounds.y, Math.min(result.y, bounds.y
+ bounds.height - result.height));
return result;
}
Window.java 文件源码
java
阅读 29
收藏 0
点赞 0
评论 0
项目:gef-gwt
作者:
评论列表
文章目录