private void drawBoardBorder(GC gc, Rectangle bounds) { gc.setClipping(bounds); int x = bounds.x; int y = bounds.y; int w = bounds.width; int h = bounds.height; gc.setBackground(boardBorder); gc.fillRoundRectangle(x, y, w, h, border + 1, border + 1); }
private static void paintImage(GC gc, Point size) { gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); gc.fillRectangle(0, 0, size.x, size.y); gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_LIST_SELECTION)); gc.fillRoundRectangle(0, 0, size.x - 1, size.y - 1, 10, 10); gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); gc.drawRoundRectangle(0, 0, size.x - 1, size.y - 1, 10, 10); gc.drawText(gc.getFont().getFontData()[0].toString(), 10, 10, true); }
/** Draw the item {@inheritDoc} */ @Override public void paintControl(final PaintEvent e) { final Display display = getDisplay(); final GC gc = e.gc; final Rectangle bounds = getBounds(); last_alarm_state = item.getSeverity(); gc.setBackground(color_provider.getColor(last_alarm_state)); gc.fillRoundRectangle(0, 0, bounds.width, bounds.height, 10, 10); gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_BORDER)); gc.drawRoundRectangle(0, 0, bounds.width - 1, bounds.height - 1, 10, 10); // Draw Text gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); final String label = item.getName(); final Point extend = gc.textExtent(label); gc.drawString(label, (bounds.width - extend.x) / 2, (bounds.height - extend.y) / 2, true); }
private void drawTileRack(GC gc, Rectangle bounds) { gc.setClipping(bounds); int x = bounds.x; int y = bounds.y; int w = bounds.width; int h = bounds.height; gc.setBackground(tileRackBorder); gc.fillRoundRectangle(x, y, w, h, border + 1, border + 1); gc.setBackground(tileRackFill); gc.fillRectangle(x + border, y + border, w - border * 2, h - border * 2); // TileRack tileRack = getLocalTileRack(); if (tileRack == null) return; Tile[] tiles = tileRack.getTiles(); x += border; y += border; for (int i = 0; i < tiles.length; i++) { Tile tile = tiles[i]; Rectangle rectangle = new Rectangle(x, y, tileSize, tileSize); DragSource source = new DragSource(); source.rectangle = rectangle; source.x = i; source.y = -1; source.tile = tile; dragSources.put(rectangle, source); DragTarget target = new DragTarget(); target.rectangle = rectangle; target.x = i; target.y = -1; dragTargets.add(target); drawTile(gc, rectangle, tile); x += tileSize; } }
private static void paintImage2(GC gc, Point size, int f) { gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); gc.fillRectangle(0, 0, size.x, size.y); // Scale line width, corner roundness, and font size. // Caveat: line width expands in all directions, so the origin also has to move. gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_LIST_SELECTION)); gc.fillRoundRectangle(f / 2, f / 2, size.x - f, size.y - f, 10 * f, 10 * f); gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); gc.setLineWidth(f); gc.drawRoundRectangle(f / 2, f / 2, size.x - f, size.y - f, 10 * f, 10 * f); FontData fontData = gc.getFont().getFontData()[0]; fontData.setHeight(fontData.getHeight() * f); Font font = new Font(gc.getDevice(), fontData); try { gc.setFont(font); gc.drawText(fontData.toString(), 10 * f, 10 * f, true); } finally { font.dispose(); } }
protected void paint(GC gc, Display display) { if (bounds == null) buildCaches(); gc.setAntialias(SWT.ON); gc.setTextAntialias(SWT.ON); int x, y, w, h; boolean focused = getControl().isFocusControl() || isForceFocus(); boolean hasBackgroundAndBorder = pressed || hovered || focused; if (hasBackgroundAndBorder) { // draw control background gc.setBackground(getBorderBackground(display)); gc.fillRoundRectangle( bounds.x, bounds.y, bounds.width, bounds.height, CORNER_SIZE, CORNER_SIZE); } if (focused) { // draw focused content background x = contentArea.x - FOCUS_BORDER; y = contentArea.y - FOCUS_BORDER; w = contentArea.width + FOCUS_BORDER * 2; h = contentArea.height + FOCUS_BORDER * 2; gc.setBackground(getRealTextBackground(display)); gc.fillRoundRectangle(x, y, w, h, FOCUS_CORNER_SIZE, FOCUS_CORNER_SIZE); } boolean hasImage = hasImage(); boolean hasText = hasText(); if (hasImage) { Rectangle clipping = gc.getClipping(); if (clipping == null || clipping.intersects(imgArea)) { // draw image Point imgSize = getImageSize(); x = imgArea.x + (imgArea.width - imgSize.x) / 2; y = imgArea.y + (imgArea.height - imgSize.y) / 2; gc.setClipping(imgArea); gc.drawImage(image, x, y); gc.setClipping(clipping); } } if (hasText) { Rectangle clipping = gc.getClipping(); if (clipping == null || clipping.intersects(textArea)) { // draw text String text = getAppliedText(); gc.setFont(getControl().getFont()); Point ext = gc.stringExtent(text); // if (hasImage) { x = textArea.x; // } else { // x = textArea.x + (textArea.width - ext.x) / 2; // } y = textArea.y + (textArea.height - ext.y) / 2; gc.setClipping(textArea); gc.setForeground(getRealTextForeground(display)); gc.drawString(text, x, y, true); gc.setClipping(clipping); } } // draw arrows if (hasArrows() && arrowLoc != null) { gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW)); x = arrowLoc.x + ARROW_WIDTH / 2; y = arrowLoc.y; int x1 = arrowLoc.x - 1; int y1 = arrowLoc.y + ARROW_HEIGHT + 1; int x2 = arrowLoc.x + ARROW_WIDTH; gc.fillPolygon(new int[] {x, y, x1, y1, x2, y1}); y += ARROW_HEIGHT * 2 + ARROWS_SPACING + 1; x1 = arrowLoc.x; y1 += ARROWS_SPACING; gc.fillPolygon(new int[] {x, y, x2, y1, x1 - 1, y1}); } // draw border if (focused) { x = bounds.x; y = bounds.y; w = bounds.width; h = bounds.height; if (DRAWS_FOCUS) { gc.drawFocus(x - MARGIN + 1, y - MARGIN + 1, w + MARGIN * 2 - 2, h + MARGIN * 2 - 2); } else { gc.setForeground(getBorderForeground(display, focused)); gc.drawRoundRectangle(x, y, w, h, CORNER_SIZE, CORNER_SIZE); } } }
/* (non-Javadoc) * @see org.eclipse.vtp.desktop.editors.themes.mantis.MantisComponentFrame#renderFrame(org.eclipse.swt.graphics.GC, int, int, java.util.Map) */ public void renderFrame(GC gc, int renderingPhase, int options, Map<String, Object> resourceMap) { Font originalFont = gc.getFont(); Color foreground = gc.getForeground(); Color background = gc.getBackground(); Color selectedColor = getColor(gc, resourceMap, "rust.selection.color", 82, 140, 55); Color elementBlue = getColor(gc, resourceMap, "rust.element.color", 207, 234, 195); Color elementGradBlue = getColor(gc, resourceMap, "rust.element.color.gradient", 161, 211, 137); Font nameFont = new Font(gc.getDevice(), "Arial", 10, SWT.NORMAL); gc.setFont(nameFont); if (upperLeft == null) { initializeGraphics(gc, resourceMap); } int width = lowerRight.x - upperLeft.x; int height = lowerRight.y - upperLeft.y; int mainBodyHeight = height - (uiElement.hasConnectors() ? 12 : 0); if (uiElement.hasConnectors()) { // draw inspector tray gc.setBackground(elementBlue); gc.fillRoundRectangle(upperLeft.x, upperLeft.y + 3, width - 1, height - 3, 20, 20); // draw inspector tray border if (selected && (options & Theme.RENDER_FLAG_NO_SELECTION) == 0) { gc.setForeground(selectedColor); } gc.drawRoundRectangle(upperLeft.x, upperLeft.y + 3, width - 1, height - 3, 20, 20); } // draw main body gc.setBackground(elementBlue); gc.fillRoundRectangle(upperLeft.x, upperLeft.y, width - 1, mainBodyHeight - 1, 20, 20); gc.setBackground(elementGradBlue); gc.fillRoundRectangle( upperLeft.x + 1, upperLeft.y + (mainBodyHeight / 2) - 1, lowerRight.x - upperLeft.x - 2, (mainBodyHeight / 2) + (mainBodyHeight % 2), 20, 20); // gc.setForeground(elementBlue); // gc.fillGradientRectangle(upperLeft.x + 2, // upperLeft.y // + (mainBodyHeight / 3), // lowerRight.x - upperLeft.x - 4, // ((mainBodyHeight / 3) * 2) - 5, // true); gc.setForeground(foreground); gc.setBackground(background); // draw main body border if (selected && (options & Theme.RENDER_FLAG_NO_SELECTION) == 0) { gc.setForeground(selectedColor); } gc.drawRoundRectangle(upperLeft.x, upperLeft.y, width - 1, mainBodyHeight - 1, 20, 20); gc.setForeground(foreground); // draw connector hot spot if (uiElement.hasConnectors()) { gc.drawLine(lowerRight.x - 19, lowerRight.y - 8, lowerRight.x - 5, lowerRight.y - 8); // gc.drawLine(lowerRight.x - 8, lowerRight.y - 15, lowerRight.x - 3, lowerRight.y - 10); gc.drawLine(lowerRight.x - 10, lowerRight.y - 3, lowerRight.x - 5, lowerRight.y - 8); } // draw icon if ((options & Theme.RENDER_FLAG_NO_ICONS) == 0) { gc.drawImage( icon, upperLeft.x + 5, upperLeft.y + (((mainBodyHeight - 16) / 2) + ((mainBodyHeight - 16) % 2))); } // draw element name int curX = upperLeft.x + 25; int curY = upperLeft.y + 5; String[] parts = this.getDesignElement().getName().split(" "); Point stringExtent = gc.stringExtent(parts[0]); int ew = stringExtent.x; gc.drawString(parts[0], curX, curY, true); curX += stringExtent.x; for (int i = 1; i < parts.length; i++) { stringExtent = gc.stringExtent(" " + parts[i]); boolean wrapped = false; if (ew + stringExtent.x > 110) // wrap it { stringExtent = gc.stringExtent(parts[i]); ew = stringExtent.x; curY += 2 + stringExtent.y; curX = upperLeft.x + 25; wrapped = true; } else ew += stringExtent.x; gc.drawString((wrapped ? "" : " ") + parts[i], curX, curY, true); curX += stringExtent.x; } // draw decorator icons if ((options & Theme.RENDER_FLAG_NO_MARKERS) == 0) { if (uiElement.hasErrors()) gc.drawImage( org.eclipse.vtp.desktop.core.Activator.getDefault() .getImageRegistry() .get("ICON_ERROR"), lowerRight.x - 17, upperLeft.y); else if (uiElement.hasWarnings()) gc.drawImage( org.eclipse.vtp.desktop.core.Activator.getDefault() .getImageRegistry() .get("ICON_WARNING"), lowerRight.x - 16, upperLeft.y); else if (uiElement.hasTodo()) gc.drawImage( org.eclipse.vtp.desktop.core.Activator.getDefault().getImageRegistry().get("ICON_TASK"), lowerRight.x - 18, upperLeft.y + 2); } // resource cleanup if (selected) { gc.setForeground(foreground); } gc.setFont(originalFont); nameFont.dispose(); }
/* (non-Javadoc) * @see org.eclipse.vtp.desktop.editors.themes.attraction.AttractionComponentFrame#renderFrame(org.eclipse.swt.graphics.GC, int, int, java.util.Map) */ public void renderFrame(GC gc, int renderingPhase, int options, Map<String, Object> resourceMap) { Font originalFont = gc.getFont(); Color foreground = gc.getForeground(); Color background = gc.getBackground(); Color selectedColor = getColor(gc, resourceMap, "attraction.selection.color", 0, 0, 255); Color elementBlue = getColor(gc, resourceMap, "attraction.element.color", 201, 229, 255); Color elementGradBlue = getColor(gc, resourceMap, "attraction.element.color.gradient", 153, 206, 255); Font nameFont = getFont(gc, resourceMap, "attraction.element.font", "Arial", 10, SWT.NORMAL); gc.setFont(nameFont); if (upperLeft == null) { initializeGraphics(gc, resourceMap); } int width = lowerRight.x - upperLeft.x; int height = lowerRight.y - upperLeft.y; gc.setBackground(elementBlue); gc.fillRoundRectangle(upperLeft.x, upperLeft.y, width - 1, height - 1, 12, 12); if ((options & Theme.RENDER_FLAG_PRINTING) == 0) { gc.setBackground(elementGradBlue); gc.fillRoundRectangle( upperLeft.x, upperLeft.y + ((lowerRight.y - upperLeft.y) / 2), lowerRight.x - upperLeft.x, ((lowerRight.y - upperLeft.y) / 2), 12, 12); gc.setForeground(elementBlue); gc.fillGradientRectangle( upperLeft.x, upperLeft.y + ((lowerRight.y - upperLeft.y) / 3), lowerRight.x - upperLeft.x, (((lowerRight.y - upperLeft.y) / 3) * 2) - 5, true); } gc.setForeground(foreground); gc.setBackground(background); // draw connector hot spot if (uiElement.hasConnectors()) { gc.drawLine(lowerRight.x - 17, lowerRight.y - 10, lowerRight.x - 3, lowerRight.y - 10); gc.drawLine(lowerRight.x - 8, lowerRight.y - 15, lowerRight.x - 3, lowerRight.y - 10); gc.drawLine(lowerRight.x - 8, lowerRight.y - 5, lowerRight.x - 3, lowerRight.y - 10); } if (selected && (options & Theme.RENDER_FLAG_NO_SELECTION) == 0) { gc.setForeground(selectedColor); } gc.drawRoundRectangle(upperLeft.x, upperLeft.y, width - 1, height - 1, 12, 12); if ((options & Theme.RENDER_FLAG_NO_ICONS) == 0) { gc.drawImage(icon, upperLeft.x + 10, upperLeft.y + 12); } int curX = upperLeft.x + 30; int curY = upperLeft.y + 15; String[] parts = this.getDesignElement().getName().split(" "); Point stringExtent = gc.stringExtent(parts[0]); int ew = stringExtent.x; gc.drawString(parts[0], curX, curY, true); curX += stringExtent.x; for (int i = 1; i < parts.length; i++) { stringExtent = gc.stringExtent(" " + parts[i]); boolean wrapped = false; if (ew + stringExtent.x > 110) // wrap it { stringExtent = gc.stringExtent(parts[i]); ew = stringExtent.x; curY += 3 + stringExtent.y; curX = upperLeft.x + 30; wrapped = true; } else ew += stringExtent.x; gc.drawString((wrapped ? "" : " ") + parts[i], curX, curY, true); curX += stringExtent.x; } if (selected) { gc.setForeground(foreground); } gc.setFont(originalFont); if ((options & Theme.RENDER_FLAG_NO_MARKERS) == 0) { if (uiElement.hasErrors()) gc.drawImage( org.eclipse.vtp.desktop.core.Activator.getDefault() .getImageRegistry() .get("ICON_ERROR"), lowerRight.x - 17, upperLeft.y); else if (uiElement.hasWarnings()) gc.drawImage( org.eclipse.vtp.desktop.core.Activator.getDefault() .getImageRegistry() .get("ICON_WARNING"), lowerRight.x - 16, upperLeft.y); else if (uiElement.hasTodo()) gc.drawImage( org.eclipse.vtp.desktop.core.Activator.getDefault().getImageRegistry().get("ICON_TASK"), lowerRight.x - 18, upperLeft.y + 2); } }
private void drawPlayerStats(GC gc, Rectangle bounds, IPlayer player, int align) { gc.setClipping(bounds); int x = bounds.x; int y = bounds.y; int w = bounds.width; int h = bounds.height; int p = w / 32; Color fillColor = null; Color handleColor = null; Color scoreColor = null; Color clockColor = null; if (game.getGameState() == GameState.ENDED) { if (player == game.getWinner()) { fillColor = new Color(null, 0, 164, 0); handleColor = new Color(null, 255, 255, 255); scoreColor = new Color(null, 255, 255, 255); clockColor = new Color(null, 255, 255, 255); } else { fillColor = new Color(null, 164, 0, 0); handleColor = new Color(null, 255, 255, 255); scoreColor = new Color(null, 255, 255, 255); clockColor = new Color(null, 255, 255, 255); } } else { if (player == game.getCurrentPlayer()) { fillColor = new Color(null, 0, 0, 192); handleColor = new Color(null, 205, 205, 255); scoreColor = new Color(null, 255, 255, 255); clockColor = new Color(null, 215, 215, 215); } else { fillColor = new Color(null, 153, 153, 153); handleColor = new Color(null, 0, 0, 128); scoreColor = new Color(null, 0, 0, 0); clockColor = new Color(null, 0, 0, 0); } } // fill gc.setBackground(fillColor); gc.fillRoundRectangle(x, y, w, h, border + 1, border + 1); // draw handle int n = h / 4; Font font = new Font(null, "Arial", n, SWT.BOLD); String s = player.getName(); gc.setFont(font); gc.setForeground(handleColor); Point extent = gc.stringExtent(s); if (align == SWT.LEFT) { gc.drawString(s, x + p, y, true); } else { gc.drawString(s, x + w - p - extent.x, y, true); } font.dispose(); // save width int i = extent.x + p; // draw clock font = new Font(null, "Courier New", n, SWT.BOLD); s = player.getClock().toString(); gc.setFont(font); gc.setForeground(clockColor); extent = gc.stringExtent(s); if (align == SWT.LEFT) { gc.drawString(s, x + p, y + h - extent.y, true); } else { gc.drawString(s, x + w - p - extent.x, y + h - extent.y, true); } font.dispose(); // draw score font = new Font(null, "Arial", h / 2, SWT.BOLD); s = Integer.toString(player.getScore()); gc.setFont(font); gc.setForeground(scoreColor); extent = gc.stringExtent(s); if (align == SWT.LEFT) { gc.drawString(s, x + i + (w - i) / 2 - extent.x / 2, y + h / 2 - extent.y / 2, true); } else { gc.drawString(s, x + (w - i) / 2 - extent.x / 2, y + h / 2 - extent.y / 2, true); } font.dispose(); fillColor.dispose(); handleColor.dispose(); scoreColor.dispose(); clockColor.dispose(); }
private void paintCanvas(GC gc, int px, int py, int pw, int ph) { if (canvas == null || canvas.isDisposed()) return; Rectangle r = canvas.getBounds(); Color b1 = canvas.getBackground(); gc.setAntialias(SWT.ON); gc.setTextAntialias(SWT.ON); // Draw selection background: if (isSelected()) { gc.setBackground(selectedBackground); gc.fillRoundRectangle(0, 0, r.width, r.height, CORNER, CORNER); } else if (showingHover) { int oldAlpha = gc.getAlpha(); gc.setAlpha(96 * oldAlpha / 255); gc.setBackground(selectedBackground); gc.fillRoundRectangle(0, 0, r.width, r.height, CORNER, CORNER); gc.setAlpha(oldAlpha); } // Draw edit indicator: if (showingEditorHover) { int oldAlpha = gc.getAlpha(); gc.setAlpha(192 * oldAlpha / 255); gc.setBackground(b1); gc.fillRoundRectangle( r.width / 2 + HOVER_SHRINK_H, HOVER_SHRINK_V, r.width / 2 - HOVER_SHRINK_H - HOVER_SHRINK_H, r.height - HOVER_SHRINK_V - HOVER_SHRINK_V, HOVER_CORNER, HOVER_CORNER); gc.setAlpha(oldAlpha); // // Control ec = editor == null ? null : editor.getControl(); // if (ec != null && !ec.isDisposed()) { // Rectangle eb = ec.getBounds(); // gc.setAlpha(192); // gc.setBackground(b1); // gc.fillRoundRectangle(eb.x, eb.y, eb.width, eb.height, 8, 8); // gc.setAlpha(255); // } } // Draw property name label: gc.setForeground(canvas.getForeground()); gc.setFont(canvas.getFont()); if (nameLayout != null && !nameLayout.isDisposed()) { Rectangle nb = nameLayout.getBounds(); nameLayout.draw(gc, MARGIN_H, (r.height - nb.height) / 2); } // Draw property value repsentating image: int right = r.width - MARGIN_H; if (valueImage != null && !valueImage.isDisposed()) { Rectangle ib = valueImage.getBounds(); int iw, ih; if (ib.height > r.height) { ih = r.height; iw = ib.width * r.height / ib.height; } else { ih = ib.height; iw = ib.width; } gc.drawImage(valueImage, 0, 0, ib.width, ib.height, right - iw, (r.height - ih) / 2, iw, ih); right = right - iw - 3; } // Draw property value label: if (valueLayout != null && !valueLayout.isDisposed()) { Rectangle vb = valueLayout.getBounds(); valueLayout.draw(gc, right - vb.width, (r.height - vb.height) / 2); } }
/* * (non-Javadoc) * * @see * org.eclipse.nebula.widgets.gallery.AbstractGalleryItemRenderer#draw(org * .eclipse.swt.graphics.GC, org.eclipse.nebula.widgets.gallery.GalleryItem, * int, int, int, int, int) */ public void draw(GC gc, GalleryItem item, int index, int x, int y, int width, int height) { Image itemImage = item.getImage(); Color itemBackgroundColor = item.getBackground(); Color itemForegroundColor = item.getForeground(); int useableHeight = height; int imageWidth = 0; int imageHeight = 0; int xShift = 0; int yShift = 0; Point size = null; if (itemImage != null) { Rectangle itemImageBounds = itemImage.getBounds(); imageWidth = itemImageBounds.width; imageHeight = itemImageBounds.height; size = RendererHelper.getBestSize( imageWidth, imageHeight, useableHeight - 4 - this.dropShadowsSize, useableHeight - 4 - this.dropShadowsSize); xShift = ((useableHeight - size.x) >> 1) + 2; yShift = (useableHeight - size.y) >> 1; if (dropShadows) { Color c = null; for (int i = this.dropShadowsSize - 1; i >= 0; i--) { c = dropShadowsColors.get(i); gc.setForeground(c); gc.drawLine( x + useableHeight + i - xShift - 1, y + dropShadowsSize + yShift, x + useableHeight + i - xShift - 1, y + useableHeight + i - yShift); gc.drawLine( x + xShift + dropShadowsSize, y + useableHeight + i - yShift - 1, x + useableHeight + i - xShift, y - 1 + useableHeight + i - yShift); } } } // Draw selection background (rounded rectangles) if (selected || RendererHelper.isColorsEquals(itemBackgroundColor, gallery.getBackground())) { if (selected) { gc.setBackground(selectionBackgroundColor); gc.setForeground(selectionBackgroundColor); } else if (itemBackgroundColor != null) { gc.setBackground(itemBackgroundColor); } if (showRoundedSelectionCorners) gc.fillRoundRectangle(x, y, width, useableHeight, selectionRadius, selectionRadius); else gc.fillRectangle(x, y, width, useableHeight); } if (itemImage != null && size != null) { if (size.x > 0 && size.y > 0) { gc.drawImage( itemImage, 0, 0, imageWidth, imageHeight, x + xShift, y + yShift, size.x, size.y); drawAllOverlays(gc, item, x, y, size, xShift, yShift); } } if (item.getText() != null && !EMPTY_STRING.equals(item.getText()) && showLabels) { // Calculate font height (text and description) gc.setFont(textFont); String text = RendererHelper.createLabel(item.getText(), gc, width - useableHeight - 10); int textFontHeight = gc.getFontMetrics().getHeight(); String description = null; int descriptionFontHeight = 0; if (item.getText(1) != null && !EMPTY_STRING.equals(item.getText(1))) { gc.setFont(descriptionFont); description = RendererHelper.createLabel(item.getText(1), gc, width - useableHeight - 10); descriptionFontHeight = gc.getFontMetrics().getHeight(); } boolean displayText = false; boolean displayDescription = false; int remainingHeight = height - 2 - textFontHeight; if (remainingHeight > 0) displayText = true; remainingHeight -= descriptionFontHeight; if (remainingHeight > 0) displayDescription = true; // Background color gc.setBackground(selected ? selectionBackgroundColor : backgroundColor); // Draw text if (displayText) { int transY = (height - textFontHeight - 2); if (displayDescription) transY -= descriptionFontHeight; transY = transY >> 1; if (selected) { gc.setForeground(this.selectionForegroundColor); } else if (itemForegroundColor != null) { gc.setForeground(itemForegroundColor); } else { gc.setForeground(this.foregroundColor); } gc.setFont(textFont); gc.drawText(text, x + useableHeight + 5, y + transY, true); } // Draw description if (description != null && displayDescription) { gc.setForeground(this.descriptionColor); gc.setFont(descriptionFont); gc.drawText( description, x + useableHeight + 5, y + ((height - descriptionFontHeight - textFontHeight - 2) >> 1) + textFontHeight + 1, true); } } }