Example usage for org.eclipse.jface.util Util isPhoton

List of usage examples for org.eclipse.jface.util Util isPhoton

Introduction

In this page you can find the example usage for org.eclipse.jface.util Util isPhoton.

Prototype

@Deprecated
public static boolean isPhoton() 

Source Link

Document

Common WS query helper method.

Usage

From source file:org.eclipse.ui.internal.presentations.r21.widgets.CTabFolder.java

License:Open Source License

private void updateCloseBar() {
    //Temporary code - need a better way to determine toolBar trim
    int toolbarTrim = 4;
    if (Util.isPhoton()) {
        toolbarTrim = 6;//from  w w  w. j  a  v  a  2  s. c  om
    }
    if (Util.isGtk()) {
        toolbarTrim = 8;
    }

    int maxHeight = tabHeight - CTabItem.TOP_MARGIN - CTabItem.BOTTOM_MARGIN - toolbarTrim;
    if (maxHeight < 3) {
        return;
    }
    int imageHeight = (maxHeight < 9) ? 9 : maxHeight;

    if (closeImage != null && closeImage.getBounds().height == imageHeight) {
        return;
    }

    if (closeBar != null) {
        closeBar.dispose();
    }
    closeBar = null;
    if (inactiveCloseBar != null) {
        inactiveCloseBar.dispose();
    }
    inactiveCloseBar = null;
    createCloseBar();

    ToolItem closeItem = closeBar.getItems()[0];
    ToolItem inactiveCloseItem = inactiveCloseBar.getItems()[0];

    if (closeImage != null) {
        closeImage.dispose();
    }

    Display display = getDisplay();
    Color foreground = getForeground();
    Color black = display.getSystemColor(SWT.COLOR_BLACK);
    Color background = getBackground();

    PaletteData palette = new PaletteData(
            new RGB[] { foreground.getRGB(), background.getRGB(), black.getRGB() });
    ImageData imageData = new ImageData(imageHeight, imageHeight, 4, palette);
    imageData.transparentPixel = 1;
    closeImage = new Image(display, imageData);
    GC gc = new GC(closeImage);
    gc.setBackground(background);
    gc.fillRectangle(0, 0, imageHeight, imageHeight);
    gc.setForeground(black);

    //draw an 9x8 'x' centered in image
    int h = (imageHeight / 2) * 2;
    int inset = (h - 8) / 2;
    gc.drawLine(inset, inset, h - inset - 1, h - inset - 1);
    gc.drawLine(inset + 1, inset, h - inset, h - inset - 1);
    gc.drawLine(inset, h - inset - 1, h - inset - 1, inset);
    gc.drawLine(inset + 1, h - inset - 1, h - inset, inset);

    gc.dispose();

    if (maxHeight < imageHeight) {
        //rescale image
        Image temp = scaleImage(closeImage, imageHeight, maxHeight);
        closeImage.dispose();
        closeImage = temp;
    }
    closeItem.setImage(closeImage);
    inactiveCloseItem.setImage(closeImage);
}