I'm using a StackLayoutPanel to show stacked emails of a conversation a la gmail where the header is the sender and the child the email's body. For the dynamic nature of this, I can only estimate the height of my stack in code. To estimate the body's height I could get the client's window's width then roughly guess how many lines the body occupies. But this is laborious and likely to be wrong.
My question is: is there a way for the StackLayoutPanel, as for GWT API 2.2, to know and so set automatically the height in display of the current shown child (plus its header and the other headers)?
I'm afraid not so I've tried other things that also, however, fail. I've tried:
Put the StackLayoutPanel inside a ScrollPanel:
Not inside a ScrollPanel: the stack gets automatically the size of remaining window's space, but with too many headers these overlap and superimpose each other.
Also, it seems the default behaviour for StackLayoutPanel is to show the rest of headers at the very end of the allocated space, not just after the before's header's child. Is it possible to change this?
Help on this would be much appreciated.
//I know a similar question is this but I think I expand on it.
You are right, you do expand on the previous question where the answer is a simple: stackLayoutPanel.setHeight((40*numChildren + 200)+"px");
The 200px body size is dependent on the content and enough so that StackLayoutPanel is probably not going to cut it for you.
I think the closet you are going to come with StackLayoutPanel is to use a fixed body width and use a ScrollPanel INSIDE the body (not SLP inside SP). This way all emails can show all content in ScrollPanel.
Since this is a bit of a compromise, the alternative is to just implement your own widget. I would probably use a VerticalPanel as the underlying widget and just hide and display div's (while keeping the headers visible all the time)
Maybe it's possible to accomplish this with a custom widget that would wrap a bunch of DisclosurePanel
s so that only one of them can be shown at a time.
If you extend the StackLayoutPanel, and write a resize() method, using the visible widget height, plus some arbitrary number for the height of the panel headers:
public void resize() {
int panelHeight = super.getVisibleWidget().getOffsetHeight();
this.setHeight(panelHeight + 200 + "px");
}
Then add a click handler on the panel header that calls this method when clicked, the stack panel resizes dynamically to display the selected panel.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With