Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 469bf08

Browse files
committed
1. Fix box-sizing css bug
2. Adjust theme color to make it more friendly to Mac OS X users 3. Adjust maximized window size 4. Other pixel adjustment
1 parent 2ab2071 commit 469bf08

30 files changed

+173
-55
lines changed

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

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
import org.eclipse.swt.SWT;
1515
import org.eclipse.swt.graphics.Point;
1616
import org.eclipse.swt.graphics.Rectangle;
17-
import org.eclipse.swt.internal.browser.OS;
18-
import org.eclipse.swt.internal.xhtml.Element;
1917
import org.eclipse.swt.widgets.Decorations;
2018
import org.eclipse.swt.widgets.Monitor;
2119
import org.eclipse.swt.widgets.QuickLaunch;
@@ -73,25 +71,30 @@ private Rectangle getClientArea() {
7371

7472
public void updateMinimized() {
7573
Rectangle clientArea = getClientArea();
76-
Element tb = null;
74+
int titleHeight = 0;
75+
if ((shell.getStyle() & SWT.TITLE) != 0)
7776
/**
7877
* @j2sNative
79-
* tb = this.shell.titleBar;
78+
* try {
79+
* titleHeight = this.shell.getTitleBarHeight();
80+
* } catch (e) {
81+
* }
8082
*/ {}
81-
int h = ((shell.getStyle() & SWT.TITLE) != 0) ? OS.getContainerHeight(tb) : 0;
82-
shell.setLocation(clientArea.x - 1, clientArea.y + clientArea.height - h - 6);
83+
shell.setLocation(clientArea.x - 1, clientArea.y + clientArea.height - titleHeight - 6);
8384
}
8485

8586
public void updateMaximized() {
8687
Rectangle clientArea = getClientArea();
8788

88-
//int titleHeight = ((shell.getStyle() & SWT.TITLE) != 0) ? 20 : 0;
89-
Element tb = null;
89+
int titleHeight = 0;
90+
if ((shell.getStyle() & SWT.TITLE) != 0)
9091
/**
9192
* @j2sNative
92-
* tb = this.shell.titleBar;
93+
* try {
94+
* titleHeight = this.shell.getTitleBarHeight();
95+
* } catch (e) {
96+
* }
9397
*/ {}
94-
int titleHeight = ((shell.getStyle() & SWT.TITLE) != 0) ? OS.getContainerHeight(tb) : 0;
9598
// FIXME: maximized size is not accurate
9699
//shell.setBounds(shell.computeTrim(0, 0, width + 4, height - titleHeight + 6));
97100
boolean disablingMaxBar = false;
@@ -105,12 +108,13 @@ public void updateMaximized() {
105108
} else if ((status & SWT.TOP) != 0 && (status & SWT.BOTTOM) != 0) {
106109
Rectangle bounds = shell.getBounds();
107110
int shellWidth = shell.getSize().x;
111+
int deltaHeight = 0; // 2
108112
if ((status & SWT.LEFT) != 0) {
109-
shell.setBounds(clientArea.x, clientArea.y, shellWidth, clientArea.height + 2);
113+
shell.setBounds(clientArea.x, clientArea.y, shellWidth, clientArea.height + deltaHeight);
110114
} else if ((status & SWT.RIGHT) != 0) {
111-
shell.setBounds(clientArea.x + clientArea.width - shellWidth, clientArea.y, shellWidth, clientArea.height + 2);
115+
shell.setBounds(clientArea.x + clientArea.width - shellWidth, clientArea.y, shellWidth, clientArea.height + deltaHeight);
112116
} else {
113-
shell.setBounds(bounds.x, clientArea.y, shellWidth, clientArea.height + 2);
117+
shell.setBounds(bounds.x, clientArea.y, shellWidth, clientArea.height + deltaHeight);
114118
}
115119
} else if ((status & SWT.LEFT) != 0 && (status & SWT.RIGHT) != 0) {
116120
Rectangle bounds = shell.getBounds();
@@ -129,12 +133,13 @@ public void updateMaximized() {
129133
} else if ((status & SWT.TOP) != 0 && (status & SWT.BOTTOM) != 0) {
130134
Rectangle bounds = shell.getBounds();
131135
int shellWidth = shell.getSize().x;
136+
int deltaHeight = 0; // 2
132137
if ((status & SWT.LEFT) != 0) {
133-
shell.setBounds(clientArea.x, clientArea.y, shellWidth, clientArea.height + 2);
138+
shell.setBounds(clientArea.x, clientArea.y, shellWidth, clientArea.height + deltaHeight);
134139
} else if ((status & SWT.RIGHT) != 0) {
135-
shell.setBounds(clientArea.x + clientArea.width - shellWidth + 2, clientArea.y, shellWidth, clientArea.height + 2);
140+
shell.setBounds(clientArea.x + clientArea.width - shellWidth + 2, clientArea.y, shellWidth, clientArea.height + deltaHeight);
136141
} else {
137-
shell.setBounds(bounds.x, clientArea.y, shellWidth, clientArea.height + 2);
142+
shell.setBounds(bounds.x, clientArea.y, shellWidth, clientArea.height + deltaHeight);
138143
}
139144
} else if ((status & SWT.LEFT) != 0 && (status & SWT.RIGHT) != 0) {
140145
Rectangle bounds = shell.getBounds();

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ private static void checkScrollBar() {
273273
s.width = "324px";
274274
s.height = "324px";
275275
document.body.appendChild(el);
276-
wScrollBar = el.offsetWidth - el.clientWidth;
277-
hScrollBar = el.offsetHeight - el.clientHeight;
276+
wScrollBar = Math.max(14, el.offsetWidth - el.clientWidth);
277+
hScrollBar = Math.max(14, el.offsetHeight - el.clientHeight);
278278
//document.body.removeChild(el);
279279
destroyHandle(el);
280280
}
@@ -462,6 +462,7 @@ private static Element setupAsStyled(String str, String className, String cssTex
462462
* f = e[g];
463463
*/ {
464464
e = g; // non-sense code
465+
if (g.length() > 0) f = (Element) e; // non-sense code
465466
}
466467
if (f != null) {
467468
clearChildren (f);
@@ -487,6 +488,8 @@ private static Element setupAsStyled(String str, String className, String cssTex
487488
}
488489
if (wrappedWidth > 0) {
489490
f.style.width = wrappedWidth + "px";
491+
} else {
492+
f.style.width = "";
490493
}
491494
/*
492495
* Set other container invisible to make sure the size is accurate

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ public class CSSStyle {
1515
public String display;
1616
public String visibility;
1717
public String overflow;
18+
public String overflowX;
19+
public String overflowY;
1820
public String opacity;
1921

2022
public int zIndex;
2123
public String textIndent;
2224
public String textDecoration;
2325
public String textAlign;
2426
public String xfloat;
27+
public String clear;
2528
public String cursor;
2629

2730
public String color;
@@ -40,6 +43,7 @@ public class CSSStyle {
4043

4144
public String border;
4245
public String borderWidth;
46+
public String borderRadius;
4347
public String borderStyle;
4448
public String borderColor;
4549
public String borderLeft;
@@ -52,10 +56,14 @@ public class CSSStyle {
5256
public String borderRightColor;
5357
public String borderTop;
5458
public String borderTopWidth;
59+
public String borderTopLeftRadius;
60+
public String borderTopRightRadius;
5561
public String borderTopStyle;
5662
public String borderTopColor;
5763
public String borderBottom;
5864
public String borderBottomWidth;
65+
public String borderBottomLeftRadius;
66+
public String borderBottomRightRadius;
5967
public String borderBottomStyle;
6068
public String borderBottomColor;
6169

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static void openAbout(Shell objShell) {
6161
gridLayout.horizontalSpacing = 0;
6262
aboutShell.setLayout(gridLayout);
6363

64-
aboutShell.setMinimumSize(442, 301);
64+
aboutShell.setMinimumSize(480, 300);
6565
aboutShell.open();
6666
aboutShell.layout();
6767
aboutShell.pack();
@@ -92,6 +92,7 @@ public void widgetDisposed(DisposeEvent e) {
9292

9393
/**
9494
* Create contents of the window
95+
* @wbp.parser.entryPoint
9596
*/
9697
private static void createContents(Shell aboutShell) {
9798
final Composite composite = new Composite(aboutShell, SWT.NONE);
@@ -145,18 +146,23 @@ private static void createContents(Shell aboutShell) {
145146
*/ {}
146147
java2scriptj2sPacemakerLabel.setFont(j2sFont);
147148
java2scriptj2sPacemakerLabel.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
148-
java2scriptj2sPacemakerLabel.setLayoutData(new GridData(225, SWT.DEFAULT));
149-
java2scriptj2sPacemakerLabel.setText("Java2Script (J2S) open source project provides an Eclipse Java to JavaScript compiler plugin, provides java.lang.*, java.util.* and other common utilities, provides an JavaScript implementation of Eclipse Standard Widget Toolkit (SWT), supports SWT-based Rich Client Platform (RCP) to Rich Internet Application (RIA) conversions.");
149+
GridData gd_java2scriptj2sPacemakerLabel = new GridData(260, SWT.DEFAULT);
150+
gd_java2scriptj2sPacemakerLabel.verticalIndent = 12;
151+
java2scriptj2sPacemakerLabel.setLayoutData(gd_java2scriptj2sPacemakerLabel);
152+
java2scriptj2sPacemakerLabel.setText("Java2Script (J2S) project provides a Java to JavaScript compiler plugin for Eclipse, provides java.lang.*, java.util.* and other common APIs, provides a JavaScript version of Eclipse Standard Widget Toolkit (SWT), supports converting SWT-based applications to web applications running in moderm browsers.");
150153

151154
final Link homepageLink = new Link(description, SWT.NONE);
152155
homepageLink.setFont(j2sFont);
153156
final GridData gd_homepageLink = new GridData();
157+
gd_homepageLink.horizontalAlignment = SWT.FILL;
158+
gd_homepageLink.grabExcessHorizontalSpace = true;
154159
gd_homepageLink.verticalIndent = 8;
155160
homepageLink.setLayoutData(gd_homepageLink);
156161
homepageLink.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
157162
homepageLink.setText("Home: <a href=\"http://java2script.org/\">java2script.org</a> / <a href=\"http://j2s.sourceforge.net/\">j2s.sourceforge.net</a>");
158163

159164
final Link founderLink = new Link(description, SWT.NONE);
165+
founderLink.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
160166
founderLink.setFont(j2sFont);
161167
founderLink.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
162168
founderLink.setText("Founder: <a href=\"http://zhourenjian.name/\">Zhou Renjian</a>");

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
padding:0;
3636
width:100%;
3737
height:100%;
38+
box-sizing: border-box !important;
3839
}
3940

4041
* html .button-push {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,7 @@ private void updateImagePosition() {
14481448
if (OS.isIE50 || OS.isIE55 || OS.isIE60 || OS.isIE70) {
14491449
btnIcon.style.marginTop = "2px";
14501450
}
1451-
} else if (OS.isFirefox) {
1451+
} else if (OS.isFirefox || OS.isSafari || OS.isChrome) {
14521452
btnIcon.style.marginTop = "-1px";
14531453
}
14541454

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
overflow:hidden;
1515
/*border-style:none;*/
1616
/*background-color:white;*/
17+
box-sizing: content-box !important;
1718
}
1819

1920
.combo-default button {
@@ -27,6 +28,7 @@
2728
padding:0;
2829
font-size:0;
2930
margin:0;
31+
box-sizing: border-box !important;
3032
}
3133
* html .combo-default button {
3234
right:-2px;

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1859,6 +1859,8 @@ void setBounds (int x, int y, int width, int height, int flags) {
18591859
textInput.style.height = Math.max(0, height - 4) + "px";
18601860
textInput.style.lineHeight = Math.max(0, height - 4) + "px";
18611861
textInput.style.marginTop = "0";
1862+
textInput.style.width = Math.max(0, width - buttonWidth - 3 - 4) + "px";
1863+
textInput.style.marginTop = "-2px";
18621864
} else if (OS.isSafari || OS.isChrome) {
18631865
textInput.style.marginTop = "0";
18641866
} else if (OS.isIE) {
@@ -1899,7 +1901,7 @@ void setBounds (int x, int y, int width, int height, int flags) {
18991901
selectInput.style.marginTop = "0";
19001902
textInput.style.height = (buttonHeight - 8) + "px";
19011903
if (OS.isChrome) {
1902-
textInput.style.width = (width - 5) + "px";
1904+
textInput.style.width = (width - 5 - 1) + "px"; // 1: padding-left: 1px in css
19031905
}
19041906
//selectInput.style.height = (Math.max(0, height - buttonHeight)) + "px";
19051907
} else if (OS.isIE || OS.isOpera) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ public int getBorderWidth() {
375375
}
376376

377377
int getChildrenCount () {
378-
if (true) return 0;
378+
return 0;
379379
/*
380380
* NOTE: The current implementation will count
381381
* non-registered children.
@@ -390,7 +390,7 @@ int getChildrenCount () {
390390
*/
391391
// TODO: search the children and filter out the essential children
392392
// return count;
393-
return _getChildren().length;
393+
// return _getChildren().length;
394394
}
395395

396396
/**

0 commit comments

Comments
 (0)