Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Extending or increaing horizontal scrollbar width(Horizontal scrollbar to canvas)
Extending or increaing horizontal scrollbar width [message #1007277] Tue, 05 February 2013 05:44 Go to next message
Chandrayya Kumarswamimath is currently offline Chandrayya Kumarswamimath
Messages: 20
Registered: August 2010
Location: Bangalore
Junior Member
I used the below code to combine two canvas.
package com.cavium.test.views;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class TwoCanvas {

    /**
     * @param args
     */
    public static void main(String[] args) {
	final Display display = new Display();
	final Shell shell = new Shell(display);
	shell.setLayout(new FillLayout());
	shell.setText("Canvas Test");

	Composite mainComp = new Composite(shell, SWT.NONE);
	GridLayout layout = new GridLayout(2, false);

	layout.horizontalSpacing = 0;

	mainComp.setLayout(layout);
	mainComp.setLayoutData(new GridData(SWT.BEGINNING, SWT.TOP, true, true));

	final Canvas hwCanvas = new Canvas(mainComp, SWT.NO_REDRAW_RESIZE | SWT.V_SCROLL);
	hwCanvas.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
	hwCanvas.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
	hwCanvas.setLayoutData(new GridData(SWT.BEGINNING, SWT.TOP, false, true));
	hwCanvas.getVerticalBar().setVisible(false);

	final Canvas traceCanvas = new Canvas(mainComp, SWT.NO_REDRAW_RESIZE | SWT.H_SCROLL | SWT.V_SCROLL);
	traceCanvas.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
	traceCanvas.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
	traceCanvas.setLayoutData(new GridData(SWT.BEGINNING, SWT.TOP, true, true));

	shell.open();
	while (!shell.isDisposed()) {
	    if (!display.readAndDispatch()) {
		display.sleep();
	    }
	}
	display.dispose();
    }
}


Is it possible to increase the width(length) of the horizontal scrollbar as attached here
  • Attachment: canvas.jpeg
    (Size: 10.38KB, Downloaded 70 times)
Re: Extending or increaing horizontal scrollbar width [message #1007409 is a reply to message #1007277] Tue, 05 February 2013 13:46 Go to previous messageGo to next message
Vasanthi Sathyanarayanan is currently offline Vasanthi Sathyanarayanan
Messages: 7
Registered: January 2013
Location: Bangalore, India
Junior Member
There seems to be a problem with your canvas griddata (both are given same position within the maincomp).

hwCanvas.setLayoutData(new GridData(SWT.BEGINNING, SWT.TOP, false, true));
traceCanvas.setLayoutData(new GridData(SWT.BEGINNING, SWT.TOP, true, true));

> So make sure of the canvas alignment. Now with your current code, the two canvas are overlapping. That is why you see issues with scrollbar. (you are seeing one canvas and scrollbar of other)
Once you align your canvas right, you will get scrollbar of length equal to length of canvas.

> The horizontal scrollbar and vertical scrollbar will take the size of the widget they belong to. All properties of scrollbar depends on the operating system.

> Also make sure you give a size to the canvas (otherwise canvas takes it default 64x64pixel size).


Regards,
Vasanthi
Re: Extending or increaing horizontal scrollbar width [message #1008396 is a reply to message #1007409] Tue, 12 February 2013 05:21 Go to previous message
Chandrayya Kumarswamimath is currently offline Chandrayya Kumarswamimath
Messages: 20
Registered: August 2010
Location: Bangalore
Junior Member
I made vertical scrollbar of first canvas invisible in order to combine two canvas. I think it is not related to allignment.
If horizontal scrollbar is made visible then it look like
index.php/fa/13377/0/ If it is hidden then it looks like index.php/fa/13376/0/ grabbing the extra space.
Is it possible to hide the horizontal scrollbar of first canvas and extend the width horizatal scrollbar of sedond cavas same as the main composite?
Previous Topic:GridData width hint hides field
Next Topic:loading a private key into the embedded browser widget
Goto Forum:
  


Current Time: Tue Sep 02 13:06:51 EDT 2014

Powered by FUDForum. Page generated in 0.06115 seconds