当前位置: 首页>>代码示例>>Java>>正文


Java ScrollBar.setVisible方法代码示例

本文整理汇总了Java中org.eclipse.swt.widgets.ScrollBar.setVisible方法的典型用法代码示例。如果您正苦于以下问题:Java ScrollBar.setVisible方法的具体用法?Java ScrollBar.setVisible怎么用?Java ScrollBar.setVisible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.swt.widgets.ScrollBar的用法示例。


在下文中一共展示了ScrollBar.setVisible方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setScrollbar

import org.eclipse.swt.widgets.ScrollBar; //导入方法依赖的package包/类
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);
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:25,代码来源:ParameterExpandBar.java

示例2: updateScrollBarProperties

import org.eclipse.swt.widgets.ScrollBar; //导入方法依赖的package包/类
/**
 * Move the scrollbar to reflect the current visible items position.
 * 
 * @param bar
 *            - the scroll bar to move
 * @param clientSize
 *            - Client (visible) area size
 * @param totalSize
 *            - Total Size
 */
private void updateScrollBarProperties(ScrollBar bar, int clientSize,
		int totalSize) {
	if (bar == null)
		return;

	bar.setMinimum(0);
	bar.setPageIncrement(clientSize);
	bar.setMaximum(totalSize);
	bar.setThumb(clientSize);

	// Let the group renderer use a custom increment value.
	if (groupRenderer != null)
		bar.setIncrement(groupRenderer.getScrollBarIncrement());

	if (totalSize > clientSize) {
		if (DEBUG)
			System.out.println("Enabling scrollbar"); //$NON-NLS-1$

		bar.setEnabled(true);
		bar.setVisible(true);
		bar.setSelection(translate);

		// Ensure that translate has a valid value.
		validateTranslation();
	} else {
		if (DEBUG)
			System.out.println("Disabling scrollbar"); //$NON-NLS-1$

		bar.setEnabled(false);
		bar.setVisible(false);
		bar.setSelection(0);
		translate = 0;
	}

}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:46,代码来源:Gallery.java

示例3: setupScrollBar

import org.eclipse.swt.widgets.ScrollBar; //导入方法依赖的package包/类
private void setupScrollBar(ScrollBar sb, boolean visible, int ca, int b, int size) {
	if (sb == null)
		return;
	sb.setVisible(visible);
	if (!visible)
		sb.setSelection(0);
	else {
		sb.setPageIncrement(ca - sb.getIncrement());
		int max = b + size - ca;
		sb.setMaximum(max);
		sb.setThumb(size > max ? max : size);
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:14,代码来源:ViewerCanvas.java

示例4: updateScrollbar

import org.eclipse.swt.widgets.ScrollBar; //导入方法依赖的package包/类
/**
	 * Setup the scrollbar based on the item counts specified. Note: This doesn't change the current selected position of the
	 * scrollbar.
	 * 
	 * @param scrollBar
	 *            the scrollbar to configure.
	 * @param viewportSize
	 *            how many columns or rows are currently visible in the
	 *            viewport.
	 * @param maximumSize
	 *            the maximum number of columns or rows.
	 * @param lastPageSize
	 *            the maximum number of columns or rows that currently fits onto
	 *            the last page of the viewport. For rows, this is at the bottom
	 *            of the grid, for columns this is over on the right).
	 */
	private void updateScrollbar(final ScrollBar scrollBar, final int viewportSize, final int maximumSize, final int lastPageSize, final int firstVisibleIndex, final int lastVisibleIndex, final boolean isLastCropped) {
		//
		// The scrollbar doesn't quite hold the total number of items. Because we want the last item to live at the bottom 
		// of the grid (for rows) or the right edge of the grid (for columns) rather than the top/left, we stop scrolling 
		// when the last item is in position. 
		//
		final int cappedMax = maximumSize - (lastPageSize - 1);
		
		//
		// The scrollbar is only required, if there are items beyond either of the viewport edged.
		//
		final boolean firstScrolledOff = (firstVisibleIndex > 0);               // The first row or column that's visible, ISN'T the first one, we need a scrollbar to be able to see it again.
		final boolean lastScrolledOff = ((lastVisibleIndex + 1) < maximumSize); // The last row or column that's visible, ISN'T the last one.
		final boolean visible = (firstScrolledOff || ((lastScrolledOff || (isLastCropped)) && (maximumSize > 1)));
		
		scrollBar.setMaximum(cappedMax);
		scrollBar.setThumb(1);
		scrollBar.setPageIncrement(Math.min(viewportSize, cappedMax));
		scrollBar.setIncrement(1);
		scrollBar.setVisible(visible);
		scrollBar.setEnabled(visible);
		
//		System.out.println(String.format("[%s:%s] -> Scroll page [%s] visible-rows [%s] maximum-model [%s] maximum-bar [%s] last-page [%s] last-vis-idx [%s] last-cropped [%s] firstScrolledOff [%s] lastScrolledOff [%s] visible [%s]", 
//			getData("org.eclipse.swtbot.widget.key"),
//			(scrollBar.getStyle() & SWT.VERTICAL) != 0 ? "VERTICAL" : "HORIZONTAL",  
//			scrollBar.getPageIncrement(),
//			viewportSize,
//			maximumSize,
//			scrollBar.getMaximum(),
//			lastPageSize,
//			lastVisibleIndex,
//			isLastCropped,
//			firstScrolledOff,
//			lastScrolledOff,
//			visible));
	}
 
开发者ID:GrandmasterTash,项目名称:jGrid,代码行数:53,代码来源:Grid.java

示例5: setVertical

import org.eclipse.swt.widgets.ScrollBar; //导入方法依赖的package包/类
public void setVertical(final boolean isVerticalGallery) {

		_isVertical = isVerticalGallery;
		_isHorizontal = !isVerticalGallery;

		if (isVerticalGallery) {

			// gallery is vertical

			final ScrollBar hBar = getHorizontalBar();
			if (hBar != null) {
				hBar.setVisible(false);
			}

			// reset to the last vertical width

			_itemWidth = _verticalItemWidth;
			_itemHeight = (int) (_itemWidth / _itemRatio);

		} else {

			// gallery is horizontal

			final ScrollBar vBar = getVerticalBar();
			if (vBar != null) {
				vBar.setVisible(false);
			}
		}

		// this will also set horizontal image height
		onResize();
	}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:33,代码来源:GalleryMT20.java

示例6: updateScrollBarsPropertiesHorizontal

import org.eclipse.swt.widgets.ScrollBar; //导入方法依赖的package包/类
/**
 * Move the scrollbar to reflect the current visible items position.
 */
private void updateScrollBarsPropertiesHorizontal() {

	final ScrollBar bar = getHorizontalBar();

	if (bar == null) {
		return;
	}

	final int areaWidth = _clientArea.width;
	final int contentWidth = _contentVirtualWidthScrollbar;

	bar.setMinimum(0);
	bar.setMaximum(contentWidth);
	bar.setPageIncrement(areaWidth);
	bar.setThumb(areaWidth);

	bar.setIncrement(16);

	if (contentWidth > areaWidth) {

		// show scrollbar

		bar.setEnabled(true);
		bar.setVisible(true);
		bar.setSelection(_galleryPosition);

		// Ensure that translate has a valid value.
		validateGalleryPosition();

	} else {

		// hide scrollbar

		bar.setEnabled(false);
		bar.setVisible(false);
		bar.setSelection(0);
		_galleryPosition = 0;
	}
}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:43,代码来源:GalleryMT20.java

示例7: updateScrollBarsPropertiesVertical

import org.eclipse.swt.widgets.ScrollBar; //导入方法依赖的package包/类
/**
 * Move the scrollbar to reflect the current visible items position.
 */
private void updateScrollBarsPropertiesVertical() {

	final ScrollBar bar = getVerticalBar();
	if (bar == null) {
		return;
	}

	final int clientAreaSize = _clientArea.height;
	final int contentSize = _contentVirtualHeight;

	bar.setMinimum(0);
	bar.setMaximum(contentSize);
	bar.setPageIncrement(clientAreaSize);
	bar.setThumb(clientAreaSize);

	bar.setIncrement(16);

	if (contentSize > clientAreaSize) {

		// show scrollbar

		bar.setEnabled(true);
		bar.setVisible(true);
		bar.setSelection(_galleryPosition);

		// Ensure that translate has a valid value.
		validateGalleryPosition();

	} else {

		// hide scrollbar

		bar.setEnabled(false);
		bar.setVisible(false);
		bar.setSelection(0);
		_galleryPosition = 0;
	}
}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:42,代码来源:GalleryMT20.java

示例8: recalcScrollBars

import org.eclipse.swt.widgets.ScrollBar; //导入方法依赖的package包/类
/**
 * Calculates the extends and visibility of horizontal and vertical
 * scroll bars.
 */
void recalcScrollBars() {
	ScrollBar hScrollBar = getHorizontalBar();
	ScrollBar vScrollBar = getVerticalBar();
	
	// If either horizontal or vertical scrolling is enabled
	if ((hScrollBar != null) || (vScrollBar != null)) {
		// Compute default size of control
		Point size = computeSize(SWT.DEFAULT, SWT.DEFAULT);
		// Get the visible client area
		Rectangle clientArea = getClientArea();

		if (hScrollBar != null) {
			// Show horizontal scroll bar if content does not fit horizontally
			hScrollBar.setVisible(size.x > clientArea.width);
			
			// Set the maximum horizontal scroll to be the default width of 
			// control minus what will show in the client area. 
			hScrollBar.setMaximum(size.x);
			hScrollBar.setThumb(clientArea.width);
			hScrollBar.setPageIncrement(clientArea.width);
		}
		if (vScrollBar != null) {
			// Show vertical scroll bar if content does not fit vertically
			vScrollBar.setVisible(size.y > clientArea.height);
			// Set the maximum vertical scroll to be the default height of 
			// control minus what will show in the client area. 
			vScrollBar.setMaximum(size.y);
			vScrollBar.setIncrement(verticalScrollIncrement);
			vScrollBar.setThumb(clientArea.height);
			vScrollBar.setPageIncrement(clientArea.height);
		}
	}
}
 
开发者ID:MentorEmbedded,项目名称:p2-installer,代码行数:38,代码来源:DetailTree.java

示例9: setContent

import org.eclipse.swt.widgets.ScrollBar; //导入方法依赖的package包/类
/**
 * Set the content that will be scrolled.
 * 
 * @param content
 *            the control to be displayed in the content area
 * 
 * @exception SWTException
 *                <ul>
 *                <li>ERROR_WIDGET_DISPOSED - if the receiver has been
 *                disposed</li>
 *                <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
 *                thread that created the receiver</li>
 *                </ul>
 */
public void setContent(Control content) {
	checkWidget();
	if (this.content != null && !this.content.isDisposed()) {
		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);
	}
}
 
开发者ID:ghillairet,项目名称:gef-gwt,代码行数:46,代码来源:ScrolledComposite.java

示例10: DayViewer

import org.eclipse.swt.widgets.ScrollBar; //导入方法依赖的package包/类
public DayViewer(Composite parent, TreeTableColumnConfiguration configuration, final DayColumnProvider dayColumnProvider, IWorkbenchPartSite site) {
	composite = new DayComposite(parent, configuration);
	composite.addMouseAdapter(mouseAdapter);

	TreeTableComposite treeTableComposite = composite.getTreeTableComposite();
	final ScrollBar vBar = treeTableComposite.getTree().getVerticalBar();
	if (vBar != null) {
		vBar.setVisible(true);
	}
	treeTableViewer = new MergeTreeViewer(treeTableComposite, configuration, site) {

		private boolean initialized = false;
		
		@Override
		protected void inputChanged(Object input, Object oldInput) {
			initialized = false;
			super.inputChanged(input, oldInput);
			initialized = true;
		}
		
		@Override
		protected void createChildren(Widget widget) {
			if (initialized && (widget instanceof Tree)) {
				// SPF-11700 -- avoid repeated attempts to create the children of an empty tree
				return;
			}
			super.createChildren(widget);
		}

		@Override
		protected ViewerComparator getDefaultViewerComparator() {
			return DayDefaultViewerComparator.INSTANCE;
		}

		@Override
		public Comparator getDefaultComparator() {
			return DayDefaultComparator.INSTANCE;
		}
		
		@Override
		protected ViewerComparator getColumnComparator(ITreeTableColumn treeTableColumn, int sortDirection) {
			return new DayColumnComparator(treeTableColumn, sortDirection == SWT.UP);
		}
		
	};
	contentProvider = new DayContentProvider();
	treeTableViewer.setContentProvider(contentProvider);
	treeTableViewer.setLabelProvider(new DayLabelProvider());
	try {
		treeTableViewer.addFilter(dayFilter);
	} catch (Exception e) {
		LogUtil.error("failed to add the day filter", e);
	}
	totalViewer = new MergeTotalViewer(composite.getTotalComposite());
	composite.pack();
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:57,代码来源:DayViewer.java

示例11: layout

import org.eclipse.swt.widgets.ScrollBar; //导入方法依赖的package包/类
protected void layout(Composite composite, boolean flushCache) {
	if (inLayout)
		return;
	ScrolledComposite sc = (ScrolledComposite) composite;
	if (sc.content == null)
		return;
	ScrollBar hBar = sc.getHorizontalBar();
	ScrollBar vBar = sc.getVerticalBar();
	if (hBar != null) {
		if (hBar.getSize().y >= sc.getSize().y) {
			return;
		}
	}
	if (vBar != null) {
		if (vBar.getSize().x >= sc.getSize().x) {
			return;
		}
	}
	inLayout = true;
	Rectangle contentRect = sc.content.getBounds();
	if (!sc.alwaysShowScroll) {
		boolean hVisible = sc.needHScroll(contentRect, false);
		boolean vVisible = sc.needVScroll(contentRect, hVisible);
		if (!hVisible && vVisible)
			hVisible = sc.needHScroll(contentRect, vVisible);
		if (hBar != null)
			hBar.setVisible(hVisible);
		if (vBar != null)
			vBar.setVisible(vVisible);
	}
	Rectangle hostRect = sc.getClientArea();
	if (sc.expandHorizontal) {
		contentRect.width = Math.max(sc.minWidth, hostRect.width);
	}
	if (sc.expandVertical) {
		contentRect.height = Math.max(sc.minHeight, hostRect.height);
	}

	if (hBar != null) {
		hBar.setMaximum(contentRect.width);
		hBar.setThumb(Math.min(contentRect.width, hostRect.width));
		int hPage = contentRect.width - hostRect.width;
		int hSelection = hBar.getSelection();
		if (hSelection >= hPage) {
			if (hPage <= 0) {
				hSelection = 0;
				hBar.setSelection(0);
			}
			contentRect.x = -hSelection;
		}
	}

	if (vBar != null) {
		vBar.setMaximum(contentRect.height);
		vBar.setThumb(Math.min(contentRect.height, hostRect.height));
		int vPage = contentRect.height - hostRect.height;
		int vSelection = vBar.getSelection();
		if (vSelection >= vPage) {
			if (vPage <= 0) {
				vSelection = 0;
				vBar.setSelection(0);
			}
			contentRect.y = -vSelection;
		}
	}

	sc.content.setBounds(contentRect);
	inLayout = false;
}
 
开发者ID:ghillairet,项目名称:gef-gwt,代码行数:70,代码来源:ScrolledCompositeLayout.java


注:本文中的org.eclipse.swt.widgets.ScrollBar.setVisible方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。