| Extending or increaing horizontal scrollbar width [message #1007277] |
Tue, 05 February 2013 05:44  |
Chandrayya Kumarswamimath Messages: 9 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 25 times)
|
|
|
| Re: Extending or increaing horizontal scrollbar width [message #1007409 is a reply to message #1007277] |
Tue, 05 February 2013 13:46   |
 |
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.13082 seconds