Skip to content

Commit 79d98f8

Browse files
author
zhourenjian
committed
Adjust TabFolder's tabs and Shell's maximized size
1 parent 56703be commit 79d98f8

File tree

5 files changed

+41
-10
lines changed

5 files changed

+41
-10
lines changed

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/custom/CTabFolder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3390,7 +3390,7 @@ void updateSelection(int index) {
33903390
// items[i].handle.style.display = "block";
33913391
Control control = items[i].control;
33923392

3393-
if(control != null && !control.isDisposed()){
3393+
if(i != index && control != null && !control.isDisposed()){
33943394
control.setVisible(false);
33953395
}
33963396
items[i].handle.style.zIndex = (i + 1) + "";
@@ -3483,7 +3483,7 @@ void updateSelection(int index) {
34833483
CSSStyle s = items[index].handle.style;
34843484
s.width = w + "px";
34853485
}
3486-
items[index].handle.style.zIndex = (items.length + 1) + "";
3486+
items[index].handle.style.zIndex = ((index >= offset) ? items.length + 1 : -1) + "";
34873487
//System.out.println("????");
34883488

34893489
if (this.width != 0) {

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,9 @@ public Rectangle getClientArea () {
988988
//h -= 21;
989989
h -= 1 + OS.getContainerHeight(shellMenuBar);
990990
}
991+
} else {
992+
h -= 6;
993+
w -= 6;
991994
}
992995
return new Rectangle(0, 0, w, h);
993996
}
@@ -1763,6 +1766,8 @@ public void setMaximized (boolean maximized) {
17631766
/**
17641767
* @j2sNative
17651768
* window.setTimeout (function () {
1769+
* var lastShell = ShellManager.getTopMaximizedShell ();
1770+
* if (lastShell == null || lastShell.titleBar == null) return;
17661771
* ShellManager.topbarContainerEl.style.display = "block";
17671772
* ShellManager.updateTopMaximized ();
17681773
* }, 250);
@@ -2361,8 +2366,8 @@ protected boolean SetWindowPos(Object hWnd, Object hWndInsertAfter, int X, int Y
23612366
height -= 4;
23622367
cx -= 4;
23632368
cy -= 4;
2364-
int dw = 7;
2365-
int dh = 7;
2369+
int dw = 6;
2370+
int dh = 6;
23662371
// if ((style & SWT.BORDER) != 0) {
23672372
// dw -= 2;
23682373
// dh -= 2;

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,11 @@ sm.initialize = function () {
9696
ShellManager.returnTopMaximized ();
9797
} else if (e.clientY <= 8 && !e.ctrlKey) {
9898
if (topbar.style.display != "block" && ShellManager.isAroundTopBar (e.clientX)) {
99-
topbar.style.display = "block";
100-
ShellManager.updateTopMaximized ();
99+
var lastShell = ShellManager.getTopMaximizedShell ();
100+
if (lastShell != null && lastShell.titleBar != null) {
101+
topbar.style.display = "block";
102+
ShellManager.updateTopMaximized ();
103+
}
101104
}
102105
} else if (e.ctrlKey || e.clientY > 12 + ((topShell.titleBar != null
103106
&& window["O$"] != null) ? O$.getContainerHeight (topShell.titleBar) : 20)) {
@@ -264,7 +267,7 @@ sm.getTopMaximizedShell = function () {
264267
};
265268
sm.updateTopMaximized = function () {
266269
var lastShell = this.getTopMaximizedShell ();
267-
if (lastShell == null) return;
270+
if (lastShell == null || lastShell.titleBar == null) return;
268271
this.lastMaximizedShell = lastShell;
269272

270273
// move the title bar elements into topbarEl

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,16 @@ protected boolean SetWindowPos(Object hWnd, Object hWndInsertAfter, int X, int Y
568568
if (ctrl != null)
569569
ctrl.setBounds(getClientArea());
570570
setSelection(selectionIndex, false);
571+
/*
572+
* Need to make sure < > button should be shown or not
573+
*/
574+
int ww = 0;
575+
if(handle.style.width.length() > 0){
576+
ww = Integer.parseInt(handle.style.width);
577+
}
578+
if (ww == 0) {
579+
updateSelectionWithWidth(selectionIndex, cx);
580+
}
571581
}
572582
return super.SetWindowPos(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags);
573583
}
@@ -1044,9 +1054,12 @@ protected void _updateOrientation(){
10441054
}
10451055

10461056
void updateSelection(int index) {
1057+
updateSelectionWithWidth(index, -1);
1058+
}
1059+
void updateSelectionWithWidth(int index, int prefWidth) {
10471060
String key = "tab-item-selected";
10481061
for (int i = 0; i < offset; i++) {
1049-
if(items[i].control != null){
1062+
if(i != index && items[i].control != null){
10501063
items[i].control.setVisible(false);
10511064
}
10521065
//items[i].handle.style.display = "none";
@@ -1077,12 +1090,14 @@ void updateSelection(int index) {
10771090
if(handle.style.width.length() > 0){
10781091
ww = Integer.parseInt(handle.style.width);
10791092
}
1093+
if (prefWidth != -1 && ww == 0) {
1094+
ww = prefWidth;
1095+
}
10801096
if (ww > 0) {
10811097
OS.updateCSSClass(borderFrame, "tab-show-more-item", x > ww || offset != 0);
10821098
}
10831099
OS.addCSSClass(items[index].handle, key);
1084-
items[index].handle.style.zIndex = (items.length + 1) + "";
1085-
//System.out.println("????");
1100+
items[index].handle.style.zIndex = ((index >= offset) ? items.length + 1 : -1) + "";
10861101
if (this.width != 0) {
10871102
int w = OS.getContainerWidth(items[index].handle);
10881103
left += 4;

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ public void setImage (Image image) {
248248
checkWidget();
249249
int index = parent.indexOf (this);
250250
if (index == -1) return;
251+
boolean boundsChanged = (image != null && this.image == null) || (image == null && this.image != null);
251252
super.setImage (image);
252253
/*
253254
* Bug in Windows. In version 6.00 of COMCTL32.DLL, tab
@@ -290,6 +291,9 @@ public void setImage (Image image) {
290291
}
291292
hasImage = image != null;
292293
OS.updateCSSClass(handle, "tab-item-image", hasImage);
294+
if (boundsChanged) {
295+
parent.updateSelection(parent.getSelectionIndex());
296+
}
293297
}
294298
/**
295299
* Sets the receiver's text. The string may include
@@ -322,6 +326,7 @@ public void setText (String string) {
322326
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
323327
int index = parent.indexOf (this);
324328
if (index == -1) return;
329+
boolean boundsChanged = string != this.text;
325330
super.setText (string);
326331
if (handle != null) {
327332
OS.clearChildren(handle);
@@ -336,6 +341,9 @@ public void setText (String string) {
336341
// super.setText (string);
337342
this.text = string;
338343
configure(index);
344+
if (boundsChanged) {
345+
parent.updateSelection(parent.getSelectionIndex());
346+
}
339347
/*
340348
/*
341349
* Bug in Windows. In version 6.00 of COMCTL32.DLL, tab

0 commit comments

Comments
 (0)