本文整理了Java中org.eclipse.swt.widgets.ScrollBar
类的一些代码示例,展示了ScrollBar
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ScrollBar
类的具体详情如下:
包路径:org.eclipse.swt.widgets.ScrollBar
类名称:ScrollBar
[英]Instances of this class are selectable user interface objects that represent a range of positive, numeric values.
At any given moment, a given scroll bar will have a single 'selection' that is considered to be its value, which is constrained to be within the range of values the scroll bar represents (that is, between its minimum and maximum values).
Typically, scroll bars will be made up of five areas:
HORIZONTAL
(which have a left facing button for decrementing the value and a right facing button for incrementing it) or VERTICAL
(which have an upward facing button for decrementing the value and a downward facing buttons for incrementing it).On some platforms, the size of the scroll bar's thumb can be varied relative to the magnitude of the range of values it represents (that is, relative to the difference between its maximum and minimum values). Typically, this is used to indicate some proportional value such as the ratio of the visible area of a document to the total amount of space that it would take to display it. SWT supports setting the thumb size even if the underlying platform does not, but in this case the appearance of the scroll bar will not change.
Scroll bars are created by specifying either H_SCROLL
, V_SCROLL
or both when creating a Scrollable
. They are accessed from the Scrollable
using getHorizontalBar
and getVerticalBar
.
Note: Scroll bars are not Controls. On some platforms, scroll bars that appear as part of some standard controls such as a text or list have no operating system resources and are not children of the control. For this reason, scroll bars are treated specially. To create a control that looks like a scroll bar but has operating system resources, use Slider
.
Styles: HORIZONTAL, VERTICAL Events: Selection
Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
IMPORTANT: This class is not intended to be subclassed.
[中]此类的实例是可选择的用户界面对象,表示一系列正值和数值。
在任何给定时刻,给定的滚动条都会有一个被视为其值的“选择”,该值被限制在滚动条表示的值范围内(即,在其最小值和最大值之间)。
通常,滚动条由五个区域组成:
1.用于递减值的箭头按钮
1.页面递减区,用于将值递减更大的量
1.用于通过鼠标拖动修改值的thumb
1.一个页面增量区域,用于将值增加更大的量
1.用于增加值的箭头按钮
根据其样式,滚动条可以是HORIZONTAL
(有一个用于递减值的左向按钮和一个用于递增值的右向按钮)或VERTICAL
(有一个用于递减值的向上按钮和一个用于递增值的向下按钮)。
在某些平台上,滚动条拇指的大小可以根据其所代表的值范围的大小(即,相对于其最大值和最小值之间的差值)而变化。通常,这用于指示某些比例值,例如文档的可见区域与显示文档所需的总空间的比率。即使底层平台不支持,SWT也支持设置拇指大小,但在这种情况下,滚动条的外观不会改变。
创建Scrollable
时,通过指定H_SCROLL
、V_SCROLL
或两者来创建滚动条。使用getHorizontalBar
和getVerticalBar
从Scrollable
访问它们。
注意:滚动条不是控件。在某些平台上,作为某些标准控件(如文本或列表)的一部分出现的滚动条没有操作系统资源,也不是该控件的子控件。由于这个原因,滚动条被特别处理。要创建一个看起来像滚动条但有操作系统资源的控件,请使用Slider
。
样式:水平、垂直事件:选择
注:只能指定水平和垂直两种样式中的一种。
重要提示:这个类不是子类。
代码示例来源:origin: pentaho/pentaho-kettle
protected int getTableWidth( Table table ) {
int width = table.getSize().x - 2;
if ( table.getVerticalBar() != null && table.getVerticalBar().isVisible() ) {
width -= table.getVerticalBar().getSize().x;
}
return width;
}
代码示例来源:origin: pentaho/pentaho-kettle
sbHorizontal.setSelection( 0 );
sbHorizontal.setVisible( false );
} else {
offsetx = -sbHorizontal.getSelection();
sbHorizontal.setVisible( true );
sbHorizontal.setMaximum( maxdrawn.width );
sbHorizontal.setMinimum( 0 );
sbHorizontal.setPageIncrement( size_widget.width );
sbHorizontal.setIncrement( 10 );
sbVertical.setSelection( 0 );
sbVertical.setVisible( false );
} else {
offsety = sbVertical.getSelection();
sbVertical.setVisible( true );
sbVertical.setMaximum( maxdrawn.height );
sbVertical.setMinimum( 0 );
sbVertical.setPageIncrement( size_widget.height );
sbVertical.setIncrement( 10 );
代码示例来源:origin: pentaho/pentaho-kettle
hori.addSelectionListener( new SelectionAdapter() {
public void widgetSelected( SelectionEvent e ) {
redraw();
vert.addSelectionListener( new SelectionAdapter() {
public void widgetSelected( SelectionEvent e ) {
redraw();
hori.setThumb( 100 );
vert.setThumb( 100 );
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.s390x
void setScrollBar(ScrollBar bar, int clientArea, int maximum, int margin) {
int inactive = 1;
if (clientArea < maximum) {
bar.setMaximum(maximum - margin);
bar.setThumb(clientArea - margin);
bar.setPageIncrement(clientArea - margin);
if (!alwaysShowScroll) bar.setVisible(true);
} else if (bar.getThumb() != inactive || bar.getMaximum() != inactive) {
bar.setValues(bar.getSelection(), bar.getMinimum(), inactive, inactive, bar.getIncrement(), inactive);
}
}
/**
代码示例来源:origin: com.google.code.maven-play-plugin.org.xhtmlrenderer/core-renderer
/**
* Update the scrollbars
*
* @return true if we need to relayout the whole thing
*/
protected boolean updateScrollBars() {
Point size = getScreenSize();
ScrollBar hBar = getHorizontalBar(), vBar = getVerticalBar();
boolean needRelayout = false;
hBar.setMaximum(_drawnSize.x);
hBar.setThumb(Math.min(_drawnSize.x, size.x));
hBar.setIncrement(15); // TODO something meaningful ?
hBar.setPageIncrement(size.x);
boolean visible = !(_origin.x == 0 && _drawnSize.x <= size.x);
hBar.setVisible(visible);
size = getScreenSize();
vBar.setMaximum(_drawnSize.y);
vBar.setThumb(Math.min(_drawnSize.y, size.y));
vBar.setIncrement(15); // TODO line height here
vBar.setPageIncrement(size.y);
visible = !(_origin.y == 0 && _drawnSize.y <= size.y);
if (!isPrint() && vBar.isVisible() != visible) {
needRelayout = true;
}
vBar.setVisible(visible);
return needRelayout;
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
@Override
int getVScrollBarWidth() {
int result = 0;
if( hasVScrollBar() ) {
result = getVerticalBar().getSize().x;
}
return result;
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples
/**
* 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);
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public int getSelection() {
return scrollBar.getSelection();
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.s390x
/**
* Returns <code>true</code> if the receiver is visible and all
* of the receiver's ancestors are visible and <code>false</code>
* otherwise.
*
* @return the receiver's visibility state
*
* @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>
*
* @see #getVisible
*/
public boolean isVisible () {
checkWidget ();
return getVisible () && getParent ().isVisible ();
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
private static void setScrollBarSelection( ScrollBar scrollBar, int selection ) {
if( scrollBar != null ) {
scrollBar.setSelection( selection );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
vert = canvas.getVerticalBar();
hori.addSelectionListener( new SelectionAdapter() {
public void widgetSelected( SelectionEvent e ) {
redraw();
vert.addSelectionListener( new SelectionAdapter() {
public void widgetSelected( SelectionEvent e ) {
redraw();
hori.setThumb( 100 );
vert.setThumb( 100 );
hori.setVisible( true );
vert.setVisible( true );
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
int getVScrollBarWidth() {
int result = 0;
if( verticalBar != null && verticalBar.getVisible() ) {
result = verticalBar.getSize().x;
}
return result;
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.forms
private void initializeScrollBars() {
ScrollBar hbar = getHorizontalBar();
if (hbar != null) {
hbar.setIncrement(H_SCROLL_INCREMENT);
}
ScrollBar vbar = getVerticalBar();
if (vbar != null) {
vbar.setIncrement(V_SCROLL_INCREMENT);
}
FormUtil.updatePageIncrement(this);
}
代码示例来源:origin: rinde/RinSim
void updateScrollbars(boolean adaptToScrollbar) {
final Rectangle rect = image.getBounds();
final Rectangle client = canvas.getClientArea();
hBar.setMaximum(rect.width);
vBar.setMaximum(rect.height);
hBar.setThumb(Math.min(rect.width, client.width));
vBar.setThumb(Math.min(rect.height, client.height));
if (!adaptToScrollbar) {
final org.eclipse.swt.graphics.Point center = getCenteredOrigin();
hBar.setSelection(-center.x);
vBar.setSelection(-center.y);
}
}
代码示例来源:origin: org.eclipse/org.eclipse.compare
public ImageCanvas(Composite parent, int style) {
super(parent, style | SWT.H_SCROLL | SWT.V_SCROLL);
ScrollBar sb= getHorizontalBar();
sb.setIncrement(20);
sb.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
repaint();
}
});
sb= getVerticalBar();
sb.setIncrement(20);
sb.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
repaint();
}
});
addListener(SWT.Resize, new Listener() {
public void handleEvent(Event e) {
updateScrollbars();
}
});
addListener(SWT.Paint, new Listener() {
public void handleEvent(Event event) {
paint(event.gc);
}
});
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.ppc
/**
* Returns <code>true</code> if the receiver is enabled and all
* of the receiver's ancestors are enabled, and <code>false</code>
* otherwise. A disabled control is typically not selectable from the
* user interface and draws with an inactive or "grayed" look.
*
* @return the receiver's enabled state
*
* @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>
*
* @see #getEnabled
*/
public boolean isEnabled () {
checkWidget ();
return getEnabled () && getParent ().getEnabled ();
}
代码示例来源:origin: org.eclipse/org.eclipse.ajdt.ui
public void controlResized(ControlEvent e) {
Rectangle clientArea = fScrolledComposite.getClientArea();
ScrollBar verticalBar= fScrolledComposite.getVerticalBar();
verticalBar.setIncrement(VERTICAL_SCROLL_INCREMENT);
verticalBar.setPageIncrement(clientArea.height - verticalBar.getIncrement());
ScrollBar horizontalBar= fScrolledComposite.getHorizontalBar();
horizontalBar.setIncrement(HORIZONTAL_SCROLL_INCREMENT);
horizontalBar.setPageIncrement(clientArea.width - horizontalBar.getIncrement());
}
});
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.aix.ppc
checkWidget ();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.Selection,typedListener);
addListener (SWT.DefaultSelection,typedListener);
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
/**
* Creates a ControlEditor for the specified Composite.
*
* @param parent the Composite above which this editor will be displayed
*/
public ControlEditor( Composite parent ) {
this.parent = parent;
controlListener = new Listener() {
public void handleEvent( Event e ) {
layout();
}
};
for( int i = 0; i < EVENTS.length; i++ ) {
parent.addListener( EVENTS[ i ], controlListener );
}
scrollbarListener = new Listener() {
public void handleEvent( Event e ) {
scroll( e );
}
};
ScrollBar hBar = parent.getHorizontalBar();
ScrollBar vBar = parent.getVerticalBar();
if( hBar != null ) {
hBar.addListener( SWT.Selection, scrollbarListener );
}
if( vBar != null ) {
vBar.addListener( SWT.Selection, scrollbarListener );
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.s390x
void handleScroll(Event event) {
ScrollBar scrollBar = (ScrollBar)event.widget;
Control scrollableParent = scrollBar.getParent();
if (scrollableParent.equals(list)) return;
if (isParentScrolling(scrollableParent)) dropDown(false);
}
/**
内容来源于网络,如有侵权,请联系作者删除!