newBounds.bottom = (short) (newBounds.top + height - inset.bottom - inset.top);
newBounds.bottom = (short) (newBounds.top + height - inset.bottom - inset.top); if (newBounds.bottom < newBounds.top) newBounds.bottom = newBounds.top; if (newBounds.right < newBounds.left) newBounds.right = newBounds.left;
int setBounds (int control, int x, int y, int width, int height, boolean move, boolean resize, boolean events) {	/* Compute the old bounds */	Rect oldBounds = new Rect ();	OS.GetControlBounds (control, oldBounds);	int [] theRoot = new int [1];	int window = OS.GetControlOwner (control);	OS.GetRootControl (window, theRoot);	int [] parentHandle = new int [1];	OS.GetSuperControl (control, parentHandle);	Rect parentRect = new Rect ();	if (parentHandle [0] != theRoot [0]) {		OS.GetControlBounds (parentHandle [0], parentRect);		OS.OffsetRect (oldBounds, (short) -parentRect.left, (short) -parentRect.top);	}	Rect inset = getInset ();	oldBounds.left -= inset.left;	oldBounds.top -= inset.top;	oldBounds.right += inset.right;	oldBounds.bottom += inset.bottom;		/* Compute the new bounds */	if (!move) {		x = oldBounds.left;		y = oldBounds.top;	}	if (!resize) {		width = oldBounds.right - oldBounds.left;		height = oldBounds.bottom - oldBounds.top;	}		Rect newBounds = new Rect ();	newBounds.left = (short) (parentRect.left + x + inset.left);	newBounds.top = (short) (parentRect.top + y + inset.top);	newBounds.right = (short) (newBounds.left + width - inset.right - inset.left);	newBounds.bottom = (short) (newBounds.top + height - inset.bottom - inset.top);		/* Get bounds again, since the one above is in SWT coordinates */	OS.GetControlBounds (control, oldBounds);		/* Check if anything changed */	boolean sameOrigin = newBounds.left == oldBounds.left && newBounds.top == oldBounds.top;	boolean sameExtent = (newBounds.right - newBounds.left) == (oldBounds.right - oldBounds.left) && (newBounds.bottom - newBounds.top) == (oldBounds.bottom - oldBounds.top);	if (sameOrigin && sameExtent) return 0;	/* Apply changes and invalidate appropriate rectangles */	int tempRgn = 0;	boolean visible = OS.IsControlVisible (control);	if (visible) {		tempRgn = OS.NewRgn ();		OS.GetControlRegion (control, (short) OS.kControlStructureMetaPart, tempRgn);		invalWindowRgn (window, tempRgn);	}	OS.SetControlBounds (control, newBounds);	invalidateVisibleRegion (control);	if (visible) {		OS.GetControlRegion (control, (short) OS.kControlStructureMetaPart, tempRgn);		invalWindowRgn (window, tempRgn);		OS.DisposeRgn(tempRgn);	}		/* Send events */	int result = 0;	if (move && !sameOrigin) {		if (events) sendEvent (SWT.Move);		result |= MOVED;	}	if (resize && !sameExtent) {		if (events) sendEvent (SWT.Resize);		result |= RESIZED;	}	return result;}