Search in sources :

Example 71 with PaintEvent

use of org.eclipse.swt.events.PaintEvent in project netxms by netxms.

the class SplashHandler method init.

/* (non-Javadoc)
	 * @see org.eclipse.ui.splash.AbstractSplashHandler#init(org.eclipse.swt.widgets.Shell)
	 */
public void init(Shell splash) {
    super.init(splash);
    instance = this;
    String progressRectString = null;
    String messageRectString = null;
    String foregroundColorString = null;
    IProduct product = Platform.getProduct();
    if (product != null) {
        progressRectString = product.getProperty(IProductConstants.STARTUP_PROGRESS_RECT);
        messageRectString = product.getProperty(IProductConstants.STARTUP_MESSAGE_RECT);
        foregroundColorString = product.getProperty(IProductConstants.STARTUP_FOREGROUND_COLOR);
    }
    if (progressRectString != null) {
        Rectangle progressRect = StringConverter.asRectangle(progressRectString, new Rectangle(10, 10, 300, 15));
        setProgressRect(progressRect);
    }
    if (messageRectString != null) {
        Rectangle messageRect = StringConverter.asRectangle(messageRectString, new Rectangle(10, 35, 300, 15));
        setMessageRect(messageRect);
    }
    int foregroundColorInteger;
    try {
        foregroundColorInteger = Integer.parseInt(foregroundColorString, 16);
    } catch (Exception ex) {
        // off white
        foregroundColorInteger = 0xD2D7FF;
    }
    setForeground(new RGB((foregroundColorInteger & 0xFF0000) >> 16, (foregroundColorInteger & 0xFF00) >> 8, foregroundColorInteger & 0xFF));
    final Color versionColor = new Color(Display.getCurrent(), 224, 224, 224);
    // $NON-NLS-1$
    final Font versionFont = new Font(Display.getCurrent(), "Verdana", 9, SWT.NONE);
    // $NON-NLS-1$ //$NON-NLS-2$
    final String versionText = Messages.get().SplashHandler_Version + NXCommon.VERSION + " (" + BuildNumber.TEXT + ")";
    // $NON-NLS-1$
    final String copyrightText = "\u00A9 2003-2018 Raden Solutions";
    final Composite content = getContent();
    content.addPaintListener(new PaintListener() {

        @Override
        public void paintControl(PaintEvent e) {
            e.gc.setForeground(versionColor);
            e.gc.setFont(versionFont);
            int y = 240;
            Point size = e.gc.textExtent(copyrightText);
            e.gc.drawText(copyrightText, 485 - size.x, y, true);
            y += size.y + 2;
            size = e.gc.textExtent(versionText);
            e.gc.drawText(versionText, 485 - size.x, y, true);
        }
    });
    content.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            versionColor.dispose();
            versionFont.dispose();
        }
    });
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) PaintEvent(org.eclipse.swt.events.PaintEvent) Composite(org.eclipse.swt.widgets.Composite) PaintListener(org.eclipse.swt.events.PaintListener) Color(org.eclipse.swt.graphics.Color) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) RGB(org.eclipse.swt.graphics.RGB) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Point(org.eclipse.swt.graphics.Point) Font(org.eclipse.swt.graphics.Font) IProduct(org.eclipse.core.runtime.IProduct)

Example 72 with PaintEvent

use of org.eclipse.swt.events.PaintEvent in project netxms by netxms.

the class ScreenshotView method createPartControl.

/*
    * (non-Javadoc)
    * 
    * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
    */
@Override
public void createPartControl(Composite parent) {
    parent.setLayout(new FillLayout());
    scroller = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    canvas = new Canvas(scroller, SWT.NONE);
    canvas.addPaintListener(new PaintListener() {

        public void paintControl(PaintEvent e) {
            GC gc = e.gc;
            if (image != null) {
                gc.drawImage(image, 0, 0);
                gc.drawText(imageInfo, 10, image.getImageData().height + 10);
            } else if (errorMessage != null) {
                gc.setForeground(canvas.getDisplay().getSystemColor(SWT.COLOR_DARK_RED));
                gc.setFont(JFaceResources.getBannerFont());
                gc.drawText(errorMessage, 10, 10, true);
            }
        }
    });
    scroller.setContent(canvas);
    scroller.setExpandVertical(true);
    scroller.setExpandHorizontal(true);
    scroller.addControlListener(new ControlAdapter() {

        public void controlResized(ControlEvent e) {
            updateScrollerSize();
        }
    });
    activateContext();
    createActions();
    contributeToActionBars();
    refresh();
}
Also used : PaintEvent(org.eclipse.swt.events.PaintEvent) ControlAdapter(org.eclipse.swt.events.ControlAdapter) PaintListener(org.eclipse.swt.events.PaintListener) Canvas(org.eclipse.swt.widgets.Canvas) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) FillLayout(org.eclipse.swt.layout.FillLayout) GC(org.eclipse.swt.graphics.GC) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 73 with PaintEvent

use of org.eclipse.swt.events.PaintEvent in project netxms by netxms.

the class AvailabilityChart method createClientArea.

/* (non-Javadoc)
	 * @see org.netxms.ui.eclipse.widgets.DashboardElement#createClientArea(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createClientArea(Composite parent) {
    Composite clientArea = new Composite(parent, SWT.NONE);
    colors = new ColorCache(clientArea);
    GridLayout layout = new GridLayout();
    layout.numColumns = 4;
    clientArea.setLayout(layout);
    dayChart = createChart(clientArea, Messages.get().AvailabilityChart_Today);
    weekChart = createChart(clientArea, Messages.get().AvailabilityChart_ThisWeek);
    monthChart = createChart(clientArea, Messages.get().AvailabilityChart_ThisMonth);
    Canvas legend = new Canvas(clientArea, SWT.NONE);
    legend.addPaintListener(new PaintListener() {

        @Override
        public void paintControl(PaintEvent e) {
            paintLegend(e.gc);
        }
    });
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    legend.setLayoutData(gd);
    return clientArea;
}
Also used : ColorCache(org.netxms.ui.eclipse.tools.ColorCache) GridLayout(org.eclipse.swt.layout.GridLayout) PaintEvent(org.eclipse.swt.events.PaintEvent) Composite(org.eclipse.swt.widgets.Composite) PaintListener(org.eclipse.swt.events.PaintListener) Canvas(org.eclipse.swt.widgets.Canvas) GridData(org.eclipse.swt.layout.GridData)

Example 74 with PaintEvent

use of org.eclipse.swt.events.PaintEvent in project liferay-ide by liferay.

the class LayoutTplPreviewEditor method _refreshViewer.

private void _refreshViewer(GraphicalViewer viewer) {
    Control control = viewer.getControl();
    control.addPaintListener(new PaintListener() {

        public void paintControl(PaintEvent e) {
            EditPart editPage = getGraphicalViewer().getContents();
            editPage.refresh();
            control.removePaintListener(this);
        }
    });
}
Also used : Control(org.eclipse.swt.widgets.Control) PaintEvent(org.eclipse.swt.events.PaintEvent) PaintListener(org.eclipse.swt.events.PaintListener) LayoutTplRootEditPart(com.liferay.ide.layouttpl.ui.parts.LayoutTplRootEditPart) EditPart(org.eclipse.gef.EditPart)

Example 75 with PaintEvent

use of org.eclipse.swt.events.PaintEvent in project whole by wholeplatform.

the class LanguageWorkbenchSplashHandler method init.

public void init(Shell splash) {
    super.init(splash);
    IProduct product = Platform.getProduct();
    if (product == null) {
        getContent();
        return;
    }
    String progressPosition = product.getProperty(IProductConstants.STARTUP_PROGRESS_RECT);
    setProgressRect(StringConverter.asRectangle(progressPosition, new Rectangle(0, 0, 300, 15)));
    String messagePosition = product.getProperty(IProductConstants.STARTUP_MESSAGE_RECT);
    setMessageRect(StringConverter.asRectangle(messagePosition, new Rectangle(0, 35, 300, 15)));
    String foreground = product.getProperty(IProductConstants.STARTUP_FOREGROUND_COLOR);
    int foregroundColor;
    try {
        foregroundColor = Integer.parseInt(foreground, 16);
    } catch (NumberFormatException e) {
        // off white
        foregroundColor = 0xD2D7FF;
    }
    setForeground(new RGB((foregroundColor & 0xFF0000) >> 16, (foregroundColor & 0xFF00) >> 8, foregroundColor & 0xFF));
    getContent().addPaintListener(new PaintListener() {

        public void paintControl(PaintEvent e) {
            e.gc.setForeground(getForeground());
            e.gc.drawText(Platform.getBundle("org.whole.product.lw").getVersion().toString(), 250, 52, true);
        }
    });
}
Also used : PaintEvent(org.eclipse.swt.events.PaintEvent) PaintListener(org.eclipse.swt.events.PaintListener) Rectangle(org.eclipse.swt.graphics.Rectangle) IProduct(org.eclipse.core.runtime.IProduct) RGB(org.eclipse.swt.graphics.RGB)

Aggregations

PaintEvent (org.eclipse.swt.events.PaintEvent)96 PaintListener (org.eclipse.swt.events.PaintListener)92 Canvas (org.eclipse.swt.widgets.Canvas)32 Composite (org.eclipse.swt.widgets.Composite)31 Rectangle (org.eclipse.swt.graphics.Rectangle)29 MouseEvent (org.eclipse.swt.events.MouseEvent)27 GridData (org.eclipse.swt.layout.GridData)26 Point (org.eclipse.swt.graphics.Point)24 GridLayout (org.eclipse.swt.layout.GridLayout)23 DisposeEvent (org.eclipse.swt.events.DisposeEvent)18 SelectionEvent (org.eclipse.swt.events.SelectionEvent)18 DisposeListener (org.eclipse.swt.events.DisposeListener)15 FillLayout (org.eclipse.swt.layout.FillLayout)15 Event (org.eclipse.swt.widgets.Event)15 MouseAdapter (org.eclipse.swt.events.MouseAdapter)14 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)13 ControlEvent (org.eclipse.swt.events.ControlEvent)12 Control (org.eclipse.swt.widgets.Control)12 GC (org.eclipse.swt.graphics.GC)11 Listener (org.eclipse.swt.widgets.Listener)11