Java 类org.eclipse.swt.widgets.ScrollBar 实例源码

项目:TuxGuitar-1.3.1-fork    文件:TGChordList.java   
public void updateScroll(){
    Rectangle rect = this.composite.getBounds();
    Rectangle client = this.composite.getClientArea();
    ScrollBar vBar = this.composite.getVerticalBar();
    vBar.setMaximum(Math.round(this.height));
    vBar.setThumb(Math.min(rect.height, client.height));
}
项目:Black    文件:blackAction.java   
public void setSlider(Slider slider) {
    if (b.text != null && !b.text.isDisposed()) {
        sliderListener = new Listener() {

            @Override
            public void handleEvent(Event arg0) {
                // TODO Auto-generated method stub
                if (slider != null && !slider.isDisposed()) {
                    ScrollBar vb = b.text.getVerticalBar();
                    slider.setValues(vb.getSelection(), vb.getMinimum(), vb.getMaximum(), vb.getThumb(),
                            vb.getIncrement(), vb.getPageIncrement());
                }
            }
        };
        b.text.addListener(SWT.Paint, sliderListener);
    }
}
项目:TranskribusSwtGui    文件:MyContentProposalAdapter.java   
void installListeners() {
    // Listeners on this popup's table and scroll bar
    proposalTable.addListener(SWT.FocusOut, this);
    ScrollBar scrollbar = proposalTable.getVerticalBar();
    if (scrollbar != null) {
        scrollbar.addListener(SWT.Selection, this);
    }

    // Listeners on this popup's shell
    getShell().addListener(SWT.Deactivate, this);
    getShell().addListener(SWT.Close, this);

    // Listeners on the target control
    control.addListener(SWT.MouseDoubleClick, this);
    control.addListener(SWT.MouseDown, this);
    control.addListener(SWT.Dispose, this);
    control.addListener(SWT.FocusOut, this);
    // Listeners on the target control's shell
    Shell controlShell = control.getShell();
    controlShell.addListener(SWT.Move, this);
    controlShell.addListener(SWT.Resize, this);

}
项目:TranskribusSwtGui    文件:MyContentProposalAdapter.java   
void removeListeners() {
    if (isValid()) {
        proposalTable.removeListener(SWT.FocusOut, this);
        ScrollBar scrollbar = proposalTable.getVerticalBar();
        if (scrollbar != null) {
            scrollbar.removeListener(SWT.Selection, this);
        }

        getShell().removeListener(SWT.Deactivate, this);
        getShell().removeListener(SWT.Close, this);
    }

    if (control != null && !control.isDisposed()) {

        control.removeListener(SWT.MouseDoubleClick, this);
        control.removeListener(SWT.MouseDown, this);
        control.removeListener(SWT.Dispose, this);
        control.removeListener(SWT.FocusOut, this);

        Shell controlShell = control.getShell();
        controlShell.removeListener(SWT.Move, this);
        controlShell.removeListener(SWT.Resize, this);
    }
}
项目:code    文件:ImageAnalyzer.java   
void scrollHorizontally(ScrollBar scrollBar) {
    if (image == null) {
        return;
    }
    Rectangle canvasBounds = imageCanvas.getClientArea();
    int width = Math.round(imageData.width * xscale);
    int height = Math.round(imageData.height * yscale);
    if (width > canvasBounds.width) {
        // Only scroll if the image is bigger than the canvas.
        int x = -scrollBar.getSelection();
        if (x + width < canvasBounds.width) {
            // Don't scroll past the end of the image.
            x = canvasBounds.width - width;
        }
        imageCanvas.scroll(x, iy, ix, iy, width, height, false);
        ix = x;
    }
}
项目:code    文件:ImageAnalyzer.java   
void scrollVertically(ScrollBar scrollBar) {
    if (image == null) {
        return;
    }
    Rectangle canvasBounds = imageCanvas.getClientArea();
    int width = Math.round(imageData.width * xscale);
    int height = Math.round(imageData.height * yscale);
    if (height > canvasBounds.height) {
        // Only scroll if the image is bigger than the canvas.
        int y = -scrollBar.getSelection();
        if (y + height < canvasBounds.height) {
            // Don't scroll past the end of the image.
            y = canvasBounds.height - height;
        }
        imageCanvas.scroll(ix, y, ix, iy, width, height, false);
        iy = y;
    }
}
项目:code    文件:ImageAnalyzer.java   
void scrollHorizontally(ScrollBar scrollBar) {
    if (image == null) {
        return;
    }
    Rectangle canvasBounds = imageCanvas.getClientArea();
    int width = Math.round(imageData.width * xscale);
    int height = Math.round(imageData.height * yscale);
    if (width > canvasBounds.width) {
        // Only scroll if the image is bigger than the canvas.
        int x = -scrollBar.getSelection();
        if (x + width < canvasBounds.width) {
            // Don't scroll past the end of the image.
            x = canvasBounds.width - width;
        }
        imageCanvas.scroll(x, iy, ix, iy, width, height, false);
        ix = x;
    }
}
项目:code    文件:ImageAnalyzer.java   
void scrollVertically(ScrollBar scrollBar) {
    if (image == null) {
        return;
    }
    Rectangle canvasBounds = imageCanvas.getClientArea();
    int width = Math.round(imageData.width * xscale);
    int height = Math.round(imageData.height * yscale);
    if (height > canvasBounds.height) {
        // Only scroll if the image is bigger than the canvas.
        int y = -scrollBar.getSelection();
        if (y + height < canvasBounds.height) {
            // Don't scroll past the end of the image.
            y = canvasBounds.height - height;
        }
        imageCanvas.scroll(ix, y, ix, iy, width, height, false);
        iy = y;
    }
}
项目:bts    文件:ColumnLayout.java   
private int computeTrim(Rectangle area, Table table, int tableWidth) {
    Point preferredSize= computeTableSize(table, area.width, area.height);
       int trim;
       if (tableWidth > 1) {
        trim= tableWidth - table.getClientArea().width;
       } else {
        // initially, the table has no extend and no client area - use the border with
        // plus some padding as educated guess
        trim= 2 * table.getBorderWidth() + 1 ;
       }
       if (preferredSize.y > area.height) {
           // Subtract the scrollbar width from the total column width
           // if a vertical scrollbar will be required, but is not currently showing
        // (in which case it is already subtracted above)
           ScrollBar vBar= table.getVerticalBar();
           if (!vBar.isVisible()) {
            Point vBarSize= vBar.getSize();
            trim += vBarSize.x;
           }
       }
    return trim;
}
项目:bts    文件:SWTUtil.java   
/**
 * Returns the shell for the given widget. If the widget doesn't represent a
 * SWT object that manage a shell, <code>null</code> is returned.
 * 
 * @param widget
 *            the widget
 * 
 * @return the shell for the given widget
 */
public static Shell getShell(Widget widget) {
    if (widget instanceof Control)
        return ((Control) widget).getShell();
    if (widget instanceof Caret)
        return ((Caret) widget).getParent().getShell();
    if (widget instanceof DragSource)
        return ((DragSource) widget).getControl().getShell();
    if (widget instanceof DropTarget)
        return ((DropTarget) widget).getControl().getShell();
    if (widget instanceof Menu)
        return ((Menu) widget).getParent().getShell();
    if (widget instanceof ScrollBar)
        return ((ScrollBar) widget).getParent().getShell();

    return null;
}
项目:raptor-chess-interface    文件:ChatConsoleController.java   
protected void smartScroll(boolean force) {
    ScrollBar scrollbar = chatConsole.inputText.getVerticalBar();
    if (scrollbar != null
            && scrollbar.isVisible()
            && getPreferences().getBoolean(
                    PreferenceKeys.CHAT_IS_SMART_SCROLL_ENABLED)) {

        if (force) {
            setAutoScrolling(true);
        }
        else if (scrollbar.getMaximum() == scrollbar.getSelection()
                + scrollbar.getThumb()) {
            setAutoScrolling(true);
        } else {
            setAutoScrolling(false);
        }
    }
}
项目:gama    文件:ParameterExpandBar.java   
void setScrollbar() {
    if (itemCount == 0) { return; }
    final ScrollBar verticalBar = getVerticalBar();
    if (verticalBar == null) { return; }
    final int height = getClientArea().height;
    final ParameterExpandItem item = items[itemCount - 1];
    int maxHeight = item.y + bandHeight + spacing;
    if (item.expanded) {
        maxHeight += item.height;
    }

    // claim bottom free space
    if (yCurrentScroll > 0 && height > maxHeight) {
        yCurrentScroll = Math.max(0, yCurrentScroll + maxHeight - height);
        layoutItems(0, false);
    }
    maxHeight += yCurrentScroll;

    final int selection = Math.min(yCurrentScroll, maxHeight);
    final int increment = verticalBar.getIncrement();
    final int pageIncrement = verticalBar.getPageIncrement();
    verticalBar.setValues(selection, 0, maxHeight, height, increment, pageIncrement);
    verticalBar.setVisible(maxHeight > height);
}
项目:jGrid    文件:GridKeyboardHandler.java   
private void pageUp() {
    //
    // Ensure there's an anchor.
    //
    ensureAnchorSet();

    //
    // Move the scrollbar down one page.
    //
    final ScrollBar verticalBar = grid.getVerticalBar();
    verticalBar.setSelection(Math.max(verticalBar.getSelection() - verticalBar.getPageIncrement(), verticalBar.getMinimum()));

    //
    // Cause a repaint.
    //
    gridModel.fireChangeEvent();

    //
    // Move the anchor to the new page.
    //
    if (verticalBar.getSelection() != verticalBar.getMaximum()) {
        final Row<T> row = gridModel.getRows().get(grid.getViewport().getFirstRowIndex());
        gridModel.getSelectionModel().setAnchorElement(row.getElement());
    }
}
项目:jGrid    文件:GridKeyboardHandler.java   
private void pageDown() {
    //
    // Ensure there's an anchor.
    //
    ensureAnchorSet();

    //
    // Move the scrollbar down one page.
    //
    final ScrollBar verticalBar = grid.getVerticalBar();
    verticalBar.setSelection(Math.min(verticalBar.getSelection() + verticalBar.getPageIncrement(), verticalBar.getMaximum()));

    //
    // Cause a repaint.
    //
    gridModel.fireChangeEvent();

    //
    // Move the anchor to the new page.
    //
    if (verticalBar.getSelection() != verticalBar.getMaximum()) {
        final Row<T> row = gridModel.getRows().get(grid.getViewport().getFirstRowIndex());
        gridModel.getSelectionModel().setAnchorElement(row.getElement());
    }
}
项目:APICloud-Studio    文件:SWTUtil.java   
/**
 * Returns the shell for the given widget. If the widget doesn't represent a SWT object that manage a shell,
 * <code>null</code> is returned.
 * 
 * @return the shell for the given widget
 */
public static Shell getShell(Widget widget)
{
    if (widget instanceof Control)
        return ((Control) widget).getShell();
    if (widget instanceof Caret)
        return ((Caret) widget).getParent().getShell();
    if (widget instanceof DragSource)
        return ((DragSource) widget).getControl().getShell();
    if (widget instanceof DropTarget)
        return ((DropTarget) widget).getControl().getShell();
    if (widget instanceof Menu)
        return ((Menu) widget).getParent().getShell();
    if (widget instanceof ScrollBar)
        return ((ScrollBar) widget).getParent().getShell();

    return null;
}
项目:APICloud-Studio    文件:ConsoleAutoScrollPageParticipant.java   
public void dispose()
{
    if (textWidget != null && !textWidget.isDisposed())
    {
        textWidget.removeListener(SWT.MouseDown, listener);
        textWidget.removeListener(SWT.MouseMove, listener);
        textWidget.removeListener(SWT.MouseUp, listener);
        textWidget.removeListener(SWT.KeyDown, listener);
        textWidget.removeListener(SWT.KeyUp, listener);
        textWidget.removeListener(SWT.Resize, listener);
        ScrollBar vBar = textWidget.getVerticalBar();
        if (vBar != null && !vBar.isDisposed())
        {
            vBar.removeListener(SWT.Selection, listener);
        }
    }
    textWidget = null;
    listener = null;
}
项目:Eclipse-Postfix-Code-Completion    文件:MethodsViewer.java   
/**
 * Restores the state of the filter actions
 * @param memento the memento
 */
public void restoreState(IMemento memento) {
    fMemberFilterActionGroup.restoreState(memento);
    getControl().setRedraw(false);
    refresh();
    getControl().setRedraw(true);

    boolean showInherited= Boolean.valueOf(memento.getString(TAG_SHOWINHERITED)).booleanValue();
    showInheritedMethods(showInherited);

    boolean showDefiningTypes= Boolean.valueOf(memento.getString(TAG_SORTBYDEFININGTYPE)).booleanValue();
    sortByDefiningType(showDefiningTypes);

    ScrollBar bar= getTable().getVerticalBar();
    if (bar != null) {
        Integer vScroll= memento.getInteger(TAG_VERTICAL_SCROLL);
        if (vScroll != null) {
            bar.setSelection(vScroll.intValue());
        }
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:SWTUtil.java   
/**
 * Returns the shell for the given widget. If the widget doesn't represent
 * a SWT object that manage a shell, <code>null</code> is returned.
 * @param widget the widget
 *
 * @return the shell for the given widget
 */
public static Shell getShell(Widget widget) {
    if (widget instanceof Control)
        return ((Control)widget).getShell();
    if (widget instanceof Caret)
        return ((Caret)widget).getParent().getShell();
    if (widget instanceof DragSource)
        return ((DragSource)widget).getControl().getShell();
    if (widget instanceof DropTarget)
        return ((DropTarget)widget).getControl().getShell();
    if (widget instanceof Menu)
        return ((Menu)widget).getParent().getShell();
    if (widget instanceof ScrollBar)
        return ((ScrollBar)widget).getParent().getShell();

    return null;
}
项目:translationstudio8    文件:JaretTable.java   
/**
 * Update the horiontal scrollbar.
 */
private void updateXScrollBar() {
    if (Display.getCurrent() != null) {
        Display.getCurrent().syncExec(new Runnable() {
            public void run() {
                ScrollBar scroll = getHorizontalBar();
                // scroll may be null
                if (scroll != null) {
                    _oldHorizontalScroll = -1; // make sure no optimization will be applied
                    scroll.setMinimum(0);
                    scroll.setMaximum(getTotalWidth() - getFixedColumnsWidth());
                    scroll.setThumb(getWidth() - getFixedColumnsWidth());
                    scroll.setIncrement(50); // increment for arrows
                    scroll.setPageIncrement(getWidth()); // page increment areas
                }
            }
        });
    }
}
项目:translationstudio8    文件:JaretTable.java   
/**
 * Update the vertical scrollbar if present.
 */
public void updateYScrollBar() {
    if (Display.getCurrent() != null) {
        Display.getCurrent().syncExec(new Runnable() {
            public void run() {
                ScrollBar scroll = getVerticalBar();
                // scroll may be null
                if (scroll != null) {
                    _oldVerticalScroll = -1; // guarantee a clean repaint
                    scroll.setMinimum(0);
                    scroll.setMaximum(getTotalHeight() - getFixedRowsHeight());
                    int height = getHeight();
                    if (_tableRect != null) {
                        height = _tableRect.height;
                    }
                    scroll.setThumb(height); // - getFixedRowsHeight() - getHeaderHeight());
                    scroll.setIncrement(50); // increment for arrows
                    scroll.setPageIncrement(getHeight()); // page increment areas
                    scroll.setSelection(getAbsBeginYForRowIdx(_firstRowIdx) + _firstRowPixelOffset
                            + getFixedRowsHeight());
                }
            }
        });
    }
}
项目:gef-gwt    文件:ContentProposalAdapter.java   
void installListeners() {
    // Listeners on this popup's table and scroll bar
    proposalTable.addListener(SWT.FocusOut, this);
    ScrollBar scrollbar = proposalTable.getVerticalBar();
    if (scrollbar != null) {
        scrollbar.addListener(SWT.Selection, this);
    }

    // Listeners on this popup's shell
    getShell().addListener(SWT.Deactivate, this);
    getShell().addListener(SWT.Close, this);

    // Listeners on the target control
    control.addListener(SWT.MouseDoubleClick, this);
    control.addListener(SWT.MouseDown, this);
    control.addListener(SWT.Dispose, this);
    control.addListener(SWT.FocusOut, this);
    // Listeners on the target control's shell
    Shell controlShell = control.getShell();
    controlShell.addListener(SWT.Move, this);
    controlShell.addListener(SWT.Resize, this);

}
项目:gef-gwt    文件:ContentProposalAdapter.java   
void removeListeners() {
    if (isValid()) {
        proposalTable.removeListener(SWT.FocusOut, this);
        ScrollBar scrollbar = proposalTable.getVerticalBar();
        if (scrollbar != null) {
            scrollbar.removeListener(SWT.Selection, this);
        }

        getShell().removeListener(SWT.Deactivate, this);
        getShell().removeListener(SWT.Close, this);
    }

    if (control != null && !control.isDisposed()) {

        control.removeListener(SWT.MouseDoubleClick, this);
        control.removeListener(SWT.MouseDown, this);
        control.removeListener(SWT.Dispose, this);
        control.removeListener(SWT.FocusOut, this);

        Shell controlShell = control.getShell();
        controlShell.removeListener(SWT.Move, this);
        controlShell.removeListener(SWT.Resize, this);
    }
}
项目:gef-gwt    文件:ScrolledComposite.java   
boolean needHScroll(Rectangle contentRect, boolean vVisible) {
    ScrollBar hBar = getHorizontalBar();
    if (hBar == null)
        return false;

    Rectangle hostRect = getBounds();
    int border = getBorderWidth();
    hostRect.width -= 2 * border;
    ScrollBar vBar = getVerticalBar();
    if (vVisible && vBar != null)
        hostRect.width -= vBar.getSize().x;

    if (!expandHorizontal && contentRect.width > hostRect.width)
        return true;
    if (expandHorizontal && minWidth > hostRect.width)
        return true;
    return false;
}
项目:gef-gwt    文件:ScrolledComposite.java   
boolean needVScroll(Rectangle contentRect, boolean hVisible) {
    ScrollBar vBar = getVerticalBar();
    if (vBar == null)
        return false;

    Rectangle hostRect = getBounds();
    int border = getBorderWidth();
    hostRect.height -= 2 * border;
    ScrollBar hBar = getHorizontalBar();
    if (hVisible && hBar != null)
        hostRect.height -= hBar.getSize().y;

    if (!expandVertical && contentRect.height > hostRect.height)
        return true;
    if (expandVertical && minHeight > hostRect.height)
        return true;
    return false;
}
项目:gef-gwt    文件:ControlEditor.java   
/**
 * Creates a ControlEditor for the specified Composite.
 * 
 * @param parent
 *            the Composite above which this editor will be displayed
 * 
 */
public ControlEditor(Composite parent) {
    this.parent = parent;

    controlListener = new Listener() {
        public void handleEvent(Event e) {
            layout();
        }
    };
    for (int i = 0; i < EVENTS.length; i++) {
        parent.addListener(EVENTS[i], controlListener);
    }

    scrollbarListener = new Listener() {
        public void handleEvent(Event e) {
            scroll(e);
        }
    };
    ScrollBar hBar = parent.getHorizontalBar();
    if (hBar != null)
        hBar.addListener(SWT.Selection, scrollbarListener);
    ScrollBar vBar = parent.getVerticalBar();
    if (vBar != null)
        vBar.addListener(SWT.Selection, scrollbarListener);
}
项目:gef-gwt    文件:ControlEditor.java   
/**
 * Removes all associations between the Editor and the underlying composite.
 * The composite and the editor Control are <b>not</b> disposed.
 */
public void dispose() {
    if (parent != null && !parent.isDisposed()) {
        for (int i = 0; i < EVENTS.length; i++) {
            parent.removeListener(EVENTS[i], controlListener);
        }
        ScrollBar hBar = parent.getHorizontalBar();
        if (hBar != null)
            hBar.removeListener(SWT.Selection, scrollbarListener);
        ScrollBar vBar = parent.getVerticalBar();
        if (vBar != null)
            vBar.removeListener(SWT.Selection, scrollbarListener);
    }

    parent = null;
    editor = null;
    hadFocus = false;
    controlListener = null;
    scrollbarListener = null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:MethodsViewer.java   
/**
 * Restores the state of the filter actions
 * @param memento the memento
 */
public void restoreState(IMemento memento) {
    fMemberFilterActionGroup.restoreState(memento);
    getControl().setRedraw(false);
    refresh();
    getControl().setRedraw(true);

    boolean showInherited= Boolean.valueOf(memento.getString(TAG_SHOWINHERITED)).booleanValue();
    showInheritedMethods(showInherited);

    boolean showDefiningTypes= Boolean.valueOf(memento.getString(TAG_SORTBYDEFININGTYPE)).booleanValue();
    sortByDefiningType(showDefiningTypes);

    ScrollBar bar= getTable().getVerticalBar();
    if (bar != null) {
        Integer vScroll= memento.getInteger(TAG_VERTICAL_SCROLL);
        if (vScroll != null) {
            bar.setSelection(vScroll.intValue());
        }
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:SWTUtil.java   
/**
 * Returns the shell for the given widget. If the widget doesn't represent
 * a SWT object that manage a shell, <code>null</code> is returned.
 * @param widget the widget
 *
 * @return the shell for the given widget
 */
public static Shell getShell(Widget widget) {
    if (widget instanceof Control)
        return ((Control)widget).getShell();
    if (widget instanceof Caret)
        return ((Caret)widget).getParent().getShell();
    if (widget instanceof DragSource)
        return ((DragSource)widget).getControl().getShell();
    if (widget instanceof DropTarget)
        return ((DropTarget)widget).getControl().getShell();
    if (widget instanceof Menu)
        return ((Menu)widget).getParent().getShell();
    if (widget instanceof ScrollBar)
        return ((ScrollBar)widget).getParent().getShell();

    return null;
}
项目:tmxeditor8    文件:JaretTable.java   
/**
 * Update the horiontal scrollbar.
 */
private void updateXScrollBar() {
    if (Display.getCurrent() != null) {
        Display.getCurrent().syncExec(new Runnable() {
            public void run() {
                ScrollBar scroll = getHorizontalBar();
                // scroll may be null
                if (scroll != null) {
                    _oldHorizontalScroll = -1; // make sure no optimization will be applied
                    scroll.setMinimum(0);
                    scroll.setMaximum(getTotalWidth() - getFixedColumnsWidth());
                    scroll.setThumb(getWidth() - getFixedColumnsWidth());
                    scroll.setIncrement(50); // increment for arrows
                    scroll.setPageIncrement(getWidth()); // page increment areas
                }
            }
        });
    }
}
项目:tmxeditor8    文件:JaretTable.java   
/**
 * Update the vertical scrollbar if present.
 */
public void updateYScrollBar() {
    if (Display.getCurrent() != null) {
        Display.getCurrent().syncExec(new Runnable() {
            public void run() {
                ScrollBar scroll = getVerticalBar();
                // scroll may be null
                if (scroll != null) {
                    _oldVerticalScroll = -1; // guarantee a clean repaint
                    scroll.setMinimum(0);
                    scroll.setMaximum(getTotalHeight() - getFixedRowsHeight());
                    int height = getHeight();
                    if (_tableRect != null) {
                        height = _tableRect.height;
                    }
                    scroll.setThumb(height); // - getFixedRowsHeight() - getHeaderHeight());
                    scroll.setIncrement(50); // increment for arrows
                    scroll.setPageIncrement(getHeight()); // page increment areas
                    scroll.setSelection(getAbsBeginYForRowIdx(_firstRowIdx) + _firstRowPixelOffset
                            + getFixedRowsHeight());
                }
            }
        });
    }
}
项目:DarwinSPL    文件:DwprofileSyntaxColoringPreferencePage.java   
private void createListViewer(Composite editorComposite) {
    fListViewer = new TreeViewer(editorComposite, SWT.SINGLE | SWT.BORDER);
    fListViewer.setLabelProvider(new ColorListLabelProvider());
    fListViewer.setContentProvider(new ColorListContentProvider());

    GridData gd = new GridData(GridData.FILL, GridData.FILL, true, true);
    gd.heightHint = convertHeightInCharsToPixels(26);
    int maxWidth = 0;
    for (Iterator<List<HighlightingColorListItem>> it = content.values().iterator(); it.hasNext();) {
        for (Iterator<HighlightingColorListItem> j = it.next().iterator(); j.hasNext();) {
            HighlightingColorListItem item = j.next();
            maxWidth = Math.max(maxWidth, convertWidthInCharsToPixels(item.getDisplayName().length()));
        }
    }
    ScrollBar vBar = ((Scrollable) fListViewer.getControl()).getVerticalBar();
    if (vBar != null) {
        // scrollbars and tree indentation guess
        maxWidth += vBar.getSize().x * 3;
    }
    gd.widthHint = maxWidth;

    fListViewer.getControl().setLayoutData(gd);

    fListViewer.setInput(content);
    fListViewer.setSelection(new StructuredSelection(content.values().iterator().next()));
    fListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            handleSyntaxColorListSelection();
        }
    });
}
项目:DarwinSPL    文件:HyexpressionSyntaxColoringPreferencePage.java   
private void createListViewer(Composite editorComposite) {
    fListViewer = new TreeViewer(editorComposite, SWT.SINGLE | SWT.BORDER);
    fListViewer.setLabelProvider(new ColorListLabelProvider());
    fListViewer.setContentProvider(new ColorListContentProvider());

    GridData gd = new GridData(GridData.FILL, GridData.FILL, true, true);
    gd.heightHint = convertHeightInCharsToPixels(26);
    int maxWidth = 0;
    for (Iterator<List<HighlightingColorListItem>> it = content.values().iterator(); it.hasNext();) {
        for (Iterator<HighlightingColorListItem> j = it.next().iterator(); j.hasNext();) {
            HighlightingColorListItem item = j.next();
            maxWidth = Math.max(maxWidth, convertWidthInCharsToPixels(item.getDisplayName().length()));
        }
    }
    ScrollBar vBar = ((Scrollable) fListViewer.getControl()).getVerticalBar();
    if (vBar != null) {
        // scrollbars and tree indentation guess
        maxWidth += vBar.getSize().x * 3;
    }
    gd.widthHint = maxWidth;

    fListViewer.getControl().setLayoutData(gd);

    fListViewer.setInput(content);
    fListViewer.setSelection(new StructuredSelection(content.values().iterator().next()));
    fListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            handleSyntaxColorListSelection();
        }
    });
}
项目:DarwinSPL    文件:HyvalidityformulaSyntaxColoringPreferencePage.java   
private void createListViewer(Composite editorComposite) {
    fListViewer = new TreeViewer(editorComposite, SWT.SINGLE | SWT.BORDER);
    fListViewer.setLabelProvider(new ColorListLabelProvider());
    fListViewer.setContentProvider(new ColorListContentProvider());

    GridData gd = new GridData(GridData.FILL, GridData.FILL, true, true);
    gd.heightHint = convertHeightInCharsToPixels(26);
    int maxWidth = 0;
    for (Iterator<List<HighlightingColorListItem>> it = content.values().iterator(); it.hasNext();) {
        for (Iterator<HighlightingColorListItem> j = it.next().iterator(); j.hasNext();) {
            HighlightingColorListItem item = j.next();
            maxWidth = Math.max(maxWidth, convertWidthInCharsToPixels(item.getDisplayName().length()));
        }
    }
    ScrollBar vBar = ((Scrollable) fListViewer.getControl()).getVerticalBar();
    if (vBar != null) {
        // scrollbars and tree indentation guess
        maxWidth += vBar.getSize().x * 3;
    }
    gd.widthHint = maxWidth;

    fListViewer.getControl().setLayoutData(gd);

    fListViewer.setInput(content);
    fListViewer.setSelection(new StructuredSelection(content.values().iterator().next()));
    fListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            handleSyntaxColorListSelection();
        }
    });
}
项目:DarwinSPL    文件:HydatavalueSyntaxColoringPreferencePage.java   
private void createListViewer(Composite editorComposite) {
    fListViewer = new TreeViewer(editorComposite, SWT.SINGLE | SWT.BORDER);
    fListViewer.setLabelProvider(new ColorListLabelProvider());
    fListViewer.setContentProvider(new ColorListContentProvider());

    GridData gd = new GridData(GridData.FILL, GridData.FILL, true, true);
    gd.heightHint = convertHeightInCharsToPixels(26);
    int maxWidth = 0;
    for (Iterator<List<HighlightingColorListItem>> it = content.values().iterator(); it.hasNext();) {
        for (Iterator<HighlightingColorListItem> j = it.next().iterator(); j.hasNext();) {
            HighlightingColorListItem item = j.next();
            maxWidth = Math.max(maxWidth, convertWidthInCharsToPixels(item.getDisplayName().length()));
        }
    }
    ScrollBar vBar = ((Scrollable) fListViewer.getControl()).getVerticalBar();
    if (vBar != null) {
        // scrollbars and tree indentation guess
        maxWidth += vBar.getSize().x * 3;
    }
    gd.widthHint = maxWidth;

    fListViewer.getControl().setLayoutData(gd);

    fListViewer.setInput(content);
    fListViewer.setSelection(new StructuredSelection(content.values().iterator().next()));
    fListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            handleSyntaxColorListSelection();
        }
    });
}
项目:DarwinSPL    文件:HymappingSyntaxColoringPreferencePage.java   
private void createListViewer(Composite editorComposite) {
    fListViewer = new TreeViewer(editorComposite, SWT.SINGLE | SWT.BORDER);
    fListViewer.setLabelProvider(new ColorListLabelProvider());
    fListViewer.setContentProvider(new ColorListContentProvider());

    GridData gd = new GridData(GridData.FILL, GridData.FILL, true, true);
    gd.heightHint = convertHeightInCharsToPixels(26);
    int maxWidth = 0;
    for (Iterator<List<HighlightingColorListItem>> it = content.values().iterator(); it.hasNext();) {
        for (Iterator<HighlightingColorListItem> j = it.next().iterator(); j.hasNext();) {
            HighlightingColorListItem item = j.next();
            maxWidth = Math.max(maxWidth, convertWidthInCharsToPixels(item.getDisplayName().length()));
        }
    }
    ScrollBar vBar = ((Scrollable) fListViewer.getControl()).getVerticalBar();
    if (vBar != null) {
        // scrollbars and tree indentation guess
        maxWidth += vBar.getSize().x * 3;
    }
    gd.widthHint = maxWidth;

    fListViewer.getControl().setLayoutData(gd);

    fListViewer.setInput(content);
    fListViewer.setSelection(new StructuredSelection(content.values().iterator().next()));
    fListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            handleSyntaxColorListSelection();
        }
    });
}
项目:DarwinSPL    文件:HyconstraintsSyntaxColoringPreferencePage.java   
private void createListViewer(Composite editorComposite) {
    fListViewer = new TreeViewer(editorComposite, SWT.SINGLE | SWT.BORDER);
    fListViewer.setLabelProvider(new ColorListLabelProvider());
    fListViewer.setContentProvider(new ColorListContentProvider());

    GridData gd = new GridData(GridData.FILL, GridData.FILL, true, true);
    gd.heightHint = convertHeightInCharsToPixels(26);
    int maxWidth = 0;
    for (Iterator<List<HighlightingColorListItem>> it = content.values().iterator(); it.hasNext();) {
        for (Iterator<HighlightingColorListItem> j = it.next().iterator(); j.hasNext();) {
            HighlightingColorListItem item = j.next();
            maxWidth = Math.max(maxWidth, convertWidthInCharsToPixels(item.getDisplayName().length()));
        }
    }
    ScrollBar vBar = ((Scrollable) fListViewer.getControl()).getVerticalBar();
    if (vBar != null) {
        // scrollbars and tree indentation guess
        maxWidth += vBar.getSize().x * 3;
    }
    gd.widthHint = maxWidth;

    fListViewer.getControl().setLayoutData(gd);

    fListViewer.setInput(content);
    fListViewer.setSelection(new StructuredSelection(content.values().iterator().next()));
    fListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            handleSyntaxColorListSelection();
        }
    });
}
项目:DarwinSPL    文件:HymanifestSyntaxColoringPreferencePage.java   
private void createListViewer(Composite editorComposite) {
    fListViewer = new TreeViewer(editorComposite, SWT.SINGLE | SWT.BORDER);
    fListViewer.setLabelProvider(new ColorListLabelProvider());
    fListViewer.setContentProvider(new ColorListContentProvider());

    GridData gd = new GridData(GridData.FILL, GridData.FILL, true, true);
    gd.heightHint = convertHeightInCharsToPixels(26);
    int maxWidth = 0;
    for (Iterator<List<HighlightingColorListItem>> it = content.values().iterator(); it.hasNext();) {
        for (Iterator<HighlightingColorListItem> j = it.next().iterator(); j.hasNext();) {
            HighlightingColorListItem item = j.next();
            maxWidth = Math.max(maxWidth, convertWidthInCharsToPixels(item.getDisplayName().length()));
        }
    }
    ScrollBar vBar = ((Scrollable) fListViewer.getControl()).getVerticalBar();
    if (vBar != null) {
        // scrollbars and tree indentation guess
        maxWidth += vBar.getSize().x * 3;
    }
    gd.widthHint = maxWidth;

    fListViewer.getControl().setLayoutData(gd);

    fListViewer.setInput(content);
    fListViewer.setSelection(new StructuredSelection(content.values().iterator().next()));
    fListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            handleSyntaxColorListSelection();
        }
    });
}
项目:team-explorer-everywhere    文件:TeamExplorerBaseControl.java   
protected void handleBodyResize() {
    int availableWidth = subForm.getSize().x;
    final ScrollBar verticalScrollBar = subForm.getVerticalBar();
    if (verticalScrollBar != null && verticalScrollBar.isVisible()) {
        availableWidth -= verticalScrollBar.getSize().x;
    }

    final TeamExplorerResizeEventArg arg = new TeamExplorerResizeEventArg(availableWidth);
    context.getEvents().notifyListener(TeamExplorerEvents.FORM_RESIZED, arg);
    subForm.layout(true, true);
    subForm.reflow(true);
}
项目:TuxGuitar-1.3.1-fork    文件:TGMatrixEditor.java   
protected void updateScroll(){
    if( this.clientArea != null ){
        int borderWidth = this.editor.getBorderWidth();
        ScrollBar vBar = this.editor.getVerticalBar();
        ScrollBar hBar = this.editor.getHorizontalBar();
        vBar.setMaximum(Math.round(this.height + (borderWidth * 2)));
        vBar.setThumb(Math.round(Math.min(this.height + (borderWidth * 2), this.clientArea.height)));
        hBar.setMaximum(Math.round(this.width + (borderWidth * 2)));
        hBar.setThumb(Math.round(Math.min(this.width + (borderWidth * 2), this.clientArea.width)));
    }
}
项目:TuxGuitar-1.3.1-fork    文件:TGControl.java   
public void paintTablature(TGPainter painter){
    this.setPainting(true);
    try{
        this.checkScroll();

        int oldWidth = this.width;
        int oldHeight = this.height;

        TGRectangle area = createRectangle(getClientArea());
        ScrollBar xScroll = getHorizontalBar();
        ScrollBar yScroll = getVerticalBar();
        this.scrollX = xScroll.getSelection();
        this.scrollY = yScroll.getSelection();

        this.tablature.paintTablature(painter, area, -this.scrollX, -this.scrollY);

        this.width = Math.round(this.tablature.getViewLayout().getWidth());
        this.height = Math.round(this.tablature.getViewLayout().getHeight());

        this.updateScroll();

        if( MidiPlayer.getInstance(this.context).isRunning()){
            this.redrawPlayingMode(painter,true);
        }
        // Si no estoy reproduciendo y hay cambios
        // muevo el scroll al compas que tiene el caret
        else if(this.tablature.getCaret().hasChanges() || (this.width != oldWidth || this.height != oldHeight)){
            // Mover el scroll puede necesitar redibujar
            // por eso es importante desmarcar los cambios antes de hacer el moveScrollTo
            this.tablature.getCaret().setChanges(false);

            this.moveScrollTo(this.tablature.getCaret().getMeasure(), xScroll, yScroll, area);
        }
    }catch(Throwable throwable){
        throwable.printStackTrace();
    }
    this.setPainting(false);
}