Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[gef-dev] Canvas Scrolling problem

Hi,
 
Is it possible to change the x,y corrdinate of canvas by horizontal and vertical scrolling
I have some draw2d figure on canvas, figures are bound with particular x,y cordinates when i scroll the canvas using following code
it looks that figures are also scrolling but actually figures keep remain on the same place because the x,y position of canvas never change.
 

final static int SIZE = 1000;

setSize(SIZE,SIZE);

final ScrollBar horizontalBar = getHorizontalBar();

horizontalBar.setMaximum(SIZE);

final ScrollBar verticalBar = getVerticalBar();

verticalBar.setMaximum(SIZE);

final Point origin = new Point(0,0);

final Canvas scrollCanvas = this;

addMouseMoveListener(this);

horizontalBar.addListener( SWT.Selection, new Listener() {

public void handleEvent( Event e ) {

int destX = -horizontalBar.getSelection();

scrollCanvas.scroll(

destX, origin.y, origin.x, origin.y, SIZE, SIZE, true );

origin.x = destX;

}

} );

verticalBar.addListener( SWT.Selection, new Listener() {

public void handleEvent( Event e ) {

int destY = -verticalBar.getSelection();

scrollCanvas.scroll(

origin.x, destY, origin.x, origin.y, SIZE, SIZE, true );

origin.y = destY;

}

} );

 
please suggest.
 
Thanks in advance
Shalaj Shukla

DISCLAIMER:
This message contains privileged and confidential information and is intended only for an individual named. If you are not the intended recipient, you should not disseminate, distribute, store, print, copy or deliver this message. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete or contain viruses. The sender, therefore, does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required, please request a hard-copy version.


Back to the top