Skip to content

Commit 69b7d66

Browse files
vogellaclaude
andcommitted
Use device-free Color constructors instead of deprecated Device-based ones
Replace all internal usages of new Color(device, ...) with the modern display-free equivalents new Color(r, g, b), new Color(rgb), etc. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 1442896 commit 69b7d66

6 files changed

Lines changed: 28 additions & 28 deletions

File tree

  • bundles/org.eclipse.swt

bundles/org.eclipse.swt/Eclipse SWT Accessibility/win32/org/eclipse/swt/accessibility/Accessible.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5099,7 +5099,7 @@ Color colorFromString(String rgbString) {
50995099
int r = Integer.parseInt(rgbString.substring(open + 1, comma1));
51005100
int g = Integer.parseInt(rgbString.substring(comma1 + 1, comma2));
51015101
int b = Integer.parseInt(rgbString.substring(comma2 + 1, close));
5102-
return new Color(control.getDisplay(), r, g, b);
5102+
return new Color(r, g, b);
51035103
} catch (NumberFormatException ex) {}
51045104
return null;
51055105
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* <pre><code>
3232
* Canvas canvas = new Canvas(shell, SWT.BORDER);
3333
* canvas.setBounds(10, 10, 300, 300);
34-
* Color color = new Color(null, 255, 0, 0);
34+
* Color color = new Color(255, 0, 0);
3535
* canvas.setBackground(color);
3636
* ControlEditor editor = new ControlEditor (canvas);
3737
* // The editor will be a button in the bottom right corner of the canvas.
@@ -46,7 +46,7 @@
4646
* RGB rgb = dialog.getRGB();
4747
* if (rgb != null) {
4848
* if (color != null) color.dispose();
49-
* color = new Color(null, rgb);
49+
* color = new Color(rgb);
5050
* canvas.setBackground(color);
5151
* }
5252
*

bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/DragSource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ void drag(Event dragDetectEvent) {
361361
int width = 20, height = 20;
362362
Image newDragImage = new Image(Display.getCurrent(), width, height);
363363
GC imageGC = new GC(newDragImage);
364-
Color grayColor = new Color(Display.getCurrent(), 50, 50, 50);
364+
Color grayColor = new Color(50, 50, 50);
365365
imageGC.setForeground(grayColor);
366366
imageGC.drawRectangle(0, 0, 19, 19);
367367
imageGC.dispose();

bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2266,16 +2266,16 @@ public static final void setTheme(boolean isDarkTheme) {
22662266

22672267
display.setData("org.eclipse.swt.internal.win32.useDarkModeExplorerTheme", isDarkTheme);
22682268
display.setData("org.eclipse.swt.internal.win32.useShellTitleColoring", isDarkTheme);
2269-
display.setData("org.eclipse.swt.internal.win32.menuBarForegroundColor", isDarkTheme ? new Color(display, 0xD0, 0xD0, 0xD0) : null);
2270-
display.setData("org.eclipse.swt.internal.win32.menuBarBackgroundColor", isDarkTheme ? new Color(display, 0x30, 0x30, 0x30) : null);
2271-
display.setData("org.eclipse.swt.internal.win32.menuBarBorderColor", isDarkTheme ? new Color(display, 0x50, 0x50, 0x50) : null);
2269+
display.setData("org.eclipse.swt.internal.win32.menuBarForegroundColor", isDarkTheme ? new Color(0xD0, 0xD0, 0xD0) : null);
2270+
display.setData("org.eclipse.swt.internal.win32.menuBarBackgroundColor", isDarkTheme ? new Color(0x30, 0x30, 0x30) : null);
2271+
display.setData("org.eclipse.swt.internal.win32.menuBarBorderColor", isDarkTheme ? new Color(0x50, 0x50, 0x50) : null);
22722272
display.setData("org.eclipse.swt.internal.win32.Canvas.use_WS_BORDER", isDarkTheme);
22732273
display.setData("org.eclipse.swt.internal.win32.List.use_WS_BORDER", isDarkTheme);
22742274
display.setData("org.eclipse.swt.internal.win32.Table.use_WS_BORDER", isDarkTheme);
22752275
display.setData("org.eclipse.swt.internal.win32.Text.use_WS_BORDER", isDarkTheme);
22762276
display.setData("org.eclipse.swt.internal.win32.Tree.use_WS_BORDER", isDarkTheme);
2277-
display.setData("org.eclipse.swt.internal.win32.Table.headerLineColor", isDarkTheme ? new Color(display, 0x50, 0x50, 0x50) : null);
2278-
display.setData("org.eclipse.swt.internal.win32.Label.disabledForegroundColor", isDarkTheme ? new Color(display, 0x80, 0x80, 0x80) : null);
2277+
display.setData("org.eclipse.swt.internal.win32.Table.headerLineColor", isDarkTheme ? new Color(0x50, 0x50, 0x50) : null);
2278+
display.setData("org.eclipse.swt.internal.win32.Label.disabledForegroundColor", isDarkTheme ? new Color(0x80, 0x80, 0x80) : null);
22792279
display.setData("org.eclipse.swt.internal.win32.Combo.useDarkTheme", isDarkTheme);
22802280
display.setData("org.eclipse.swt.internal.win32.ProgressBar.useColors", isDarkTheme);
22812281
display.setData("org.eclipse.swt.internal.win32.Text.useDarkThemeIcons", isDarkTheme);

bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Device.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -594,23 +594,23 @@ public boolean getWarnings () {
594594
*/
595595
protected void init () {
596596
/* Create the standard colors */
597-
COLOR_TRANSPARENT = new Color (this, 0xFF,0xFF,0xFF,0);
598-
COLOR_BLACK = new Color (this, 0,0,0);
599-
COLOR_DARK_RED = new Color (this, 0x80,0,0);
600-
COLOR_DARK_GREEN = new Color (this, 0,0x80,0);
601-
COLOR_DARK_YELLOW = new Color (this, 0x80,0x80,0);
602-
COLOR_DARK_BLUE = new Color (this, 0,0,0x80);
603-
COLOR_DARK_MAGENTA = new Color (this, 0x80,0,0x80);
604-
COLOR_DARK_CYAN = new Color (this, 0,0x80,0x80);
605-
COLOR_GRAY = new Color (this, 0xC0,0xC0,0xC0);
606-
COLOR_DARK_GRAY = new Color (this, 0x80,0x80,0x80);
607-
COLOR_RED = new Color (this, 0xFF,0,0);
608-
COLOR_GREEN = new Color (this, 0,0xFF,0);
609-
COLOR_YELLOW = new Color (this, 0xFF,0xFF,0);
610-
COLOR_BLUE = new Color (this, 0,0,0xFF);
611-
COLOR_MAGENTA = new Color (this, 0xFF,0,0xFF);
612-
COLOR_CYAN = new Color (this, 0,0xFF,0xFF);
613-
COLOR_WHITE = new Color (this, 0xFF,0xFF,0xFF);
597+
COLOR_TRANSPARENT = new Color (0xFF,0xFF,0xFF,0);
598+
COLOR_BLACK = new Color (0,0,0);
599+
COLOR_DARK_RED = new Color (0x80,0,0);
600+
COLOR_DARK_GREEN = new Color (0,0x80,0);
601+
COLOR_DARK_YELLOW = new Color (0x80,0x80,0);
602+
COLOR_DARK_BLUE = new Color (0,0,0x80);
603+
COLOR_DARK_MAGENTA = new Color (0x80,0,0x80);
604+
COLOR_DARK_CYAN = new Color (0,0x80,0x80);
605+
COLOR_GRAY = new Color (0xC0,0xC0,0xC0);
606+
COLOR_DARK_GRAY = new Color (0x80,0x80,0x80);
607+
COLOR_RED = new Color (0xFF,0,0);
608+
COLOR_GREEN = new Color (0,0xFF,0);
609+
COLOR_YELLOW = new Color (0xFF,0xFF,0);
610+
COLOR_BLUE = new Color (0,0,0xFF);
611+
COLOR_MAGENTA = new Color (0xFF,0,0xFF);
612+
COLOR_CYAN = new Color (0,0xFF,0xFF);
613+
COLOR_WHITE = new Color (0xFF,0xFF,0xFF);
614614

615615
paragraphStyle = (NSMutableParagraphStyle)new NSMutableParagraphStyle().alloc().init();
616616
paragraphStyle.setAlignment(OS.NSTextAlignmentLeft);

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4858,7 +4858,7 @@ private class SetBackgroundOperation extends ReplaceableOperation {
48584858

48594859
SetBackgroundOperation(Color color) {
48604860
RGB rgb = color.getRGB();
4861-
this.color = new Color(color.getDevice(), rgb);
4861+
this.color = new Color(rgb);
48624862
registerForDisposal(this.color);
48634863
}
48644864

@@ -5207,7 +5207,7 @@ private class SetForegroundOperation extends ReplaceableOperation {
52075207

52085208
SetForegroundOperation(Color color) {
52095209
RGB rgb = color.getRGB();
5210-
this.color = new Color(color.getDevice(), rgb);
5210+
this.color = new Color(rgb);
52115211
registerForDisposal(this.color);
52125212
}
52135213

0 commit comments

Comments
 (0)