Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » canvas scrolling
canvas scrolling [message #451035] Tue, 22 February 2005 09:38 Go to next message
Eclipse UserFriend
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 12:27 Go to previous message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
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;
> }
> });
>
Previous Topic:Disabling the changing of tabs in a CTabFolder.
Next Topic:how place Canvas or image in a cell inside Table widget
Goto Forum:
  


Current Time: Fri Oct 23 22:14:00 GMT 2020

Powered by FUDForum. Page generated in 0.01881 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top