Skip to content

Commit 684cb82

Browse files
author
jossonsmith
committed
Update widget background color and adjust Decorations#setMaximized
1 parent 99f810c commit 684cb82

17 files changed

Lines changed: 115 additions & 120 deletions

File tree

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import org.eclipse.swt.SWT;
1717
import org.eclipse.swt.graphics.Point;
1818
import org.eclipse.swt.graphics.Rectangle;
19+
import org.eclipse.swt.internal.browser.OS;
20+
import org.eclipse.swt.internal.xhtml.document;
1921
import org.eclipse.swt.widgets.Decorations;
2022
import org.eclipse.swt.widgets.Monitor;
2123

@@ -41,15 +43,17 @@ public void updateMinimized() {
4143
}
4244
public void updateMaximized() {
4345
Monitor monitor = shell.getMonitor();
44-
Rectangle clientArea = monitor.getClientArea();
45-
Rectangle bounds = monitor.getBounds();
46-
int height = clientArea.height - 0;
47-
if (height > bounds.height - 10) {
48-
height = bounds.height - 10;
49-
}
50-
int width = clientArea.width;
51-
if (width > bounds.width) {
52-
width = bounds.width;
46+
Rectangle area = monitor.getClientArea();
47+
int height = area.height;
48+
int width = area.width;
49+
boolean isBodyMonitor = false;
50+
/**
51+
* @j2sNative
52+
* isBodyMonitor = monitor.handle == document.body;
53+
*/ {}
54+
if (isBodyMonitor) { // update with current body client area
55+
width = document.body.parentNode.clientWidth;
56+
height = OS.getFixedBodyClientHeight();
5357
}
5458
int titleHeight = ((shell.getStyle() & SWT.TITLE) != 0) ? 20 : 0;
5559
// FIXME: maximized size is not accurate

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
}
1414

1515
.button-flat .button-push {
16-
border:2px solid gray;
16+
border:2px solid buttonshadow;
1717
}
1818

1919
.button-flat .button-toggle {
20-
border:2px solid gray;
20+
border:2px solid buttonshadow;
2121
}
2222

2323
.button-flat .button-arrow {
24-
border:2px solid gray;
24+
border:2px solid buttonshadow;
2525
}
2626

2727
.button-push, .button-toggle, .button-arrow {
@@ -30,10 +30,6 @@
3030
font-family:inherit;
3131
font-size:1em;
3232
font-size:inherit;
33-
/*
34-
background-color:inherit;
35-
color:inherit;
36-
*/
3733
margin:0;
3834
padding:0;
3935
width:100%;
@@ -52,7 +48,7 @@
5248
.button-push, .button-toggle, .button-arrow {
5349
border-width:2px;
5450
border-style:solid;
55-
background-color:menu;
51+
background-color:buttonface;
5652
border-color:#f0f0f0 #303030 #303030 #f0f0f0;
5753
}
5854
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,7 @@ public void run() {
12731273
if ((style & (SWT.CHECK | SWT.TOGGLE)) != 0) {
12741274
HTMLEvent e = (HTMLEvent) getEvent();
12751275
if ((style & SWT.CHECK) != 0) {
1276+
// Still buggy on check button with image
12761277
if (e.srcElement != btnHandle) {
12771278
setSelection (!getSelection ());
12781279
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
font-size:0;
44
width:200px;
55
height:280px;
6-
background-color:menu;
6+
background-color:buttonface;
77
overflow:hidden;
88
}
99
.color-dialog-custom {
@@ -54,7 +54,7 @@
5454
.define-custom-colors-button, .color-dialog-button, .add-to-custom-colors-button {
5555
border-width:2px;
5656
border-style:solid;
57-
background-color:menu;
57+
background-color:buttonface;
5858
border-color:#f0f0f0 #303030 #303030 #f0f0f0;
5959
}
6060
}
@@ -94,12 +94,12 @@
9494
.box-focus {
9595
float:left;
9696
margin:1px;
97-
border:1px solid menu;
97+
border:1px solid buttonface;
9898
width:21px;
9999
height:16px;
100100
}
101101
.box-select {
102-
border:1px solid menu;
102+
border:1px solid buttonface;
103103
width:19px;
104104
height:14px;
105105
}
@@ -197,7 +197,7 @@ div.color-cross-right {
197197
line-height:0;
198198

199199
border-style:solid solid solid none;
200-
border-color:menu;
200+
border-color:buttonface;
201201
border-right-color:black;
202202
border-width:5px;
203203
border-left-width:0;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
line-height:0;
3939

4040
border-style:solid solid none solid;
41-
border-color:menu;
41+
border-color:buttonface;
4242
border-top-color:black;
4343
border-bottom-width:0;
4444
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.cool-bar-default {
22
position:absolute;
3-
background-color:menu;
3+
background-color:buttonface;
44
cursor:default;
55
/*overflow:visible;
66
overflow-x:hidden;*/
@@ -88,7 +88,7 @@
8888
border-right:2px solid gray;
8989
}
9090
.cool-bar-locked .cool-item-handler {
91-
border-left:4px solid menu;
91+
border-left:4px solid buttonface;
9292
cursor:default;
9393
}
9494
.cool-item-content {
@@ -110,7 +110,7 @@
110110
.cool-item-more-enabled .cool-item-more {
111111
display:block !important;
112112
float:right;
113-
border:1px solid menu;
113+
border:1px solid buttonface;
114114
}
115115
.cool-item-more-enabled .cool-item-more:hover {
116116
border:1px outset white;
@@ -123,7 +123,7 @@
123123
cursor:default;
124124
}
125125
.cool-bar-disabled .cool-item-more:hover {
126-
border:1px solid menu !important;
126+
border:1px solid buttonface !important;
127127
}
128128
.swt-widgets-coolbar {
129129
width:324px;

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

Lines changed: 55 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,8 @@ public boolean getMaximized () {
10801080
if (OS.IsWindowVisible (handle)) return OS.IsZoomed (handle);
10811081
return swFlags == OS.SW_SHOWMAXIMIZED;
10821082
*/
1083-
return false; // TODO
1083+
//return OS.existedCSSClass(titleBar, "shell-maximized");
1084+
return oldBounds != null;
10841085
}
10851086

10861087
/**
@@ -1170,6 +1171,9 @@ public String getText () {
11701171
OS.GetWindowText (handle, buffer, length + 1);
11711172
return buffer.toString (0, length);
11721173
*/
1174+
if (this.shellTitle == null) {
1175+
return "";
1176+
}
11731177
Element[] children = this.shellTitle.childNodes;
11741178
if (children.length <= 0) {
11751179
return "";
@@ -1634,67 +1638,16 @@ public void setMaximized (boolean maximized) {
16341638
OS.UpdateWindow (handle);
16351639
}
16361640
*/
1637-
if (maximized && contentHandle != null) {
1638-
if (oldBounds == null) {
1639-
oldBounds = getBounds();
1640-
oldBounds.width -= 4; // FIXME
1641-
}
1642-
Monitor monitor = getMonitor();
1643-
int height = monitor.clientHeight - 0;
1644-
// if (height > getMonitor().height - 10) {
1645-
// height = getMonitor().height - 10;
1646-
// }
1647-
int width = monitor.clientWidth;
1648-
// if (width > getMonitor().width) {
1649-
// width = getMonitor().width;
1650-
// }
1651-
if (monitor.handle == document.body) { // update with current body client area
1652-
width = document.body.parentNode.clientWidth;
1653-
height = OS.getFixedBodyClientHeight();
1654-
}
1655-
int titleHeight = ((style & SWT.TITLE) != 0) ? 20 : 0;
1656-
setBounds(computeTrim(0, 0, width, height - titleHeight));
1657-
}
1658-
if (maximized) {
1659-
ResizeSystem.register(this, SWT.MAX);
1660-
} else {
1661-
ResizeSystem.unregister(this, SWT.MAX);
1662-
}
1663-
}
1664-
1665-
void toggleMaximize() {
16661641
String key = "shell-maximized";
16671642
Element b = document.body;
1668-
boolean isStrictMode = b.parentNode.clientHeight != 0;
1643+
boolean isStrictMode = b.parentNode.clientHeight != 0;
16691644
Element node = b;
16701645
if ((OS.isIE) && isStrictMode) {
16711646
node = b.parentNode;
16721647
}
16731648
Monitor monitor = getMonitor();
16741649
boolean updateBody = (monitor.handle == document.body); // update with current body client area
1675-
if (oldBounds != null) {
1676-
setBounds(oldBounds);
1677-
OS.removeCSSClass(titleBar, key);
1678-
oldBounds = null;
1679-
ResizeSystem.unregister(this, SWT.MAX);
1680-
if (updateBody) {
1681-
node.style.cssText = lastClientAreaCSSText;
1682-
b.style.cssText = lastBodyCSSText;
1683-
if (OS.isOpera) {
1684-
String ofl = node.style.overflow;
1685-
if (ofl == null || ofl.length() == 0) {
1686-
node.style.overflow = "auto";
1687-
}
1688-
ofl = node.style.overflow;
1689-
if (ofl == null || ofl.length() == 0) {
1690-
b.style.overflow = "auto";
1691-
}
1692-
}
1693-
node.scrollLeft = lastBodyScrollLeft;
1694-
node.scrollTop = lastBodyScrollTop;
1695-
node.onscroll = lastClientAreaOnScroll;
1696-
}
1697-
} else {
1650+
if (maximized) {
16981651
if (updateBody) {
16991652
lastBodyScrollLeft = node.scrollLeft;
17001653
lastBodyScrollTop = node.scrollTop;
@@ -1705,8 +1658,8 @@ void toggleMaximize() {
17051658
lastClientAreaOnScroll = node.onscroll;
17061659

17071660
node.style.border = "0 none transparent";
1708-
node.style.overflow = "hidden";
1709-
b.style.margin = "0";
1661+
node.style.overflow = "hidden";
1662+
b.style.margin = "0";
17101663
b.style.padding = "0";
17111664
node.scrollLeft = 0;
17121665
node.scrollTop = 0;
@@ -1721,10 +1674,51 @@ void toggleMaximize() {
17211674
* this.scrollTop = 0;
17221675
* };
17231676
*/ { }
1724-
}
1725-
setMaximized(true);
1726-
OS.addCSSClass(titleBar, key);
1727-
}
1677+
}
1678+
if (contentHandle != null) {
1679+
if (oldBounds == null) {
1680+
oldBounds = getBounds();
1681+
oldBounds.width -= 4; // FIXME
1682+
}
1683+
//Monitor monitor = getMonitor();
1684+
int height = monitor.clientHeight;
1685+
int width = monitor.clientWidth;
1686+
if (monitor.handle == document.body) { // update with current body client area
1687+
width = document.body.parentNode.clientWidth;
1688+
height = OS.getFixedBodyClientHeight();
1689+
}
1690+
int titleHeight = ((style & SWT.TITLE) != 0) ? 20 : 0;
1691+
setBounds(computeTrim(0, 0, width, height - titleHeight));
1692+
}
1693+
ResizeSystem.register(this, SWT.MAX);
1694+
if (titleBar != null) {
1695+
OS.addCSSClass(titleBar, key);
1696+
}
1697+
} else {
1698+
setBounds(oldBounds);
1699+
if (titleBar != null) {
1700+
OS.removeCSSClass(titleBar, key);
1701+
}
1702+
oldBounds = null;
1703+
ResizeSystem.unregister(this, SWT.MAX);
1704+
if (updateBody) {
1705+
node.style.cssText = lastClientAreaCSSText;
1706+
b.style.cssText = lastBodyCSSText;
1707+
if (OS.isOpera) {
1708+
String ofl = node.style.overflow;
1709+
if (ofl == null || ofl.length() == 0) {
1710+
node.style.overflow = "auto";
1711+
}
1712+
ofl = node.style.overflow;
1713+
if (ofl == null || ofl.length() == 0) {
1714+
b.style.overflow = "auto";
1715+
}
1716+
}
1717+
node.scrollLeft = lastBodyScrollLeft;
1718+
node.scrollTop = lastBodyScrollTop;
1719+
node.onscroll = lastClientAreaOnScroll;
1720+
}
1721+
}
17281722
}
17291723

17301724
/**
@@ -2020,7 +2014,7 @@ public void run() {
20202014
titleBar.appendChild(shellMax);
20212015
shellMax.onclick = new RunnableCompatibility() {
20222016
public void run() {
2023-
toggleMaximize();
2017+
setMaximized(!getMaximized());
20242018
display.timerExec(25, new Runnable() {
20252019
public void run() {
20262020
layout();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
color:highlighttext;
2929
}
3030
.menu-item-disabled .menu-item-text {
31-
color:gray;
31+
color:graytext;
3232
}
3333
.menu-item-disabled .menu-item-accel {
34-
color:gray;
34+
color:graytext;
3535
}
3636
.menu-item-text span span {
3737
text-decoration:underline;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
cursor:default;
1717
font-size:0;
1818
z-index:4;
19-
background-color:menu;
19+
background-color:buttonface;
2020
border-width:1px;
2121
border-style:outset;
2222
}
@@ -38,7 +38,7 @@
3838
margin:0;
3939
padding:0;
4040
height:24px;
41-
background-color:menu;
41+
background-color:buttonface;
4242
width:100%;
4343
z-index:2;
4444
}
@@ -78,7 +78,7 @@
7878
cursor:default;
7979
font-size:0;
8080
z-index:4;
81-
background-color:menu;
81+
background-color:buttonface;
8282
border-width:1px;
8383
border-style:outset;
8484
}
@@ -100,7 +100,7 @@
100100
margin:0;
101101
padding:0;
102102
width:24px;
103-
background-color:menu;
103+
background-color:buttonface;
104104
height:100%;
105105
z-index:2;
106106
}

0 commit comments

Comments
 (0)