canvas scrolling [message #451035] |
Tue, 22 February 2005 04:38  |
Eclipse User |
|
|
|
Originally posted by: robbiec.gmail.com
i have a canvas in a view, and have a scroll bar as shown below
it does not scroll properly though, areas outside the original viewable
area are not drawn, and if i scroll back some of the drawing has been
erased
how do i ensure the the canvas is redrawn properly
final Point origin = new Point (0, 0);
final ScrollBar horizontalBar = canvas.getHorizontalBar();
horizontalBar.addListener(SWT.Selection, new Listener()
{
public void handleEvent(Event event)
{
int hSelection = horizontalBar.getSelection();
int destX = -hSelection - origin.x;
org.eclipse.swt.graphics.Rectangle rect = canvas.getBounds();
canvas.scroll(destX,0,0,0,rect.width, rect.height, true);
origin.x = -hSelection;
}
});
|
|
|
Re: canvas scrolling [message #451038 is a reply to message #451035] |
Tue, 22 February 2005 07:27  |
Eclipse User |
|
|
|
See:
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet48.java?rev=HEAD&a mp;content-type=text/vnd.viewcvs-markup
"rob c" <robbiec@gmail.com> wrote in message
news:cveujc$er7$1@www.eclipse.org...
>i have a canvas in a view, and have a scroll bar as shown below
> it does not scroll properly though, areas outside the original viewable
> area are not drawn, and if i scroll back some of the drawing has been
> erased
> how do i ensure the the canvas is redrawn properly
>
> final Point origin = new Point (0, 0);
> final ScrollBar horizontalBar = canvas.getHorizontalBar();
> horizontalBar.addListener(SWT.Selection, new Listener() {
> public void handleEvent(Event event)
> {
> int hSelection = horizontalBar.getSelection();
> int destX = -hSelection - origin.x;
> org.eclipse.swt.graphics.Rectangle rect = canvas.getBounds();
> canvas.scroll(destX,0,0,0,rect.width, rect.height, true);
> origin.x = -hSelection;
> }
> });
>
|
|
|
Powered by
FUDForum. Page generated in 0.05597 seconds