if (height < 0) { y += height; height = -height; if (vertical) swapColors = true; } if (swapColors) { final int t = fromColor; fromColor = toColor; toColor = t; } if (fromColor == toColor) {  installForeColor(data.foreground); fRect.set(x, y, width, height); OS.PaintRect(fRect.getData());  unfocus(true); return; }   int depth= 32; final boolean directColor = (depth > 8);         RGB fromRGB = Color.carbon_new(data.device, fromColor).getRGB(); RGB toRGB = Color.carbon_new(data.device, toColor).getRGB();  final int redBits, greenBits, blueBits; if (directColor) {  redBits = getChannelWidth(0x00ff0000 ); greenBits = getChannelWidth(0x0000ff00 ); blueBits = getChannelWidth(0x000000ff ); } else {  redBits = greenBits = blueBits = 0; }  ImageData.fillGradientRectangle(this, data.device, x, y, width, height, vertical, fromRGB, toRGB, redBits, greenBits, blueBits);  unfocus(true);
public void fillGradientRectangle(int x, int y, int width, int height, boolean vertical) {	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);	if ((width == 0) || (height == 0)) return;		focus(true);		/* AW	int xDisplay = data.display;	int xScreenNum = OS.XDefaultScreen(xDisplay);	XGCValues values = new XGCValues();	*/	int fromColor, toColor;	/* AW	OS.XGetGCValues(xDisplay, handle, OS.GCForeground | OS.GCBackground, values);	fromColor = values.foreground;	toColor = values.background;	*/	fromColor = data.foreground;	toColor = data.background;		boolean swapColors = false;	if (width < 0) {		x += width; width = -width;		if (! vertical) swapColors = true;	}	if (height < 0) {		y += height; height = -height;		if (vertical) swapColors = true;	}	if (swapColors) {		final int t = fromColor;		fromColor = toColor;		toColor = t;	}	if (fromColor == toColor) {		/* AW		OS.XFillRectangle(xDisplay, data.drawable, handle, x, y, width, height);		*/		installForeColor(data.foreground);		fRect.set(x, y, width, height);		OS.PaintRect(fRect.getData());				unfocus(true);		return;	}	/* X Window deals with a virtually limitless array of color formats	 * but we only distinguish between paletted and direct modes	 */		/* AW	final int xScreen = OS.XDefaultScreenOfDisplay(xDisplay);	final int xVisual = OS.XDefaultVisual(xDisplay, xScreenNum);	Visual visual = new Visual();	OS.memmove(visual, xVisual, visual.sizeof);	final int depth = OS.XDefaultDepthOfScreen(xScreen);	*/	int depth= 32;	final boolean directColor = (depth > 8);	// This code is intentionally commented since elsewhere in SWT we	// assume that depth <= 8 means we are in a paletted mode though	// this is not always the case.	//final boolean directColor = (visual.c_class == OS.TrueColor) || (visual.c_class == OS.DirectColor);	/* AW	XColor xColor = new XColor();	xColor.pixel = fromColor;	OS.XQueryColor(xDisplay, data.colormap, xColor);	final RGB fromRGB = new RGB((xColor.red & 0xffff) >>> 8, (xColor.green & 0xffff) >>> 8, (xColor.blue & 0xffff) >>> 8);	xColor.pixel = toColor;	OS.XQueryColor(xDisplay, data.colormap, xColor);	final RGB toRGB = new RGB((xColor.red & 0xffff) >>> 8, (xColor.green & 0xffff) >>> 8, (xColor.blue & 0xffff) >>> 8);	*/		RGB fromRGB = Color.carbon_new(data.device, fromColor).getRGB();	RGB toRGB = Color.carbon_new(data.device, toColor).getRGB();	final int redBits, greenBits, blueBits;	if (directColor) {		// RGB mapped display		redBits = getChannelWidth(0x00ff0000 /* AW visual.red_mask */);		greenBits = getChannelWidth(0x0000ff00 /* AW visual.green_mask */);		blueBits = getChannelWidth(0x000000ff /* AW visual.blue_mask */);	} else {		// Index display		redBits = greenBits = blueBits = 0;	}	ImageData.fillGradientRectangle(this, data.device,		x, y, width, height, vertical, fromRGB, toRGB,		redBits, greenBits, blueBits);	unfocus(true);}