开发者

GWT Layout: "take up the rest of the space."

开发者 https://www.devze.com 2023-01-23 08:21 出处:网络
My existing layout is a stack of two divs - g:layers in a LayoutPanel.The top div should be as big as it needs to be to contain its contents.The bottom div should take up the rest of the space on the

My existing layout is a stack of two divs - g:layers in a LayoutPanel. The top div should be as big as it needs to be to contain its contents. The bottom div should take up the rest of the space on the screen, without causing scrollbars to appear.

The contents of the top div can change, so the size of the top div can change.

My current solution is a callback that's triggered w开发者_如何学Pythonhenever the contents of the top div change. The containing LayoutPanel can then recalculate the size of the top div and explicitly set the top and bottom attributes of the second layer to take up the rest of the space. Is there a better way? Something like,

<g:LayoutPanel>
    <g:layer top="0px" height="whatever you need, baby">
        <c:SomeWidget/>
    </g:layer>
    <g:layer top="the bottom of the first layer" bottom="0px">
        <c:Anotherwidget/>
    </g:layer>
</g:LayoutPanel>


What about using DockLayoutPanel?

<g:DockLayoutPanel unit='PX'>
  <north size="10" ui:field='northWidget'>
    <c:SomeWidget/>
  </north>
  <center>
    <c:Anotherwidget/>
  </center>
</g:DockLayoutPanel>

Then the center will take up the rest of the space. If you want to resize the top, call setWidgetSize(northWidget, newSize); and the center widget will be recalculated.


The answer seems to be that there is not a better way. Manual recalculation isn't so bad when you get used to it!


I think HeaderPanel is the standard Widget to do this. Maybe it was added after the question was asked. We missed it too and had our own version for a while.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号