Java Code Examples for org.eclipse.swt.widgets.Button#getStyle()

The following examples show how to use org.eclipse.swt.widgets.Button#getStyle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PShelfExampleTab.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public void createParameters(Composite parent) {
	GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).applyTo(parent);

	Listener listenerRecreates = event -> {
		if (event.widget instanceof Button) {
			Button b = (Button) event.widget;
			if ((b.getStyle() & SWT.RADIO) != 0) {
				if (!b.getSelection())
					return;
			}
		}
		recreateExample();
	};

	Group styles = new Group(parent, SWT.NONE);
	styles.setText("Styles");
	GridLayoutFactory.swtDefaults().applyTo(styles);
	GridDataFactory.fillDefaults().applyTo(styles);

	border = ButtonFactory.create(styles, SWT.CHECK, "SWT.BORDER", listenerRecreates, false);
	simple = ButtonFactory.create(styles, SWT.CHECK, "SWT.SIMPLE", listenerRecreates, false);

	Group parms = new Group(parent, SWT.NONE);
	parms.setText("Other");
	GridLayoutFactory.swtDefaults().numColumns(2).equalWidth(false).applyTo(parms);

	new Label(parms, SWT.NONE).setText("Renderer:");

	rendererCombo = new Combo(parms, SWT.READ_ONLY);
	rendererCombo.setItems(new String[] { "PaletteShelfRenderer", "RedmondShelfRenderer" });
	rendererCombo.select(0);
	rendererCombo.addListener(SWT.Selection, listenerRecreates);

}
 
Example 2
Source File: PropsUi.java    From hop with Apache License 2.0 4 votes vote down vote up
public void setLook( final Control control, int style ) {
  if ( this.isOSLookShown() && style != WIDGET_STYLE_FIXED ) {
    return;
  }

  final GuiResource gui = GuiResource.getInstance();
  Font font = null;
  Color background = null;

  switch ( style ) {
    case WIDGET_STYLE_DEFAULT:
      background = gui.getColorBackground();
      if ( control instanceof Group && OS.indexOf( "mac" ) > -1 ) {
        control.addPaintListener( paintEvent -> {
          paintEvent.gc.setBackground( gui.getColorBackground() );
          paintEvent.gc.fillRectangle( 2, 0, control.getBounds().width - 8, control.getBounds().height - 20 );
        } );
      }
      font = null; // GuiResource.getInstance().getFontDefault();
      break;
    case WIDGET_STYLE_FIXED:
      if ( !this.isOSLookShown() ) {
        background = gui.getColorBackground();
      }
      font = gui.getFontFixed();
      break;
    case WIDGET_STYLE_TABLE:
      background = gui.getColorBackground();
      font = null; // gui.getFontGrid();
      break;
    case WIDGET_STYLE_NOTEPAD:
      background = gui.getColorBackground();
      font = gui.getFontNote();
      break;
    case WIDGET_STYLE_GRAPH:
      background = gui.getColorBackground();
      font = gui.getFontGraph();
      break;
    case WIDGET_STYLE_TOOLBAR:
      background = GuiResource.getInstance().getColorDemoGray();
      break;
    case WIDGET_STYLE_TAB:
      background = GuiResource.getInstance().getColorWhite();
      CTabFolder tabFolder = (CTabFolder) control;
      tabFolder.setSimple( false );
      tabFolder.setBorderVisible( true );
      // need to make a copy of the tab selection background color to get around PDI-13940
      Color c = GuiResource.getInstance().getColorTab();
      Color tabColor = new Color( c.getDevice(), c.getRed(), c.getGreen(), c.getBlue() );
      tabFolder.setSelectionBackground( tabColor );
      break;
    default:
      background = gui.getColorBackground();
      font = null; // gui.getFontDefault();
      break;
  }

  if ( font != null && !font.isDisposed() ) {
    control.setFont( font );
  }

  if ( background != null && !background.isDisposed() ) {
    if ( control instanceof Button ) {
      Button b = (Button) control;
      if ( ( b.getStyle() & SWT.PUSH ) != 0 ) {
        return;
      }
    }
    control.setBackground( background );
  }
}
 
Example 3
Source File: PaletteEditorComposite.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public void widgetSelected( SelectionEvent sev )
{
	if ( sev.getSource( ) == sb )
	{
		int iSelection = sb.getSelection( );
		iViewY = iSelection;
		coPaletteEntries.redraw( );
	}
	else
	{
		final Button btn = (Button) sev.getSource( );
		if ( btn == btnAdd )
		{
			if ( fccNewEntry.getFill( ) != null )
			{
				append( fccNewEntry.getFill( ).copyInstance( ) );
			}
			else
			{
				append( ColorDefinitionImpl.TRANSPARENT( ) );
			}
		}
		else if ( btn == btnRemove )
		{
			remove( iSelectedIndex );
		}
		else if ( ( btn.getStyle( ) & SWT.UP ) == SWT.UP )
		{
			if ( iSelectedIndex > 0 )
			{
				swap( iSelectedIndex, iSelectedIndex - 1 );
			}
		}
		else if ( ( btn.getStyle( ) & SWT.DOWN ) == SWT.DOWN )
		{
			if ( iSelectedIndex < elPaletteEntries1.size( ) - 1 )
			{
				swap( iSelectedIndex, iSelectedIndex + 1 );
			}
		}
	}
}
 
Example 4
Source File: ExcelFileSelectionWizardPage.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Create the middle button composite that displays ADD button
 * 
 * @param composite
 * @return
 */
private Composite createAddBtnComposite( Composite composite )
{
	FormData data = new FormData( );
	data.top = new FormAttachment( 50, 5 );
	data.left = new FormAttachment( availableList, 3 );

	Composite btnComposite = new Composite( composite, SWT.NONE );
	btnComposite.setLayoutData( data );
	GridLayout layout = new GridLayout( );
	layout.numColumns = 1;
	btnComposite.setLayout( layout );

	btnAdd = new Button( btnComposite, SWT.NONE );
	GridData gridData = new GridData( GridData.VERTICAL_ALIGN_CENTER
			| GridData.FILL_HORIZONTAL );
	gridData.heightHint = 25;
	btnAdd.setLayoutData( gridData );
	btnAdd.setToolTipText( Messages.getString( "tooltip.button.add" ) ); //$NON-NLS-1$

	if ( btnAdd.getStyle( ) == ( btnAdd.getStyle( ) | SWT.LEFT_TO_RIGHT ) )
	{
		btnAdd.setImage( PlatformUI.getWorkbench( )
				.getSharedImages( )
				.getImage( ISharedImages.IMG_TOOL_FORWARD ) );
	}
	else
	{
		btnAdd.setImage( PlatformUI.getWorkbench( )
				.getSharedImages( )
				.getImage( ISharedImages.IMG_TOOL_BACK ) );
	}

	btnAdd.addSelectionListener( new SelectionAdapter( ) {

		public void widgetSelected( SelectionEvent e )
		{
			addColumns( );
		}
	} );
	btnAdd.setEnabled( false );
	return btnComposite;
}
 
Example 5
Source File: PropsUI.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public void setLook( final Control control, int style ) {
  if ( this.isOSLookShown() && style != WIDGET_STYLE_FIXED ) {
    return;
  }

  final GUIResource gui = GUIResource.getInstance();
  Font font = null;
  Color background = null;

  switch ( style ) {
    case WIDGET_STYLE_DEFAULT:
      background = gui.getColorBackground();
      if ( control instanceof Group && OS.indexOf( "mac" ) > -1 ) {
        control.addPaintListener( new PaintListener() {
          @Override
          public void paintControl( PaintEvent paintEvent ) {
            paintEvent.gc.setBackground( gui.getColorBackground() );
            paintEvent.gc.fillRectangle( 2, 0, control.getBounds().width - 8, control.getBounds().height - 20 );
          }
        } );
      }
      font = null; // GUIResource.getInstance().getFontDefault();
      break;
    case WIDGET_STYLE_FIXED:
      if ( !this.isOSLookShown() ) {
        background = gui.getColorBackground();
      }
      font = gui.getFontFixed();
      break;
    case WIDGET_STYLE_TABLE:
      background = gui.getColorBackground();
      font = null; // gui.getFontGrid();
      break;
    case WIDGET_STYLE_NOTEPAD:
      background = gui.getColorBackground();
      font = gui.getFontNote();
      break;
    case WIDGET_STYLE_GRAPH:
      background = gui.getColorBackground();
      font = gui.getFontGraph();
      break;
    case WIDGET_STYLE_TOOLBAR:
      background = GUIResource.getInstance().getColorDemoGray();
      break;
    case WIDGET_STYLE_TAB:
      background = GUIResource.getInstance().getColorWhite();
      CTabFolder tabFolder = (CTabFolder) control;
      tabFolder.setSimple( false );
      tabFolder.setBorderVisible( true );
      // need to make a copy of the tab selection background color to get around PDI-13940
      Color c = GUIResource.getInstance().getColorTab();
      Color tabColor = new Color( c.getDevice(), c.getRed(), c.getGreen(), c.getBlue() );
      tabFolder.setSelectionBackground( tabColor );
      break;
    default:
      background = gui.getColorBackground();
      font = null; // gui.getFontDefault();
      break;
  }

  if ( font != null && !font.isDisposed() ) {
    control.setFont( font );
  }

  if ( background != null && !background.isDisposed() ) {
    if ( control instanceof Button ) {
      Button b = (Button) control;
      if ( ( b.getStyle() & SWT.PUSH ) != 0 ) {
        return;
      }
    }
    control.setBackground( background );
  }
}