Java Code Examples for org.eclipse.swt.widgets.Composite#getBackground()
The following examples show how to use
org.eclipse.swt.widgets.Composite#getBackground() .
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: CTextCellEditor.java From birt with Eclipse Public License 1.0 | 6 votes |
protected Control createControl( Composite parent ) { Font font = parent.getFont( ); Color bg = parent.getBackground( ); editor = new Composite( parent, getStyle( ) ); editor.setFont( font ); editor.setBackground( bg ); editor.setLayout( new FillLayout( ) ); createContents( editor ); updateContents( value ); setValueValid( true ); return editor; }
Example 2
Source File: ComboBoxCellEditor.java From birt with Eclipse Public License 1.0 | 6 votes |
protected Control createControl( Composite parent ) { Font font = parent.getFont( ); Color bg = parent.getBackground( ); editor = new Composite( parent, getStyle( ) ); editor.setFont( font ); editor.setBackground( bg ); editor.setLayout( new FillLayout( ) ); createContents( editor ); updateContents( value ); setValueValid( true ); return editor; }
Example 3
Source File: BufferDialog.java From e4macs with Eclipse Public License 1.0 | 6 votes |
private Control createBufferTip(Composite parent, IEditorReference ref) { Composite result = new Composite(parent, SWT.NO_FOCUS); Color bg = parent.getBackground(); result.setBackground(bg); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 1; result.setLayout(gridLayout); StyledText name = new StyledText(result, SWT.READ_ONLY | SWT.HIDE_SELECTION); // italics results in slightly clipped text unless extended String text = ref.getTitleToolTip() + ' '; name.setText(text); name.setBackground(bg); name.setCaret(null); StyleRange styleIt = new StyleRange(0, text.length(), null, bg); styleIt.fontStyle = SWT.ITALIC; name.setStyleRange(styleIt); return result; }
Example 4
Source File: ToolkitControl.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
/** * @param parent * @param style */ public ToolkitControl(Composite parent, WBToolkit wbToolkit) { super(parent, SWT.NONE); this.wbToolkit = wbToolkit; setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); setBackground(parent.getBackground()); defaultBackgroundColor = parent.getBackground(); selectedBackgroundColor = Display.getDefault().getSystemColor( SWT.COLOR_LIST_SELECTION); initControl(); }
Example 5
Source File: BoxSettingsTab.java From gama with GNU General Public License v3.0 | 5 votes |
protected Label newLabel(final Composite c, final String msg) { final Label l = new Label(c, SWT.NONE); l.setText(msg); final Color bc = c.getBackground(); if (bc != null) { l.setBackground(new Color(null, bc.getRGB())); } return l; }
Example 6
Source File: FXColorPicker.java From gef with Eclipse Public License 2.0 | 4 votes |
/** * Constructs a new {@link FXColorPicker}. * * @param parent * The parent {@link Composite}. * @param color * The initial {@link Color} to set. */ public FXColorPicker(final Composite parent, Color color) { super(parent, SWT.NONE); setLayout(new FillLayout()); FXCanvas canvas = new FXCanvas(this, SWT.NONE); // container Group colorPickerGroup = new Group(); HBox hbox = new HBox(); colorPickerGroup.getChildren().add(hbox); // color wheel WritableImage colorWheelImage = new WritableImage(64, 64); renderColorWheel(colorWheelImage, 0, 0, 64); ImageView colorWheel = new ImageView(colorWheelImage); colorWheel.setFitWidth(16); colorWheel.setFitHeight(16); BorderPane colorWheelPane = new BorderPane(); Insets insets = new Insets(2.0); colorWheelPane.setPadding(insets); colorWheelPane.setCenter(colorWheel); // use background color of parent composite (the wheel image is // transparent outside the wheel, so otherwise the hbox color would look // through) colorWheelPane.setStyle("-fx-background-color: " + computeRgbString(Color.rgb(parent.getBackground().getRed(), parent.getBackground().getGreen(), parent.getBackground().getBlue()))); colorRectangle = new Rectangle(50, 20); // bind to ColorWheel instead of buttonPane to prevent layout // problems. colorRectangle.widthProperty().bind(colorWheel.fitWidthProperty() .add(insets.getLeft()).add(insets.getRight()).multiply(2.5)); colorRectangle.heightProperty().bind(colorWheelPane.heightProperty()); // draw 'border' around hbox (and fill background, which covers the // space beween color rect and wheel hbox.setStyle("-fx-border-color: " + computeRgbString(Color.DARKGREY) + "; -fx-background-color: " + computeRgbString(Color.DARKGREY)); hbox.getChildren().addAll(colorRectangle, colorWheelPane); hbox.setSpacing(0.5); // interaction colorWheelPane.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { Color colorOrNull = FXColorPicker.pickColor(getShell(), getColor()); if (colorOrNull != null) { setColor(colorOrNull); } } }); Scene scene = new Scene(colorPickerGroup); // copy background color from parent composite org.eclipse.swt.graphics.Color backgroundColor = parent.getBackground(); scene.setFill(Color.rgb(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue())); canvas.setScene(scene); // initialize some color setColor(color); colorRectangle.fillProperty().bind(this.color); }
Example 7
Source File: FileComboBoxCellEditor.java From ice with Eclipse Public License 1.0 | 4 votes |
@Override protected Control createControl(Composite parent) { Font font = parent.getFont(); Color bg = parent.getBackground(); // Create the editor composite editor = new Composite(parent, getStyle()); editor.setFont(font); editor.setBackground(bg); editor.setLayout(new DialogCellLayout()); // Create the contents contents = (CCombo) super.createControl(editor); // Create the Browse Button button = createButton(editor); button.setFont(font); // Add a escape key listener button.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.character == '\u001b') { // Escape fireCancelEditor(); } } }); // Add the focus listener button.addFocusListener(getButtonFocusListener()); // Add the button listener to throw up the file browser button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { // Remove the button's focus listener since it's guaranteed // to lose focus when the dialog opens button.removeFocusListener(getButtonFocusListener()); // Get the IClient so we can do the import IClient client = ClientHolder.getClient(); // Open the file browser and get the selection String newValue = (String) openDialogBox(editor); // Re-add the listener once the dialog closes button.addFocusListener(getButtonFocusListener()); if (newValue != null) { // Import the files File importedFile = new File(newValue); client.importFile(importedFile.toURI()); String[] currentItems = FileComboBoxCellEditor.this.getItems(); String[] newItems = new String[currentItems.length + 1]; for (int i = 0; i < currentItems.length; i++) { newItems[i] = currentItems[i]; } newItems[currentItems.length] = importedFile.getName(); FileComboBoxCellEditor.this.setItems(newItems); doSetValue(new Integer(currentItems.length)); ArrayList<String> valueList = new ArrayList<String>(Arrays.asList(newItems)); // Set the new list element.getEntry().setAllowedValues(valueList); support.setValue(element, currentItems.length); markDirty(); setValueValid(true); fireApplyEditorValue(); deactivate(); } } }); setValueValid(true); return editor; }
Example 8
Source File: ReflectivityDataPropertySection.java From ice with Eclipse Public License 1.0 | 4 votes |
/** * This operation draws the (initial) controls in the properties view based * on the input. Adds the <code>DataComponent</code> to a * <code>DataComponentComposite</code> to be used in the properties view. */ @Override public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) { super.createControls(parent, aTabbedPropertySheetPage); // Get the default background color. Color backgroundColor = parent.getBackground(); // Create a section for the data composites. section = getWidgetFactory().createSection(parent, Section.SHORT_TITLE_BAR | Section.DESCRIPTION); section.setText(data.getName()); section.setDescription(data.getDescription()); section.setBackground(backgroundColor); dataComposite = new DataComponentComposite(data, section, SWT.NONE); // Sets the entries to be enabled to the state of the isEnabled flag Control[] children = dataComposite.getChildren(); for (Control child : children) { if (child instanceof IEntryComposite) { IEntryComposite entry = (IEntryComposite) child; entry.getComposite().setEnabled(isEnabled); } } GridLayout clientLayout = new GridLayout(2, true); // Set the margins and spacing based on the tabbed property // constants. clientLayout.marginLeft = ITabbedPropertyConstants.HMARGIN; clientLayout.marginRight = ITabbedPropertyConstants.HMARGIN; clientLayout.marginTop = ITabbedPropertyConstants.VMARGIN; clientLayout.marginBottom = ITabbedPropertyConstants.VMARGIN; clientLayout.horizontalSpacing = ITabbedPropertyConstants.HSPACE; clientLayout.verticalSpacing = ITabbedPropertyConstants.VSPACE; dataComposite.setLayout(clientLayout); // Make the background of the section client white unless ICE is in // debug mode. if (System.getProperty("DebugICE") == null) { dataComposite.setBackground(backgroundColor); } else { dataComposite.setBackground( Display.getCurrent().getSystemColor(SWT.COLOR_RED)); } // Adapt the composite to be rendered with the default widget factory // toolkit getWidgetFactory().adapt(dataComposite); // Set the client area for the section. section.setClient(dataComposite); return; }
Example 9
Source File: ComponentPropertySection.java From ice with Eclipse Public License 1.0 | 4 votes |
/** * This operation draws the controls in the properties view based on the * input. */ @Override public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) { super.createControls(parent, aTabbedPropertySheetPage); // Get the default background color (white). Color backgroundColor = parent.getBackground(); // Create a section for the data composites. section = getWidgetFactory().createSection(parent, ExpandableComposite.SHORT_TITLE_BAR | Section.DESCRIPTION); section.setText("Node properties"); section.setDescription("All properties available for " + "this node can be modified here."); section.setBackground(backgroundColor); // Create the Composite that contains all DataComponentComposites. final Composite client = new Composite(section, SWT.NONE); // Set the layout of the client area so that all DataComponentComposites // are stacked on top of each other. GridLayout clientLayout = new GridLayout(); // Set the margins and spacing based on the tabbed property constants. clientLayout.marginLeft = ITabbedPropertyConstants.HMARGIN; clientLayout.marginRight = ITabbedPropertyConstants.HMARGIN; clientLayout.marginTop = ITabbedPropertyConstants.VMARGIN; clientLayout.marginBottom = ITabbedPropertyConstants.VMARGIN; clientLayout.horizontalSpacing = ITabbedPropertyConstants.HSPACE; clientLayout.verticalSpacing = ITabbedPropertyConstants.VSPACE; client.setLayout(clientLayout); // Make the background of the section client white unless ICE is in // debug mode. if (System.getProperty("DebugICE") == null) { client.setBackground(backgroundColor); } else { client.setBackground( Display.getCurrent().getSystemColor(SWT.COLOR_RED)); } // Set the client area for the section. section.setClient(client); // Get the property viewer's ScrolledComposite and its first Composite // (its "client" Composite). scrollCompositeClient = section.getParent().getParent().getParent() .getParent(); scrollComposite = (ScrolledComposite) scrollCompositeClient.getParent(); // Add a listener to resize the Section's properties and update the // ScrollComposite's minimum bounds correctly based on the displayed // properties. scrollComposite.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { resizeProperties(); } }); return; }
Example 10
Source File: TreePropertySection.java From ice with Eclipse Public License 1.0 | 4 votes |
/** * This operation draws the (initial) controls in the properties view based * on the input. In this case, there are initially no widgets to prepare. */ @Override public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) { super.createControls(parent, aTabbedPropertySheetPage); // Get the default background color. Color backgroundColor = parent.getBackground(); // Create a section for the data composites. section = getWidgetFactory().createSection(parent, ExpandableComposite.SHORT_TITLE_BAR | Section.DESCRIPTION); section.setText("Node properties"); section.setDescription("All properties available for " + "this node can be modified here."); section.setBackground(backgroundColor); // Create the Composite that contains all DataComponentComposites. final Composite client = new Composite(section, SWT.NONE); GridLayout clientLayout = new GridLayout(2, false); // Set the margins and spacing based on the tabbed property constants. clientLayout.marginLeft = ITabbedPropertyConstants.HMARGIN; clientLayout.marginRight = ITabbedPropertyConstants.HMARGIN; clientLayout.marginTop = ITabbedPropertyConstants.VMARGIN; clientLayout.marginBottom = ITabbedPropertyConstants.VMARGIN; clientLayout.horizontalSpacing = ITabbedPropertyConstants.HSPACE; clientLayout.verticalSpacing = ITabbedPropertyConstants.VSPACE; client.setLayout(clientLayout); // Make the background of the section client white unless ICE is in // debug mode. if (System.getProperty("DebugICE") == null) { client.setBackground(backgroundColor); } else { client.setBackground( Display.getCurrent().getSystemColor(SWT.COLOR_RED)); } // Set the client area for the section. section.setClient(client); // Get the property viewer's ScrolledComposite and its first Composite // (its "client" Composite). scrollCompositeClient = section.getParent().getParent().getParent() .getParent(); scrollComposite = (ScrolledComposite) scrollCompositeClient.getParent(); // Add a listener to resize the Section's properties and update the // ScrollComposite's minimum bounds correctly based on the displayed // properties. scrollComposite.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { resizePropertyView(); } }); // Create the type Combo Composite. typeComposite = createTypeComposite(client); GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false); gridData.horizontalSpan = 2; typeComposite.setLayoutData(gridData); // Refresh the contents of the type Combo and its containing Composite. refreshTypeWidgets(); // Create the table of properties. tableViewer = createTableViewer(client); // Set the table's layout data so it occupies all spare space in the // property section client. tableViewer.getControl() .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); // Create the add/delete buttons. Composite buttonComposite = createButtons(client); // The button Composite shouldn't grab any space. Align it along the // center and top of the space to the right of the table. buttonComposite .setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false)); return; }