Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
129 lines (110 sloc) 3.79 KB
//
// FutureMethods.m
// iTerm
//
// Created by George Nachman on 8/29/11.
// Copyright 2011 Georgetech. All rights reserved.
//
#import "FutureMethods.h"
const int FutureNSWindowCollectionBehaviorStationary = (1 << 4); // value stolen from 10.6 SDK
@implementation NSWindow (Future)
- (void)futureSetRestorable:(BOOL)value
{
if ([self respondsToSelector:@selector(setRestorable:)]) {
NSMethodSignature *sig = [[self class] instanceMethodSignatureForSelector:@selector(setRestorable:)];
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:sig];
[inv setTarget:self];
[inv setSelector:@selector(setRestorable:)];
[inv setArgument:&value atIndex:2];
[inv invoke];
}
}
- (void)futureSetRestorationClass:(Class)class
{
if ([self respondsToSelector:@selector(setRestorationClass:)]) {
[self performSelector:@selector(setRestorationClass:) withObject:class];
}
}
- (void)futureInvalidateRestorableState
{
if ([self respondsToSelector:@selector(invalidateRestorableState)]) {
[self performSelector:@selector(invalidateRestorableState)];
}
}
@end
@implementation NSView (Future)
- (void)futureSetAcceptsTouchEvents:(BOOL)value
{
if ([self respondsToSelector:@selector(setAcceptsTouchEvents:)]) {
NSMethodSignature *sig = [[self class] instanceMethodSignatureForSelector:@selector(setAcceptsTouchEvents:)];
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:sig];
[inv setTarget:self];
[inv setSelector:@selector(setAcceptsTouchEvents:)];
[inv setArgument:&value atIndex:2];
[inv invoke];
}
}
- (void)futureSetWantsRestingTouches:(BOOL)value
{
if ([self respondsToSelector:@selector(setWantsRestingTouches:)]) {
NSMethodSignature *sig = [[self class] instanceMethodSignatureForSelector:@selector(setWantsRestingTouches:)];
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:sig];
[inv setTarget:self];
[inv setSelector:@selector(setWantsRestingTouches:)];
[inv setArgument:&value atIndex:2];
[inv invoke];
}
}
@end
@implementation NSEvent (Future)
- (NSArray *)futureTouchesMatchingPhase:(int)phase inView:(NSView *)view
{
if ([self respondsToSelector:@selector(touchesMatchingPhase:inView:)]) {
NSMethodSignature *sig = [[self class] instanceMethodSignatureForSelector:@selector(touchesMatchingPhase:inView:)];
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:sig];
[inv setTarget:self];
[inv setSelector:@selector(touchesMatchingPhase:inView:)];
[inv setArgument:&phase atIndex:2];
[inv setArgument:&view atIndex:3];
[inv invoke];
NSArray *result;
[inv getReturnValue:&result];
return result;
} else {
return [NSArray array];
}
}
@end
static FutureNSScrollerStyle GetScrollerStyle(id theObj)
{
NSMethodSignature *sig = [[NSScroller class] instanceMethodSignatureForSelector:@selector(scrollerStyle)];
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:sig];
[inv setTarget:theObj];
[inv setSelector:@selector(scrollerStyle)];
[inv invoke];
FutureNSScrollerStyle result;
[inv getReturnValue:&result];
return result;
}
@implementation NSScroller (Future)
- (FutureNSScrollerStyle)futureScrollerStyle
{
if ([self respondsToSelector:@selector(scrollerStyle)]) {
return GetScrollerStyle(self);
} else {
return FutureNSScrollerStyleLegacy;
}
}
@end
@implementation NSScrollView (Future)
- (FutureNSScrollerStyle)futureScrollerStyle
{
if ([self respondsToSelector:@selector(scrollerStyle)]) {
return GetScrollerStyle(self);
} else {
return FutureNSScrollerStyleLegacy;
}
}
@end
@implementation CIImage (Future)
@end
Something went wrong with that request. Please try again.