Package org.eclipse.swt.widgets

Examples of org.eclipse.swt.widgets.ScrollBar


            Rectangle calcArea = clientAreaResizeCommand.getCalcArea();
            int widthDiff = clientArea.width - calcArea.width;
            int heightDiff = clientArea.height - calcArea.height;

            if (this.hBarListener == null && this.horizontalScrollbarEnabled) {
                ScrollBar hBar = scrollable.getHorizontalBar();

                if (this.horizontalScroller != null) {
                    hBar.setEnabled(false);
                    hBar.setVisible(false);
                } else {
                    this.horizontalScroller = new ScrollBarScroller(hBar);
                }

                this.hBarListener = new HorizontalScrollBarHandler(this, this.horizontalScroller);

                if (scrollable instanceof NatTable) {
                    this.hBarListener.setTable((NatTable) scrollable);
                }
            }

            if (this.vBarListener == null && this.verticalScrollbarEnabled) {
                ScrollBar vBar = scrollable.getVerticalBar();

                if (this.verticalScroller != null) {
                    vBar.setEnabled(false);
                    vBar.setVisible(false);
                } else {
                    this.verticalScroller = new ScrollBarScroller(vBar);
                }

                this.vBarListener = new VerticalScrollBarHandler(this, this.verticalScroller);
View Full Code Here


        if (currentTabComposite != null) {
            currentTabSize = currentTabComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
        }
        getScrolledComposite().setMinSize(currentTabSize);

        ScrollBar verticalScrollBar = getScrolledComposite().getVerticalBar();
        if (verticalScrollBar != null) {
            Rectangle clientArea = getScrolledComposite().getClientArea();
            int increment = clientArea.height - 5;
            verticalScrollBar.setPageIncrement(increment);
        }

        ScrollBar horizontalScrollBar = getScrolledComposite().getHorizontalBar();
        if (horizontalScrollBar != null) {
            Rectangle clientArea = getScrolledComposite().getClientArea();
            int increment = clientArea.width - 5;
            horizontalScrollBar.setPageIncrement(increment);
        }
    }
View Full Code Here

    resizeScrollBars();
      }
  });

  //TODO: 垂直滚动条也应该用自定控件,否则太那看了 :-(
  ScrollBar bar = shell.getVerticalBar();
  if (bar != null)
  {
      bar.addSelectionListener(new SelectionAdapter()
      {
    public void widgetSelected(SelectionEvent event)
    {
        scrollVertical((ScrollBar) event.widget);
    }
View Full Code Here

     * 自动调整垂直滚动条
     */
    private void resizeScrollBars()
    {
  Rectangle clientArea = playListPanelRec;
  ScrollBar vbar = shell.getVerticalBar();
  if (vbar != null)
  {
      vbar.setMaximum(maxY);
      vbar.setThumb(clientArea.height);
      vbar.setPageIncrement(clientArea.height);
      vbar.setIncrement(lineHeight);
      if (clientArea.height >= lineHeight * getItemCount() + 2)
      {
    vbar.setVisible(false);
      }
      else
      {
    vbar.setVisible(true);
      }
  }
    }
View Full Code Here

      if (menu == null) {
        return null;
      }
      return menu.getParent();
    } else if (widget instanceof ScrollBar) {
      ScrollBar item = (ScrollBar) widget;
      return item.getParent();
    } else if (widget instanceof ToolTip) {
      ToolTip item = (ToolTip) widget;
      return item.getParent();
    } else if (widget instanceof CoolItem) {
      CoolItem item = (CoolItem) widget;
      return item.getParent();
    } else if (widget instanceof CTabItem) {
      CTabItem item = (CTabItem) widget;
      return item.getParent();
    } else if (widget instanceof ExpandItem) {
      ExpandItem item = (ExpandItem) widget;
      return item.getParent();
    } else if (widget instanceof TabItem) {
      TabItem item = (TabItem) widget;
      return item.getParent();
    } else if (widget instanceof TableColumn) {
      TableColumn item = (TableColumn) widget;
      return item.getParent();
    } else if (widget instanceof TableItem) {
      TableItem item = (TableItem) widget;
      return item.getParent();
    } else if (widget instanceof TableTreeItem) {
      TableTreeItem item = (TableTreeItem) widget;
      return item.getParent();
    } else if (widget instanceof ToolItem) {
      ToolItem item = (ToolItem) widget;
      return item.getParent();
    } else if (widget instanceof TreeColumn) {
      TreeColumn item = (TreeColumn) widget;
      return item.getParent();
    } else if (widget instanceof TreeItem) {
      TreeItem item = (TreeItem) widget;
      return item.getParent();
    } else if (widget instanceof Caret) {
      Caret item = (Caret) widget;
      return item.getParent();
    }
    return null;
  }
View Full Code Here

          showColorAt(event.x, event.y);
      }
    });

    // Set up the image canvas scroll bars.
    ScrollBar horizontal = imageCanvas.getHorizontalBar();
    horizontal.setVisible(true);
    horizontal.setMinimum(0);
    horizontal.setEnabled(false);
    horizontal.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        scrollHorizontally((ScrollBar) event.widget);
      }
    });
    ScrollBar vertical = imageCanvas.getVerticalBar();
    vertical.setVisible(true);
    vertical.setMinimum(0);
    vertical.setEnabled(false);
    vertical.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        scrollVertically((ScrollBar) event.widget);
      }
    });

    // Label to show the image size.
    sizeLabel = new Label(shell, SWT.NONE);
    sizeLabel.setText(ImageAnalyzer.bundle.getString("Size_initial"));
    sizeLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

    // Label to show the image depth.
    depthLabel = new Label(shell, SWT.NONE);
    depthLabel.setText(ImageAnalyzer.bundle.getString("Depth_initial"));
    depthLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

    // Label to show the transparent pixel.
    transparentPixelLabel = new Label(shell, SWT.NONE);
    transparentPixelLabel.setText(ImageAnalyzer.bundle.getString("Transparent_pixel_initial"));
    transparentPixelLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

    // Label to show the time to load.
    timeToLoadLabel = new Label(shell, SWT.NONE);
    timeToLoadLabel.setText(ImageAnalyzer.bundle.getString("Time_to_load_initial"));
    timeToLoadLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

    // Separate the animation fields from the rest of the fields.
    Label separator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
    separator.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

    // Label to show the logical screen size for animation.
    screenSizeLabel = new Label(shell, SWT.NONE);
    screenSizeLabel.setText(ImageAnalyzer.bundle.getString("Animation_size_initial"));
    screenSizeLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

    // Label to show the background pixel.
    backgroundPixelLabel = new Label(shell, SWT.NONE);
    backgroundPixelLabel.setText(ImageAnalyzer.bundle.getString("Background_pixel_initial"));
    backgroundPixelLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

    // Label to show the image location (x, y).
    locationLabel = new Label(shell, SWT.NONE);
    locationLabel.setText(ImageAnalyzer.bundle.getString("Image_location_initial"));
    locationLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

    // Label to show the image disposal method.
    disposalMethodLabel = new Label(shell, SWT.NONE);
    disposalMethodLabel.setText(ImageAnalyzer.bundle.getString("Disposal_initial"));
    disposalMethodLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

    // Label to show the image delay time.
    delayTimeLabel = new Label(shell, SWT.NONE);
    delayTimeLabel.setText(ImageAnalyzer.bundle.getString("Delay_initial"));
    delayTimeLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

    // Label to show the background pixel.
    repeatCountLabel = new Label(shell, SWT.NONE);
    repeatCountLabel.setText(ImageAnalyzer.bundle.getString("Repeats_initial"));
    repeatCountLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

    // Separate the animation fields from the palette.
    separator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
    separator.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

    // Label to show if the image has a direct or indexed palette.
    paletteLabel = new Label(shell, SWT.NONE);
    paletteLabel.setText(ImageAnalyzer.bundle.getString("Palette_initial"));
    paletteLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

    // Canvas to show the image's palette.
    paletteCanvas = new Canvas(shell, SWT.BORDER | SWT.V_SCROLL | SWT.NO_REDRAW_RESIZE);
    paletteCanvas.setFont(fixedWidthFont);
    paletteCanvas.getVerticalBar().setVisible(true);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    GC gc = new GC(paletteLabel);
    paletteWidth = gc.stringExtent(ImageAnalyzer.bundle.getString("Max_length_string")).x;
    gc.dispose();
    gridData.widthHint = paletteWidth;
    gridData.heightHint = 16 * 11; // show at least 16 colors
    paletteCanvas.setLayoutData(gridData);
    paletteCanvas.addPaintListener(new PaintListener() {
      public void paintControl(PaintEvent event) {
        if (image != null)
          paintPalette(event);
      }
    });

    // Set up the palette canvas scroll bar.
    vertical = paletteCanvas.getVerticalBar();
    vertical.setVisible(true);
    vertical.setMinimum(0);
    vertical.setIncrement(10);
    vertical.setEnabled(false);
    vertical.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        scrollPalette((ScrollBar) event.widget);
      }
    });

View Full Code Here

    paletteCanvas.getVerticalBar().setSelection(0);
  }

  void resizeScrollBars() {
    // Set the max and thumb for the image canvas scroll bars.
    ScrollBar horizontal = imageCanvas.getHorizontalBar();
    ScrollBar vertical = imageCanvas.getVerticalBar();
    Rectangle canvasBounds = imageCanvas.getClientArea();
    int width = Math.round(imageData.width * xscale);
    if (width > canvasBounds.width) {
      // The image is wider than the canvas.
      horizontal.setEnabled(true);
      horizontal.setMaximum(width);
      horizontal.setThumb(canvasBounds.width);
      horizontal.setPageIncrement(canvasBounds.width);
    } else {
      // The canvas is wider than the image.
      horizontal.setEnabled(false);
      if (ix != 0) {
        // Make sure the image is completely visible.
        ix = 0;
        imageCanvas.redraw();
      }
    }
    int height = Math.round(imageData.height * yscale);
    if (height > canvasBounds.height) {
      // The image is taller than the canvas.
      vertical.setEnabled(true);
      vertical.setMaximum(height);
      vertical.setThumb(canvasBounds.height);
      vertical.setPageIncrement(canvasBounds.height);
    } else {
      // The canvas is taller than the image.
      vertical.setEnabled(false);
      if (iy != 0) {
        // Make sure the image is completely visible.
        iy = 0;
        imageCanvas.redraw();
      }
    }

    // Set the max and thumb for the palette canvas scroll bar.
    vertical = paletteCanvas.getVerticalBar();
    if (imageData.palette.isDirect)
      vertical.setEnabled(false);
    else { // indexed palette
      canvasBounds = paletteCanvas.getClientArea();
      int paletteHeight = imageData.palette.getRGBs().length * 10 + 20; // 10 pixels each index + 20 for
      // margins.
      vertical.setEnabled(true);
      vertical.setMaximum(paletteHeight);
      vertical.setThumb(canvasBounds.height);
      vertical.setPageIncrement(canvasBounds.height);
    }
  }
View Full Code Here

        maxX = size.x * 3 / 2;
        maxY = size.y * 3 / 2;
        resizeScrollBars();
      }
    });
    ScrollBar bar = canvas.getHorizontalBar();
    if (bar != null) {
      hookListeners(bar);
      bar.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
          scrollHorizontal((ScrollBar) event.widget);
        }
      });
    }
    bar = canvas.getVerticalBar();
    if (bar != null) {
      hookListeners(bar);
      bar.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
          scrollVertical((ScrollBar) event.widget);
        }
      });
    }
View Full Code Here

  /**
   * Resizes the maximum and thumb of both scrollbars.
   */
  void resizeScrollBars() {
    Rectangle clientArea = canvas.getClientArea();
    ScrollBar bar = canvas.getHorizontalBar();
    if (bar != null) {
      bar.setMaximum(maxX);
      bar.setThumb(clientArea.width);
      bar.setPageIncrement(clientArea.width);
    }
    bar = canvas.getVerticalBar();
    if (bar != null) {
      bar.setMaximum(maxY);
      bar.setThumb(clientArea.height);
      bar.setPageIncrement(clientArea.height);
    }
  }
View Full Code Here

    Rectangle visibleRect = paintCanvas.getClientArea();
    visibleWidth = visibleRect.width;
    visibleHeight = visibleRect.height;

    ScrollBar horizontal = paintCanvas.getHorizontalBar();
    if (horizontal != null) {
      displayFDC.xOffset = Math.min(horizontal.getSelection(), imageWidth - visibleWidth);
      if (imageWidth <= visibleWidth) {
        horizontal.setEnabled(false);
        horizontal.setSelection(0);
      } else {
        horizontal.setEnabled(true);
        horizontal.setValues(displayFDC.xOffset, 0, imageWidth, visibleWidth, 8, visibleWidth);
      }
    }

    ScrollBar vertical = paintCanvas.getVerticalBar();
    if (vertical != null) {
      displayFDC.yOffset = Math.min(vertical.getSelection(), imageHeight - visibleHeight);
      if (imageHeight <= visibleHeight) {
        vertical.setEnabled(false);
        vertical.setSelection(0);
      } else {
        vertical.setEnabled(true);
        vertical.setValues(displayFDC.yOffset, 0, imageHeight, visibleHeight, 8, visibleHeight);
      }
    }
  }
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.