summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse
diff options
context:
space:
mode:
authorKevin Barnes <krbarnes>2009-03-02 20:39:42 +0000
committerKevin Barnes <krbarnes>2009-03-02 20:39:42 +0000
commit452714f24f515b00ab76d9bacdce42e894494e93 (patch)
treed1392a45d7bc8914aa4752d3e5cfdfe5bb9618e9 /bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse
parent5178249fdd1fca0f70d91159c2c3d6a155fa3d86 (diff)
downloadeclipse.platform.swt-452714f24f515b00ab76d9bacdce42e894494e93.tar.gz
eclipse.platform.swt-452714f24f515b00ab76d9bacdce42e894494e93.tar.xz
eclipse.platform.swt-452714f24f515b00ab76d9bacdce42e894494e93.zip
266475 - Control#setBackgroundImage() does not work
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse')
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Button.java13
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java17
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java8
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/DateTime.java14
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Label.java9
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Link.java25
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/List.java16
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Spinner.java13
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java16
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Text.java13
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java14
11 files changed, 94 insertions, 64 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Button.java
index 74c761489b..16584048b6 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Button.java
@@ -640,12 +640,15 @@ void _setAlignment (int alignment) {
// }
}
-void setBackground (float /*double*/ [] color) {
- NSColor nsColor;
- if (color == null) {
- return; // TODO set to OS default
- } else {
+void updateBackground () {
+ NSColor nsColor = null;
+ if (backgroundImage != null) {
+ nsColor = NSColor.colorWithPatternImage(backgroundImage.handle);
+ } else if (background != null) {
+ float /*double*/ [] color = background.handle;
nsColor = NSColor.colorWithDeviceRed(color[0], color[1], color[2], 1);
+ } else {
+ return; // TODO set to OS default
}
NSButtonCell cell = new NSButtonCell(((NSButton)view).cell());
cell.setBackgroundColor(nsColor);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java
index c87ac7b93e..1bf65e264f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java
@@ -1266,18 +1266,17 @@ boolean sendKeyEvent (NSEvent nsEvent, int type) {
return result;
}
-void setBackground (float /*double*/ [] color) {
- NSColor nsColor;
- if (color == null) {
- nsColor = NSColor.textBackgroundColor ();
- } else {
+void updateBackground () {
+ NSColor nsColor = null;
+ if (backgroundImage != null) {
+ nsColor = NSColor.colorWithPatternImage(backgroundImage.handle);
+ } else if (background != null) {
+ float /*double*/ [] color = background.handle;
nsColor = NSColor.colorWithDeviceRed(color[0], color[1], color[2], 1);
- }
- if ((style & SWT.READ_ONLY) != 0) {
- //TODO
} else {
- ((NSTextField)view).setBackgroundColor(nsColor);
+ nsColor = NSColor.textBackgroundColor ();
}
+ ((NSTextField)view).setBackgroundColor(nsColor);
}
void setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java
index e8ec51aa73..4103a232a5 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java
@@ -2864,7 +2864,7 @@ public void setBackground (Color color) {
}
// if (equals (background, this.background)) return;
this.background = color;
- setBackground (color != null ? color.handle : null);
+ updateBackground ();
view.setNeedsDisplay(true);
}
@@ -2895,10 +2895,14 @@ public void setBackgroundImage (Image image) {
if (image != null && image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
if (image == backgroundImage) return;
backgroundImage = image;
+ updateBackground();
redrawWidget(view, false);
}
-void setBackground (float /*double*/ [] color) {
+void updateBackground () {
+}
+
+void setBackground (NSColor nsColor) {
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/DateTime.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/DateTime.java
index 26d64a7260..d1dd5eae50 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/DateTime.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/DateTime.java
@@ -326,16 +326,20 @@ void sendSelection () {
postEvent (SWT.Selection);
}
-void setBackground (float /*double*/ [] color) {
- NSColor nsColor;
- if (color == null) {
+void updateBackground () {
+ NSColor nsColor = null;
+ if (backgroundImage != null) {
+ nsColor = NSColor.colorWithPatternImage(backgroundImage.handle);
+ } else if (background != null) {
+ float /*double*/ [] color = background.handle;
+ nsColor = NSColor.colorWithDeviceRed(color[0], color[1], color[2], 1);
+ } else {
if ((style & SWT.CALENDAR) != 0) {
nsColor = NSColor.controlBackgroundColor ();
} else {
nsColor = NSColor.textBackgroundColor ();
}
- } else {
- nsColor = NSColor.colorWithDeviceRed(color[0], color[1], color[2], 1);
+
}
((NSDatePicker)view).setBackgroundColor(nsColor);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Label.java
index 12929a35c0..dd57913204 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Label.java
@@ -416,16 +416,17 @@ public void setAlignment (int alignment) {
_setAlignment();
}
-void setBackground (float /*double*/ [] color) {
+void updateBackground () {
if ((style & SWT.SEPARATOR) != 0) return;
NSColor nsColor = null;
-
- if (color != null) {
+ if (backgroundImage != null) {
+ nsColor = NSColor.colorWithPatternImage(backgroundImage.handle);
+ } else if (background != null) {
+ float /*double*/ [] color = background.handle;
nsColor = NSColor.colorWithDeviceRed(color[0], color[1], color[2], 1);
} else {
nsColor = NSColor.clearColor();
}
-
((NSBox)view).setFillColor(nsColor);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Link.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Link.java
index 2ed9dd1d3d..2c1e1e4a5c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Link.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Link.java
@@ -412,14 +412,25 @@ int parseMnemonics (char[] buffer, int start, int end, StringBuffer result) {
return mnemonic;
}
-void setBackground (float /*double*/ [] color) {
- NSColor nsColor;
- NSTextView widget = (NSTextView)view;
- if (color == null) {
- widget.setDrawsBackground (false);
+void updateBackground () {
+ NSColor nsColor = null;
+ if (backgroundImage != null) {
+ nsColor = NSColor.colorWithPatternImage(backgroundImage.handle);
+ } else if (background != null) {
+ float /*double*/ [] color = background.handle;
+ nsColor = NSColor.colorWithDeviceRed(color[0], color[1], color[2], 1);
} else {
- widget.setDrawsBackground (true);
- nsColor = NSColor.colorWithDeviceRed (color [0], color [1], color [2], 1);
+ nsColor = NSColor.clearColor();
+ }
+ setBackground(nsColor);
+}
+
+void setBackground(NSColor nsColor) {
+ NSTextView widget = (NSTextView)view;
+ if (nsColor == null) {
+ widget.setDrawsBackground(false);
+ } else {
+ widget.setDrawsBackground(true);
widget.setBackgroundColor (nsColor);
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/List.java
index 705c8367d9..d9ba2c654d 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/List.java
@@ -1061,14 +1061,14 @@ boolean sendKeyEvent (NSEvent nsEvent, int type) {
return result;
}
-void setBackground (float /*double*/ [] color) {
- super.setBackground (color);
- NSColor nsColor;
- if (color == null) {
- nsColor = null;
- } else {
- nsColor = NSColor.colorWithDeviceRed (color [0], color [1], color [2], 1);
- }
+void updateBackground () {
+ NSColor nsColor = null;
+ if (backgroundImage != null) {
+ nsColor = NSColor.colorWithPatternImage(backgroundImage.handle);
+ } else if (background != null) {
+ float /*double*/ [] color = background.handle;
+ nsColor = NSColor.colorWithDeviceRed(color[0], color[1], color[2], 1);
+ }
((NSTableView) view).setBackgroundColor (nsColor);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Spinner.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Spinner.java
index 108b0f7dbb..a548c28b57 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Spinner.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Spinner.java
@@ -682,12 +682,15 @@ void sendSelection () {
setSelection (getSelection(), false, true, true);
}
-void setBackground (float /*double*/ [] color) {
- NSColor nsColor;
- if (color == null) {
- nsColor = NSColor.textBackgroundColor ();
+void updateBackground () {
+ NSColor nsColor = null;
+ if (backgroundImage != null) {
+ nsColor = NSColor.colorWithPatternImage(backgroundImage.handle);
+ } else if (background != null) {
+ float /*double*/ [] color = background.handle;
+ nsColor = NSColor.colorWithDeviceRed(color[0], color[1], color[2], 1);
} else {
- nsColor = NSColor.colorWithDeviceRed (color [0], color [1], color [2], 1);
+ nsColor = NSColor.textBackgroundColor ();
}
((NSTextField) textView).setBackgroundColor (nsColor);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java
index afc6c103e3..9dab20f9f9 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java
@@ -2030,14 +2030,14 @@ public void selectAll () {
ignoreSelect = false;
}
-void setBackground (float /*double*/ [] color) {
- super.setBackground (color);
- NSColor nsColor;
- if (color == null) {
- nsColor = null;
- } else {
- nsColor = NSColor.colorWithDeviceRed (color [0], color [1], color [2], 1);
- }
+void updateBackground () {
+ NSColor nsColor = null;
+ if (backgroundImage != null) {
+ nsColor = NSColor.colorWithPatternImage(backgroundImage.handle);
+ } else if (background != null) {
+ float /*double*/ [] color = background.handle;
+ nsColor = NSColor.colorWithDeviceRed(color[0], color[1], color[2], 1);
+ }
((NSTableView) view).setBackgroundColor (nsColor);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Text.java
index 6692f4fbe3..441d42bfff 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Text.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Text.java
@@ -1357,12 +1357,15 @@ void sendCancelSelection () {
postEvent (SWT.DefaultSelection, event);
}
-void setBackground (float /*double*/ [] color) {
- NSColor nsColor;
- if (color == null) {
- nsColor = NSColor.textBackgroundColor ();
+void updateBackground () {
+ NSColor nsColor = null;
+ if (backgroundImage != null) {
+ nsColor = NSColor.colorWithPatternImage(backgroundImage.handle);
+ } else if (background != null) {
+ float /*double*/ [] color = background.handle;
+ nsColor = NSColor.colorWithDeviceRed(color[0], color[1], color[2], 1);
} else {
- nsColor = NSColor.colorWithDeviceRed (color [0], color [1], color [2], 1);
+ nsColor = NSColor.textBackgroundColor ();
}
if ((style & SWT.SINGLE) != 0) {
((NSTextField) view).setBackgroundColor (nsColor);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java
index 14cd987657..6e74bf9ad9 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java
@@ -2089,13 +2089,15 @@ void selectItems (TreeItem[] items, boolean ignoreDisposed) {
ignoreSelect = false;
}
-void setBackground (float /*double*/ [] color) {
- super.setBackground (color);
- NSColor nsColor;
- if (color == null) {
- nsColor = null;
+void updateBackground () {
+ NSColor nsColor = null;
+ if (backgroundImage != null) {
+ nsColor = NSColor.colorWithPatternImage(backgroundImage.handle);
+ } else if (background != null) {
+ float /*double*/ [] color = background.handle;
+ nsColor = NSColor.colorWithDeviceRed(color[0], color[1], color[2], 1);
} else {
- nsColor = NSColor.colorWithDeviceRed (color [0], color [1], color [2], 1);
+ nsColor = null;
}
((NSOutlineView) view).setBackgroundColor (nsColor);
}