Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThorsten Hake2015-11-18 13:27:29 +0000
committerNiraj Modi2017-08-09 09:35:37 +0000
commita3ffb152c005b14af78dbeb2418309d647a196ba (patch)
tree575571f6639c93ab315ed00e02fbee778f556cf6
parent397db9e1dca6e0a853777d316b8756845ddcfd78 (diff)
downloadeclipse.platform.swt-a3ffb152c005b14af78dbeb2418309d647a196ba.tar.gz
eclipse.platform.swt-a3ffb152c005b14af78dbeb2418309d647a196ba.tar.xz
eclipse.platform.swt-a3ffb152c005b14af78dbeb2418309d647a196ba.zip
Bug 298679 - [StyledText] Fixed left margin if alignment is set.
Change-Id: I7144cc95c1f0940e791526c3bb3c4326fe9e007c Signed-off-by: Thorsten Hake <eclipse@thorsten-hake.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java8
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java14
2 files changed, 17 insertions, 5 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
index 7f6cbe3669..413fca4417 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
@@ -8582,7 +8582,7 @@ public void setBidiColoring(boolean mode) {
*/
public void setBottomMargin (int bottomMargin) {
checkWidget();
- setMargins(leftMargin, topMargin, rightMargin, bottomMargin);
+ setMargins(getLeftMargin(), topMargin, rightMargin, bottomMargin);
}
/**
* Moves the Caret to the current caret offset.
@@ -9452,7 +9452,7 @@ public void setMarginColor(Color color) {
*/
public void setMargins (int leftMargin, int topMargin, int rightMargin, int bottomMargin) {
checkWidget();
- this.leftMargin = Math.max(0, leftMargin);
+ this.leftMargin = Math.max(0, leftMargin) + alignmentMargin;
this.topMargin = Math.max(0, topMargin);
this.rightMargin = Math.max(0, rightMargin);
this.bottomMargin = Math.max(0, bottomMargin);
@@ -9509,7 +9509,7 @@ public void setOrientation(int orientation) {
*/
public void setRightMargin (int rightMargin) {
checkWidget();
- setMargins(leftMargin, topMargin, rightMargin, bottomMargin);
+ setMargins(getLeftMargin(), topMargin, rightMargin, bottomMargin);
}
void setScrollBar(ScrollBar bar, int clientArea, int maximum, int margin) {
int inactive = 1;
@@ -10241,7 +10241,7 @@ public void setTopIndex(int topIndex) {
*/
public void setTopMargin (int topMargin) {
checkWidget();
- setMargins(leftMargin, topMargin, rightMargin, bottomMargin);
+ setMargins(getLeftMargin(), topMargin, rightMargin, bottomMargin);
}
/**
* Sets the top pixel offset. Do nothing if there is no text set.
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java
index 4ee7edfdf9..285b4140ef 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java
@@ -611,7 +611,19 @@ public void test_computeSizeAlignment(){
assertEquals(beforeAlignment, afterAlignment);
singleText.dispose();
}
-
+@Test
+public void test_marginsCorrect(){
+ shell.setLayout(new GridLayout());
+ StyledText singleText = new StyledText(shell, SWT.SINGLE);
+ int leftMargin = 10;
+ singleText.setLeftMargin(leftMargin);
+ shell.layout(true);
+ singleText.setAlignment(SWT.RIGHT);
+ assertEquals(leftMargin, singleText.getLeftMargin());
+ singleText.setLeftMargin(leftMargin);
+ assertEquals(leftMargin, singleText.getLeftMargin());
+ singleText.dispose();
+}
@Test
public void test_copy() {
if (SwtTestUtil.isCocoa) {

Back to the top