Skip to content

Commit 9960541

Browse files
author
zhourenjian
committed
Fixed bug that IE6 is not working correctly
Fixed bug on Combo, Button#SWT_CHECK
1 parent 6c48bf3 commit 9960541

File tree

10 files changed

+59
-40
lines changed

10 files changed

+59
-40
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.eclipse.swt.graphics.Point;
2323
import org.eclipse.swt.internal.RunnableCompatibility;
2424
import org.eclipse.swt.internal.browser.OS;
25+
import org.eclipse.swt.internal.dnd.HTMLEventWrapper;
2526
import org.eclipse.swt.internal.xhtml.CSSStyle;
2627
import org.eclipse.swt.internal.xhtml.Element;
2728
import org.eclipse.swt.internal.xhtml.HTMLEvent;
@@ -954,10 +955,10 @@ public void setImage (Image image) {
954955
if (image == null) {
955956
hasImage = false;
956957
btnText.style.backgroundImage = "";
957-
if (OS.isIENeedPNGFix && image.url != null && image.url.toLowerCase().endsWith(".png")
958-
&& btnText.style.filter != null) {
958+
if (OS.isIENeedPNGFix && btnText.style.filter != null) {
959959
btnText.style.filter = "";
960960
}
961+
return;
961962
}
962963
if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
963964
// _setImage (this.image = image);
@@ -1014,7 +1015,7 @@ public void setImage (Image image) {
10141015
handleStyle.paddingLeft = (this.image.width + 1) + "px";
10151016
}
10161017
handleStyle.minHeight = this.image.height + "px";
1017-
if (OS.isIENeedPNGFix && image.url.toLowerCase().endsWith(".png") && handleStyle.filter != null) {
1018+
if (OS.isIENeedPNGFix && image.url != null && image.url.toLowerCase().endsWith(".png") && handleStyle.filter != null) {
10181019
// Element imgBackground = document.createElement("DIV");
10191020
// imgBackground.style.position = "absolute";
10201021
// imgBackground.style.width = "100%";
@@ -1213,7 +1214,7 @@ public void setText (String string) {
12131214
}
12141215
if (OS.isIE && (style & (SWT.RADIO | SWT.CHECK)) != 0) {
12151216
if (OS.isIE70) {
1216-
btnHandle.parentNode.style.marginTop = text.length() == 0 ? "-2px" : "-2px";
1217+
btnHandle.parentNode.style.marginTop = text.length() == 0 ? "-5px" : "-6px";
12171218
} else if ((style & SWT.RADIO) != 0) {
12181219
btnHandle.parentNode.style.marginTop = text.length() == 0 ? "0" : "2px";
12191220
} else {
@@ -1344,6 +1345,10 @@ public void run() {
13441345
// Still buggy on check button with image
13451346
if (e.srcElement != btnHandle && e.target != btnHandle) {
13461347
setSelection (!getSelection ());
1348+
toReturn(false);
1349+
} else if (OS.isIE){
1350+
toReturn(true);
1351+
new HTMLEventWrapper(e).stopPropagation();
13471352
}
13481353
} else {
13491354
setSelection (!getSelection ());

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,8 @@ void show(){
766766
}
767767
this.selectShown = true;
768768
window.currentTopZIndex = "" + (Integer.parseInt(window.currentTopZIndex) + 1);
769-
selectInput.style.zIndex = window.currentTopZIndex;
769+
// related bug: http://groups.google.com/group/java2script/browse_thread/thread/8085561fcf953fc?hl=en
770+
selectInput.style.zIndex = "" + (Integer.parseInt(window.currentTopZIndex) + 4); //sgurin
770771
try {
771772
handle.removeChild(selectInput);
772773
document.body.appendChild(selectInput);
@@ -1684,7 +1685,7 @@ void setBounds (int x, int y, int width, int height, int flags) {
16841685
* items and ignore the height value that the programmer supplies.
16851686
*/
16861687
int buttonHeight = getTextHeight();
1687-
int buttonWidth = OS.getContainerWidth(dropDownButton);
1688+
int buttonWidth = OS.getContainerHeight(dropDownButton);
16881689

16891690
if (!isSimple) {
16901691
//height = getTextHeight () + (getItemHeight () * visibleCount) + 2;

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,6 +1475,14 @@ public void setImage (Image image) {
14751475
// if (image != null) {
14761476
// shellIcon.style.backgroundImage = "url('" + image.url + "')";
14771477
// }
1478+
if (image == null) {
1479+
shellIcon.style.backgroundImage = "";
1480+
if (OS.isIENeedPNGFix && shellIcon.style.filter != null) {
1481+
shellIcon.style.filter = "";
1482+
}
1483+
return;
1484+
}
1485+
14781486
if (shellIcon != null && this.image.handle == null && this.image.url != null && this.image.url.length() != 0) {
14791487
CSSStyle iconStyle = shellIcon.style;
14801488
if (OS.isIENeedPNGFix && image.url.toLowerCase().endsWith(".png") && contentHandle.style.filter != null) {

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,13 @@ public void setImage (Image image) {
510510
if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
511511
//_setImage (this.image = image);
512512
this.image = image;
513+
if (image == null) {
514+
handle.style.backgroundImage = "";
515+
if (OS.isIENeedPNGFix && handle.style.filter != null) {
516+
handle.style.filter = "";
517+
}
518+
return;
519+
}
513520
if (this.image.handle == null && this.image.url != null && this.image.url.length() != 0) {
514521
CSSStyle handleStyle = handle.style;
515522
if (OS.isIENeedPNGFix && image.url.toLowerCase().endsWith(".png") && handleStyle.filter != null) {

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

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -954,22 +954,23 @@ public void setImage (Image image) {
954954
}
955955
OS.removeCSSClass(handle, "menu-item-enable-image");
956956
}
957-
if (imageEl != null && image != null) {
958-
if (this.image.handle == null && this.image.url != null && this.image.url.length() != 0) {
959-
OS.clearChildren(imageEl);
960-
CSSStyle handleStyle = imageEl.style;
961-
if (OS.isIENeedPNGFix && image.url.toLowerCase().endsWith(".png") && handleStyle.filter != null) {
962-
// Element imgBackground = document.createElement("DIV");
963-
// imgBackground.style.position = "absolute";
964-
// imgBackground.style.width = "100%";
965-
// imgBackground.style.height = "100%";
966-
// imgBackground.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\"" + this.image.url + "\", sizingMethod=\"image\")";
967-
// handle.appendChild(imgBackground);
968-
handleStyle.backgroundImage = "";
969-
handleStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\"" + this.image.url + "\", sizingMethod=\"image\")";
970-
} else {
971-
if (OS.isIENeedPNGFix && handleStyle.filter != null) handleStyle.filter = "";
972-
handleStyle.backgroundImage = "url(\"" + this.image.url + "\")";
957+
if (imageEl != null) {
958+
if (image != null) {
959+
if (this.image.handle == null && this.image.url != null && this.image.url.length() != 0) {
960+
OS.clearChildren(imageEl);
961+
CSSStyle handleStyle = imageEl.style;
962+
if (OS.isIENeedPNGFix && image.url.toLowerCase().endsWith(".png") && handleStyle.filter != null) {
963+
handleStyle.backgroundImage = "";
964+
handleStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\"" + this.image.url + "\", sizingMethod=\"image\")";
965+
} else {
966+
if (OS.isIENeedPNGFix && handleStyle.filter != null) handleStyle.filter = "";
967+
handleStyle.backgroundImage = "url(\"" + this.image.url + "\")";
968+
}
969+
}
970+
} else {
971+
imageEl.style.backgroundImage = "";
972+
if (OS.isIENeedPNGFix && imageEl.style.filter != null) {
973+
imageEl.style.filter = "";
973974
}
974975
}
975976
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ public Element addShortcut(String name, String icon, Object clickFun) {
253253
itemDiv.className = "shortcut-item";
254254
if (OS.isIENeedPNGFix) {
255255
if (icon != null && icon.length() != 0) {
256+
// The following is commented out intentionally.
257+
// Using filter may result in black blocks
256258
// if (icon.toLowerCase().endsWith(".png")) {
257259
// itemDiv.style.backgroundImage = "url(\"about:blank\")";
258260
// itemDiv.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\"" + icon + "\", sizingMethod=\"image\")";

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,7 @@ public void setImage (Image image) {
286286
}
287287
} else {
288288
textEl.style.backgroundImage = "";
289-
if (OS.isIE && image.url != null && image.url.toLowerCase().endsWith(".png")
290-
&& textEl.style.filter != null) {
289+
if (OS.isIENeedPNGFix && textEl.style.filter != null) {
291290
textEl.style.filter = "";
292291
}
293292
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ public void updateItems() {
318318
Image image = item.shell.getImage();
319319
CSSStyle handleStyle = item.iconHandle.style;
320320
if (image != null) {
321-
if (OS.isIENeedPNGFix && image.url.toLowerCase().endsWith(".png") && handleStyle.filter != null) {
321+
if (OS.isIENeedPNGFix && image.url != null && image.url.toLowerCase().endsWith(".png") && handleStyle.filter != null) {
322322
handleStyle.backgroundImage = "url(\"about:blank\")";
323323
handleStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\"" + image.url + "\", sizingMethod=\"image\")";
324324
} else {
@@ -331,8 +331,7 @@ public void updateItems() {
331331
OS.addCSSClass(item.iconHandle, "shell-item-icon-console");
332332
}
333333
handleStyle.backgroundImage = "";
334-
if (OS.isIENeedPNGFix && image.url != null && image.url.toLowerCase().endsWith(".png")
335-
&& handleStyle.filter != null) {
334+
if (OS.isIENeedPNGFix && handleStyle.filter != null) {
336335
handleStyle.filter = "";
337336
}
338337
}

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,19 +1352,17 @@ void updateImages (boolean enabled) {
13521352
if (this.image.handle == null && this.image.url != null && this.image.url.length() != 0) {
13531353
CSSStyle handleStyle = handle.style;
13541354
if (OS.isIENeedPNGFix && image.url.toLowerCase().endsWith(".png") && handleStyle.filter != null) {
1355-
// Element imgBackground = document.createElement("DIV");
1356-
// imgBackground.style.position = "absolute";
1357-
// imgBackground.style.width = "100%";
1358-
// imgBackground.style.height = "100%";
1359-
// imgBackground.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\"" + this.image.url + "\", sizingMethod=\"image\")";
1360-
// handle.appendChild(imgBackground);
1361-
handleStyle.backgroundImage = "";
1362-
handleStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\"" + this.image.url + "\", sizingMethod=\"image\")";
1355+
handleStyle.backgroundImage = "";
1356+
handleStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\"" + this.image.url + "\", sizingMethod=\"image\")";
13631357
} else {
1364-
if (OS.isIENeedPNGFix && handleStyle.filter != null) handleStyle.filter = "";
1365-
handleStyle.backgroundImage = "url(\"" + this.image.url + "\")";
1358+
if (OS.isIENeedPNGFix && handleStyle.filter != null) handleStyle.filter = "";
1359+
handleStyle.backgroundImage = "url(\"" + this.image.url + "\")";
13661360
}
13671361
}
1362+
} else {
1363+
CSSStyle handleStyle = handle.style;
1364+
if (OS.isIENeedPNGFix && handleStyle.filter != null) handleStyle.filter = "";
1365+
handleStyle.backgroundImage = "";
13681366
}
13691367
/*
13701368
int hwnd = parent.handle;

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,13 +446,12 @@ public void setImage (Image image) {
446446
super.setImage (image);
447447
if (image == null) {
448448
handle.style.backgroundImage = "";
449-
if (OS.isIENeedPNGFix && image.url != null && image.url.toLowerCase().endsWith(".png")
450-
&& handle.style.filter != null) {
449+
if (OS.isIENeedPNGFix && handle.style.filter != null) {
451450
handle.style.filter = "";
452451
}
453452
} else {
454453
CSSStyle handleStyle = handle.style;
455-
if (OS.isIENeedPNGFix && image.url.toLowerCase().endsWith(".png") && handleStyle.filter != null) {
454+
if (OS.isIENeedPNGFix && image.url != null && image.url.toLowerCase().endsWith(".png") && handleStyle.filter != null) {
456455
handleStyle.backgroundImage = "";
457456
handleStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\"" + this.image.url + "\", sizingMethod=\"image\")";
458457
} else {

0 commit comments

Comments
 (0)