summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorLina Kemmel2013-03-13 15:12:29 (EDT)
committer Carolyn MacLeod2013-04-09 10:56:30 (EDT)
commit444160ea1f20af86e896ce6c1517272e903c9efb (patch)
tree8f3457985e2e7abae9d36ceee6f4b9ec7ce75fa5
parentaaac93287e3fdf7e419db998c255fac87f770fc6 (diff)
downloadeclipse.platform.swt-444160ea1f20af86e896ce6c1517272e903c9efb.zip
eclipse.platform.swt-444160ea1f20af86e896ce6c1517272e903c9efb.tar.gz
eclipse.platform.swt-444160ea1f20af86e896ce6c1517272e903c9efb.tar.bz2
Bug 273198 - [Bidi] Lack of support for controlling text direction independently from widget orientation
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Item.java9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java21
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java76
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandItem.java12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java67
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java16
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java15
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java55
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java4
19 files changed, 300 insertions, 50 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java
index 20af4b0..2e723aa 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java
@@ -1932,6 +1932,12 @@ public Point getSize () {
return new Point((int)rect.width, (int)rect.height);
}
+public int getTextDirection() {
+ checkWidget ();
+ /* return the widget orientation */
+ return style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
+}
+
float getThemeAlpha () {
return 1 * parent.getThemeAlpha ();
}
@@ -4114,6 +4120,10 @@ boolean setTabItemFocus () {
return forceFocus ();
}
+public void setTextDirection(int textDirection) {
+ checkWidget ();
+}
+
/**
* Sets the receiver's tool tip text to the argument, which
* may be null indicating that the default tool tip for the
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java
index 306b976..9c439e2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java
@@ -1784,6 +1784,18 @@ public class SWT {
public static final int TRANSPARENT = 1 << 30;
/**
+ * Style constant to indicate base text direction (value is 1&lt;&lt;31).
+ * <p>
+ * When the bit is set, text direction mismatches the widget orientation
+ * <p><b>Used By:</b><ul>
+ * <li><code>Control</code></li>
+ * </ul></p>
+ *
+ * @since 3.102
+ */
+ public static final int FLIP_TEXT_DIRECTION = 1 << 31;
+
+ /**
* Style constant for align up behavior (value is 1&lt;&lt;7,
* since align UP and align TOP are considered the same).
* <p><b>Used By:</b><ul>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Item.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Item.java
index 282bff2..b77e4fd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Item.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Item.java
@@ -183,4 +183,13 @@ public void setText (String string) {
text = string;
}
+boolean updateTextDirection(int textDirection) {
+ if (((style & SWT.FLIP_TEXT_DIRECTION) ^ textDirection) != 0) {
+ style ^= SWT.FLIP_TEXT_DIRECTION;
+ return true;
+ }
+ return false;
+}
+
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
index 99345bb..c929cf0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
@@ -266,6 +266,12 @@ public int getOrientation () {
return style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
}
+public int getTextDirection() {
+ checkWidget ();
+ /* return the widget orientation */
+ return style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
+}
+
boolean hasFocus () {
return this == display.getFocusControl();
}
@@ -4546,6 +4552,10 @@ boolean setTabItemFocus (boolean next) {
return forceFocus ();
}
+public void setTextDirection(int textDirection) {
+ checkWidget ();
+}
+
/**
* Sets the receiver's tool tip text to the argument, which
* may be null indicating that the default tool tip for the
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java
index b4260cc..1509189 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java
@@ -2067,6 +2067,7 @@ void updateOrientation () {
} else {
bits &= ~OS.WS_EX_LAYOUTRTL;
}
+ bits &= ~OS.WS_EX_RTLREADING;
OS.SetWindowLong (handle, OS.GWL_EXSTYLE, bits);
long /*int*/ hwndText = 0, hwndList = 0;
COMBOBOXINFO pcbi = new COMBOBOXINFO ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java
index 632a44a..c88e9be 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java
@@ -1159,6 +1159,23 @@ boolean setTabGroupFocus () {
return false;
}
+boolean updateTextDirection(int textDirection) {
+ if (super.updateTextDirection(textDirection)) {
+ /*
+ * OS.WS_EX_RTLREADING doesn't propagate to children
+ */
+ Control[] children = _getChildren ();
+ int i = children.length;
+ while (i-- > 0) {
+ if (children[i] != null && !children[i].isDisposed ()) {
+ children[i].updateTextDirection(textDirection);
+ }
+ }
+ return true;
+ }
+ return false;
+}
+
String toolTipText (NMTTDISPINFO hdr) {
Shell shell = getShell ();
if ((hdr.uFlags & OS.TTF_IDISHWND) == 0) {
@@ -1891,7 +1908,9 @@ LRESULT wmNotify (NMHDR hdr, long /*int*/ wParam, long /*int*/ lParam) {
}
}
if (widget != null) {
- if ((widget.getStyle () & SWT.RIGHT_TO_LEFT) != 0) {
+ int style = widget.getStyle();
+ int flags = SWT.RIGHT_TO_LEFT | SWT.FLIP_TEXT_DIRECTION;
+ if ((style & flags) != 0 && (style & flags) != flags) {
lpnmtdi.uFlags |= OS.TTF_RTLREADING;
} else {
lpnmtdi.uFlags &= ~OS.TTF_RTLREADING;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
index 92056be..f9f75ef 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
@@ -1581,6 +1581,26 @@ public Point getSize () {
}
/**
+ * Returns the text direction of the receiver, which will be one of the
+ * constants <code>SWT.LEFT_TO_RIGHT</code> or <code>SWT.RIGHT_TO_LEFT</code>.
+ *
+ * @return the text direction style
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.102
+ */
+public int getTextDirection() {
+ checkWidget ();
+ int flags = OS.WS_EX_LAYOUTRTL | OS.WS_EX_RTLREADING;
+ int bits = OS.GetWindowLong (handle, OS.GWL_EXSTYLE) & flags;
+ return bits == 0 || bits == flags ? SWT.LEFT_TO_RIGHT : SWT.RIGHT_TO_LEFT;
+}
+
+/**
* Returns the receiver's tool tip text, or null if it has
* not been set.
*
@@ -3488,6 +3508,7 @@ public void setOrientation (int orientation) {
style &= ~SWT.MIRRORED;
style &= ~flags;
style |= orientation & flags;
+ style &= ~SWT.FLIP_TEXT_DIRECTION;
updateOrientation ();
checkMirrored ();
}
@@ -3651,6 +3672,35 @@ boolean setTabItemFocus () {
}
/**
+ * Sets the base text direction (a.k.a. "paragraph direction") of the receiver,
+ * which must be one of the constants <code>SWT.LEFT_TO_RIGHT</code> or
+ * <code>SWT.RIGHT_TO_LEFT</code>.
+ * <p>
+ * <code>setOrientation</code> would override this value with the text direction
+ * that is consistent with the new orientation.
+ *
+ * @param textDirection the base text direction style
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.102
+ */
+public void setTextDirection(int textDirection) {
+ checkWidget ();
+ if (OS.IsWinCE) return;
+ if (OS.WIN32_VERSION < OS.VERSION (4, 10)) return;
+ int flags = SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT;
+ textDirection &= flags;
+ if (textDirection == 0 || textDirection == flags) return;
+ if (updateTextDirection(textDirection)) {
+ OS.InvalidateRect (handle, null, true);
+ }
+}
+
+/**
* Sets the receiver's tool tip text to the argument, which
* may be null indicating that the default tool tip for the
* control will be shown. For a control that has a default
@@ -4420,10 +4470,35 @@ void updateOrientation () {
} else {
bits &= ~OS.WS_EX_LAYOUTRTL;
}
+ bits &= ~OS.WS_EX_RTLREADING;
OS.SetWindowLong (handle, OS.GWL_EXSTYLE, bits);
OS.InvalidateRect (handle, null, true);
}
+boolean updateTextDirection (int textDirection) {
+ int bits = OS.GetWindowLong (handle, OS.GWL_EXSTYLE);
+ /*
+ * OS.WS_EX_RTLREADING means that the text direction is opposite to the
+ * natural one for the current layout. So text direction would be RTL when
+ * one and only one of the flags OS.WS_EX_LAYOUTRTL | OS.WS_EX_RTLREADING is
+ * on.
+ */
+ int flags = OS.WS_EX_LAYOUTRTL | OS.WS_EX_RTLREADING;
+ boolean oldRtl = ((bits & flags) != 0 && (bits & flags) != flags);
+ boolean newRtl = textDirection == SWT.RIGHT_TO_LEFT;
+ if (newRtl == oldRtl) return false;
+ oldRtl = (bits & OS.WS_EX_LAYOUTRTL) != 0;
+ if (newRtl != oldRtl) {
+ bits |= OS.WS_EX_RTLREADING;
+ style |= SWT.FLIP_TEXT_DIRECTION;
+ } else {
+ bits &= ~OS.WS_EX_RTLREADING;
+ style &= ~SWT.FLIP_TEXT_DIRECTION;
+ }
+ OS.SetWindowLong (handle, OS.GWL_EXSTYLE, bits);
+ return true;
+}
+
CREATESTRUCT widgetCreateStruct () {
return null;
}
@@ -4446,6 +4521,7 @@ int widgetExtStyle () {
}
bits |= OS.WS_EX_NOINHERITLAYOUT;
if ((style & SWT.RIGHT_TO_LEFT) != 0) bits |= OS.WS_EX_LAYOUTRTL;
+ if ((style & SWT.FLIP_TEXT_DIRECTION) != 0) bits |= OS.WS_EX_RTLREADING;
return bits;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java
index 676518b..4ef3a33 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java
@@ -567,6 +567,18 @@ public void setSpacing (int spacing) {
OS.InvalidateRect (handle, null, true);
}
+boolean updateTextDirection(int textDirection) {
+ if (super.updateTextDirection(textDirection)) {
+ for (int i = 0, n = items.length; i < n; i++) {
+ if (items[i] != null) {
+ items[i].updateTextDirection(style & SWT.FLIP_TEXT_DIRECTION);
+ }
+ }
+ return true;
+ }
+ return false;
+}
+
void showItem (ExpandItem item) {
Control control = item.control;
if (control != null && !control.isDisposed ()) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandItem.java
index 3ef2b02..5d71883 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandItem.java
@@ -197,7 +197,17 @@ void drawItem (GC gc, long /*int*/ hTheme, RECT clipRect, boolean drawFocus) {
}
if (text.length () > 0) {
rect.left += ExpandItem.TEXT_INSET;
- TCHAR buffer = new TCHAR (parent.getCodePage (), text, false);
+ TCHAR buffer;
+ if ((style & SWT.FLIP_TEXT_DIRECTION) != 0) {
+ int bits = OS.GetWindowLong (parent.handle, OS.GWL_EXSTYLE);
+ if ((bits & OS.WS_EX_LAYOUTRTL) != 0) {
+ buffer = new TCHAR (parent.getCodePage (), LRE + text, false);
+ } else {
+ buffer = new TCHAR (parent.getCodePage (), RLE + text, false);
+ }
+ }
+ else
+ buffer = new TCHAR (parent.getCodePage (), text, false);
if (hTheme != 0) {
OS.DrawThemeText (hTheme, hDC, OS.EBP_NORMALGROUPHEAD, 0, buffer.chars, buffer.length(), OS.DT_VCENTER | OS.DT_SINGLELINE, 0, rect);
} else {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java
index bded168..5419177 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java
@@ -154,24 +154,13 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
Point size = super.computeSize (wHint, hHint, changed);
int length = text.length ();
if (length != 0) {
- /*
- * Bug in Windows. When a group control is right-to-left and
- * is disabled, the first pixel of the text is clipped. The
- * fix is to add a space to both sides of the text. Note that
- * the work around must run all the time to stop the preferred
- * size from changing when a group is enabled and disabled.
- */
- String string = text;
- if ((style & SWT.RIGHT_TO_LEFT) != 0) {
- if (OS.COMCTL32_MAJOR < 6 || !OS.IsAppThemed ()) {
- string = " " + string + " ";
- }
- }
+ String string = fixText (false);
+
/*
* If the group has text, and the text is wider than the
* client area, pad the width so the text is not clipped.
*/
- TCHAR buffer = new TCHAR (getCodePage (), string, true);
+ TCHAR buffer = new TCHAR (getCodePage (), string == null ? text : string, true);
long /*int*/ newFont, oldFont = 0;
long /*int*/ hDC = OS.GetDC (handle);
newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
@@ -230,13 +219,30 @@ void enableWidget (boolean enabled) {
* is disabled, the first pixel of the text is clipped. The
* fix is to add a space to both sides of the text.
*/
+ String string = fixText (enabled);
+ if (string != null) {
+ TCHAR buffer = new TCHAR (getCodePage (), string, true);
+ OS.SetWindowText (handle, buffer);
+ }
+}
+
+String fixText (boolean enabled) {
+ /*
+ * Bug in Windows. When a group control is right-to-left and
+ * is disabled, the first pixel of the text is clipped. The
+ * fix is to add a space to both sides of the text.
+ */
+ if (text.length() == 0) return null;
if ((style & SWT.RIGHT_TO_LEFT) != 0) {
- if (OS.COMCTL32_MAJOR < 6 || !OS.IsAppThemed ()) {
- String string = enabled || text.length() == 0 ? text : " " + text + " ";
- TCHAR buffer = new TCHAR (getCodePage (), string, true);
- OS.SetWindowText (handle, buffer);
+ String string = null;
+ if (!enabled && (OS.COMCTL32_MAJOR < 6 || !OS.IsAppThemed ())) {
+ string = " " + text + " ";
}
+ return (style & SWT.FLIP_TEXT_DIRECTION) == 0 ? string : string != null ? LRE + string : LRE + text;
+ } else if ((style & SWT.FLIP_TEXT_DIRECTION) != 0) {
+ return RLE + text;
}
+ return null;
}
public Rectangle getClientArea () {
@@ -394,20 +400,21 @@ public void setText (String string) {
checkWidget ();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
text = string;
- /*
- * Bug in Windows. When a group control is right-to-left and
- * is disabled, the first pixel of the text is clipped. The
- * fix is to add a space to both sides of the text.
- */
- if ((style & SWT.RIGHT_TO_LEFT) != 0) {
- if (OS.COMCTL32_MAJOR < 6 || !OS.IsAppThemed ()) {
- if (!OS.IsWindowEnabled (handle)) {
- if (string.length() != 0) string = " " + string + " ";
- }
+ string = fixText (OS.IsWindowEnabled (handle));
+ TCHAR buffer = new TCHAR (getCodePage (), string == null ? text : string, true);
+ OS.SetWindowText (handle, buffer);
+}
+
+boolean updateTextDirection(int textDirection) {
+ if (super.updateTextDirection(textDirection)) {
+ String string = fixText (OS.IsWindowEnabled (handle));
+ if (string != null) {
+ TCHAR buffer = new TCHAR (getCodePage (), string, true);
+ OS.SetWindowText (handle, buffer);
}
+ return true;
}
- TCHAR buffer = new TCHAR (getCodePage (), string, true);
- OS.SetWindowText (handle, buffer);
+ return false;
}
int widgetStyle () {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java
index 7181cab..6f697ee 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java
@@ -738,6 +738,19 @@ public void setText (String string) {
}
}
+boolean updateTextDirection(int textDirection) {
+ if (super.updateTextDirection(textDirection)) {
+ int flags = SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT;
+ style &= ~SWT.MIRRORED;
+ style &= ~flags;
+ style |= textDirection & flags;
+ updateOrientation ();
+ checkMirrored ();
+ return true;
+ }
+ return false;
+}
+
int widgetStyle () {
int bits = super.widgetStyle ();
return bits | OS.WS_TABSTOP;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java
index a44eff8..590eff5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java
@@ -1488,6 +1488,7 @@ void _setOrientation (int orientation) {
if ((orientation & flags) == 0 || (orientation & flags) == flags) return;
style &= ~flags;
style |= orientation & flags;
+ style &= ~SWT.FLIP_TEXT_DIRECTION;
MenuItem [] itms = getItems ();
for (int i=0; i<itms.length; i++) {
itms [i].setOrientation (orientation);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
index e1e8b99..6df3452 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
@@ -745,6 +745,16 @@ void setSelection (int index, boolean notify) {
}
}
+boolean updateTextDirection(int textDirection) {
+ if (super.updateTextDirection(textDirection)) {
+ for (int i = 0, n = items.length; i < n && items[i] != null; i++) {
+ items[i].updateTextDirection (textDirection);
+ }
+ return true;
+ }
+ return false;
+}
+
String toolTipText (NMTTDISPINFO hdr) {
if ((hdr.uFlags & OS.TTF_IDISHWND) != 0) {
return null;
@@ -759,7 +769,8 @@ String toolTipText (NMTTDISPINFO hdr) {
* enters the control from the top edge. The fix is
* to explicitly set TTF_RTLREADING.
*/
- if ((style & SWT.RIGHT_TO_LEFT) != 0) {
+ int flags = SWT.RIGHT_TO_LEFT | SWT.FLIP_TEXT_DIRECTION;
+ if ((style & flags) != 0 && (style & flags) != flags) {
hdr.uFlags |= OS.TTF_RTLREADING;
} else {
hdr.uFlags &= ~OS.TTF_RTLREADING;
@@ -805,6 +816,7 @@ void updateOrientation () {
} else {
bits &= ~OS.WS_EX_LAYOUTRTL;
}
+ bits &= ~OS.WS_EX_RTLREADING;
OS.SetWindowLong (hwndChild, OS.GWL_EXSTYLE, bits);
OS.InvalidateRect (hwndChild, null, true);
break;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java
index 35f1845..2c5c527 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java
@@ -344,6 +344,22 @@ public void setText (String string) {
_setText (index, string);
}
+boolean updateTextDirection(int textDirection) {
+ if (super.updateTextDirection(textDirection)) {
+ int index = parent.indexOf (this);
+ if (index != -1) {
+ if ((textDirection & SWT.RIGHT_TO_LEFT) != 0) {
+ _setText(index, RLE + text);
+ return true;
+ } else if ((textDirection & SWT.LEFT_TO_RIGHT) != 0) {
+ _setText(index, LRE + text);
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
/**
* Sets the receiver's tool tip text to the argument, which
* may be null indicating that the default tool tip for the
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
index ec71cb1..c195872 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
@@ -5654,6 +5654,7 @@ void updateOrientation () {
} else {
bits &= ~OS.WS_EX_LAYOUTRTL;
}
+ bits &= ~OS.WS_EX_RTLREADING;
OS.SetWindowLong (hwndHeader, OS.GWL_EXSTYLE, bits);
OS.InvalidateRect (hwndHeader, null, true);
RECT rect = new RECT ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java
index 485e707..a9a6dfa 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java
@@ -1098,6 +1098,18 @@ boolean setTabItemFocus () {
return super.setTabItemFocus ();
}
+boolean updateTextDirection(int textDirection) {
+ if (super.updateTextDirection(textDirection)) {
+ ToolItem [] items = _getItems ();
+ int i = items.length;
+ while (i-- > 0) {
+ items[i].updateTextDirection(style & SWT.FLIP_TEXT_DIRECTION);
+ }
+ return true;
+ }
+ return false;
+}
+
String toolTipText (NMTTDISPINFO hdr) {
if ((hdr.uFlags & OS.TTF_IDISHWND) != 0) {
return null;
@@ -1120,7 +1132,8 @@ String toolTipText (NMTTDISPINFO hdr) {
* enters the control from the top edge. The fix is
* to explicitly set TTF_RTLREADING.
*/
- if ((style & SWT.RIGHT_TO_LEFT) != 0) {
+ int flags = SWT.RIGHT_TO_LEFT | SWT.FLIP_TEXT_DIRECTION;
+ if ((style & flags) != 0 && (style & flags) != flags) {
hdr.uFlags |= OS.TTF_RTLREADING;
} else {
hdr.uFlags &= ~OS.TTF_RTLREADING;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java
index e536d95..d20bdf9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java
@@ -778,6 +778,35 @@ boolean setTabItemFocus () {
return false;
}
+void _setText (String string) {
+ long /*int*/ hwnd = parent.handle;
+ TBBUTTONINFO info = new TBBUTTONINFO ();
+ info.cbSize = TBBUTTONINFO.sizeof;
+ info.dwMask = OS.TBIF_TEXT | OS.TBIF_STYLE;
+ info.fsStyle = (byte) (widgetStyle () | OS.BTNS_AUTOSIZE);
+ long /*int*/ hHeap = OS.GetProcessHeap (), pszText = 0;
+ if (string.length () != 0) {
+ info.fsStyle |= OS.BTNS_SHOWTEXT;
+ TCHAR buffer;
+ if ((style & SWT.FLIP_TEXT_DIRECTION) != 0) {
+ int bits = OS.GetWindowLong (hwnd, OS.GWL_EXSTYLE);
+ if ((bits & OS.WS_EX_LAYOUTRTL) != 0) {
+ buffer = new TCHAR (parent.getCodePage (), LRE + string, true);
+ } else {
+ buffer = new TCHAR (parent.getCodePage (), RLE + string, true);
+ }
+ } else {
+ buffer = new TCHAR(parent.getCodePage (), string, true);
+ }
+ int byteCount = buffer.length () * TCHAR.sizeof;
+ pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ OS.MoveMemory (pszText, buffer, byteCount);
+ info.pszText = pszText;
+ }
+ OS.SendMessage (hwnd, OS.TB_SETBUTTONINFO, id, info);
+ if (pszText != 0) OS.HeapFree (hHeap, 0, pszText);
+}
+
/**
* Sets the receiver's text. The string may include
* the mnemonic character.
@@ -809,22 +838,7 @@ public void setText (String string) {
if ((style & SWT.SEPARATOR) != 0) return;
if (string.equals (text)) return;
super.setText (string);
- long /*int*/ hwnd = parent.handle;
- TBBUTTONINFO info = new TBBUTTONINFO ();
- info.cbSize = TBBUTTONINFO.sizeof;
- info.dwMask = OS.TBIF_TEXT | OS.TBIF_STYLE;
- info.fsStyle = (byte) (widgetStyle () | OS.BTNS_AUTOSIZE);
- long /*int*/ hHeap = OS.GetProcessHeap (), pszText = 0;
- if (string.length () != 0) {
- info.fsStyle |= OS.BTNS_SHOWTEXT;
- TCHAR buffer = new TCHAR (parent.getCodePage (), string, true);
- int byteCount = buffer.length () * TCHAR.sizeof;
- pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
- OS.MoveMemory (pszText, buffer, byteCount);
- info.pszText = pszText;
- }
- OS.SendMessage (hwnd, OS.TB_SETBUTTONINFO, id, info);
- if (pszText != 0) OS.HeapFree (hHeap, 0, pszText);
+ _setText (string);
/*
* Bug in Windows. For some reason, when the font is set
@@ -835,12 +849,21 @@ public void setText (String string) {
* the tool bar to redraw and layout.
*/
parent.setDropDownItems (false);
+ long /*int*/ hwnd = parent.handle;
long /*int*/ hFont = OS.SendMessage (hwnd, OS.WM_GETFONT, 0, 0);
OS.SendMessage (hwnd, OS.WM_SETFONT, hFont, 0);
parent.setDropDownItems (true);
parent.layoutItems ();
}
+boolean updateTextDirection(int textDirection) {
+ if (super.updateTextDirection(textDirection) && text.length() != 0) {
+ _setText (text);
+ return true;
+ }
+ return false;
+}
+
/**
* Sets the receiver's tool tip text to the argument, which
* may be null indicating that the default tool tip for the
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
index 47980b8..e3fd80a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
@@ -5609,6 +5609,7 @@ void updateOrientation () {
} else {
bits &= ~OS.WS_EX_LAYOUTRTL;
}
+ bits &= ~OS.WS_EX_RTLREADING;
OS.SetWindowLong (hwndParent, OS.GWL_EXSTYLE, bits);
rect = new RECT ();
OS.GetWindowRect (hwndParent, rect);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
index 723256b..51b2637 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
@@ -97,6 +97,10 @@ public abstract class Widget {
static final int DEFAULT_WIDTH = 64;
static final int DEFAULT_HEIGHT = 64;
+ /* Bidi UCC to enforce text orientation */
+ static final char LRE = '\u202a';
+ static final char RLE = '\u202b';
+
/* Check and initialize the Common Controls DLL */
static final int MAJOR = 5, MINOR = 80;
static {