PDA

View Full Version : [CLOSED] problem with nested horizontal RowLayout



asimpkins
22 Aug 2008, 11:52 AM
I'm using GXT1.02, hosted mode, Firefox 2.0.0.16, and Windows XP.

I believe that the code below should render 'innerPanel' at the top of the screen, only taking up enough height as is necessary for 'innerField'. The rest of the screen should be taken up with 'innerArea' to the right of 'innerField' and with 'area' taking up everything below them.

When I run this, however, 'innerPanel' fails to appear at all and the entire screen is taken up by 'area'.


public class Test implements EntryPoint {
public void onModuleLoad() {
TextField innerField = new TextField();
TextArea innerArea = new TextArea();
TextArea area = new TextArea();

LayoutContainer innerPanel = new LayoutContainer(new RowLayout(Style.Orientation.HORIZONTAL));
innerPanel.add(innerField, new RowData(-1, -1));
innerPanel.add(innerArea, new RowData(1, 1));

LayoutContainer mainPanel = new LayoutContainer(new RowLayout(Style.Orientation.VERTICAL));
mainPanel.add(innerPanel, new RowData(1, -1));
mainPanel.add(area, new RowData(1, 1));

Viewport viewport = new Viewport();
viewport.setLayout(new FitLayout());
viewport.add(mainPanel);
RootPanel.get().add(viewport);
}
}What leads me to believe that this is a bug, particular to horizontally oriented RowLayouts, is that if I switch line 7:


LayoutContainer innerPanel = new LayoutContainer(new RowLayout(Style.Orientation.HORIZONTAL));...to this:


LayoutContainer innerPanel = new LayoutContainer(new RowLayout(Style.Orientation.VERTICAL));...then 'innerPanel' displays at the top of the screen, though vertically aligned, of course.

darrellmeyer
23 Aug 2008, 7:10 AM
Form fields are rendered absolutely which means they will not have a "natural" size. You need to avoid -1 values when using fields with RowLayout.


public void onModuleLoad() {
TextField innerField = new TextField();
TextArea innerArea = new TextArea();
TextArea area = new TextArea();

LayoutContainer innerPanel = new LayoutContainer(new RowLayout(
Style.Orientation.HORIZONTAL));
innerPanel.add(innerField, new RowData(-1, 50));
innerPanel.add(innerArea, new RowData(1, 1));

LayoutContainer mainPanel = new LayoutContainer(new RowLayout(
Style.Orientation.VERTICAL));
mainPanel.add(innerPanel, new RowData(1, 50));
mainPanel.add(area, new RowData(1, 1));

Viewport viewport = new Viewport();
viewport.setLayout(new FitLayout());
viewport.add(mainPanel);
RootPanel.get().add(viewport);
}