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

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

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

Button.getAlignment介绍

[英]Returns a value which describes the position of the text or image in the receiver. The value will be one of LEFT, RIGHT or CENTER unless the receiver is an ARROW button, in which case, the alignment will indicate the direction of the arrow (one of LEFT, RIGHT, UP or DOWN).
[中]返回一个值,该值描述文本或图像在接收器中的位置。除非接收器是ARROW按钮,否则该值将是LEFTRIGHTCENTER中的一个,在这种情况下,对齐将指示箭头的方向(LEFTRIGHTUPDOWN中的一个)。

代码示例

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

private static String getAlignment( Button button ) {
 int alignment = button.getAlignment();
 String result;
 if( ( alignment & SWT.LEFT ) != 0 ) {
  result = "left";
 } else if( ( alignment & SWT.CENTER ) != 0 ) {
  result = "center";
 } else if( ( alignment & SWT.RIGHT ) != 0 ) {
  result = "right";
 } else if( ( alignment & SWT.UP ) != 0 ) {
  result = "up";
 } else if( ( alignment & SWT.DOWN ) != 0 ) {
  result = "down";
 } else {
  result = "left";
 }
 return result;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.e4.ui.css.swt

@Override
  public String retrieveCSSProperty(Control control, String property,
      String pseudo, CSSEngine engine) throws Exception {
    if (control instanceof Button) {
      Button button = (Button)control;
      switch(button.getAlignment()){
      case SWT.RIGHT: return "right";  //Note same value as SWT.TRAIL
      case SWT.LEFT: return "left";  //Note same value as SWT.LEAD
      case SWT.CENTER: return "center";
      case SWT.UP: return "up";
      case SWT.DOWN: return "down";
      }
    }
    else if (control instanceof Label) {
      Label label = (Label)control;
      switch(label.getAlignment()){
      case SWT.RIGHT: return "right";  //Note same value as SWT.TRAIL
      case SWT.LEFT: return "left";  //Note same value as SWT.LEAD
      case SWT.CENTER: return "center";
      }
    }
    return null;
  }
}

代码示例来源:origin: org.eclipse.e4.ui.css/swt

public String retrieveCSSProperty(Control control, String property,
      String pseudo, CSSEngine engine) throws Exception {
    if (control instanceof Button) {
      Button button = (Button)control;
      switch(button.getAlignment()){
      case SWT.RIGHT: return "right";  //Note same value as SWT.TRAIL
      case SWT.LEFT: return "left";  //Note same value as SWT.LEAD
      case SWT.CENTER: return "center";
      case SWT.UP: return "up";
      case SWT.DOWN: return "down";
      }
    }
    else if (control instanceof Label) {
      Label label = (Label)control;
      switch(label.getAlignment()){
      case SWT.RIGHT: return "right";  //Note same value as SWT.TRAIL
      case SWT.LEFT: return "left";  //Note same value as SWT.LEAD
      case SWT.CENTER: return "center";
      }
    }
    return null;
  }
}

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

static void writeAlignment( final Button button ) throws IOException {
 if( ( button.getStyle() & SWT.ARROW ) == 0 ) {
  Integer newValue = new Integer( button.getAlignment() );
  Integer defValue = DEFAULT_ALIGNMENT;
  if( WidgetLCAUtil.hasChanged( button, PROP_ALIGNMENT, newValue, defValue ) )
  {
   JSWriter writer = JSWriter.getWriterFor( button );
   String value;
   switch( newValue.intValue() ) {
    case SWT.LEFT:
     value = "left";
    break;
    case SWT.CENTER:
     value = "center";
    break;
    case SWT.RIGHT:
     value = "right";
    break;
    default:
     value = "left";
    break;
   }
   writer.set( JS_PROP_HORIZONTAL_CHILDREN_ALIGN, value );
  }
 }
}

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

static void preserveValues( final Button button ) {
 ControlLCAUtil.preserveValues( button );
 IWidgetAdapter adapter = WidgetUtil.getAdapter( button );
 adapter.preserve( Props.TEXT, button.getText() );
 adapter.preserve( Props.IMAGE, button.getImage() );
 adapter.preserve( PROP_SELECTION,
          Boolean.valueOf( button.getSelection() ) );
 adapter.preserve( PROP_SELECTION_LISTENERS,
          Boolean.valueOf( SelectionEvent.hasListener( button ) ) );
 adapter.preserve( PROP_ALIGNMENT, new Integer( button.getAlignment() ) );
 boolean hasListeners = SelectionEvent.hasListener( button );
 adapter.preserve( Props.SELECTION_LISTENERS,
          Boolean.valueOf( hasListeners ) );
 WidgetLCAUtil.preserveCustomVariant( button );
}

相关文章

Button类方法