Skip to content

Commit b9f62a7

Browse files
author
jossonsmith
committed
Refine Spinner, Combo, List
Reformat part of sources, so I can compare codes with SWT win32 sources
1 parent d42ced4 commit b9f62a7

File tree

12 files changed

+3359
-3196
lines changed

12 files changed

+3359
-3196
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Java2Script Configuration
2-
#Sat Aug 26 21:21:26 CST 2006
2+
#Sun Sep 10 22:20:48 CST 2006
33
j2s.compiler.visitor=SWTScriptVisitor
44
j2s.abandoned.resources.list=bin/org/eclipse/swt/internal/xhtml/window.js,bin/org/eclipse/swt/internal/xhtml/document.js,bin/org/eclipse/swt/internal/xhtml/Screen.js,bin/org/eclipse/swt/internal/xhtml/Option.js,bin/org/eclipse/swt/internal/xhtml/Element.js,bin/org/eclipse/swt/internal/xhtml/ContentWindow.js,bin/org/eclipse/swt/internal/xhtml/Clazz.js,bin/org/eclipse/swt/internal/xhtml/CSSStyle.js,bin/org/eclipse/swt/internal/xhtml/Body.js,bin/org/eclipse/swt/internal/xhtml/HTMLEvent.js
55
j2s.compiler.abbreviation=true

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

Lines changed: 75 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
package org.eclipse.swt.internal.browser;
1515

16+
import org.eclipse.swt.SWT;
1617
import org.eclipse.swt.graphics.Point;
1718
import org.eclipse.swt.internal.xhtml.CSSStyle;
1819
import org.eclipse.swt.internal.xhtml.Element;
@@ -425,20 +426,86 @@ public static Point getStringStyledSize(String str, String className, String css
425426
return new Point(getContainerWidth(c), getContainerHeight(c));
426427
}
427428

428-
static public Point getElementPositionInShell(Element elem, Element shellElem){
429-
Element currentElem = elem;
429+
public static Point calcuateRelativePosition(Element el, Element relativeEl){
430+
Element currentEl = el;
430431
int left = 0;
431432
int top = 0;
432-
while (currentElem != null && currentElem != shellElem) {
433-
left += currentElem.offsetLeft;
434-
top += currentElem.offsetTop;
435-
currentElem = currentElem.offsetParent;
433+
while (currentEl != null && currentEl != relativeEl) {
434+
left += currentEl.offsetLeft;
435+
top += currentEl.offsetTop;
436+
currentEl = currentEl.offsetParent;
436437
}
437-
// System.out.println(getShell().she)
438438
if(isFirefox){
439+
// why?
439440
left += 6;
440441
top += 2;
441442
}
442-
return new Point(left, top + OS.getContainerHeight(elem));
443+
return new Point(left, top + OS.getContainerHeight(el));
443444
}
445+
446+
public static void updateArrowSize(Object el, int style, int cx, int cy) {
447+
int xx = Math.min(cx, cy) / 3;
448+
final CSSStyle s = ((Element) el).style;
449+
s.borderWidth = (xx > 0 ? xx : 0) + "px";
450+
if ((style & SWT.LEFT) != 0) {
451+
s.borderLeftWidth = "0";
452+
} else if ((style & SWT.RIGHT) != 0) {
453+
s.borderRightWidth = "0";
454+
} else if ((style & SWT.UP) != 0) {
455+
s.borderTopWidth = "0";
456+
} else if ((style & SWT.DOWN) != 0) {
457+
if (xx > 1) {
458+
s.borderWidth = (xx - 1) + "px";
459+
}
460+
s.borderBottomWidth = "0";
461+
} else {
462+
s.borderTopWidth = "0";
463+
}
464+
int x = cy / 6;
465+
xx = cy / 3;
466+
s.position = "relative";
467+
if ((style & (SWT.RIGHT | SWT.LEFT)) != 0) {
468+
s.top = (x - 3) + "px";
469+
if ((style & SWT.RIGHT) != 0) {
470+
s.left = "1px";
471+
}
472+
} else {
473+
if ((style & SWT.UP) != 0) {
474+
s.top = (xx - 3)+ "px";
475+
} else if ((style & SWT.DOWN) != 0) {
476+
s.top = (xx - 2)+ "px";
477+
}
478+
}
479+
/**
480+
* TODO: Get rid of these nasty position things!
481+
*/
482+
if (OS.isMozilla && !OS.isFirefox) {
483+
if ((style & SWT.UP) != 0) {
484+
s.left = "-2px";
485+
} else if ((style & SWT.DOWN) != 0) {
486+
s.left = "-1px";
487+
}
488+
}
489+
if (OS.isFirefox) {
490+
if ((style & (SWT.RIGHT | SWT.LEFT)) != 0) {
491+
s.top = "-2px";
492+
if ((style & SWT.RIGHT) != 0) {
493+
s.left = "1px";
494+
}
495+
} else {
496+
if ((style & SWT.UP) != 0) {
497+
if (Math.min(cx, cy) <= 12) {
498+
s.left = "-1px";
499+
} else {
500+
s.left = "-2px";
501+
}
502+
s.top = "-1px";
503+
} else if ((style & SWT.DOWN) != 0) {
504+
s.left = "-1px";
505+
s.top = "-1px";
506+
}
507+
}
508+
}
509+
}
510+
444511
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public class Element {
5555

5656
public boolean readOnly;
5757

58+
public boolean multiple;
59+
5860
public Object onchange;
5961

6062
public Object onselectchange;

0 commit comments

Comments
 (0)