import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
+import com.itmill.toolkit.terminal.gwt.client.BrowserInfo;
import com.itmill.toolkit.terminal.gwt.client.ContainerResizedListener;
import com.itmill.toolkit.terminal.gwt.client.ErrorMessage;
import com.itmill.toolkit.terminal.gwt.client.Paintable;
ShortcutActionHandler shortcutHandler;
+ private String width;
+
+ private Element geckoCaptionMeter;
+
public IPanel() {
super();
DOM.appendChild(getElement(), captionNode);
}
// Height adjustment
- iLayout();
+ iLayout(false);
// Render content
final UIDL layoutUidl = uidl.getChildUIDL(0);
}
public void iLayout() {
+ iLayout(true);
+ }
+
+ public void iLayout(boolean runGeckoFix) {
if (height != null && height != "") {
final boolean hasChildren = getWidget() != null;
Element contentEl = null;
} else {
DOM.setStyleAttribute(contentNode, "height", "");
}
+
+ if (runGeckoFix && BrowserInfo.get().isGecko()) {
+ // workaround for #1764
+ if (width == null || width.equals("")) {
+ if (geckoCaptionMeter == null) {
+ geckoCaptionMeter = DOM.createDiv();
+ DOM.appendChild(captionNode, geckoCaptionMeter);
+ }
+ int captionWidth = DOM.getElementPropertyInt(captionText,
+ "offsetWidth");
+ int availWidth = DOM.getElementPropertyInt(geckoCaptionMeter,
+ "offsetWidth");
+ if (captionWidth == availWidth) {
+ /*
+ * Caption width defines panel width -> Gecko based browsers
+ * somehow fails to float things right, without the
+ * "noncode" below
+ */
+ setWidth(getOffsetWidth() + "px");
+ } else {
+ DOM.setStyleAttribute(captionNode, "width", "");
+ }
+ }
+ }
Util.runDescendentsLayout(this);
}
* Panel handles dimensions by itself.
*/
public void setWidth(String width) {
- // Let browser handle 100% width (DIV element takes all size by default).
+ this.width = width;
+ // Let browser handle 100% width (DIV element takes all size by
+ // default).
// This way we can specify borders for Panel's outer element.
- if(!width.equals("100%")) {
+ if (!width.equals("100%")) {
super.setWidth(width);
}
}