display.inPaint = oldInPaint;
int kEventControlDraw (int nextHandler, int theEvent, int userData) {	int [] theControl = new int [1];	OS.GetEventParameter (theEvent, OS.kEventParamDirectObject, OS.typeControlRef, null, 4, null, theControl);	int [] region = new int [1];		OS.GetEventParameter (theEvent, OS.kEventParamRgnHandle, OS.typeQDRgnHandle, null, 4, null, region);	if (OS.HIVIEW) {		int[] context = new int [1];		OS.GetEventParameter (theEvent, OS.kEventParamCGContextRef, OS.typeCGContextRef, null, 4, null, context);		int visibleRgn = region [0];		drawBackground (theControl [0], context [0]);		callPaintEventHandler (theControl [0], region [0], visibleRgn, theEvent, nextHandler);		drawWidget (theControl [0], context [0], region [0], visibleRgn, theEvent);	} else {		if (getDrawCount (theControl [0]) > 0) return OS.noErr;		int visibleRgn = getVisibleRegion (theControl [0], true);		OS.SectRgn(region [0], visibleRgn, visibleRgn);		if (!OS.EmptyRgn (visibleRgn)) {			int [] port = new int [1];			OS.GetPort (port);			OS.LockPortBits (port [0]);//			OS.QDSetDirtyRegion (port, visibleRgn);			int oldClip = OS.NewRgn ();			OS.GetClip (oldClip);			OS.SetClip (visibleRgn);			drawBackground (theControl [0], 0);			callPaintEventHandler (theControl [0], region [0], visibleRgn, theEvent, nextHandler);			drawWidget (theControl [0], 0, region [0], visibleRgn, theEvent);			OS.SetClip (oldClip);			OS.DisposeRgn (oldClip);			OS.UnlockPortBits (port [0]);		}		OS.DisposeRgn (visibleRgn);	}	return OS.noErr;}