Search in sources :

Example 56 with Canvas

use of org.eclipse.swt.widgets.Canvas in project archi by archimatetool.

the class OverviewOutlinePage method createControl.

@Override
public void createControl(Composite parent) {
    if (fEditPart == null) {
        return;
    }
    // create canvas and lws
    fCanvas = new Canvas(parent, SWT.NONE);
    LightweightSystem lws = new LightweightSystem(fCanvas);
    fThumbnail = new ScrollableThumbnail((Viewport) fEditPart.getFigure());
    fThumbnail.setUseScaledGraphics(false);
    fThumbnail.setSource(fEditPart.getLayer(LayerConstants.PRINTABLE_LAYERS));
    fThumbnail.setBorder(new MarginBorder(3));
    lws.setContents(fThumbnail);
    // Help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(fCanvas, HELP_ID);
}
Also used : Canvas(org.eclipse.swt.widgets.Canvas) MarginBorder(org.eclipse.draw2d.MarginBorder) Viewport(org.eclipse.draw2d.Viewport) LightweightSystem(org.eclipse.draw2d.LightweightSystem) ScrollableThumbnail(org.eclipse.draw2d.parts.ScrollableThumbnail)

Example 57 with Canvas

use of org.eclipse.swt.widgets.Canvas in project archi by archimatetool.

the class BufferedGraphicsSource method flushGraphics.

/**
 * @see org.eclipse.draw2d.GraphicsSource#flushGraphics(org.eclipse.draw2d.geometry.Rectangle)
 */
@Override
public void flushGraphics(Rectangle region) {
    if (inUse.isEmpty())
        return;
    boolean restoreCaret = false;
    Canvas canvas = null;
    if (control instanceof Canvas) {
        canvas = (Canvas) control;
        Caret caret = canvas.getCaret();
        if (caret != null)
            restoreCaret = caret.isVisible();
        if (restoreCaret && caret != null)
            caret.setVisible(false);
    }
    /*
         * The imageBuffer may be null if double-buffering was not successful.
         */
    if (imageBuffer != null) {
        imageGC.dispose();
        controlGC.drawImage(getImage(), 0, 0, inUse.width, inUse.height, inUse.x, inUse.y, inUse.width, inUse.height);
        imageBuffer.dispose();
        imageBuffer = null;
        imageGC = null;
    }
    controlGC.dispose();
    controlGC = null;
    if (restoreCaret && canvas != null)
        canvas.getCaret().setVisible(true);
}
Also used : Canvas(org.eclipse.swt.widgets.Canvas) Caret(org.eclipse.swt.widgets.Caret)

Example 58 with Canvas

use of org.eclipse.swt.widgets.Canvas in project cogtool by cogtool.

the class Draw2DMouseState method dealWithEvent.

// Force subclasses to implement the "dealWith" versions
/**
     * Returns true if subclass processing should continue, false
     * if subclass processing should be terminated.
     */
protected boolean dealWithEvent(Event evt) {
    if (evt.type == SWT.MenuDetect) {
        // that each of our windows using Draw2D contains only one Canvas!
        if (isMenuClick || (OSUtils.MACOSX && (evt.widget instanceof Canvas))) {
            Canvas c = (Canvas) evt.widget;
            Text focusedText = WindowUtil.getFocusedText();
            if (focusedText != null) {
                if (focusedText instanceof ManagedText) {
                    ManagedText txt = (ManagedText) focusedText;
                    if (!txt.confirm(ManagedText.LOSE_FOCUS)) {
                        return false;
                    }
                }
                c.forceFocus();
            }
            Combo focusedCombo = WindowUtil.getFocusedCombo();
            if (focusedCombo != null) {
                if (focusedCombo instanceof ManagedCombo) {
                    ManagedCombo combo = (ManagedCombo) focusedCombo;
                    if (!combo.confirm(ManagedCombo.LOSE_FOCUS)) {
                        return false;
                    }
                }
                c.forceFocus();
            }
            Point p = c.toControl(evt.x, evt.y);
            menuUI.showContextMenu(p.x, p.y);
        } else {
            menuUI.showContextMenu();
        }
    }
    return true;
}
Also used : ManagedCombo(edu.cmu.cs.hcii.cogtool.util.ManagedCombo) Canvas(org.eclipse.swt.widgets.Canvas) ManagedText(edu.cmu.cs.hcii.cogtool.util.ManagedText) Text(org.eclipse.swt.widgets.Text) ManagedText(edu.cmu.cs.hcii.cogtool.util.ManagedText) Combo(org.eclipse.swt.widgets.Combo) ManagedCombo(edu.cmu.cs.hcii.cogtool.util.ManagedCombo) Point(org.eclipse.swt.graphics.Point)

Example 59 with Canvas

use of org.eclipse.swt.widgets.Canvas in project translationstudio8 by heartsome.

the class CheckBoxCellEditor method activateCell.

/**
	 * As soon as the editor is activated, flip the current data value and commit it.<br/>
	 * The repaint will pick up the new value and flip the image.
	 */
@Override
protected Control activateCell(Composite parent, Object originalCanonicalValue, Character initialEditValue) {
    setCanonicalValue(originalCanonicalValue);
    checked = !checked;
    canvas = new Canvas(parent, SWT.NONE);
    canvas.addPaintListener(new PaintListener() {

        public void paintControl(PaintEvent paintEvent) {
            Rectangle bounds = canvas.getBounds();
            Rectangle rect = new Rectangle(0, 0, bounds.width, bounds.height);
            checkBoxCellPainter.paintIconImage(paintEvent.gc, rect, bounds.height / 2 - checkBoxCellPainter.getPreferredHeight(checked) / 2, checked);
        }
    });
    canvas.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseUp(MouseEvent e) {
            checked = !checked;
            canvas.redraw();
        }
    });
    commit(MoveDirectionEnum.NONE, false);
    return canvas;
}
Also used : PaintEvent(org.eclipse.swt.events.PaintEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) PaintListener(org.eclipse.swt.events.PaintListener) Canvas(org.eclipse.swt.widgets.Canvas) Rectangle(org.eclipse.swt.graphics.Rectangle) MouseAdapter(org.eclipse.swt.events.MouseAdapter)

Example 60 with Canvas

use of org.eclipse.swt.widgets.Canvas in project dbeaver by serge-rider.

the class ProgressEditorPart method createProgressPane.

private void createProgressPane(final Composite parent) {
    progressCanvas = new Canvas(parent, SWT.NONE);
    progressCanvas.addPaintListener(new PaintListener() {

        @Override
        public void paintControl(PaintEvent e) {
            e.gc.drawText("Connecting to datasource '" + getEditorInput().getDatabaseObject().getName() + "'...", 5, 5, true);
        }
    });
    InitNodeService loadingService = new InitNodeService();
    LoadingJob<IDatabaseEditorInput> loadJob = LoadingJob.createService(loadingService, new InitNodeVisualizer(loadingService));
    loadJob.schedule();
}
Also used : IDatabaseEditorInput(org.jkiss.dbeaver.ui.editors.IDatabaseEditorInput) PaintEvent(org.eclipse.swt.events.PaintEvent) PaintListener(org.eclipse.swt.events.PaintListener) Canvas(org.eclipse.swt.widgets.Canvas)

Aggregations

Canvas (org.eclipse.swt.widgets.Canvas)111 GridData (org.eclipse.swt.layout.GridData)47 GridLayout (org.eclipse.swt.layout.GridLayout)38 Composite (org.eclipse.swt.widgets.Composite)38 PaintEvent (org.eclipse.swt.events.PaintEvent)36 PaintListener (org.eclipse.swt.events.PaintListener)35 Point (org.eclipse.swt.graphics.Point)32 Rectangle (org.eclipse.swt.graphics.Rectangle)32 Label (org.eclipse.swt.widgets.Label)31 Text (org.eclipse.swt.widgets.Text)24 Button (org.eclipse.swt.widgets.Button)22 Color (org.eclipse.swt.graphics.Color)20 Shell (org.eclipse.swt.widgets.Shell)20 MouseEvent (org.eclipse.swt.events.MouseEvent)18 GC (org.eclipse.swt.graphics.GC)17 FillLayout (org.eclipse.swt.layout.FillLayout)17 Event (org.eclipse.swt.widgets.Event)17 SelectionEvent (org.eclipse.swt.events.SelectionEvent)16 Listener (org.eclipse.swt.widgets.Listener)16 Display (org.eclipse.swt.widgets.Display)15