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

x33g5p2x  于2022-02-02 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(135)

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

Widget.getStyle介绍

[英]Returns the receiver's style information.

Note that the value which is returned by this method may not match the value which was provided to the constructor when the receiver was created. This can occur when the underlying operating system does not support a particular combination of requested styles. For example, if the platform widget used to implement a particular SWT widget always has scroll bars, the result of calling this method would always have the SWT.H_SCROLL and SWT.V_SCROLL bits set.
[中]返回接收器的样式信息。
请注意,此方法返回的值可能与创建接收器时提供给构造函数的值不匹配。当底层操作系统不支持所请求样式的特定组合时,可能会发生这种情况。例如,如果用于实现特定SWT小部件的平台小部件始终具有滚动条,则调用此方法的结果将始终设置SWT.H_SCROLLSWT.V_SCROLL位。

代码示例

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

private static AbstractLabelLCADelegate getDelegate( final Widget widget ) {
  AbstractLabelLCADelegate result;
  if( ( widget.getStyle() & SWT.SEPARATOR ) != 0 ) {
   result = SEPARATOR_LCA;
  } else {
   result = LABEL_LCA;
  }
  return result;
 }
}

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

private static AbstractDateTimeLCADelegate getDelegate( Widget widget ) {
 if( ( widget.getStyle() & SWT.DATE ) != 0 ) {
  return DateTimeDateLCA.INSTANCE;
 }
 if( ( widget.getStyle() & SWT.TIME ) != 0 ) {
  return DateTimeTimeLCA.INSTANCE;
 }
 return DateTimeCalendarLCA.INSTANCE;
}

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

private static AbstractLabelLCADelegate getDelegate( Widget widget ) {
 if( ( widget.getStyle() & SWT.SEPARATOR ) != 0 ) {
  return SeparatorLabelLCA.INSTANCE;
 }
 return StandardLabelLCA.INSTANCE;
}

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

@Override
 public boolean matches( Widget widget ) {
  return ( widget.getStyle() & style ) != 0;
 }
};

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

private static AbstractDateTimeLCADelegate getDelegate( final Widget widget )
 {
  AbstractDateTimeLCADelegate result;
  if( ( widget.getStyle() & SWT.DATE ) != 0 ) {
   result = DATE_LCA;
  } else if( ( widget.getStyle() & SWT.TIME ) != 0 ) {
   result = TIME_LCA;
  } else {
   result = CALENDAR_LCA;
  }
  return result;
 }
}

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

/**
   * Sets the state of the "Example" widgets.
   */
  @Override
  void setExampleWidgetState () {
    super.setExampleWidgetState ();
    Widget [] widgets = getExampleWidgets ();
    if (widgets.length != 0){
      singleButton.setSelection ((widgets [0].getStyle () & SWT.SINGLE) != 0);
      multiButton.setSelection ((widgets [0].getStyle () & SWT.MULTI) != 0);
      horizontalButton.setSelection ((widgets [0].getStyle () & SWT.H_SCROLL) != 0);
      verticalButton.setSelection ((widgets [0].getStyle () & SWT.V_SCROLL) != 0);
      borderButton.setSelection ((widgets [0].getStyle () & SWT.BORDER) != 0);
    }
  }
}

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

/**
   * Sets the state of the "Example" widgets.
   */
  @Override
  void setExampleWidgetState () {
    super.setExampleWidgetState ();
    Widget [] widgets = getExampleWidgets ();
    if (widgets.length != 0) {
      leftButton.setSelection ((widgets [0].getStyle () & SWT.LEFT) != 0);
      centerButton.setSelection ((widgets [0].getStyle () & SWT.CENTER) != 0);
      rightButton.setSelection ((widgets [0].getStyle () & SWT.RIGHT) != 0);
    }
  }
}

代码示例来源:origin: com.diffplug.durian/durian-swt

/** Returns true if `flag` is set in the style value of `widget`. */
public static boolean flagIsSet(int flag, Widget widget) {
  return flagIsSet(flag, widget.getStyle());
}

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

/**
   * Sets the state of the "Example" widgets.
   */
  @Override
  void setExampleWidgetState () {
    super.setExampleWidgetState ();
    Widget [] widgets = getExampleWidgets ();
    if (widgets.length != 0){
      verticalButton.setSelection ((widgets [0].getStyle () & SWT.V_SCROLL) != 0);
      borderButton.setSelection ((widgets [0].getStyle () & SWT.BORDER) != 0);
    }
  }
}

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

public static String[] filterStyles( Widget widget, String... allowedStyles ) {
 return filterStyles( widget.getStyle(), allowedStyles );
}

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

/**
 * Return SWT style constant from {@link Widget} <code>widget</code> as
 * String. Each SWT style are separate with space character.
 * 
 * @param style
 * @return
 */
public static String getSWTWidgetStyleAsString(Widget widget) {
  if (widget.isDisposed()) {
    return "";
  }
  return getSWTWidgetStyleAsString(widget.getStyle(), " ");
}

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

/**
 * Return SWT style constant from {@link Widget} <code>widget</code> as
 * String. Each SWT style are separate with space character.
 *
 * @param style
 * @return
 */
public static String getSWTWidgetStyleAsString(Widget widget) {
  if (widget.isDisposed()) {
    return "";
  }
  return getSWTWidgetStyleAsString(widget.getStyle(), " ");
}

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

/**
 * Sets the state of the "Example" widgets.
 */
@Override
void setExampleWidgetState () {
  super.setExampleWidgetState ();
  if (!instance.startup) {
    setWidgetMinimum ();
    setWidgetMaximum ();
    setWidgetSelection ();
  }
  Widget [] widgets = getExampleWidgets ();
  if (widgets.length != 0) {
    if (orientationButtons) {
      horizontalButton.setSelection ((widgets [0].getStyle () & SWT.HORIZONTAL) != 0);
      verticalButton.setSelection ((widgets [0].getStyle () & SWT.VERTICAL) != 0);
    }
    borderButton.setSelection ((widgets [0].getStyle () & SWT.BORDER) != 0);
  }
}

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

/**
 * Checks whether a certain style flag is set on the specified widget and if
 * so, writes code to set the according state on the client-side widget.
 *
 * @param widget the widget whose style to write
 * @param style the SWT style flag in question
 * @param styleName the uppercase name of the style
 * @throws IOException
 * @since 1.2
 */
public static void writeStyleFlag( final Widget widget,
                  final int style,
                  final String styleName )
 throws IOException
{
 JSWriter writer = JSWriter.getWriterFor( widget );
 if( ( widget.getStyle() & style ) != 0 ) {
  writer.call( JSConst.QX_FUNC_ADD_STATE,
         new Object[] { "rwt_" + styleName } );
 }
}

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

public void renderInitialization( final Widget widget ) throws IOException {
 CLabel label = ( CLabel )widget;
 JSWriter writer = JSWriter.getWriterFor( label );
 writer.newWidget( "qx.ui.basic.Atom" );
 if( ( widget.getStyle() & SWT.SHADOW_IN ) != 0 ) {
  writer.call( "addState", new Object[]{ "rwt_SHADOW_IN" } );
 } else if( ( widget.getStyle() & SWT.SHADOW_OUT ) != 0 ) {
  writer.call( "addState", new Object[]{ "rwt_SHADOW_OUT" } );
 }
 ControlLCAUtil.writeStyleFlags( label );
 Object[] args = { label };
 writer.callStatic( "org.eclipse.swt.CLabelUtil.initialize", args  );
}

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

/**
 * The action item implementation of this <code>IContributionItem</code>
 * method returns <code>true</code> for menu items and <code>false</code>
 * for everything else.
 */
@Override
public boolean isDynamic() {
  if (widget instanceof MenuItem) {
    // Optimization. Only recreate the item is the check or radio style
    // has changed.
    boolean itemIsCheck = (widget.getStyle() & SWT.CHECK) != 0;
    boolean actionIsCheck = getAction() != null
        && getAction().getStyle() == IAction.AS_CHECK_BOX;
    boolean itemIsRadio = (widget.getStyle() & SWT.RADIO) != 0;
    boolean actionIsRadio = getAction() != null
        && getAction().getStyle() == IAction.AS_RADIO_BUTTON;
    return (itemIsCheck != actionIsCheck)
        || (itemIsRadio != actionIsRadio);
  }
  return false;
}

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

/**
 * The action item implementation of this <code>IContributionItem</code>
 * method returns <code>true</code> for menu items and <code>false</code>
 * for everything else.
 */
@Override
public boolean isDynamic() {
  if (widget instanceof MenuItem) {
    // Optimization. Only recreate the item is the check or radio style
    // has changed.
    boolean itemIsCheck = (widget.getStyle() & SWT.CHECK) != 0;
    boolean actionIsCheck = getAction() != null
        && getAction().getStyle() == IAction.AS_CHECK_BOX;
    boolean itemIsRadio = (widget.getStyle() & SWT.RADIO) != 0;
    boolean actionIsRadio = getAction() != null
        && getAction().getStyle() == IAction.AS_RADIO_BUTTON;
    return (itemIsCheck != actionIsCheck)
        || (itemIsRadio != actionIsRadio);
  }
  return false;
}

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

/**
 * The action item implementation of this <code>IContributionItem</code>
 * method returns <code>true</code> for menu items and <code>false</code>
 * for everything else.
 */
public boolean isDynamic() {
  if (widget instanceof MenuItem) {
    // Optimization. Only recreate the item is the check or radio style
    // has changed.
    boolean itemIsCheck = (widget.getStyle() & SWT.CHECK) != 0;
    boolean actionIsCheck = getAction() != null
        && getAction().getStyle() == IAction.AS_CHECK_BOX;
    boolean itemIsRadio = (widget.getStyle() & SWT.RADIO) != 0;
    boolean actionIsRadio = getAction() != null
        && getAction().getStyle() == IAction.AS_RADIO_BUTTON;
    return (itemIsCheck != actionIsCheck)
        || (itemIsRadio != actionIsRadio);
  }
  return false;
}

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

/**
   * Override the "Control" group.  The "Control" group
   * is typically the right hand column in the tab.
   */
  @Override
  void createControlGroup () {
    controlGroup = new Group (tabFolderPage, SWT.NONE);
    controlGroup.setLayout (new GridLayout (2, true));
    controlGroup.setLayoutData (new GridData(SWT.FILL, SWT.FILL, false, false));
    controlGroup.setText (ControlExample.getResourceString("Parameters"));
    /* Create individual groups inside the "Control" group */
    createOtherGroup ();
    createSetGetGroup();
    createSizeGroup ();
    createOrientationGroup ();

    SelectionListener selectionListener = widgetSelectedAdapter(event -> {
      if ((event.widget.getStyle () & SWT.RADIO) != 0) {
        if (!((Button) event.widget).getSelection ()) return;
      }
      if (!handleTextDirection (event.widget)) {
        recreateExampleWidgets ();
      }
    });
    // attach listeners to the Orientation buttons
    rtlButton.addSelectionListener (selectionListener);
    ltrButton.addSelectionListener (selectionListener);
    defaultOrietationButton.addSelectionListener (selectionListener);
  }
}

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

public void handleEvent(Event event) {
    if (!event.widget.isDisposed()) {
      Widget realItem = (Widget) event.widget.getData();
      if (!realItem.isDisposed()) {
        int style = event.widget.getStyle();
        if (event.type == SWT.Selection
            && ((style & (SWT.TOGGLE | SWT.CHECK | SWT.RADIO)) != 0)
            && realItem instanceof MenuItem) {
          ((MenuItem) realItem)
              .setSelection(((MenuItem) event.widget)
                  .getSelection());
        }
        event.widget = realItem;
        realItem.notifyListeners(event.type, event);
      }
    }
  }
};

相关文章

Widget类方法