Search in sources :

Example 6 with PaintEvent

use of org.eclipse.swt.events.PaintEvent in project cubrid-manager by CUBRID.

the class InformationWindow method createContents.

protected Control createContents(Composite parent) {
    final Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new FillLayout());
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    infoText = new StyledText(composite, SWT.None);
    infoText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    infoText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
    infoText.setEditable(false);
    infoText.setEnabled(false);
    infoText.addMouseTrackListener(new MouseTrackListener() {

        public void mouseHover(MouseEvent e) {
            increaseAlpha();
        }

        public void mouseExit(MouseEvent e) {
            reduceAlpha();
        }

        public void mouseEnter(MouseEvent e) {
            increaseAlpha();
        }
    });
    parentShell.addControlListener(new ControlListener() {

        public void controlResized(ControlEvent e) {
            updateLocation();
        }

        public void controlMoved(ControlEvent e) {
            updateLocation();
        }
    });
    if (Platform.getOS().equals(Platform.OS_WIN32)) {
        parentShell.addPaintListener(new PaintListener() {

            public void paintControl(PaintEvent e) {
                updateLocation();
            }
        });
    }
    this.getShell().setAlpha(minAlpha);
    updateLocation();
    return parent;
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) MouseEvent(org.eclipse.swt.events.MouseEvent) PaintEvent(org.eclipse.swt.events.PaintEvent) CombinedQueryEditorComposite(com.cubrid.common.ui.query.control.CombinedQueryEditorComposite) Composite(org.eclipse.swt.widgets.Composite) PaintListener(org.eclipse.swt.events.PaintListener) MouseTrackListener(org.eclipse.swt.events.MouseTrackListener) GridData(org.eclipse.swt.layout.GridData) ControlListener(org.eclipse.swt.events.ControlListener) FillLayout(org.eclipse.swt.layout.FillLayout) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 7 with PaintEvent

use of org.eclipse.swt.events.PaintEvent in project dbeaver by serge-rider.

the class ViewValuePanel method createContents.

@Override
public Control createContents(IResultSetPresentation presentation, Composite parent) {
    this.presentation = presentation;
    viewPlaceholder = new Composite(parent, SWT.NONE);
    viewPlaceholder.setLayout(new FillLayout());
    viewPlaceholder.addPaintListener(new PaintListener() {

        @Override
        public void paintControl(PaintEvent e) {
            if (viewPlaceholder.getChildren().length == 0) {
                String hidePanelCmd = ActionUtils.findCommandDescription(ResultSetCommandHandler.CMD_TOGGLE_PANELS, ViewValuePanel.this.presentation.getController().getSite(), true);
                UIUtils.drawMessageOverControl(viewPlaceholder, e, "Select a cell to view/edit value", 0);
                UIUtils.drawMessageOverControl(viewPlaceholder, e, "Press " + hidePanelCmd + " to hide this panel", 20);
            }
        }
    });
    if (this.presentation instanceof ISelectionProvider) {
        final ISelectionProvider selectionProvider = (ISelectionProvider) this.presentation;
        final ISelectionChangedListener selectionListener = new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                if (ViewValuePanel.this.presentation.getController().getVisiblePanel() == ViewValuePanel.this) {
                    refreshValue(false);
                }
            }
        };
        selectionProvider.addSelectionChangedListener(selectionListener);
        viewPlaceholder.addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent e) {
                selectionProvider.removeSelectionChangedListener(selectionListener);
            }
        });
    }
    return viewPlaceholder;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) PaintEvent(org.eclipse.swt.events.PaintEvent) Composite(org.eclipse.swt.widgets.Composite) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) PaintListener(org.eclipse.swt.events.PaintListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) FillLayout(org.eclipse.swt.layout.FillLayout) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Example 8 with PaintEvent

use of org.eclipse.swt.events.PaintEvent in project translationstudio8 by heartsome.

the class NatCombo method createTextControl.

private void createTextControl() {
    text = new Text(this, HorizontalAlignmentEnum.getSWTStyle(cellStyle));
    text.setBackground(cellStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR));
    text.setForeground(cellStyle.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR));
    text.setFont(cellStyle.getAttributeValue(CellStyleAttributes.FONT));
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    text.setLayoutData(gridData);
    text.forceFocus();
    text.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent event) {
            if (event.keyCode == SWT.ARROW_DOWN || event.keyCode == SWT.ARROW_UP) {
                showDropdownControl();
                int selectionIndex = dropdownList.getSelectionIndex();
                selectionIndex += event.keyCode == SWT.ARROW_DOWN ? 1 : -1;
                if (selectionIndex < 0) {
                    selectionIndex = 0;
                }
                dropdownList.select(selectionIndex);
                text.setText(dropdownList.getSelection()[0]);
            }
        }
    });
    iconImage = GUIHelper.getImage("down_2");
    final Canvas iconCanvas = new Canvas(this, SWT.NONE) {

        @Override
        public Point computeSize(int wHint, int hHint, boolean changed) {
            Rectangle iconImageBounds = iconImage.getBounds();
            return new Point(iconImageBounds.width + 2, iconImageBounds.height + 2);
        }
    };
    gridData = new GridData(GridData.BEGINNING, SWT.FILL, false, true);
    iconCanvas.setLayoutData(gridData);
    iconCanvas.addPaintListener(new PaintListener() {

        public void paintControl(PaintEvent event) {
            GC gc = event.gc;
            Rectangle iconCanvasBounds = iconCanvas.getBounds();
            Rectangle iconImageBounds = iconImage.getBounds();
            int horizontalAlignmentPadding = CellStyleUtil.getHorizontalAlignmentPadding(HorizontalAlignmentEnum.CENTER, iconCanvasBounds, iconImageBounds.width);
            int verticalAlignmentPadding = CellStyleUtil.getVerticalAlignmentPadding(VerticalAlignmentEnum.MIDDLE, iconCanvasBounds, iconImageBounds.height);
            gc.drawImage(iconImage, horizontalAlignmentPadding, verticalAlignmentPadding);
            Color originalFg = gc.getForeground();
            gc.setForeground(GUIHelper.COLOR_WIDGET_BORDER);
            gc.drawRectangle(0, 0, iconCanvasBounds.width - 1, iconCanvasBounds.height - 1);
            gc.setForeground(originalFg);
        }
    });
    iconCanvas.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent e) {
            showDropdownControl();
        }
    });
}
Also used : PaintEvent(org.eclipse.swt.events.PaintEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) PaintListener(org.eclipse.swt.events.PaintListener) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Canvas(org.eclipse.swt.widgets.Canvas) Color(org.eclipse.swt.graphics.Color) Rectangle(org.eclipse.swt.graphics.Rectangle) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) KeyEvent(org.eclipse.swt.events.KeyEvent) GridData(org.eclipse.swt.layout.GridData) GC(org.eclipse.swt.graphics.GC)

Example 9 with PaintEvent

use of org.eclipse.swt.events.PaintEvent in project archi by archimatetool.

the class AboutDialog method createAboutTab.

private void createAboutTab() {
    aboutTabItem = new TabItem(folder, SWT.NONE);
    aboutTabItem.setText(Messages.AboutDialog_1);
    Composite control = new Composite(folder, SWT.NONE);
    control.setLayout(new GridLayout());
    aboutTabItem.setControl(control);
    Composite imageControl = new Composite(control, SWT.NO_BACKGROUND);
    GridData gd = new GridData(GridData.CENTER, GridData.CENTER, true, true);
    imageControl.setLayoutData(gd);
    final int imageHeight;
    // $NON-NLS-1$
    final Image image = IArchiImages.ImageFactory.getImage("splash.bmp");
    if (image != null) {
        ImageData id = image.getImageData();
        gd.widthHint = id.width;
        gd.heightHint = id.height;
        imageHeight = id.height;
    } else {
        gd.widthHint = 500;
        gd.heightHint = 300;
        imageHeight = 300;
    }
    final String version = Messages.AboutDialog_2 + System.getProperty(Application.APPLICATION_VERSIONID);
    final String build = Messages.AboutDialog_3 + System.getProperty(Application.APPLICATION_BUILDID);
    // $NON-NLS-1$
    final String copyright = ArchiPlugin.INSTANCE.getResourceString("%aboutCopyright");
    imageControl.addPaintListener(new PaintListener() {

        public void paintControl(PaintEvent e) {
            int fontHeight = e.gc.getFontMetrics().getHeight() + 2;
            e.gc.drawImage(image, 0, 0);
            e.gc.drawString(version, 19, 166, true);
            e.gc.drawString(build, 19, 166 + fontHeight, true);
            e.gc.drawString(copyright, 12, imageHeight - fontHeight - 5, true);
        }
    });
}
Also used : TabItem(org.eclipse.swt.widgets.TabItem) GridLayout(org.eclipse.swt.layout.GridLayout) PaintEvent(org.eclipse.swt.events.PaintEvent) Composite(org.eclipse.swt.widgets.Composite) PaintListener(org.eclipse.swt.events.PaintListener) ImageData(org.eclipse.swt.graphics.ImageData) GridData(org.eclipse.swt.layout.GridData) Image(org.eclipse.swt.graphics.Image)

Example 10 with PaintEvent

use of org.eclipse.swt.events.PaintEvent in project eclipse.platform.text by eclipse.

the class OverviewRuler method createControl.

@Override
public Control createControl(Composite parent, ITextViewer textViewer) {
    fTextViewer = textViewer;
    fHitDetectionCursor = parent.getDisplay().getSystemCursor(SWT.CURSOR_HAND);
    fHeader = new Canvas(parent, SWT.NONE);
    if (fAnnotationAccess instanceof IAnnotationAccessExtension) {
        fHeader.addMouseTrackListener(new MouseTrackAdapter() {

            /*
				 * @see org.eclipse.swt.events.MouseTrackAdapter#mouseHover(org.eclipse.swt.events.MouseEvent)
				 * @since 3.3
				 */
            @Override
            public void mouseEnter(MouseEvent e) {
                updateHeaderToolTipText();
            }
        });
    }
    fCanvas = new Canvas(parent, SWT.NO_BACKGROUND);
    fCanvas.addPaintListener(new PaintListener() {

        @Override
        public void paintControl(PaintEvent event) {
            if (fTextViewer != null)
                doubleBufferPaint(event.gc);
        }
    });
    fCanvas.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent event) {
            handleDispose();
            fTextViewer = null;
        }
    });
    fCanvas.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent event) {
            handleMouseDown(event);
        }
    });
    fCanvas.addMouseMoveListener(new MouseMoveListener() {

        @Override
        public void mouseMove(MouseEvent event) {
            handleMouseMove(event);
        }
    });
    fCanvas.addMouseWheelListener(new MouseWheelListener() {

        @Override
        public void mouseScrolled(MouseEvent e) {
            handleMouseScrolled(e);
        }
    });
    if (fTextViewer != null) {
        fTextViewer.addTextListener(fInternalListener);
        // on word wrap toggle a "resized" ControlEvent is fired: suggest a redraw of the ruler
        fTextViewer.getTextWidget().addControlListener(new ControlAdapter() {

            @Override
            public void controlResized(ControlEvent e) {
                if (fTextViewer == null) {
                    return;
                }
                StyledText textWidget = fTextViewer.getTextWidget();
                if (textWidget != null && textWidget.getWordWrap()) {
                    redraw();
                }
            }
        });
    }
    return fCanvas;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) MouseEvent(org.eclipse.swt.events.MouseEvent) PaintEvent(org.eclipse.swt.events.PaintEvent) StyledText(org.eclipse.swt.custom.StyledText) ControlAdapter(org.eclipse.swt.events.ControlAdapter) PaintListener(org.eclipse.swt.events.PaintListener) Canvas(org.eclipse.swt.widgets.Canvas) MouseTrackAdapter(org.eclipse.swt.events.MouseTrackAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) MouseWheelListener(org.eclipse.swt.events.MouseWheelListener) DisposeEvent(org.eclipse.swt.events.DisposeEvent) MouseMoveListener(org.eclipse.swt.events.MouseMoveListener) ControlEvent(org.eclipse.swt.events.ControlEvent)

Aggregations

PaintEvent (org.eclipse.swt.events.PaintEvent)92 PaintListener (org.eclipse.swt.events.PaintListener)88 Canvas (org.eclipse.swt.widgets.Canvas)32 Composite (org.eclipse.swt.widgets.Composite)30 MouseEvent (org.eclipse.swt.events.MouseEvent)28 GridData (org.eclipse.swt.layout.GridData)26 Rectangle (org.eclipse.swt.graphics.Rectangle)25 Point (org.eclipse.swt.graphics.Point)23 GridLayout (org.eclipse.swt.layout.GridLayout)22 DisposeEvent (org.eclipse.swt.events.DisposeEvent)17 SelectionEvent (org.eclipse.swt.events.SelectionEvent)17 MouseAdapter (org.eclipse.swt.events.MouseAdapter)15 DisposeListener (org.eclipse.swt.events.DisposeListener)14 FillLayout (org.eclipse.swt.layout.FillLayout)14 ControlEvent (org.eclipse.swt.events.ControlEvent)13 Control (org.eclipse.swt.widgets.Control)13 Event (org.eclipse.swt.widgets.Event)13 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)12 GC (org.eclipse.swt.graphics.GC)11 Label (org.eclipse.swt.widgets.Label)10