Examples of ScrollBar


Examples of org.eclipse.swt.widgets.ScrollBar

  private void onTreeResize() {
    int totalWidth = fTree.getParent().getClientArea().width;
    totalWidth -= fTree.getBorderWidth() * 2;

    ScrollBar verticalBar = fTree.getVerticalBar();
    if (verticalBar != null)
      totalWidth -= fTree.getVerticalBar().getSize().x;

    /* Bug on Mac: Width is too big */
    if (Application.IS_MAC)
View Full Code Here

Examples of org.eclipse.swt.widgets.ScrollBar

  }
 
  private void propagateScrollBarVisiblity(){
    setScrollbars();
    for(Dimension d : HOR_VER){
      ScrollBar bar = scrollBars.get(d);
      boolean shouldBeVisible =  scrollBarsVisible.get(d);
      if(bar != null && bar.isVisible() != shouldBeVisible){
        bar.setVisible(shouldBeVisible);
      }
    }
  }
View Full Code Here

Examples of org.eclipse.swt.widgets.ScrollBar

  }
 
  private void updateScrollBars(){
    setScrollbars();
    for(Dimension d : HOR_VER){
      ScrollBar bar = scrollBars.get(d);
      if(bar == null) {
        continue;
      }
      double diff = figure.size.get(d) - viewPortSize.get(d);
      viewPortLocation.setMinMax(d, 0, diff);
      bar.setMinimum(0);
      bar.setMaximum(FigureMath.ceil( figure.size.get(d)));
      bar.setIncrement(50);
      int selSize = FigureMath.floor(viewPortSize.get(d));
      bar.setPageIncrement(selSize);
      bar.setThumb(selSize);
      bar.setSelection((int)viewPortLocation.get(d));
    }
  }
View Full Code Here

Examples of org.eclipse.swt.widgets.ScrollBar

  @Override
  public void widgetSelected(SelectionEvent e) {
    setScrollbars();
    for(Dimension d : HOR_VER){
     
      ScrollBar bar = scrollBars.get(d);
     
      if(bar != null){
        viewPortLocation.set(d,bar.getSelection());
        Rectangle part = getViewPortRectangle();
        adjustOverlaps(part);
      } else {
      }
    }
View Full Code Here

Examples of org.eclipse.swt.widgets.ScrollBar

        int maxWidth = 0;
        for (final TokenHighlight item : fColors) {
            maxWidth = Math.max(maxWidth, convertWidthInCharsToPixels(item.getName()
                    .length()));
        }
        final ScrollBar vBar = ((Scrollable) fListViewer.getControl()).getVerticalBar();
        if (vBar != null) {
            maxWidth += vBar.getSize().x * 3; // scrollbars and tree
        }
        // indentation guess
        gd.widthHint = maxWidth;

        fListViewer.getControl().setLayoutData(gd);
View Full Code Here

Examples of org.eclipse.swt.widgets.ScrollBar

        }
    }

    /* Initalize the scrollbar and register listeners. */
    private void initScrollBars() {
        final ScrollBar horizontal = getHorizontalBar();
        horizontal.setEnabled(false);
        horizontal.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {
                scrollHorizontally((ScrollBar) event.widget);
            }
        });
        final ScrollBar vertical = getVerticalBar();
        vertical.setEnabled(false);
        vertical.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent event) {
                scrollVertically((ScrollBar) event.widget);
            }
        });
View Full Code Here

Examples of org.eclipse.swt.widgets.ScrollBar

        }
        if (ty > 0) {
            ty = 0;
        }

        final ScrollBar horizontal = getHorizontalBar();
        horizontal.setIncrement(getClientArea().width / 100);
        horizontal.setPageIncrement(getClientArea().width);
        final Rectangle imageBound = sourceImage.getBounds();
        final int cw = getClientArea().width, ch = getClientArea().height;
        if (imageBound.width * sx > cw) { /* image is wider than client area */
            horizontal.setMaximum((int) (imageBound.width * sx));
            horizontal.setEnabled(true);
            if ((int) -tx > horizontal.getMaximum() - cw) {
                tx = -horizontal.getMaximum() + cw;
            }
        } else { /* image is narrower than client area */
            horizontal.setEnabled(false);
            tx = (cw - imageBound.width * sx) / 2; // center if too small.
        }
        horizontal.setSelection((int) -tx);
        horizontal.setThumb(getClientArea().width);

        final ScrollBar vertical = getVerticalBar();
        vertical.setIncrement(getClientArea().height / 100);
        vertical.setPageIncrement(getClientArea().height);
        if (imageBound.height * sy > ch) { /* image is higher than client area */
            vertical.setMaximum((int) (imageBound.height * sy));
            vertical.setEnabled(true);
            if ((int) -ty > vertical.getMaximum() - ch) {
                ty = -vertical.getMaximum() + ch;
            }
        } else { /* image is less higher than client area */
            vertical.setEnabled(false);
            ty = (ch - imageBound.height * sy) / 2; // center if too small.
        }
        vertical.setSelection((int) -ty);
        vertical.setThumb(getClientArea().height);

        /* update transform. */
        af = AffineTransform.getScaleInstance(sx, sy);
        af.preConcatenate(AffineTransform.getTranslateInstance(tx, ty));
        transform = af;
View Full Code Here

Examples of org.eclipse.swt.widgets.ScrollBar

      // Install the listeners for events that need to be monitored for
      // popup closure.
      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);
View Full Code Here

Examples of org.eclipse.swt.widgets.ScrollBar

      // Remove installed listeners
      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);
        }
View Full Code Here

Examples of org.eclipse.swt.widgets.ScrollBar

            //use a monospaced font for a better layout
            Font font = new Font(compositeHolder.getDisplay(), "Courier", 10, SWT.NORMAL);
            hexText.setFont(font);
            asciiText.setFont(font);

            final ScrollBar hexScrollBar = hexText.getVerticalBar();
            final ScrollBar asciiScrollBar = asciiText.getVerticalBar();

            //create a sub composite to contain all the buttons
            final Composite buttonComposite = toolkit.createComposite(localComposite, SWT.NONE);
            layout = new GridLayout(7, false);
            layout.marginWidth = 0;
            buttonComposite.setLayout(layout);
            buttonComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));

            _firstButton = toolkit.createButton(buttonComposite, "<<", SWT.PUSH);
            GridData layoutData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
            layoutData.widthHint = 40;
            _firstButton.setLayoutData(layoutData);
            _firstButton.setToolTipText("See the first n bytes");

            _previousButton = toolkit.createButton(buttonComposite, "<", SWT.PUSH);
            layoutData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
            layoutData.widthHint = 40;
            _previousButton.setLayoutData(layoutData);
            _previousButton.setToolTipText("See the previous n bytes");
            _previousButton.setEnabled(false);

            _hexNumTextToStart = toolkit.createText(buttonComposite, "0");
            layoutData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
            layoutData.widthHint = 40;
            _hexNumTextToStart.setLayoutData(layoutData);
            _hexNumTextToStart.setEditable(false);

            final Text hexNumText = toolkit.createText(buttonComposite, "" + startContentSize);
            layoutData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
            layoutData.widthHint = 40;
            hexNumText.setLayoutData(layoutData);

            _hexNumTextToEnd = toolkit.createText(buttonComposite, "" + (byteArray.length - startContentSize));
            layoutData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
            layoutData.widthHint = 40;
            _hexNumTextToEnd.setLayoutData(layoutData);
            _hexNumTextToEnd.setEditable(false);

            _nextButton = toolkit.createButton(buttonComposite, ">", SWT.PUSH);
            layoutData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
            layoutData.widthHint = 40;
            _nextButton.setLayoutData(layoutData);
            _nextButton.setToolTipText("See the next n bytes");
            _nextButton.setEnabled(true);

            _lastButton = toolkit.createButton(buttonComposite, ">>", SWT.PUSH);
            layoutData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
            layoutData.widthHint = 40;
            _lastButton.setToolTipText("See the last n bytes");
            _lastButton.setLayoutData(layoutData);

            SelectionListener listener = new SelectionAdapter()
            {
                public void widgetSelected(SelectionEvent e)
                {
                    if (e.widget instanceof Button)
                    {
                        String numOfBytes = hexNumText.getText();
                        try
                        {
                            int n = Integer.parseInt(numOfBytes);

                            //Reset range display if user requests a large value
                            if (n > byteArray.length)
                            {
                                n = (byteArray.length > DEFAULT_CONTENT_SIZE) ? DEFAULT_CONTENT_SIZE : byteArray.length;
                                hexNumText.setText("" + n);
                            }

                            //rest if the user requests 0
                            if (n < 1)
                            {
                                n = DEFAULT_CONTENT_SIZE;
                                hexNumText.setText("" + n);
                            }

                            Button button = (Button) e.widget;
                            hexText.setText(displayByteFormat(localComposite, byteArray, n * 2, thisEncoding,
                                                              button.getText(), true));
                            asciiText.setText(displayByteFormat(localComposite, byteArray, n * 2, thisEncoding,
                                                                button.getText(), false));
                        }
                        catch (NumberFormatException exp)
                        {
                            popupErrorMessage("Error", "Please input the number of bytes you wish to look at");
                        }
                    }
                    if (e.widget instanceof ScrollBar)
                    {
                        //synchronize the movements of the two scrollbars
                        ScrollBar sb = (ScrollBar) e.widget;
                        if (sb.getParent().equals(hexText))
                        {
                            asciiScrollBar.setIncrement(sb.getIncrement());
                            asciiScrollBar.setSelection(sb.getSelection());
                        }
                        else if (sb.getParent().equals(asciiText))
                        {
                            hexScrollBar.setSelection(sb.getSelection());
                            hexScrollBar.setIncrement(sb.getIncrement());
                        }
                    }
                }
            };
            localComposite.addControlListener(new ControlAdapter()
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.