Package org.eclipse.swt.widgets

Examples of org.eclipse.swt.widgets.ScrollBar


   */
  public void setAlwaysShowScrollBars(boolean show) {
    checkWidget();
    if (show == alwaysShowScroll) return;
    alwaysShowScroll = show;
    ScrollBar hBar = getHorizontalBar ();
    if (hBar != null && alwaysShowScroll) hBar.setVisible(true);
    ScrollBar vBar = getVerticalBar ();
    if (vBar != null && alwaysShowScroll) vBar.setVisible(true);
    layout(false);
  }
View Full Code Here


      this.content.removeListener(SWT.Resize, contentListener);
      this.content.setBounds(new Rectangle(-200, -200, 0, 0))
    }

    this.content = content;
    ScrollBar vBar = getVerticalBar ();
    ScrollBar hBar = getHorizontalBar ();
    if (this.content != null) {
      if (vBar != null) {
        vBar.setMaximum (0);
        vBar.setThumb (0);
        vBar.setSelection(0);
      }
      if (hBar != null) {
        hBar.setMaximum (0);
        hBar.setThumb (0);
        hBar.setSelection(0);
      }
      content.setLocation(0, 0);
      layout(false);
      this.content.addListener(SWT.Resize, contentListener);
    } else {
      if (hBar != null) hBar.setVisible(alwaysShowScroll);
      if (vBar != null) vBar.setVisible(alwaysShowScroll);
    }
  }
View Full Code Here

  }

  void vScroll() {
    if (content == null) return;
    Point location = content.getLocation ();
    ScrollBar vBar = getVerticalBar ();
    int vSelection = vBar.getSelection ();
    content.setLocation (location.x, -vSelection);
  }
View Full Code Here

            //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

        fSubjectControl.addMouseMoveListener(this);
        fSubjectControl.addControlListener(this);
        fSubjectControl.addKeyListener(this);
        if (fSubjectControl instanceof Scrollable) {
          Scrollable scrollable= (Scrollable) fSubjectControl;
          ScrollBar vBar= scrollable.getVerticalBar();
          if (vBar != null)
            vBar.addSelectionListener(this);
          ScrollBar hBar= scrollable.getHorizontalBar();
          if (hBar != null)
            hBar.addSelectionListener(this);
        }
       
        fDisplay= fSubjectControl.getDisplay();
        if (!fDisplay.isDisposed()) {
          fDisplay.addFilter(SWT.Activate, this);
View Full Code Here

        fSubjectControl.removeMouseMoveListener(this);
        fSubjectControl.removeControlListener(this);
        fSubjectControl.removeKeyListener(this);
        if (fSubjectControl instanceof Scrollable) {
          Scrollable scrollable= (Scrollable) fSubjectControl;
          ScrollBar vBar= scrollable.getVerticalBar();
          if (vBar != null)
            vBar.removeSelectionListener(this);
          ScrollBar hBar= scrollable.getHorizontalBar();
          if (hBar != null)
            hBar.removeSelectionListener(this);
        }
      }

      if (fDisplay != null && !fDisplay.isDisposed()) {
        fDisplay.removeFilter(SWT.Activate, this);
View Full Code Here

  public OverviewRulerHoverManager(IOverviewRuler ruler, ISourceViewer sourceViewer, IAnnotationHover annotationHover, IInformationControlCreator creator) {
    super(ruler, sourceViewer, annotationHover, creator);
    setAnchor(ANCHOR_LEFT);
    StyledText textWidget= sourceViewer.getTextWidget();
    if (textWidget != null) {
      ScrollBar verticalBar= textWidget.getVerticalBar();
      if (verticalBar != null)
        setMargins(verticalBar.getSize().x, 5);
    }
  }
View Full Code Here

    // update content size now
    updateContentSize();
    //
    addListener(SWT.Resize, new Listener() {
      public void handleEvent(Event event) {
        ScrollBar vBar = getVerticalBar();
        vBar.setIncrement(m_pixelCharOne);
        vBar.setPageIncrement(getSize().y);
      }
    });
  }
View Full Code Here

    }
  }

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

    double sx = af.getScaleX(), sy = af.getScaleY();
    double tx = af.getTranslateX(), ty = af.getTranslateY();
    if (tx > 0) tx = 0;
    if (ty > 0) ty = 0;

    ScrollBar horizontal = getHorizontalBar();
    horizontal.setIncrement((int) (getClientArea().width / 100));
    horizontal.setPageIncrement(getClientArea().width);
    Rectangle imageBound = sourceImage.getBounds();
    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((int) (getClientArea().width));

    ScrollBar vertical = getVerticalBar();
    vertical.setIncrement((int) (getClientArea().height / 100));
    vertical.setPageIncrement((int) (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((int) (getClientArea().height));

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

TOP

Related Classes of org.eclipse.swt.widgets.ScrollBar

Copyright © 2018 www.massapicom. 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.