width += rect.width; if (hasText) width += MARGIN * 2; height += rect.height;
width = rect.width; if (hasText && text.length () != 0) { width += MARGIN * 2; } height = rect.height;
public Point computeSize (int wHint, int hHint, boolean changed) {	checkWidget ();	int width = 0, height = 0, border = getBorderWidth ();	if ((style & SWT.ARROW) != 0) {		if ((style & (SWT.UP | SWT.DOWN)) != 0) {			width += OS.GetSystemMetrics (OS.SM_CXVSCROLL);			height += OS.GetSystemMetrics (OS.SM_CYVSCROLL);		} else {			width += OS.GetSystemMetrics (OS.SM_CXHSCROLL);			height += OS.GetSystemMetrics (OS.SM_CYHSCROLL);		}		if (wHint != SWT.DEFAULT) width = wHint;		if (hHint != SWT.DEFAULT) height = hHint;		width += border * 2; height += border * 2;		return new Point (width, height);	}	int extra = 0;	boolean hasImage = image != null, hasText = text.length () != 0;	if (OS.COMCTL32_MAJOR < 6) {		int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);		hasImage = (bits & (OS.BS_BITMAP | OS.BS_ICON)) != 0;		if (hasImage) hasText = false;	}	if (hasImage) {		if (image != null) {			Rectangle rect = image.getBounds ();			width += rect.width;			if (hasText) width += MARGIN * 2;			height += rect.height;			extra = MARGIN * 2;		}	}	if (hasText) {		int oldFont = 0;		int hDC = OS.GetDC (handle);		int newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);		if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);		TEXTMETRIC lptm = OS.IsUnicode ? (TEXTMETRIC) new TEXTMETRICW () : new TEXTMETRICA ();		OS.GetTextMetrics (hDC, lptm);		int length = text.length ();		if (length == 0) {			height += lptm.tmHeight;		} else {			extra = Math.max (MARGIN * 2, lptm.tmAveCharWidth);			TCHAR buffer = new TCHAR (getCodePage (), text, true);			RECT rect = new RECT ();			int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE;			OS.DrawText (hDC, buffer, -1, rect, flags);			width += rect.right - rect.left;			height = Math.max (height, rect.bottom - rect.top);		}		if (newFont != 0) OS.SelectObject (hDC, oldFont);		OS.ReleaseDC (handle, hDC);	}	if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {		width += CHECK_WIDTH + extra;		height = Math.max (height, CHECK_HEIGHT + 3);	}	if ((style & (SWT.PUSH | SWT.TOGGLE)) != 0) {		width += 12;  height += 10;	}	if (wHint != SWT.DEFAULT) width = wHint;	if (hHint != SWT.DEFAULT) height = hHint;	width += border * 2; height += border * 2;	return new Point (width, height);}