Search in sources :

Example 86 with PaintEvent

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

the class ScribbleView method createPartControl.

public void createPartControl(Composite parent) {
    Composite backgroundComposite = new Composite(parent, SWT.NONE);
    GridLayout backgroundGridLayout = new GridLayout(3, false);
    backgroundGridLayout.marginHeight = 0;
    backgroundGridLayout.marginBottom = 0;
    backgroundGridLayout.marginLeft = 0;
    backgroundGridLayout.marginRight = 0;
    backgroundGridLayout.marginWidth = 0;
    backgroundGridLayout.horizontalSpacing = 0;
    backgroundComposite.setLayout(backgroundGridLayout);
    backgroundComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    Composite paletteComposite = new Composite(backgroundComposite, SWT.NONE);
    backgroundGridLayout = new GridLayout();
    backgroundGridLayout.marginHeight = 0;
    backgroundGridLayout.marginBottom = 0;
    backgroundGridLayout.marginLeft = 0;
    backgroundGridLayout.marginRight = 0;
    backgroundGridLayout.marginWidth = 0;
    backgroundGridLayout.horizontalSpacing = 0;
    paletteComposite.setLayout(backgroundGridLayout);
    GridData toolboxGridData = new GridData(GridData.FILL_VERTICAL);
    toolboxGridData.widthHint = 60;
    paletteComposite.setLayoutData(toolboxGridData);
    final TableViewer toolbox = new TableViewer(paletteComposite, SWT.FLAT | SWT.FULL_SELECTION);
    toolboxGridData = new GridData(GridData.FILL_BOTH);
    toolbox.getTable().setLayoutData(toolboxGridData);
    toolbox.setLabelProvider(new ToolboxLabelProvider());
    toolbox.setContentProvider(new ListContentProvider());
    toolbox.setInput(createTools());
    toolbox.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            currentTool = (AbstractTool) ((StructuredSelection) toolbox.getSelection()).getFirstElement();
            // Apply the drawSettings to the currently selected tool.
            currentTool.setDrawSettings(drawSettings);
        }
    });
    // Create the UI widgets to modify the DrawSettings instance.
    createSettings(paletteComposite);
    Label separator = new Label(backgroundComposite, SWT.SEPARATOR | SWT.VERTICAL);
    separator.setLayoutData(new GridData(GridData.FILL_VERTICAL));
    canvas = new Canvas(backgroundComposite, SWT.NONE);
    canvas.setLayoutData(new GridData(GridData.FILL_BOTH));
    display = parent.getDisplay();
    canvas.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
    canvas.addPaintListener(new PaintListener() {

        public void paintControl(PaintEvent e) {
            for (Iterator i = tools.iterator(); i.hasNext(); ) {
                AbstractTool at = (AbstractTool) i.next();
                at.draw(canvas);
            }
        }
    });
    Listener listener = new Listener() {

        public void handleEvent(Event event) {
            if (currentTool != null) {
                // Have the tool interpret the mouse events.
                currentTool.handleUIEvent(event, canvas);
                // other clients for rendering.
                if (currentTool.isComplete()) {
                    tools.add(currentTool);
                    sendTool(currentTool);
                    // Only do this once per Tool.
                    currentTool.setComplete(false);
                }
            /*else {
						if (currentTool instanceof Pencil) {
							tools.add(currentTool);
						}
					}*/
            }
        }
    };
    canvas.addListener(SWT.MouseDown, listener);
    canvas.addListener(SWT.MouseMove, listener);
    canvas.addListener(SWT.MouseUp, listener);
}
Also used : PaintEvent(org.eclipse.swt.events.PaintEvent) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) PaintListener(org.eclipse.swt.events.PaintListener) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionListener(org.eclipse.swt.events.SelectionListener) Composite(org.eclipse.swt.widgets.Composite) PaintListener(org.eclipse.swt.events.PaintListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Canvas(org.eclipse.swt.widgets.Canvas) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) GridLayout(org.eclipse.swt.layout.GridLayout) ListContentProvider(org.eclipse.ecf.tutorial.scribbleshare.toolbox.ListContentProvider) GridData(org.eclipse.swt.layout.GridData) Iterator(java.util.Iterator) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event) PaintEvent(org.eclipse.swt.events.PaintEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ToolboxLabelProvider(org.eclipse.ecf.tutorial.scribbleshare.toolbox.ToolboxLabelProvider) TableViewer(org.eclipse.jface.viewers.TableViewer) AbstractTool(org.eclipse.ecf.tutorial.scribbleshare.toolbox.AbstractTool)

Example 87 with PaintEvent

use of org.eclipse.swt.events.PaintEvent in project statecharts by Yakindu.

the class DiagramPartitioningBreadcrumbViewer method createDropDownTreeViewer.

protected TreeViewer createDropDownTreeViewer(final Composite composite, TreePath paramPath, final IBreadcrumbDropDownSite site) {
    Diagram diagram = (Diagram) paramPath.getParentPath().getLastSegment();
    TreeViewer viewer = null;
    if (diagram != null)
        viewer = createDiagramViewer(composite, diagram);
    else
        viewer = createProjectStatechartViewer(composite, (Diagram) paramPath.getLastSegment());
    viewer.getControl().addPaintListener(new PaintListener() {

        public void paintControl(PaintEvent e) {
            getDropDownShell().pack(true);
        }
    });
    return viewer;
}
Also used : PaintEvent(org.eclipse.swt.events.PaintEvent) PaintListener(org.eclipse.swt.events.PaintListener) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Diagram(org.eclipse.gmf.runtime.notation.Diagram)

Example 88 with PaintEvent

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

the class ScreenCaptureConfirmationDialog method createDialogArea.

protected Control createDialogArea(Composite parent) {
    final Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(new GridData(width, height));
    composite.addPaintListener(new PaintListener() {

        public void paintControl(PaintEvent e) {
            e.gc.drawImage(image, 0, 0);
        }
    });
    return composite;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) PaintEvent(org.eclipse.swt.events.PaintEvent) PaintListener(org.eclipse.swt.events.PaintListener) GridData(org.eclipse.swt.layout.GridData)

Example 89 with PaintEvent

use of org.eclipse.swt.events.PaintEvent in project core by jcryptool.

the class AlgorithmView method createSearchArea.

/**
 * Creates the search field. On Mac the text does contain a clear (reset) icon which resets
 * the view filter. Since Windows does not support this an additional clear (reset) icon
 * is shown next to the text.
 *
 * @param parent The parent composite
 */
private void createSearchArea(Composite parent) {
    // search field
    final Text search = new Text(parent, SWT.SEARCH | SWT.ICON_CANCEL | SWT.ICON_SEARCH);
    if ((search.getStyle() & SWT.CANCEL) == 0) {
        // reset search button for systems that do not support the cancel icon
        Canvas canvas = new Canvas(parent, SWT.NONE);
        GridData gridData = new GridData();
        gridData.heightHint = 18;
        gridData.widthHint = 18;
        canvas.setLayoutData(gridData);
        canvas.addPaintListener(new PaintListener() {

            public void paintControl(PaintEvent e) {
                // $NON-NLS-1$
                e.gc.drawImage(ViewsPlugin.getImageDescriptor("icons/clear.gif").createImage(), 1, 1);
            }
        });
        canvas.addMouseListener(new MouseAdapter() {

            public void mouseUp(MouseEvent e) {
                search.setText(Messages.AlgorithmView_search_message);
                search.setForeground(COLOR_FILTER_INITIAL);
                initialSearchState = true;
                // $NON-NLS-1$
                treeView.setFilter("");
                // $NON-NLS-1$
                paletteView.setFilter("");
            }
        });
    }
    search.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    search.setText(Messages.AlgorithmView_search_message);
    search.setForeground(COLOR_FILTER_INITIAL);
    search.addMouseListener(new MouseAdapter() {

        public void mouseDown(MouseEvent e) {
            if (initialSearchState) {
                // $NON-NLS-1$
                search.setText("");
                search.setForeground(COLOR_FILTER_USER);
                initialSearchState = false;
            }
        }
    });
    search.addKeyListener(new KeyAdapter() {

        public void keyReleased(KeyEvent e) {
            treeView.setFilter(search.getText());
            paletteView.setFilter(search.getText());
        }
    });
    search.addSelectionListener(new SelectionAdapter() {

        public void widgetDefaultSelected(SelectionEvent e) {
            if (e.detail == SWT.CANCEL) {
                search.setText(Messages.AlgorithmView_search_message);
                search.setForeground(COLOR_FILTER_INITIAL);
                initialSearchState = true;
                // $NON-NLS-1$
                treeView.setFilter("");
                // $NON-NLS-1$
                paletteView.setFilter("");
            }
        }
    });
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) PaintEvent(org.eclipse.swt.events.PaintEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) PaintListener(org.eclipse.swt.events.PaintListener) Canvas(org.eclipse.swt.widgets.Canvas) KeyAdapter(org.eclipse.swt.events.KeyAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) MouseAdapter(org.eclipse.swt.events.MouseAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Text(org.eclipse.swt.widgets.Text)

Example 90 with PaintEvent

use of org.eclipse.swt.events.PaintEvent in project jbosstools-openshift by jbosstools.

the class AbstractProjectPage method onPageActivated.

@Override
protected void onPageActivated(final DataBindingContext dbc) {
    loadResources(getPreviousPage() == null);
    // fix GTK3 combo boxes too small
    // https://issues.jboss.org/browse/JBIDE-16877,
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=431425
    getControl().addPaintListener(new PaintListener() {

        @Override
        public void paintControl(PaintEvent e) {
            if (getControl().isVisible()) {
                ((Composite) getControl()).layout(true, true);
                ((Composite) getControl()).update();
                getControl().removePaintListener(this);
            }
        }
    });
}
Also used : PaintEvent(org.eclipse.swt.events.PaintEvent) PaintListener(org.eclipse.swt.events.PaintListener)

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