X Tutup
Skip to content

Commit 7c2b943

Browse files
author
jossonsmith
committed
1. Try to implement integrate Monitor with HTML element. That is to say treat HTML element
with CSS style "display:block;" as monitor. 2. Comment out some not commonly used codes temporarily.
1 parent 8c99799 commit 7c2b943

File tree

21 files changed

+520
-290
lines changed

21 files changed

+520
-290
lines changed

sources/net.sf.j2s.java.org.eclipse.swt/.j2s

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

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

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
package org.eclipse.swt.internal;
1515

1616
import org.eclipse.swt.graphics.Point;
17+
import org.eclipse.swt.graphics.Rectangle;
1718
import org.eclipse.swt.internal.xhtml.document;
1819
import org.eclipse.swt.internal.xhtml.window;
1920
import org.eclipse.swt.widgets.Decorations;
21+
import org.eclipse.swt.widgets.Monitor;
2022

2123
/**
2224
* @author josson smith
@@ -36,29 +38,32 @@ public ResizeHandler(Decorations shell, int status) {
3638
}
3739

3840
public void updateMinimized() {
39-
shell.setLocation(-1, document.body.clientHeight - 26);
41+
shell.setLocation(-1, shell.getMonitor().getClientArea().height - 26);
4042
}
4143
public void updateMaximized() {
42-
int height = document.body.clientHeight - 0;
43-
if (height > window.screen.availHeight - 10) {
44-
height = window.screen.availHeight - 10;
44+
Monitor monitor = shell.getMonitor();
45+
Rectangle clientArea = monitor.getClientArea();
46+
Rectangle bounds = monitor.getBounds();
47+
int height = clientArea.height - 0;
48+
if (height > bounds.height - 10) {
49+
height = bounds.height - 10;
4550
}
46-
int width = document.body.clientWidth;
47-
if (width > window.screen.availWidth) {
48-
width = window.screen.availWidth;
51+
int width = clientArea.width;
52+
if (width > bounds.width) {
53+
width = bounds.width;
4954
}
5055
// shell.setBounds(0 - 4, 0 - 4, width - 2, height + 4);
5156
shell.setBounds(shell.computeTrim(0, 0, width + 2, height - 18));
52-
document.body.scrollTop = 0;
5357
}
5458
public void updateCentered() {
5559
// Not used now
60+
Monitor monitor = shell.getMonitor();
5661
Point size = shell.getSize();
57-
int y = (document.body.clientHeight - size.y) / 2 - 20;
62+
int y = (monitor.getClientArea().height - size.y) / 2 - 20;
5863
if (y < 0) {
5964
y = 0;
6065
}
61-
shell.setLocation((document.body.clientWidth - size.x) / 2, y);
66+
shell.setLocation((monitor.getClientArea().width - size.x) / 2, y);
6267
}
6368
public int getStatus() {
6469
return status;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ private static void init() {
120120
document.body.appendChild (el);
121121
CSSStyle s = el.style;
122122
s.position = "absolute";
123+
s.left = "-4000px";
123124
s.top = "-300px";
124125
s.width = "3000px";
125126
s.height = "100px";
@@ -428,7 +429,7 @@ static public Point getElementPositionInShell(Element elem, Element shellElem){
428429
Element currentElem = elem;
429430
int left = 0;
430431
int top = 0;
431-
while (currentElem != shellElem) {
432+
while (currentElem != null && currentElem != shellElem) {
432433
left += currentElem.offsetLeft;
433434
top += currentElem.offsetTop;
434435
currentElem = currentElem.offsetParent;

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

Lines changed: 24 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -20,84 +20,44 @@
2020
* @author josson smith
2121
*
2222
* 2006-3-15
23+
*
2324
* @j2sSuffix
2425
var methods = ["onmousedown", "onmouseup", "onmousemove",
2526
"onkeyup", "onselectstart"];
2627
for (var i = 0; i < methods.length; i++) {
2728
org.eclipse.swt.internal.dnd.DNDUtils["$" + methods[i]] =
2829
org.eclipse.swt.internal.dnd.DNDUtils[methods[i]];
2930
}
30-
org.eclipse.swt.internal.dnd.DNDUtils.bindFunctionWith = function (aFun, obj) {
31-
var xFun = null;
32-
eval ("xFun = " + aFun + ";");
33-
return (function (yFun, o) {
34-
return function (e) {
35-
return yFun (e, o);
36-
}
37-
}) (xFun, obj);
38-
};
39-
org.eclipse.swt.internal.dnd.HTMLEventWrapper.prototype.wrapEvent = null;
40-
org.eclipse.swt.internal.dnd.HTMLEventWrapper.mozLastButton = 0;
41-
Clazz.defineMethod (org.eclipse.swt.internal.dnd.HTMLEventWrapper, "wrapEvent",
42-
function (e) {
43-
this.target = null;
44-
this.x = 0;
45-
this.y = 0;
46-
this.leftButtonHold = true;
47-
this.event = null;
48-
this.type = 0;
49-
50-
// See more about Event properties at
51-
// http://www.quirksmode.org/js/events_properties.html
52-
if (!e) {
53-
e = window.event;
54-
this.stopPropagation = function () {
55-
this.event.cancelBubble = true;
56-
};
57-
this.preventDefault = function () {
58-
this.event.returnValue = false;
59-
};
60-
} else {
61-
this.stopPropagation = function () {
62-
this.event.stopPropagation ();
63-
};
64-
this.preventDefault = function () {
65-
this.event.preventDefault ();
66-
};
67-
}
68-
this.event = e;
69-
this.type = e.type;
70-
if (e.target) {
71-
this.target = e.target;
72-
} else if (e.srcElement) {
73-
this.target = e.srcElement;
74-
}
75-
if (e.pageX || e.pageY) {
76-
this.x = e.pageX;
77-
this.y = e.pageY;
78-
} else if (e.clientX || e.clientY) {
79-
this.x = e.clientX + document.body.scrollLeft;
80-
this.y = e.clientY + document.body.scrollTop;
81-
}
82-
83-
if (e.which) {
84-
this.leftButtonHold = (e.which == 1);
85-
if (e.which == 19 || e.which == 65536 || e.which > 8) {
86-
this.leftButtonHold = (org.eclipse.swt.internal.dnd.HTMLEventWrapper.mozLastButton == 1);
87-
} else {
88-
org.eclipse.swt.internal.dnd.HTMLEventWrapper.mozLastButton = e.which;
89-
}
90-
} else if (e.button) {
91-
this.leftButtonHold = (e.button == 1);
92-
}
93-
}, "Object");
9431
*/
9532
public class DNDUtils {
9633
public static Object onselectstart;
9734
public static Object onmousemove;
9835
public static Object onmousedown;
9936
public static Object onmouseup;
10037
public static Object onkeyup;
38+
39+
/**
40+
* @param aFun
41+
* @param obj
42+
* @return
43+
*
44+
* @j2sNative
45+
var xFun = null;
46+
eval ("xFun = " + a + ";");
47+
return (function (yFun, o) {
48+
return function (e) {
49+
return yFun (e, o);
50+
}
51+
}) (xFun, b);
52+
* @j2sNativeSrc
53+
var xFun = null;
54+
eval ("xFun = " + aFun + ";");
55+
return (function (yFun, o) {
56+
return function (e) {
57+
return yFun (e, o);
58+
}
59+
}) (xFun, obj);
60+
*/
10161
public static Object bindFunctionWith(Object aFun, Object obj) {
10262
return obj;
10363
}

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

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
* @author josson smith
2020
*
2121
* 2006-3-15
22+
*
23+
* @j2sSuffix
24+
org.eclipse.swt.internal.dnd.HTMLEventWrapper.mozLastButton = 0;
2225
*/
2326
public class HTMLEventWrapper {
2427
public Element target;
@@ -33,7 +36,63 @@ public HTMLEventWrapper(Object event) {
3336
this.wrapEvent(event);
3437
}
3538

36-
protected void wrapEvent(Object event) {
39+
/**
40+
* @param a
41+
*
42+
* @j2sNative
43+
var e = a; // event
44+
this.target = null;
45+
this.x = 0;
46+
this.y = 0;
47+
this.leftButtonHold = true;
48+
this.event = null;
49+
this.type = 0;
50+
51+
// See more about Event properties at
52+
// http://www.quirksmode.org/js/events_properties.html
53+
if (!e) {
54+
e = window.event;
55+
this.stopPropagation = function () {
56+
this.event.cancelBubble = true;
57+
};
58+
this.preventDefault = function () {
59+
this.event.returnValue = false;
60+
};
61+
} else {
62+
this.stopPropagation = function () {
63+
this.event.stopPropagation ();
64+
};
65+
this.preventDefault = function () {
66+
this.event.preventDefault ();
67+
};
68+
}
69+
this.event = e;
70+
this.type = e.type;
71+
if (e.target) {
72+
this.target = e.target;
73+
} else if (e.srcElement) {
74+
this.target = e.srcElement;
75+
}
76+
if (e.pageX || e.pageY) {
77+
this.x = e.pageX;
78+
this.y = e.pageY;
79+
} else if (e.clientX || e.clientY) {
80+
this.x = e.clientX + document.body.scrollLeft;
81+
this.y = e.clientY + document.body.scrollTop;
82+
}
83+
84+
if (e.which) {
85+
this.leftButtonHold = (e.which == 1);
86+
if (e.which == 19 || e.which == 65536 || e.which > 8) {
87+
this.leftButtonHold = (org.eclipse.swt.internal.dnd.HTMLEventWrapper.mozLastButton == 1);
88+
} else {
89+
org.eclipse.swt.internal.dnd.HTMLEventWrapper.mozLastButton = e.which;
90+
}
91+
} else if (e.button) {
92+
this.leftButtonHold = (e.button == 1);
93+
}
94+
*/
95+
protected void wrapEvent(Object a) {
3796

3897
}
3998

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*
2424
* 2006-3-15
2525
*/
26-
public class SashDND extends DragAdapter {
26+
public class SashDND implements DragListener {
2727
protected int sourceX = 0;
2828
protected int sourceY = 0;
2929
protected Element thumb;
@@ -129,4 +129,8 @@ public boolean dragging(DragEvent e) {
129129
return true;
130130
}
131131

132+
public boolean isDraggable(HTMLEventWrapper e) {
133+
return true;
134+
}
135+
132136
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*
2222
* 2006-3-15
2323
*/
24-
public class ScaleDND extends DragAdapter {
24+
public class ScaleDND implements DragListener {
2525
protected int sourceX = 0;
2626
protected int sourceY = 0;
2727
protected boolean isHorizontal;
@@ -95,4 +95,8 @@ public boolean dragging(DragEvent e) {
9595
return true;
9696
}
9797

98+
public boolean isDraggable(HTMLEventWrapper e) {
99+
return true;
100+
}
101+
98102
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*
2424
* 2006-3-15
2525
*/
26-
public class ShellFrameDND extends DragAdapter {
26+
public class ShellFrameDND implements DragListener {
2727
int sourceX = 0;
2828
int sourceY = 0;
2929
int sourceWidth = 0;

0 commit comments

Comments
 (0)
X Tutup