Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » ScrollingGraphicalViewer in a FormPage
ScrollingGraphicalViewer in a FormPage [message #204196] Thu, 01 December 2005 03:50 Go to next message
Jason Grant is currently offline Jason GrantFriend
Messages: 77
Registered: July 2009
Member
I want to embed a ScrollingGraphicalViewer viewer into a FormPage so
that the viewer occupies the available space. To this end, I do the
following:

Composite parent = toolkit.createComposite(...);
parent.setLayout(new GridLayout());
viewerControl = viewer.createControl(parent);
viewerControl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

When I run the application, the viewer, which has a ScalableRootEditPart
as it's root, is rendered as approximately a 10 pixel square in the
FormPage. Given that the root contains only my DiagramEditPart with a
FlowLayout and a default RectangleFigure, I guess I'm just seeing some
sort of default inset/padding/border?

1) How do I ensure that the viewer has zero size when it contains no child
Figures?

Later, when a Figure appears in my diagram as a result of an element being
added to the model, the viewer correctly repaints itself with rectangular
dimensions to equal the size of the new Figure, however unfortunately, not
all of the figure is displayed, since the viewer also includes scrollbars
in this rectangle (even though the parent layout can find plenty of room
for the viewer). I've tried all sorts of combinations of reflow(),
repaint(), layout(), etc., on various parent controls, and also similar on
children such as the root part and it's viewport, canvas, etc., to the
point where I'm confused.

2) What should be done to ensure that scrollbars only appear when the
parent layout cannot find adequate space?

I suspect that I actually don't need scrollbars at all for the behaviour
described above, since the parent Controls can do the scrolling. However
when I turn off scrolling in the Viewer via the FigureCanvas API, the
Viewer no longer automatically repaints itself when Figures are added. It
just remains at approx 10x10 pixels. The viewer Control doesn't even fire
controlResized() when Figures are removed.

3) Should I be listening for some sort of event from the viewer, then
performing a reflow(), repaint(), layout(), or similar?

When all of this works, I'm hoping that when I add Figures to my
"DiagramEditPart" (which has a FlowLayout), it will be smart enough to
ensure that it's child figures wrap if they overflow the horizontal width
of the parent viewer. Similarly, when the FormPage is resized, I'm hoping
that the Figures will re-wrap based on available horizontal space.

4) Am I right to assume that GEF will automatically participate in the
parent's layout like this? i.e. a resize of the Viewer's parent
Composite will propagate down the Figure hierarchy to update the layouts?
I think I will need to turn off horizontal scrolling in the root
FigureCanvas for this behaviour to work, right?

Thanks for any pointers.

Jason.
Re: ScrollingGraphicalViewer in a FormPage [message #204356 is a reply to message #204196] Fri, 02 December 2005 06:01 Go to previous message
Jason Grant is currently offline Jason GrantFriend
Messages: 77
Registered: July 2009
Member
Took me a day, but I 'Figured' things out for myself in the end.

For the benefit of others, all is working fine now; it was just a matter
of setting figureCanvas.getViewport().setContentsTracksWidth(true). Now,
when I resize my FormPage, the wHint propagates down the Figure hierarchy
to ensure that FlowLayout doesn't place child figures beyond the width of
the viewer. The scrollbars in the viewport work beautifully - I didn't
need to switch them off after all. Thanks GEF team!
Previous Topic:Simple question about polygon/shape borders
Next Topic:Pros and Cons about Using a tree view inside the editor
Goto Forum:
  


Current Time: Thu Apr 25 04:13:36 GMT 2024

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

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

Back to the top