tabFolder_2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); tabFolder_2.setBounds(0, 0, 156, 125); tabFolder_2.setSelectionBackground(Display.getCurrent().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT));
tabFolder.setSelectionBackground(Display.getCurrent().getSystemColor( SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT)); tabFolder.setFocus(); tabFolder_1.setSelectionBackground(Display.getCurrent().getSystemColor( SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT));
CTabFolder folder = new CTabFolder(shell, SWT.BORDER); folder.setBackground(new Color[]{display.getSystemColor(SWT.COLOR_YELLOW), display.getSystemColor(SWT.COLOR_RED)}, new int[]{100}, true); folder.setSelectionBackground(new Color[]{display.getSystemColor(SWT.COLOR_WHITE), display.getSystemColor(SWT.COLOR_BLUE)}, new int[]{100}, true);
tabFolder.setSelectionBackground( tabColor ); break; default:
/** * Specify a gradient of colours to be draw in the background of the selected tab. * For example to draw a gradient that varies from dark blue to blue and then to * white, use the following call to setBackground: * <pre> * cfolder.setBackground(new Color[]{display.getSystemColor(SWT.COLOR_DARK_BLUE), * display.getSystemColor(SWT.COLOR_BLUE), * display.getSystemColor(SWT.COLOR_WHITE), * display.getSystemColor(SWT.COLOR_WHITE)}, * new int[] {25, 50, 100}); * </pre> * * @param colors an array of Color that specifies the colors to appear in the gradient * in order of appearance left to right. The value <code>null</code> clears the * background gradient. The value <code>null</code> can be used inside the array of * Color to specify the background color. * @param percents an array of integers between 0 and 100 specifying the percent of the width * of the widget at which the color should change. The size of the percents array must be one * less than the size of the colors array. * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> * </ul> */ public void setSelectionBackground(Color[] colors, int[] percents) { setSelectionBackground(colors, percents, false); } /**
/** * Specify a gradient of colours to be draw in the background of the selected tab. * For example to draw a gradient that varies from dark blue to blue and then to * white, use the following call to setBackground: * <pre> * cfolder.setBackground(new Color[]{display.getSystemColor(SWT.COLOR_DARK_BLUE), * display.getSystemColor(SWT.COLOR_BLUE), * display.getSystemColor(SWT.COLOR_WHITE), * display.getSystemColor(SWT.COLOR_WHITE)}, * new int[] {25, 50, 100}); * </pre> * * @param colors an array of Color that specifies the colors to appear in the gradient * in order of appearance left to right. The value <code>null</code> clears the * background gradient. The value <code>null</code> can be used inside the array of * Color to specify the background color. * @param percents an array of integers between 0 and 100 specifying the percent of the width * of the widget at which the color should change. The size of the percents array must be one * less than the size of the colors array. * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> * </ul> */ public void setSelectionBackground(Color[] colors, int[] percents) { setSelectionBackground(colors, percents, false); } /**
/** * Specify a gradient of colours to be draw in the background of the selected tab. * For example to draw a gradient that varies from dark blue to blue and then to * white, use the following call to setBackground: * <pre> * cfolder.setBackground(new Color[]{display.getSystemColor(SWT.COLOR_DARK_BLUE), * display.getSystemColor(SWT.COLOR_BLUE), * display.getSystemColor(SWT.COLOR_WHITE), * display.getSystemColor(SWT.COLOR_WHITE)}, * new int[] {25, 50, 100}); * </pre> * * @param colors an array of Color that specifies the colors to appear in the gradient * in order of appearance left to right. The value <code>null</code> clears the * background gradient. The value <code>null</code> can be used inside the array of * Color to specify the background color. * @param percents an array of integers between 0 and 100 specifying the percent of the width * of the widget at which the color should change. The size of the percents array must be one * less than the size of the colors array. * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> * </ul> */ public void setSelectionBackground(Color[] colors, int[] percents) { setSelectionBackground(colors, percents, false); } /**
/** Helper function to avoid setting colors unnecessarily */ public static void setSelectionBackground(CTabFolder folder, Color newColor) { if (!equals(folder.getSelectionBackground(), newColor)) { folder.setSelectionBackground(newColor); } } }
@Override protected void applyCSSProperty(Control control, String property, CSSValue value, String pseudo, CSSEngine engine) throws Exception { if (!(control instanceof CTabFolder)) { return; } if (value.getCssValueType() == CSSValue.CSS_VALUE_LIST) { Gradient grad = (Gradient) engine.convert(value, Gradient.class, control.getDisplay()); CTabFolder folder = ((CTabFolder) control); if (grad.getValues().isEmpty()) { folder.setSelectionBackground(null, null, true); return; } Color[] colors = CSSSWTColorHelper.getSWTColors(grad, folder.getDisplay(), engine); int[] percents = CSSSWTColorHelper.getPercents(grad); folder.setSelectionBackground(colors, percents, true); } }
@Override public void applyCSSPropertyBackgroundImage(Object element, CSSValue value, String pseudo, CSSEngine engine) throws Exception { // Widget control = (Widget) element; Widget widget = (Widget) ((WidgetElement) element).getNativeWidget(); Image image = (Image) engine.convert(value, Image.class, widget.getDisplay()); if (widget instanceof CTabFolder && "selected".equals(pseudo)) { ((CTabFolder) widget).setSelectionBackground(image); } else if (widget instanceof Button) { Button button = ((Button) widget); // Image oldImage = button.getImage(); // if (oldImage != null) // oldImage.dispose(); CSSSWTImageHelper.setImage(button, image); } else if (widget instanceof Control) { CSSSWTImageHelper.setBackgroundImage((Control) widget, image); } }
private void styleTabFolder(CTabFolder folder) { Display display = folder.getDisplay(); folder.setSelectionBackground(new Color[]{ display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND), display.getSystemColor(SWT.COLOR_TITLE_BACKGROUND_GRADIENT) }, new int[]{75}, true); folder.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); }
public void applyCSSPropertyBackgroundImage(Object element, CSSValue value, String pseudo, CSSEngine engine) throws Exception { // Widget control = (Widget) element; Widget control = (Widget) ((WidgetElement) element).getNativeWidget(); Image image = (Image) engine.convert(value, Image.class, control .getDisplay()); if (control instanceof CTabFolder && "selected".equals(pseudo)) { ((CTabFolder) control).setSelectionBackground(image); } else if (control instanceof Button) { Button button = ((Button) control); // Image oldImage = button.getImage(); // if (oldImage != null) // oldImage.dispose(); button.setImage(image); } else { try { if(control instanceof Control) ((Control) control).setBackgroundImage(image); } catch (Throwable e) { //TODO replace with eclipse logging // if (logger.isWarnEnabled()) // logger // .warn("Impossible to manage backround-image, This SWT version doesn't support control.setBackgroundImage(Image image) Method"); } } }
@Override protected void applyCSSProperty(Control control, String property, CSSValue value, String pseudo, CSSEngine engine) throws Exception { if (!(control instanceof CTabFolder)) return; if (value.getCssValueType() == CSSValue.CSS_VALUE_LIST) { Gradient grad = (Gradient) engine.convert(value, Gradient.class, control.getDisplay()); CTabFolder folder = ((CTabFolder) control); Color[] colors = CSSSWTColorHelper.getSWTColors(grad, folder.getDisplay(), engine); int[] percents = CSSSWTColorHelper.getPercents(grad); folder.setSelectionBackground(colors, percents, true); } }
/** * Sets the background color of CTabItem 0. */ void setSelectionBackground () { if (!instance.startup) { tabFolder1.setSelectionBackground(selectionBackgroundColor); } // Set the selection background item's image to match the background color of the selection. Color color = selectionBackgroundColor; if (color == null) color = tabFolder1.getSelectionBackground (); TableItem item = colorAndFontTable.getItem(SELECTION_BACKGROUND_COLOR); Image oldImage = item.getImage(); if (oldImage != null) oldImage.dispose(); item.setImage (colorImage(color)); }
private void customize() { ColorRegistry reg = JFaceResources.getColorRegistry(); Color c1 = reg.get("org.eclipse.ui.workbench.ACTIVE_TAB_BG_START"), //$NON-NLS-1$ c2 = reg.get("org.eclipse.ui.workbench.ACTIVE_TAB_BG_END"); //$NON-NLS-1$ customizationsTabFolder.setSelectionBackground(new Color[] {c1, c2}, new int[] {100}, true); customizationsTabFolder.setSelectionForeground(reg.get("org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR")); //$NON-NLS-1$ customizationsTabFolder.setSimple(PlatformUI.getPreferenceStore().getBoolean(IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS)); }
@Override public void reset() { CTabFolder folder = (CTabFolder) getWidget(); folder.setSelectionBackground((Color) null); folder.setSelectionForeground((Color) null); folder.setSelectionBackground((Image) null); folder.setBackground(null, null); resetChildrenBackground(folder); if (folder.getRenderer() instanceof ICTabRendering) { ICTabRendering renderer = (ICTabRendering) folder .getRenderer(); folder.setRenderer(null); renderer.setSelectedTabFill(null); renderer.setTabOutline(null); renderer.setInnerKeyline(null); renderer.setOuterKeyline(null); renderer.setShadowColor(null); } super.reset(); }
if ("selected".equals(pseudo)) { folder.setSelectionBackground(newColor); } else { folder.setBackground(newColor); if (widget instanceof CTabItem && "selected".equals(pseudo)) { CTabFolder folder = ((CTabItem) widget).getParent(); folder.setSelectionBackground( CSSSWTColorHelper.getSWTColors(grad, folder.getDisplay(), engine), CSSSWTColorHelper.getPercents(grad),
/** * Create contents of the view part. * * @param parent */ @Override public void createPartControl( Composite parent ) { Composite container = toolkit.createComposite( parent, SWT.NONE ); toolkit.paintBordersFor( container ); container.setLayout( new FillLayout( SWT.HORIZONTAL ) ); CTabFolder tabFolder = new CTabFolder( container, SWT.BORDER | SWT.BOTTOM ); toolkit.adapt( tabFolder ); toolkit.paintBordersFor( tabFolder ); tabFolder.setSelectionBackground( Display.getCurrent().getSystemColor( SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT ) ); CTabItem tbtmXml = new CTabItem( tabFolder, SWT.NONE ); tbtmXml.setText( "XML" ); Composite composite = new Composite( tabFolder, SWT.NONE ); tbtmXml.setControl( composite ); toolkit.paintBordersFor( composite ); composite.setLayout( new FillLayout( SWT.HORIZONTAL ) ); xmlText = new Text( composite, SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI ); xmlText.setEditable( false ); toolkit.adapt( xmlText, true, true ); tabFolder.setSelection( tbtmXml ); createActions(); initializeToolBar(); initializeMenu(); }
private CTabFolder createTabFolder(Composite parent) { CTabFolder folder = new CTabFolder(parent, SWT.NO_REDRAW_RESIZE | SWT.NO_TRIM | SWT.FLAT); ColorRegistry reg = JFaceResources.getColorRegistry(); Color c1 = reg.get("org.eclipse.ui.workbench.ACTIVE_TAB_BG_START"), //$NON-NLS-1$ c2 = reg.get("org.eclipse.ui.workbench.ACTIVE_TAB_BG_END"); //$NON-NLS-1$ folder.setSelectionBackground(new Color[] { c1, c2 }, new int[] { 100 }, true); folder.setSelectionForeground(reg.get("org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR")); //$NON-NLS-1$ folder.setSimple(PlatformUI.getPreferenceStore().getBoolean(IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS)); folder.setBorderVisible(true); folder.setFont(fViewPaneCanvas.getFont()); folder.addCTabFolder2Listener(new CTabFolder2Adapter() { @Override public void close(CTabFolderEvent event) { if (event.item.getData() instanceof MemoryViewTab) { RenderingViewPane.this.removeMemoryRendering(((MemoryViewTab) event.item.getData()).getRendering()); } event.doit = false; } }); return folder; }
/** * Set the folder colors and fonts */ private void setColorsAndFonts() { folder.setSelectionForeground(theme.getColorRegistry().get( IWorkbenchThemeConstants.ACTIVE_TAB_TEXT_COLOR)); folder.setForeground(theme.getColorRegistry().get( IWorkbenchThemeConstants.INACTIVE_TAB_TEXT_COLOR)); Color[] colors = new Color[2]; colors[0] = theme.getColorRegistry().get( IWorkbenchThemeConstants.INACTIVE_TAB_BG_START); colors[1] = theme.getColorRegistry().get( IWorkbenchThemeConstants.INACTIVE_TAB_BG_END); colors[0] = theme.getColorRegistry().get( IWorkbenchThemeConstants.ACTIVE_TAB_BG_START); colors[1] = theme.getColorRegistry().get( IWorkbenchThemeConstants.ACTIVE_TAB_BG_END); folder.setSelectionBackground(colors, new int[] { theme .getInt(IWorkbenchThemeConstants.ACTIVE_TAB_PERCENT) }, theme .getBoolean(IWorkbenchThemeConstants.ACTIVE_TAB_VERTICAL)); folder.setFont(theme.getFontRegistry().get( IWorkbenchThemeConstants.TAB_TEXT_FONT)); }