Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLina Kemmel2016-01-21 14:11:29 +0000
committerLina Kemmel2016-01-24 12:37:40 +0000
commitbe1032bd2490a6698295b836e076fe7e9ff90552 (patch)
tree85af4fbf0f36b7895c94389c85c77263a1e5efcd /examples
parent431d7aa5b700733697692dc5dfa5e334e05eeec3 (diff)
downloadeclipse.platform.swt-be1032bd2490a6698295b836e076fe7e9ff90552.tar.gz
eclipse.platform.swt-be1032bd2490a6698295b836e076fe7e9ff90552.tar.xz
eclipse.platform.swt-be1032bd2490a6698295b836e076fe7e9ff90552.zip
Bug 473850 - [BiDi] Add text direction test toI20160124-2000
org.eclipse.swt.examples.controlexample.CustomControlExample Change-Id: I5a7c045abc1d651c95c1455a6574d23d81ab7dd6
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.swt.examples/src/examples_control.properties3
-rw-r--r--examples/org.eclipse.swt.examples/src/examples_control_iw.properties63
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/Tab.java64
3 files changed, 128 insertions, 2 deletions
diff --git a/examples/org.eclipse.swt.examples/src/examples_control.properties b/examples/org.eclipse.swt.examples/src/examples_control.properties
index de294f3745..f97f435739 100644
--- a/examples/org.eclipse.swt.examples/src/examples_control.properties
+++ b/examples/org.eclipse.swt.examples/src/examples_control.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2007 IBM Corporation and others.
+# Copyright (c) 2000, 2016 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@@ -238,6 +238,7 @@ MenuItem_Copy = &Copy Ctrl+C
MenuItem_Paste = &Paste Ctrl+V
MenuItem_SelectAll = Select &All Ctrl+A
Orientation = Orientation
+Text_Direction = Text Direction
Default = Default (Inherit)
Images = Images
Accelerators = Accelerators
diff --git a/examples/org.eclipse.swt.examples/src/examples_control_iw.properties b/examples/org.eclipse.swt.examples/src/examples_control_iw.properties
new file mode 100644
index 0000000000..132cd39582
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/src/examples_control_iw.properties
@@ -0,0 +1,63 @@
+###############################################################################
+# Copyright (c) 2000, 2016 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+Two = \u05e9\u05Ea\u05d9\u05d9\u05dd Two...
+Three = Three...
+One_Two_Three = \u05d0\u05d7\u05d3 One Two Three...
+Multi_line = \u05d4\u05d9!!! A multi line text widget...
+Example_string = \u05d4\u05d9!!! The quick brown fox jumps over the lazy dog.
+Node_1 = \u05d0\u05d7\u05d3 Node 1...
+Node_2 = Node 2...
+Node_3 = Node 3...
+Node_4 = Node 4...
+Node_1_1 = Node 1.1...
+Node_2_1 = \u05e6\u05d5\u05de\u05ea Node 2.1...
+Node_3_1 = Node 3.1...
+Node_2_2 = Node 2.2...
+Node_2_2_1 = Node 2.2.1...
+TableLine0_3 = \u05d4\u05d9\u05d5\u05dd - today...
+TableLine1_3 = tomorrow...
+ListData0_0 = Line \u05e9\u05d5\u05e8\u05d4 1...
+ListData0_1 = Line 2...
+ListData0_2 = \u05e9\u05d5\u05e8\u05d4 Line 3...
+ListData0_3 = Line 4...
+ListData0_4 = Line 5...
+ListData0_5 = Line 6...
+ListData0_6 = Line 7...
+ListData0_7 = Line 8...
+ListData0_8 = Longest Line In List...
+ListData1_0 = \u05ea\u05e4\u05d5\u05d7\u05d9\u05dd Apples!!!
+ListData1_1 = Oranges \u05ea\u05e4\u05d5\u05d6\u05d9\u05dd!!!
+ListData1_2 = Bananas...
+ListData1_3 = Grapefruit...
+ListData1_4 = Peaches...
+ListData1_5 = Kiwi...
+ListData1_6 = Apricots...
+ListData1_7 = Strawberries...
+ListData1_8 = The Longest String...
+DropDownData_0 = \u05ea\u05e4\u05d5\u05d7\u05d9\u05dd Apples!!!
+DropDownData_1 = Oranges \u05ea\u05e4\u05d5\u05d6\u05d9\u05dd!!!
+DropDownData_3 = Grapefruit...
+DropDownData_4 = Peaches...
+DropDownData_5 = Kiwi...
+DropDownData_7 = Strawberries...
+DropDownData_8 = The Longest String...
+Wrap_Text = \u05d4\u05d9!!! Jack and Jill went up the hill to fetch a pail of water, \
+ Jack fell down and broke his crown and Jill came tumbling after!
+TabItem1_0 = Tab &0...
+TabItem1_1 = \u05dc\u05e9\u05d5\u05e0\u05d9\u05ea - Tab &1...
+TabItem1_2 = Tab &2...
+CTabItem1_0 = CTabItem \u05d0\u05e4\u05e1 &0...
+CTabItem1_1 = \u05d0\u05d7\u05d3 CTabItem &1...
+CTabItem1_2 = \u05e9\u05ea\u05d9\u05d9\u05dd CTabItem &2 has a long name...
+LinkText =\u05d4\u05d9!!! Visit the <A HREF=\"www.eclipse.org\">Eclipse.org</A> project and the <A HREF=\"www.eclipse.org\\swt">SWT</A> homepage.
+Item1_Text = \u05db\u05e4\u05ea\u05d5\u05e8 - What is your favorite button?
+Item2_Text = What is your favorite icon - \u05e1\u05de\u05dc?
+ToolTip_Title = \u05e9' vs. \u05db' - Foxes vs. Dogs !!!
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/Tab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/Tab.java
index db83f4d57f..9bbcc92f70 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/Tab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/Tab.java
@@ -108,6 +108,8 @@ abstract class Tab {
static final boolean RTL_SUPPORT_ENABLE = "win32".equals(SWT.getPlatform()) || "gtk".equals(SWT.getPlatform());
Group orientationGroup;
Button rtlButton, ltrButton, defaultOrietationButton;
+ Group directionGroup;
+ Button rtlDirectionButton, ltrDirectionButton, autoDirectionButton, defaultDirectionButton;
/* Controls and resources for the "Colors & Fonts" group */
static final int IMAGE_SIZE = 12;
@@ -295,6 +297,7 @@ abstract class Tab {
createColorAndFontGroup ();
if (rtlSupport()) {
createOrientationGroup ();
+ createDirectionGroup ();
}
createBackgroundModeGroup ();
@@ -315,7 +318,16 @@ abstract class Tab {
if ((event.widget.getStyle () & SWT.RADIO) != 0) {
if (!((Button) event.widget).getSelection ()) return;
}
- recreateExampleWidgets ();
+ if (!handleTextDirection (event.widget)) {
+ recreateExampleWidgets ();
+ if (rtlSupport ()) {
+ /* Reflect the base direction falls back to the default (i.e. orientation). */
+ ltrDirectionButton.setSelection (false);
+ rtlDirectionButton.setSelection (false);
+ autoDirectionButton.setSelection (false);
+ defaultDirectionButton.setSelection (true);
+ }
+ }
}
};
Control [] children = styleGroup.getChildren ();
@@ -341,6 +353,10 @@ abstract class Tab {
rtlButton.addSelectionListener (selectionListener);
ltrButton.addSelectionListener (selectionListener);
defaultOrietationButton.addSelectionListener (selectionListener);
+ rtlDirectionButton.addSelectionListener (selectionListener);
+ ltrDirectionButton.addSelectionListener (selectionListener);
+ autoDirectionButton.addSelectionListener (selectionListener);
+ defaultDirectionButton.addSelectionListener (selectionListener);
}
}
@@ -1265,6 +1281,23 @@ abstract class Tab {
rtlButton.setText ("SWT.RIGHT_TO_LEFT");
}
+ void createDirectionGroup () {
+ /* Create Text Direction group*/
+ directionGroup = new Group (controlGroup, SWT.NONE);
+ directionGroup.setLayout (new GridLayout());
+ directionGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, false, false));
+ directionGroup.setText (ControlExample.getResourceString("Text_Direction"));
+ defaultDirectionButton = new Button (directionGroup, SWT.RADIO);
+ defaultDirectionButton.setText (ControlExample.getResourceString("Default"));
+ defaultDirectionButton.setSelection (true);
+ ltrDirectionButton = new Button (directionGroup, SWT.RADIO);
+ ltrDirectionButton.setText ("SWT.LEFT_TO_RIGHT");
+ rtlDirectionButton = new Button (directionGroup, SWT.RADIO);
+ rtlDirectionButton.setText ("SWT.RIGHT_TO_LEFT");
+ autoDirectionButton = new Button (directionGroup, SWT.RADIO);
+ autoDirectionButton.setText ("AUTO direction");
+ }
+
/**
* Creates the "Size" group. The "Size" group contains
* controls that allow the user to change the size of
@@ -1535,6 +1568,35 @@ abstract class Tab {
}
/**
+ * In case one of the buttons that control text direction was selected,
+ * apply the text direction on the controls in the client area.
+ *
+ * @return true if text direction style was applied and false otherwise.
+ */
+ boolean handleTextDirection (Widget widget) {
+ int textDirection = SWT.NONE;
+ if (ltrDirectionButton.equals (widget)) {
+ textDirection = SWT.LEFT_TO_RIGHT;
+ } else if (rtlDirectionButton.equals (widget)) {
+ textDirection = SWT.RIGHT_TO_LEFT;
+ } else if (autoDirectionButton.equals (widget)) {
+ textDirection = SWT.AUTO_TEXT_DIRECTION;
+ } else if (!defaultDirectionButton.equals (widget)) {
+ return false;
+ }
+ Control [] children = getExampleControls ();
+ if (children.length > 0) {
+ if (SWT.NONE == textDirection) {
+ textDirection = children [0].getOrientation ();
+ }
+ for (Control child : children) {
+ child.setTextDirection (textDirection);
+ }
+ }
+ return true;
+ }
+
+ /**
* Hooks all listeners to all example controls
* and example control items.
*/

Back to the top