Search in sources :

Example 11 with URLInfo

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();
}
Also used : GCStringPrinter(com.biglybt.ui.swt.shells.GCStringPrinter) URLInfo(com.biglybt.ui.swt.shells.GCStringPrinter.URLInfo) ParseException(java.text.ParseException)

Aggregations

URLInfo (com.biglybt.ui.swt.shells.GCStringPrinter.URLInfo)11 GCStringPrinter (com.biglybt.ui.swt.shells.GCStringPrinter)8 ActivitiesEntry (com.biglybt.activities.ActivitiesEntry)3 TableCellSWT (com.biglybt.ui.swt.views.table.TableCellSWT)3 UIFunctionsSWT (com.biglybt.ui.swt.UIFunctionsSWT)2 UISkinnableSWTListener (com.biglybt.ui.swt.UISkinnableSWTListener)2 ClipboardCopy (com.biglybt.ui.swt.mainwindow.ClipboardCopy)2 SearchSubsResultBase (com.biglybt.ui.swt.utils.SearchSubsResultBase)2 LogAlert (com.biglybt.core.logging.LogAlert)1 LogEvent (com.biglybt.core.logging.LogEvent)1 PluginInterface (com.biglybt.pif.PluginInterface)1 UserPrompterResultListener (com.biglybt.ui.UserPrompterResultListener)1 ImageLoader (com.biglybt.ui.swt.imageloader.ImageLoader)1 MessageBoxShell (com.biglybt.ui.swt.shells.MessageBoxShell)1 ButtonListenerAdapter (com.biglybt.ui.swt.skin.SWTSkinButtonUtility.ButtonListenerAdapter)1 SkinnedDialog (com.biglybt.ui.swt.views.skin.SkinnedDialog)1 SkinnedDialogClosedListener (com.biglybt.ui.swt.views.skin.SkinnedDialog.SkinnedDialogClosedListener)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 URL (java.net.URL)1 ParseException (java.text.ParseException)1