ScrollingGraphicalViewer in a FormPage [message #204196] |
Thu, 01 December 2005 03:50 |
Jason Grant 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.
|
|
|
|
Powered by
FUDForum. Page generated in 0.02755 seconds