public void mouseMove(MouseEvent e) { if ((e.stateMask & SWT.BUTTON1) == 0) return; GC gc = new GC((Canvas) e.widget); gc.drawLine(p.x, p.y, e.x, e.y); gc.dispose(); updatePoint(e); }
void drawWidget(GC gc, RECT rect) { drawBackground(gc.handle, rect); int selStart = selection.x; int selEnd = selection.y; if (selStart > selEnd) { selStart = selection.y; selEnd = selection.x; } // temporary code to disable text selection selStart = selEnd = -1; if (!OS.IsWindowEnabled(handle)) gc.setForeground(disabledColor); layout.draw(gc, 0, 0, selStart, selEnd, null, null); if (hasFocus() && focusIndex != -1) { Rectangle[] rects = getRectangles(focusIndex); for (int i = 0; i < rects.length; i++) { Rectangle rectangle = rects[i]; gc.drawFocus(rectangle.x, rectangle.y, rectangle.width, rectangle.height); } } if (hooks(SWT.Paint) || filters(SWT.Paint)) { Event event = new Event(); event.gc = gc; event.x = rect.left; event.y = rect.top; event.width = rect.right - rect.left; event.height = rect.bottom - rect.top; sendEvent(SWT.Paint, event); event.gc = null; } }
/** * Shorten the given text <code>t</code> so that its length doesn't exceed the given width. The * default implementation replaces characters in the center of the original string with an * ellipsis ("..."). Override if you need a different strategy. * * @param gc the gc to use for text measurement * @param t the text to shorten * @param width the width to shorten the text to, in pixels * @return the shortened text */ protected String shortenText(GC gc, String t, int width) { if (t == null) return null; int w = gc.textExtent(ELLIPSIS, DRAW_FLAGS).x; if (width <= w) return t; int l = t.length(); int max = l / 2; int min = 0; int mid = (max + min) / 2 - 1; if (mid <= 0) return t; TextLayout layout = new TextLayout(getDisplay()); layout.setText(t); mid = validateOffset(layout, mid); while (min < mid && mid < max) { String s1 = t.substring(0, mid); String s2 = t.substring(validateOffset(layout, l - mid), l); int l1 = gc.textExtent(s1, DRAW_FLAGS).x; int l2 = gc.textExtent(s2, DRAW_FLAGS).x; if (l1 + w + l2 > width) { max = mid; mid = validateOffset(layout, (max + min) / 2); } else if (l1 + w + l2 < width) { min = mid; mid = validateOffset(layout, (max + min) / 2); } else { min = max; } } String result = mid == 0 ? t : t.substring(0, mid) + ELLIPSIS + t.substring(validateOffset(layout, l - mid), l); layout.dispose(); return result; }
private void drawBevelRect(GC gc, int x, int y, int w, int h, Color topleft, Color bottomright) { gc.setForeground(topleft); gc.drawLine(x, y, x + w - 1, y); gc.drawLine(x, y, x, y + h - 1); gc.setForeground(bottomright); gc.drawLine(x + w, y, x + w, y + h); gc.drawLine(x, y + h, x + w, y + h); }
/** @return the small {@link Image} that can be used as placeholder for missing image. */ private static Image getMissingImage() { Image image = new Image(Display.getCurrent(), MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE); // GC gc = new GC(image); gc.setBackground(getColor(SWT.COLOR_RED)); gc.fillRectangle(0, 0, MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE); gc.dispose(); // return image; }
/** * Retrieves the Handle object associated with a {@link RubyObject}. Retrieval is either done * through the {@link GC} for Handles that have already been created, or depending on the object's * native class index.<br> * Fixnum's and Symbol's native Handles are created through bit-shifting on their values, File and * Float Handles are created using special JNI methods. All other objects are passed to the * generic {@link Native#newHandle} method.<br> * Once a Handle has been created, it is registered with the {@link GC} to prevent * garbage-collection during native method runs. */ static Handle valueOf(IRubyObject obj) { Handle h = GC.lookup(obj); if (h != null) { return h; } Ruby runtime = obj.getRuntime(); long nativeHandle; if (obj instanceof RubyObject) { int type = ((RubyObject) obj).getNativeTypeIndex(); switch (type) { case ClassIndex.FIXNUM: { final long val = ((RubyFixnum) obj).getLongValue(); nativeHandle = (val <= FIXNUM_MAX && val >= FIXNUM_MIN) ? ((val << FIXNUM_SHIFT) | FIXNUM_FLAG) : Native.getInstance(runtime).newFixnumHandle(obj, val); } break; case ClassIndex.FLOAT: nativeHandle = Native.getInstance(runtime).newFloatHandle(obj, ((RubyNumeric) obj).getDoubleValue()); break; case ClassIndex.SYMBOL: nativeHandle = ((long) ((RubySymbol) obj).getId() << SYMBOL_SHIFT) | SYMBOL_FLAG; break; case ClassIndex.FILE: // RubyIO uses FILE as type index, matching MRI's T_FILE nativeHandle = Native.getInstance(runtime) .newIOHandle( obj, (int) ((RubyIO) obj).fileno(runtime.getCurrentContext()).getLongValue(), ((RubyIO) obj).getOpenFile().getMode()); break; default: nativeHandle = Native.getInstance(runtime).newHandle(obj, type); break; } } else { nativeHandle = Native.getInstance(runtime).newHandle(obj, ClassIndex.OBJECT); } Handle handle = newHandle(runtime, obj, nativeHandle); GC.register(obj, handle); return handle; }
public void translate(double tx, double ty) { if (_transform == null) { _transform = new Transform(_gc.getDevice()); } _transform.translate((int) tx, (int) ty); _gc.setTransform(_transform); if (_clippingArea != null) { AffineTransform t = new AffineTransform(); t.translate(-tx, -ty); _clippingArea.transform(t); } }
// @see // org.gudy.azureus2.ui.swt.views.table.TableCellSWTPaintListener#cellPaint(org.eclipse.swt.graphics.GC, org.gudy.azureus2.ui.swt.views.table.TableCellSWT) public void cellPaint(GC gc, TableCellSWT cell) { VuzeActivitiesEntry entry = (VuzeActivitiesEntry) cell.getDataSource(); if (entry == null) { return; } TableRow row = cell.getTableRow(); if (row == null) { return; } String text = (String) row.getData("text"); if (text != null && text.length() > 0) { if (font == null) { FontData[] fontData = gc.getFont().getFontData(); fontData[0].setStyle(SWT.BOLD); font = new Font(gc.getDevice(), fontData); } gc.setFont(font); Rectangle bounds = getDrawBounds(cell); GCStringPrinter sp = new GCStringPrinter(gc, text, bounds, true, true, SWT.WRAP | SWT.CENTER); sp.calculateMetrics(); if (sp.hasHitUrl()) { URLInfo[] hitUrlInfo = sp.getHitUrlInfo(); for (int i = 0; i < hitUrlInfo.length; i++) { URLInfo info = hitUrlInfo[i]; // handle fake row when showing in column editor info.urlUnderline = cell.getTableRow() == null || cell.getTableRow().isSelected(); if (info.urlUnderline) { info.urlColor = null; } else { info.urlColor = colorLinkNormal; } } int[] mouseOfs = cell.getMouseOffset(); if (mouseOfs != null) { Rectangle realBounds = cell.getBounds(); URLInfo hitUrl = sp.getHitUrl(mouseOfs[0] + realBounds.x, mouseOfs[1] + realBounds.y); if (hitUrl != null) { hitUrl.urlColor = colorLinkHover; } } } sp.printString(); } }
public void setClip(Shape s) { Path path = convertToPath(s); if (path == null) { _gc.setClipping((Rectangle) null); } else { _gc.setClipping(path); } if (_clippingPath != null) { _clippingPath.dispose(); } _clippingPath = path; _clippingArea = (s == null ? null : new Area(s)); }
LRESULT WM_PRINTCLIENT(int /*long*/ wParam, int /*long*/ lParam) { LRESULT result = super.WM_PRINTCLIENT(wParam, lParam); if (OS.COMCTL32_MAJOR < 6) { RECT rect = new RECT(); OS.GetClientRect(handle, rect); GCData data = new GCData(); data.device = display; data.foreground = getForegroundPixel(); GC gc = GC.win32_new(wParam, data); drawWidget(gc, rect); gc.dispose(); } return result; }
public void setStroke(Stroke s) { _stroke = s; /* * Code borrowed from SwingWT */ if (s == null) { _gc.setLineWidth(1); _gc.setLineCap(SWT.CAP_SQUARE); _gc.setLineJoin(SWT.JOIN_MITER); _gc.setLineDash(null); return; } if (!(s instanceof BasicStroke)) { return; } BasicStroke bs = (BasicStroke) s; // Setup the line width _gc.setLineWidth((int) bs.getLineWidth()); // Setup the line cap int gcCap = SWT.CAP_SQUARE; switch (bs.getEndCap()) { case BasicStroke.CAP_BUTT: gcCap = SWT.CAP_FLAT; break; case BasicStroke.CAP_ROUND: gcCap = SWT.CAP_ROUND; break; case BasicStroke.CAP_SQUARE: gcCap = SWT.CAP_SQUARE; break; } _gc.setLineCap(gcCap); // Setup the line Join int gcJoin = SWT.JOIN_MITER; switch (bs.getLineJoin()) { case BasicStroke.JOIN_BEVEL: gcJoin = SWT.JOIN_BEVEL; break; case BasicStroke.JOIN_MITER: gcJoin = SWT.JOIN_MITER; break; case BasicStroke.JOIN_ROUND: gcJoin = SWT.JOIN_ROUND; } _gc.setLineJoin(gcJoin); float d[] = bs.getDashArray(); int[] dashes = new int[d.length]; for (int i = 0; i < d.length; i++) { dashes[i] = (int) d[i]; } _gc.setLineDash(dashes); }
public void setColor(java.awt.Color color) { if (color.equals(_awt_color)) { return; } Color col = new Color(_gc.getDevice(), color.getRed(), color.getGreen(), color.getBlue()); _gc.setForeground(col); _gc.setBackground(col); _gc.setAlpha(color.getAlpha()); if (_color != null) { _color.dispose(); } _color = col; _awt_color = color; }
/** * Returns the runtime class of an object. That <tt>Class</tt> object is the object that is locked * by <tt>static synchronized</tt> methods of the represented class. * * @return the object of type <code>Class</code> that represents the runtime class of the object. */ public final Class getClass() { Klass klass = GC.getKlass(this); if (klass == Klass.STRING_OF_BYTES) { klass = Klass.STRING; } return Klass.asClass(klass); }
/** * Convert an AWT Shape to an SWT Path. * * @param shape * @return the SWT Path or <code>null</code> if <code>shape == null</code> */ private Path convertToPath(Shape shape) { if (shape == null) { return null; } Path path = new Path(_gc.getDevice()); PathIterator iter = shape.getPathIterator(null); float[] coords = new float[6]; while (!iter.isDone()) { int op = iter.currentSegment(coords); switch (op) { case PathIterator.SEG_MOVETO: path.moveTo(coords[0], coords[1]); break; case PathIterator.SEG_LINETO: path.lineTo(coords[0], coords[1]); break; case PathIterator.SEG_QUADTO: path.quadTo(coords[0], coords[1], coords[2], coords[3]); break; case PathIterator.SEG_CUBICTO: path.cubicTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]); break; case PathIterator.SEG_CLOSE: path.close(); break; } iter.next(); } return path; }
/** Clean used resources. */ public void clean() { if (_clippingPath != null) { _gc.setClipping((Rectangle) null); _clippingPath.dispose(); _clippingPath = null; _clippingArea = null; } if (_color != null) { _color.dispose(); _color = null; } if (_transform != null) { _gc.setTransform(null); _transform.dispose(); } }
/** Sets or clears the caret in the "Example" widget. */ void setCaret() { Caret oldCaret = canvas.getCaret(); if (caretButton.getSelection()) { Caret newCaret = new Caret(canvas, SWT.NONE); Font font = canvas.getFont(); newCaret.setFont(font); GC gc = new GC(canvas); gc.setFont(font); newCaret.setBounds(1, 1, 1, gc.getFontMetrics().getHeight()); gc.dispose(); canvas.setCaret(newCaret); canvas.setFocus(); } else { canvas.setCaret(null); } if (oldCaret != null) oldCaret.dispose(); }
int getPreferredWidth(GC gc) { int width = ExpandItem.TEXT_INSET * 2 + ExpandItem.CHEVRON_SIZE; if (image != null) { width += ExpandItem.TEXT_INSET + imageWidth; } if (text.length() > 0) { width += gc.stringExtent(text).x; } return width; }
void paint(PaintEvent event) { GC gc = event.gc; Display disp = getDisplay(); Rectangle rect = getClientArea(); gc.fillRectangle(rect); if (showBorder) { drawBevelRect( gc, rect.x, rect.y, rect.width - 1, rect.height - 1, disp.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW), disp.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW)); } paintStripes(gc); }
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Widget"); final Table table = new Table(shell, SWT.MULTI); table.setLinesVisible(true); table.setBounds(10, 10, 100, 100); for (int i = 0; i < 9; i++) { new TableItem(table, SWT.NONE).setText("item" + i); } Button button = new Button(shell, SWT.PUSH); button.setText("Capture"); button.pack(); button.setLocation(10, 140); button.addListener( SWT.Selection, event -> { Point tableSize = table.getSize(); GC gc = new GC(table); final Image image = new Image(display, tableSize.x, tableSize.y); gc.copyArea(image, 0, 0); gc.dispose(); Shell popup = new Shell(shell); popup.setText("Image"); popup.addListener(SWT.Close, e -> image.dispose()); Canvas canvas = new Canvas(popup, SWT.NONE); canvas.setBounds(10, 10, tableSize.x + 10, tableSize.y + 10); canvas.addPaintListener(e -> e.gc.drawImage(image, 0, 0)); popup.pack(); popup.open(); }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
/** * Returns <code>true</code> if the specified point is contained by the receiver and false * otherwise. * * <p>If outline is <code>true</code>, the point (x, y) checked for containment in the receiver's * outline. If outline is <code>false</code>, the point is checked to see if it is contained * within the bounds of the (closed) area covered by the receiver. * * @param x the x coordinate of the point to test for containment * @param y the y coordinate of the point to test for containment * @param gc the GC to use when testing for containment * @param outline controls whether to check the outline or contained area of the path * @return <code>true</code> if the path contains the point and <code>false</code> otherwise * @exception IllegalArgumentException * <ul> * <li>ERROR_NULL_ARGUMENT - if the gc is null * <li>ERROR_INVALID_ARGUMENT - if the gc has been disposed * </ul> * * @exception SWTException * <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed * </ul> */ public boolean contains(float x, float y, GC gc, boolean outline) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (gc == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (gc.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); // gc.checkGC(GC.LINE_CAP | GC.LINE_JOIN | GC.LINE_STYLE | GC.LINE_WIDTH); // TODO outline NSPoint point = new NSPoint(); point.x = x; point.y = y; return handle.containsPoint(point); }
@Override void drawWidget(GC gc) { int selStart = selection.x; int selEnd = selection.y; if (selStart > selEnd) { selStart = selection.y; selEnd = selection.x; } // temporary code to disable text selection selStart = selEnd = -1; if ((state & DISABLED) != 0) gc.setForeground(disabledColor); layout.draw(gc, 0, 0, selStart, selEnd, null, null); if (hasFocus() && focusIndex != -1) { Rectangle[] rects = getRectangles(focusIndex); for (int i = 0; i < rects.length; i++) { Rectangle rect = rects[i]; gc.drawFocus(rect.x, rect.y, rect.width, rect.height); } } }
public void setRenderingHint(Key key, Object value) { if (RenderingHints.KEY_ANTIALIASING.equals(key)) { int antialias = SWT.DEFAULT; if (RenderingHints.VALUE_ANTIALIAS_OFF.equals(value)) { antialias = SWT.OFF; } else if (RenderingHints.VALUE_ANTIALIAS_ON.equals(value)) { antialias = SWT.ON; } _gc.setAntialias(antialias); } }
LRESULT WM_PAINT(int /*long*/ wParam, int /*long*/ lParam) { if (OS.COMCTL32_MAJOR >= 6) { return super.WM_PAINT(wParam, lParam); } PAINTSTRUCT ps = new PAINTSTRUCT(); GCData data = new GCData(); data.ps = ps; data.hwnd = handle; GC gc = new_GC(data); if (gc != null) { int width = ps.right - ps.left; int height = ps.bottom - ps.top; if (width != 0 && height != 0) { RECT rect = new RECT(); OS.SetRect(rect, ps.left, ps.top, ps.right, ps.bottom); drawWidget(gc, rect); } gc.dispose(); } return LRESULT.ZERO; }
/** Compute the minimum size. */ private Point getTotalSize(Image image, String text) { Point size = new Point(0, 0); if (image != null) { Rectangle r = image.getBounds(); size.x += r.width; size.y += r.height; } GC gc = new GC(this); if (text != null && text.length() > 0) { Point e = gc.textExtent(text, DRAW_FLAGS); size.x += e.x; size.y = Math.max(size.y, e.y); if (image != null) size.x += GAP; } else { size.y = Math.max(size.y, gc.getFontMetrics().getHeight()); } gc.dispose(); return size; }
void drawChevron(GC gc, int x, int y) { int[] polyline1, polyline2; if (expanded) { int px = x + 4 + 5; int py = y + 4 + 7; polyline1 = new int[] { px, py, px + 1, py, px + 1, py - 1, px + 2, py - 1, px + 2, py - 2, px + 3, py - 2, px + 3, py - 3, px + 3, py - 2, px + 4, py - 2, px + 4, py - 1, px + 5, py - 1, px + 5, py, px + 6, py }; py += 4; polyline2 = new int[] { px, py, px + 1, py, px + 1, py - 1, px + 2, py - 1, px + 2, py - 2, px + 3, py - 2, px + 3, py - 3, px + 3, py - 2, px + 4, py - 2, px + 4, py - 1, px + 5, py - 1, px + 5, py, px + 6, py }; } else { int px = x + 4 + 5; int py = y + 4 + 4; polyline1 = new int[] { px, py, px + 1, py, px + 1, py + 1, px + 2, py + 1, px + 2, py + 2, px + 3, py + 2, px + 3, py + 3, px + 3, py + 2, px + 4, py + 2, px + 4, py + 1, px + 5, py + 1, px + 5, py, px + 6, py }; py += 4; polyline2 = new int[] { px, py, px + 1, py, px + 1, py + 1, px + 2, py + 1, px + 2, py + 2, px + 3, py + 2, px + 3, py + 3, px + 3, py + 2, px + 4, py + 2, px + 4, py + 1, px + 5, py + 1, px + 5, py, px + 6, py }; } gc.setForeground(display.getSystemColor(SWT.COLOR_TITLE_FOREGROUND)); gc.drawPolyline(polyline1); gc.drawPolyline(polyline2); }
public Object getRenderingHint(Key key) { if (RenderingHints.KEY_ANTIALIASING.equals(key)) { switch (_gc.getAntialias()) { case SWT.DEFAULT: return RenderingHints.VALUE_ANTIALIAS_DEFAULT; case SWT.OFF: return RenderingHints.VALUE_ANTIALIAS_OFF; case SWT.ON: return RenderingHints.VALUE_ANTIALIAS_ON; } } return null; }
LRESULT wmDrawChild(long /*int*/ wParam, long /*int*/ lParam) { DRAWITEMSTRUCT struct = new DRAWITEMSTRUCT(); OS.MoveMemory(struct, lParam, DRAWITEMSTRUCT.sizeof); if (image != null) { GCData data = new GCData(); data.device = display; GC gc = GC.win32_new(struct.hDC, data); /* * Bug in Windows. When a bitmap is included in the * menu bar, the HDC seems to already include the left * coordinate. The fix is to ignore this value when * the item is in a menu bar. */ int x = (parent.style & SWT.BAR) != 0 ? MARGIN_WIDTH * 2 : struct.left; Image image = getEnabled() ? this.image : new Image(display, this.image, SWT.IMAGE_DISABLE); gc.drawImage(image, x, struct.top + MARGIN_HEIGHT); if (this.image != image) image.dispose(); gc.dispose(); } if (parent.foreground != -1) OS.SetTextColor(struct.hDC, parent.foreground); return null; }
public static void main(String[] args) { final Display display = new Display(); final Image image = new Image(display, 16, 16); GC gc = new GC(image); gc.setBackground(display.getSystemColor(SWT.COLOR_RED)); gc.fillRectangle(image.getBounds()); gc.dispose(); final Shell shell = new Shell(display); shell.setText("Lazy Table"); shell.setLayout(new FillLayout()); final Table table = new Table(shell, SWT.BORDER | SWT.MULTI); table.setSize(200, 200); Thread thread = new Thread() { @Override public void run() { for (int i = 0; i < 20000; i++) { if (table.isDisposed()) return; final int[] index = new int[] {i}; display.syncExec( () -> { if (table.isDisposed()) return; TableItem item = new TableItem(table, SWT.NONE); item.setText("Table Item " + index[0]); item.setImage(image); }); } } }; thread.start(); shell.setSize(200, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } image.dispose(); display.dispose(); }
/** * Constructs a new Pattern that represents a linear, two color gradient. Drawing with the pattern * will cause the resulting area to be tiled with the gradient specified by the arguments. * * <p>This operation requires the operating system's advanced graphics subsystem which may not be * available on some platforms. * * @param device the device on which to allocate the pattern * @param x1 the x coordinate of the starting corner of the gradient * @param y1 the y coordinate of the starting corner of the gradient * @param x2 the x coordinate of the ending corner of the gradient * @param y2 the y coordinate of the ending corner of the gradient * @param color1 the starting color of the gradient * @param alpha1 the starting alpha value of the gradient * @param color2 the ending color of the gradient * @param alpha2 the ending alpha value of the gradient * @exception IllegalArgumentException * <ul> * <li>ERROR_NULL_ARGUMENT - if the device is null and there is no current device, or if * either color1 or color2 is null * <li>ERROR_INVALID_ARGUMENT - if either color1 or color2 has been disposed * </ul> * * @exception SWTException * <ul> * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available * </ul> * * @exception SWTError * <ul> * <li>ERROR_NO_HANDLES if a handle for the pattern could not be obtained * </ul> * * @see #dispose() * @since 3.2 */ public Pattern( Device device, float x1, float y1, float x2, float y2, Color color1, int alpha1, Color color2, int alpha2) { super(device); if (color1 == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (color1.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); if (color2 == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (color2.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); this.device.checkCairo(); handle = Cairo.cairo_pattern_create_linear(x1, y1, x2, y2); if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES); GC.setCairoPatternColor(handle, 0, color1, alpha1); GC.setCairoPatternColor(handle, 1, color2, alpha2); Cairo.cairo_pattern_set_extend(handle, Cairo.CAIRO_EXTEND_REPEAT); init(); }
/** * Causes the receiver to be resized to its preferred size. For a composite, this involves * computing the preferred size from its layout, if there is one. * * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver * </ul> */ public void pack() { checkWidget(); int width = 0; /* compute header width */ NSTableHeaderCell headerCell = nsColumn.headerCell(); NSSize size = headerCell.cellSize(); width += Math.ceil(size.width); if (image != null) { NSSize imageSize = image.handle.size(); width += Math.ceil(imageSize.width) + MARGIN; } if (parent.sortColumn == this && parent.sortDirection != SWT.NONE) { NSRect sortRect = headerCell.sortIndicatorRectForBounds(new NSRect()); width += Math.ceil(sortRect.width + 2 * MARGIN); } /* compute item widths down column */ GC gc = new GC(parent); width = Math.max(width, parent.calculateWidth(parent.items, parent.indexOf(this), gc, true)); gc.dispose(); setWidth(width); }