Okay, here is your example, I just removed some code that is specific to my
stacked layout to make it more readable.
public class StackedLayout extends AbstractLayout {
/**
* @see
org.eclipse.draw2d.AbstractLayout#calculatePreferredSize(org.eclipse.draw2d.IFigure,
int, int)
*/
protected Dimension calculatePreferredSize( IFigure container, int wHint,
int hHint ) {
Dimension preferred = new Dimension( 0, 0 );
if( container.isVisible() ) {
for( Iterator i = container.getChildren().iterator(); i.hasNext(); ) {
IFigure child = (IFigure) i.next();
Dimension current = child.getPreferredSize();
// compute preferred here
}//for
Insets insets = container.getInsets();
preferred.expand( insets.getWidth(), insets.getHeight() );
}//if
return preferred;
}//calculatePreferredSize()
/**
* @see
org.eclipse.draw2d.LayoutManager#getMinimumSize(org.eclipse.draw2d.IFigure,
int, int)
*/
public Dimension getMinimumSize( IFigure container, int wHint, int hHint )
{
// Compute the minimum size as the preferred size of the first
// Compartment, which should be the title of the classifier.
return ((IFigure) container.getChildren().get( 0 )).getPreferredSize();
}//getMinimumSize()
/**
* @see
org.eclipse.draw2d.AbstractLayout#layout(org.eclipse.draw2d.IFigure)
*/
public void layout( IFigure container ) {
Rectangle clientArea = container.getClientArea();
LOG.finest( "container=" + container + " clientArea=" + clientArea );
int maxHeight = clientArea.height;
Rectangle previous = new Rectangle( clientArea.x, clientArea.y,
clientArea.width, 0 );
for( Iterator i = container.getChildren().iterator(); i.hasNext(); ) {
IFigure child = (IFigure) i.next();
Rectangle bounds = // Whatever you need, previous probably helps
child.setBounds( bounds );
previous = bounds;
}//for
}//layout()
}
"Christian Sell" <christian.sell@xxxxxxxxxxxxx> wrote in message
news:diofvo$e5e$1@xxxxxxxxxxxxxxxxxxx
thanks, thats the answer I feared. My preference would have been "look at
example XYZ", or "see the code sample below". Should this turn out to be a
case of YCAGWYW (You Cant Always Get What You Want)?
christian
Felix L J Mayer wrote:
You need to write a LayoutManager for the parent figure.
"Christian Sell" <christian.sell@xxxxxxxxxxxxx> wrote in message
news:diocps$98a$1@xxxxxxxxxxxxxxxxxxx
Hello,
can somebody give me a hint how to lay out child figures in 2 columns,
such that the row contents are left-aligned in each columnn? Each row is
one edit part which has 2 text items. Example:
_________________________
|row1text row2text |
|moretexttext moretext |
thanks,
Christian