Skip to content

Commit 3e90179

Browse files
committed
Compute fg and bg colors for setEditable for StyledText
This commit adds the foreground and background color computation for setEditable. Earlier this was handled only for setEnabled. This commit also adds a different foreground and background color for StyledText when background is not editable. Fixes :#3132
1 parent 4b1fc8c commit 3e90179

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8280,7 +8280,7 @@ public void setBackground(Color color) {
82808280
boolean backgroundDisabled = false;
82818281
if (!this.enabled && color == null) {
82828282
if (background != null) {
8283-
Color disabledBg = getDisplay().getSystemColor(SWT.COLOR_TEXT_DISABLED_BACKGROUND);
8283+
Color disabledBg = new Color(COLOR_DISABLED_STATE);
82848284
if (background.equals(disabledBg)) {
82858285
return;
82868286
} else {
@@ -8910,7 +8910,7 @@ public void setForeground(Color color) {
89108910
boolean foregroundDisabled = false;
89118911
if (!this.enabled && color == null) {
89128912
if (foreground != null) {
8913-
Color disabledFg = getDisplay().getSystemColor(SWT.COLOR_WIDGET_DISABLED_FOREGROUND);
8913+
Color disabledFg = getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY);
89148914
if (foreground.equals(disabledFg)) {
89158915
return;
89168916
} else {

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
import org.eclipse.swt.graphics.GC;
6767
import org.eclipse.swt.graphics.GlyphMetrics;
6868
import org.eclipse.swt.graphics.Point;
69+
import org.eclipse.swt.graphics.RGB;
6970
import org.eclipse.swt.graphics.Rectangle;
7071
import org.eclipse.swt.internal.BidiUtil;
7172
import org.eclipse.swt.layout.FillLayout;
@@ -101,6 +102,7 @@ public class Test_org_eclipse_swt_custom_StyledText extends Test_org_eclipse_swt
101102
final static String PLATFORM_LINE_DELIMITER = System.lineSeparator();
102103
private boolean listenerCalled;
103104
private boolean listener2Called;
105+
private static final RGB COLOR_DISABLED_STATE = new RGB(54, 54, 54);
104106

105107
@Override
106108
@BeforeEach
@@ -3245,8 +3247,8 @@ public void test_setDoubleClickEnabledZ(){
32453247
@Test
32463248
public void test_setEnabled(){
32473249
// Get colors
3248-
Color disabledBg = text.getDisplay().getSystemColor(SWT.COLOR_TEXT_DISABLED_BACKGROUND);
3249-
Color disabledFg = text.getDisplay().getSystemColor(SWT.COLOR_WIDGET_DISABLED_FOREGROUND);
3250+
Color disabledBg = new Color(text.getDisplay(), COLOR_DISABLED_STATE);
3251+
Color disabledFg = text.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY);
32503252
Color enabledBg = text.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
32513253
Color enabledFg = text.getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND);
32523254

0 commit comments

Comments
 (0)