rect.left = rect.right - headerHeight;
int chevronSize = ExpandItem.CHEVRON_SIZE; rect.left = rect.right - chevronSize; rect.top = y + (headerHeight - chevronSize) / 2; rect.bottom = rect.top + chevronSize;
void drawItem (GC gc, int hTheme, RECT clipRect, boolean drawFocus) {	int hDC = gc.handle;	int headerHeight = ExpandBar.HEADER_HEIGHT;	RECT rect = new RECT ();	OS.SetRect (rect, x, y, x + width, y + headerHeight);	if (hTheme != 0) {		OS.DrawThemeBackground (hTheme, hDC, OS.EBP_NORMALGROUPHEAD, 0, rect, clipRect);	} else {		int oldBrush = OS.SelectObject (hDC, OS.GetSysColorBrush (OS.COLOR_BTNFACE));		OS.PatBlt (hDC, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, OS.PATCOPY);		OS.SelectObject (hDC, oldBrush);			}	if (image != null) {		rect.left += ExpandItem.TEXT_INSET;		if (imageHeight > headerHeight) {			gc.drawImage (image, rect.left, rect.top + headerHeight - imageHeight);		} else {			gc.drawImage (image, rect.left, rect.top + (headerHeight - imageHeight) / 2);		}		rect.left += imageWidth;	}	if (text.length () > 0) {		rect.left += ExpandItem.TEXT_INSET;		TCHAR buffer = new TCHAR (parent.getCodePage (), text, false);		if (hTheme != 0) {			OS.DrawThemeText (hTheme, hDC, OS.EBP_NORMALGROUPHEAD, 0, buffer.chars, buffer.length(), OS.DT_VCENTER | OS.DT_SINGLELINE, 0, rect);		} else {			NONCLIENTMETRICS info = OS.IsUnicode ? (NONCLIENTMETRICS) new NONCLIENTMETRICSW () : new NONCLIENTMETRICSA ();			info.cbSize = NONCLIENTMETRICS.sizeof;			int hFont = 0, oldFont = 0;			if (!OS.IsWinCE) {				if (OS.SystemParametersInfo (OS.SPI_GETNONCLIENTMETRICS, 0, info, 0)) {					LOGFONT logFont = OS.IsUnicode ? (LOGFONT) ((NONCLIENTMETRICSW)info).lfCaptionFont : ((NONCLIENTMETRICSA)info).lfCaptionFont;					hFont = OS.CreateFontIndirect (logFont);					oldFont = OS.SelectObject (hDC, hFont);				}			}			int oldBkMode = OS.SetBkMode (hDC, OS.TRANSPARENT);			OS.DrawText (hDC, buffer, buffer.length (), rect, OS.DT_VCENTER | OS.DT_SINGLELINE);			OS.SetBkMode (hDC, oldBkMode);			if (hFont != 0) {				OS.SelectObject (hDC, oldFont);				OS.DeleteObject (hFont);			}		}	}	rect.left = rect.right - headerHeight;	if (hTheme != 0) {		int partID = expanded ? OS.EBP_NORMALGROUPCOLLAPSE : OS.EBP_NORMALGROUPEXPAND;		int stateID = hover ? OS.EBNGC_HOT : OS.EBNGC_NORMAL;		OS.DrawThemeBackground (hTheme, hDC, partID, stateID, rect, clipRect);	} else {		drawChevron (hDC, rect);	} 	if (drawFocus) {		OS.SetRect (rect, x + 1, y + 1, x + width - 2, y + headerHeight - 2);		OS.DrawFocusRect (hDC, rect);	}	if (expanded) {		if (OS.COMCTL32_MAJOR < 6 || !OS.IsAppThemed ()) {			int pen = OS.CreatePen (OS.PS_SOLID, 1, OS.GetSysColor (OS.COLOR_BTNFACE));			int oldPen = OS.SelectObject (hDC, pen);			int [] points = {					x, y + headerHeight, 					x, y + headerHeight + height, 					x + width - 1, y + headerHeight + height, 					x + width - 1, y + headerHeight - 1};			OS.Polyline (hDC, points, points.length / 2);			OS.SelectObject (hDC, oldPen);			OS.DeleteObject (pen);		}	}}