public void switchForegroundBackgroundColors() { Color fg = gc.getForeground(); Color bg = gc.getBackground(); gc.setForeground( bg ); gc.setBackground( fg ); }
public void switchForegroundBackgroundColors() { Color fg = gc.getForeground(); Color bg = gc.getBackground(); gc.setForeground( bg ); gc.setBackground( fg ); }
Color fore = gc.getForeground(); Color back = gc.getBackground(); gc.setBackground( fore );
private void drawNegated( GC gc, int x, int y, Condition condition ) { Color color = gc.getForeground(); if ( hover_not ) { gc.setBackground( gray ); } gc.fillRectangle( Real2Screen( size_not ) ); gc.drawRectangle( Real2Screen( size_not ) ); if ( condition.isNegated() ) { if ( hover_not ) { gc.setForeground( green ); } gc.drawText( STRING_NOT, size_not.x + 5 + offsetx, size_not.y + 2 + offsety, SWT.DRAW_TRANSPARENT ); gc.drawText( STRING_NOT, size_not.x + 6 + offsetx, size_not.y + 2 + offsety, SWT.DRAW_TRANSPARENT ); if ( hover_not ) { gc.setForeground( color ); } } else { if ( hover_not ) { gc.setForeground( red ); gc.drawText( STRING_NOT, size_not.x + 5 + offsetx, size_not.y + 2 + offsety, SWT.DRAW_TRANSPARENT ); gc.drawText( STRING_NOT, size_not.x + 6 + offsetx, size_not.y + 2 + offsety, SWT.DRAW_TRANSPARENT ); gc.setForeground( color ); } } if ( hover_not ) { gc.setBackground( bg ); } }
public Color getForeground() { return gc.getForeground(); }
/** * Returns the current color for this graphics context. * * @return The current color. * * @see #setColor(Color) */ @Override public Color getColor() { // TODO: it might be a good idea to keep a reference to the color // specified in setPaint() or setColor(), rather than creating a // new object every time getPaint() is called. return SWTUtils.toAwtColor(this.gc.getForeground()); }
/** * Returns the current paint for this graphics context. * * @return The current paint. * * @see #setPaint(Paint) */ @Override public Paint getPaint() { // TODO: it might be a good idea to keep a reference to the color // specified in setPaint() or setColor(), rather than creating a // new object every time getPaint() is called. return SWTUtils.toAwtColor(this.gc.getForeground()); }
/** {@inheritDoc} */ public Color getColor() { final org.eclipse.swt.graphics.Color color = gc.getForeground(); final Color awtColor = new Color(color.getRed(), color.getGreen(), color.getBlue()); return awtColor; }
/** * Perform a switch between foreground and background * color of gc. This is needed for consistency with * the AWT behaviour, and is required notably for the * filling methods. */ private void switchColors() { org.eclipse.swt.graphics.Color bg = this.gc.getBackground(); org.eclipse.swt.graphics.Color fg = this.gc.getForeground(); this.gc.setBackground(fg); this.gc.setForeground(bg); }
private void doDispatch() { int lineWidth = gc.getLineWidth(); Color foreground = gc.getForeground(); int alpha = gc.getAlpha(); dispatchOperations(); restoreLastSettings( lineWidth, foreground, alpha ); }
private void drawUnderline(GC gc, int swidth, int x, int y, boolean hover, boolean rolloverMode) { if (underline || rolloverMode) { Color saved = null; if (rolloverMode && !hover) { saved = gc.getForeground(); gc.setForeground(gc.getBackground()); } gc.drawLine(x, y, x + swidth-1, y); if (saved != null) gc.setForeground(saved); } }
private void drawUnderline(GC gc, int swidth, int x, int y, boolean hover, boolean rolloverMode) { if (underline || rolloverMode) { Color saved = null; if (rolloverMode && !hover) { saved = gc.getForeground(); gc.setForeground(gc.getBackground()); } gc.drawLine(x, y, x + swidth-1, y); if (saved != null) gc.setForeground(saved); } }
@Override public void handleEvent(Event event) { Color old = event.gc.getForeground(); event.gc.setForeground(Colors.black); int char_width = event.gc.getFontMetrics().getAverageCharWidth(); String pb_text = pbt.convert(result.getSelection()); event.gc.drawText(pb_text, (result.getSize().x - pb_text.length() * char_width )/2, -1, true); event.gc.setForeground(old); } });
public void handleEvent(Event e) { Color gcForeground = e.gc.getForeground(); Rectangle bounds = ((Composite) e.widget).getBounds(); Color border = e.widget.getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW); e.gc.setForeground(border); e.gc.drawLine(bounds.width - 1, 0, bounds.width - 1, bounds.height); e.gc.setForeground(gcForeground); } });
@Override void doPaint(GC gc, ILineRange visibleLines) { Color foreground= gc.getForeground(); if (visibleLines != null) { if (fRevisionPainter.hasInformation()) fRevisionPainter.paint(gc, visibleLines); else if (fDiffPainter.hasInformation()) // don't paint quick diff colors if revisions are painted fDiffPainter.paint(gc, visibleLines); } gc.setForeground(foreground); if (fShowNumbers || fCharacterDisplay) super.doPaint(gc, visibleLines); }
@Override public void paint(GC gc, boolean hover, Hashtable<String, Object> resourceTable, boolean selected, SelectionData selData, Rectangle repaintRegion) { boolean rolloverMode = settings.getHyperlinkUnderlineMode() == HyperlinkSettings.UNDERLINE_HOVER; underline = settings.getHyperlinkUnderlineMode() == HyperlinkSettings.UNDERLINE_ALWAYS; Color savedFg = gc.getForeground(); Color newFg = hover ? settings.getActiveForeground() : settings.getForeground(); if (newFg!=null) gc.setForeground(newFg); super.paint(gc, hover, resourceTable, selected, rolloverMode, selData, repaintRegion); gc.setForeground(savedFg); }
@Override public void paint(GC gc, boolean hover, Hashtable<String, Object> resourceTable, boolean selected, SelectionData selData, Rectangle repaintRegion) { boolean rolloverMode = settings.getHyperlinkUnderlineMode() == HyperlinkSettings.UNDERLINE_HOVER; underline = settings.getHyperlinkUnderlineMode() == HyperlinkSettings.UNDERLINE_ALWAYS; Color savedFg = gc.getForeground(); Color newFg = hover ? settings.getActiveForeground() : settings.getForeground(); if (newFg!=null) gc.setForeground(newFg); super.paint(gc, hover, resourceTable, selected, rolloverMode, selData, repaintRegion); gc.setForeground(savedFg); }
public static void debugLayout(final Composite c, final int color) { c.addPaintListener(e -> { Color save = e.gc.getForeground(); e.gc.setForeground(Display.getCurrent().getSystemColor(color)); e.gc.drawRectangle(1, 1, c.getBounds().width - 1, c.getBounds().width - 1); // e.gc.drawLine(1, 1, c.getBounds().width - 1, c.getBounds().height - 1); e.gc.setForeground(save); }); }
@Override void doPaint(GC gc, ILineRange visibleLines) { Color foreground= gc.getForeground(); if (visibleLines != null) { if (fRevisionPainter.hasInformation()) { fRevisionPainter.setZoom(fZoom); fRevisionPainter.paint(gc, visibleLines); } else if (fDiffPainter.hasInformation()) { // don't paint quick diff colors if revisions are painted fDiffPainter.setZoom(fZoom); fDiffPainter.paint(gc, visibleLines); } } gc.setForeground(foreground); if (fShowNumbers || fCharacterDisplay) super.doPaint(gc, visibleLines); }
public void paintControl(PaintEvent event) { Control control = (Control) event.widget; Rectangle rect = new Rectangle(0, 0, control.getSize().x, control.getSize().y); GC gc = event.gc; //System.out.println(event.count); Color color = gc.getForeground(); gc.setForeground(event.display.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW)); gc.drawLine(rect.x, rect.y, rect.width, rect.y); gc.drawLine(rect.x, rect.y, rect.x, rect.height); gc.setForeground(event.display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW)); gc.drawLine(rect.x, rect.height-1, rect.width, rect.height-1); gc.drawLine(rect.width-1, rect.y, rect.width-1, rect.height); gc.setForeground(color); }