本文整理了Java中org.eclipse.swt.widgets.Button.computeSize()
方法的一些代码示例,展示了Button.computeSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Button.computeSize()
方法的具体详情如下:
包路径:org.eclipse.swt.widgets.Button
类名称:Button
方法名:computeSize
暂无
代码示例来源:origin: pentaho/pentaho-kettle
void layout() {
Composite parent = canvas.getParent();
Rectangle rect = parent.getClientArea();
int width = 0;
String[] items = list.getItems();
GC gc = new GC( list );
for ( int i = 0; i < objects.length; i++ ) {
width = Math.max( width, gc.stringExtent( items[i] ).x );
}
gc.dispose();
Point size1 = start.computeSize( SWT.DEFAULT, SWT.DEFAULT );
Point size2 = stop.computeSize( SWT.DEFAULT, SWT.DEFAULT );
Point size3 = check.computeSize( SWT.DEFAULT, SWT.DEFAULT );
Point size4 = label.computeSize( SWT.DEFAULT, SWT.DEFAULT );
width = Math.max( size1.x, Math.max( size2.x, Math.max( size3.x, width ) ) );
width = Math.max( 64, Math.max( size4.x, list.computeSize( width, SWT.DEFAULT ).x ) );
start.setBounds( 0, 0, width, size1.y );
stop.setBounds( 0, size1.y, width, size2.y );
check.setBounds( 0, size1.y + size2.y, width, size3.y );
label.setBounds( 0, rect.height - size4.y, width, size4.y );
int height = size1.y + size2.y + size3.y;
list.setBounds( 0, height, width, rect.height - height - size4.y );
text.setBounds( width, 0, rect.width - width, rect.height );
canvas.setBounds( width, 0, rect.width - width, rect.height );
}
代码示例来源:origin: pentaho/pentaho-kettle
wbBrowse.setText( BaseMessages.getString( PKG, "System.Button.Browse" ) );
wbBrowse.addListener( SWT.Selection, event -> browseForFileInputPath() );
int bOffset = ( wbBrowse.computeSize( SWT.DEFAULT, SWT.DEFAULT, false ).y
- wPath.computeSize( SWT.DEFAULT, SWT.DEFAULT, false ).y ) / 2;
wbBrowse.setLayoutData( new FormDataBuilder().left( wPath, FIELD_LABEL_SEP ).top( wlPath, FIELD_LABEL_SEP - bOffset ).result() );
代码示例来源:origin: pentaho/pentaho-kettle
editor.grabVertical = false;
Point size = button.computeSize( SWT.DEFAULT, SWT.DEFAULT );
editor.minimumWidth = size.x;
editor.minimumHeight = size.y - 2;
代码示例来源:origin: org.apache.uima/ruta-ep-ide-ui
protected void setButtonLayoutData(Button button) {
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
int widthHint = 80;
Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
data.widthHint = Math.max(widthHint, minSize.x);
button.setLayoutData(data);
}
代码示例来源:origin: org.eclipse/org.eclipse.wst.server.ui
/**
* Returns a width hint for a button control.
*/
protected static int getButtonWidthHint(Button button) {
int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH);
return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
}
代码示例来源:origin: org.eclipse/org.eclipse.jdt.debug.ui
private GridData getButtonGridData(Button button, FontMetrics fontMetrics) {
GridData gd= new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
int widthHint= Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH);
gd.widthHint= Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
return gd;
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
private GridData setButtonLayoutData(Button button, FontMetrics fontMetrics) {
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH);
Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
data.widthHint = Math.max(widthHint, minSize.x);
button.setLayoutData(data);
return data;
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
/**
* Status dialog button should be aligned SWT.END.
*/
@Override
protected void setButtonLayoutData(Button button) {
GridData data = new GridData(SWT.END, SWT.CENTER, false, false);
int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
data.widthHint = Math.max(widthHint, minSize.x);
button.setLayoutData(data);
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.jface
@Override
protected void setButtonLayoutData(Button button) {
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
// On large fonts this can make this dialog huge
widthHint = Math.min(widthHint,
button.getDisplay().getBounds().width / 5);
Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
data.widthHint = Math.max(widthHint, minSize.x);
button.setLayoutData(data);
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface
@Override
protected void doFillIntoGrid(Composite parent, int numColumns) {
super.doFillIntoGrid(parent, numColumns - 1);
changeButton = getChangeControl(parent);
GridData gd = new GridData();
gd.horizontalAlignment = GridData.FILL;
int widthHint = convertHorizontalDLUsToPixels(changeButton,
IDialogConstants.BUTTON_WIDTH);
gd.widthHint = Math.max(widthHint, changeButton.computeSize(
SWT.DEFAULT, SWT.DEFAULT, true).x);
changeButton.setLayoutData(gd);
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.team.ui
protected Button createButton(Composite parent, String label, int style) {
Button button = new Button(parent, SWT.PUSH);
button.setText(label);
// we need to explicitly set the font to the parent's font for dialogs
button.setFont(parent.getFont());
GridData data = new GridData(style);
data.heightHint = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_HEIGHT);
int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH);
data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
button.setLayoutData(data);
return button;
}
代码示例来源:origin: org.eclipse.pde/org.eclipse.pde.ui
/**
* Returns a width hint for a button control.
*/
public static int getButtonWidthHint(Button button) {
button.setFont(JFaceResources.getDialogFont());
PixelConverter converter = new PixelConverter(button);
int widthHint = converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
}
代码示例来源:origin: org.eclipse.equinox.p2/ui
private void setButtonLayoutData(Button button) {
GridData data = new GridData(SWT.FILL, SWT.CENTER, false, false);
GC gc = new GC(button);
gc.setFont(JFaceResources.getDialogFont());
FontMetrics fm = gc.getFontMetrics();
gc.dispose();
int widthHint = Dialog.convertHorizontalDLUsToPixels(fm, IDialogConstants.BUTTON_WIDTH);
Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
data.widthHint = Math.max(widthHint, minSize.x);
button.setLayoutData(data);
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench.texteditor
/**
* Returns a width hint for the given button.
*
* @param button the button
* @return the width hint for the button
*/
public static int getButtonWidthHint(Button button) {
button.setFont(JFaceResources.getDialogFont());
PixelConverter converter= new PixelConverter(button);
int widthHint= converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.workbench.texteditor
/**
* Returns a width hint for the given button.
*
* @param button the button
* @return the width hint for the button
*/
public static int getButtonWidthHint(Button button) {
button.setFont(JFaceResources.getDialogFont());
PixelConverter converter= new PixelConverter(button);
int widthHint= converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
}
代码示例来源:origin: org.eclipse/org.eclipse.jdt.debug.ui
private static GridData getButtonGridData(Button button) {
GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
GC gc = new GC(button);
gc.setFont(button.getFont());
FontMetrics fontMetrics = gc.getFontMetrics();
gc.dispose();
int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH);
gd.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
return gd;
}
代码示例来源:origin: org.eclipse/org.eclipse.jst.pagedesigner
public void layout(Composite editor, boolean force) {
Rectangle bounds = editor.getClientArea();
Point size = _button.computeSize(SWT.DEFAULT, SWT.DEFAULT, force);
// if (_wrapped != null)
_wrapped.getControl().setBounds(0, 0, bounds.width - size.x,
bounds.height);
_button.setBounds(bounds.width - size.x, 0, size.x, bounds.height);
}
代码示例来源:origin: org.eclipse.swt.cocoa.macosx/x86_64
void internalLayout (boolean changed) {
if (isDropped ()) dropDown (false);
Rectangle rect = getClientArea ();
int width = rect.width;
int height = rect.height;
Point arrowSize = arrow.computeSize (SWT.DEFAULT, height, changed);
text.setBounds (0, 0, width - arrowSize.x, height);
arrow.setBounds (width - arrowSize.x, 0, arrowSize.x, arrowSize.y);
}
void listEvent (Event event) {
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.swt.win32.win32.x86
void internalLayout (boolean changed) {
if (isDropped ()) dropDown (false);
Rectangle rect = getClientArea ();
int width = rect.width;
int height = rect.height;
Point arrowSize = arrow.computeSize (SWT.DEFAULT, height, changed);
text.setBounds (0, 0, width - arrowSize.x, height);
arrow.setBounds (width - arrowSize.x, 0, arrowSize.x, arrowSize.y);
}
void listEvent (Event event) {
代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui
private static int getButtonWidthHint(Button button) {
button.setFont(JFaceResources.getDialogFont());
GC gc = new GC(button);
gc.setFont(button.getFont());
FontMetrics fontMetrics= gc.getFontMetrics();
gc.dispose();
int widthHint= Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH);
return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
}
}
内容来源于网络,如有侵权,请联系作者删除!