[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.gef] Re: Correct Layout Procedure?

preferredSize concept in draw2d is very similar to preferredSize in Swing, 
and computeSize in SWT. It is only used if the parent or parent's layout 
asks. In the case of XYLayout, the parent will ask if -1,-1 is the 
width,height.


"Daniel Rozeboom" <Daniel.Rozeboom@xxxxxxxxxxxxx> wrote in message 
news:e95ro9$61e$1@xxxxxxxxxxxxxxxxxxxx
>    The way I have it running right now, it seems to be working correctly. 
> What I do here is I don't specify a height and width for the container 
> (A); I just specify its location and -1, -1 for width and height using 
> setLayoutConstraint(), and its parent has an XYLayout.  Then A and B have 
> toolbar layouts, so they seem to resize themselves automatically - I never 
> specify sizes for them.  The only place where I specify a size is in C, 
> where I say setPreferredSize() with information from the model.  Is this 
> the correct way to do this, or am I calling some methods I shouldn't be? 
> Also, are setLayoutConstraint() and setPreferredSize() basically 
> equivalent operations for the XYLayout and ToolbarLayout, respectively? 
> Thanks in advance.
>
> - Daniel
>
> "Nhu Le" <nle.misc@xxxxxxxxx> wrote in message 
> news:e948vv$d3l$1@xxxxxxxxxxxxxxxxxxxx
>> The way I understand this is:  If you use a layout manager provided in 
>> GEF, you don't have to calculate the preferred size because it is 
>> provided to you.  Take a look at the source code of one of the layout 
>> manager and look for getPreferredSize() for more information.  When you 
>> create your own layout manager, however, you will have to calculate the 
>> minimum size and the preferred size by yourself.
>>
>>
>> Daniel Rozeboom wrote:
>>> Hi there,
>>>
>>>     I have a situation where I have a container (A) that has children 
>>> (B), each of which has children of its own (C).  The container (A) 
>>> resides in a document which has an XYLayout, so when A is asked to 
>>> refresh visuals, I call setLayoutConstraint on the parent with the 
>>> preferred size.  However, does this preferred size need to be calculated 
>>> manually from the children (B)?  Likewise, when each of the children (B) 
>>> is in refreshVisuals, do they need to set a preferred dimension 
>>> calculated manually using the sizes of their children (C)?
>>>     What's the correct way to do this?  I'm wondering if GEF handles 
>>> this for me, because right now I'm doing a bunch of calculations with 
>>> insets and children's edit parts' figures' sizes and whatnot.  Basically 
>>> I want A to be large enough to accomodate all of the figures of B, which 
>>> are each in turn large enough to accomodate all of the figures of C, 
>>> which are each sized on the basis of a model constraint.  Thanks in 
>>> advance.
>>>
>>> - Daniel
>
>