Home » Eclipse Projects » GEF » laying out child figures in 2 columns
laying out child figures in 2 columns [message #199245] |
Fri, 14 October 2005 13:45 |
Eclipse User |
|
|
|
Originally posted by: christian.sell.netcologne.de
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
|
|
| |
Re: laying out child figures in 2 columns [message #199326 is a reply to message #199269] |
Fri, 14 October 2005 14:39 |
Eclipse User |
|
|
|
Originally posted by: christian.sell.netcologne.de
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@netcologne.de> wrote in message
> news:diocps$98a$1@news.eclipse.org...
>
>>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
>
>
>
|
|
|
Re: laying out child figures in 2 columns [message #199402 is a reply to message #199326] |
Fri, 14 October 2005 15:47 |
Felix L J Mayer Messages: 202 Registered: July 2009 |
Senior Member |
|
|
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@netcologne.de> wrote in message
news:diofvo$e5e$1@news.eclipse.org...
> 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@netcologne.de> wrote in message
>> news:diocps$98a$1@news.eclipse.org...
>>
>>>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
>>
>>
|
|
|
Re: laying out child figures in 2 columns [message #199425 is a reply to message #199402] |
Fri, 14 October 2005 16:38 |
Eclipse User |
|
|
|
Originally posted by: christian.sell.netcologne.de
thanks, I'll check this out.
chris
Felix L J Mayer wrote:
> 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@netcologne.de> wrote in message
> news:diofvo$e5e$1@news.eclipse.org...
>
>>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@netcologne.de> wrote in message
>>>news:diocps$98a$1@news.eclipse.org...
>>>
>>>
>>>>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
>>>
>>>
>
|
|
|
Goto Forum:
Current Time: Wed Nov 13 09:59:57 GMT 2024
Powered by FUDForum. Page generated in 0.05183 seconds
|