if (topRightAlignment == SWT.RIGHT && topRight != null) tabAreaWidth -= topRight.computeSize(SWT.DEFAULT, SWT.DEFAULT).x + 3;
if (topRightAlignment == SWT.RIGHT && topRight != null) { Point rightSize = topRight.computeSize(SWT.DEFAULT, SWT.DEFAULT, false); tabAreaWidth -= rightSize.x + 3; }
boolean setItemSize() {	boolean changed = false;	if (isDisposed()) return changed;	showChevron = false;	Point size = getSize();	if (size.x <= 0 || size.y <= 0) return changed;	xClient = borderLeft + marginWidth + highlight_margin;	if (onBottom) {		yClient = borderTop + highlight_margin + marginHeight;	} else {		yClient = borderTop + tabHeight + highlight_header + marginHeight; 	}	if (single) {		showChevron = true;		if (selectedIndex != -1) {			CTabItem tab = items[selectedIndex];			GC gc = new GC(this);			int width = tab.preferredWidth(gc, true, false);			gc.dispose();			width = Math.min(width, getRightItemEdge() - borderLeft);			if (tab.height != tabHeight || tab.width != width) {				changed = true;				tab.shortenedText = null;				tab.shortenedTextWidth = 0;				tab.height = tabHeight;				tab.width = width;				tab.closeRect.width = tab.closeRect.height = 0;				if (showClose || tab.showClose) {					tab.closeRect.width = BUTTON_SIZE;					tab.closeRect.height = BUTTON_SIZE;				}			}		}		return changed;	}		int[] widths = new int[items.length];	widths = new int[items.length];	GC gc = new GC(this);	for (int i = 0; i < items.length; i++) {		widths[i] = items[i].preferredWidth(gc, i == selectedIndex, false);	}		if (items.length > 0) {		int totalWidth = 0;		int tabAreaWidth = size.x - borderLeft - borderRight - 3;		if (showMin) tabAreaWidth -= BUTTON_SIZE;		if (showMax) tabAreaWidth -= BUTTON_SIZE;		if (topRightAlignment == SWT.RIGHT && topRight != null) tabAreaWidth -= topRight.computeSize(SWT.DEFAULT, SWT.DEFAULT).x + 3;		if (!simple) tabAreaWidth -= curveWidth - 2*curveIndent;		tabAreaWidth = Math.max(0, tabAreaWidth);		int count = items.length;		for (int i = 0 ; i < count; i++) {			totalWidth += widths[i];		}		if (totalWidth > tabAreaWidth) {			// try maximum compression size			totalWidth = 0;			int[] minWidths = new int[items.length];			for (int i = 0 ; i < count; i++) {				minWidths[i] = items[i].preferredWidth(gc, i == selectedIndex, true);				totalWidth += minWidths[i];			}			if (totalWidth > tabAreaWidth) {				//  maximum compression required and a chevron				showChevron = items.length > 1;				if (showChevron) tabAreaWidth -= 3*BUTTON_SIZE/2;				widths = minWidths;				int index = selectedIndex != -1 ? selectedIndex : 0;				if (tabAreaWidth < widths[index]) {					widths[index] = Math.max(0, tabAreaWidth);				}			} else {				// determine compression for each item				int extra = (tabAreaWidth - totalWidth) / items.length;				int large = 0;				while (true) {					totalWidth = 0;					large = 0;					for (int i = 0 ; i < count; i++) {						if (widths[i] > minWidths[i] + extra) { 							totalWidth += minWidths[i] + extra;							large++;						} else {							totalWidth += widths[i];						}					}					if (totalWidth >= tabAreaWidth) {						extra--;						break;					}					if (large == 0 ||tabAreaWidth - totalWidth < large) break;					extra++;				}				for (int i = 0; i < items.length; i++) {					widths[i] = Math.min(widths[i], minWidths[i] + extra);				}				}		}	}		for (int i = 0; i < items.length; i++) {		CTabItem tab = items[i];		int width = widths[i];		if (tab.height != tabHeight || tab.width != width) {			changed = true;			tab.shortenedText = null;			tab.shortenedTextWidth = 0;			tab.height = tabHeight;			tab.width = width;			tab.closeRect.width = tab.closeRect.height = 0;			if (showClose || tab.showClose) {				if (i == selectedIndex || showUnselectedClose) {					tab.closeRect.width = BUTTON_SIZE;					tab.closeRect.height = BUTTON_SIZE;				}			}		}	}	gc.dispose();	return changed;}