Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLina Kemmel2015-08-18 20:54:28 +0000
committerArun Thondapu2015-08-24 12:41:20 +0000
commit48f8779ad0bcc91ca895524c6cd481d73e20d582 (patch)
treed5f3ca0f11232b7b807bc40ff48251e61c10e6bf
parent7143d17b5fe556de53ad67fe1338887207a436d6 (diff)
downloadeclipse.platform.swt-48f8779ad0bcc91ca895524c6cd481d73e20d582.tar.gz
eclipse.platform.swt-48f8779ad0bcc91ca895524c6cd481d73e20d582.tar.xz
eclipse.platform.swt-48f8779ad0bcc91ca895524c6cd481d73e20d582.zip
Bug 467852 - [Win32][bidi] Control#setTextDirection(int) on Composite
doesn't memorize AUTO state on Button and Group children Change-Id: Ifd04c2268de593c7065d4328a2acb58dcda3d5d8 Signed-off-by: Arun Thondapu <arunkumar.thondapu@in.ibm.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java16
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java56
8 files changed, 66 insertions, 59 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
index d4a4b772c7..052e1b1340 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
@@ -804,6 +804,10 @@ public void removeSelectionListener (SelectionListener listener) {
eventTable.unhook (SWT.DefaultSelection,listener);
}
+int resolveTextDirection() {
+ return (style & SWT.ARROW) != 0 ? SWT.NONE : resolveTextDirection(text);
+}
+
void selectRadio () {
/*
* This code is intentionally commented. When two groups
@@ -1104,11 +1108,7 @@ public void setText (String string) {
_setText (string);
}
-@Override
boolean updateTextDirection(int textDirection) {
- if (textDirection == AUTO_TEXT_DIRECTION) {
- textDirection = (style & SWT.ARROW) != 0 ? SWT.NONE : resolveTextDirection(text);
- }
if (super.updateTextDirection(textDirection)) {
// TODO: Keep for now, to follow up
// int flags = SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT;
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 300c0bf11d..aa3d4d6f9f 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
@@ -413,11 +413,13 @@ void applyEditSegments () {
* This is to ensure correct caret movement, and makes sense even when the
* UCC was added by an authentic SegmentListener.
*/
+ int auto = state & HAS_AUTO_DIRECTION;
if (segmentsChars[0] == RLE) {
super.updateTextDirection(SWT.RIGHT_TO_LEFT);
} else if (segmentsChars[0] == LRE) {
super.updateTextDirection(SWT.LEFT_TO_RIGHT);
}
+ state |= auto;
}
OS.SendMessage (hwndText, OS.EM_SETSEL, start [0], end [0]);
ignoreCharacter = oldIgnoreCharacter;
@@ -2465,19 +2467,14 @@ void updateDropDownHeight () {
}
}
-@Override
boolean updateTextDirection(int textDirection) {
- state &= ~HAS_AUTO_DIRECTION;
if (super.updateTextDirection(textDirection)) {
- /*
- * state gets updated in Control#setTextDirection after updateTextDirection
- * completes, but we need here the state to be up-to-date already, before
- * clearing / applying segments.
- */
if (textDirection == AUTO_TEXT_DIRECTION) {
/* To support auto direction we use UCC that are not available in ANSI CP */
- if (!OS.IsUnicode) return false;
- state |= HAS_AUTO_DIRECTION;
+ if (!OS.IsUnicode) {
+ state &= ~HAS_AUTO_DIRECTION;
+ return false;
+ }
}
clearSegments (true);
applyEditSegments ();
@@ -2729,11 +2726,13 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
Event event = getSegments (items [index]);
segments = event != null ? event.segments : null;
if (event.segmentsChars != null) {
+ int auto = state & HAS_AUTO_DIRECTION;
if (event.segmentsChars[0] == RLE) {
super.updateTextDirection(SWT.RIGHT_TO_LEFT);
} else if (event.segmentsChars[0] == LRE) {
super.updateTextDirection(SWT.LEFT_TO_RIGHT);
}
+ state |= auto;
}
return code;
}
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 28d08b9d99..8384d1206c 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
@@ -2829,6 +2829,14 @@ public void removeTraverseListener(TraverseListener listener) {
eventTable.unhook (SWT.Traverse, listener);
}
+int resolveTextDirection() {
+ /*
+ * For generic Controls do nothing here. Text-enabled Controls will resolve
+ * AUTO text direction according to their text content.
+ */
+ return SWT.NONE;
+}
+
void showWidget (boolean visible) {
long /*int*/ topHandle = topHandle ();
OS.ShowWindow (topHandle, visible ? OS.SW_SHOW : OS.SW_HIDE);
@@ -4531,7 +4539,13 @@ void updateOrientation () {
}
boolean updateTextDirection (int textDirection) {
- if (textDirection == 0 || textDirection == AUTO_TEXT_DIRECTION) return false;
+ if (textDirection == AUTO_TEXT_DIRECTION) {
+ textDirection = resolveTextDirection();
+ state |= HAS_AUTO_DIRECTION;
+ } else {
+ state &= ~HAS_AUTO_DIRECTION;
+ }
+ if (textDirection == 0) return false;
int bits = OS.GetWindowLong (handle, OS.GWL_EXSTYLE);
/*
* OS.WS_EX_RTLREADING means that the text direction is opposite to the
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 3c3321eb9e..5be415c4cc 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
@@ -363,6 +363,10 @@ void releaseWidget () {
text = null;
}
+int resolveTextDirection () {
+ return resolveTextDirection (text);
+}
+
public void setFont (Font font) {
checkWidget ();
Rectangle oldRect = getClientArea ();
@@ -410,10 +414,6 @@ public void setText (String string) {
}
boolean updateTextDirection(int textDirection) {
- if (textDirection == AUTO_TEXT_DIRECTION) {
- /* resolveTextDirection is called before fixText intentionally */
- textDirection = resolveTextDirection (text);
- }
if (super.updateTextDirection(textDirection)) {
String string = fixText (OS.IsWindowEnabled (handle));
TCHAR buffer = new TCHAR (getCodePage (), string == null ? text : string, true);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
index a0db09c90a..5bf95c6dc1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
@@ -291,6 +291,10 @@ void releaseWidget () {
image = null;
}
+int resolveTextDirection() {
+ return (style & SWT.SEPARATOR) != 0 ? SWT.NONE : resolveTextDirection(text);
+}
+
/**
* Controls how text and images will be displayed in the receiver.
* The argument should be one of <code>LEFT</code>, <code>RIGHT</code>
@@ -431,14 +435,6 @@ public void setText (String string) {
}
}
-@Override
-boolean updateTextDirection(int textDirection) {
- if (textDirection == AUTO_TEXT_DIRECTION) {
- textDirection = (style & SWT.SEPARATOR) != 0 ? SWT.NONE : resolveTextDirection(text);
- }
- return super.updateTextDirection(textDirection);
-}
-
int widgetExtStyle () {
int bits = super.widgetExtStyle () & ~OS.WS_EX_CLIENTEDGE;
if ((style & SWT.BORDER) != 0) return bits | OS.WS_EX_STATICEDGE;
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 3f119ca1f8..53ad648e62 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
@@ -742,10 +742,11 @@ public void setText (String string) {
}
}
+int resolveTextDirection() {
+ return resolveTextDirection(text);
+}
+
boolean updateTextDirection(int textDirection) {
- if (textDirection == AUTO_TEXT_DIRECTION) {
- textDirection = resolveTextDirection(text);
- }
if (super.updateTextDirection(textDirection)) {
int flags = SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT;
style &= ~SWT.MIRRORED;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java
index 7d553a3a55..cb58bf4839 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java
@@ -1555,7 +1555,6 @@ void updateMenuLocation (Event event) {
event.y = pt.y;
}
-@Override
boolean updateTextDirection (int textDirection) {
if (textDirection == AUTO_TEXT_DIRECTION) {
/*
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
index 02c323a841..fe8f50344d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
@@ -461,7 +461,7 @@ public void append (String string) {
ignoreCharacter = false;
OS.SendMessage (handle, OS.EM_SCROLLCARET, 0, 0);
if ((state & HAS_AUTO_DIRECTION) != 0) {
- updateTextDirection (AUTO_TEXT_DIRECTION);
+ super.updateTextDirection (AUTO_TEXT_DIRECTION);
}
applySegments ();
}
@@ -1559,7 +1559,7 @@ public void insert (String string) {
OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer);
ignoreCharacter = false;
if ((state & HAS_AUTO_DIRECTION) != 0) {
- updateTextDirection (AUTO_TEXT_DIRECTION);
+ super.updateTextDirection (AUTO_TEXT_DIRECTION);
}
applySegments ();
}
@@ -1728,6 +1728,28 @@ public void removeVerifyListener (VerifyListener listener) {
eventTable.unhook (SWT.Verify, listener);
}
+int resolveTextDirection() {
+ int textDirection = SWT.NONE;
+ int length = OS.GetWindowTextLength (handle);
+ if (length > 0) {
+ TCHAR buffer = new TCHAR (getCodePage (), length + 1);
+ OS.GetWindowText (handle, buffer, length + 1);
+ if (segments != null) {
+ buffer = deprocessText (buffer, 0, -1, false);
+ textDirection = resolveTextDirection(buffer.toString ());
+ } else {
+ textDirection = resolveTextDirection(buffer.toString (0, length));
+ }
+ if (textDirection == SWT.NONE) {
+ /*
+ * Force direction update also when there are no strong bidi chars.
+ */
+ textDirection = (style & SWT.RIGHT_TO_LEFT) != 0 ? SWT.RIGHT_TO_LEFT : SWT.LEFT_TO_RIGHT;
+ }
+ }
+ return textDirection;
+}
+
/**
* Selects all the text in the receiver.
*
@@ -2273,7 +2295,7 @@ public void setText (String string) {
TCHAR buffer = new TCHAR (getCodePage (), string, true);
OS.SetWindowText (handle, buffer);
if ((state & HAS_AUTO_DIRECTION) != 0) {
- updateTextDirection(AUTO_TEXT_DIRECTION);
+ super.updateTextDirection(AUTO_TEXT_DIRECTION);
}
applySegments ();
/*
@@ -2338,7 +2360,7 @@ public void setTextChars (char[] text) {
OS.SetWindowText (handle, buffer);
buffer.clear ();
if ((state & HAS_AUTO_DIRECTION) != 0) {
- updateTextDirection (AUTO_TEXT_DIRECTION);
+ super.updateTextDirection (AUTO_TEXT_DIRECTION);
}
applySegments ();
/*
@@ -2461,31 +2483,7 @@ void updateOrientation (){
fixAlignment ();
}
-@Override
boolean updateTextDirection(int textDirection) {
- if (textDirection == AUTO_TEXT_DIRECTION) {
- int length = OS.GetWindowTextLength (handle);
- if (length > 0) {
- TCHAR buffer = new TCHAR (getCodePage (), length + 1);
- OS.GetWindowText (handle, buffer, length + 1);
- if (segments != null) {
- buffer = deprocessText (buffer, 0, -1, false);
- textDirection = resolveTextDirection(buffer.toString ());
- } else {
- textDirection = resolveTextDirection(buffer.toString (0, length));
- }
- if (textDirection == SWT.NONE) {
- /*
- * Force direction update also when no strong bidi chars are
- * found.
- */
- textDirection = (style & SWT.RIGHT_TO_LEFT) != 0 ? SWT.RIGHT_TO_LEFT : SWT.LEFT_TO_RIGHT;
- }
- }
- state |= HAS_AUTO_DIRECTION;
- } else {
- state &= ~HAS_AUTO_DIRECTION;
- }
if (super.updateTextDirection(textDirection)) {
clearSegments (true);
applySegments ();
@@ -2672,7 +2670,7 @@ long /*int*/ windowProc (long /*int*/ hwnd, int msg, long /*int*/ wParam, long /
}
code = super.windowProc (hwnd, msg, wParam, lParam);
if (updateDirection) {
- updateTextDirection (AUTO_TEXT_DIRECTION);
+ super.updateTextDirection (AUTO_TEXT_DIRECTION);
}
if (processSegments) {
applySegments ();

Back to the top