本文整理汇总了Java中org.eclipse.swt.widgets.Control.computeSize方法的典型用法代码示例。如果您正苦于以下问题:Java Control.computeSize方法的具体用法?Java Control.computeSize怎么用?Java Control.computeSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.widgets.Control
的用法示例。
在下文中一共展示了Control.computeSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeSize
import org.eclipse.swt.widgets.Control; //导入方法依赖的package包/类
@Override
protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
int width = 0;
int height = 0;
Point textDimension = textDimensions();
Control[] children = composite.getChildren();
for (Control child : children) {
if (child instanceof Text) {
final String textContent = ((Text) child).getText();
textDimension = gc.textExtent(textContent);
width += textDimension.x;
height += textDimension.y;
}
if (child instanceof Label) {
Point computedSize = child.computeSize(0, 0);
width += computedSize.x;
}
}
return new Point(width, height + 4);
}
示例2: createContents
import org.eclipse.swt.widgets.Control; //导入方法依赖的package包/类
@Override
protected Control createContents(Composite parent) {
Control control = super.createContents(parent);
/* set the shell minimum size */
Point clientArea = control.computeSize(SWT.DEFAULT, SWT.DEFAULT);
Rectangle trim = getShell().computeTrim(0, 0, clientArea.x, clientArea.y);
getShell().setMinimumSize(trim.width, trim.height);
return control;
}
示例3: setButtonLayoutData
import org.eclipse.swt.widgets.Control; //导入方法依赖的package包/类
protected void setButtonLayoutData(FontMetrics metrics, Control button,
boolean visible) {
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
int widthHint = Dialog.convertHorizontalDLUsToPixels(metrics,
IDialogConstants.BUTTON_WIDTH);
Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
data.widthHint = Math.max(widthHint, minSize.x);
data.exclude = !visible;
button.setLayoutData(data);
}