public void fillGradientRectangle( int x, int y, int width, int height, boolean vertical ) { gc.fillGradientRectangle( x, y, width, height, vertical ); }
public void fillGradientRectangle( int x, int y, int width, int height, boolean vertical ) { gc.fillGradientRectangle( x, y, width, height, vertical ); }
public void drawPentahoGradient( Display display, GC gc, Rectangle rect, boolean vertical ) { if ( !vertical ) { gc.setForeground( display.getSystemColor( SWT.COLOR_WIDGET_BACKGROUND ) ); gc.setBackground( GUIResource.getInstance().getColorPentaho() ); gc.fillGradientRectangle( rect.x, rect.y, 2 * rect.width / 3, rect.height, vertical ); gc.setForeground( GUIResource.getInstance().getColorPentaho() ); gc.setBackground( display.getSystemColor( SWT.COLOR_WIDGET_BACKGROUND ) ); gc.fillGradientRectangle( rect.x + 2 * rect.width / 3, rect.y, rect.width / 3 + 1, rect.height, vertical ); } else { gc.setForeground( display.getSystemColor( SWT.COLOR_WIDGET_BACKGROUND ) ); gc.setBackground( GUIResource.getInstance().getColorPentaho() ); gc.fillGradientRectangle( rect.x, rect.y, rect.width, 2 * rect.height / 3, vertical ); gc.setForeground( GUIResource.getInstance().getColorPentaho() ); gc.setBackground( display.getSystemColor( SWT.COLOR_WIDGET_BACKGROUND ) ); gc.fillGradientRectangle( rect.x, rect.y + 2 * rect.height / 3, rect.width, rect.height / 3 + 1, vertical ); } }
gc.setForeground(color1); gc.setBackground(color2); gc.fillGradientRectangle(rect.x, rect.y, rect.width, rect.height, true); } finally {
Listener listener = new Listener () { public void handleEvent (Event e) { GC gc = e.gc; Rectangle rect = composite.getClientArea (); Point offset = ((Control)e.widget).toControl(composite.toDisplay(0, 0)); Color color1 = new Color (display, 0, 0, 0); Color color2 = new Color (display, 255, 255, 255); gc.setForeground(color1); gc.setBackground(color2); gc.fillGradientRectangle (rect.x + offset.x, rect.y + offset.y, rect.width, rect.height , true); } } composite.addListener (SWT.Paint, listener); label.addListener(SWT.Paint, listener);
/** * Fills a gradient rectangle of in the direction specified. * * @param x left of resulting rectangle * @param y top of resulting rectangle * @param width width of resulting rectangle * @param height height of resulting rectangle * @param vertical whether the gradient should be drawn vertically or * horizontally */ public void fillGradientRectangle(final double x, final double y, final double width, final double height, final boolean vertical) { TEMP_RECT.setRect(x, y, width, height); SWTShapeManager.transform(TEMP_RECT, transform); SWTShapeManager.awtToSWT(TEMP_RECT, SWT_RECT); gc.fillGradientRectangle(SWT_RECT.x, SWT_RECT.y, SWT_RECT.width, SWT_RECT.height, vertical); }
@Override public void handleEvent(Event e) { if (composite.isDisposed()) return; Rectangle bounds = composite.getBounds(); GC gc = e.gc; gc.setForeground(colors.getColor(IFormColors.SEPARATOR)); if (colors.getBackground() != null) gc.setBackground(colors.getBackground()); gc.fillGradientRectangle(0, 0, bounds.width, bounds.height, false); } });
table.addListener(SWT.EraseItem, new Listener() { public void handleEvent(Event event) { event.detail &= ~SWT.HOT; if ((event.detail & SWT.SELECTED) == 0) return; int clientWidth = ((Composite)event.widget).getClientArea().width; GC gc = event.gc; Color oldForeground = gc.getForeground(); Color oldBackground = gc.getBackground(); gc.setBackground(event.display.getColor(SWT.COLOR_YELLOW)); gc.setForeground(event.display.getColor(SWT.COLOR_BLUE)); gc.fillGradientRectangle(0, event.y, clientWidth, event.height, true); gc.setForeground(oldForeground); gc.setBackground(oldBackground); event.detail &= ~SWT.SELECTED; } });
/** * Creates the composite that can server as a separator between various * parts of a form. Separator height should be controlled by setting the * height hint on the layout data for the composite. * * @param parent * the separator parent * @return the separator widget */ public Composite createCompositeSeparator(Composite parent) { checkDisposed(); final Composite composite = new Composite(parent, orientation); composite.addListener(SWT.Paint, e -> { if (composite.isDisposed()) return; Rectangle bounds = composite.getBounds(); GC gc = e.gc; gc.setForeground(colors.getColor(IFormColors.SEPARATOR)); if (colors.getBackground() != null) gc.setBackground(colors.getBackground()); gc.fillGradientRectangle(0, 0, bounds.width, bounds.height, false); }); if (parent instanceof Section) ((Section) parent).setSeparatorControl(composite); return composite; }
void fillRectangle(Color c, GC gc, int x, int y, int width, int height) { if (c == null) return; gc.setBackground(c); if (settings.getRoundBox()){ gc.fillRoundRectangle(x, y, width, height, ROUND_BOX_ARC, ROUND_BOX_ARC); } else { if (settings.getFillGradient() && settings.getFillGradientColor()!=null) { gc.setBackground(settings.getFillGradientColor()); gc.setForeground(c); gc.fillGradientRectangle(x, y, width, height, false); }else { gc.fillRectangle(x, y, width, height); } } }
@Override public Image createImage(boolean returnMissingImageOnError, Device device) { Image image = new Image(device, 1, fLength); Color color1 = new Color(device, fRGBs[0]); Color color2 = new Color(device, fRGBs[1]); image.setBackground(color1); GC gc = new GC(image); gc.setBackground(color1); gc.fillRectangle(0, 0, 1, fLength); gc.setForeground(color2); gc.setBackground(color1); gc.fillGradientRectangle(0, fMarginHeight + 2, 1, fTheight - 2, true); gc.dispose(); color1.dispose(); color2.dispose(); return image; }
@Override public Image createImage(boolean returnMissingImageOnError, Device device) { Image image = new Image(device, 1, fLength); Color color1 = new Color(device, fRGBs[0]); Color color2 = new Color(device, fRGBs[1]); image.setBackground(color1); GC gc = new GC(image); gc.setBackground(color1); gc.fillRectangle(0, 0, 1, fLength); gc.setForeground(color2); gc.setBackground(color1); gc.fillGradientRectangle(0, fMarginHeight + 2, 1, fTheight - 2, true); gc.dispose(); color1.dispose(); color2.dispose(); return image; }
@Override public Image createImage(boolean returnMissingImageOnError, Device device) { Image image = new Image(device, 1, fLength); Color color1 = new Color(device, fRGBs[0]); Color color2 = new Color(device, fRGBs[1]); image.setBackground(color1); GC gc = new GC(image); gc.setBackground(color1); gc.fillRectangle(0, 0, 1, fLength); gc.setForeground(color2); gc.setBackground(color1); gc.fillGradientRectangle(0, fMarginHeight + 2, 1, fTheight - 2, true); gc.dispose(); color1.dispose(); color2.dispose(); return image; } }
@Override public Image createImage(boolean returnMissingImageOnError, Device device) { Image image = new Image(device, 1, fLength); Color color1 = new Color(device, fRGBs[0]); Color color2 = new Color(device, fRGBs[1]); image.setBackground(color1); GC gc = new GC(image); gc.setBackground(color1); gc.fillRectangle(0, 0, 1, fLength); gc.setForeground(color2); gc.setBackground(color1); gc.fillGradientRectangle(0, fMarginHeight + 2, 1, fTheight - 2, true); gc.dispose(); color1.dispose(); color2.dispose(); return image; } }
gc.setForeground (display.getSystemColor (SWT.COLOR_TITLE_BACKGROUND)); gc.setBackground (display.getSystemColor (SWT.COLOR_TITLE_BACKGROUND_GRADIENT)); gc.fillGradientRectangle (x, y, width, headerHeight, true); if (expanded) { gc.setForeground (display.getSystemColor (SWT.COLOR_TITLE_BACKGROUND_GRADIENT));
protected void paintRect(GC gc, int x, int y, Color a, Color b, Color c) { int[] p = new int[] { 0, 2, 2, 0, 30, 0, 32, 2, 32, 30, 30, 32, 2, 32, 0, 30}; int[] q = new int[p.length]; for (int i = 0; i < p.length / 2; i++) { q[i*2] = p[i*2] + x; q[i*2+1] = p[i*2+1] + y; } Region region = new Region(getDisplay()); region.add(q); gc.setClipping(region); gc.setBackground(a); gc.setForeground(b); gc.fillGradientRectangle(x, y, 32, 32, true); gc.setClipping((Region)null); gc.setForeground(c); gc.drawPolygon(q); gc.setForeground(getForeground()); gc.setBackground(getBackground()); String st = "Tomcat Test Environment"; Point stp = gc.stringExtent(st); gc.drawString(st, x+16 - stp.x / 2, y + 32 + 2); }
gc.setForeground (display.getSystemColor (SWT.COLOR_TITLE_BACKGROUND)); gc.setBackground (display.getSystemColor (SWT.COLOR_TITLE_BACKGROUND_GRADIENT)); gc.fillGradientRectangle (x, y, width, headerHeight, true); if (expanded) { gc.setForeground (display.getSystemColor (SWT.COLOR_TITLE_BACKGROUND_GRADIENT));
public void handleEvent(Event event) { if (shouldApplyGradient(event)) { Scrollable scrollable = (Scrollable) event.widget; GC gc = event.gc; Rectangle area = scrollable.getClientArea(); Rectangle rect = event.getBounds(); /* Paint the selection beyond the end of last column */ expandRegion(event, scrollable, gc, area); /* Draw Gradient Rectangle */ Color oldForeground = gc.getForeground(); Color oldBackground = gc.getBackground(); gc.setForeground(categoryGradientEnd); gc.drawLine(0, rect.y, area.width, rect.y); gc.setForeground(categoryGradientStart); gc.setBackground(categoryGradientEnd); // gc.setForeground(categoryGradientStart); // gc.setBackground(categoryGradientEnd); // gc.setForeground(new Clr(Display.getCurrent(), 255, 0, 0)); gc.fillGradientRectangle(0, rect.y + 1, area.width, rect.height, true); /* Bottom Line */ // gc.setForeground(); gc.setForeground(categoryGradientEnd); gc.drawLine(0, rect.y + rect.height - 1, area.width, rect.y + rect.height - 1); gc.setForeground(oldForeground); gc.setBackground(oldBackground); /* Mark as Background being handled */ event.detail &= ~SWT.BACKGROUND; } }
/** * @param e */ protected void drawTitleBackground(PaintEvent e) { Rectangle bounds = getClientArea(); label.setBackground(new Color[] { factory.getColors().getColor(IFormColors.H_GRADIENT_END), factory.getColors().getColor(IFormColors.H_GRADIENT_START) }, new int[] { 100 }, true); Color bg = factory.getColors().getColor(IFormColors.H_GRADIENT_END); Color gbg = factory.getColors().getColor(IFormColors.H_GRADIENT_START); GC gc = e.gc; gc.setForeground(bg); gc.setBackground(gbg); gc.fillGradientRectangle(bounds.x, bounds.y, bounds.width, bounds.height, true); // background bottom separator gc.setForeground(factory.getColors().getColor( IFormColors.H_BOTTOM_KEYLINE1)); gc.drawLine(bounds.x, bounds.height - 2, bounds.x + bounds.width - 1, bounds.height - 2); gc.setForeground(factory.getColors().getColor( IFormColors.H_BOTTOM_KEYLINE2)); gc.drawLine(bounds.x, bounds.height - 1, bounds.x + bounds.width - 1, bounds.height - 1); }
private void updateBackgroundImage() { FormToolkit toolkit = helpPart.getForm().getToolkit(); FormColors colors = toolkit.getColors(); Rectangle carea = container.getClientArea(); Image oldImage = bgImage; if (bgImage!=null) { Rectangle ibounds = bgImage.getBounds(); if (carea.height==ibounds.height) return; } bgImage = new Image(container.getDisplay(), 1, carea.height); GC gc = new GC(bgImage); gc.setBackground(colors.getColor(IFormColors.H_GRADIENT_END)); gc.setForeground(colors.getColor(IFormColors.H_GRADIENT_START)); gc.fillGradientRectangle(0, 0, 1, carea.height, true); gc.setForeground(colors.getColor(IFormColors.H_BOTTOM_KEYLINE2)); gc.drawLine(0, 0, 1, 0); gc.setForeground(colors.getColor(IFormColors.H_BOTTOM_KEYLINE1)); gc.drawLine(0, 1, 1, 1); gc.dispose(); container.setBackgroundImage(bgImage); if (oldImage != null && !oldImage.isDisposed()) { oldImage.dispose(); } }