Rect bounds = new Rect(); OS.GetControlBounds(data.control, bounds); if (data.clipRgn == 0 && data.visibleRgn == 0) { int width = bounds.right - bounds.left; int height = bounds.bottom - bounds.top; return new Rectangle(0, 0, width, height);
if (data.clipRgn != 0 || data.visibleRgn != 0) { int clipping = OS.NewRgn(); OS.SetRectRgn(clipping, (short)0, (short)0, (short)width, (short)height); if (data.clipRgn != 0) OS.SectRgn(data.clipRgn, clipping, clipping); if (data.visibleRgn != 0) {  OS.OffsetRgn(data.visibleRgn, (short)-bounds.left, (short)-bounds.top); OS.SectRgn(data.visibleRgn, clipping, clipping); OS.OffsetRgn(data.visibleRgn, bounds.left, bounds.top); } OS.GetRegionBounds(clipping, bounds); x = bounds.left; y = bounds.top; width = bounds.right - bounds.left; height = bounds.bottom - bounds.top; OS.DisposeRgn(clipping);
public Rectangle getClipping() {	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);	if (data.control == 0) {		int width = 0, height = 0;		if (data.image != null) {			int image = data.image.handle;			width = OS.CGImageGetWidth(image);			height = OS.CGImageGetHeight(image);		}		return new Rectangle(0, 0, width, height);	}	Rect bounds = new Rect();	OS.GetControlBounds(data.control, bounds);	if (data.clipRgn == 0 && data.visibleRgn == 0) {		int width = bounds.right - bounds.left;		int height = bounds.bottom - bounds.top;		return new Rectangle(0, 0, width, height);	}	int clipping = OS.NewRgn();	OS.RectRgn(clipping, bounds);	OS.OffsetRgn(clipping, (short)-bounds.left, (short)-bounds.top);	if (data.clipRgn != 0) OS.SectRgn(data.clipRgn, clipping, clipping);	if (data.visibleRgn != 0) {		OS.OffsetRgn(data.visibleRgn, (short)-bounds.left, (short)-bounds.top);		OS.SectRgn(data.visibleRgn, clipping, clipping);		OS.OffsetRgn(data.visibleRgn, bounds.left, bounds.top);	}	OS.GetRegionBounds(clipping, bounds);	int width = bounds.right - bounds.left;	int height = bounds.bottom - bounds.top;	OS.DisposeRgn(clipping);	return new Rectangle(bounds.left, bounds.top, width, height);}