diff options
author | Lina Kemmel <lkemmel@il.ibm.com> | 2013-03-13 15:12:29 -0400 |
---|---|---|
committer | Silenio Quarti <silenio_quarti@ca.ibm.com> | 2013-03-13 15:12:29 -0400 |
commit | 2b14d767020ed3598cdf53c0df27bc3b8bd1ea64 (patch) | |
tree | c1d7cf106131c5d5751b32f571340a38b99f3353 /bundles/org.eclipse.swt/Eclipse SWT/win32/org | |
parent | 71391fc1dc9d75effb13782c0dee4de011e77da2 (diff) | |
download | eclipse.platform.swt-2b14d767020ed3598cdf53c0df27bc3b8bd1ea64.tar.gz eclipse.platform.swt-2b14d767020ed3598cdf53c0df27bc3b8bd1ea64.tar.xz eclipse.platform.swt-2b14d767020ed3598cdf53c0df27bc3b8bd1ea64.zip |
Bug 273198 - [Bidi] Lack of support for controlling text direction independently from widget orientation
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/win32/org')
15 files changed, 259 insertions, 50 deletions
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 b4260ccfd1..1509189fcb 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 632a44a63a..c88e9be174 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 92056be90c..f9f75ef205 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 676518bb05..4ef3a33cdf 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 3ef2b02572..5d71883aed 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 bded168bba..5419177269 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 7181cab877..6f697eeff6 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 a44eff8633..590eff501a 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 e1e8b9990a..6df34525d0 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 35f1845a52..2c5c5275c1 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 ec71cb13f9..c195872ac5 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 485e7070f2..a9a6dfa837 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 e536d9548f..d20bdf93de 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 47980b87c4..e3fd80a933 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 723256bc8c..51b26379e8 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 { |