View | Details | Raw Unified | Return to bug 273198 | Differences between
and this patch

Collapse All | Expand All

(-)a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java (+10 lines)
Lines 1932-1937 Link Here
1932
	return new Point((int)rect.width, (int)rect.height);
1932
	return new Point((int)rect.width, (int)rect.height);
1933
}
1933
}
1934
1934
1935
public int getTextDirection() {
1936
	checkWidget ();
1937
	/* return the widget orientation */
1938
	return style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
1939
}
1940
1935
float getThemeAlpha () {
1941
float getThemeAlpha () {
1936
	return 1 * parent.getThemeAlpha ();
1942
	return 1 * parent.getThemeAlpha ();
1937
}
1943
}
Lines 4114-4119 Link Here
4114
	return forceFocus ();
4120
	return forceFocus ();
4115
}
4121
}
4116
4122
4123
public void setTextDirection(int textDirection) {
4124
	checkWidget ();
4125
}
4126
4117
/**
4127
/**
4118
 * Sets the receiver's tool tip text to the argument, which
4128
 * Sets the receiver's tool tip text to the argument, which
4119
 * may be null indicating that the default tool tip for the 
4129
 * may be null indicating that the default tool tip for the 
(-)a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java (+12 lines)
Lines 1784-1789 Link Here
1784
	public static final int TRANSPARENT = 1 << 30;
1784
	public static final int TRANSPARENT = 1 << 30;
1785
	
1785
	
1786
	/**
1786
	/**
1787
	 * Style constant to indicate base text direction (value is 1&lt;&lt;31).
1788
	 * <p>
1789
	 * When the bit is set, text direction mismatches the widget orientation 
1790
	 * <p><b>Used By:</b><ul>
1791
	 * <li><code>Control</code></li>
1792
	 * </ul></p>
1793
	 * 
1794
	 * @since 3.101
1795
	 */
1796
	public static final int FLIP_TEXT_DIRECTION = 1 << 31;
1797
1798
	/**
1787
	 * Style constant for align up behavior (value is 1&lt;&lt;7,
1799
	 * Style constant for align up behavior (value is 1&lt;&lt;7,
1788
	 * since align UP and align TOP are considered the same).
1800
	 * since align UP and align TOP are considered the same).
1789
	 * <p><b>Used By:</b><ul>
1801
	 * <p><b>Used By:</b><ul>
(-)a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Item.java (+10 lines)
Lines 183-186 Link Here
183
	text = string;
183
	text = string;
184
}
184
}
185
185
186
boolean updateTextDirection(int textDirection) {
187
	checkWidget ();
188
	if (((style  & SWT.FLIP_TEXT_DIRECTION) ^ textDirection) != 0) {
189
		style ^= SWT.FLIP_TEXT_DIRECTION;
190
		return true;
191
	}
192
	return false;
193
}
194
195
186
}
196
}
(-)a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java (+10 lines)
Lines 266-271 Link Here
266
	return style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
266
	return style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
267
}
267
}
268
268
269
public int getTextDirection() {
270
	checkWidget ();
271
	/* return the widget orientation */
272
	return style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
273
}
274
269
boolean hasFocus () {
275
boolean hasFocus () {
270
	return this == display.getFocusControl();
276
	return this == display.getFocusControl();
271
}
277
}
Lines 4546-4551 Link Here
4546
	return forceFocus ();
4552
	return forceFocus ();
4547
}
4553
}
4548
4554
4555
public void setTextDirection(int textDirection) {
4556
	checkWidget ();
4557
}
4558
4549
/**
4559
/**
4550
 * Sets the receiver's tool tip text to the argument, which
4560
 * Sets the receiver's tool tip text to the argument, which
4551
 * may be null indicating that the default tool tip for the 
4561
 * may be null indicating that the default tool tip for the 
(-)a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java (+1 lines)
Lines 2067-2072 Link Here
2067
	} else {
2067
	} else {
2068
		bits &= ~OS.WS_EX_LAYOUTRTL;
2068
		bits &= ~OS.WS_EX_LAYOUTRTL;
2069
	}
2069
	}
2070
	bits &= ~OS.WS_EX_RTLREADING;
2070
	OS.SetWindowLong (handle, OS.GWL_EXSTYLE, bits);
2071
	OS.SetWindowLong (handle, OS.GWL_EXSTYLE, bits);
2071
	long /*int*/ hwndText = 0, hwndList = 0;
2072
	long /*int*/ hwndText = 0, hwndList = 0;
2072
	COMBOBOXINFO pcbi = new COMBOBOXINFO ();
2073
	COMBOBOXINFO pcbi = new COMBOBOXINFO ();
(-)a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java (-1 / +20 lines)
Lines 1157-1162 Link Here
1157
	return false;
1157
	return false;
1158
}
1158
}
1159
1159
1160
boolean updateTextDirection(int textDirection) {
1161
	if (super.updateTextDirection(textDirection)) {
1162
		/* 
1163
		 * OS.WS_EX_RTLREADING doesn't propagate to children
1164
		 */
1165
		Control[] children = _getChildren ();
1166
		int i = children.length;
1167
		while (i-- > 0) {
1168
			if (children[i] != null && !children[i].isDisposed ()) {
1169
				children[i].updateTextDirection(textDirection);
1170
			}
1171
		}
1172
		return true;
1173
	}
1174
	return false;
1175
}
1176
1160
String toolTipText (NMTTDISPINFO hdr) {
1177
String toolTipText (NMTTDISPINFO hdr) {
1161
	Shell shell = getShell ();
1178
	Shell shell = getShell ();
1162
	if ((hdr.uFlags & OS.TTF_IDISHWND) == 0) {
1179
	if ((hdr.uFlags & OS.TTF_IDISHWND) == 0) {
Lines 1871-1877 Link Here
1871
						}
1888
						}
1872
					}
1889
					}
1873
					if (widget != null) {
1890
					if (widget != null) {
1874
						if ((widget.getStyle () & SWT.RIGHT_TO_LEFT) != 0) {
1891
						int style = widget.getStyle();
1892
						int flags = SWT.RIGHT_TO_LEFT | SWT.FLIP_TEXT_DIRECTION;
1893
						if ((style & flags) != 0 && (style & flags) != flags) {
1875
							lpnmtdi.uFlags |= OS.TTF_RTLREADING;
1894
							lpnmtdi.uFlags |= OS.TTF_RTLREADING;
1876
						} else {
1895
						} else {
1877
							lpnmtdi.uFlags &= ~OS.TTF_RTLREADING;
1896
							lpnmtdi.uFlags &= ~OS.TTF_RTLREADING;
(-)a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java (+76 lines)
Lines 1581-1586 Link Here
1581
}
1581
}
1582
1582
1583
/**
1583
/**
1584
 * Returns the text direction of the receiver, which will be one of the
1585
 * constants <code>SWT.LEFT_TO_RIGHT</code> or <code>SWT.RIGHT_TO_LEFT</code>.
1586
 *
1587
 * @return the text direction style
1588
 * 
1589
 * @exception SWTException <ul>
1590
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
1591
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
1592
 * </ul>
1593
 * 
1594
 * @since 3.101
1595
 */
1596
public int getTextDirection() {
1597
	checkWidget ();
1598
	int flags = OS.WS_EX_LAYOUTRTL | OS.WS_EX_RTLREADING;
1599
	int bits  = OS.GetWindowLong (handle, OS.GWL_EXSTYLE) & flags;
1600
	return bits == 0 || bits == flags ? SWT.LEFT_TO_RIGHT : SWT.RIGHT_TO_LEFT;
1601
}
1602
1603
/**
1584
 * Returns the receiver's tool tip text, or null if it has
1604
 * Returns the receiver's tool tip text, or null if it has
1585
 * not been set.
1605
 * not been set.
1586
 *
1606
 *
Lines 3488-3493 Link Here
3488
	style &= ~SWT.MIRRORED;
3508
	style &= ~SWT.MIRRORED;
3489
	style &= ~flags;
3509
	style &= ~flags;
3490
	style |= orientation & flags;
3510
	style |= orientation & flags;
3511
	style &= ~SWT.FLIP_TEXT_DIRECTION;
3491
	updateOrientation ();
3512
	updateOrientation ();
3492
	checkMirrored ();
3513
	checkMirrored ();
3493
}
3514
}
Lines 3648-3653 Link Here
3648
boolean setTabItemFocus () {
3669
boolean setTabItemFocus () {
3649
	if (!isShowing ()) return false;
3670
	if (!isShowing ()) return false;
3650
	return forceFocus ();
3671
	return forceFocus ();
3672
}
3673
3674
/**
3675
 * Sets the base text direction (a.k.a. "paragraph direction") of the receiver,
3676
 * which must be one of the constants <code>SWT.LEFT_TO_RIGHT</code> or
3677
 * <code>SWT.RIGHT_TO_LEFT</code>.
3678
 * <p>
3679
 * <code>setOrientation</code> would override this value with the text direction
3680
 * that is consistent with the new orientation
3681
 *
3682
 * @param textDirection New base text direction style
3683
 * 
3684
 * @exception SWTException <ul>
3685
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
3686
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
3687
 * </ul>
3688
 * 
3689
 * @since 3.101
3690
 */
3691
public void setTextDirection(int textDirection) {
3692
	checkWidget ();
3693
	if (OS.IsWinCE) return;
3694
	if (OS.WIN32_VERSION < OS.VERSION (4, 10)) return;
3695
	int flags = SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT;
3696
	textDirection &= flags;
3697
	if (textDirection == 0 || textDirection == flags) return;
3698
	if (updateTextDirection(textDirection)) {
3699
		OS.InvalidateRect (handle, null, true);
3700
	}
3651
}
3701
}
3652
3702
3653
/**
3703
/**
Lines 4420-4427 Link Here
4420
	} else {
4470
	} else {
4421
		bits &= ~OS.WS_EX_LAYOUTRTL;
4471
		bits &= ~OS.WS_EX_LAYOUTRTL;
4422
	}
4472
	}
4473
	bits &= ~OS.WS_EX_RTLREADING;
4423
	OS.SetWindowLong (handle, OS.GWL_EXSTYLE, bits);
4474
	OS.SetWindowLong (handle, OS.GWL_EXSTYLE, bits);
4424
	OS.InvalidateRect (handle, null, true);
4475
	OS.InvalidateRect (handle, null, true);
4476
}
4477
4478
boolean updateTextDirection (int textDirection) {
4479
	int bits  = OS.GetWindowLong (handle, OS.GWL_EXSTYLE);
4480
	/*
4481
	* OS.WS_EX_RTLREADING means that the text direction is opposite to the
4482
	* natural one for the current layout. So text direction would be RTL when
4483
	* one and only one of the flags OS.WS_EX_LAYOUTRTL | OS.WS_EX_RTLREADING is
4484
	* on. 
4485
	*/
4486
	int flags = OS.WS_EX_LAYOUTRTL | OS.WS_EX_RTLREADING;
4487
	boolean oldRtl = ((bits & flags) != 0 && (bits & flags) != flags);
4488
	boolean newRtl = textDirection == SWT.RIGHT_TO_LEFT;
4489
	if (newRtl == oldRtl) return false;
4490
	oldRtl = (bits & OS.WS_EX_LAYOUTRTL) != 0;
4491
	if (newRtl != oldRtl) {
4492
		bits |= OS.WS_EX_RTLREADING;
4493
		style |= SWT.FLIP_TEXT_DIRECTION;
4494
	} else {
4495
		bits &= ~OS.WS_EX_RTLREADING;
4496
		style &= ~SWT.FLIP_TEXT_DIRECTION;
4497
	}
4498
	OS.SetWindowLong (handle, OS.GWL_EXSTYLE, bits);
4499
	return true;
4425
}
4500
}
4426
4501
4427
CREATESTRUCT widgetCreateStruct () {
4502
CREATESTRUCT widgetCreateStruct () {
Lines 4446-4451 Link Here
4446
	} 
4521
	} 
4447
	bits |= OS.WS_EX_NOINHERITLAYOUT;
4522
	bits |= OS.WS_EX_NOINHERITLAYOUT;
4448
	if ((style & SWT.RIGHT_TO_LEFT) != 0) bits |= OS.WS_EX_LAYOUTRTL;
4523
	if ((style & SWT.RIGHT_TO_LEFT) != 0) bits |= OS.WS_EX_LAYOUTRTL;
4524
	if ((style & SWT.FLIP_TEXT_DIRECTION) != 0) bits |= OS.WS_EX_RTLREADING;
4449
	return bits;
4525
	return bits;
4450
}
4526
}
4451
4527
(-)a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java (+12 lines)
Lines 567-572 Link Here
567
	OS.InvalidateRect (handle, null, true);
567
	OS.InvalidateRect (handle, null, true);
568
}
568
}
569
569
570
boolean updateTextDirection(int textDirection) {
571
	if (super.updateTextDirection(textDirection)) {
572
		for (int i = 0, n = items.length; i < n; i++) {
573
			if (items[i] != null) {
574
				items[i].updateTextDirection(style & SWT.FLIP_TEXT_DIRECTION);
575
			}
576
		}
577
		return true;
578
	}
579
	return false;
580
}
581
570
void showItem (ExpandItem item) {
582
void showItem (ExpandItem item) {
571
	Control control = item.control;
583
	Control control = item.control;
572
	if (control != null && !control.isDisposed ()) {
584
	if (control != null && !control.isDisposed ()) {
(-)a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandItem.java (-1 / +11 lines)
Lines 197-203 Link Here
197
	}
197
	}
198
	if (text.length () > 0) {
198
	if (text.length () > 0) {
199
		rect.left += ExpandItem.TEXT_INSET;
199
		rect.left += ExpandItem.TEXT_INSET;
200
		TCHAR buffer = new TCHAR (parent.getCodePage (), text, false);
200
		TCHAR buffer;
201
		if ((style & SWT.FLIP_TEXT_DIRECTION) != 0) {
202
			int bits  = OS.GetWindowLong (parent.handle, OS.GWL_EXSTYLE);
203
			if ((bits & OS.WS_EX_LAYOUTRTL) != 0) {
204
				buffer = new TCHAR (parent.getCodePage (), LRE + text, false);
205
			} else {
206
				buffer = new TCHAR (parent.getCodePage (), RLE + text, false);
207
			}
208
		}
209
		else
210
			buffer = new TCHAR (parent.getCodePage (), text, false);
201
		if (hTheme != 0) {
211
		if (hTheme != 0) {
202
			OS.DrawThemeText (hTheme, hDC, OS.EBP_NORMALGROUPHEAD, 0, buffer.chars, buffer.length(), OS.DT_VCENTER | OS.DT_SINGLELINE, 0, rect);
212
			OS.DrawThemeText (hTheme, hDC, OS.EBP_NORMALGROUPHEAD, 0, buffer.chars, buffer.length(), OS.DT_VCENTER | OS.DT_SINGLELINE, 0, rect);
203
		} else {
213
		} else {
(-)a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java (-31 / +38 lines)
Lines 154-177 Link Here
154
	Point size = super.computeSize (wHint, hHint, changed);
154
	Point size = super.computeSize (wHint, hHint, changed);
155
	int length = text.length ();
155
	int length = text.length ();
156
	if (length != 0) {
156
	if (length != 0) {
157
		/*
157
		String string = fixText (false);
158
		* Bug in Windows.  When a group control is right-to-left and
158
159
		* is disabled, the first pixel of the text is clipped.  The
160
		* fix is to add a space to both sides of the text.  Note that
161
		* the work around must run all the time to stop the preferred
162
		* size from changing when a group is enabled and disabled.
163
		*/
164
		String string = text;
165
		if ((style & SWT.RIGHT_TO_LEFT) != 0) {
166
			if (OS.COMCTL32_MAJOR < 6 || !OS.IsAppThemed ()) {
167
				string = " " + string + " ";
168
			}
169
		}
170
		/*
159
		/*
171
		* If the group has text, and the text is wider than the
160
		* If the group has text, and the text is wider than the
172
		* client area, pad the width so the text is not clipped.
161
		* client area, pad the width so the text is not clipped.
173
		*/
162
		*/
174
		TCHAR buffer = new TCHAR (getCodePage (), string, true);
163
		TCHAR buffer = new TCHAR (getCodePage (), string == null ? text : string, true);
175
		long /*int*/ newFont, oldFont = 0;
164
		long /*int*/ newFont, oldFont = 0;
176
		long /*int*/ hDC = OS.GetDC (handle);
165
		long /*int*/ hDC = OS.GetDC (handle);
177
		newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
166
		newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
Lines 230-242 Link Here
230
	* is disabled, the first pixel of the text is clipped.  The
219
	* is disabled, the first pixel of the text is clipped.  The
231
	* fix is to add a space to both sides of the text.
220
	* fix is to add a space to both sides of the text.
232
	*/
221
	*/
233
	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
222
	String string = fixText (enabled);
234
		if (OS.COMCTL32_MAJOR < 6 || !OS.IsAppThemed ()) {
223
	if (string != null) {
235
			String string = enabled || text.length() == 0 ? text : " " + text + " ";
236
			TCHAR buffer = new TCHAR (getCodePage (), string, true);
224
			TCHAR buffer = new TCHAR (getCodePage (), string, true);
237
			OS.SetWindowText (handle, buffer);
225
			OS.SetWindowText (handle, buffer);
238
		}
239
	}
226
	}
227
}
228
229
String fixText (boolean enabled) {
230
	/*
231
	* Bug in Windows.  When a group control is right-to-left and
232
	* is disabled, the first pixel of the text is clipped.  The
233
	* fix is to add a space to both sides of the text.
234
	*/
235
	if (text.length() == 0) return null;
236
	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
237
		String string = null;
238
		if (!enabled && (OS.COMCTL32_MAJOR < 6 || !OS.IsAppThemed ())) {
239
			string = " " + text + " ";
240
		}
241
		return (style & SWT.FLIP_TEXT_DIRECTION) == 0 ? string : string != null ? LRE + string : LRE + text;
242
	} else if ((style & SWT.FLIP_TEXT_DIRECTION) != 0) {
243
		return RLE + text;
244
	}
245
	return null;
240
}
246
}
241
247
242
public Rectangle getClientArea () {
248
public Rectangle getClientArea () {
Lines 394-415 Link Here
394
	checkWidget ();
400
	checkWidget ();
395
	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
401
	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
396
	text = string;
402
	text = string;
397
	/*
403
	string = fixText (OS.IsWindowEnabled (handle));
398
	* Bug in Windows.  When a group control is right-to-left and
404
	TCHAR buffer = new TCHAR (getCodePage (), string == null ? text : string, true);
399
	* is disabled, the first pixel of the text is clipped.  The
400
	* fix is to add a space to both sides of the text.
401
	*/
402
	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
403
		if (OS.COMCTL32_MAJOR < 6 || !OS.IsAppThemed ()) {
404
			if (!OS.IsWindowEnabled (handle)) {
405
				if (string.length() != 0) string = " " + string + " ";
406
			}
407
		}
408
	}
409
	TCHAR buffer = new TCHAR (getCodePage (), string, true);
410
	OS.SetWindowText (handle, buffer);
405
	OS.SetWindowText (handle, buffer);
411
}
406
}
412
407
408
boolean updateTextDirection(int textDirection) {
409
	if (super.updateTextDirection(textDirection)) {
410
		String string = fixText (OS.IsWindowEnabled (handle));
411
		if (string != null) {
412
			TCHAR buffer = new TCHAR (getCodePage (), string, true);
413
			OS.SetWindowText (handle, buffer);
414
		}
415
		return true;
416
	}
417
	return false;
418
}
419
413
int widgetStyle () {
420
int widgetStyle () {
414
	/*
421
	/*
415
	* Bug in Windows.  When GetDCEx() is called with DCX_INTERSECTUPDATE,
422
	* Bug in Windows.  When GetDCEx() is called with DCX_INTERSECTUPDATE,
(-)a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java (+13 lines)
Lines 738-743 Link Here
738
	}
738
	}
739
}
739
}
740
740
741
boolean updateTextDirection(int textDirection) {
742
	if (super.updateTextDirection(textDirection)) {
743
		int flags = SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT;
744
		style &= ~SWT.MIRRORED;
745
		style &= ~flags;
746
		style |= textDirection & flags;
747
		updateOrientation ();
748
		checkMirrored ();
749
		return true;
750
	}
751
	return false;
752
}
753
741
int widgetStyle () {
754
int widgetStyle () {
742
	int bits = super.widgetStyle ();
755
	int bits = super.widgetStyle ();
743
	return bits | OS.WS_TABSTOP;
756
	return bits | OS.WS_TABSTOP;
(-)a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java (+1 lines)
Lines 1488-1493 Link Here
1488
   if ((orientation & flags) == 0 || (orientation & flags) == flags) return;
1488
   if ((orientation & flags) == 0 || (orientation & flags) == flags) return;
1489
   style &= ~flags;
1489
   style &= ~flags;
1490
   style |= orientation & flags;
1490
   style |= orientation & flags;
1491
   style &= ~SWT.FLIP_TEXT_DIRECTION;
1491
   MenuItem [] itms = getItems ();
1492
   MenuItem [] itms = getItems ();
1492
   for (int i=0; i<itms.length; i++) {
1493
   for (int i=0; i<itms.length; i++) {
1493
       itms [i].setOrientation (orientation);
1494
       itms [i].setOrientation (orientation);
(-)a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java (-1 / +13 lines)
Lines 745-750 Link Here
745
	}
745
	}
746
}
746
}
747
747
748
boolean updateTextDirection(int textDirection) {
749
	if (super.updateTextDirection(textDirection)) {
750
		for (int i = 0, n = items.length; i < n && items[i] != null; i++) {
751
			items[i].updateTextDirection (textDirection);
752
		}
753
		return true;
754
	}
755
	return false;
756
}
757
748
String toolTipText (NMTTDISPINFO hdr) {
758
String toolTipText (NMTTDISPINFO hdr) {
749
	if ((hdr.uFlags & OS.TTF_IDISHWND) != 0) {
759
	if ((hdr.uFlags & OS.TTF_IDISHWND) != 0) {
750
		return null;
760
		return null;
Lines 759-765 Link Here
759
		* enters the control from the top edge.  The fix is
769
		* enters the control from the top edge.  The fix is
760
		* to explicitly set TTF_RTLREADING.
770
		* to explicitly set TTF_RTLREADING.
761
		*/
771
		*/
762
		if ((style & SWT.RIGHT_TO_LEFT) != 0) {
772
		int flags = SWT.RIGHT_TO_LEFT | SWT.FLIP_TEXT_DIRECTION;
773
		if ((style & flags) != 0 && (style & flags) != flags) {
763
			hdr.uFlags |= OS.TTF_RTLREADING;
774
			hdr.uFlags |= OS.TTF_RTLREADING;
764
		} else {
775
		} else {
765
			hdr.uFlags &= ~OS.TTF_RTLREADING;
776
			hdr.uFlags &= ~OS.TTF_RTLREADING;
Lines 805-810 Link Here
805
			} else {
816
			} else {
806
				bits &= ~OS.WS_EX_LAYOUTRTL;
817
				bits &= ~OS.WS_EX_LAYOUTRTL;
807
			}
818
			}
819
			bits &= ~OS.WS_EX_RTLREADING;
808
			OS.SetWindowLong (hwndChild, OS.GWL_EXSTYLE, bits);
820
			OS.SetWindowLong (hwndChild, OS.GWL_EXSTYLE, bits);
809
			OS.InvalidateRect (hwndChild, null, true);
821
			OS.InvalidateRect (hwndChild, null, true);
810
			break;
822
			break;
(-)a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java (+16 lines)
Lines 344-349 Link Here
344
	_setText (index, string);
344
	_setText (index, string);
345
}
345
}
346
346
347
boolean updateTextDirection(int textDirection) {
348
	if (super.updateTextDirection(textDirection)) {
349
		int index = parent.indexOf (this);
350
		if (index != -1) {
351
			if ((textDirection & SWT.RIGHT_TO_LEFT) != 0) {
352
				_setText(index, RLE + text);
353
				return true;
354
			} else if ((textDirection & SWT.LEFT_TO_RIGHT) != 0) {
355
				_setText(index, LRE + text);
356
				return true;
357
			}
358
		}
359
	}
360
	return false;
361
}
362
347
/**
363
/**
348
 * Sets the receiver's tool tip text to the argument, which
364
 * Sets the receiver's tool tip text to the argument, which
349
 * may be null indicating that the default tool tip for the 
365
 * may be null indicating that the default tool tip for the 
(-)a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java (+1 lines)
Lines 5654-5659 Link Here
5654
		} else {
5654
		} else {
5655
			bits &= ~OS.WS_EX_LAYOUTRTL;
5655
			bits &= ~OS.WS_EX_LAYOUTRTL;
5656
		}
5656
		}
5657
		bits &= ~OS.WS_EX_RTLREADING;
5657
		OS.SetWindowLong (hwndHeader, OS.GWL_EXSTYLE, bits);
5658
		OS.SetWindowLong (hwndHeader, OS.GWL_EXSTYLE, bits);
5658
		OS.InvalidateRect (hwndHeader, null, true);
5659
		OS.InvalidateRect (hwndHeader, null, true);
5659
		RECT rect = new RECT ();
5660
		RECT rect = new RECT ();
(-)a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java (-1 / +14 lines)
Lines 1098-1103 Link Here
1098
	return super.setTabItemFocus ();
1098
	return super.setTabItemFocus ();
1099
}
1099
}
1100
1100
1101
boolean updateTextDirection(int textDirection) {
1102
	if (super.updateTextDirection(textDirection)) {
1103
		ToolItem [] items = _getItems ();
1104
		int i = items.length;
1105
		while (i-- > 0) {
1106
			items[i].updateTextDirection(style & SWT.FLIP_TEXT_DIRECTION);
1107
		}
1108
		return true;
1109
	}
1110
	return false;
1111
}
1112
1101
String toolTipText (NMTTDISPINFO hdr) {
1113
String toolTipText (NMTTDISPINFO hdr) {
1102
	if ((hdr.uFlags & OS.TTF_IDISHWND) != 0) {
1114
	if ((hdr.uFlags & OS.TTF_IDISHWND) != 0) {
1103
		return null;
1115
		return null;
Lines 1120-1126 Link Here
1120
		* enters the control from the top edge.  The fix is
1132
		* enters the control from the top edge.  The fix is
1121
		* to explicitly set TTF_RTLREADING.
1133
		* to explicitly set TTF_RTLREADING.
1122
		*/
1134
		*/
1123
		if ((style & SWT.RIGHT_TO_LEFT) != 0) {
1135
		int flags = SWT.RIGHT_TO_LEFT | SWT.FLIP_TEXT_DIRECTION;
1136
		if ((style & flags) != 0 && (style & flags) != flags) {
1124
			hdr.uFlags |= OS.TTF_RTLREADING;
1137
			hdr.uFlags |= OS.TTF_RTLREADING;
1125
		} else {
1138
		} else {
1126
			hdr.uFlags &= ~OS.TTF_RTLREADING;
1139
			hdr.uFlags &= ~OS.TTF_RTLREADING;
(-)a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java (-16 / +39 lines)
Lines 778-783 Link Here
778
	return false;
778
	return false;
779
}
779
}
780
780
781
void _setText (String string) {
782
	long /*int*/ hwnd = parent.handle;
783
	TBBUTTONINFO info = new TBBUTTONINFO ();
784
	info.cbSize = TBBUTTONINFO.sizeof;
785
	info.dwMask = OS.TBIF_TEXT | OS.TBIF_STYLE;
786
	info.fsStyle = (byte) (widgetStyle () | OS.BTNS_AUTOSIZE);
787
	long /*int*/ hHeap = OS.GetProcessHeap (), pszText = 0;
788
	if (string.length () != 0) {
789
		info.fsStyle |= OS.BTNS_SHOWTEXT;
790
		TCHAR buffer;
791
		if ((style & SWT.FLIP_TEXT_DIRECTION) != 0) {
792
			int bits  = OS.GetWindowLong (hwnd, OS.GWL_EXSTYLE);
793
			if ((bits & OS.WS_EX_LAYOUTRTL) != 0) {
794
				buffer = new TCHAR (parent.getCodePage (), LRE + string, true);
795
			} else {
796
				buffer = new TCHAR (parent.getCodePage (), RLE + string, true);
797
			}
798
		} else {
799
			buffer = new TCHAR(parent.getCodePage (), string, true);
800
		}
801
		int byteCount = buffer.length () * TCHAR.sizeof;
802
		pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
803
		OS.MoveMemory (pszText, buffer, byteCount); 
804
		info.pszText = pszText;
805
	}
806
	OS.SendMessage (hwnd, OS.TB_SETBUTTONINFO, id, info);
807
	if (pszText != 0) OS.HeapFree (hHeap, 0, pszText);
808
}
809
781
/**
810
/**
782
 * Sets the receiver's text. The string may include
811
 * Sets the receiver's text. The string may include
783
 * the mnemonic character.
812
 * the mnemonic character.
Lines 809-830 Link Here
809
	if ((style & SWT.SEPARATOR) != 0) return;
838
	if ((style & SWT.SEPARATOR) != 0) return;
810
	if (string.equals (text)) return;
839
	if (string.equals (text)) return;
811
	super.setText (string);
840
	super.setText (string);
812
	long /*int*/ hwnd = parent.handle;
841
	_setText (string);
813
	TBBUTTONINFO info = new TBBUTTONINFO ();
814
	info.cbSize = TBBUTTONINFO.sizeof;
815
	info.dwMask = OS.TBIF_TEXT | OS.TBIF_STYLE;
816
	info.fsStyle = (byte) (widgetStyle () | OS.BTNS_AUTOSIZE);
817
	long /*int*/ hHeap = OS.GetProcessHeap (), pszText = 0;
818
	if (string.length () != 0) {
819
		info.fsStyle |= OS.BTNS_SHOWTEXT;
820
		TCHAR buffer = new TCHAR (parent.getCodePage (), string, true);
821
		int byteCount = buffer.length () * TCHAR.sizeof;
822
		pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
823
		OS.MoveMemory (pszText, buffer, byteCount); 
824
		info.pszText = pszText;
825
	}
826
	OS.SendMessage (hwnd, OS.TB_SETBUTTONINFO, id, info);
827
	if (pszText != 0) OS.HeapFree (hHeap, 0, pszText);
828
	
842
	
829
	/*
843
	/*
830
	* Bug in Windows.  For some reason, when the font is set
844
	* Bug in Windows.  For some reason, when the font is set
Lines 835-846 Link Here
835
	* the tool bar to redraw and layout.
849
	* the tool bar to redraw and layout.
836
	*/
850
	*/
837
	parent.setDropDownItems (false);
851
	parent.setDropDownItems (false);
852
	long /*int*/ hwnd = parent.handle;
838
	long /*int*/ hFont = OS.SendMessage (hwnd, OS.WM_GETFONT, 0, 0);
853
	long /*int*/ hFont = OS.SendMessage (hwnd, OS.WM_GETFONT, 0, 0);
839
	OS.SendMessage (hwnd, OS.WM_SETFONT, hFont, 0);
854
	OS.SendMessage (hwnd, OS.WM_SETFONT, hFont, 0);
840
	parent.setDropDownItems (true);
855
	parent.setDropDownItems (true);
841
	parent.layoutItems ();
856
	parent.layoutItems ();
842
}
857
}
843
858
859
boolean updateTextDirection(int textDirection) {
860
	if (super.updateTextDirection(textDirection) && text.length() != 0) {
861
		_setText (text);
862
		return true;
863
	}
864
	return false;
865
}
866
844
/**
867
/**
845
 * Sets the receiver's tool tip text to the argument, which
868
 * Sets the receiver's tool tip text to the argument, which
846
 * may be null indicating that the default tool tip for the 
869
 * may be null indicating that the default tool tip for the 
(-)a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java (+1 lines)
Lines 5583-5588 Link Here
5583
		} else {
5583
		} else {
5584
			bits &= ~OS.WS_EX_LAYOUTRTL;
5584
			bits &= ~OS.WS_EX_LAYOUTRTL;
5585
		}
5585
		}
5586
		bits &= ~OS.WS_EX_RTLREADING;
5586
		OS.SetWindowLong (hwndParent, OS.GWL_EXSTYLE, bits);
5587
		OS.SetWindowLong (hwndParent, OS.GWL_EXSTYLE, bits);
5587
		rect = new RECT ();
5588
		rect = new RECT ();
5588
		OS.GetWindowRect (hwndParent, rect);
5589
		OS.GetWindowRect (hwndParent, rect);
(-)a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java (+4 lines)
Lines 97-102 Link Here
97
	static final int DEFAULT_WIDTH	= 64;
97
	static final int DEFAULT_WIDTH	= 64;
98
	static final int DEFAULT_HEIGHT	= 64;
98
	static final int DEFAULT_HEIGHT	= 64;
99
99
100
	/* Bidi UCC to enforce text orientation */
101
	static final char LRE = '\u202a';
102
	static final char RLE = '\u202b';
103
100
	/* Check and initialize the Common Controls DLL */
104
	/* Check and initialize the Common Controls DLL */
101
	static final int MAJOR = 5, MINOR = 80;
105
	static final int MAJOR = 5, MINOR = 80;
102
	static {
106
	static {

Return to bug 273198