Skip to content

Commit 0af2b2f

Browse files
author
soheil_h_y
committed
1 parent 30f3d25 commit 0af2b2f

File tree

5 files changed

+64
-36
lines changed

5 files changed

+64
-36
lines changed

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

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.eclipse.swt.widgets.Menu;
3939
import org.eclipse.swt.widgets.MenuItem;
4040
import org.eclipse.swt.widgets.Shell;
41+
import org.eclipse.swt.widgets.TabItem;
4142
import org.eclipse.swt.widgets.TypedListener;
4243

4344
/**
@@ -3140,6 +3141,12 @@ public void setBounds(int x, int y, int width, int height) {
31403141
contentArea.style.width = (width - 6) + "px";
31413142
buttonArea.style.width = (width - 4) + "px";
31423143
super.setBounds(x, y, width, height);
3144+
if(selectedIndex != -1 ){
3145+
Control control = items[selectedIndex].control;
3146+
if(control != null && control.isDisposed()){
3147+
control.setBounds(getClientArea());
3148+
}
3149+
}
31433150
// int idx = getSelectionIndex();
31443151
// items[idx].fixControlBounds();
31453152
}
@@ -3326,21 +3333,13 @@ void setSelection (int index, boolean notify) {
33263333
*/
33273334
// int oldIndex = OS.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0);
33283335
int oldIndex = getSelectionIndex();
3329-
System.out.println("setselection called! at " + oldIndex + " at " + index);
3330-
/*
3331-
* Whenever the old index is equals to the requested index
3332-
* do nothing.
3333-
*/
3334-
if(oldIndex == index){
3335-
return;
3336-
}
33373336

3338-
if (oldIndex != -1) {
3337+
if (oldIndex != -1 && oldIndex != index) {
33393338
CTabItem item = items [oldIndex];
33403339
Control control = item.control;
33413340
if (control != null && !control.isDisposed ()) {
33423341
control.setVisible (false);
3343-
control.handle.style.display = "none";
3342+
// control.handle.style.display = "none";
33443343
}
33453344
}
33463345

@@ -3352,22 +3351,27 @@ void setSelection (int index, boolean notify) {
33523351
// if (oldIndex == index) {
33533352
// newIndex = -1;
33543353
// }
3354+
3355+
if (oldIndex == index) {
3356+
newIndex = -1;
3357+
}
3358+
33553359
if (newIndex != -1) {
33563360
CTabItem item = items [newIndex];
33573361
selectedIndex = newIndex;
33583362
Control control = item.control;
33593363
if (control != null && !control.isDisposed ()) {
33603364
control.setBounds (getClientArea ());
33613365
control.setVisible (true);
3362-
control.handle.style.display = "block";
3366+
// control.handle.style.display = "block";
33633367
}
33643368
if (notify) {
33653369
Event event = new Event ();
33663370
event.item = item;
33673371
sendEvent (SWT.Selection, event);
33683372
}
33693373
}
3370-
layout();
3374+
//layout();
33713375
}
33723376

33733377
void updateSelection(int index) {
@@ -3378,7 +3382,12 @@ void updateSelection(int index) {
33783382
int x = 2;
33793383

33803384
for (int i = offset; i < items.length; i++) {
3381-
items[i].handle.style.display = "block";
3385+
// items[i].handle.style.display = "block";
3386+
Control control = items[i].control;
3387+
3388+
if(control != null && !control.isDisposed()){
3389+
control.setVisible(false);
3390+
}
33823391
items[i].handle.style.zIndex = (i + 1) + "";
33833392

33843393
//if (index == i) continue;
@@ -3446,7 +3455,12 @@ void updateSelection(int index) {
34463455
if (cssName == null) cssName = "";
34473456
int idx = cssName.indexOf(key);
34483457
if (idx == -1) {
3458+
Control control = items[index].control;
34493459

3460+
if(control != null && !control.isDisposed()){
3461+
control.setVisible(true);
3462+
}
3463+
34503464
items[index].handle.className += " " + key;
34513465
items[index].rightEl.className = items[index].cssClassForRight();
34523466
items[index].handle.style.height = (OS.getContainerHeight(buttonArea) + 3) + "px";
@@ -3495,7 +3509,10 @@ void updateSelection(int index) {
34953509
}
34963510
boolean after = false;
34973511
for (int i = 0; i < offset; i++) {
3498-
items[i].handle.style.display = "none";
3512+
// items[i].handle.style.display = "none";
3513+
if(items[i].control != null){
3514+
items[i].control.setVisible(false);
3515+
}
34993516
String cssName = items[i].handle.className;
35003517
if (cssName == null) cssName = "";
35013518
int idx = cssName.indexOf(key);

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,7 @@ public CTabItem (CTabFolder parent, int style, int index) {
135135
super (parent, checkStyle(style));
136136
this.parent = parent;
137137
showClose = parent.showClose;
138-
System.out.println("after sw" + showClose + " " + (style & SWT.CLOSE) + " " + style);
139138
parent.createItem (this, index);
140-
System.out.println("handle " + handle);
141139
configure(index);
142140
}
143141
String getNameText () {
@@ -148,7 +146,6 @@ private void configure(int index) {
148146
handle.onclick = new RunnableCompatibility() {
149147
public void run() {
150148
parent.setSelection(CTabItem.this);
151-
System.out.println("An item is selected " + CTabItem.this);
152149
}
153150
};
154151
if(parent.showClose){
@@ -466,8 +463,11 @@ public void setControl (Control control) {
466463
} else {
467464
newControl.setBounds (clientArea);
468465
newControl.setVisible(true);
469-
System.out.println("bounds " + clientArea);
470466
}
467+
// if (newControl != null) {
468+
// newControl.setBounds (parent.getClientArea ());
469+
// newControl.setVisible (true);
470+
// }
471471
// System.err.println(clientArea);
472472
// System.out.println("here!");
473473
//newControl.setVisible (true);
@@ -603,7 +603,6 @@ public void setText (String string) {
603603
}
604604
void configureRightEl() {
605605
// TODO Auto-generated method stub
606-
System.out.println("Show close : " + showClose);
607606
if(showClose){
608607
rightEl.onclick = new RunnableCompatibility() {
609608
public void run() {
@@ -625,7 +624,6 @@ public void run() {
625624
parent.destroyItem(CTabItem.this);
626625
}
627626

628-
System.out.println("An item is closed " + CTabItem.this);
629627

630628
}
631629
};

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ protected void layout(Composite composite, boolean flushCache) {
115115
for (int i = 0; i < children.length; i++) {
116116
children[i].setBounds(rect);
117117
children[i].setVisible(children[i] == topControl);
118-
119118
}
120119
}
121120

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2650,7 +2650,8 @@ public void setVisible (boolean visible) {
26502650
sendEvent (SWT.Show);
26512651
if (isDisposed ()) return;
26522652
}
2653-
2653+
handle.style.visibility = visible ? "visible" : "hidden";
2654+
handle.style.display = visible ? "block" : "none";
26542655
/*
26552656
* Feature in Windows. If the receiver has focus, hiding
26562657
* the receiver causes no window to have focus. The fix is

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

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,6 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
203203
checkWidget ();
204204
System.out.println(wHint + "," + hHint + "," + changed);
205205
Point size = super.computeSize (wHint, hHint, changed);
206-
207-
System.out.println("super size of tabfolder:" + size);
208206
int width = -124; // this number is an experimental number from WinXP in classical style
209207
if (items != null && items.length != 0) {
210208
// int height = OS.getContainerHeight(items[0].handle);
@@ -239,7 +237,6 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
239237

240238
// size.x += items.length * 32;
241239
// size.y += 24;
242-
System.out.println("in tab folder " + size);
243240
return size;
244241
}
245242

@@ -430,15 +427,15 @@ public void run() {
430427
if (w > width) {
431428
if (i < items.length - 1) {
432429
offset++;
433-
System.out.println("Offset:" + offset);
430+
// System.out.println("Offset:" + offset);
434431
setSelection(getSelectionIndex(), false);
435432
return ;
436433
}
437434
}
438435
}
439436
if (ww > width) {
440437
offset++;
441-
System.out.println("Offset:" + offset);
438+
// System.out.println("Offset:" + offset);
442439
setSelection(getSelectionIndex(), false);
443440
return ;
444441
}
@@ -456,10 +453,10 @@ public void run() {
456453
}
457454
el.onclick = btnPrevTab.onclick = new RunnableCompatibility() {
458455
public void run() {
459-
System.out.println("in Offset:" + offset);
456+
// System.out.println("in Offset:" + offset);
460457
if (offset <= 0) return ;
461458
offset--;
462-
System.out.println("Offset:" + offset);
459+
// System.out.println("Offset:" + offset);
463460
setSelection(getSelectionIndex(), false);
464461
}
465462
};
@@ -535,8 +532,20 @@ public void setBounds(int x, int y, int width, int height) {
535532
// height = Math.max(0, height - 6);
536533
// }
537534
// outerArea.style.height = height + "px";
535+
// }
536+
537+
super.setBounds(x, y, width, height);
538+
// int selectedIndex = getSelectionIndex();
539+
// if(selectedIndex != -1 ){
540+
//
541+
// Control control = items[selectedIndex].control;
542+
// if(control != null)
543+
// System.out.println(" tab folder conrol for bounds 1 " + control + " " + getClientArea() + " " + control.isDisposed());
544+
// if(control != null && control.isDisposed()){
545+
// System.out.println("tab folder set bounds for " + control + " " + getClientArea());
546+
// control.setBounds(getClientArea());
547+
// }
538548
// }
539-
super.setBounds(x, y, width, height);
540549
// int idx = getSelectionIndex();
541550
// items[idx].fixControlBounds();
542551
}
@@ -717,7 +726,7 @@ public int getSelectionIndex () {
717726
return i;
718727
}
719728
}
720-
System.out.println("The selection is not happend yet!");
729+
// System.out.println("The selection is not happend yet!");
721730
/*
722731
* should return -1 instead of 0
723732
*/
@@ -977,7 +986,7 @@ void setSelection (int index, boolean notify) {
977986
* TODO: When a tab is selected programmly, should move
978987
* the tab into visible tab area.
979988
*/
980-
System.out.println("set selection is called!");
989+
// System.out.println("set selection is called!");
981990
// int oldIndex = OS.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0);
982991
int oldIndex = getSelectionIndex();
983992

@@ -986,7 +995,7 @@ void setSelection (int index, boolean notify) {
986995
Control control = item.control;
987996
if (control != null && !control.isDisposed ()) {
988997
control.setVisible (false);
989-
control.handle.style.display = "none";
998+
//control.handle.style.display = "none";
990999
}
9911000
}
9921001
// OS.SendMessage (handle, OS.TCM_SETCURSEL, index, 0);
@@ -1006,8 +1015,9 @@ void setSelection (int index, boolean notify) {
10061015
* later layout should relayout the control.
10071016
*/
10081017
control.setBounds (getClientArea ());
1018+
// System.out.println("set selection bounds " + getClientArea());
10091019
control.setVisible (true);
1010-
control.handle.style.display = "block";
1020+
//control.handle.style.display = "block";
10111021
}
10121022
if (notify) {
10131023
Event event = new Event ();
@@ -1020,7 +1030,10 @@ void setSelection (int index, boolean notify) {
10201030
void updateSelection(int index) {
10211031
String key = "tab-item-selected";
10221032
for (int i = 0; i < offset; i++) {
1023-
items[i].handle.style.display = "none";
1033+
if(items[i].control != null){
1034+
items[i].control.setVisible(false);
1035+
}
1036+
//items[i].handle.style.display = "none";
10241037
if (index >= offset) {
10251038
String cssName = items[i].handle.className;
10261039
if (cssName == null) cssName = "";
@@ -1035,7 +1048,7 @@ void updateSelection(int index) {
10351048
int left = -2;
10361049
int x = 2;
10371050
for (int i = offset; i < items.length; i++) {
1038-
items[i].handle.style.display = "block";
1051+
//items[i].handle.style.display = "block";
10391052
items[i].handle.style.zIndex = (i + 1) + "";
10401053
//if (index == i) continue;
10411054
String cssName = items[i].handle.className;

0 commit comments

Comments
 (0)