Example usage for org.eclipse.swt.widgets Display getCurrent

List of usage examples for org.eclipse.swt.widgets Display getCurrent

Introduction

In this page you can find the example usage for org.eclipse.swt.widgets Display getCurrent.

Prototype

public static Display getCurrent() 

Source Link

Document

Returns the display which the currently running thread is the user-interface thread for, or null if the currently running thread is not a user-interface thread for any display.

Usage

From source file:PrintKTableExample.java

public static void drawTransparentImage(GC gc, Image image, int x, int y) {
    if (image == null)
        return;/*from   w  ww .j a v  a 2  s.c om*/
    Point imageSize = new Point(image.getBounds().width, image.getBounds().height);
    Image img = new Image(Display.getCurrent(), imageSize.x, imageSize.y);
    GC gc2 = new GC(img);
    gc2.setBackground(gc.getBackground());
    gc2.fillRectangle(0, 0, imageSize.x, imageSize.y);
    gc2.drawImage(image, 0, 0);
    gc.drawImage(img, x, y);
    gc2.dispose();
    img.dispose();
}

From source file:PrintKTableExample.java

public static void drawButtonUp(GC gc, String text, int textAlign, Image image, int imageAlign, int x, int y,
        int w, int h, Color face) {
    Display display = Display.getCurrent();
    drawButtonUp(gc, text, textAlign, image, imageAlign, x, y, w, h, face,
            display.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW),
            display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW),
            display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW), 2, 2);
}

From source file:PrintKTableExample.java

public static void drawButtonUp(GC gc, String text, int textAlign, Image image, int imageAlign, Rectangle r,
        int leftMargin, int topMargin) {
    Display display = Display.getCurrent();
    drawButtonUp(gc, text, textAlign, image, imageAlign, r.x, r.y, r.width, r.height,
            display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND),
            display.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW),
            display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW),
            display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW), leftMargin, topMargin);
}

From source file:PrintKTableExample.java

public static void drawButtonUp(GC gc, String text, int textAlign, Image image, int imageAlign, int x, int y,
        int w, int h) {
    Display display = Display.getCurrent();
    drawButtonUp(gc, text, textAlign, image, imageAlign, x, y, w, h,
            display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND),
            display.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW),
            display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW),
            display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW), 2, 2);
}

From source file:PrintKTableExample.java

public static void drawButtonUp(GC gc, String text, int textAlign, Image image, int imageAlign, Rectangle r) {
    Display display = Display.getCurrent();
    drawButtonUp(gc, text, textAlign, image, imageAlign, r.x, r.y, r.width, r.height);
}

From source file:PrintKTableExample.java

public static void drawButtonDown(GC gc, String text, int textAlign, Image image, int imageAlign, int x, int y,
        int w, int h) {
    Display display = Display.getCurrent();
    drawButtonDown(gc, text, textAlign, image, imageAlign, x, y, w, h,
            display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND),
            display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW), 2, 2);
}

From source file:PrintKTableExample.java

public static void drawButtonDown(GC gc, String text, int textAlign, Image image, int imageAlign, int x, int y,
        int w, int h, Color face) {
    Display display = Display.getCurrent();
    drawButtonDown(gc, text, textAlign, image, imageAlign, x, y, w, h, face,
            display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW), 2, 2);
}

From source file:PrintKTableExample.java

public static void drawButtonDeepDown(GC gc, String text, int textAlign, Image image, int imageAlign, int x,
        int y, int w, int h) {
    Display display = Display.getCurrent();
    gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
    gc.drawLine(x, y, x + w - 2, y);//from   w w  w.j a va2s.c o  m
    gc.drawLine(x, y, x, y + h - 2);
    gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
    gc.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
    gc.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
    gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    gc.drawLine(x + 1, y + h - 2, x + w - 2, y + h - 2);
    gc.drawLine(x + w - 2, y + h - 2, x + w - 2, y + 1);
    //
    gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_FOREGROUND));
    gc.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    gc.fillRectangle(x + 2, y + 2, w - 4, 1);
    gc.fillRectangle(x + 1, y + 2, 2, h - 4);
    //
    gc.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    drawTextImage(gc, text, textAlign, image, imageAlign, x + 2 + 1, y + 2 + 1, w - 4, h - 3 - 1);
}

From source file:PrintKTableExample.java

public static void drawShadowImage(GC gc, Image image, int x, int y, int alpha) {
    Display display = Display.getCurrent();
    Point imageSize = new Point(image.getBounds().width, image.getBounds().height);
    ///*  w  w w.java  2  s  .  co  m*/
    ImageData imgData = new ImageData(imageSize.x, imageSize.y, 24, new PaletteData(255, 255, 255));
    imgData.alpha = alpha;
    Image img = new Image(display, imgData);
    GC imgGC = new GC(img);
    imgGC.drawImage(image, 0, 0);
    gc.drawImage(img, x, y);
    imgGC.dispose();
    img.dispose();
}