@Override protected void paintText(GC gc, Rectangle bounds) { super.paintText(gc, bounds); if (strikeThrough) { Point totalSize = computeTextSize(SWT.DEFAULT, SWT.DEFAULT); int textWidth = Math.min(bounds.width, totalSize.x); int textHeight = totalSize.y; // int descent = gc.getFontMetrics().getDescent(); int lineY = bounds.y + (textHeight / 2); // - descent + 1; gc.drawLine(bounds.x, lineY, bounds.x + textWidth, lineY); } }
private int drawText(GC gc, Rectangle clientArea, int textX, int textWidth) { Point textSize = computeTextSize(textWidth, SWT.DEFAULT); int slotHeight = clientArea.height - marginHeight - marginHeight; int textY; textWidth = textSize.x; int textHeight = textSize.y; if (verticalAlignment == SWT.BOTTOM) { textY = marginHeight + slotHeight - textHeight; } else if (verticalAlignment == SWT.CENTER) { textY = marginHeight + slotHeight / 2 - textHeight / 2; } else { textY = marginHeight; } paintText(gc, new Rectangle(textX, textY, textWidth, textHeight)); return textWidth; }
private int drawText(GC gc, Rectangle clientArea, int textX, int textWidth) { Point textSize = computeTextSize(textWidth, SWT.DEFAULT); int slotHeight = clientArea.height - marginHeight - marginHeight; int textY; textWidth = textSize.x; int textHeight = textSize.y; if (verticalAlignment == SWT.BOTTOM) { textY = marginHeight + slotHeight - textHeight; } else if (verticalAlignment == SWT.CENTER) { textY = marginHeight + slotHeight / 2 - textHeight / 2; } else { textY = marginHeight; } paintText(gc, new Rectangle(textX, textY, textWidth, textHeight)); return textWidth; }