if (!isPaint) {
if (isPaint) { rect.right += rect.left; rect.bottom += rect.top; rect.left = rect.top = 0; } else { if (OS.HIVIEW) { int [] contentView = new int [1]; OS.HIViewFindByID (OS.HIViewGetRoot (window), OS.kHIViewWindowContentID (), contentView); CGPoint pt = new CGPoint (); OS.HIViewConvertPoint (pt, handle, contentView [0]); rect.left += (int) pt.x; rect.top += (int) pt.y; rect.right += (int) pt.x; rect.bottom += (int) pt.y; }
public int internal_new_GC (GCData data) {	checkWidget();	int port = data != null ? data.port : 0;	if (port == 0) {		int window = OS.GetControlOwner (handle);		port = OS.GetWindowPort (window);	}	int context;	int [] buffer = new int [1];	boolean isPaint = OS.HIVIEW && data != null && data.paintEvent != 0; 	if (isPaint) {		OS.GetEventParameter (data.paintEvent, OS.kEventParamCGContextRef, OS.typeCGContextRef, null, 4, null, buffer);	} else {		OS.CreateCGContextForPort (port, buffer);	}	context = buffer [0];	if (context == 0) SWT.error (SWT.ERROR_NO_HANDLES);	int visibleRgn = 0;	if (data != null && data.paintEvent != 0) {		visibleRgn = data.visibleRgn;	} else {		if (getDrawCount (handle) > 0) {			visibleRgn = OS.NewRgn ();		} else {			visibleRgn = getVisibleRegion (handle, true);		}	}	Rect rect = new Rect ();	Rect portRect = new Rect ();	OS.GetControlBounds (handle, rect);	OS.GetPortBounds (port, portRect);	if (!isPaint) {		OS.ClipCGContextToRegion (context, portRect, visibleRgn);		int portHeight = portRect.bottom - portRect.top;		OS.CGContextScaleCTM (context, 1, -1);		OS.CGContextTranslateCTM (context, rect.left, -portHeight + rect.top);	} else {		rect.right += rect.left;		rect.bottom += rect.top;		rect.left = rect.top = 0;	}	if (data != null) {		int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;		if ((data.style & mask) == 0) {			data.style |= style & (mask | SWT.MIRRORED);		}		data.device = display;		data.thread = display.thread;		data.background = background != null ? background : defaultBackground ().handle;		data.foreground = foreground != null ? foreground : defaultForeground ().handle;		data.font = font != null ? font : defaultFont ();		data.visibleRgn = visibleRgn;		data.control = handle;		data.portRect = portRect;		data.controlRect = rect;			if (data.paintEvent == 0) {			if (gcs == null) gcs = new GCData [4];			int index = 0;			while (index < gcs.length && gcs [index] != null) index++;			if (index == gcs.length) {				GCData [] newGCs = new GCData [gcs.length + 4];				System.arraycopy (gcs, 0, newGCs, 0, gcs.length);				gcs = newGCs;			}			gcs [index] = data;		}	}	return context;}