Revision: 22919 http://sourceforge.net/p/bibdesk/svn/22919 Author: hofman Date: 2018-11-02 22:30:19 +0000 (Fri, 02 Nov 2018) Log Message: ----------- macro for deployment target check
Modified Paths: -------------- trunk/bibdesk/BDSKAddressTextField.m trunk/bibdesk/BDSKCompatibility.h trunk/bibdesk/BDSKDragImageView.m trunk/bibdesk/BDSKEditorTextFieldCell.m trunk/bibdesk/BDSKPreferenceIconButton.m trunk/bibdesk/NSView_BDSKExtensions.m Modified: trunk/bibdesk/BDSKAddressTextField.m =================================================================== --- trunk/bibdesk/BDSKAddressTextField.m 2018-11-02 06:31:01 UTC (rev 22918) +++ trunk/bibdesk/BDSKAddressTextField.m 2018-11-02 22:30:19 UTC (rev 22919) @@ -43,7 +43,7 @@ #define BUTTON_MARGIN_X 3.0 #define BUTTON_MARGIN_Y 2.0 -#if defined(MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 +#if !DEPLOYMENT_BEFORE(10_7) @interface BDSKAddressTextField () <NSDraggingSource> @end #endif @@ -154,9 +154,28 @@ return [super setKeyboardFocusRingNeedsDisplayInRect:[self bounds]]; } -#if defined(MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 +#if DEPLOYMENT_BEFORE(10_7) - (void)dragItems:(NSArray *)items withImage:(NSImage *)image fromFrame:(NSRect)frame forEvent:(NSEvent *)event { + NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard]; + [pboard clearContents]; + [pboard writeObjects:items]; + + NSPoint dragPoint = frame.origin; + if ([self isFlipped]) + dragPoint.y += NSHeight(frame); + + [self dragImage:image at:dragPoint offset:NSZeroSize event:event pasteboard:pboard source:self slideBack:YES]; +} + +// flag changes during a drag are not forwarded to the application, so we fix that at the end of the drag +- (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation{ + [[NSNotificationCenter defaultCenter] postNotificationName:BDSKFlagsChangedNotification object:NSApp]; +} + +#else + +- (void)dragItems:(NSArray *)items withImage:(NSImage *)image fromFrame:(NSRect)frame forEvent:(NSEvent *)event { NSMutableArray *dragItems = [NSMutableArray array]; for (NSPasteboardItem *item in items) { @@ -178,25 +197,6 @@ [[NSNotificationCenter defaultCenter] postNotificationName:BDSKFlagsChangedNotification object:NSApp]; } -#else - -- (void)dragItems:(NSArray *)items withImage:(NSImage *)image fromFrame:(NSRect)frame forEvent:(NSEvent *)event { - NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard]; - [pboard clearContents]; - [pboard writeObjects:items]; - - NSPoint dragPoint = frame.origin; - if ([self isFlipped]) - dragPoint.y += NSHeight(frame); - - [self dragImage:image at:dragPoint offset:NSZeroSize event:event pasteboard:pboard source:self slideBack:YES]; -} - -// flag changes during a drag are not forwarded to the application, so we fix that at the end of the drag -- (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation{ - [[NSNotificationCenter defaultCenter] postNotificationName:BDSKFlagsChangedNotification object:NSApp]; -} - #endif - (void)mouseDown:(NSEvent *)theEvent { Modified: trunk/bibdesk/BDSKCompatibility.h =================================================================== --- trunk/bibdesk/BDSKCompatibility.h 2018-11-02 06:31:01 UTC (rev 22918) +++ trunk/bibdesk/BDSKCompatibility.h 2018-11-02 22:30:19 UTC (rev 22919) @@ -39,6 +39,7 @@ #import <Cocoa/Cocoa.h> #define SDK_BEFORE(_version) (!defined(MAC_OS_X_VERSION_ ## _version) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_ ## _version) +#define DEPLOYMENT_BEFORE(_version) (!defined(MAC_OS_X_VERSION_ ## _version) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_ ## _version) #if SDK_BEFORE(10_13) Modified: trunk/bibdesk/BDSKDragImageView.m =================================================================== --- trunk/bibdesk/BDSKDragImageView.m 2018-11-02 06:31:01 UTC (rev 22918) +++ trunk/bibdesk/BDSKDragImageView.m 2018-11-02 22:30:19 UTC (rev 22919) @@ -39,7 +39,7 @@ #import "BDSKDragImageView.h" #import "NSBezierPath_BDSKExtensions.h" -#if defined(MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 +#if !DEPLOYMENT_BEFORE(10_7) @interface BDSKDragImageView () <NSDraggingSource> @end #endif @@ -94,27 +94,26 @@ } } -#if defined(MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 +#if DEPLOYMENT_BEFORE(10_7) - (void)dragItems:(NSArray *)items withImage:(NSImage *)image fromFrame:(NSRect)frame forEvent:(NSEvent *)event { - NSMutableArray *dragItems = [NSMutableArray array]; + NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard]; + [pboard clearContents]; + [pboard writeObjects:items]; - for (NSPasteboardItem *item in items) { - NSDraggingItem *dragItem = [[NSDraggingItem alloc] initWithPasteboardWriter:item]; - [dragItem setDraggingFrame:frame contents:image]; - [dragItems addObject:dragItem]; - [dragItem release]; - } + NSPoint dragPoint = frame.origin; + if ([self isFlipped]) + dragPoint.y += NSHeight(frame); - [self beginDraggingSessionWithItems:dragItems event:event source:self]; + [self dragImage:image at:dragPoint offset:NSZeroSize event:event pasteboard:pboard source:self slideBack:YES]; } -- (NSDragOperation)draggingSession:(NSDraggingSession *)session sourceOperationMaskForDraggingContext:(NSDraggingContext)context { +- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal{ return isLocal ? NSDragOperationNone : NSDragOperationCopy; } // flag changes during a drag are not forwarded to the application, so we fix that at the end of the drag -- (void)draggingSession:(NSDraggingSession *)session endedAtPoint:(NSPoint)screenPoint operation:(NSDragOperation)operation { +- (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation{ [[NSNotificationCenter defaultCenter] postNotificationName:BDSKFlagsChangedNotification object:NSApp]; } @@ -121,23 +120,24 @@ #else - (void)dragItems:(NSArray *)items withImage:(NSImage *)image fromFrame:(NSRect)frame forEvent:(NSEvent *)event { - NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard]; - [pboard clearContents]; - [pboard writeObjects:items]; + NSMutableArray *dragItems = [NSMutableArray array]; - NSPoint dragPoint = frame.origin; - if ([self isFlipped]) - dragPoint.y += NSHeight(frame); + for (NSPasteboardItem *item in items) { + NSDraggingItem *dragItem = [[NSDraggingItem alloc] initWithPasteboardWriter:item]; + [dragItem setDraggingFrame:frame contents:image]; + [dragItems addObject:dragItem]; + [dragItem release]; + } - [self dragImage:image at:dragPoint offset:NSZeroSize event:event pasteboard:pboard source:self slideBack:YES]; + [self beginDraggingSessionWithItems:dragItems event:event source:self]; } -- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal{ - return isLocal ? NSDragOperationNone : NSDragOperationCopy; +- (NSDragOperation)draggingSession:(NSDraggingSession *)session sourceOperationMaskForDraggingContext:(NSDraggingContext)context { + return context == NSDraggingContextWithinApplication ? NSDragOperationNone : NSDragOperationCopy; } // flag changes during a drag are not forwarded to the application, so we fix that at the end of the drag -- (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation{ +- (void)draggingSession:(NSDraggingSession *)session endedAtPoint:(NSPoint)screenPoint operation:(NSDragOperation)operation { [[NSNotificationCenter defaultCenter] postNotificationName:BDSKFlagsChangedNotification object:NSApp]; } Modified: trunk/bibdesk/BDSKEditorTextFieldCell.m =================================================================== --- trunk/bibdesk/BDSKEditorTextFieldCell.m 2018-11-02 06:31:01 UTC (rev 22918) +++ trunk/bibdesk/BDSKEditorTextFieldCell.m 2018-11-02 22:30:19 UTC (rev 22919) @@ -43,7 +43,7 @@ #define BUTTON_MARGIN 2.0 #define BUTTON_SIZE NSMakeSize(12.0, 12.0) -#if defined(MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 +#if !DEPLOYMENT_BEFORE(10_7) @interface BDSKEditorTextFieldCell () <NSDraggingSource> @end #endif @@ -107,22 +107,9 @@ return hit; } -#if defined(MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 +#if DEPLOYMENT_BEFORE(10_7) - (void)dragImage:(NSImage *)image fromFrame:(NSRect)frame inView:(NSView *)controlView forEvent:(NSEvent *)event { - NSDraggingItem *dragItem = [[[NSDraggingItem alloc] initWithPasteboardWriter:[NSArray arrayWithObjects:[self URL], nil]] autorelease]; - [dragItem setDraggingFrame:frame contents:image]; - - [controlView beginDraggingSessionWithItems:[NSArray arrayWithObejcts:dragItem, nil] event:event source:self]; -} - -- (NSDragOperation)draggingSession:(NSDraggingSession *)session sourceOperationMaskForDraggingContext:(NSDraggingContext)context { - return NSDragOperationCopy | NSDragOperationLink | NSDragOperationGeneric | NSDragOperationPrivate; -} - -#else - -- (void)dragImage:(NSImage *)image fromFrame:(NSRect)frame inView:(NSView *)controlView forEvent:(NSEvent *)event { NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard]; [pboard clearContents]; [pboard writeObjects:[NSArray arrayWithObjects:[self URL], nil]]; @@ -134,6 +121,19 @@ [controlView dragImage:image at:dragPoint offset:NSZeroSize event:event pasteboard:pboard source:self slideBack:YES]; } +#else + +- (void)dragImage:(NSImage *)image fromFrame:(NSRect)frame inView:(NSView *)controlView forEvent:(NSEvent *)event { + NSDraggingItem *dragItem = [[[NSDraggingItem alloc] initWithPasteboardWriter:[NSArray arrayWithObjects:[self URL], nil]] autorelease]; + [dragItem setDraggingFrame:frame contents:image]; + + [controlView beginDraggingSessionWithItems:[NSArray arrayWithObejcts:dragItem, nil] event:event source:self]; +} + +- (NSDragOperation)draggingSession:(NSDraggingSession *)session sourceOperationMaskForDraggingContext:(NSDraggingContext)context { + return NSDragOperationCopy | NSDragOperationLink | NSDragOperationGeneric | NSDragOperationPrivate; +} + #endif - (BOOL)trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame ofView:(NSView *)controlView untilMouseUp:(BOOL)untilMouseUp { Modified: trunk/bibdesk/BDSKPreferenceIconButton.m =================================================================== --- trunk/bibdesk/BDSKPreferenceIconButton.m 2018-11-02 06:31:01 UTC (rev 22918) +++ trunk/bibdesk/BDSKPreferenceIconButton.m 2018-11-02 22:30:19 UTC (rev 22919) @@ -44,7 +44,7 @@ + (Class)cellClass { return [BDSKPreferenceIconCell class]; } -#if !defined(MAC_OS_X_VERSION_10_7) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7 +#if DEPLOYMENT_BEFORE(10_7) // flag changes during a drag are not forwarded to the application, so we fix that at the end of the drag - (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation{ [[NSNotificationCenter defaultCenter] postNotificationName:BDSKFlagsChangedNotification object:NSApp]; @@ -53,7 +53,7 @@ @end -#if defined(MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 +#if !DEPLOYMENT_BEFORE(10_7) @interface BDSKEditorTextFieldCell () <NSDraggingSource> @end #endif @@ -67,12 +67,27 @@ [super drawWithFrame:cellFrame inView:controlView]; } -#if defined(MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 +#if DEPLOYMENT_BEFORE(10_7) - (void)dragImage:(NSImage *)image fromFrame:(NSRect)frame inView:(NSView *)controlView forEvent:(NSEvent *)event { + NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard]; + [pboard clearContents]; + [pboard declareTypes:[NSArray arrayWithObject:@"NSToolbarIndividualItemDragType"] owner:nil]; + [pboard setString:[self representedObject] forType:@"NSToolbarItemIdentifierPboardType"]; + + NSPoint dragPoint = frame.origin; + if ([controlView isFlipped]) + dragPoint.y += NSHeight(frame); + + [controlView dragImage:image at:dragPoint offset:NSZeroSize event:event pasteboard:pboard source:self slideBack:YES]; +} + +#else + +- (void)dragImage:(NSImage *)image fromFrame:(NSRect)frame inView:(NSView *)controlView forEvent:(NSEvent *)event { NSPasteboardItem *item = [[[NSPasteboardItem alloc] init] autorelease]; [item setString:[self representedObject] forType:@"NSToolbarItemIdentifierPboardType"]; - + NSDraggingItem *dragItem = [[[NSDraggingItem alloc] initWithPasteboardWriter:[NSArray arrayWithObjects:item, nil]] autorelease]; [dragItem setDraggingFrame:frame contents:image]; @@ -88,21 +103,6 @@ [[NSNotificationCenter defaultCenter] postNotificationName:BDSKFlagsChangedNotification object:NSApp]; } -#else - -- (void)dragImage:(NSImage *)image fromFrame:(NSRect)frame inView:(NSView *)controlView forEvent:(NSEvent *)event { - NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard]; - [pboard clearContents]; - [pboard declareTypes:[NSArray arrayWithObject:@"NSToolbarIndividualItemDragType"] owner:nil]; - [pboard setString:[self representedObject] forType:@"NSToolbarItemIdentifierPboardType"]; - - NSPoint dragPoint = frame.origin; - if ([controlView isFlipped]) - dragPoint.y += NSHeight(frame); - - [controlView dragImage:image at:dragPoint offset:NSZeroSize event:event pasteboard:pboard source:self slideBack:YES]; -} - #endif - (BOOL)trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame ofView:(NSView *)controlView untilMouseUp:(BOOL)untilMouseUp { Modified: trunk/bibdesk/NSView_BDSKExtensions.m =================================================================== --- trunk/bibdesk/NSView_BDSKExtensions.m 2018-11-02 06:31:01 UTC (rev 22918) +++ trunk/bibdesk/NSView_BDSKExtensions.m 2018-11-02 22:30:19 UTC (rev 22919) @@ -132,47 +132,47 @@ [self scrollPoint:desiredRect.origin]; } -#if defined(MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 +#if DEPLOYMENT_BEFORE(10_7) - (NSRect)convertRectToScreen:(NSRect)rect { - return [[self window] convertRectToScreen:[self convertRect:rect toView:nil]]; + rect = [self convertRect:rect toView:nil]; + rect.origin = [[self window] convertBaseToScreen:rect.origin]; + return rect; } - (NSRect)convertRectFromScreen:(NSRect)rect { - return [self convertRect:[[self window] convertRectFromScreen:rect] fromView:nil]; + rect.origin = [[self window] convertScreenToBase:rect.origin]; + return [self convertRect:rect fromView:nil]; } - (NSPoint)convertPointToScreen:(NSPoint)point { - NSRect rect = NSZeroRect; - rect.origin = [self convertPoint:point toView:nil]; - return [[self window] convertRectToScreen:rect].origin; + return [self convertPoint:[[self window] convertBaseToScreen:point] toView:nil]; } - (NSPoint)convertPointFromScreen:(NSPoint)point { - NSRect rect = NSZeroRect; - rect.origin = point; - return [self convertPoint:[[self window] convertRectFromScreen:rect].origin fromView:nil]; + return [self convertPoint:[[self window] convertScreenToBase:point] fromView:nil]; } #else - (NSRect)convertRectToScreen:(NSRect)rect { - rect = [self convertRect:rect toView:nil]; - rect.origin = [[self window] convertBaseToScreen:rect.origin]; - return rect; + return [[self window] convertRectToScreen:[self convertRect:rect toView:nil]]; } - (NSRect)convertRectFromScreen:(NSRect)rect { - rect.origin = [[self window] convertScreenToBase:rect.origin]; - return [self convertRect:rect fromView:nil]; + return [self convertRect:[[self window] convertRectFromScreen:rect] fromView:nil]; } - (NSPoint)convertPointToScreen:(NSPoint)point { - return [self convertPoint:[[self window] convertBaseToScreen:point] toView:nil]; + NSRect rect = NSZeroRect; + rect.origin = [self convertPoint:point toView:nil]; + return [[self window] convertRectToScreen:rect].origin; } - (NSPoint)convertPointFromScreen:(NSPoint)point { - return [self convertPoint:[[self window] convertScreenToBase:point] fromView:nil]; + NSRect rect = NSZeroRect; + rect.origin = point; + return [self convertPoint:[[self window] convertRectFromScreen:rect].origin fromView:nil]; } #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Bibdesk-commit mailing list Bibdesk-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-commit