shape[index++] = y + height;
shape[index++] = y + height + 1;
void drawSelected(GC gc ) {	Point size = parent.getSize();	// Draw selection border across all tabs	int parentX = parent.borderLeft;	int parentY = parent.onBottom ? size.y - parent.borderBottom - parent.tabHeight - CTabFolder2.HIGHLIGHT_HEADER : parent.borderTop + parent.tabHeight + 1;	int parentWidth = size.x - parent.borderLeft - parent.borderRight;	int parentHeight = CTabFolder2.HIGHLIGHT_HEADER - 1;	int[] shape = new int[] {parentX,parentY, parentX+parentWidth,parentY, parentX+parentWidth,parentY+parentHeight, parentX,parentY+parentHeight};	parent.drawBackground(gc, shape, true);	// if selected tab scrolled out of view or partially out of view	// draw line and clean up partial tab area	int rightTabEdge = parent.getRightItemEdge();	if (!parent.single && parent.selectedIndex != parent.topTabIndex && x + width >= rightTabEdge){		if (parent.onBottom) {			shape = new int[4];			int index = 0;			shape[index++] = Math.max(0, parent.borderLeft - 1);			shape[index++] = y - 1;			shape[index++] = size.x - parent.borderRight;			shape[index++] = y - 1;		} else {			shape = new int[4];			int index = 0;			shape[index++] = Math.max(0, parent.borderLeft - 1);			shape[index++] = y + height;			shape[index++] = size.x - parent.borderRight;			shape[index++] = y + height;		}		// draw line			gc.setForeground(CTabFolder2.borderColor);		gc.drawPolyline(shape);		// if tab partially visible, fill in background for tab		shape = new int[] {x,y-1, x,y+height, size.x,y+height, size.x,y-1};		parent.drawBackground(gc, shape, false);		return;	}	// fill in background for non-rectangular shape	shape = new int[] {x,y, x+width,y, x+width,y+height, x,y+height};	parent.drawBackground(gc, shape, false);		// draw selected tab background and outline	int extra = CTabFolder2.CURVE_WIDTH/2 + 4; // +4 to avoid overlapping with text in next tab	shape = null;	if (this.parent.onBottom) {		int[] left = CTabFolder2.BOTTOM_LEFT_CORNER;		int[] right = parent.curve;		shape = new int[left.length+right.length+8];		int index = 0;		shape[index++] = x; // first point repeated here because below we reuse shape to draw outline		shape[index++] = y - 1;		shape[index++] = x;		shape[index++] = y - 1;		for (int i = 0; i < left.length/2; i++) {			shape[index++] = x + left[2*i];			shape[index++] = y + height + left[2*i+1] - 1;		}		for (int i = 0; i < right.length/2; i++) {			shape[index++] = x + width - extra + right[2*i];			shape[index++] = y + right[2*i+1] - 2;		}		int temp = 0;		for (int i = 0; i < shape.length/2; i++) {			if (shape[2*i] > rightTabEdge) {				if (temp == 0 && i > 0) {					temp = shape[2*i-1];				} else {					temp = y - 1;				}				shape[2*i] = rightTabEdge;				shape[2*i+1] = temp;			}		}		shape[index++] = rightTabEdge;		shape[index++] = y - 1;		shape[index++] = x + width + extra;		shape[index++] = y - 1;	} else {		int[] left = CTabFolder2.TOP_LEFT_CORNER;		int[] right = parent.curve;		shape = new int[left.length+right.length+8];		int index = 0;		shape[index++] = x; // first point repeated here because below we reuse shape to draw outline		shape[index++] = y + height;		shape[index++] = x;		shape[index++] = y + height;		for (int i = 0; i < left.length/2; i++) {			shape[index++] = x + left[2*i];			shape[index++] = y + left[2*i+1];		}		for (int i = 0; i < right.length/2; i++) {			shape[index++] = x + width - extra + right[2*i];			shape[index++] = y + right[2*i+1];		}		int temp = 0;		for (int i = 0; i < shape.length/2; i++) {			if (shape[2*i] > rightTabEdge) {				if (temp == 0 && i > 0) {					temp = shape[2*i-1];				} else {					temp = y + height + 1;				}				shape[2*i] = rightTabEdge;				shape[2*i+1] = temp;			}		}		shape[index++] = rightTabEdge;		shape[index++] = y + height + 1;		shape[index++] = x + width + extra;		shape[index++] = y + height + 1;	}	parent.drawBackground(gc, shape, true);		if ( x < rightTabEdge) {		// Limit drawing area of tab		Region r = new Region();		r.subtract(r); //clear		Region clipping = new Region();		gc.getClipping(clipping);		r.add(clipping);		r.intersect(new Rectangle(x, y, Math.min(width, rightTabEdge-x), height));		gc.setClipping(r);			// draw Image		int xDraw = x + LEFT_MARGIN;		Image image = getImage();		if (image != null) {			Rectangle imageBounds = image.getBounds();			int imageX = xDraw;			int imageHeight = imageBounds.height;			int imageY = y + (height - imageHeight) / 2;			imageY += parent.onBottom ? -1 : 1;			int imageWidth = imageBounds.width * imageHeight / imageBounds.height;			gc.drawImage(image, 				         imageBounds.x, imageBounds.y, imageBounds.width, imageBounds.height,				         imageX, imageY, imageWidth, imageHeight);			xDraw += imageWidth + INTERNAL_SPACING;		}				// draw Text		int textWidth = x + width - xDraw - RIGHT_MARGIN;		if (closeRect.width > 0) textWidth -= closeRect.width + INTERNAL_SPACING;		if (shortenedText == null || shortenedTextWidth != textWidth) {			shortenedText = shortenText(gc, getText(), textWidth);			shortenedTextWidth = textWidth;		}		Point extent = gc.textExtent(shortenedText, FLAGS);			int textY = y + (height - extent.y) / 2;		textY += parent.onBottom ? -1 : 1;				gc.setForeground(parent.selectionForeground);		gc.drawText(shortenedText, xDraw, textY, FLAGS);				if (parent.showClose || showClose) drawClose(gc);				// draw a Focus rectangle		if (parent.isFocusControl()) {			Display display = getDisplay();			gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK));			gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));			gc.drawFocus(xDraw-3, textY-2, extent.x+6, extent.y+4);		}				gc.setClipping(clipping);		r.dispose();		clipping.dispose();	}		// draw outline	shape[0] = Math.max(0, parent.borderLeft - 1);	shape[shape.length - 2] = size.x - parent.borderRight + 1;	for (int i = 0; i < shape.length/2; i++) {		if (shape[2*i + 1] == y + height + 1) shape[2*i + 1] -= 1;	}	RGB inside = parent.selectionBackground.getRGB();	if (parent.selectionBgImage != null || (parent.selectionGradientColors != null && parent.selectionGradientColors.length > 1 && !parent.selectionGradientVertical)) inside = null;	RGB outside = parent.getBackground().getRGB();			if (parent.bgImage != null || (parent.gradientColors != null && parent.gradientColors.length > 1 && !parent.gradientVertical)) outside = null;	parent.antialias(shape, CTabFolder2.borderColor.getRGB(), inside, outside, gc);	gc.setForeground(CTabFolder2.borderColor);	gc.drawPolyline(shape);}