Search in sources :

Example 21 with ScrollBar

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

the class CTable method onArrowLeft.

void onArrowLeft(int stateMask) {
    if (horizontalOffset == 0)
        return;
    int newSelection = Math.max(0, horizontalOffset - SIZE_HORIZONTALSCROLL);
    update();
    GC gc = new GC(this);
    gc.copyArea(0, 0, clientArea.width, clientArea.height, horizontalOffset - newSelection, 0);
    gc.dispose();
    if (header.getVisible()) {
        header.update();
        Rectangle headerClientArea = header.getClientArea();
        gc = new GC(header);
        gc.copyArea(0, 0, headerClientArea.width, headerClientArea.height, horizontalOffset - newSelection, 0);
        gc.dispose();
    }
    horizontalOffset = newSelection;
    ScrollBar hBar = getHorizontalBar();
    if (hBar != null)
        hBar.setSelection(horizontalOffset);
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle) GC(org.eclipse.swt.graphics.GC) Point(org.eclipse.swt.graphics.Point) ScrollBar(org.eclipse.swt.widgets.ScrollBar)

Example 22 with ScrollBar

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

the class CTable method destroyItem.

/*
 * Allows the Table to update internal structures it has that may contain the
 * item being destroyed.
 */
void destroyItem(CTableItem item) {
    if (item == focusItem)
        reassignFocus();
    int index = item.index;
    Rectangle bounds = item.getBounds(false);
    int rightX = bounds.x + bounds.width;
    if (index != itemsCount - 1) {
        /* item is not at end of items list, so must shift items left to reclaim its slot */
        System.arraycopy(items, index + 1, items, index, itemsCount - index - 1);
        items[itemsCount - 1] = null;
    } else {
        items[index] = null;
    /* last item, so no array copy needed */
    }
    itemsCount--;
    if (drawCount <= 0 && items.length - itemsCount == 4) {
        /* shrink the items array */
        CTableItem[] newItems = new CTableItem[itemsCount];
        System.arraycopy(items, 0, newItems, 0, newItems.length);
        items = newItems;
    }
    /* update the index on affected items */
    for (int i = index; i < itemsCount; i++) {
        items[i].index = i;
    }
    item.index = -1;
    int oldTopIndex = topIndex;
    updateVerticalBar();
    updateHorizontalBar(0, -rightX);
    /*
	 * If destroyed item is above viewport then adjust topIndex and the vertical
	 * scrollbar so that the current viewport items will not change.
	 */
    if (index < topIndex) {
        topIndex = oldTopIndex - 1;
        ScrollBar vBar = getVerticalBar();
        if (vBar != null)
            vBar.setSelection(topIndex);
    }
    /* selectedItems array */
    if (item.isSelected()) {
        int selectionIndex = getSelectionIndex(item);
        CTableItem[] newSelectedItems = new CTableItem[selectedItems.length - 1];
        System.arraycopy(selectedItems, 0, newSelectedItems, 0, selectionIndex);
        System.arraycopy(selectedItems, selectionIndex + 1, newSelectedItems, selectionIndex, newSelectedItems.length - selectionIndex);
        selectedItems = newSelectedItems;
    }
    if (item == anchorItem)
        anchorItem = null;
    if (item == lastClickedItem)
        lastClickedItem = null;
    /*
	 * If this was the last item and the receiver has focus then its boundary
	 * focus ring must be redrawn.
	 */
    if (itemsCount == 0 && isFocusControl()) {
        redraw();
    }
    int[] eventData = new int[5];
    eventData[0] = ACC.DELETE;
    eventData[1] = index;
    eventData[2] = 1;
    eventData[3] = 0;
    eventData[4] = 0;
    getAccessible().sendEvent(ACC.EVENT_TABLE_CHANGED, eventData);
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) ScrollBar(org.eclipse.swt.widgets.ScrollBar)

Example 23 with ScrollBar

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

the class CTable method setTopIndex.

/**
 * Sets the zero-relative index of the item which is currently
 * at the top of the receiver. This index can change when items
 * are scrolled or new items are added and removed.
 *
 * @param index the index of the top item
 *
 * @exception SWTException <ul>
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
 * </ul>
 */
public void setTopIndex(int index) {
    checkWidget();
    if (!(0 <= index && index < itemsCount))
        return;
    int visibleItemCount = (clientArea.height - getHeaderHeight()) / itemHeight;
    if (itemsCount <= visibleItemCount)
        return;
    index = Math.min(index, itemsCount - visibleItemCount);
    if (index == topIndex)
        return;
    update();
    int change = topIndex - index;
    topIndex = index;
    ScrollBar vBar = getVerticalBar();
    if (vBar != null)
        vBar.setSelection(topIndex);
    if (drawCount <= 0) {
        GC gc = new GC(this);
        gc.copyArea(0, 0, clientArea.width, clientArea.height, 0, change * itemHeight);
        gc.dispose();
    }
}
Also used : GC(org.eclipse.swt.graphics.GC) Point(org.eclipse.swt.graphics.Point) ScrollBar(org.eclipse.swt.widgets.ScrollBar)

Example 24 with ScrollBar

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

the class ScrollBarHandlerTemplate method handleEvent.

public void handleEvent(Event event) {
    ScrollBar scrollBar = (ScrollBar) event.widget;
    int position = getPositionByPixel(scrollBar.getSelection());
    setViewportOrigin(position);
}
Also used : ScrollBar(org.eclipse.swt.widgets.ScrollBar)

Example 25 with ScrollBar

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

the class PlainTextPresentation method createPresentation.

@Override
public void createPresentation(@NotNull final IResultSetController controller, @NotNull Composite parent) {
    super.createPresentation(controller, parent);
    UIUtils.createHorizontalLine(parent);
    text = new StyledText(parent, SWT.READ_ONLY | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    text.setBlockSelection(true);
    text.setCursor(parent.getDisplay().getSystemCursor(SWT.CURSOR_IBEAM));
    text.setMargins(4, 4, 4, 4);
    text.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
    text.setLayoutData(new GridData(GridData.FILL_BOTH));
    text.addCaretListener(new CaretListener() {

        @Override
        public void caretMoved(CaretEvent event) {
            onCursorChange(event.caretOffset);
        }
    });
    text.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            curSelection = text.getSelectionText();
            fireSelectionChanged(new PlainTextSelectionImpl());
        }
    });
    final ScrollBar verticalBar = text.getVerticalBar();
    verticalBar.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (verticalBar.getSelection() + verticalBar.getPageIncrement() >= verticalBar.getMaximum()) {
                if (controller.getPreferenceStore().getBoolean(DBeaverPreferences.RESULT_SET_AUTO_FETCH_NEXT_SEGMENT) && !controller.isRecordMode() && controller.isHasMoreData()) {
                    controller.readNextSegment();
                }
            }
        }
    });
    findReplaceTarget = new StyledTextFindReplaceTarget(text);
    UIUtils.enableHostEditorKeyBindingsSupport(controller.getSite(), text);
    applyThemeSettings();
    registerContextMenu();
    trackPresentationControl();
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) StyledTextFindReplaceTarget(org.jkiss.dbeaver.ui.controls.StyledTextFindReplaceTarget) ScrollBar(org.eclipse.swt.widgets.ScrollBar)

Aggregations

ScrollBar (org.eclipse.swt.widgets.ScrollBar)50 Point (org.eclipse.swt.graphics.Point)32 Rectangle (org.eclipse.swt.graphics.Rectangle)20 GC (org.eclipse.swt.graphics.GC)14 Event (org.eclipse.swt.widgets.Event)11 SelectionEvent (org.eclipse.swt.events.SelectionEvent)9 GridData (org.eclipse.swt.layout.GridData)7 Listener (org.eclipse.swt.widgets.Listener)7 Composite (org.eclipse.swt.widgets.Composite)6 SWT (org.eclipse.swt.SWT)5 Font (org.eclipse.swt.graphics.Font)5 GridLayout (org.eclipse.swt.layout.GridLayout)5 Button (org.eclipse.swt.widgets.Button)5 AccessibleControlEvent (org.eclipse.swt.accessibility.AccessibleControlEvent)4 AccessibleEvent (org.eclipse.swt.accessibility.AccessibleEvent)4 AccessibleTableEvent (org.eclipse.swt.accessibility.AccessibleTableEvent)4 ControlListener (org.eclipse.swt.events.ControlListener)4 Color (org.eclipse.swt.graphics.Color)4 ClientAreaResizeCommand (net.sourceforge.nattable.grid.command.ClientAreaResizeCommand)3 SelectionListener (org.eclipse.swt.events.SelectionListener)3