Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » HowTo get scroll bars to work in draw2d.FigureCanvas?
HowTo get scroll bars to work in draw2d.FigureCanvas? [message #216191] Mon, 15 May 2006 21:26 Go to next message
Paul E. Keyser is currently offline Paul E. KeyserFriend
Messages: 878
Registered: July 2009
Senior Member
R3.1.1

There are several old posts on this subject that suggest it is possible in draw2d (I am not using
GEF) to get scrolling of a figure/canvas by using FigureCanvas. I have not been able to get this to
work. Here is what I do:

Composite parent;
// created on some child of the Composite passed in from Eclipse to my edit-part

FigureCanvas canvas = new FigureCanvas(parent, SWT.NULL);
canvas.setViewport(new Viewport(true));

IFigure theFig = new Figure() {
// override some methods as needed
};
theFig.{setBorder(); setLayoutManager(); setOpaque(); etc.};

// here create a bunch of IFigure instances and add them to theFig

new LightweightSystem(canvas).setContents(theFig);

My figures appear just fine, but no matter what I do, no scrollbars ever do. What am I missing? (If
there is an example of doing this in the GEF-examples, I sure could not find it.)

thanks,
Paul
Re: HowTo get scroll bars to work in draw2d.FigureCanvas? [message #216199 is a reply to message #216191] Tue, 16 May 2006 07:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rajakididi.hotmail.com

Hey Paul

Try this if it works ::


Composite parent;
// created on some child of the Composite passed in from Eclipse
to my edit-part

FigureCanvas canvas = new FigureCanvas(parent, SWT.H_SCROLL |
SWT.V_SCROLL);

The second argument is the style. Try it. It should work.

Melanie
Re: HowTo get scroll bars to work in draw2d.FigureCanvas? [message #216223 is a reply to message #216199] Tue, 16 May 2006 13:10 Go to previous messageGo to next message
Paul E. Keyser is currently offline Paul E. KeyserFriend
Messages: 878
Registered: July 2009
Senior Member
Melanie --

Thanks for prompt reply, and good suggetion (I should have thought of that!) -- but it does not
work; still no scroll bars. Other ideas?

Paul
Re: HowTo get scroll bars to work in draw2d.FigureCanvas? [message #216328 is a reply to message #216223] Wed, 17 May 2006 07:56 Go to previous messageGo to next message
Sabri Skhiri dit Gabouje is currently offline Sabri Skhiri dit GaboujeFriend
Messages: 10
Registered: July 2009
Junior Member
Hello Paul,

I tried this and it works !

FigureCanvas canvas = new FigureCanvas(parent, SWT.H_SCROLL |
SWT.V_SCROLL);
LightweightSystem lws = new LightweightSystem(canvas);
canvas.setViewport(new Viewport(true));
canvas.setScrollBarVisibility(FigureCanvas.ALWAYS);

IFigure content = //Your content
canvas.setContents(content);
lws.setContents(canvas.getViewport());
}

The view port "fake" the figure when you scroll it.

Bye.

Sabri.
Re: HowTo get scroll bars to work in draw2d.FigureCanvas? [message #216356 is a reply to message #216328] Wed, 17 May 2006 14:08 Go to previous messageGo to next message
Paul E. Keyser is currently offline Paul E. KeyserFriend
Messages: 878
Registered: July 2009
Senior Member
Excellent! Thaanks! I knew it would something simple (I was not setting the contents of the LWS to
the Viewport but to the IFigure). And it works with scrollbars' visibility set to AUTOMATIC, too.

BTW, do you know what the effect of this call is:

canvas.getViewport().setContentsTracksWidth(true)

(doesn't seem to do anything, and the javadocs are not, um, clear).

thanks,
Paul
Re: HowTo get scroll bars to work in draw2d.FigureCanvas? [message #218015 is a reply to message #216356] Fri, 16 June 2006 17:01 Go to previous message
Eclipse UserFriend
Originally posted by: tanmay.cmu.edu

Another way is to use ScrollPane in Draw2D api.

Assuming you have your figure in object 'figure' and LightWeightSystem as
'lws'. All you have to do is

ScrollPane scp = new ScrollPane();
scp.setContents(figure);
lws.setContents(scp);

tanmay



On 5/17/06 10:08 AM, in article e4fap7$eao$1@utils.eclipse.org, "Paul
Keyser" <rolarenfan@earthlink.net> wrote:

> Excellent! Thaanks! I knew it would something simple (I was not setting the
> contents of the LWS to
> the Viewport but to the IFigure). And it works with scrollbars' visibility set
> to AUTOMATIC, too.
>
> BTW, do you know what the effect of this call is:
>
> canvas.getViewport().setContentsTracksWidth(true)
>
> (doesn't seem to do anything, and the javadocs are not, um, clear).
>
> thanks,
> Paul
Previous Topic:Text Editor Incorporating Images
Next Topic:Question regarding key handing
Goto Forum:
  


Current Time: Fri Apr 26 08:20:24 GMT 2024

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

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

Back to the top