Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Does a Form with TableWrapLayout allow child FigureCanvas?
Does a Form with TableWrapLayout allow child FigureCanvas? [message #211432] Fri, 10 March 2006 22:41 Go to next message
Nathan Snapp is currently offline Nathan SnappFriend
Messages: 14
Registered: July 2009
Junior Member
I have a ScrolledForm with a TableWrapLayout. As a child to this form I
have one or more FigureCanvas's. I chose FigureCanvas because I want to
have wrapped text with a box around it, so I am using a Figure with
TextFlows contained in a PageFlow and a border drawn around the whole
thing. They wrap just fine, but the TableWrapLayout causes them to be
clipped if the lines wrap. Is TableWrapLayout not meant for this?

If not is this the wrong approach? I would really like to put
FigureCanvases into a TableWrapLayout even if it means submitting a patch,
but I want to know if What I am trying to do is just WRONG! :)

Thanks!
Re: Does a Form with TableWrapLayout allow child FigureCanvas? [message #211456 is a reply to message #211432] Mon, 13 March 2006 04:11 Go to previous messageGo to next message
Nathan Snapp is currently offline Nathan SnappFriend
Messages: 14
Registered: July 2009
Junior Member
I figured out part of the answer to this. If the FigureCanvas is a direct
child to the Form with the TableWrapLayout simply wrap the FigureCanvas in
a Composite, setting the SWT.WRAP flag. Then give it a layout like
FillLayout and it will display correctly. The key is the SWT.WRAP flag so
that TableWrapLayout.computeSize() knows to pass the true width to the
forwarded computeSize() call--otherwise it passes SWT.DEFAULT (-1).

In my case I still would like to put the FigureCanvas inside of a Section
(I am using a Section to group Figures and allow them to be
collapsed/expanded). Section doesn't allow the SWT.WRAP flag as far as I
know and so the correct width is not passed and hence, it clips. Any
ideas on how to do this? I tried wrapping the Section in a Composite like
my solution above but still no luck.

Thanks
Re: Does a Form with TableWrapLayout allow child FigureCanvas? [message #211464 is a reply to message #211456] Mon, 13 March 2006 05:42 Go to previous message
Nathan Snapp is currently offline Nathan SnappFriend
Messages: 14
Registered: July 2009
Junior Member
Once again, stepping through the code in all its gory detail has yielded
an answer :)

The problem is the Section extends ExpandableComposite which ignores the
SWT.WRAP flag if it's child is a Composite and instead looks to see if the
Composite's layout implements ILayoutExtension (which is used for wrapping
calculations). So I ended up rolling my own layout (just copying
FillLayout and FillData into my own classes since they are final and
non-public respectively). In the class representing FillLayout you need
to implement ILayoutExtension and provide functions computeMaximumWidth
and computeMinimumWidth.

Here are my implementations if anyone cares:

public int computeMaximumWidth(Composite parent, boolean changed) {
return computeSize(parent, SWT.DEFAULT, SWT.DEFAULT, changed).x;
}

public int computeMinimumWidth(Composite parent, boolean changed) {
return computeSize(parent, 0, SWT.DEFAULT, changed).x;
}

Hopes this helps someone who may tread down this same confusing path!
Previous Topic:Snap only when key is pressed - DragEditPartsTracker SnapToHelper?
Next Topic:Manifest and plugin.xml for GEF logic example
Goto Forum:
  


Current Time: Fri Sep 27 04:18:14 GMT 2024

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

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

Back to the top