Skip to content

Commit 6f0881b

Browse files
author
zhourenjian
committed
Fixed bug that Menu's width is not correct in IE and Opera.
Fixed bug that #setImage for *.png after *.gif may result in two images in the background.
1 parent ec4b234 commit 6f0881b

File tree

4 files changed

+29
-9
lines changed

4 files changed

+29
-9
lines changed

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/browser/Browser.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,15 +1392,19 @@ public boolean setText(String html) {
13921392
handle.src = "about:blank";
13931393
}
13941394
try {
1395-
handle.contentWindow.document.write (html);
1396-
handle.contentWindow.document.close ();
1395+
var doc = handle.contentWindow.document;
1396+
doc.open ();
1397+
doc.write (html);
1398+
doc.close ();
13971399
} catch (e) {
1398-
window.setTimeout ((function () {
1400+
window.setTimeout ((function (handle, html) {
13991401
return function () {
1400-
handle.contentWindow.document.write (html);
1401-
handle.contentWindow.document.close ();
1402+
var doc = handle.contentWindow.document;
1403+
doc.open ();
1404+
doc.write (html);
1405+
doc.close ();
14021406
};
1403-
}) (), 25);
1407+
}) (handle, html), 25);
14041408
}
14051409
*/
14061410
private native void iframeDocumentWrite(Object handle, String html);

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/Label.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ public void setImage (Image image) {
519519
// imgBackground.style.height = "100%";
520520
// imgBackground.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\"" + this.image.url + "\", sizingMethod=\"image\")";
521521
// handle.appendChild(imgBackground);
522+
handleStyle.backgroundImage = "";
522523
handleStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\"" + this.image.url + "\", sizingMethod=\"image\")";
523524
} else {
524525
handleStyle.backgroundRepeat = "no-repeat";

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/Menu.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,23 @@ void _setVisible (boolean visible) {
225225
style.zIndex = "1" + window.currentTopZIndex;
226226
style.display = "block";
227227
int height = OS.getContainerHeight(handle);
228-
if (OS.isIE) {
229-
handle.style.width = "200px";
228+
if (OS.isIE || OS.isOpera) {
229+
int maxWidth = 0;
230+
boolean hasImage = false;
231+
boolean hasSelection = false;
232+
MenuItem[] children = getItems();
233+
for (int i = 0; i < children.length; i++) {
234+
MenuItem item = children[i];
235+
int width = OS.getStringStyledWidth(item.getText(), "menu-item-text", null);
236+
if (item.getImage() != null) {
237+
hasImage = true;
238+
}
239+
if ((item.getStyle() & (SWT.CHECK | SWT.RADIO)) != 0) {
240+
hasImage = true;
241+
}
242+
maxWidth = Math.max(maxWidth, width);
243+
}
244+
handle.style.width = (maxWidth + (hasImage ? 18 : 0) + (hasSelection ? 18 : 0) + 32) + "px";
230245
}
231246
int width = OS.getContainerWidth(handle);
232247
int left = x, top = y;

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/ShellManager.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
background-color:buttonface;
1212
border-style:solid solid solid none;
1313
border-width:1px;
14-
border-height:buttonshadow;
14+
border-color:buttonshadow;
1515
/*opacity:0.25;
1616
filter:Alpha(Opacity=25);*/
1717
}

0 commit comments

Comments
 (0)