Skip to content

Commit 39c70c7

Browse files
author
zhourenjian
committed
Change the type of Element.style.zIndex into int type, so the codes should be a lot clearer. And it is considered as compatible with IE/Firefox/WebKit/Opera
1 parent b808921 commit 39c70c7

File tree

18 files changed

+93
-87
lines changed

18 files changed

+93
-87
lines changed

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/internal/dnd/ShellFrameDND.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public boolean dragBegan(DragEvent e) {
5555
this.frame.style.backgroundColor = "menu";
5656
this.frame.style.left = this.sourceX + "px";
5757
this.frame.style.top = this.sourceY + "px";
58-
this.frame.style.zIndex = "" + (Integer.parseInt(window.currentTopZIndex) + 100);
58+
this.frame.style.zIndex = window.currentTopZIndex + 100;
5959
document.body.appendChild (this.frame);
6060
boolean existedTitleBar = false;
6161
Element[] els = e.sourceElement.getElementsByTagName("DIV");
@@ -325,7 +325,7 @@ public boolean dragEnded(DragEvent e) {
325325
// shell.style.top = y + "px";
326326
// shell.style.width = width + "px";
327327
// shell.style.height = height + "px";
328-
shell.style.zIndex = window.currentTopZIndex = "" + (Integer.parseInt(window.currentTopZIndex) + 2);
328+
shell.style.zIndex = window.currentTopZIndex = window.currentTopZIndex + 2;
329329

330330
// ShellFrameDND.fixShellHeight (e.sourceElement);
331331
// ShellFrameDND.fixShellWidth (e.sourceElement);

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/internal/xhtml/CSSStyle.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class CSSStyle {
1717
public String overflow;
1818
public String opacity;
1919

20-
public String zIndex;
20+
public int zIndex;
2121
public String textIndent;
2222
public String textDecoration;
2323
public String textAlign;

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/internal/xhtml/window.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ public class window {
55
public static String defaultWindowTop;
66
public static String defaultWindowWidth;
77
public static String defaultWindowHeight;
8-
public static String currentTopZIndex;
8+
public static int currentTopZIndex;
99

1010
public static int clientWidth;
1111
public static int clientHeight;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,9 +766,9 @@ void show(){
766766
//h -= 2;
767767
}
768768
this.selectShown = true;
769-
window.currentTopZIndex = "" + (Integer.parseInt(window.currentTopZIndex) + 1);
769+
window.currentTopZIndex = window.currentTopZIndex + 1;
770770
// related bug: http://groups.google.com/group/java2script/browse_thread/thread/8085561fcf953fc?hl=en
771-
selectInput.style.zIndex = "" + (Integer.parseInt(window.currentTopZIndex) + 4); //sgurin
771+
selectInput.style.zIndex = window.currentTopZIndex + 4; //sgurin
772772
try {
773773
handle.removeChild(selectInput);
774774
document.body.appendChild(selectInput);

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,8 @@ void bringToTop (boolean parentShell, boolean childShells) {
238238
// if (style.display == "none") {
239239
// style.display = "block";
240240
// }
241-
if (window.currentTopZIndex == null) {
242-
window.currentTopZIndex = "1000";
243-
}
244241
if (style.zIndex != window.currentTopZIndex) {
245-
style.zIndex = window.currentTopZIndex = ""
246-
+ (Integer.parseInt(window.currentTopZIndex) + 2);
242+
style.zIndex = window.currentTopZIndex = window.currentTopZIndex + 2;
247243
}
248244
if ((style.width == null || style.width.length() == 0)
249245
&& (style.height == null || style.height.length() == 0)){
@@ -275,8 +271,7 @@ void bringToTop (boolean parentShell, boolean childShells) {
275271
&& (control instanceof Shell)/* && control.isVisible()*/) {
276272
style = control.handle.style;
277273
if (style != null && style.zIndex != window.currentTopZIndex) {
278-
style.zIndex = window.currentTopZIndex = ""
279-
+ (Integer.parseInt(window.currentTopZIndex) + 2);
274+
style.zIndex = window.currentTopZIndex = window.currentTopZIndex + 2;
280275
}
281276
}
282277
}
@@ -296,7 +291,7 @@ void bringToTop (boolean parentShell, boolean childShells) {
296291
}
297292

298293
if (modalHandle != null) {
299-
modalHandle.style.zIndex = "" + (Integer.parseInt("" + handle.style.zIndex) - 1);
294+
modalHandle.style.zIndex = handle.style.zIndex - 1;
300295
}
301296
}
302297

@@ -825,7 +820,7 @@ void nextWindowLocation(int wHint, int hHint) {
825820
void addModalLayer() {
826821
modalHandle = document.createElement ("DIV");
827822
modalHandle.className = "shell-modal-block";
828-
modalHandle.style.zIndex = "" + (Integer.parseInt("" + handle.style.zIndex) - 1);
823+
modalHandle.style.zIndex = handle.style.zIndex - 1;
829824
getMonitor().handle.insertBefore(modalHandle, handle);
830825
}
831826

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public abstract class DesktopItem {
2121

2222
boolean mouseAlreadyMoved;
2323

24-
String layerZIndex = null;
24+
int layerZIndex = -1;
2525

2626
private Runnable leaving;
2727

@@ -53,7 +53,7 @@ public void run() {
5353

5454
public abstract void initialize();
5555

56-
public abstract void bringToTop(String zIndex);
56+
public abstract void bringToTop(int zIndex);
5757

5858
public abstract void updateLayout();
5959

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@
159159
FontSizeSystem.monitorFontSize (true)
160160
}, 250);
161161
};
162+
window.currentTopZIndex = 1000;
162163
*/
163164

164165
public class Display extends Device {
@@ -4554,15 +4555,10 @@ static int wcsToMbcs (char ch) {
45544555
}
45554556
*/
45564557

4557-
static String getNextZIndex(boolean increase) {
4558-
String zIndex = "";
4559-
if (window.currentTopZIndex == null) {
4560-
zIndex = "1000";
4561-
} else {
4562-
zIndex = (Integer.parseInt(window.currentTopZIndex) + 1) + "";
4563-
if (increase) {
4564-
window.currentTopZIndex = zIndex;
4565-
}
4558+
static int getNextZIndex(boolean increase) {
4559+
int zIndex = window.currentTopZIndex + 1;
4560+
if (increase) {
4561+
window.currentTopZIndex = zIndex;
45664562
}
45674563
return zIndex;
45684564
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
height:1.6em;
1212
min-height:24px;
1313
_height:1.7em;*/
14+
width:320px;
15+
z-index:6174;
1416
text-align:left;
1517
font-size:0;
1618
margin:0;

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ public void initialize() {
8484
tbc.className = "shell-manager-topbar-container";
8585
document.body.appendChild(tbc);
8686
tbc.style.display = "none";
87-
tbc.style.width = "320px";
88-
tbc.style.zIndex = "3456";
8987
this.handle = tbc;
9088

9189
boolean supportShadow = false;
@@ -170,8 +168,7 @@ public boolean handleMouseMove(long now, int x, int y, boolean ctrlKey) {
170168
return false;
171169
}
172170

173-
public void bringToTop(String index) {
174-
// TODO Auto-generated method stub
171+
public void bringToTop(int index) {
175172

176173
}
177174

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ void _setVisible (boolean visible) {
221221
if (visible) {
222222
//style.width = "200px";
223223
Rectangle clientArea = getDisplay().getPrimaryMonitor().getClientArea();
224-
style.zIndex = "1" + window.currentTopZIndex;
224+
style.zIndex = window.currentTopZIndex + 1000;
225225
style.display = "block";
226226
handle.style.height = "";
227227
int height = OS.getContainerHeight(handle);

0 commit comments

Comments
 (0)