Skip to content

Commit d727af9

Browse files
committed
[Cocoa] Replace deprecated macOS Button Type and Bezel Style constants
Replaces deprecated NSButtonCell.h constants (deprecated since macOS 10.14) with their modern equivalents as tracked in issue #3214: Button Types: NSMomentaryLightButton -> NSButtonTypeMomentaryLight NSPushOnPushOffButton -> NSButtonTypePushOnPushOff NSRadioButton -> NSButtonTypeRadio NSSwitchButton -> NSButtonTypeSwitch Bezel Styles: NSRoundedBezelStyle -> NSBezelStylePush NSRegularSquareBezelStyle -> NSBezelStyleFlexiblePush NSShadowlessSquareBezelStyle -> NSBezelStyleSmallSquare NSRoundedDisclosureBezelStyle -> NSBezelStylePushDisclosure Updated OS.java constant declarations, AppKitFull.bridgesupport(.extras), and all call sites in Button, DateTime, Table, and Tree widgets.
1 parent ee1713a commit d727af9

File tree

7 files changed

+41
-33
lines changed

7 files changed

+41
-33
lines changed

bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,6 +1309,10 @@
13091309
<enum name='NSBelowTop' value='3'/>
13101310
<enum name='NSBevelLineJoinStyle' value='2'/>
13111311
<enum name='NSBezelBorder' value='2'/>
1312+
<enum name='NSBezelStyleFlexiblePush' value='2'/>
1313+
<enum name='NSBezelStylePush' value='1'/>
1314+
<enum name='NSBezelStylePushDisclosure' value='14'/>
1315+
<enum name='NSBezelStyleSmallSquare' value='6'/>
13121316
<enum name='NSBlueControlTint' value='1'/>
13131317
<enum name='NSBoldFontMask' value='2'/>
13141318
<enum name='NSBorderlessWindowMask' value='0'/>
@@ -1325,6 +1329,10 @@
13251329
<enum name='NSBrowserNoColumnResizing' value='0'/>
13261330
<enum name='NSBrowserUserColumnResizing' value='2'/>
13271331
<enum name='NSButtLineCapStyle' value='0'/>
1332+
<enum name='NSButtonTypeMomentaryLight' value='0'/>
1333+
<enum name='NSButtonTypePushOnPushOff' value='1'/>
1334+
<enum name='NSButtonTypeRadio' value='4'/>
1335+
<enum name='NSButtonTypeSwitch' value='3'/>
13281336
<enum name='NSCMYKColorSpaceModel' value='2'/>
13291337
<enum name='NSCMYKModeColorPanel' value='2'/>
13301338
<enum name='NSCancelButton' value='0'/>

bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4372,12 +4372,20 @@
43724372
<enum name="NSBackspaceCharacter" swt_gen="true"></enum>
43734373
<enum name="NSBevelLineJoinStyle" swt_gen="true"></enum>
43744374
<enum name="NSBezelBorder" swt_gen="true"></enum>
4375+
<enum name="NSBezelStyleFlexiblePush" swt_gen="true"></enum>
4376+
<enum name="NSBezelStylePush" swt_gen="true"></enum>
4377+
<enum name="NSBezelStylePushDisclosure" swt_gen="true"></enum>
4378+
<enum name="NSBezelStyleSmallSquare" swt_gen="true"></enum>
43754379
<enum name="NSBoldFontMask" swt_gen="true"></enum>
43764380
<enum name="NSBorderlessWindowMask" swt_gen="true"></enum>
43774381
<enum name="NSBottomTabsBezelBorder" swt_gen="true"></enum>
43784382
<enum name="NSBoxCustom" swt_gen="true"></enum>
43794383
<enum name="NSBoxSeparator" swt_gen="true"></enum>
43804384
<enum name="NSButtLineCapStyle" swt_gen="true"></enum>
4385+
<enum name="NSButtonTypeMomentaryLight" swt_gen="true"></enum>
4386+
<enum name="NSButtonTypePushOnPushOff" swt_gen="true"></enum>
4387+
<enum name="NSButtonTypeRadio" swt_gen="true"></enum>
4388+
<enum name="NSButtonTypeSwitch" swt_gen="true"></enum>
43814389
<enum name="NSCancelButton" swt_gen="true"></enum>
43824390
<enum name="NSCarriageReturnCharacter" swt_gen="true"></enum>
43834391
<enum name="NSClockAndCalendarDatePickerStyle" swt_gen="true"></enum>
@@ -4454,7 +4462,6 @@
44544462
<enum name="NSMiniaturizableWindowMask" swt_gen="true"></enum>
44554463
<enum name="NSMiterLineJoinStyle" swt_gen="true"></enum>
44564464
<enum name="NSMixedState" swt_gen="true"></enum>
4457-
<enum name="NSMomentaryLightButton" swt_gen="true"></enum>
44584465
<enum name="NSMouseEntered" swt_gen="true"></enum>
44594466
<enum name="NSMouseExited" swt_gen="true"></enum>
44604467
<enum name="NSMouseMoved" swt_gen="true"></enum>
@@ -4486,19 +4493,14 @@
44864493
<enum name="NSPrintPanelShowsPageSetupAccessory" swt_gen="true"></enum>
44874494
<enum name="NSPrintPanelShowsPrintSelection" swt_gen="true"></enum>
44884495
<enum name="NSProgressIndicatorPreferredThickness" swt_gen="true"></enum>
4489-
<enum name="NSPushOnPushOffButton" swt_gen="true"></enum>
44904496
<enum name="NSRGBColorSpaceModel" swt_gen="true"></enum>
4491-
<enum name="NSRadioButton" swt_gen="true"></enum>
44924497
<enum name="NSRegularControlSize" swt_gen="true"></enum>
4493-
<enum name="NSRegularSquareBezelStyle" swt_gen="true"></enum>
44944498
<enum name="NSResizableWindowMask" swt_gen="true"></enum>
44954499
<enum name="NSRightMouseDown" swt_gen="true"></enum>
44964500
<enum name="NSRightMouseDragged" swt_gen="true"></enum>
44974501
<enum name="NSRightMouseUp" swt_gen="true"></enum>
44984502
<enum name="NSRoundLineCapStyle" swt_gen="true"></enum>
44994503
<enum name="NSRoundLineJoinStyle" swt_gen="true"></enum>
4500-
<enum name="NSRoundedBezelStyle" swt_gen="true"></enum>
4501-
<enum name="NSRoundedDisclosureBezelStyle" swt_gen="true"></enum>
45024504
<enum name="NSScaleNone" swt_gen="true"></enum>
45034505
<enum name="NSScrollElasticityNone" swt_gen="true"></enum>
45044506
<enum name="NSScrollWheel" swt_gen="true"></enum>
@@ -4510,14 +4512,12 @@
45104512
<enum name="NSScrollerKnobSlot" swt_gen="true"></enum>
45114513
<enum name="NSScrollerStyleLegacy" swt_gen="true"></enum>
45124514
<enum name="NSScrollerStyleOverlay" swt_gen="true"></enum>
4513-
<enum name="NSShadowlessSquareBezelStyle" swt_gen="true"></enum>
45144515
<enum name="NSShiftKeyMask" swt_gen="true"></enum>
45154516
<enum name="NSSmallControlSize" swt_gen="true"></enum>
45164517
<enum name="NSSquareLineCapStyle" swt_gen="true"></enum>
45174518
<enum name="NSStatusWindowLevel" swt_gen="true"></enum>
45184519
<enum name="NSStringDrawingUsesLineFragmentOrigin" swt_gen="true"></enum>
45194520
<enum name="NSSubmenuWindowLevel" swt_gen="true"></enum>
4520-
<enum name="NSSwitchButton" swt_gen="true"></enum>
45214521
<enum name="NSSystemDefined" swt_gen="true"></enum>
45224522
<enum name="NSTabCharacter" swt_gen="true"></enum>
45234523
<enum name="NSTableColumnNoResizing" swt_gen="true"></enum>

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2159,12 +2159,20 @@ public static Selector getSelector (long value) {
21592159
public static final int NSBackspaceCharacter = 8;
21602160
public static final int NSBevelLineJoinStyle = 2;
21612161
public static final int NSBezelBorder = 2;
2162+
public static final int NSBezelStyleFlexiblePush = 2;
2163+
public static final int NSBezelStylePush = 1;
2164+
public static final int NSBezelStylePushDisclosure = 14;
2165+
public static final int NSBezelStyleSmallSquare = 6;
21622166
public static final int NSBoldFontMask = 2;
21632167
public static final int NSBorderlessWindowMask = 0;
21642168
public static final int NSBottomTabsBezelBorder = 2;
21652169
public static final int NSBoxCustom = 4;
21662170
public static final int NSBoxSeparator = 2;
21672171
public static final int NSButtLineCapStyle = 0;
2172+
public static final int NSButtonTypeMomentaryLight = 0;
2173+
public static final int NSButtonTypePushOnPushOff = 1;
2174+
public static final int NSButtonTypeRadio = 4;
2175+
public static final int NSButtonTypeSwitch = 3;
21682176
public static final int NSCancelButton = 0;
21692177
public static final int NSCarriageReturnCharacter = 13;
21702178
public static final int NSClockAndCalendarDatePickerStyle = 1;
@@ -2242,7 +2250,6 @@ public static Selector getSelector (long value) {
22422250
public static final int NSMiniaturizableWindowMask = 4;
22432251
public static final int NSMiterLineJoinStyle = 0;
22442252
public static final int NSMixedState = -1;
2245-
public static final int NSMomentaryLightButton = 0;
22462253
public static final int NSMouseEntered = 8;
22472254
public static final int NSMouseExited = 9;
22482255
public static final int NSMouseMoved = 5;
@@ -2274,19 +2281,14 @@ public static Selector getSelector (long value) {
22742281
public static final int NSPrintPanelShowsPageSetupAccessory = 256;
22752282
public static final int NSPrintPanelShowsPrintSelection = 32;
22762283
public static final int NSProgressIndicatorPreferredThickness = 14;
2277-
public static final int NSPushOnPushOffButton = 1;
22782284
public static final int NSRGBColorSpaceModel = 1;
2279-
public static final int NSRadioButton = 4;
22802285
public static final int NSRegularControlSize = 0;
2281-
public static final int NSRegularSquareBezelStyle = 2;
22822286
public static final int NSResizableWindowMask = 8;
22832287
public static final int NSRightMouseDown = 3;
22842288
public static final int NSRightMouseDragged = 7;
22852289
public static final int NSRightMouseUp = 4;
22862290
public static final int NSRoundLineCapStyle = 1;
22872291
public static final int NSRoundLineJoinStyle = 1;
2288-
public static final int NSRoundedBezelStyle = 1;
2289-
public static final int NSRoundedDisclosureBezelStyle = 14;
22902292
public static final int NSScaleNone = 2;
22912293
public static final int NSScrollElasticityNone = 1;
22922294
public static final int NSScrollWheel = 22;
@@ -2298,14 +2300,12 @@ public static Selector getSelector (long value) {
22982300
public static final int NSScrollerKnobSlot = 6;
22992301
public static final int NSScrollerStyleLegacy = 0;
23002302
public static final int NSScrollerStyleOverlay = 1;
2301-
public static final int NSShadowlessSquareBezelStyle = 6;
23022303
public static final int NSShiftKeyMask = 131072;
23032304
public static final int NSSmallControlSize = 1;
23042305
public static final int NSSquareLineCapStyle = 2;
23052306
public static final int NSStatusWindowLevel = 25;
23062307
public static final int NSStringDrawingUsesLineFragmentOrigin = 1;
23072308
public static final int NSSubmenuWindowLevel = 3;
2308-
public static final int NSSwitchButton = 3;
23092309
public static final int NSSystemDefined = 14;
23102310
public static final int NSTabCharacter = 9;
23112311
public static final int NSTableColumnNoResizing = 0;

bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Button.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -250,27 +250,27 @@ void createHandle () {
250250
superview = superview.superview();
251251
}
252252
}
253-
int type = OS.NSMomentaryLightButton;
253+
int type = OS.NSButtonTypeMomentaryLight;
254254
if ((style & SWT.PUSH) != 0) {
255255
if ((style & SWT.FLAT) != 0) {
256-
widget.setBezelStyle(OS.NSShadowlessSquareBezelStyle);
256+
widget.setBezelStyle(OS.NSBezelStyleSmallSquare);
257257
} else {
258-
widget.setBezelStyle((style & SWT.WRAP) != 0 ? OS.NSRegularSquareBezelStyle : OS.NSRoundedBezelStyle);
258+
widget.setBezelStyle((style & SWT.WRAP) != 0 ? OS.NSBezelStyleFlexiblePush : OS.NSBezelStylePush);
259259
}
260260
} else if ((style & SWT.CHECK) != 0) {
261-
type = OS.NSSwitchButton;
261+
type = OS.NSButtonTypeSwitch;
262262
} else if ((style & SWT.RADIO) != 0) {
263-
type = OS.NSRadioButton;
263+
type = OS.NSButtonTypeRadio;
264264
radioParent = (SWTView) new SWTView().alloc().init();
265265
} else if ((style & SWT.TOGGLE) != 0) {
266-
type = OS.NSPushOnPushOffButton;
266+
type = OS.NSButtonTypePushOnPushOff;
267267
if ((style & SWT.FLAT) != 0) {
268-
widget.setBezelStyle(OS.NSShadowlessSquareBezelStyle);
268+
widget.setBezelStyle(OS.NSBezelStyleSmallSquare);
269269
} else {
270-
widget.setBezelStyle((style & SWT.WRAP) != 0 ? OS.NSRegularSquareBezelStyle : OS.NSRoundedBezelStyle);
270+
widget.setBezelStyle((style & SWT.WRAP) != 0 ? OS.NSBezelStyleFlexiblePush : OS.NSBezelStylePush);
271271
}
272272
} else if ((style & SWT.ARROW) != 0) {
273-
widget.setBezelStyle(OS.NSShadowlessSquareBezelStyle);
273+
widget.setBezelStyle(OS.NSBezelStyleSmallSquare);
274274
}
275275
widget.setButtonType(type);
276276
widget.setTitle(NSString.string());
@@ -363,10 +363,10 @@ void drawBezelWithFrame_inView (long id, long sel, NSRect cellFrame, long viewid
363363
lineWidth = 1f;
364364
}
365365
final long bezelStyle = button.bezelStyle();
366-
if (bezelStyle == OS.NSRoundedBezelStyle) {
366+
if (bezelStyle == OS.NSBezelStylePush) {
367367
NSRect rect2 = smallerRect(cellFrame, 6.5f, 4.5f, 7.5f, lineWidth);
368368
path = NSBezierPath.bezierPathWithRoundedRect(rect2, 3, 3);
369-
} else if (bezelStyle == OS.NSRegularSquareBezelStyle) {
369+
} else if (bezelStyle == OS.NSBezelStyleFlexiblePush) {
370370
NSRect rect2 = smallerRect(cellFrame, 2.5f, 2.5f, 3.5f, lineWidth);
371371
path = NSBezierPath.bezierPathWithRoundedRect(rect2, 3, 3);
372372
} else {
@@ -830,9 +830,9 @@ void setBounds (int x, int y, int width, int height, boolean move, boolean resiz
830830

831831
NSButton button = (NSButton)view;
832832
if (height > heightThreshold) {
833-
button.setBezelStyle(OS.NSRegularSquareBezelStyle);
833+
button.setBezelStyle(OS.NSBezelStyleFlexiblePush);
834834
} else {
835-
button.setBezelStyle(OS.NSRoundedBezelStyle);
835+
button.setBezelStyle(OS.NSBezelStylePush);
836836
}
837837
}
838838
super.setBounds(x, y, width, height, move, resize);

bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/DateTime.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ void createHandle () {
201201
if ((this.style & SWT.DROP_DOWN) != 0) {
202202
NSButton buttonWidget = (NSButton)new SWTButton().alloc();
203203
buttonWidget.init();
204-
buttonWidget.setButtonType(OS.NSMomentaryLightButton);
205-
buttonWidget.setBezelStyle(OS.NSRoundedDisclosureBezelStyle);
204+
buttonWidget.setButtonType(OS.NSButtonTypeMomentaryLight);
205+
buttonWidget.setBezelStyle(OS.NSBezelStylePushDisclosure);
206206
buttonWidget.setFocusRingType(OS.NSFocusRingTypeNone);
207207
buttonWidget.setTitle(NSString.stringWith(""));
208208
buttonWidget.setImagePosition(OS.NSNoImage);

bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ void createHandle () {
584584
buttonCell = new NSButtonCell (OS.class_createInstance (cls, 0));
585585
buttonCell.init ();
586586
checkColumn.setDataCell (buttonCell);
587-
buttonCell.setButtonType (OS.NSSwitchButton);
587+
buttonCell.setButtonType (OS.NSButtonTypeSwitch);
588588
buttonCell.setControlSize(OS.NSSmallControlSize);
589589
buttonCell.setImagePosition (OS.NSImageOnly);
590590
buttonCell.setAllowsMixedState (true);

bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ void createHandle () {
614614
buttonCell = new NSButtonCell (OS.class_createInstance (cls, 0));
615615
buttonCell.init ();
616616
checkColumn.setDataCell (buttonCell);
617-
buttonCell.setButtonType (OS.NSSwitchButton);
617+
buttonCell.setButtonType (OS.NSButtonTypeSwitch);
618618
buttonCell.setControlSize (OS.NSSmallControlSize);
619619
buttonCell.setImagePosition (OS.NSImageOnly);
620620
buttonCell.setAllowsMixedState (true);

0 commit comments

Comments
 (0)