本文整理汇总了Java中org.eclipse.swt.widgets.ScrollBar类的典型用法代码示例。如果您正苦于以下问题:Java ScrollBar类的具体用法?Java ScrollBar怎么用?Java ScrollBar使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ScrollBar类属于org.eclipse.swt.widgets包,在下文中一共展示了ScrollBar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateScroll
import org.eclipse.swt.widgets.ScrollBar; //导入依赖的package包/类
public void updateScroll(){
Rectangle rect = this.composite.getBounds();
Rectangle client = this.composite.getClientArea();
ScrollBar vBar = this.composite.getVerticalBar();
vBar.setMaximum(Math.round(this.height));
vBar.setThumb(Math.min(rect.height, client.height));
}
示例2: setSlider
import org.eclipse.swt.widgets.ScrollBar; //导入依赖的package包/类
public void setSlider(Slider slider) {
if (b.text != null && !b.text.isDisposed()) {
sliderListener = new Listener() {
@Override
public void handleEvent(Event arg0) {
// TODO Auto-generated method stub
if (slider != null && !slider.isDisposed()) {
ScrollBar vb = b.text.getVerticalBar();
slider.setValues(vb.getSelection(), vb.getMinimum(), vb.getMaximum(), vb.getThumb(),
vb.getIncrement(), vb.getPageIncrement());
}
}
};
b.text.addListener(SWT.Paint, sliderListener);
}
}
示例3: installListeners
import org.eclipse.swt.widgets.ScrollBar; //导入依赖的package包/类
void installListeners() {
// Listeners on this popup's table and scroll bar
proposalTable.addListener(SWT.FocusOut, this);
ScrollBar scrollbar = proposalTable.getVerticalBar();
if (scrollbar != null) {
scrollbar.addListener(SWT.Selection, this);
}
// Listeners on this popup's shell
getShell().addListener(SWT.Deactivate, this);
getShell().addListener(SWT.Close, this);
// Listeners on the target control
control.addListener(SWT.MouseDoubleClick, this);
control.addListener(SWT.MouseDown, this);
control.addListener(SWT.Dispose, this);
control.addListener(SWT.FocusOut, this);
// Listeners on the target control's shell
Shell controlShell = control.getShell();
controlShell.addListener(SWT.Move, this);
controlShell.addListener(SWT.Resize, this);
}
示例4: removeListeners
import org.eclipse.swt.widgets.ScrollBar; //导入依赖的package包/类
void removeListeners() {
if (isValid()) {
proposalTable.removeListener(SWT.FocusOut, this);
ScrollBar scrollbar = proposalTable.getVerticalBar();
if (scrollbar != null) {
scrollbar.removeListener(SWT.Selection, this);
}
getShell().removeListener(SWT.Deactivate, this);
getShell().removeListener(SWT.Close, this);
}
if (control != null && !control.isDisposed()) {
control.removeListener(SWT.MouseDoubleClick, this);
control.removeListener(SWT.MouseDown, this);
control.removeListener(SWT.Dispose, this);
control.removeListener(SWT.FocusOut, this);
Shell controlShell = control.getShell();
controlShell.removeListener(SWT.Move, this);
controlShell.removeListener(SWT.Resize, this);
}
}
示例5: scrollHorizontally
import org.eclipse.swt.widgets.ScrollBar; //导入依赖的package包/类
void scrollHorizontally(ScrollBar scrollBar) {
if (image == null) {
return;
}
Rectangle canvasBounds = imageCanvas.getClientArea();
int width = Math.round(imageData.width * xscale);
int height = Math.round(imageData.height * yscale);
if (width > canvasBounds.width) {
// Only scroll if the image is bigger than the canvas.
int x = -scrollBar.getSelection();
if (x + width < canvasBounds.width) {
// Don't scroll past the end of the image.
x = canvasBounds.width - width;
}
imageCanvas.scroll(x, iy, ix, iy, width, height, false);
ix = x;
}
}
示例6: scrollVertically
import org.eclipse.swt.widgets.ScrollBar; //导入依赖的package包/类
void scrollVertically(ScrollBar scrollBar) {
if (image == null) {
return;
}
Rectangle canvasBounds = imageCanvas.getClientArea();
int width = Math.round(imageData.width * xscale);
int height = Math.round(imageData.height * yscale);
if (height > canvasBounds.height) {
// Only scroll if the image is bigger than the canvas.
int y = -scrollBar.getSelection();
if (y + height < canvasBounds.height) {
// Don't scroll past the end of the image.
y = canvasBounds.height - height;
}
imageCanvas.scroll(ix, y, ix, iy, width, height, false);
iy = y;
}
}
示例7: computeTrim
import org.eclipse.swt.widgets.ScrollBar; //导入依赖的package包/类
private int computeTrim(Rectangle area, Table table, int tableWidth) {
Point preferredSize= computeTableSize(table, area.width, area.height);
int trim;
if (tableWidth > 1) {
trim= tableWidth - table.getClientArea().width;
} else {
// initially, the table has no extend and no client area - use the border with
// plus some padding as educated guess
trim= 2 * table.getBorderWidth() + 1 ;
}
if (preferredSize.y > area.height) {
// Subtract the scrollbar width from the total column width
// if a vertical scrollbar will be required, but is not currently showing
// (in which case it is already subtracted above)
ScrollBar vBar= table.getVerticalBar();
if (!vBar.isVisible()) {
Point vBarSize= vBar.getSize();
trim += vBarSize.x;
}
}
return trim;
}
示例8: getShell
import org.eclipse.swt.widgets.ScrollBar; //导入依赖的package包/类
/**
* Returns the shell for the given widget. If the widget doesn't represent a
* SWT object that manage a shell, <code>null</code> is returned.
*
* @param widget
* the widget
*
* @return the shell for the given widget
*/
public static Shell getShell(Widget widget) {
if (widget instanceof Control)
return ((Control) widget).getShell();
if (widget instanceof Caret)
return ((Caret) widget).getParent().getShell();
if (widget instanceof DragSource)
return ((DragSource) widget).getControl().getShell();
if (widget instanceof DropTarget)
return ((DropTarget) widget).getControl().getShell();
if (widget instanceof Menu)
return ((Menu) widget).getParent().getShell();
if (widget instanceof ScrollBar)
return ((ScrollBar) widget).getParent().getShell();
return null;
}
示例9: smartScroll
import org.eclipse.swt.widgets.ScrollBar; //导入依赖的package包/类
protected void smartScroll(boolean force) {
ScrollBar scrollbar = chatConsole.inputText.getVerticalBar();
if (scrollbar != null
&& scrollbar.isVisible()
&& getPreferences().getBoolean(
PreferenceKeys.CHAT_IS_SMART_SCROLL_ENABLED)) {
if (force) {
setAutoScrolling(true);
}
else if (scrollbar.getMaximum() == scrollbar.getSelection()
+ scrollbar.getThumb()) {
setAutoScrolling(true);
} else {
setAutoScrolling(false);
}
}
}
示例10: 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);
}
示例11: 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());
}
}
示例12: 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());
}
}
示例13: getShell
import org.eclipse.swt.widgets.ScrollBar; //导入依赖的package包/类
/**
* Returns the shell for the given widget. If the widget doesn't represent a SWT object that manage a shell,
* <code>null</code> is returned.
*
* @return the shell for the given widget
*/
public static Shell getShell(Widget widget)
{
if (widget instanceof Control)
return ((Control) widget).getShell();
if (widget instanceof Caret)
return ((Caret) widget).getParent().getShell();
if (widget instanceof DragSource)
return ((DragSource) widget).getControl().getShell();
if (widget instanceof DropTarget)
return ((DropTarget) widget).getControl().getShell();
if (widget instanceof Menu)
return ((Menu) widget).getParent().getShell();
if (widget instanceof ScrollBar)
return ((ScrollBar) widget).getParent().getShell();
return null;
}
示例14: dispose
import org.eclipse.swt.widgets.ScrollBar; //导入依赖的package包/类
public void dispose()
{
if (textWidget != null && !textWidget.isDisposed())
{
textWidget.removeListener(SWT.MouseDown, listener);
textWidget.removeListener(SWT.MouseMove, listener);
textWidget.removeListener(SWT.MouseUp, listener);
textWidget.removeListener(SWT.KeyDown, listener);
textWidget.removeListener(SWT.KeyUp, listener);
textWidget.removeListener(SWT.Resize, listener);
ScrollBar vBar = textWidget.getVerticalBar();
if (vBar != null && !vBar.isDisposed())
{
vBar.removeListener(SWT.Selection, listener);
}
}
textWidget = null;
listener = null;
}
示例15: 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());
}
}
}