Skip to content

Commit cac04a5

Browse files
author
soheil_h_y
committed
1. Right To Left Problem Solved.
2. Some minor issues solved.
1 parent a681efd commit cac04a5

17 files changed

Lines changed: 434 additions & 98 deletions

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4339,6 +4339,10 @@ public Element containerHandle() {
43394339
return contentArea;
43404340
}
43414341

4342+
protected void _updateOrientation(){
4343+
handle.style.direction = "ltr";
4344+
}
4345+
43424346
Object createCSSElement(Object parent, String css) {
43434347
Element el = document.createElement("DIV");
43444348
if (css != null) {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public class CSSStyle {
7474
public String backgroundRepeat;
7575
public String backgroundPosition;
7676
public String filter;
77-
77+
78+
public String direction;
7879
public String cssText;
7980
}

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

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,8 @@ void show(){
651651

652652
void updateSelection(){
653653
textInput.value = selectInput.options[getSelectionIndex()].value;
654+
setText(getItem(getSelectionIndex()));
655+
sendEvent(SWT.Selection);
654656
}
655657

656658
/**
@@ -1565,11 +1567,8 @@ void setBounds (int x, int y, int width, int height, int flags) {
15651567
// && this instanceof Composite) {
15661568
// display.sendMessage(new MESSAGE(this, MESSAGE.CONTROL_LAYOUT, null));
15671569
// }
1568-
this.left = x;
1569-
this.top = y;
1570-
this.width = width;
1571-
this.height = height;
1572-
SetWindowPos (handle, null, x, y, width, height, flags);
1570+
super.setBounds (x, y, width, height, flags);
1571+
// SetWindowPos (handle, null, x, y, width, height, flags);
15731572
textInput.style.height = dropDownButton.style.height = Math.min(height, buttonHeight) + "px";
15741573
dropDownButton.style.width = buttonWidth + "px";
15751574
textInput.style.width = Math.max(0, width - buttonWidth) + "px";
@@ -1813,17 +1812,19 @@ public void setText (String string) {
18131812
public void setText (String string, boolean modify) {
18141813
checkWidget ();
18151814
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
1816-
if ((style & SWT.READ_ONLY) != 0) {
1817-
int index = indexOf (string);
1818-
if (index != -1) select (index);
1819-
return;
1820-
}
1815+
// if ((style & SWT.READ_ONLY) != 0) {
1816+
// int index = indexOf (string);
1817+
// if(selectInput.selectedIndex != index && index != -1)
1818+
// select (index);
1819+
// return;
1820+
// }
18211821
textInput.readOnly = false;
18221822
textInput.value = string;
18231823
textInput.readOnly = (style & SWT.READ_ONLY) != 0;
18241824
// TCHAR buffer = new TCHAR (getCodePage (), string, true);
18251825
// if (OS.SetWindowText (handle, buffer)) {
18261826
if(modify){
1827+
// System.out.println("send event modify");
18271828
sendEvent (SWT.Modify);
18281829
}
18291830
// widget could be disposed at this point
@@ -2449,4 +2450,25 @@ protected void releaseHandle() {
24492450
super.releaseHandle();
24502451
}
24512452

2453+
void enableWidget(boolean enabled) {
2454+
// TODO Auto-generated method stub
2455+
super.enableWidget(enabled);
2456+
this.textInput.disabled = !enabled;
2457+
this.dropDownButton.disabled = !enabled;
2458+
2459+
String cssName = handle.className;
2460+
if (cssName == null) cssName = "";
2461+
String key = "text-disabled";
2462+
int idx = cssName.indexOf(key);
2463+
if (!enabled) {
2464+
if (idx == -1) {
2465+
handle.className += " " + key;
2466+
}
2467+
} else {
2468+
if (idx != -1) {
2469+
handle.className = cssName.substring(0, idx) + cssName.substring(idx + key.length());
2470+
}
2471+
}
2472+
}
2473+
24522474
}

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ void createWidget () {
523523
setDefaultFont ();
524524
checkMirrored ();
525525
checkBorder ();
526+
_updateOrientation();
526527
}
527528

528529
/*
@@ -1133,6 +1134,9 @@ public boolean getVisible () {
11331134
if (drawCount != 0) return (state & HIDDEN) == 0;
11341135
// int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
11351136
// return (bits & OS.WS_VISIBLE) != 0;
1137+
if(handle == null){
1138+
return false;
1139+
}
11361140
return handle.style.visibility != "hidden";
11371141
}
11381142

@@ -2063,6 +2067,14 @@ void setBounds (int x, int y, int width, int height, int flags) {
20632067
}
20642068

20652069
void setBounds (int x, int y, int width, int height, int flags, boolean defer) {
2070+
/**
2071+
* A patch to send bounds to support mirroring features like what Windows have.
2072+
*/
2073+
if(parent != null){
2074+
if((parent.style & SWT.RIGHT_TO_LEFT) != 0){
2075+
x = Math.max(0, parent.getClientArea().width - x - width);
2076+
}
2077+
}
20662078
Element topHandle = topHandle ();
20672079
if (defer && parent != null) {
20682080
forceResize ();
@@ -2650,6 +2662,9 @@ public void setVisible (boolean visible) {
26502662
if (visible) {
26512663
sendEvent (SWT.Show);
26522664
if (isDisposed ()) return;
2665+
if(this instanceof Composite) {
2666+
display.sendMessage(new MESSAGE(this, MESSAGE.CONTROL_LAYOUT, null));
2667+
}
26532668
}
26542669
handle.style.visibility = visible ? "visible" : "hidden";
26552670
handle.style.display = visible ? "block" : "none";
@@ -3235,7 +3250,13 @@ public boolean setParent (Composite parent) {
32353250
//TODO
32363251
// Element topHandle = topHandle ();
32373252
// if (OS.SetParent (topHandle, parent.handle) == 0) return false;
3253+
// Element newHandle = this.handle.cloneNode(true);
3254+
// parent.handle.appendChild(this.handle.cloneNode(true));
3255+
// this.parent.handle.removeChild(this.handle);
3256+
// display.sendMessage(new MESSAGE(parent, MESSAGE.CONTROL_LAYOUT, null));
32383257
this.parent = parent;
3258+
// this.handle = newHandle;
3259+
// display.sendMessage(new MESSAGE(parent, MESSAGE.CONTROL_LAYOUT, null));
32393260
// int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE;
32403261
// SetWindowPos (topHandle, OS.HWND_BOTTOM, 0, 0, 0, 0, flags);
32413262
return true;

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,9 @@ public void setText (String string) {
502502
}
503503
groupText = string;
504504
}
505-
505+
protected void _updateOrientation(){
506+
this.handle.style.direction = "ltr";
507+
}
506508
/*
507509
int widgetStyle () {
508510
/*

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ void createHandle() {
178178

179179
public boolean dragEnded(DragEvent e) {
180180
super.dragEnded(e);
181-
181+
/*
182+
* TODO: Sash form on right to left should be fixed.
183+
*/
182184
Event event = new Event ();
183185
event.x = lastX; //e.currentX; //Integer.parseInt(thumb.style.left); //lastX;
184186
event.y = lastY; //e.currentY; //Integer.parseInt(thumb.style.top); //lastY;
@@ -199,7 +201,7 @@ public boolean dragEnded(DragEvent e) {
199201
event.height = height;
200202
event.widget = Sash.this;
201203
event.item = Sash.this;
202-
System.out.println("drop");
204+
// System.out.println("drop");
203205
sendEvent (SWT.Selection, event);
204206
if (event.doit) {
205207
if ((style & SWT.SMOOTH) != 0) {

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

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,15 @@ protected void createHandle () {
192192
digits = 0;
193193
TCHAR buffer = new TCHAR (getCodePage (), "0", true);
194194
OS.SetWindowText (hwndText, buffer);
195-
*/
196-
handle = document.createElement ("DIV");
197-
handle.className = "spinner-default";
195+
*/
196+
handle.className += " spinner-default";
198197

199-
if (parent != null) {
200-
Element parentHandle = parent.containerHandle();
201-
if (parentHandle!= null) {
202-
parentHandle.appendChild(handle);
203-
}
204-
}
198+
// if (parent != null) {
199+
// Element parentHandle = parent.containerHandle();
200+
// if (parentHandle!= null) {
201+
// parentHandle.appendChild(handle);
202+
// }
203+
// }
205204

206205
if ((style & SWT.BORDER) != 0) {
207206
handle.className += " spinner-border";
@@ -246,6 +245,7 @@ public void run() {
246245
}
247246

248247
};
248+
// System.out.println("spinner handle" + handle);
249249
}
250250

251251
/**
@@ -1125,7 +1125,25 @@ void setBounds (int x, int y, int width, int height, int flags) {
11251125
textInputHandle.style.height = ((height - 2) > 24 ? 20 : height - 2) + "px";
11261126

11271127
}
1128-
1128+
protected boolean SetWindowPos(Object hWnd, Object hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags) {
1129+
if ((style & SWT.BORDER) != 0) {
1130+
cx -= 4;
1131+
cy -= 4;
1132+
// textHandle.style.width = ((cx - 4) > 0 ? (cx - 4) : 0) + "px";
1133+
// textHandle.style.height = ((cy - 4) > 0 ? (cy - 4) : 0) + "px";
1134+
// return super.SetWindowPos(hWnd, hWndInsertAfter, X, Y, cx - 4, cy - 4, uFlags);
1135+
}
1136+
textHandle.style.width = (cx > 0 ? cx : 0) + "px";
1137+
textHandle.style.height = (cy > 0 ? cy : 0) + "px";
1138+
Element el = (Element) hWnd;
1139+
// TODO: What about hWndInsertAfter and uFlags
1140+
el.style.left = X + "px";
1141+
el.style.top = Y + "px";
1142+
el.style.width = (cx > 0 ? cx : 0) + "px";
1143+
el.style.height = (cy > 0 ? cy : 0) + "px";
1144+
return true;
1145+
//return super.SetWindowPos(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags);
1146+
}
11291147
/* (non-Javadoc)
11301148
* @see org.eclipse.swt.widgets.Scrollable#releaseHandle()
11311149
*/

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
*/
5454
public class TabFolder extends Composite {
5555
TabItem [] items;
56-
private Element borderFrame, borderNW, borderNE, borderSW, borderSE,
56+
Element borderFrame, borderNW, borderNE, borderSW, borderSE,
5757
itemMore, btnPrevTab, btnNextTab, contentArea;
5858
private int offset;
5959

@@ -1032,6 +1032,9 @@ void setSelection (int index, boolean notify) {
10321032
}
10331033
}
10341034
}
1035+
protected void _updateOrientation(){
1036+
handle.style.direction = "ltr";
1037+
}
10351038

10361039
void updateSelection(int index) {
10371040
String key = "tab-item-selected";

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ public void setText (String string) {
340340
textEl = document.createElement("SPAN");
341341
handle.appendChild(textEl);
342342
textEl.appendChild(document.createTextNode(string));
343+
this.handle.style.height = "14px";
343344
//handle.appendChild(document.createTextNode(string));
344345
}
345346
// int index = parent.indexOf (this);

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

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.eclipse.swt.internal.dnd.TableColumnDND;
2525
import org.eclipse.swt.internal.xhtml.Element;
2626
import org.eclipse.swt.internal.xhtml.document;
27+
import org.w3c.dom.NodeList;
2728

2829
/**
2930
* Instances of this class implement a selectable user interface
@@ -147,6 +148,14 @@ TableItem _getItem (int index) {
147148
return items [index] = new TableItem (this, SWT.NONE, -1, false);
148149
}
149150

151+
void enableWidget(boolean enabled) {
152+
// TODO Auto-generated method stub
153+
super.enableWidget(enabled);
154+
for(int i = 0; i < this.items.length; i++){
155+
this.items[i].enableWidget(enabled);
156+
}
157+
}
158+
150159
/**
151160
* Adds the listener to the collection of listeners who will
152161
* be notified when the receiver's selection changes, by sending
@@ -1023,14 +1032,14 @@ void createItem (TableItem item, int index) {
10231032
tbodyTRTemplate = document.createElement("TR");
10241033
// String trStr = "<TR class=\"table-item-default\"></TR>";
10251034
tbodyTRTemplate.className = "table-item-default";
1026-
int length = this.columns.length;
1035+
int length = Math.max(1,this.columns.length);
10271036
for(int i = 0; i < length; i++){
10281037
Element td = document.createElement("TD");
10291038
tbodyTRTemplate.appendChild(td);
10301039
Element el = document.createElement("DIV");
10311040
td.appendChild(el);
10321041
el.className = "table-item-cell-default";
1033-
if (index == 0 && (style & SWT.CHECK) != 0) {
1042+
if (i == 0 && (style & SWT.CHECK) != 0) {
10341043
Element check = document.createElement("INPUT");
10351044
check.type = "checkbox";
10361045
el.appendChild(check);
@@ -1046,9 +1055,15 @@ void createItem (TableItem item, int index) {
10461055
// *alert(this.tbodyTRTemplateInnerHTML);
10471056
// */{}
10481057
}
1049-
Element tbodyTR = tbodyTRTemplate.cloneNode(true);
1058+
1059+
Element tbodyTR = tbodyTRTemplate.cloneNode(true);
1060+
// System.out.println("the table is now " + tbodyTR.innerHTML);
10501061
// tbodyTR.className = "table-item-default";
1051-
// tbodyTR.innerHTML = tbodyTRTemplateInnerHTML;
1062+
// tbodyTR.innerHTML = tbodyTRTemplateInnerHTML;
1063+
if ((style & SWT.CHECK) != 0) {
1064+
Element[] nl = tbodyTR.getElementsByTagName("INPUT");
1065+
item.check = (Element) nl[0];
1066+
}
10521067
if (index < 0 || index >= tbody.childNodes.length) { //theadTD == null){
10531068
tbody.appendChild(tbodyTR);
10541069
items[index] = item;
@@ -1815,7 +1830,7 @@ public boolean getLinesVisible () {
18151830
public int getSelectionCount () {
18161831
checkWidget ();
18171832
//return OS.SendMessage (handle, OS.LVM_GETSELECTEDCOUNT, 0, 0);
1818-
return 0;
1833+
return selection.length;
18191834
}
18201835

18211836
/**
@@ -1841,7 +1856,10 @@ public int getSelectionIndex () {
18411856
}
18421857
return selectedIndex;
18431858
*/
1844-
return 0;
1859+
if(selection.length == 0){
1860+
return -1;
1861+
}
1862+
return selection[0].index;
18451863
}
18461864

18471865
/**
@@ -1872,7 +1890,7 @@ public int getSelectionIndex () {
18721890
*/
18731891
int [] result = new int [selection.length];
18741892
for (int i = 0; i < selection.length; i++) {
1875-
result[i] = 0;//selection[i].index;
1893+
result[i] = selection[i].index;
18761894
}
18771895
return result;
18781896
}

0 commit comments

Comments
 (0)