/** * */ @Override public void render(XCalendarFrame frame) { // Background final GC gc = frame.getGc(); final XCalendarModel model = popup.getModel(); final XCalendarTheme theme = model.getTheme(); final boolean hovered = this.mouse.isEntered(); int x = bounds.x, y = bounds.y, w = bounds.width, h = bounds.height; gc.setBackground(theme.getBackground(true, false, false, hovered)); gc.fillRoundRectangle(x, y, w, h, theme.getArc(), theme.getArc()); // Foreground String text = chevron_up; gc.setForeground(theme.getToolBarBackground(hovered)); gc.setFont(Fonts.getAwesomeFont()); final Point size = extent(gc, text); gc.drawText(text, x + 1 + ((w - size.x) >> 1), y + 1 + ((h - size.y) >> 1)); }
public static void drawString(GC gc, String str, float x, float y, float width, float height, int bgAlpha) { if (str == null) return; org.eclipse.swt.graphics.Point size = gc.stringExtent(str); int posX = Math.round(x + width / 2 - size.x / 2); int posY = Math.round(y + height / 2 - size.y / 2); if (bgAlpha >= 255) { gc.drawString(str, posX, posY); } else { gc.drawString(str, posX, posY, true); if (bgAlpha > 0) { gc.setAlpha(bgAlpha); gc.fillRectangle(posX, posY, size.x, size.y); gc.setAlpha(255); } } }
/** * Paints an looping arc from scr to tgt. * <p/> * <b>Assumption:</b> The tgt is located right/below of the src. */ public static float[] arcSelf(GC gc, Point src, Point tgt) { Path path = new Path(gc.getDevice()); int diffH = 10; int diff = diffH * 3; path.moveTo((int) src.x, (int) src.y); path.cubicTo( (int) src.x + diff, (int) src.y - diffH, (int) tgt.x, (int) tgt.y - diff, (int) tgt.x, (int) tgt.y); gc.drawPath(path); float[] pp = path.getPathData().points; return pp; }
/** * */ @Override public void render(XCalendarFrame frame) { // Background final GC gc = frame.getGc(); final XCalendarModel model = popup.getModel(); final XCalendarTheme theme = model.getTheme(); final boolean hovered = this.mouse.isEntered(); int x = bounds.x, y = bounds.y, w = bounds.width, h = bounds.height; gc.setBackground(theme.getBackground(true, false, false, hovered)); gc.fillRoundRectangle(x, y, w, h, theme.getArc(), theme.getArc()); // Foreground String text = chevron_left; gc.setForeground(theme.getForeground(true, false, true)); gc.setFont(Fonts.getAwesomeFont()); final Point size = extent(gc, text); gc.drawText(text, x + 1 + ((w - size.x) >> 1), y + 1 + ((h - size.y) >> 1)); }
/** * Pre-compute column widths for the file tab. * These can and are over-ridden by user sizing. */ protected void computeColumnWidths(int format) { List headers = disks[0].getFileColumnHeaders(format); int[] headerWidths = new int[headers.size()]; GC gc = new GC(shell); for (int i=0; i<headers.size(); i++) { FileColumnHeader header = (FileColumnHeader) headers.get(i); if (header.getTitle().length() >= header.getMaximumWidth()) { headerWidths[i] = gc.stringExtent(header.getTitle()).x + 2 * gc.stringExtent(textBundle.get("WidestCharacter")).x; //$NON-NLS-1$ } else { headerWidths[i] = gc.stringExtent( textBundle.get("WidestCharacter")).x //$NON-NLS-1$ * header.getMaximumWidth(); } } gc.dispose(); gc = null; columnWidths.put(new Integer(format), headerWidths); }
/** * draw temporary labels for external nodes (and save their bounds for later) */ private List<Rectangle> drawTemporaryLabels(GC gc) { final List<Rectangle> nodesExternalBounds = new ArrayList<>(); final Rectangle clip = GraphUtils.getClip(gc); float px = clip.x + clip.width; float py = clip.y + clip.height; for (String currNE : endNodesExternal) { final org.eclipse.swt.graphics.Point size = gc.stringExtent(currNE); py -= size.y + 4; final float rx = px - (size.x + 4); final Rectangle b = new Rectangle(rx, py, size.x, size.y); nodesExternalBounds.add(b); // TODO string extent will be computed twice :( GraphUtils.drawString(gc, currNE, b.x + b.width / 2, b.y + b.height / 2); } return nodesExternalBounds; }
/** Paints an edge */ void paintEdge(GC gc, Node srcN, Node tgtN) { setColor(gc); Point src = srcN.getCenter(); Point tgt = tgtN.getCenter(); Point tgtB; if (srcN == tgtN) { tgtB = paintSelfArc(gc, tgtN, tgt); } else if (isReverseArc(src, tgt)) { tgtB = paintReverseArc(gc, srcN, tgtN, src, tgt); } else { tgtB = paintArc(gc, srcN, tgtN, src, tgt); } drawArrowHead(gc, tgt, tgtB); }
/** * */ @Override public void render(XCalendarFrame frame) { // Background final GC gc = frame.getGc(); final XCalendarModel model = popup.getModel(); final XCalendarTheme theme = model.getTheme(); final boolean hovered = this.mouse.isEntered(); int x = bounds.x, y = bounds.y, w = bounds.width, h = bounds.height; gc.setBackground(theme.getBackground(true, false, false, hovered)); gc.fillRoundRectangle(x, y, w, h, theme.getArc(), theme.getArc()); // Foreground String text = chevron_down; gc.setForeground(theme.getToolBarBackground(hovered)); gc.setFont(Fonts.getAwesomeFont()); final Point size = extent(gc, text); gc.drawText(text, x + 1 + ((w - size.x) >> 1), y + 1 + ((h - size.y) >> 1)); }
/** Draws the label between jumping control flow elements. */ void drawLabel(GC gc, Point p) { label = ""; for (ControlFlowType cfType : cfTypes) { switch (cfType) { case Break: case Continue: case Return: case Throw: case LoopEnter: case LoopReenter: case LoopInfinite: if (!label.isEmpty()) label += "|"; label += cfType.name(); break; default: } } org.eclipse.swt.graphics.Point size = gc.stringExtent(label); float x = p.x - size.x / 2; float y = p.y - size.y / 2; GraphUtils.drawString(gc, label, x, y); }
/** * Paints the Node */ public void paint(GC gc) { gc.setBackground(getBackgroundColor()); gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_BLACK)); gc.fillRoundRectangle(Math.round(x), Math.round(y), Math.round(width), Math.round(height), 5, 5); GraphUtils.drawString(gc, title, x, y, width, height, 0); if (hasOutgoingCrossLinksInternal || hasOutgoingCrossLinksExternal) { Color colorRed = gc.getDevice().getSystemColor(SWT.COLOR_RED); gc.setBackground(colorRed); gc.setForeground(colorRed); int ovalX = Math.round(x + width - SIZE_CROSS_LINKS_MARKER - 2); int ovalY = Math.round(y + 2); int ovalSize = Math.round(SIZE_CROSS_LINKS_MARKER); if (hasOutgoingCrossLinksInternal) { gc.fillOval(ovalX, ovalY, ovalSize, ovalSize); } else { gc.drawOval(ovalX, ovalY, ovalSize, ovalSize); } } gc.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); }
@Override public Rectangle resize ( final ResourceManager resourceManager, final Rectangle clientRectangle ) { if ( this.title == null || this.title.isEmpty () ) { return null; } final GC gc = new GC ( resourceManager.getDevice () ); gc.setFont ( createFont ( resourceManager ) ); try { final Point size = gc.textExtent ( this.title ); this.rect = new Rectangle ( clientRectangle.x, clientRectangle.y, clientRectangle.width, size.y + this.padding * 2 ); return new Rectangle ( clientRectangle.x, this.rect.y + this.rect.height, clientRectangle.width, clientRectangle.height - this.rect.height ); } finally { gc.dispose (); } }
void refreshLabel () { int colors = 0, cursors = 0, fonts = 0, gcs = 0, images = 0, regions = 0; for (int i=0; i<objects.length; i++) { Object object = objects [i]; if (object instanceof Color) colors++; if (object instanceof Cursor) cursors++; if (object instanceof Font) fonts++; if (object instanceof GC) gcs++; if (object instanceof Image) images++; if (object instanceof Region) regions++; } String string = ""; //$NON-NLS-1$ if (colors != 0) string += colors + " Color(s)\n"; //$NON-NLS-1$ if (cursors != 0) string += cursors + " Cursor(s)\n"; //$NON-NLS-1$ if (fonts != 0) string += fonts + " Font(s)\n"; //$NON-NLS-1$ if (gcs != 0) string += gcs + " GC(s)\n"; //$NON-NLS-1$ if (images != 0) string += images + " Image(s)\n"; //$NON-NLS-1$ if (regions != 0) string += regions + " Region(s)\n"; //$NON-NLS-1$ if (string.length () != 0) { string = string.substring (0, string.length () - 1); } label.setText (string); }
public Rectangle getInsertionBounds(Control control) { // This doesn't take horizontal scrolling into affect. // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=204599 CCombo combo = (CCombo) control; int position = combo.getSelection().y; String contents = combo.getText(); GC gc = new GC(combo); gc.setFont(combo.getFont()); Point extent = gc.textExtent(contents.substring(0, Math.min(position, contents.length()))); gc.dispose(); if (COMPUTE_TEXT_USING_CLIENTAREA) { return new Rectangle(combo.getClientArea().x + extent.x, combo .getClientArea().y, 1, combo.getClientArea().height); } return new Rectangle(extent.x, 0, 1, combo.getSize().y); }
/** * */ @Override public void render(XCalendarFrame frame) { // Background final GC gc = frame.getGc(); final XCalendarModel model = popup.getModel(); final XCalendarTheme theme = model.getTheme(); final boolean hovered = this.mouse.isEntered(); int x = bounds.x, y = bounds.y, w = bounds.width, h = bounds.height; gc.setBackground(theme.getBackground(true, false, false, hovered)); gc.fillRoundRectangle(x, y, w, h, theme.getArc(), theme.getArc()); // Foreground String text = theme.getSecondTheme()[row][col]; gc.setForeground(theme.getForeground(true, false, true)); gc.setFont(theme.getFont()); final Point size = extent(gc, text); gc.drawText(text, x + 1 + ((w - size.x) >> 1), y + 1 + ((h - size.y) >> 1)); }
public static void drawButtonDeepDown(GC gc, String text, int textAlign, Image image, int imageAlign, int x, int y, int w, int h) { Display display = Display.getCurrent(); gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); gc.drawLine(x, y, x + w - 2, y); gc.drawLine(x, y, x, y + h - 2); gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE)); gc.drawLine(x + w - 1, y, x + w - 1, y + h - 1); gc.drawLine(x, y + h - 1, x + w - 1, y + h - 1); gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); gc.drawLine(x + 1, y + h - 2, x + w - 2, y + h - 2); gc.drawLine(x + w - 2, y + h - 2, x + w - 2, y + 1); // gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_FOREGROUND)); gc.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); gc.fillRectangle(x + 2, y + 2, w - 4, 1); gc.fillRectangle(x + 1, y + 2, 2, h - 4); // gc.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); drawTextImage(gc, text, textAlign, image, imageAlign, x + 2 + 1, y + 2 + 1, w - 4, h - 3 - 1); }
/** * */ @Override public void render(XCalendarFrame frame) { // Background final GC gc = frame.getGc(); final XCalendarModel model = popup.getModel(); final XCalendarTheme theme = model.getTheme(); final boolean hovered = this.mouse.isEntered(); final boolean time = model.getStateMachine().isTime(); int x = bounds.x, y = bounds.y, w = bounds.width, h = bounds.height; gc.setBackground(theme.getBackground(true, false, false, hovered)); gc.fillRoundRectangle(x, y, w, h, theme.getArc(), theme.getArc()); // Foreground String text = time ? calendar : clock_o; gc.setForeground(theme.getToolBarBackground(false)); gc.setFont(Fonts.getAwesomeFont()); final Point size = extent(gc, text); gc.drawText(text, x + 1 + ((w - size.x) >> 1), y + 1 + ((h - size.y) >> 1)); }
/** * Activates the editor at the given position. * * @param row * @param col * @param rect */ public void open(KTable table, int col, int row, Rectangle rect) { m_Table = table; m_Model = table.getModel(); m_Rect = rect; m_Row = row; m_Col = col; if (m_Control == null) { m_Control = createControl(); m_Control.setToolTipText(toolTip); m_Control.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent arg0) { close(true); } }); } setBounds(m_Rect); GC gc = new GC(m_Table); m_Table.drawCell(gc, m_Col, m_Row); gc.dispose(); }
@Override public void cellPaint(GC gc, TableCellSWT cell) { Rectangle bounds = cell.getBounds(); ImageLoader imageLoader = ImageLoader.getInstance(); Image viewImage = imageLoader.getImage("ic_view"); if(imageWidth == -1 || imageHeight == -1) { imageWidth = viewImage.getBounds().width; imageHeight = viewImage.getBounds().height; } bounds.width -= (imageWidth + 5); GCStringPrinter.printString(gc, cell.getSortValue().toString(), bounds,true,false,SWT.LEFT); Subscription sub = (Subscription) cell.getDataSource(); if ( sub != null && !sub.isSearchTemplate()){ gc.drawImage(viewImage, bounds.x + bounds.width, bounds.y + bounds.height / 2 - imageHeight / 2); } imageLoader.releaseImage("ic_view"); //gc.drawText(cell.getText(), bounds.x,bounds.y); }
@Override public void draw(int paintX, int paintSpaceLeadingX, int paintY, GC gc) { StyledText styledText = getTextViewer().getTextWidget(); Rectangle client = styledText.getClientArea(); gc.setBackground(styledText.getDisplay().getSystemColor(SWT.COLOR_WHITE)); styledText.drawBackground(gc, paintX, paintY, client.width, this.getHeightInPx()); gc.setForeground(styledText.getDisplay().getSystemColor(SWT.COLOR_GRAY)); Font font = new Font(styledText.getDisplay(), "Arial", 9, SWT.ITALIC); gc.setFont(font); String text = getText(gc, paintSpaceLeadingX); if (text != null) { int y = paintY + 4; gc.drawText(text, paintSpaceLeadingX, y); if (hoveredCodeLensEndX != null) { Point extent = gc.textExtent(text); gc.drawLine(hoveredCodeLensStartX, y + extent.y - 1, hoveredCodeLensEndX, y + extent.y - 1); } } }
@Override public Object invoke(Object obj, Method thisMethod, Method proceed, Object[] args) throws Throwable { if ("createControl".equals(thisMethod.getName())) { CompositeRuler parentRuler = (CompositeRuler) args[0]; this.fCachedTextViewer = parentRuler.getTextViewer(); this.fCachedTextWidget = fCachedTextViewer.getTextWidget(); } else if ("setDisplayMode".equals(thisMethod.getName())) { this.fCharacterDisplay = (boolean) args[0]; } else if ("doPaint".equals(thisMethod.getName()) && args.length > 1) { GC gc = (GC) args[0]; ILineRange visibleLines = (ILineRange) args[1]; if (fRevisionPainter == null) { fRevisionPainter = getValue("fRevisionPainter", obj); fDiffPainter = getValue("fDiffPainter", obj); } LineNumberChangeRulerColumn l = ((LineNumberChangeRulerColumn) obj); doPaint(gc, visibleLines, l); return null; } return proceed.invoke(obj, args); }
void doPaint(GC gc, ILineRange visibleLines, LineNumberChangeRulerColumn l) { 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 (l.isShowingLineNumbers() || fCharacterDisplay) doPaintPatch(gc, visibleLines, l); }
public void print() { final Printer printer = SwtUtil.showPrintDialog(imageCanvas); if (printer == null) return; // Print was cancelled new Thread(new Runnable() { public void run() { printer.startJob(getPrintJobName()); printer.startPage(); Point dpi = printer.getDPI(); Image image = getImageCanvas().getImage(); int imageWidth = image.getImageData().width; int imageHeight = image.getImageData().height; int printedWidth = imageWidth * (dpi.x / 96); int printedHeight = imageHeight * (dpi.y / 96); GC gc = new GC(printer); gc.drawImage(image, 0, 0, imageWidth, imageHeight, 0, 0, printedWidth, printedHeight); printer.endPage(); printer.endJob(); gc.dispose(); printer.dispose(); } }).start(); }
private Point computeSizeOfTextAndImages() { int width = 0, height = 0; final boolean textISNotEmpty = getText() != null && !getText().equals(""); if (textISNotEmpty) { final GC gc = new GC(this.parentBreadcrumb); gc.setFont(this.parentBreadcrumb.getFont()); final Point extent = gc.stringExtent(getText()); gc.dispose(); width += extent.x; height = extent.y; } final Point imageSize = computeMaxWidthAndHeightForImages(getImage(), this.selectionImage, this.disabledImage); if (imageSize.x != -1) { width += imageSize.x; height = Math.max(imageSize.y, height); if (textISNotEmpty) { width += MARGIN * 2; } } width += MARGIN; return new Point(width, height); }
/** * Render */ @Override public void render(XCalendarFrame frame) { // Background final GC gc = frame.getGc(); final XCalendarModel model = popup.getModel(); final XCalendarTheme theme = model.getTheme(); final boolean hovered = this.mouse.isEntered(); int x = bounds.x, y = bounds.y, w = bounds.width, h = bounds.height; gc.setBackground(theme.getBackground(true, false, false, hovered)); gc.fillRoundRectangle(x, y, w, h, theme.getArc(), theme.getArc()); // Foreground String text = trash_o; gc.setForeground(theme.getToolBarBackground(false)); gc.setFont(Fonts.getAwesomeFont()); final Point size = extent(gc, text); gc.drawText(text, x + 1 + ((w - size.x) >> 1), y + 1 + ((h - size.y) >> 1)); }
/** * Paint. */ protected void onPaint(GC gc) { final Rectangle b = getBounds(); final TestStatus status = counter != null ? counter.getAggregatedStatus() : null; if (status != null) { final int total = Math.max(expectedTotal, counter.getTotal()); // this is our 100% value final int value = counter.getTotal(); // current value final int totalPx = b.width; final int valuePx = Math.round(totalPx * (((float) value) / ((float) total))); gc.setBackground(getColorForStatus(status)); gc.fillRectangle(0, 0, valuePx, b.height); gc.setBackground(getBackground()); gc.fillRectangle(0 + valuePx, 0, b.width - valuePx, b.height); } else { // clear gc.setBackground(getBackground()); gc.fillRectangle(b); } if (counter != null) { final FontMetrics fm = gc.getFontMetrics(); gc.setForeground(getForeground()); final int pending = expectedTotal > 0 ? expectedTotal - counter.getTotal() : -1; gc.drawString(counter.toString(true, pending, SWT.RIGHT), 4, b.height / 2 - fm.getHeight() / 2 - fm.getDescent(), true); } }
/** Paints an arc from src to tgt using the given control point ctr. */ public static float[] arc(GC gc, Point ctr, Point src, Point tgt) { Path path = new Path(gc.getDevice()); path.moveTo((int) src.x, (int) src.y); path.quadTo((int) ctr.x, (int) ctr.y, (int) tgt.x, (int) tgt.y); gc.drawPath(path); float[] pp = path.getPathData().points; return pp; }
/** * Paints an arc from src to tgt. * <p/> * <b>Assumption:</b> The tgt is located below of the src. */ public static float[] arcReversed(GC gc, Point src, Point tgt) { Path path = new Path(gc.getDevice()); int ydiff = (int) ((tgt.y - src.y) / 3); path.moveTo((int) src.x, (int) src.y); path.cubicTo((int) src.x, (int) src.y + ydiff, (int) tgt.x, (int) tgt.y - ydiff * 2, (int) tgt.x, (int) tgt.y); gc.drawPath(path); float[] pp = path.getPathData().points; return pp; }
public static void drawArrowHead(GC gc, Point referencePoint, Point p) { final double angle = Math.atan2(p.y - referencePoint.y, p.x - referencePoint.x) * 180.0 / Math.PI; final Transform tf = new Transform(gc.getDevice()); tf.rotate(new Double(angle).floatValue()); tf.scale(7, 3); final float[] pnts = new float[] { -1, 1, -1, -1 }; tf.transform(pnts); gc.drawLine(Math.round(p.x), Math.round(p.y), Math.round(p.x + pnts[0]), Math.round(p.y + pnts[1])); gc.drawLine(Math.round(p.x), Math.round(p.y), Math.round(p.x + pnts[2]), Math.round(p.y + pnts[3])); tf.dispose(); }
private void setHeight(FormData fd, Control control, int rowcount) { GC gc = new GC(control); try { gc.setFont(control.getFont()); FontMetrics fm = gc.getFontMetrics(); fd.height = rowcount * fm.getHeight(); } finally { gc.dispose(); } }
@Override public void layout(GC gc) { if (layoutDone) return; int lastLine = 0; int posInLine = 10; int lineCounter = 0; Set<Entry<CFNode, ControlFlowElement>> entries = nodeMap.entrySet(); Iterator<Entry<CFNode, ControlFlowElement>> entriesIt = entries.iterator(); while (entriesIt.hasNext()) { Entry<CFNode, ControlFlowElement> entry = entriesIt.next(); CFNode node = entry.getKey(); ControlFlowElement cfe = entry.getValue(); int line = getLineEnd(cfe); boolean lineChange = lastLine != line; lastLine = line; if (lineChange) { posInLine = 10; lineCounter++; } node.x = posInLine; node.y = lineCounter * 100; node.trim(gc); posInLine += node.width + 50; } layoutDone = true; }
/** * Paint the ... guess what! */ @Override public void paint(GC gc) { gc.setBackground(getColor(parentScale, siblingScale)); gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_BLACK)); gc.fillRectangle(Math.round(x), Math.round(y), Math.round(width), Math.round(height)); // StackUtils.drawString(gc, title, x, y, width, height, 0); gc.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); }
/** Paint edge to given GC. */ @Override public void paint(GC gc) { Node startNode = startNodes.get(0); Node endNode = endNodes.get(0); paintEdge(gc, startNode, endNode); }
/** Sets the color of the {@link GC} depending on the edge type. */ void setColor(GC gc) { Display displ = Display.getCurrent(); Color color = GraphUtils.getColor(50, 50, 50); if (isDead || cfTypes.contains(ControlFlowType.DeadCode)) { color = displ.getSystemColor(SWT.COLOR_GRAY); } else { for (ControlFlowType cfType : cfTypes) { switch (cfType) { case LoopEnter: case LoopReenter: case LoopInfinite: case Break: case Continue: case Return: color = displ.getSystemColor(SWT.COLOR_BLUE); break; case Throw: color = displ.getSystemColor(SWT.COLOR_RED); break; default: break; } } } gc.setForeground(color); }
/** * Paints the reverse arc. Since reverse arcs always point downwards, the start and end points are simply located at * the lower/upper center of the source/target nodes. */ private Point paintSelfArc(GC gc, Node tgtN, Point tgt) { Point srcB = new Point(tgt.x + tgtN.width / 2 + 2, tgt.y); Point tgtB = new Point(tgt.x, tgt.y - tgtN.height / 2 - 2); Point tgtL = new Point(tgtB.x, tgtB.y - 20); drawLabel(gc, tgtL); GraphUtils.arcSelf(gc, srcB, tgtB); return tgtB; }
private void drawSelf(GC gc, float x, float y, float h, float errorEstimate){ int x0 = scale.getX(x, y); int y0 = scale.getY(x, y); //gc.drawOval(x0-50, y0-50, 100, 100); gc.drawLine(x0-15, y0, x0+15, y0); // Horizontal gc.drawLine(x0, y0-15, x0, y0+15); // Vertical }
@Override public void cellPaint(GC gc, TableCellSWT cell) { Rectangle bounds = cell.getBounds(); Color foregroundSWT = cell.getForegroundSWT(); if (foregroundSWT != null) { gc.setBackground(foregroundSWT); bounds.x+=1; bounds.y+=1; bounds.width-=1; bounds.height-=1; gc.fillRectangle(bounds); } }
/** * Change size of receiving Node to its preferred size. */ public void trim(GC gc) { if (title != null) { final org.eclipse.swt.graphics.Point size = gc.stringExtent(title); this.width = size.x + BORDER * 2; this.height = size.y + BORDER * 2; } else { this.width = DEFAULT_WIDTH; this.height = DEFAULT_HEIGHT; } }