本文整理匯總了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());
}
}
}