use of com.biglybt.ui.swt.shells.GCStringPrinter.URLInfo in project BiglyBT by BiglySoftware.
the class SWTSkinObjectText2 method paintControl.
// @see SWTSkinObjectBasic#paintControl(org.eclipse.swt.graphics.GC)
@Override
public void paintControl(GC gc) {
if (sText == null || sText.length() == 0) {
return;
}
super.paintControl(gc);
Composite composite = (Composite) control;
Rectangle clientArea = composite.getClientArea();
clientArea.x += hpadding;
clientArea.width -= hpadding * 2;
clientArea.y += vpadding;
clientArea.height -= vpadding * 2;
Font existingFont = (Font) canvas.getData("font");
Color existingColor = (Color) canvas.getData("color");
if (existingFont != null) {
gc.setFont(existingFont);
}
if (debug) {
System.out.println("paint " + existingColor + ";" + gc.getForeground());
}
if (existingColor != null) {
gc.setForeground(existingColor);
}
if (antialiasMode != SWT.DEFAULT) {
try {
gc.setTextAntialias(antialiasMode);
} catch (Exception ex) {
// Ignore ERROR_NO_GRAPHICS_LIBRARY error or any others
}
}
if (hasShadow) {
Rectangle r = new Rectangle(clientArea.x + 1, clientArea.y + 1, clientArea.width, clientArea.height);
Color foreground = gc.getForeground();
if (colorShadow.color == null) {
Color color = ColorCache.getColor(gc.getDevice(), 0, 0, 0);
gc.setForeground(color);
gc.setAlpha(64);
} else {
gc.setForeground(colorShadow.color);
gc.setAlpha(colorShadow.alpha);
}
GCStringPrinter.printString(gc, sDisplayText, r, true, false, style);
gc.setForeground(foreground);
}
gc.setAlpha(alpha);
// hack to fix shadow wrapping (different widths for text drawn with alpha and text drawn without)
if (alpha == 255 && hasShadow && (colorShadow.color == null || colorShadow.alpha < 255)) {
gc.setAlpha(254);
}
lastStringPrinter = new GCStringPrinter(gc, sDisplayText, clientArea, true, false, style);
if (colorUrl != null) {
lastStringPrinter.setUrlColor(colorUrl);
}
if (colorUrl2 != null && mouseDown) {
lastStringPrinter.calculateMetrics();
Display display = Display.getCurrent();
Point cursorLocation = canvas.toControl(display.getCursorLocation());
URLInfo hitUrl = lastStringPrinter.getHitUrl(cursorLocation.x, cursorLocation.y);
if (hitUrl != null) {
hitUrl.urlColor = colorUrl2;
}
}
lastStringPrinter.printString();
}
Aggregations