gc.setFont (getFont (columnIndex));
gc.setFont (getFont (columnIndex, false));
void paint (GC gc, TableColumn column, boolean paintBackgroundOnly) {	if (!parent.checkData (this, true)) return;	int columnIndex = 0, x = 0;	if (column != null) {		columnIndex = column.getIndex ();		x = column.getX ();	}	if (parent.hooks (SWT.MeasureItem) && parent.columns.length == 0) {		int contentWidth = getContentWidth (columnIndex);		int contentX = getContentX (columnIndex);		gc.setFont (getFont (columnIndex));		Event event = new Event ();		event.item = this;		event.gc = gc;		event.index = columnIndex;		event.x = contentX;		event.y = parent.getItemY (this);		event.width = contentWidth;		event.height = parent.itemHeight;		parent.sendEvent (SWT.MeasureItem, event);		event.gc = null;		if (isDisposed ()) return;		if (parent.allowItemHeightChange) {			parent.allowItemHeightChange = false;			if (parent.itemHeight != event.height) {				parent.itemHeight = event.height;				parent.redraw ();			}		}		int change = event.width - (customWidth != -1 ? customWidth : contentWidth);		if (event.width != contentWidth || customWidth != -1) customWidth = event.width;		if (change != 0) {	/* scrollbar may be affected since no columns */			parent.updateHorizontalBar (contentX + event.width, change);			// TODO what if clip is too small now?		}	}	/* if this cell is completely to the right of the client area then there's no need to paint it */	Rectangle clientArea = parent.getClientArea ();	if (clientArea.x + clientArea.width < x) return;	Rectangle cellBounds = getCellBounds (columnIndex);	if (parent.linesVisible) {		cellBounds.y++;		cellBounds.height--;	}	int cellRightX = 0;	if (column != null) {		cellRightX = column.getX () + column.width;	} else {		cellRightX = cellBounds.x + cellBounds.width;	}	/* restrict the clipping region to the cell */	gc.setClipping (x, cellBounds.y, clientArea.width - x, cellBounds.height);		int y = parent.getItemY (this);	int itemHeight = parent.itemHeight;	/* draw the background color of this cell */	Color background = getBackground (columnIndex);	if (columnIndex == 0 && (column == null || column.getOrderIndex () == 0)) {		Rectangle focusBounds = getFocusBounds ();		gc.setBackground (parent.getBackground ());		if (focusBounds.x > 0) {			/* fill space to left of selection rect */			gc.fillRectangle (0, y, focusBounds.x, itemHeight);		}		if (column == null) {			/* fill space to right of selection rect */			int rightX = focusBounds.x + focusBounds.width;			int width = clientArea.width - rightX;			if (width > 0) {				gc.fillRectangle (rightX, y, width, itemHeight);			}		}				int fillWidth = 0;		if (column == null) {			fillWidth = focusBounds.width;		} else {			fillWidth = column.width - focusBounds.x;			if (parent.linesVisible) fillWidth--;		}		gc.setBackground (background);		gc.fillRectangle (focusBounds.x, focusBounds.y, fillWidth, focusBounds.height);	} else {		int fillWidth = cellBounds.width;		if (parent.linesVisible) fillWidth--;		gc.setBackground (background);		gc.fillRectangle (cellBounds.x, cellBounds.y, fillWidth, cellBounds.height);	}	boolean isSelected = isSelected ();	boolean drawSelection = isSelected;	boolean drawContent = true;	if (parent.hooks (SWT.EraseItem)) {		gc.setFont (getFont ());		if (isSelected) {			gc.setForeground (display.getSystemColor (SWT.COLOR_LIST_SELECTION_TEXT));			gc.setBackground (display.getSystemColor (SWT.COLOR_LIST_SELECTION));		} else {			gc.setForeground (getForeground (columnIndex));			gc.setBackground (getBackground (columnIndex));		}		Event event = new Event ();		event.item = this;		event.gc = gc;		event.index = columnIndex;		event.doit = true;		if (drawSelection) event.detail |= SWT.SELECTED;		if (parent.focusItem == this) event.detail |= SWT.FOCUSED;		event.x = cellBounds.x;		event.y = cellBounds.y;		event.width = cellBounds.width;		event.height = cellBounds.height;		gc.setClipping (event.x, event.y, event.width, event.height);		parent.sendEvent (SWT.EraseItem, event);		event.gc = null;		if (isDisposed ()) return;		drawSelection = drawSelection && (event.detail & SWT.SELECTED) != 0;		drawContent = event.doit;	}	/* draw the selection bar if the receiver is selected */	if (drawSelection && (columnIndex == 0 || (parent.style & SWT.FULL_SELECTION) != 0)) {		if (parent.hasFocus () || (parent.style & SWT.HIDE_SELECTION) == 0) {			gc.setBackground (display.getSystemColor (SWT.COLOR_LIST_SELECTION));			if (columnIndex == 0) {				Rectangle focusBounds = getFocusBounds ();				int startX, fillWidth;				if (column == null || column.getOrderIndex () == 0 || (parent.style & SWT.FULL_SELECTION) == 0) {					startX = focusBounds.x + 1;		/* space for left bound of focus rect */				} else {					startX = column.getX ();				}				if (column == null) {					fillWidth = focusBounds.width - 2;				} else {					fillWidth = column.getX () + column.width - startX;					if (column.getOrderIndex () == parent.columns.length - 1 || (parent.style & SWT.FULL_SELECTION) == 0) {						fillWidth -= 2;	/* space for right bound of focus rect */					}				}				if (fillWidth > 0) {					gc.fillRectangle (startX, focusBounds.y + 1, fillWidth, focusBounds.height - 2);				}			} else {				int startX = column.getX ();				int fillWidth = column.width;				if (column.getOrderIndex () == 0) {					startX += 1;	/* space for left bound of focus rect */					fillWidth -= 1;				}				if (column.getOrderIndex () == parent.columns.length - 1) {					fillWidth -= 2;		/* space for right bound of focus rect */				}				if (fillWidth > 0) {					gc.fillRectangle (						column.getX (),						cellBounds.y + 1,						fillWidth,						cellBounds.height - 2);				}			}		}	}	if (paintBackgroundOnly) return;	/* Draw checkbox if drawing column 0 and parent has style SWT.CHECK */	if (columnIndex == 0 && (parent.style & SWT.CHECK) != 0) {		Image baseImage = grayed ? parent.getGrayUncheckedImage () : parent.getUncheckedImage ();		Rectangle checkboxBounds = getCheckboxBounds ();		gc.drawImage (baseImage, checkboxBounds.x, checkboxBounds.y);		/* Draw checkmark if item is checked */		if (checked) {			Image checkmarkImage = parent.getCheckmarkImage ();			Rectangle checkmarkBounds = checkmarkImage.getBounds ();			int xInset = (checkboxBounds.width - checkmarkBounds.width) / 2;			int yInset = (checkboxBounds.height - checkmarkBounds.height) / 2;			gc.drawImage (checkmarkImage, checkboxBounds.x + xInset, checkboxBounds.y + yInset);		}	}	if (drawContent) {		Image image = getImage (columnIndex, false);		String text = getDisplayText (columnIndex);		Rectangle imageArea = getImageBounds (columnIndex);		int startX = imageArea.x;				/* while painting the cell's content restrict the clipping region */		int padding = parent.getCellPadding ();		gc.setClipping (			startX,			cellBounds.y + padding - (parent.linesVisible ? 1 : 0),			cellRightX - startX - padding,			cellBounds.height - 2 * (padding - (parent.linesVisible ? 1 : 0)));			/* draw the image */		if (image != null) {			Rectangle imageBounds = image.getBounds ();			gc.drawImage (				image,				0, 0,									/* source x, y */				imageBounds.width, imageBounds.height,	/* source width, height */				imageArea.x, imageArea.y,				/* dest x, y */				imageArea.width, imageArea.height);		/* dest width, height */		}			/* draw the text */		if (text.length () > 0) {			gc.setFont (getFont (columnIndex, false));			int fontHeight = getFontHeight (columnIndex);			if (drawSelection && (columnIndex == 0 || (parent.style & SWT.FULL_SELECTION) != 0)) {				if (parent.hasFocus () || (parent.style & SWT.HIDE_SELECTION) == 0) {					gc.setForeground (display.getSystemColor (SWT.COLOR_LIST_SELECTION_TEXT));				}			} else {				gc.setForeground (getForeground (columnIndex));			}			x = getTextX (columnIndex) + MARGIN_TEXT;			gc.drawString (text, x, y + (itemHeight - fontHeight) / 2, true);		}	}	if (parent.hooks (SWT.PaintItem)) {		int contentWidth = getContentWidth (columnIndex);		int contentX = getContentX (columnIndex);		gc.setFont (getFont ());		if (isSelected) {			gc.setForeground (display.getSystemColor (SWT.COLOR_LIST_SELECTION_TEXT));			gc.setBackground (display.getSystemColor (SWT.COLOR_LIST_SELECTION));		} else {			gc.setForeground (getForeground (columnIndex));			gc.setBackground (getBackground (columnIndex));		}		Event event = new Event ();		event.item = this;		event.gc = gc;		event.index = columnIndex;		if (isSelected) event.detail |= SWT.SELECTED;		if (parent.focusItem == this) event.detail |= SWT.FOCUSED;		event.x = contentX;		event.y = cellBounds.y;		event.width = contentWidth;		event.height = cellBounds.height;		gc.setClipping (cellBounds.x, cellBounds.y, cellBounds.width, cellBounds.height);		parent.sendEvent (SWT.PaintItem, event);		event.gc = null;	}}