本文整理汇总了Java中com.google.gwt.user.client.ui.Widget.getOffsetHeight方法的典型用法代码示例。如果您正苦于以下问题:Java Widget.getOffsetHeight方法的具体用法?Java Widget.getOffsetHeight怎么用?Java Widget.getOffsetHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.user.client.ui.Widget
的用法示例。
在下文中一共展示了Widget.getOffsetHeight方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPreferredSizeOfDetachedWidget
import com.google.gwt.user.client.ui.Widget; //导入方法依赖的package包/类
/**
* Returns the preferred size of the specified widget,
* in an array of the form {@code [width, height]}.
* <p>
* It is assumed that:
* <ul>
* <li>{@code w} has no parent</li>
* <li>{@code w} has not been configured to be invisible</li>
* </ul>
*/
public static int[] getPreferredSizeOfDetachedWidget(Widget w) {
// Attach the widget to the DOM, so that its preferred size is calculated correctly
RootPanel.get().add(w);
String[] style = clearSizeStyle(w);
int width = w.getOffsetWidth() + 4;
int height = w.getOffsetHeight();
restoreSizeStyle(w, style);
// Detach the widget from the DOM before returning
RootPanel.get().remove(w);
return new int[] { width, height };
}
示例2: toRectangle
import com.google.gwt.user.client.ui.Widget; //导入方法依赖的package包/类
private Rectangle toRectangle(Widget widget) {
return new Rectangle(widget.getAbsoluteLeft(), widget.getAbsoluteTop(), widget.getOffsetWidth(), widget.getOffsetHeight());
}
示例3: isInside
import com.google.gwt.user.client.ui.Widget; //导入方法依赖的package包/类
/**
* Returns whether the specified widget contains a position given
* by the absolute coordinates.
*
* @param w widget to test
* @param absX absolute x coordinate of position
* @param absY absolute y coordinate of position
* @return {@code true} if the position is within the widget, {@code false}
* otherwise
*/
private static boolean isInside(Widget w, int absX, int absY) {
int wx = w.getAbsoluteLeft();
int wy = w.getAbsoluteTop();
int ww = w.getOffsetWidth();
int wh = w.getOffsetHeight();
return (wx <= absX) && (absX < wx + ww) && (wy <= absY) && (absY < wy + wh);
}