类org.eclipse.swt.widgets.Slider源码实例Demo

下面列出了怎么用org.eclipse.swt.widgets.Slider的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: xtext-eclipse   文件: XbaseInformationControl.java
/**
 * Tells whether the SWT Browser widget and hence this information control is available.
 * 
 * @param parent
 *            the parent component used for checking or <code>null</code> if none
 * @return <code>true</code> if this control is available
 */
public static boolean isAvailable(Composite parent) {
	if (!fgAvailabilityChecked) {
		try {
			Browser browser = new Browser(parent, SWT.NONE);
			browser.dispose();

			fgIsAvailable = true;

			Slider sliderV = new Slider(parent, SWT.VERTICAL);
			Slider sliderH = new Slider(parent, SWT.HORIZONTAL);
			int width = sliderV.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
			int height = sliderH.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
			fgScrollBarSize = new Point(width, height);
			sliderV.dispose();
			sliderH.dispose();
		} catch (SWTError er) {
			fgIsAvailable = false;
		} finally {
			fgAvailabilityChecked = true;
		}
	}

	return fgIsAvailable;
}
 
源代码2 项目: nebula   文件: InternalCompositeTable.java
/**
 * Initialize the sliderHolder and slider. The SliderHolder is a Composite
 * that is responsible for showing and hiding the vertical slider upon
 * request.
 */
private void createVSliderHolder() {
	GridData gd = getVSliderGridData();
	vSliderHolder = new Composite(this, SWT.NULL);
	vSlider = new Slider(vSliderHolder, SWT.VERTICAL);
	vSlider.addSelectionListener(sliderSelectionListener);
	vSliderHolder.setLayout(new FillLayout());
	vSliderHolder.setLayoutData(gd);
	vSliderHolder.setTabList(new Control[] {});
}
 
源代码3 项目: nebula   文件: InternalCompositeTable.java
/**
 * Initialize the sliderHolder and slider. The SliderHolder is a Composite
 * that is responsible for showing and hiding the vertical slider upon
 * request.
 */
private void createHSliderHolder() {
	GridData gd = getHSliderGridData();
	hSliderHolder = new Composite(this, SWT.NULL);
	hSlider = new Slider(hSliderHolder, SWT.HORIZONTAL);
	hSlider.setMinimum(0);
	hSlider.setIncrement(20);
	hSlider.addSelectionListener(sliderSelectionListener);
	hSliderHolder.setLayout(new FillLayout());
	hSliderHolder.setLayoutData(gd);
	hSliderHolder.setTabList(new Control[] {});
	hSlider.addSelectionListener(hSliderSelectionListener);
}
 
源代码4 项目: tracecompass   文件: TmfRawEventViewer.java
private void createSlider(int style) {
    fSlider = new Slider(this, SWT.VERTICAL);
    fSlider.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
    fSlider.setValues(0, 0, SLIDER_MAX, SLIDER_MAX, 1, 1);
    fSlider.addSelectionListener(this);
    fSlider.addMouseListener(this);
    if ((style & SWT.V_SCROLL) == 0) {
        fSlider.setVisible(false);
    }
}
 
源代码5 项目: tracecompass   文件: TmfAbstractToolTipHandler.java
private static synchronized Point getScrollbarSize(Composite parent) {
    if (fScrollBarSize == null) {
        // Don't move these lines below the new Browser() line
        Slider sliderV = new Slider(parent, SWT.VERTICAL);
        Slider sliderH = new Slider(parent, SWT.HORIZONTAL);
        int width = sliderV.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
        int height = sliderH.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
        Point scrollBarSize = new Point(width, height);
        sliderV.dispose();
        sliderH.dispose();
        fScrollBarSize = scrollBarSize;
    }
    return fScrollBarSize;
}
 
/**
 * Test the vertical scroll bar position
 */
@Test
public void testVerticalScrollbar() {
    SWTBotView viewBot = openView();
    List<? extends @NonNull Slider> sliders = viewBot.bot().widgets(WidgetOfType.widgetOfType(Slider.class));
    assertTrue("The view has " + sliders.size() + " sliders", sliders.size() >= 2);
    Rectangle sliderRect = getBounds(sliders.get(VERTICAL_SCROLLBAR_INDEX));

    Rectangle timegraphRect = getBounds(viewBot.bot().widget(WidgetOfType.widgetOfType(TimeGraphControl.class)));
    assertEquals("Incorrect vertical slider start position", timegraphRect.width, sliderRect.x);
    assertEquals("Incorrect vertical slider height", timegraphRect.height, sliderRect.height);
}
 
/**
 * Test the horizontal scroll bar position
 */
@Test
public void testHorizontalScrollbar() {
    SWTBotView viewBot = openView();
    List<? extends @NonNull Slider> sliders = viewBot.bot().widgets(WidgetOfType.widgetOfType(Slider.class));
    assertTrue("The view has " + sliders.size() + " sliders", sliders.size() >= 2);
    Rectangle sliderRect = getBounds(sliders.get(HORIZONTAL_SCROLLBAR_INDEX));

    SWTBotTimeGraph tgBot = new SWTBotTimeGraph(viewBot.bot().widget(WidgetOfType.widgetOfType(TimeGraphControl.class)));
    Rectangle timegraphRect = getBounds(viewBot.bot().widget(WidgetOfType.widgetOfType(TimeGraphControl.class)));
    assertEquals("Incorrect horizontal slider start position", timegraphRect.x + tgBot.getNameSpace(), sliderRect.x);
}
 
private int getResizeHandleSize(Composite parent)
{
	if (fResizeHandleSize == -1)
	{
		Slider sliderV = new Slider(parent, SWT.VERTICAL);
		Slider sliderH = new Slider(parent, SWT.HORIZONTAL);
		int width = sliderV.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
		int height = sliderH.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
		sliderV.dispose();
		sliderH.dispose();
		fResizeHandleSize = Math.min(width, height);
	}

	return fResizeHandleSize;
}
 
/**
 * Tells whether the SWT Browser widget and hence this information control is available.
 * 
 * @param parent
 *            the parent component used for checking or <code>null</code> if none
 * @return <code>true</code> if this control is available
 */
public static boolean isAvailable(Composite parent)
{
	if (!fgAvailabilityChecked)
	{
		try
		{
			Browser browser = new Browser(parent, SWT.NONE);
			browser.dispose();
			fgIsAvailable = true;

			Slider sliderV = new Slider(parent, SWT.VERTICAL);
			Slider sliderH = new Slider(parent, SWT.HORIZONTAL);
			int width = sliderV.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
			int height = sliderH.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
			fgScrollBarSize = new Point(width, height);
			sliderV.dispose();
			sliderH.dispose();
		}
		catch (SWTError er)
		{
			fgIsAvailable = false;
		}
		finally
		{
			fgAvailabilityChecked = true;
		}
	}

	return fgIsAvailable;
}
 
源代码10 项目: birt   文件: ChartSlider.java
protected void placeComponents( int style )
{
	GridLayout gl = new GridLayout( 1, false );
	gl.marginBottom = 0;
	gl.marginHeight = 0;
	gl.marginLeft = 0;
	gl.marginRight = 0;
	gl.marginTop = 0;
	gl.marginWidth = 0;
	this.setLayout( gl );
	
	slider = new Slider( this, style );
	GridData gd = new GridData( GridData.FILL_BOTH );
	slider.setLayoutData( gd );
}
 
源代码11 项目: nebula   文件: FontAwesomeSnippet3.java
public static void main(final String[] args) {
	final Display display = new Display();
	final Shell shell = new Shell(display);
	shell.setText("FontAwesome Snippet");
	shell.setSize(1000, 600);
	shell.setLayout(new GridLayout(2, false));

	fScrolledComposite = new ScrolledComposite(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
	fScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
	fScrolledComposite.setAlwaysShowScrollBars(false);
	fScrolledComposite.setExpandHorizontal(true);
	fScrolledComposite.setExpandVertical(true);

	Composite composite = new Composite(fScrolledComposite, SWT.NONE);
	fScrolledComposite.setContent(composite);

	RowLayout rowLayout = new RowLayout(SWT.HORIZONTAL);
	rowLayout.marginTop = 5;
	rowLayout.marginRight = 5;
	rowLayout.marginLeft = 5;
	rowLayout.marginBottom = 5;
	rowLayout.pack = false;
	composite.setLayout(rowLayout);
	buildComposite(composite);
	calcMinsize(composite);
	shell.layout(true, true);

	fFontLabel = new Label(shell, SWT.NONE);
	fFontLabel.setText("Font size (22)");


	fSlider = new Slider(shell, SWT.NONE);
	fSlider.addListener(SWT.MouseUp, e -> {
		shell.setRedraw(false);
		Arrays.asList(composite.getChildren()).forEach(c -> c.dispose());
		fFontSize = fSlider.getSelection();
		buildComposite(composite);
		fFontLabel.setText("Font size (" + fFontSize + ")");
		shell.setRedraw(true);

		shell.layout(true, true);
		calcMinsize(composite);
	});
	fSlider.setPageIncrement(1);
	fSlider.setMaximum(150);
	fSlider.setMinimum(4);
	fSlider.setSelection(22);
	fSlider.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
	display.dispose();

}
 
源代码12 项目: tuxguitar   文件: SWTSlider.java
public SWTSlider(SWTContainer<? extends Composite> parent, int orientation) {
	super(new Slider(parent.getControl(), SWT.BORDER | orientation), parent);
	
	this.selectionListener = new SWTSelectionListenerManager(this);
}
 
源代码13 项目: dawnsci   文件: CompositeTableRow.java
public CompositeTableRow(CompositeEntry entry,
					     Table container,
						 CompositingControl control,
						 boolean disableOp) {
	
	this.name = entry.getName();
	TableItem newItem = new TableItem(container,SWT.DOUBLE_BUFFERED);
	TableEditor editor0 = new TableEditor(container);
	editor0.horizontalAlignment = SWT.CENTER;
	editor0.grabHorizontal = true;
	chkActive = new Button(container,SWT.CHECK);
	chkActive.setSelection(true);
	chkActive.addSelectionListener(control);
	editor0.setEditor(chkActive,newItem,0);
	
	TableEditor editor = new TableEditor(container);
	editor.horizontalAlignment = SWT.CENTER;
	editor.grabHorizontal = true;
	panel = new Composite(container, SWT.NONE);
	panel.setLayout(new GridLayout(2,true));
	slider = new Slider(panel,SWT.HORIZONTAL|SWT.NO_TRIM);
	slider.setValues((int)(entry.getWeight()*100), 0, 104, 5, 1, 5);
	slider.addSelectionListener(this);
	slider.addSelectionListener(control);
	spinner = new Spinner(panel,SWT.DOUBLE_BUFFERED);
	spinner.setMinimum(0);
	spinner.setMaximum(100);
	spinner.setSelection((int)(entry.getWeight()*100));
	spinner.addSelectionListener(control);
	spinner.addSelectionListener(this);
	panel.pack();
	editor.setEditor(panel,newItem,2);
	newItem.setText(1,name);
	TableEditor editor2 = new TableEditor(container);
	editor2.horizontalAlignment = SWT.CENTER;
	editor2.grabHorizontal = true;
	editor2.grabVertical = true;
	op = new Combo(container,SWT.NONE);
	op.add("ADD");
	op.add("SUBTRACT");
	op.add("MULTIPLY");
	op.add("DIVIDE");
	op.add("MINIMUM");
	op.add("MAXIMUM");
	op.select(convertOperationToInt(entry.getOperation()));
	op.pack();
	op.addSelectionListener(control);
	op.setEnabled(!disableOp);
	editor2.setEditor(op,newItem,3);
	TableEditor editor3 = new TableEditor(container);
	editor3.horizontalAlignment = SWT.CENTER;
	editor3.grabHorizontal = true;
	editor3.grabVertical = true;
	chkRed = new Button(container,SWT.CHECK);
	chkRed.setSelection(true);
	chkRed.pack();
	chkRed.addSelectionListener(control);
	editor3.setEditor(chkRed,newItem,4);
	TableEditor editor4 = new TableEditor(container);
	editor4.horizontalAlignment = SWT.CENTER;
	editor4.grabHorizontal = true;
	editor4.grabVertical = true;
	chkGreen = new Button(container,SWT.CHECK);
	chkGreen.pack();
	chkGreen.setSelection(true);
	chkGreen.addSelectionListener(control);
	editor4.setEditor(chkGreen,newItem,5);
	TableEditor editor5 = new TableEditor(container);
	editor5.horizontalAlignment = SWT.CENTER;
	editor5.grabHorizontal = true;
	editor5.grabVertical = true;
	chkBlue = new Button(container,SWT.CHECK);
	chkBlue.pack();
	chkBlue.setSelection(true);
	chkBlue.addSelectionListener(control);
	editor5.setEditor(chkBlue,newItem,6);		
	
}
 
源代码14 项目: birt   文件: ChartSlider.java
public Slider getWidget( )
{
	return this.slider;
}
 
源代码15 项目: tracecompass   文件: TimeGraphViewer.java
/**
 * Get the horizontal scroll bar object
 *
 * @return The scroll bar
 */
public Slider getHorizontalBar() {
    return fHorizontalScrollBar;
}
 
源代码16 项目: tracecompass   文件: TimeGraphViewer.java
/**
 * Get the vertical scroll bar object
 *
 * @return The scroll bar
 */
public Slider getVerticalBar() {
    return fVerticalScrollBar;
}
 
 类所在包
 同包方法