Skip to content

Commit 85ed253

Browse files
author
zhourenjian
committed
Fixed bugs that ScrollBar does not behavior correctly and its layout is not positioned as expected.
Improve Menu's border.
1 parent a98ce6f commit 85ed253

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public Composite (Composite parent, int style) {
109109
/*
110110
* TODO: search the DOM and filter out the children
111111
*/
112-
int count = children.length; //handle.childNodes.length;
112+
int count = children != null ? children.length : 0; //handle.childNodes.length;
113113
//Control [] children = new Control [0];
114114
int index = 0;
115115
Control [] newChildren = new Control [0];

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
.menu-default {
22
position:absolute;
3-
border:1px outset white;
3+
border-width:2px;
4+
border-style:groove solid solid groove;
5+
border-color:white gray gray white;
46
background-color:menu;
57
font-family:Tahoma, Arial, sans-serif;
68
font-size:8pt;

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ protected void createVerticalScrollBar(Element parent, int sbOuterHeight, int sb
253253
style.padding = "0";
254254
style.borderStyle = "none";
255255
style.overflow = "hidden";
256+
style.zIndex = "1";
256257
int sbWidth = OS.getScrollBarWidth();
257258
style.width = sbWidth + "px";
258259
style.height = sbOuterHeight + "px";
@@ -286,6 +287,7 @@ protected void createHorizontalScrollBar(Element parent, int sbOuterWidth, int s
286287
style.padding = "0";
287288
style.borderStyle = "none";
288289
style.overflow = "hidden";
290+
style.zIndex = "1";
289291
style.width = sbOuterWidth + "px";
290292
int sbHeight = OS.getScrollBarHeight();
291293
style.height = sbHeight + "px";
@@ -776,6 +778,7 @@ public void setEnabled (boolean enabled) {
776778
public void setIncrement (int value) {
777779
checkWidget();
778780
if (value < 1) return;
781+
if (increment == value) return;
779782
increment = value;
780783
}
781784

@@ -805,7 +808,8 @@ public void setMaximum (int value) {
805808
info.nMax = value;
806809
SetScrollInfo (hwnd, type, info, true);
807810
*/
808-
if (value < minimum) return ;
811+
if (value < minimum) return;
812+
if (maximum == value) return;
809813
maximum = value;
810814
if (selection > maximum) {
811815
selection = maximum;
@@ -840,6 +844,7 @@ public void setMinimum (int value) {
840844
SetScrollInfo (hwnd, type, info, true);
841845
*/
842846
if (value > maximum) return;
847+
if (minimum == value) return;
843848
minimum = value;
844849
if (selection < minimum) {
845850
selection = minimum;
@@ -954,6 +959,7 @@ public void setSelection (int selection) {
954959
SetScrollInfo (hwnd, type, info, true);
955960
*/
956961
if (selection < 0) return;
962+
if (this.selection == selection) return;
957963
if (selection < minimum) {
958964
this.selection = minimum;
959965
} else if (selection > maximum - thumb) {
@@ -991,6 +997,7 @@ public void setThumb (int value) {
991997
if (info.nPage != 0) info.nPage++;
992998
SetScrollInfo (hwnd, type, info, true);
993999
*/
1000+
if (thumb == value) return;
9941001
thumb = value;
9951002
updateScrollBar();
9961003
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,12 @@ public Rectangle getClientArea () {
189189
// }
190190
w = width;
191191
h = height;
192+
if (verticalBar != null) { //if ((style & SWT.V_SCROLL) != 0) {
193+
w -= OS.getScrollBarWidth();
194+
}
195+
if (horizontalBar != null) { //if ((style & SWT.H_SCROLL) != 0) {
196+
h -= OS.getScrollBarHeight();
197+
}
192198
if (w < 0) {
193199
w = 64;
194200
}

0 commit comments

Comments
 (0)