org.eclipse.swt.widgets.Button.getFont()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(152)

本文整理了Java中org.eclipse.swt.widgets.Button.getFont()方法的一些代码示例,展示了Button.getFont()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Button.getFont()方法的具体详情如下:
包路径:org.eclipse.swt.widgets.Button
类名称:Button
方法名:getFont

Button.getFont介绍

暂无

代码示例

代码示例来源: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.rap/org.eclipse.rap.jface

/**
 * Set the GridData on button to be one that is spaced for the
 * current font.
 * @param button the button the data is being set on.
 */
protected void setButtonLayoutData(Button button) {
  GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
  // Compute and store a font metric
  GC gc = new GC(button);
  gc.setFont(button.getFont());
  FontMetrics fontMetrics = gc.getFontMetrics();
  gc.dispose();
  int widthHint = org.eclipse.jface.dialogs.Dialog
      .convertVerticalDLUsToPixels(fontMetrics,
          IDialogConstants.BUTTON_WIDTH);
  data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT,
      SWT.DEFAULT, true).x);
  button.setLayoutData(data);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface

/**
 * Set the GridData on button to be one that is spaced for the
 * current font.
 * @param button the button the data is being set on.
 */
protected void setButtonLayoutData(Button button) {
  GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
  // Compute and store a font metric
  GC gc = new GC(button);
  gc.setFont(button.getFont());
  FontMetrics fontMetrics = gc.getFontMetrics();
  gc.dispose();
  int widthHint = org.eclipse.jface.dialogs.Dialog
      .convertVerticalDLUsToPixels(fontMetrics,
          IDialogConstants.BUTTON_WIDTH);
  data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT,
      SWT.DEFAULT, true).x);
  button.setLayoutData(data);
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface

/**
 * Set the GridData on button to be one that is spaced for the
 * current font.
 * @param button the button the data is being set on.
 */
protected void setButtonLayoutData(Button button) {
  GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
  // Compute and store a font metric
  GC gc = new GC(button);
  gc.setFont(button.getFont());
  FontMetrics fontMetrics = gc.getFontMetrics();
  gc.dispose();
  int widthHint = org.eclipse.jface.dialogs.Dialog
      .convertVerticalDLUsToPixels(fontMetrics,
          IDialogConstants.BUTTON_WIDTH);
  data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT,
      SWT.DEFAULT, true).x);
  button.setLayoutData(data);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench

private GridData setButtonLayoutData(Button button) {
    button.setFont(JFaceResources.getDialogFont());

    GC gc = new GC(button);
    gc.setFont(button.getFont());
    FontMetrics fontMetrics = gc.getFontMetrics();
    gc.dispose();

    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: oyse/yedit

/**
 * Returns a height hint for a button control.
 * @deprecated
 * @see IDialogConstants#BUTTON_HEIGHT
 */     
@Deprecated
public static int getButtonHeigthHint(Button button) {
  if (button.getFont().equals(JFaceResources.getDefaultFont()))
    button.setFont(JFaceResources.getDialogFont());
  PixelConverter converter= new PixelConverter(button);
  return converter.convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
}

代码示例来源:origin: org.eclipse.pde/org.eclipse.pde.ui

/**
 * Returns a width hint for a button control.
 */
public static int getButtonWidthHint(Button button) {
  if (button.getFont().equals(JFaceResources.getDefaultFont()))
    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: oyse/yedit

/**
 * Returns a width hint for a button control.
 */
public static int getButtonWidthHint(Button button) {
  if (button.getFont().equals(JFaceResources.getDefaultFont()))
    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.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);
  }
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt

private void createFontStyleGroup( Composite parent ) {
 Display display = getDisplay();
 Group result = new Group( parent, SWT.NONE );
 result.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
 result.setText( RWTMessages.getMessage( "RWT_FontDialogFontStyleTitle" ) );
 GridLayout layout = new GridLayout();
 layout.marginWidth = 0;
 layout.marginHeight = 0;
 result.setLayout( layout );
 cbBold = new Button( result, SWT.CHECK );
 cbBold.setText( RWTMessages.getMessage( "RWT_FontDialogFontStyleBold" ) );
 FontData normalFont = cbBold.getFont().getFontData()[ 0 ];
 Font boldFont = new Font( display, normalFont.getName(), normalFont.getHeight(), SWT.BOLD );
 cbBold.setFont( boldFont );
 cbItalic = new Button( result, SWT.CHECK );
 cbItalic.setText( RWTMessages.getMessage( "RWT_FontDialogFontStyleItalic" ) );
 Font italicFont = new Font( display, normalFont.getName(), normalFont.getHeight(), SWT.ITALIC );
 cbItalic.setFont( italicFont );
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide

private static int getButtonWidthHint(Button button) {
  button.setFont(JFaceResources.getDialogFont());
  FontMetrics fontMetrics;
  GC gc = new GC(button);
  try {
    gc.setFont(button.getFont());
    fontMetrics = gc.getFontMetrics();
  } finally {
    gc.dispose();
  }
  int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics,
      IDialogConstants.BUTTON_WIDTH);
  return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT,
      true).x);
}

代码示例来源:origin: com.github.rinde/rinsim-example

runButton.setText(START_DEMO_TEXT);
final Font f = runButton.getFont();
final FontData[] fontData = f.getFontData();
for (int i = 0; i < fontData.length; i++) {

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt

boolean hasImage = image != null;
boolean hasText = text.length() > 0;
Font font = getFont();
if( ( style & ( SWT.CHECK | SWT.RADIO ) ) != 0 ) {
 Size checkSize = themeAdapter.getCheckSize( this );

代码示例来源:origin: rinde/RinSim

runButton.setText(START_DEMO_TEXT);
final Font f = runButton.getFont();
final FontData[] fontData = f.getFontData();
for (int i = 0; i < fontData.length; i++) {

代码示例来源:origin: org.eclipse.swt.cocoa.macosx/x86_64

cell.setControlSize(OS.NSSmallControlSize);
setFont(getFont());

代码示例来源:origin: BiglySoftware/BiglyBT

fontButton = FontUtils.getFontPercentOf(button.getFont(), 0.8f);

相关文章

Button类方法