Browse Source

fixes #1764


svn changeset:4861/svn branch:trunk
tags/6.7.0.beta1
Matti Tahvonen 16 years ago
parent
commit
b3cab0ab2e

+ 4
- 0
src/com/itmill/toolkit/terminal/gwt/client/BrowserInfo.java View File

@@ -89,6 +89,10 @@ public class BrowserInfo {
return isIE && ieVersion == 7;
}

public boolean isGecko() {
return isGecko;
}

public boolean isFF2() {
return isGecko && geckoVersion == 1.8;
}

+ 38
- 3
src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java View File

@@ -10,6 +10,7 @@ import com.google.gwt.user.client.Event;
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;
@@ -45,6 +46,10 @@ public class IPanel extends SimplePanel implements Paintable,

ShortcutActionHandler shortcutHandler;

private String width;

private Element geckoCaptionMeter;

public IPanel() {
super();
DOM.appendChild(getElement(), captionNode);
@@ -136,7 +141,7 @@ public class IPanel extends SimplePanel implements Paintable,
}

// Height adjustment
iLayout();
iLayout(false);

// Render content
final UIDL layoutUidl = uidl.getChildUIDL(0);
@@ -212,6 +217,10 @@ public class IPanel extends SimplePanel implements Paintable,
}

public void iLayout() {
iLayout(true);
}

public void iLayout(boolean runGeckoFix) {
if (height != null && height != "") {
final boolean hasChildren = getWidget() != null;
Element contentEl = null;
@@ -267,6 +276,30 @@ public class IPanel extends SimplePanel implements Paintable,
} 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);
}

@@ -311,9 +344,11 @@ public class IPanel extends SimplePanel implements Paintable,
* 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);
}
}

Loading…
Cancel
Save