Search in sources :

Example 76 with ScrollBar

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

the class PlainTextPresentation method performHorizontalScroll.

@Override
protected void performHorizontalScroll(int scrollCount) {
    ScrollBar hsb = text.getHorizontalBar();
    if (hsb != null && hsb.isVisible()) {
        int curPosition = text.getHorizontalPixel();
        int pageIncrement = UIUtils.getFontHeight(text.getFont()) * 10;
        if (scrollCount > 0) {
            if (curPosition > 0) {
                curPosition -= pageIncrement;
            }
        } else {
            curPosition += pageIncrement;
        }
        if (curPosition < 0)
            curPosition = 0;
        text.setHorizontalPixel(curPosition);
    // text.setHorizontalIndex();
    }
}
Also used : ScrollBar(org.eclipse.swt.widgets.ScrollBar)

Example 77 with ScrollBar

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

the class StatisticsNavigatorNodeRenderer method getActionButtonFor.

private INavigatorNodeActionHandler getActionButtonFor(DBNNode element, Tree tree, Event event) {
    List<INavigatorNodeActionHandler> nodeActions = NavigatorExtensionsRegistry.getInstance().getNodeActions(getView(), element);
    ScrollBar horizontalScrollBar = tree.getHorizontalBar();
    if (horizontalScrollBar != null && horizontalScrollBar.isVisible()) {
        return null;
    }
    int widthOccupied = 0;
    for (INavigatorNodeActionHandler nah : nodeActions) {
        if (!nah.isSticky(view, element)) {
            // Non-sticky buttons are active only for selected or hovered items
            boolean isSelected = (event.stateMask & SWT.SELECTED) != 0;
            boolean isHover = false;
            if (!isSelected && !isHover) {
                return null;
            }
        }
        // Margin
        widthOccupied += 2;
        DBPImage icon = nah.getNodeActionIcon(getView(), element);
        if (icon != null) {
            Image image = DBeaverIcons.getImage(icon);
            Rectangle imageBounds = image.getBounds();
            int imageSize = imageBounds.height;
            widthOccupied += imageSize;
            if (event.x > tree.getClientArea().width - widthOccupied) {
                return nah;
            }
        }
    }
    return null;
}
Also used : INavigatorNodeActionHandler(org.jkiss.dbeaver.ui.navigator.INavigatorNodeActionHandler) ScrollBar(org.eclipse.swt.widgets.ScrollBar)

Example 78 with ScrollBar

use of org.eclipse.swt.widgets.ScrollBar in project dbeaver by dbeaver.

the class ImageViewCanvas method initScrollBars.

/* Initalize the scrollbar and register listeners. */
private void initScrollBars() {
    ScrollBar horizontal = getHorizontalBar();
    horizontal.setEnabled(false);
    horizontal.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            scrollHorizontally((ScrollBar) event.widget);
        }
    });
    ScrollBar vertical = getVerticalBar();
    vertical.setEnabled(false);
    vertical.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            scrollVertically((ScrollBar) event.widget);
        }
    });
}
Also used : ScrollBar(org.eclipse.swt.widgets.ScrollBar)

Example 79 with ScrollBar

use of org.eclipse.swt.widgets.ScrollBar in project dbeaver by dbeaver.

the class PlainTextPresentation method performHorizontalScroll.

@Override
protected void performHorizontalScroll(int scrollCount) {
    ScrollBar hsb = text.getHorizontalBar();
    if (hsb != null && hsb.isVisible()) {
        int curPosition = text.getHorizontalPixel();
        int pageIncrement = UIUtils.getFontHeight(text.getFont()) * 10;
        if (scrollCount > 0) {
            if (curPosition > 0) {
                curPosition -= pageIncrement;
            }
        } else {
            curPosition += pageIncrement;
        }
        if (curPosition < 0)
            curPosition = 0;
        text.setHorizontalPixel(curPosition);
    // text.setHorizontalIndex();
    }
}
Also used : ScrollBar(org.eclipse.swt.widgets.ScrollBar)

Example 80 with ScrollBar

use of org.eclipse.swt.widgets.ScrollBar in project dbeaver by dbeaver.

the class StatisticsNavigatorNodeRenderer method getTreeWidth.

// /////////////////////////////////////////////////////////////////
// Utils
private int getTreeWidth(Tree tree) {
    int treeWidth;
    int xShift;
    ScrollBar hSB = tree.getHorizontalBar();
    if (hSB == null || !hSB.isVisible()) {
        treeWidth = tree.getClientArea().width;
        xShift = 0;
    } else {
        treeWidth = hSB.getMaximum();
        xShift = hSB.getSelection();
    }
    return treeWidth - xShift;
}
Also used : ScrollBar(org.eclipse.swt.widgets.ScrollBar)

Aggregations

ScrollBar (org.eclipse.swt.widgets.ScrollBar)84 Point (org.eclipse.swt.graphics.Point)39 Rectangle (org.eclipse.swt.graphics.Rectangle)25 SelectionEvent (org.eclipse.swt.events.SelectionEvent)18 GC (org.eclipse.swt.graphics.GC)14 GridData (org.eclipse.swt.layout.GridData)12 Event (org.eclipse.swt.widgets.Event)12 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)11 Composite (org.eclipse.swt.widgets.Composite)8 GridLayout (org.eclipse.swt.layout.GridLayout)7 Listener (org.eclipse.swt.widgets.Listener)7 StyledText (org.eclipse.swt.custom.StyledText)6 Button (org.eclipse.swt.widgets.Button)6 Label (org.eclipse.swt.widgets.Label)6 SWT (org.eclipse.swt.SWT)5 ControlListener (org.eclipse.swt.events.ControlListener)5 SelectionListener (org.eclipse.swt.events.SelectionListener)5 Font (org.eclipse.swt.graphics.Font)5 Text (org.eclipse.swt.widgets.Text)5 AffineTransform (java.awt.geom.AffineTransform)4