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));
}
java类org.eclipse.swt.widgets.ScrollBar的实例源码
TGChordList.java 文件源码
项目:TuxGuitar-1.3.1-fork
阅读 41
收藏 0
点赞 0
评论 0
blackAction.java 文件源码
项目:Black
阅读 38
收藏 0
点赞 0
评论 0
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);
}
}
MyContentProposalAdapter.java 文件源码
项目:TranskribusSwtGui
阅读 31
收藏 0
点赞 0
评论 0
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);
}
MyContentProposalAdapter.java 文件源码
项目:TranskribusSwtGui
阅读 34
收藏 0
点赞 0
评论 0
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);
}
}
ImageAnalyzer.java 文件源码
项目:code
阅读 30
收藏 0
点赞 0
评论 0
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;
}
}
ImageAnalyzer.java 文件源码
项目:code
阅读 25
收藏 0
点赞 0
评论 0
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;
}
}
ImageAnalyzer.java 文件源码
项目:code
阅读 32
收藏 0
点赞 0
评论 0
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;
}
}
ImageAnalyzer.java 文件源码
项目:code
阅读 29
收藏 0
点赞 0
评论 0
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;
}
}
ColumnLayout.java 文件源码
项目:bts
阅读 43
收藏 0
点赞 0
评论 0
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;
}
SWTUtil.java 文件源码
项目:bts
阅读 30
收藏 0
点赞 0
评论 0
/**
* 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;
}
ChatConsoleController.java 文件源码
项目:raptor-chess-interface
阅读 32
收藏 0
点赞 0
评论 0
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);
}
}
}
ParameterExpandBar.java 文件源码
项目:gama
阅读 25
收藏 0
点赞 0
评论 0
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);
}
GridKeyboardHandler.java 文件源码
项目:jGrid
阅读 33
收藏 0
点赞 0
评论 0
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());
}
}
GridKeyboardHandler.java 文件源码
项目:jGrid
阅读 31
收藏 0
点赞 0
评论 0
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());
}
}
SWTUtil.java 文件源码
项目:APICloud-Studio
阅读 35
收藏 0
点赞 0
评论 0
/**
* 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;
}
ConsoleAutoScrollPageParticipant.java 文件源码
项目:APICloud-Studio
阅读 39
收藏 0
点赞 0
评论 0
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;
}
MethodsViewer.java 文件源码
项目:Eclipse-Postfix-Code-Completion
阅读 29
收藏 0
点赞 0
评论 0
/**
* 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());
}
}
}
SWTUtil.java 文件源码
项目:Eclipse-Postfix-Code-Completion
阅读 45
收藏 0
点赞 0
评论 0
/**
* 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;
}
JaretTable.java 文件源码
项目:translationstudio8
阅读 31
收藏 0
点赞 0
评论 0
/**
* Update the horiontal scrollbar.
*/
private void updateXScrollBar() {
if (Display.getCurrent() != null) {
Display.getCurrent().syncExec(new Runnable() {
public void run() {
ScrollBar scroll = getHorizontalBar();
// scroll may be null
if (scroll != null) {
_oldHorizontalScroll = -1; // make sure no optimization will be applied
scroll.setMinimum(0);
scroll.setMaximum(getTotalWidth() - getFixedColumnsWidth());
scroll.setThumb(getWidth() - getFixedColumnsWidth());
scroll.setIncrement(50); // increment for arrows
scroll.setPageIncrement(getWidth()); // page increment areas
}
}
});
}
}
JaretTable.java 文件源码
项目:translationstudio8
阅读 36
收藏 0
点赞 0
评论 0
/**
* Update the vertical scrollbar if present.
*/
public void updateYScrollBar() {
if (Display.getCurrent() != null) {
Display.getCurrent().syncExec(new Runnable() {
public void run() {
ScrollBar scroll = getVerticalBar();
// scroll may be null
if (scroll != null) {
_oldVerticalScroll = -1; // guarantee a clean repaint
scroll.setMinimum(0);
scroll.setMaximum(getTotalHeight() - getFixedRowsHeight());
int height = getHeight();
if (_tableRect != null) {
height = _tableRect.height;
}
scroll.setThumb(height); // - getFixedRowsHeight() - getHeaderHeight());
scroll.setIncrement(50); // increment for arrows
scroll.setPageIncrement(getHeight()); // page increment areas
scroll.setSelection(getAbsBeginYForRowIdx(_firstRowIdx) + _firstRowPixelOffset
+ getFixedRowsHeight());
}
}
});
}
}
ContentProposalAdapter.java 文件源码
项目:gef-gwt
阅读 35
收藏 0
点赞 0
评论 0
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);
}
ContentProposalAdapter.java 文件源码
项目:gef-gwt
阅读 29
收藏 0
点赞 0
评论 0
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);
}
}
ScrolledComposite.java 文件源码
项目:gef-gwt
阅读 34
收藏 0
点赞 0
评论 0
boolean needHScroll(Rectangle contentRect, boolean vVisible) {
ScrollBar hBar = getHorizontalBar();
if (hBar == null)
return false;
Rectangle hostRect = getBounds();
int border = getBorderWidth();
hostRect.width -= 2 * border;
ScrollBar vBar = getVerticalBar();
if (vVisible && vBar != null)
hostRect.width -= vBar.getSize().x;
if (!expandHorizontal && contentRect.width > hostRect.width)
return true;
if (expandHorizontal && minWidth > hostRect.width)
return true;
return false;
}
ScrolledComposite.java 文件源码
项目:gef-gwt
阅读 32
收藏 0
点赞 0
评论 0
boolean needVScroll(Rectangle contentRect, boolean hVisible) {
ScrollBar vBar = getVerticalBar();
if (vBar == null)
return false;
Rectangle hostRect = getBounds();
int border = getBorderWidth();
hostRect.height -= 2 * border;
ScrollBar hBar = getHorizontalBar();
if (hVisible && hBar != null)
hostRect.height -= hBar.getSize().y;
if (!expandVertical && contentRect.height > hostRect.height)
return true;
if (expandVertical && minHeight > hostRect.height)
return true;
return false;
}
ControlEditor.java 文件源码
项目:gef-gwt
阅读 29
收藏 0
点赞 0
评论 0
/**
* 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();
if (hBar != null)
hBar.addListener(SWT.Selection, scrollbarListener);
ScrollBar vBar = parent.getVerticalBar();
if (vBar != null)
vBar.addListener(SWT.Selection, scrollbarListener);
}
ControlEditor.java 文件源码
项目:gef-gwt
阅读 28
收藏 0
点赞 0
评论 0
/**
* Removes all associations between the Editor and the underlying composite.
* The composite and the editor Control are <b>not</b> disposed.
*/
public void dispose() {
if (parent != null && !parent.isDisposed()) {
for (int i = 0; i < EVENTS.length; i++) {
parent.removeListener(EVENTS[i], controlListener);
}
ScrollBar hBar = parent.getHorizontalBar();
if (hBar != null)
hBar.removeListener(SWT.Selection, scrollbarListener);
ScrollBar vBar = parent.getVerticalBar();
if (vBar != null)
vBar.removeListener(SWT.Selection, scrollbarListener);
}
parent = null;
editor = null;
hadFocus = false;
controlListener = null;
scrollbarListener = null;
}
MethodsViewer.java 文件源码
项目:Eclipse-Postfix-Code-Completion-Juno38
阅读 41
收藏 0
点赞 0
评论 0
/**
* 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());
}
}
}
SWTUtil.java 文件源码
项目:Eclipse-Postfix-Code-Completion-Juno38
阅读 39
收藏 0
点赞 0
评论 0
/**
* 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;
}
JaretTable.java 文件源码
项目:tmxeditor8
阅读 26
收藏 0
点赞 0
评论 0
/**
* Update the horiontal scrollbar.
*/
private void updateXScrollBar() {
if (Display.getCurrent() != null) {
Display.getCurrent().syncExec(new Runnable() {
public void run() {
ScrollBar scroll = getHorizontalBar();
// scroll may be null
if (scroll != null) {
_oldHorizontalScroll = -1; // make sure no optimization will be applied
scroll.setMinimum(0);
scroll.setMaximum(getTotalWidth() - getFixedColumnsWidth());
scroll.setThumb(getWidth() - getFixedColumnsWidth());
scroll.setIncrement(50); // increment for arrows
scroll.setPageIncrement(getWidth()); // page increment areas
}
}
});
}
}
JaretTable.java 文件源码
项目:tmxeditor8
阅读 25
收藏 0
点赞 0
评论 0
/**
* Update the vertical scrollbar if present.
*/
public void updateYScrollBar() {
if (Display.getCurrent() != null) {
Display.getCurrent().syncExec(new Runnable() {
public void run() {
ScrollBar scroll = getVerticalBar();
// scroll may be null
if (scroll != null) {
_oldVerticalScroll = -1; // guarantee a clean repaint
scroll.setMinimum(0);
scroll.setMaximum(getTotalHeight() - getFixedRowsHeight());
int height = getHeight();
if (_tableRect != null) {
height = _tableRect.height;
}
scroll.setThumb(height); // - getFixedRowsHeight() - getHeaderHeight());
scroll.setIncrement(50); // increment for arrows
scroll.setPageIncrement(getHeight()); // page increment areas
scroll.setSelection(getAbsBeginYForRowIdx(_firstRowIdx) + _firstRowPixelOffset
+ getFixedRowsHeight());
}
}
});
}
}