本文整理匯總了Java中org.eclipse.swt.widgets.ScrollBar.setSelection方法的典型用法代碼示例。如果您正苦於以下問題:Java ScrollBar.setSelection方法的具體用法?Java ScrollBar.setSelection怎麽用?Java ScrollBar.setSelection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.swt.widgets.ScrollBar
的用法示例。
在下文中一共展示了ScrollBar.setSelection方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: pageUp
import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
private void pageUp() {
//
// Ensure there's an anchor.
//
ensureAnchorSet();
//
// Move the scrollbar down one page.
//
final ScrollBar verticalBar = grid.getVerticalBar();
verticalBar.setSelection(Math.max(verticalBar.getSelection() - verticalBar.getPageIncrement(), verticalBar.getMinimum()));
//
// Cause a repaint.
//
gridModel.fireChangeEvent();
//
// Move the anchor to the new page.
//
if (verticalBar.getSelection() != verticalBar.getMaximum()) {
final Row<T> row = gridModel.getRows().get(grid.getViewport().getFirstRowIndex());
gridModel.getSelectionModel().setAnchorElement(row.getElement());
}
}
示例2: pageDown
import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
private void pageDown() {
//
// Ensure there's an anchor.
//
ensureAnchorSet();
//
// Move the scrollbar down one page.
//
final ScrollBar verticalBar = grid.getVerticalBar();
verticalBar.setSelection(Math.min(verticalBar.getSelection() + verticalBar.getPageIncrement(), verticalBar.getMaximum()));
//
// Cause a repaint.
//
gridModel.fireChangeEvent();
//
// Move the anchor to the new page.
//
if (verticalBar.getSelection() != verticalBar.getMaximum()) {
final Row<T> row = gridModel.getRows().get(grid.getViewport().getFirstRowIndex());
gridModel.getSelectionModel().setAnchorElement(row.getElement());
}
}
示例3: restoreState
import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
/**
* Restores the state of the filter actions
* @param memento the memento
*/
public void restoreState(IMemento memento) {
fMemberFilterActionGroup.restoreState(memento);
getControl().setRedraw(false);
refresh();
getControl().setRedraw(true);
boolean showInherited= Boolean.valueOf(memento.getString(TAG_SHOWINHERITED)).booleanValue();
showInheritedMethods(showInherited);
boolean showDefiningTypes= Boolean.valueOf(memento.getString(TAG_SORTBYDEFININGTYPE)).booleanValue();
sortByDefiningType(showDefiningTypes);
ScrollBar bar= getTable().getVerticalBar();
if (bar != null) {
Integer vScroll= memento.getInteger(TAG_VERTICAL_SCROLL);
if (vScroll != null) {
bar.setSelection(vScroll.intValue());
}
}
}
示例4: scrollTable
import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
private void scrollTable( ScrollBar widget, KeyEvent event )
{
int newSelectionValue = widget.getSelection( );
if ( event.keyCode == SWT.ARROW_LEFT )
{
newSelectionValue -= TableCanvas.SCROLL_HORIZONTAL_STEP;
}
else if ( event.keyCode == SWT.ARROW_RIGHT )
{
newSelectionValue += TableCanvas.SCROLL_HORIZONTAL_STEP;
}
else if ( event.keyCode == SWT.PAGE_UP
|| event.keyCode == SWT.ARROW_UP )
{
newSelectionValue -= 1;
}
else if ( event.keyCode == SWT.PAGE_DOWN
|| event.keyCode == SWT.ARROW_DOWN )
{
newSelectionValue += 1;
}
if ( newSelectionValue < widget.getMinimum( ) )
{
newSelectionValue = widget.getMinimum( );
}
else if ( newSelectionValue > widget.getMaximum( ) )
{
newSelectionValue = widget.getMaximum( );
}
widget.setSelection( newSelectionValue );
Event newEvent = new Event( );
newEvent.widget = widget;
newEvent.type = SWT.Selection;
newEvent.data = event.data;
widget.notifyListeners( SWT.Selection, newEvent );
}
示例5: moveScrollTo
import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
public boolean moveScrollTo(TGMeasureImpl measure,ScrollBar xScroll,ScrollBar yScroll,TGRectangle area){
boolean success = false;
if( measure != null && measure.getTs() != null ){
int mX = Math.round(measure.getPosX());
int mY = Math.round(measure.getPosY());
int mWidth = Math.round(measure.getWidth(this.tablature.getViewLayout()));
int mHeight = Math.round(measure.getTs().getSize());
int marginWidth = Math.round(this.tablature.getViewLayout().getFirstMeasureSpacing());
int marginHeight = Math.round(this.tablature.getViewLayout().getFirstTrackSpacing());
boolean forceRedraw = false;
//Solo se ajusta si es necesario
//si el largo del compas es mayor al de la pantalla. nunca se puede ajustar a la medida.
if( mX < 0 || ( (mX + mWidth ) > area.getWidth() && (area.getWidth() >= mWidth + marginWidth || mX > marginWidth) ) ){
xScroll.setSelection((this.scrollX + mX) - marginWidth );
success = true;
}
//Solo se ajusta si es necesario
//si el alto del compas es mayor al de la pantalla. nunca se puede ajustar a la medida.
if( mY < 0 || ( (mY + mHeight ) > area.getHeight() && (area.getHeight() >= mHeight + marginHeight || mY > marginHeight) ) ){
yScroll.setSelection( (this.scrollY + mY) - marginHeight );
success = true;
}
if(!success){
// Si la seleccion "real" del scroll es distinta a la anterior, se fuerza el redraw
forceRedraw = (this.scrollX != xScroll.getSelection() || this.scrollY != yScroll.getSelection());
}
if(forceRedraw || success){
redraw();
}
}
return success;
}
示例6: 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;
}
}
示例7: refresh
import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
private void refresh(Image reportImage, String errorMessage, JRPrintPage page) {
if (this.reportImage != null)
this.reportImage.dispose();
if (isDisposed())
return;
this.reportImage = reportImage;
this.errorMessage = errorMessage;
this.page = page;
setCursor(null);
setToolTipText(null);
currentLink = null;
initHypelinks();
ScrollBar hBar = getHorizontalBar();
ScrollBar vBar = getVerticalBar();
hBar.setSelection(0);
vBar.setSelection(0);
if (!updatingScrollbars)
try {
updatingScrollbars = true;
Rectangle b = getContentBounds();
boolean hVisible = hasHScroll(b.width, false);
boolean vVisible = hasVScroll(b.height, hVisible);
if (!hVisible && vVisible)
hVisible = hasHScroll(b.width, vVisible);
Point size = getSize();
Rectangle clientArea = getClientArea();
setupScrollBar(hBar, hVisible, clientArea.width, b.width, size.x);
setupScrollBar(vBar, vVisible, clientArea.height, b.height, size.y);
} finally {
updatingScrollbars = false;
}
redraw();
}
示例8: 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);
}
}
示例9: createPartControl
import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
@Override
public void createPartControl(final Composite parent) {
_pc = new PixelConverter(parent);
// define all columns for the viewer
_columnManager = new ColumnManager(this, _state);
_columnManager.setIsCategoryAvailable(true);
defineAllColumns(parent);
createUI(parent);
createActions();
fillViewMenu();
addPartListener();
addPostSelectionListener();
addTourEventListener();
addPrefListener();
// set selection provider
getSite().setSelectionProvider(_postSelectionProvider = new PostSelectionProvider(ID));
_tourViewer.setInput(_rootItem = new TVICatalogRootItem(this));
restoreState();
// move the horizontal scrollbar to the left border
final ScrollBar horizontalBar = _tourViewer.getTree().getHorizontalBar();
if (horizontalBar != null) {
horizontalBar.setSelection(0);
}
}
示例10: 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;
}
}
示例11: 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;
}
}
示例12: handleEvent
import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
@Override
public void handleEvent(Event event) {
ScrollBar hBar = getHorizontalBar();
int selection = hBar.getSelection();
selection -= 5 * event.count;
hBar.setSelection(selection);
updateDaysChildren();
}
示例13: clear
import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
/**
* Remove the old composites from the scrolled composite and clear the selection.
*/
private void clear() {
Composite fillableComposite = list.getFillableComposite();
if ((fillableComposite != null) && !fillableComposite.isDisposed()) {
for (Control child : fillableComposite.getChildren()) {
child.dispose();
}
}
selectedLabel = null;
ScrollBar scroll = list.getVerticalBar();
scroll.setSelection(scroll.getMinimum());
scroll = list.getHorizontalBar();
scroll.setSelection(scroll.getMinimum());
list.setMinSize(SWT.DEFAULT, SWT.DEFAULT);
}
示例14: reveal
import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
/**
* Reveals an item, scrolling vertically if necessary.
*
* @param item Item to reveal
*/
public void reveal(DetailTreeItem item) {
// Clear hover item
hoverItem = null;
// If item is not revealed
if (!item.isRevealed()) {
// Expand all parent items
DetailTreeItem parent = item.getParent();
while (parent != null) {
parent.expand();
parent = parent.getParent();
}
}
ScrollBar vScrollBar = getVerticalBar();
if (vScrollBar != null) {
Rectangle clientArea = getClientArea();
int itemExtent = item.getArea().y + item.getArea().height;
// Bottom of item is below visible area
if (itemExtent > clientArea.height) {
scrollOffset.y += itemExtent - clientArea.height;
vScrollBar.setSelection(scrollOffset.y);
redraw();
}
// Top of item is above visible area
else if (item.getArea().y < 0) {
scrollOffset.y += item.getArea().y;
vScrollBar.setSelection(scrollOffset.y);
redraw();
}
}
}
示例15: 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);
}
}