本文整理匯總了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);
}