Skip to content

Commit

Permalink
Remove now-useless calls to responsToSelector:
Browse files Browse the repository at this point in the history
Most of them were for pre-Lion checks.
  • Loading branch information
MaddTheSane committed Feb 3, 2024
1 parent 2f62166 commit 777a80d
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 43 deletions.
1 change: 0 additions & 1 deletion Boxer/Application Delegate/BXAppController+BXGamesFolder.m
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ - (NSURL *) shelfArtworkURL
{
BOOL useRetinaAssets = NO;
//10.7 and up
if ([[NSScreen mainScreen] respondsToSelector: @selector(convertRectToBacking:)])
{
NSRect backingPixel = [[NSScreen mainScreen] convertRectToBacking: NSMakeRect(0, 0, 1, 1)];
useRetinaAssets = (backingPixel.size.width >= 2.0);
Expand Down
7 changes: 1 addition & 6 deletions Boxer/BXImportWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ - (void) windowDidLoad
self.currentPanel = self.dropzonePanel;

//Disable window restoration.
if ([self.window respondsToSelector: @selector(setRestorable:)])
self.window.restorable = NO;
self.window.restorable = NO;

//Observe ourselves for changes to the document or its import stage,
//so we can sync the active panel.
Expand Down Expand Up @@ -148,7 +147,6 @@ - (void) handOffToController: (NSWindowController *)controller

//Suppress the default Lion window animations...
NSWindowAnimationBehavior oldToBehavior = NSWindowAnimationBehaviorDefault, oldFromBehavior = NSWindowAnimationBehaviorDefault;
if ([toWindow respondsToSelector: @selector(setAnimationBehavior:)])
{
oldToBehavior = toWindow.animationBehavior;
oldFromBehavior = fromWindow.animationBehavior;
Expand All @@ -165,7 +163,6 @@ - (void) handOffToController: (NSWindowController *)controller
[fromWindow orderOut: self];

//...and then turn the Lion animations back on after the transition is complete.
if ([toWindow respondsToSelector: @selector(setAnimationBehavior:)])
{
toWindow.animationBehavior = oldToBehavior;
fromWindow.animationBehavior = oldFromBehavior;
Expand Down Expand Up @@ -195,7 +192,6 @@ - (void) pickUpFromController: (NSWindowController *)controller

//Suppress the default Lion window animations...
NSWindowAnimationBehavior oldToBehavior = NSWindowAnimationBehaviorDefault, oldFromBehavior = NSWindowAnimationBehaviorDefault;
if ([toWindow respondsToSelector: @selector(setAnimationBehavior:)])
{
oldToBehavior = toWindow.animationBehavior;
oldFromBehavior = fromWindow.animationBehavior;
Expand All @@ -215,7 +211,6 @@ - (void) pickUpFromController: (NSWindowController *)controller
[fromWindow orderOut: self];

//...and then turn them back on after the transition is complete.
if ([toWindow respondsToSelector: @selector(setAnimationBehavior:)])
{
toWindow.animationBehavior = oldToBehavior;
fromWindow.animationBehavior = oldFromBehavior;
Expand Down
20 changes: 5 additions & 15 deletions Boxer/BXScroller.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ - (BOOL) isVertical

- (NSSize) knobMargin
{
if ([self respondsToSelector: @selector(scrollerStyle)] && [self scrollerStyle] == NSScrollerStyleOverlay)
if ([self scrollerStyle] == NSScrollerStyleOverlay)
{
return NSMakeSize(2.0f, 3.0f);
}
Expand All @@ -41,7 +41,7 @@ - (NSSize) knobMargin

- (NSSize) slotMargin
{
if ([self respondsToSelector: @selector(scrollerStyle)] && [self scrollerStyle] == NSScrollerStyleOverlay)
if ([self scrollerStyle] == NSScrollerStyleOverlay)
{
return NSMakeSize(1.0f, 2.0f);
}
Expand Down Expand Up @@ -88,17 +88,7 @@ - (BOOL) isOpaque { return NO; }
- (void) drawRect: (NSRect)dirtyRect
{
//On 10.7 and above, the regular NSScroller class should handle drawing
if ([self respondsToSelector: @selector(scrollerStyle)])
{
[super drawRect: dirtyRect];
}
//On 10.6 and below, we wish to override drawing to avoid drawing the 'caps'
//on the end of the standard scroller.
else
{
[self drawKnobSlotInRect: [self rectForPart: NSScrollerKnobSlot] highlight: NO];
[self drawKnob];
}
[super drawRect: dirtyRect];
}

- (void) drawKnob
Expand Down Expand Up @@ -186,7 +176,7 @@ @implementation BXHUDScroller

- (NSSize) knobMargin
{
if ([self respondsToSelector: @selector(scrollerStyle)] && [self scrollerStyle] == NSScrollerStyleOverlay)
if ([self scrollerStyle] == NSScrollerStyleOverlay)
{
return NSMakeSize(2.0f, 2.0f);
}
Expand All @@ -198,7 +188,7 @@ - (NSSize) knobMargin

- (NSSize) slotMargin
{
if ([self respondsToSelector: @selector(scrollerStyle)] && [self scrollerStyle] == NSScrollerStyleOverlay)
if ([self scrollerStyle] == NSScrollerStyleOverlay)
{
return NSMakeSize(1.0f, 1.0f);
}
Expand Down
1 change: 0 additions & 1 deletion Boxer/BXShelfArt.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ - (NSImage *) tiledImageWithPixelSize: (NSSize)pixelSize
NSSize logicalSize = pixelSize;

//TODO: ask our drawing context to do the conversion itself
if ([[NSScreen mainScreen] respondsToSelector: @selector(convertRectFromBacking:)])
{
NSRect pixelFrame = NSMakeRect(0, 0, pixelSize.width, pixelSize.height);
logicalSize = [[NSScreen mainScreen] convertRectFromBacking: pixelFrame].size;
Expand Down
3 changes: 1 addition & 2 deletions Boxer/DOS window/BXDOSWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@ - (void) windowDidLoad
self.window.acceptsMouseMovedEvents = YES;

//Disable window restoration.
if ([self.window respondsToSelector: @selector(setRestorable:)])
self.window.restorable = NO;
self.window.restorable = NO;

//Adjust the window's initial dimensions to suit the current aspect-ratio correction settings.
BOOL aspectCorrectText = [[NSUserDefaults standardUserDefaults] boolForKey: @"aspectCorrectedText"];
Expand Down
9 changes: 3 additions & 6 deletions Boxer/DOS window/BXLaunchPanelController.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,11 @@ - (void) viewDidLoad {
[super viewDidLoad];

//These attributes are unsupported in 10.6 and so cannot be defined in the XIB.
if ([self.launcherScrollView respondsToSelector: @selector(setScrollerKnobStyle:)])
self.launcherScrollView.scrollerKnobStyle = NSScrollerKnobStyleLight;
self.launcherScrollView.scrollerKnobStyle = NSScrollerKnobStyleLight;

if ([self.launcherScrollView respondsToSelector: @selector(setUsesPredominantAxisScrolling:)])
self.launcherScrollView.usesPredominantAxisScrolling = YES;
self.launcherScrollView.usesPredominantAxisScrolling = YES;

if ([self.launcherScrollView respondsToSelector: @selector(setHorizontalScrollElasticity:)])
self.launcherScrollView.horizontalScrollElasticity = NSScrollElasticityNone;
self.launcherScrollView.horizontalScrollElasticity = NSScrollElasticityNone;
}

- (void) setRepresentedObject: (id)representedObject
Expand Down
5 changes: 1 addition & 4 deletions Boxer/DOS window/BXProgramPanelController.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,7 @@ - (void) awakeFromNib
{
//Disable vertical scrolling on 10.7: while we can only scroll horizontally, it's still otherwise
//possible for the user to pull on the content vertically, and this causes ugly redraw errors.
if ([[self programScroller] respondsToSelector: @selector(setVerticalScrollElasticity:)])
{
[[self programScroller] setVerticalScrollElasticity: NSScrollElasticityNone];
}
[[self programScroller] setVerticalScrollElasticity: NSScrollElasticityNone];
}

- (void) syncActivePanel
Expand Down
12 changes: 4 additions & 8 deletions Boxer/Documentation Panel/BXDocumentationBrowser.m
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,9 @@ - (void) setRepresentedObject: (id)representedObject

- (void) awakeFromNib
{
if ([self.documentationScrollView respondsToSelector: @selector(setUsesPredominantAxisScrolling:)])
self.documentationScrollView.usesPredominantAxisScrolling = YES;
self.documentationScrollView.usesPredominantAxisScrolling = YES;

if ([self.documentationScrollView respondsToSelector: @selector(setHorizontalScrollElasticity:)])
self.documentationScrollView.horizontalScrollElasticity = NSScrollElasticityNone;
self.documentationScrollView.horizontalScrollElasticity = NSScrollElasticityNone;

[self.view registerForDraggedTypes: @[NSPasteboardTypeFileURL]];
//Allow documentation files to be dragged out of the documentation list to other applications,
Expand Down Expand Up @@ -195,8 +193,7 @@ - (void) _syncDocumentationURLs
[self.delegate documentationBrowser: self didUpdateFromURLs: oldURLs toURLs: newURLs];

//Flash the scrollbars (if any) to indicate that the content of the scroller has changed.
if ([self.documentationScrollView respondsToSelector: @selector(flashScrollers)])
[self.documentationScrollView flashScrollers];
[self.documentationScrollView flashScrollers];
}
}

Expand Down Expand Up @@ -837,8 +834,7 @@ - (void) _refreshIcon
//Meanwhile, load in a quicklook preview for this file in the background.
//Take retina displays into account when calculating the appropriate preview size.
NSSize thumbnailSize = self.view.bounds.size;
if ([self.view respondsToSelector: @selector(convertSizeToBacking:)])
thumbnailSize = [self.view convertSizeToBacking: thumbnailSize];
thumbnailSize = [self.view convertSizeToBacking: thumbnailSize];

//We perform this in an asynchronous block, because it can take a while
//to prepare the thumbnail.
Expand Down

0 comments on commit 777a80d

Please sign in to comment.