From d8aeb282abf29d3bccdefb5d71460321adb42c3f Mon Sep 17 00:00:00 2001 From: gcasa Date: Sat, 5 Feb 2005 20:39:49 +0000 Subject: [PATCH] Datalink and connector improvements. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@20662 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 12 ++++ Headers/AppKit/NSDataLinkManager.h | 11 ++- Source/Functions.m | 22 ++++-- Source/NSBundleAdditions.m | 10 +++ Source/NSDataLink.m | 21 ++++++ Source/NSDataLinkManager.m | 106 +++++++++-------------------- 6 files changed, 93 insertions(+), 89 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1a48ac7b1..d9ff1ad52 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2005-02-05 15:42 Gregory John Casamento + + * Headers/AppKit/NSDataLinkManager.h: Moved NSDataLinkManager delegate + methods to an informal protocol NSDataLinkManagerDelegate. + * Source/Functions.m: Implemented NSFrameLinkRect() to draw the frames + around source and destination links. + * Source/NSBundleAdditions.m: Modified -description method in + NSNibConnector to display the source, destination and label for the + connection. This makes it easier to debug. + * Source/NSDataLink.m: Implemented a few private methods. + * Source/NSDataLinkManager.m: Implemented -breakAllLinks. + 2005-02-03 10:54 Alexander Malmberg * Source/NSImage.m (min, max): Rename to ... diff --git a/Headers/AppKit/NSDataLinkManager.h b/Headers/AppKit/NSDataLinkManager.h index 0c353fa14..632e032c7 100644 --- a/Headers/AppKit/NSDataLinkManager.h +++ b/Headers/AppKit/NSDataLinkManager.h @@ -101,10 +101,13 @@ - (NSDataLink *)destinationLinkWithSelection:(NSSelection *)destSel; - (void)setLinkOutlinesVisible:(BOOL)flag; - (NSEnumerator *)sourceLinkEnumerator; +@end + // // Methods Implemented by the Delegate // +@interface NSObject (NSDataLinkManagerDelegate) - (BOOL)copyToPasteboard:(NSPasteboard *)pasteboard at:(NSSelection *)selection cheapCopyAllowed:(BOOL)flag; @@ -126,15 +129,9 @@ at:(NSSelection *)selection; - (BOOL)showSelection:(NSSelection *)selection; - (NSWindow *)windowForSelection:(NSSelection *)selection; - -// -// NSCoding protocol -// -- (void)encodeWithCoder: (NSCoder *)aCoder; -- initWithCoder: (NSCoder *)aDecoder; - @end + // // Draw a Distinctive Outline around Linked Data // diff --git a/Source/Functions.m b/Source/Functions.m index 2f6462a33..a711c3c0f 100644 --- a/Source/Functions.m +++ b/Source/Functions.m @@ -776,19 +776,27 @@ NSDrawWindowBackground(NSRect aRect) NSRectFill(aRect); } -void -NSFrameLinkRect(NSRect aRect, BOOL isDestination) -{ -// TODO -} - float NSLinkFrameThickness(void) { -// TODO return 1.5; } +void +NSFrameLinkRect(NSRect aRect, BOOL isDestination) +{ + if (isDestination) + { + [[NSColor redColor] set]; + } + else + { + [[NSColor greenColor] set]; + } + + NSFrameRectWithWidth(aRect, NSLinkFrameThickness()); +} + void NSConvertGlobalToWindowNumber(int globalNum, unsigned int *winNum) { diff --git a/Source/NSBundleAdditions.m b/Source/NSBundleAdditions.m index e8c220b29..50c38e801 100644 --- a/Source/NSBundleAdditions.m +++ b/Source/NSBundleAdditions.m @@ -134,6 +134,16 @@ ASSIGN(_src, anObject); } +- (NSString *)description +{ + NSString *desc = [NSString stringWithFormat: @"<%@ src=%@ dst=%@ label=%@>", + [super description], + [self source], + [self destination], + [self label]]; + return desc; +} + @end @implementation NSNibControlConnector diff --git a/Source/NSDataLink.m b/Source/NSDataLink.m index c3d1f6804..ea242490d 100644 --- a/Source/NSDataLink.m +++ b/Source/NSDataLink.m @@ -27,6 +27,27 @@ #include "AppKit/NSDataLink.h" #include "AppKit/NSDataLinkManager.h" +@interface NSDataLink (Private) +- (void) setLastUpdateTime: (NSDate *)date; +- (void) setSourceFilename: (NSString *)src; +- (void) setDestinationFilename: (NSString *)src; +@end + +@implementation NSDataLink (Private) +- (void) setLastUpdateTime: (NSDate *)date +{ + ASSIGN(lastUpdateTime, date); +} +- (void) setSourceFilename: (NSString *)src +{ + ASSIGN(sourceFilename,src); +} +- (void) setDestinationFilename: (NSString *)dst +{ + ASSIGN(destinationFilename, dst); +} +@end + @implementation NSDataLink // diff --git a/Source/NSDataLinkManager.m b/Source/NSDataLinkManager.m index 865695daf..290d7af48 100644 --- a/Source/NSDataLinkManager.m +++ b/Source/NSDataLinkManager.m @@ -24,7 +24,10 @@ */ #include "config.h" -#include "AppKit/NSDataLinkManager.h" +#include +#include +#include +#include @implementation NSDataLinkManager @@ -99,7 +102,19 @@ - (void)breakAllLinks { - NSLog(@"Break all links."); + NSEnumerator *en = [self destinationLinkEnumerator]; + id obj = nil; + + while((obj = [en nextObject]) != nil) + { + [obj break]; + } + + en = [self sourceLinkEnumerator]; + while((obj = [en nextObject]) != nil) + { + [obj break]; + } } - (void)writeLinksToPasteboard:(NSPasteboard *)pasteboard @@ -181,12 +196,23 @@ - (NSEnumerator *)destinationLinkEnumerator { - return nil; + return [destinationLinks keyEnumerator]; } - (NSDataLink *)destinationLinkWithSelection:(NSSelection *)destSel { - return nil; + NSEnumerator *en = [self destinationLinkEnumerator]; + id obj = nil; + + while((obj = [en nextObject]) != nil) + { + if([obj destinationSelection] == destSel) + { + break; + } + } + + return obj; } - (void)setLinkOutlinesVisible:(BOOL)flag @@ -196,77 +222,7 @@ - (NSEnumerator *)sourceLinkEnumerator { - return nil; -} - -// -// Methods Implemented by the Delegate -// -- (BOOL)copyToPasteboard:(NSPasteboard *)pasteboard - at:(NSSelection *)selection -cheapCopyAllowed:(BOOL)flag -{ - return NO; -} - -- (void)dataLinkManager:(NSDataLinkManager *)sender - didBreakLink:(NSDataLink *)link -{ -} - -- (BOOL)dataLinkManager:(NSDataLinkManager *)sender - isUpdateNeededForLink:(NSDataLink *)link -{ - return NO; -} - -- (void)dataLinkManager:(NSDataLinkManager *)sender - startTrackingLink:(NSDataLink *)link -{ -} - -- (void)dataLinkManager:(NSDataLinkManager *)sender - stopTrackingLink:(NSDataLink *)link -{ -} - -- (void)dataLinkManagerCloseDocument:(NSDataLinkManager *)sender -{ -} - -- (void)dataLinkManagerDidEditLinks:(NSDataLinkManager *)sender -{ -} - -- (void)dataLinkManagerRedrawLinkOutlines:(NSDataLinkManager *)sender -{ -} - -- (BOOL)dataLinkManagerTracksLinksIndividually:(NSDataLinkManager *)sender -{ - return NO; -} - -- (BOOL)importFile:(NSString *)filename - at:(NSSelection *)selection -{ - return NO; -} - -- (BOOL)pasteFromPasteboard:(NSPasteboard *)pasteboard - at:(NSSelection *)selection -{ - return NO; -} - -- (BOOL)showSelection:(NSSelection *)selection -{ - return NO; -} - -- (NSWindow *)windowForSelection:(NSSelection *)selection -{ - return nil; + return [sourceLinks keyEnumerator]; } //