org.eclipse.swt.widgets.Scrollable Java Examples

The following examples show how to use org.eclipse.swt.widgets.Scrollable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ScrollView.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Convert overview coordinates to global coordinates.
 *
 * @param loc
 *            the control reference
 * @param x
 *            The x coordinate to convert
 * @param y
 *            The y coordinate to convert
 * @return The new converted Point
 */
protected Point toGlobalCoordinates(Control loc, int x, int y) {
    Point p = new Point(x, y);
    for (Control c = loc; c != null; c = c.getParent()) {
        // control might have client area with 'decorations'
        int trimX = 0, trimY = 0;
        // other kind of widget with trimming ??
        if (c instanceof Scrollable) {
            Scrollable s = (Scrollable) c;
            Rectangle rr = s.getClientArea();
            Rectangle tr = s.computeTrim(rr.x, rr.y, rr.width, rr.height);
            trimX = rr.x - tr.x;
            trimY = rr.y - tr.y;
        }
        p.x += c.getLocation().x + trimX;
        p.y += c.getLocation().y + trimY;
    }
    return p;
}
 
Example #2
Source File: GridColumnLayout.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void setColumnWidths(Scrollable tableTree, int[] widths) {
	GridColumn[] columns = ((Grid) tableTree).getColumns();
	for (int i = 0; i < widths.length; i++) {
		columns[i].setWidth(widths[i]);
	}
}
 
Example #3
Source File: ScrollingSmoother.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @param c2
 * @param movement
 */
public ScrollingSmoother(final Scrollable c2, IMovement movement) {
	this.component = c2;
	verticalScrollBar = c2.getVerticalBar();
	horizontalScrollBar = c2.getHorizontalBar();
	this.movement = movement;
}
 
Example #4
Source File: AbstractPageFlowLayout.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected Result getReportBounds( Rectangle reportSize )
{
	Result revValue = new Result( );
	revValue.reportSize.y = MINTOPSPACE;
	revValue.reportSize.width = reportSize.width;
	revValue.reportSize.height = reportSize.height;

	EditPartViewer viewer = owner.getViewer( );
	Scrollable control = viewer == null ? null : (Scrollable)viewer.getControl( );
	Rectangle containerSize = control == null ? new Rectangle( )
			: new Rectangle( control.getClientArea( ) );

	PrecisionDimension dim = new PrecisionDimension( containerSize.width,
			containerSize.height );

	double scale = getZoomManager( ).getZoom( );
	dim.performScale( 1 / scale );
	if ( dim.width > reportSize.width + MINLEFTSPACE + MINRIGHTSPACE )
	{
		revValue.reportSize.x = ( dim.width - reportSize.width ) / 2;
		revValue.rightSpace = ( dim.width - reportSize.width ) / 2;
	}
	else
	{
		revValue.reportSize.x = MINLEFTSPACE;
		revValue.rightSpace = MINRIGHTSPACE;
	}

	if ( dim.height > reportSize.height + MINTOPSPACE + MINBOTTOMSPACE )
	{
		revValue.bottomSpace = dim.height - reportSize.height
				- revValue.reportSize.y;
	}
	else
	{
		revValue.bottomSpace = MINBOTTOMSPACE;
	}

	return revValue;
}
 
Example #5
Source File: GridColumnLayout.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected int getColumnCount(Scrollable tableTree) {
	return ((Grid) tableTree).getColumnCount();
}
 
Example #6
Source File: GridColumnLayout.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected ColumnLayoutData getLayoutData(Scrollable tableTree,
		int columnIndex) {
	GridColumn column = ((Grid) tableTree).getColumn(columnIndex);
	return (ColumnLayoutData) column.getData(LAYOUT_DATA);
}
 
Example #7
Source File: ErrorTraceTreeViewer.java    From tlaplus with MIT License 4 votes vote down vote up
TraceDisplayResizer(final Tree resizingTree) {
	tree = resizingTree;
	treeParentComponent = (Scrollable)tree.getParent();
	columns = new TreeColumn[COLUMN_TEXTS.length];
}
 
Example #8
Source File: ScrollbarHandler.java    From depan with Apache License 2.0 4 votes vote down vote up
public ScrollbarHandler(Scrollable view, GLScene scene) {
  this.view = view;
  this.scene = scene;
  this.vertBar = view.getVerticalBar();
  this.horizBar = view.getHorizontalBar();
}
 
Example #9
Source File: ControlThemer.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
protected void addSelectionColorOverride()
{
	if (controlIsDisposed())
	{
		return;
	}
	// Override selection color to match what is set in theme
	selectionOverride = new Listener()
	{
		public void handleEvent(Event event)
		{
			if (!invasiveThemesEnabled())
			{
				return;
			}
			GC gc = event.gc;
			Color oldBackground = gc.getBackground();
			if ((event.detail & SWT.SELECTED) != 0)
			{
				Scrollable scrollable = (Scrollable) event.widget;
				Rectangle clientArea = scrollable.getClientArea();

				gc.setBackground(getSelection());
				// The +2 on width is for Linux, since clientArea begins at [-2,-2] and
				// without it we don't properly color full width (see broken coloring when scrolling horizontally)
				gc.fillRectangle(clientArea.x, event.y, clientArea.width + 2, event.height);

				event.detail &= ~SWT.SELECTED;
				event.detail &= ~SWT.BACKGROUND;

				gc.setBackground(oldBackground);
			}
			else
			{
				// Draw normal background color. This seems to only be necessary for some variants of Linux,
				// and is the correct way to force custom painting of background when setBackground() doesn't work
				// properly.
				if (!isWindows && !isMacOSX)
				{
					Color controlBG = control.getBackground();
					if (controlBG.getRGB().equals(oldBackground.getRGB()))
					{
						gc.setBackground(getBackground());
						gc.fillRectangle(event.x, event.y, event.width, event.height);
						event.detail &= ~SWT.BACKGROUND;
						gc.setBackground(oldBackground);
					}
				}
			}

			// force foreground color. Otherwise on dark themes we get black FG (all the time on Win, on
			// non-focus for Mac)
			gc.setForeground(getForeground());
		}
	};
	getControl().addListener(SWT.EraseItem, selectionOverride);
}
 
Example #10
Source File: ClientAreaResizeCommand.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
public ClientAreaResizeCommand(Scrollable scrollable) {
	super();
	this.scrollable = scrollable;
}
 
Example #11
Source File: ClientAreaResizeCommand.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
public Scrollable getScrollable() {
	return scrollable;
}
 
Example #12
Source File: ClientAreaResizeCommand.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
public ClientAreaResizeCommand(Scrollable scrollable) {
	super();
	this.scrollable = scrollable;
}
 
Example #13
Source File: ClientAreaResizeCommand.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
public Scrollable getScrollable() {
	return scrollable;
}
 
Example #14
Source File: ScrollingSmoother.java    From nebula with Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Create a Scrolling Smoother instance over a scrollable widget. This
 * effect can then be activated using
 * {@link ScrollingSmoother#smoothControl(boolean)}.
 * 
 * @see ScrollingSmoother#smoothControl(boolean)
 * 
 * @param c2
 * @param movement
 */
public ScrollingSmoother(final Scrollable c2, IMovement movement) {
	this.component = c2;
	verticalScrollBar = c2.getVerticalBar();
	horizontalScrollBar = c2.getHorizontalBar();
	this.movement = movement;
}
 
Example #15
Source File: ScrollingSmoother.java    From nebula with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Create a Scrolling Smoother instance over a scrollable widget. This
 * effect can then be activated using
 * {@link ScrollingSmoother#smoothControl(boolean)}.
 * 
 * @see ScrollingSmoother#smoothControl(boolean)
 * 
 * @param c2
 * @param movement
 * @param duration
 */
public ScrollingSmoother(final Scrollable c2, IMovement movement,
		int duration) {
	this(c2, movement);
	this.duration = duration;
}