btnPN = new Button( cmpButtons, SWT.NONE ); GridData gdImage = new GridData( GridData.FILL_BOTH ); gdImage.heightHint = 26; gdImage.horizontalSpan = 2; btnPN.setLayoutData( gdImage ); btnPN.setText( Messages.getString( "FillChooserComposite.Lbl.PositiveNegative" ) ); btnPN.addSelectionListener( this ); btnPN.addListener( SWT.FocusOut, this ); btnPN.addListener( SWT.KeyDown, this ); btnPN.addListener( SWT.Traverse, this );
if ( this.bPositiveNegativeEnabled ) { btnPN = new Button( cmpButtons, SWT.NONE ); GridData gdPN = new GridData( GridData.FILL_BOTH ); gdPN.heightHint = 26; gdPN.horizontalSpan = 2; btnPN.setLayoutData( gdPN ); btnPN.setText( Messages.getString( "FillChooserComposite.Lbl.PositiveNegative" ) ); btnPN.addSelectionListener( this ); btnPN.addListener( SWT.FocusOut, this ); btnPN.addListener( SWT.KeyDown, this ); btnPN.addListener( SWT.Traverse, this ); }
	private void createDropDownComponent( int iXLoc, int iYLoc )	{		if ( !bEnabled )		{			return;		}		int iShellHeight = 170;		int iShellWidth = 160;		// Reduce the height based on which buttons are to be shown.		if ( bGradientEnabled )		{			iShellHeight += 30;		}		if ( bImageEnabled )		{			iShellHeight += 30;		}		if ( bAutoEnabled )		{			iShellHeight += 30;		}		if ( bTransparentEnabled )		{			iShellHeight += 30;		}		iShellHeight += 30;		Shell shell = new Shell( this.getShell( ), SWT.NO_FOCUS );		shell.setLayout( new FillLayout( ) );		shell.setSize( iShellWidth, iShellHeight );		if ( ( getStyle( ) & SWT.RIGHT_TO_LEFT ) != 0 )		{			iXLoc -= iShellWidth;		}		shell.setLocation( iXLoc, iYLoc );		shell.addShellListener( new ShellAdapter( ) {			public void shellClosed( ShellEvent e )			{				clearColorSelection( );			}		} );		cmpDropDown = new Composite( shell, SWT.NO_FOCUS );		GridLayout glDropDown = new GridLayout( );		glDropDown.marginHeight = 2;		glDropDown.marginWidth = 2;		glDropDown.horizontalSpacing = 1;		glDropDown.verticalSpacing = 4;		cmpDropDown.setLayout( glDropDown );		if ( colorArray == null )		{			colorArray = createColorMap( getDisplay( ) );		}		ColorSelectionCanvas cnv = new ColorSelectionCanvas( cmpDropDown,				SWT.BORDER,				colorArray );		GridData gdCnv = new GridData( GridData.FILL_BOTH );		gdCnv.heightHint = 110;		cnv.setLayoutData( gdCnv );		cnv.addListener( SWT.Traverse, this );		cnv.addListener( SWT.FocusOut, this );		if ( this.fCurrent instanceof ColorDefinition )		{			cnv.setColor( new Color( this.getDisplay( ),					( (ColorDefinition) fCurrent ).getRed( ),					( (ColorDefinition) fCurrent ).getGreen( ),					( (ColorDefinition) fCurrent ).getBlue( ) ) );		}		cmpButtons = new Composite( cmpDropDown, SWT.NO_FOCUS );		GridLayout glButtons = new GridLayout( );		glButtons.marginHeight = 3;		glButtons.marginWidth = 4;		glButtons.horizontalSpacing = 1;		glButtons.verticalSpacing = 4;		glButtons.numColumns = 2;		cmpButtons.setLayout( glButtons );		GridData gdButtons = new GridData( GridData.FILL_HORIZONTAL );		cmpButtons.setLayoutData( gdButtons );		// Layout for Transparency Composite		GridLayout glTransparency = new GridLayout( );		glTransparency.numColumns = 1;		glTransparency.horizontalSpacing = 5;		glTransparency.verticalSpacing = 3;		glTransparency.marginHeight = 4;		glTransparency.marginWidth = 0;		Composite cmpTransparency = new Composite( cmpButtons, SWT.NONE				| SWT.NO_FOCUS );		GridData gdTransparency = new GridData( GridData.FILL_BOTH );		gdTransparency.horizontalSpan = 2;		cmpTransparency.setLayoutData( gdTransparency );		cmpTransparency.setLayout( glTransparency );		lblTransparency = new Label( cmpTransparency, SWT.NONE );		GridData gdLBLTransparency = new GridData( GridData.FILL_HORIZONTAL );		gdLBLTransparency.horizontalIndent = 2;		lblTransparency.setLayoutData( gdLBLTransparency );		lblTransparency.setText( Messages.getString( "FillChooserComposite.Lbl.Opacity" ) ); //$NON-NLS-1$		srTransparency = new Slider( cmpTransparency, SWT.HORIZONTAL				| SWT.NO_FOCUS );		GridData gdTransparent = new GridData( GridData.VERTICAL_ALIGN_BEGINNING				| GridData.FILL_HORIZONTAL );		gdTransparent.horizontalSpan = 2;		srTransparency.setLayoutData( gdTransparent );		if ( fCurrent == null )		{			srTransparency.setValues( 0, 0, 256, 1, 1, 10 );			srTransparency.setEnabled( false );		}		else		{			int iValue = 0;			if ( fCurrent instanceof ColorDefinition )			{				iValue = ( (ColorDefinition) fCurrent ).getTransparency( );				srTransparency.setValues( iValue, 0, 256, 1, 1, 10 );			}			else if ( fCurrent instanceof Gradient )			{				iValue = ( (Gradient) fCurrent ).getTransparency( );				srTransparency.setValues( iValue, 0, 256, 1, 1, 10 );			}			else			{				srTransparency.setEnabled( false );			}		}		lblTransparency.setText( new MessageFormat( Messages.getString( "FillChooserComposite.Lbl.Opacity" ) ) //$NON-NLS-1$		.format( new Object[]{			new Integer( srTransparency.getSelection( ) )		} ) );		srTransparency.setToolTipText( String.valueOf( srTransparency.getSelection( ) ) );		srTransparency.addSelectionListener( this );		srTransparency.addListener( SWT.FocusOut, this );		srTransparency.addListener( SWT.KeyDown, this );		srTransparency.addListener( SWT.Traverse, this );		if ( this.bTransparentEnabled )		{			btnReset = new Button( cmpButtons, SWT.NONE );			GridData gdReset = new GridData( GridData.FILL_BOTH );			gdReset.heightHint = 26;			gdReset.horizontalSpan = 2;			btnReset.setLayoutData( gdReset );			btnReset.setText( Messages.getString( "FillChooserComposite.Lbl.Transparent" ) ); //$NON-NLS-1$			btnReset.addSelectionListener( this );			btnReset.addListener( SWT.FocusOut, this );			btnReset.addListener( SWT.KeyDown, this );			btnReset.addListener( SWT.Traverse, this );		}		if ( this.bAutoEnabled )		{			btnAuto = new Button( cmpButtons, SWT.NONE );			GridData gdGradient = new GridData( GridData.FILL_BOTH );			gdGradient.heightHint = 26;			gdGradient.horizontalSpan = 2;			btnAuto.setLayoutData( gdGradient );			btnAuto.setText( Messages.getString( "FillChooserComposite.Lbl.Auto" ) ); //$NON-NLS-1$			btnAuto.addSelectionListener( this );			btnAuto.addListener( SWT.FocusOut, this );			btnAuto.addListener( SWT.KeyDown, this );			btnAuto.addListener( SWT.Traverse, this );		}		if ( this.bGradientEnabled )		{			btnGradient = new Button( cmpButtons, SWT.NONE );			GridData gdGradient = new GridData( GridData.FILL_BOTH );			gdGradient.heightHint = 26;			gdGradient.horizontalSpan = 2;			btnGradient.setLayoutData( gdGradient );			btnGradient.setText( Messages.getString( "FillChooserComposite.Lbl.Gradient" ) ); //$NON-NLS-1$			btnGradient.addSelectionListener( this );			btnGradient.addListener( SWT.FocusOut, this );			btnGradient.addListener( SWT.KeyDown, this );			btnGradient.addListener( SWT.Traverse, this );		}		btnCustom = new Button( cmpButtons, SWT.NONE );		GridData gdCustom = new GridData( GridData.FILL_BOTH );		gdCustom.heightHint = 26;		gdCustom.horizontalSpan = 2;		btnCustom.setLayoutData( gdCustom );		btnCustom.setText( Messages.getString( "FillChooserComposite.Lbl.CustomColor" ) ); //$NON-NLS-1$		btnCustom.addSelectionListener( this );		btnCustom.addListener( SWT.FocusOut, this );		btnCustom.addListener( SWT.KeyDown, this );		btnCustom.addListener( SWT.Traverse, this );		if ( this.bImageEnabled )		{			btnImage = new Button( cmpButtons, SWT.NONE );			GridData gdImage = new GridData( GridData.FILL_BOTH );			gdImage.heightHint = 26;			gdImage.horizontalSpan = 2;			btnImage.setLayoutData( gdImage );			btnImage.setText( Messages.getString( "FillChooserComposite.Lbl.Image" ) ); //$NON-NLS-1$			btnImage.addSelectionListener( this );			btnImage.addListener( SWT.FocusOut, this );			btnImage.addListener( SWT.KeyDown, this );			btnImage.addListener( SWT.Traverse, this );		}		btnPN = new Button( cmpButtons, SWT.NONE );		GridData gdImage = new GridData( GridData.FILL_BOTH );		gdImage.heightHint = 26;		gdImage.horizontalSpan = 2;		btnPN.setLayoutData( gdImage );		btnPN.setText( Messages.getString( "FillChooserComposite.Lbl.PositiveNegative" ) ); //$NON-NLS-1$		btnPN.addSelectionListener( this );		btnPN.addListener( SWT.FocusOut, this );		btnPN.addListener( SWT.KeyDown, this );		btnPN.addListener( SWT.Traverse, this );		shell.layout( );		shell.open( );	}