Skip to content

Commit 80c124c

Browse files
author
zhourenjian
committed
1. Fixed bug that Tree with V/H_SCROLL style failed to initialize
2. Fixed bug that new Shell always locates in (0, 0) 3. Fixed bug that Shell#pack get incorrect size 4. Fixed bug that Link/Label does not have button face background color by default. 5. Temporarily fixed bug that Menu's width is too large in IE.
1 parent dd3fb0a commit 80c124c

File tree

10 files changed

+59
-44
lines changed

10 files changed

+59
-44
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public abstract class Control extends Widget implements Drawable {
7171
protected int height;
7272
protected int width;
7373
//private int lastLeft, lastTop, lastHeight, lastWidth;
74-
boolean boundsSet = false;
74+
boolean locationSet = false;
7575
/**
7676
* Prevents uninitialized instances from being created outside the package.
7777
* @j2sIgnore
@@ -2082,7 +2082,9 @@ void setBounds (int x, int y, int width, int height, int flags, boolean defer) {
20822082
/**
20832083
* A patch to send bounds to support mirroring features like what Windows have.
20842084
*/
2085-
boundsSet = true;
2085+
if (!locationSet) {
2086+
locationSet = moved;
2087+
}
20862088
int tempX = x;
20872089
if(parent != null){
20882090
if((parent.style & SWT.RIGHT_TO_LEFT) != 0){

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

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -578,13 +578,13 @@ public void run() {
578578
window.defaultWindowWidth = "768";
579579
}
580580
if (window.defaultWindowHeight == null) {
581-
window.defaultWindowHeight = "557";
581+
window.defaultWindowHeight = "558";
582582
}
583583
width = Integer.parseInt(window.defaultWindowWidth);
584584
height = Integer.parseInt(window.defaultWindowHeight);
585585

586586
this.width = 768;
587-
this.height = 557;
587+
this.height = 558;
588588
// if ((style & SWT.NO_TRIM) == 0 & (style & SWT.RESIZE) != 0) {
589589
// handle.className += " shell-trim";
590590
// }
@@ -690,7 +690,7 @@ void nextWindowLocation(int wHint, int hHint) {
690690
/*
691691
* if the user has set the bounds of the shell we should not override it!
692692
*/
693-
if(boundsSet) {
693+
if(locationSet) {
694694
return;
695695
}
696696

@@ -699,7 +699,7 @@ void nextWindowLocation(int wHint, int hHint) {
699699
window.defaultWindowLeft = "64";
700700
} else {
701701
int num = Integer.parseInt("" + window.defaultWindowLeft);
702-
if (this.parent == null) num += delta;
702+
num += delta;
703703
if (num + wHint > getMonitor().clientWidth) {
704704
num = delta;
705705
}
@@ -709,18 +709,14 @@ void nextWindowLocation(int wHint, int hHint) {
709709
window.defaultWindowTop = "64";
710710
} else {
711711
int num = Integer.parseInt("" + window.defaultWindowTop);
712-
if (this.parent == null) num += delta;
712+
num += delta;
713713
if (num + hHint > getMonitor().clientHeight) {
714714
num = delta;
715715
}
716716
window.defaultWindowTop = "" + num;
717717
}
718718
left = Integer.parseInt(window.defaultWindowLeft);
719719
top = Integer.parseInt(window.defaultWindowTop);
720-
if (parent != null) {
721-
left += delta;
722-
top += delta;
723-
}
724720
left += OS.getFixedBodyOffsetLeft ();
725721
top += OS.getFixedBodyOffsetTop ();
726722
}
@@ -909,7 +905,8 @@ public Rectangle getClientArea () {
909905
//h -= 20;
910906
h -= OS.getContainerHeight(titleBar);
911907
w -= 8;
912-
h -= 8;
908+
//h -= 8;
909+
h -= 5;
913910
if ((style & SWT.BORDER) != 0) {
914911
w -= 4;
915912
h -= 4;
@@ -1124,15 +1121,15 @@ public Point getSize () {
11241121
return new Point (width, height);
11251122
}
11261123
}
1127-
return super.getSize ();
11281124
*/
1129-
Point size = super.getSize();
1130-
//size.y += 26;
1131-
size.y += 6;
1132-
if (titleBar != null) {
1133-
size.y += OS.getContainerHeight(titleBar);
1134-
}
1135-
return size;
1125+
return super.getSize ();
1126+
// Point size = super.getSize();
1127+
// //size.y += 26;
1128+
// size.y += 6;
1129+
// if (titleBar != null) {
1130+
// size.y += OS.getContainerHeight(titleBar);
1131+
// }
1132+
// return size;
11361133
}
11371134

11381135
/**

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
font-family:Arial, sans-serif;
44
font-size:8pt;
55
overflow:hidden;
6+
background-color:buttonface;
67
}
78
.group-border-default {
89
border:2px inset white;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
font-family:Tahoma, Arial, sans-serif;
88
font-size:8pt;
99
overflow:hidden;
10+
background-color:buttonface;
1011
}
1112
.label-default span span {
1213
text-decoration:underline;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
font-size:8pt;
88
white-space:normal;
99
overflow:hidden;
10+
background-color:buttonface;
1011
}
1112
.link-default a {
1213
color:rgb(0,51,153);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
192192
*/
193193
if (text != null) {
194194
if ((style & SWT.WRAP) != 0 && wHint != SWT.DEFAULT && hHint == SWT.DEFAULT) {
195-
height = OS.getStringStyledWrappedHeight(cachedText, "label-default", handle.style.cssText, wHint);
195+
height = OS.getStringStyledWrappedHeight(cachedText, "link-default", handle.style.cssText, wHint);
196196
} else {
197197
if (!textSizeCached || changed) {
198-
Point cssSize = OS.getStringStyledSize(cachedText, "label-default", handle.style.cssText);
198+
Point cssSize = OS.getStringStyledSize(cachedText, "link-default", handle.style.cssText);
199199
textSizeCached = true;
200200
textWidthCached = cssSize.x;
201201
textHeightCached = cssSize.y;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ void _setVisible (boolean visible) {
225225
style.zIndex = "1" + window.currentTopZIndex;
226226
style.display = "block";
227227
int height = OS.getContainerHeight(handle);
228+
if (OS.isIE) {
229+
handle.style.width = "200px";
230+
}
228231
int width = OS.getContainerWidth(handle);
229232
int left = x, top = y;
230233
if (y + height > clientArea.y + clientArea.height) {

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

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -207,24 +207,23 @@ void createWidget () {
207207
pageIncrement = 10;
208208
size = 100;
209209

210-
if (!parent.useNativeScrollBar()) {
211-
if ((style & SWT.H_SCROLL) != 0) {
212-
createHorizontalScrollBar(parent.scrolledHandle(), size, size * (maximum - minimum) / thumb);
213-
} else {
214-
createVerticalScrollBar(parent.scrolledHandle(), size, size * (maximum - minimum) / thumb);
215-
}
216-
sbHandle.onscroll = new RunnableCompatibility() {
210+
if ((style & SWT.H_SCROLL) != 0) {
211+
createHorizontalScrollBar(parent.scrolledHandle(), size, size * (maximum - minimum) / thumb);
212+
} else {
213+
createVerticalScrollBar(parent.scrolledHandle(), size, size * (maximum - minimum) / thumb);
214+
}
215+
sbHandle.onscroll = new RunnableCompatibility() {
217216

218-
public void run() {
219-
/*
220-
* Send the event because WM_HSCROLL and
221-
* WM_VSCROLL are sent from a modal message
222-
* loop in Windows that is active when the
223-
* user is scrolling.
224-
*/
225-
Event event = new Event ();
226-
event.detail = SWT.NONE;
227-
/*
217+
public void run() {
218+
/*
219+
* Send the event because WM_HSCROLL and
220+
* WM_VSCROLL are sent from a modal message
221+
* loop in Windows that is active when the
222+
* user is scrolling.
223+
*/
224+
Event event = new Event ();
225+
event.detail = SWT.NONE;
226+
/*
228227
switch (code) {
229228
case OS.SB_THUMBPOSITION: event.detail = SWT.NONE; break;
230229
case OS.SB_THUMBTRACK: event.detail = SWT.DRAG; break;
@@ -235,12 +234,11 @@ public void run() {
235234
case OS.SB_PAGEDOWN: event.detail = SWT.PAGE_DOWN; break;
236235
case OS.SB_PAGEUP: event.detail = SWT.PAGE_UP; break;
237236
}
238-
*/
239-
sendEvent (SWT.Selection, event);
240-
}
237+
*/
238+
sendEvent (SWT.Selection, event);
239+
}
241240

242-
};
243-
}
241+
};
244242
}
245243

246244

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ protected boolean useNativeScrollBar() {
137137
}
138138

139139
ScrollBar createScrollBar (int type) {
140+
if (useNativeScrollBar()) return null;
140141
ScrollBar bar = new ScrollBar (this, type);
141142
if ((state & CANVAS) != 0) {
142143
bar.setMaximum (100);

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,17 @@ static int checkStyle (int style) {
408408
return bits;
409409
}
410410

411+
public Point computeSize(int wHint, int hHint, boolean changed) {
412+
Point size = super.computeSize(wHint, hHint, changed);
413+
if (size.x < minWidth) {
414+
size.x = minWidth;
415+
}
416+
if (size.y < minHeight) {
417+
size.y = minHeight;
418+
}
419+
return size;
420+
}
421+
411422
/**
412423
* Adds the listener to the collection of listeners who will
413424
* be notified when operations are performed on the receiver,

0 commit comments

Comments
 (0)