Revision: 26171 http://sourceforge.net/p/bibdesk/svn/26171 Author: hofman Date: 2021-06-08 14:46:05 +0000 (Tue, 08 Jun 2021) Log Message: ----------- Move complex string cell class to formatter files, implement NSCopying for formatter
Modified Paths: -------------- trunk/bibdesk/BDSKComplexStringEditor.h trunk/bibdesk/BDSKComplexStringEditor.m trunk/bibdesk/BDSKComplexStringFormatter.h trunk/bibdesk/BDSKComplexStringFormatter.m trunk/bibdesk/BDSKEditorTextFieldCell.h Modified: trunk/bibdesk/BDSKComplexStringEditor.h =================================================================== --- trunk/bibdesk/BDSKComplexStringEditor.h 2021-06-08 14:39:17 UTC (rev 26170) +++ trunk/bibdesk/BDSKComplexStringEditor.h 2021-06-08 14:46:05 UTC (rev 26171) @@ -62,7 +62,3 @@ @property (nonatomic, readonly, getter=isAttached) BOOL attached; @end - - -@interface BDSKComplexStringCell : NSTextFieldCell -@end Modified: trunk/bibdesk/BDSKComplexStringEditor.m =================================================================== --- trunk/bibdesk/BDSKComplexStringEditor.m 2021-06-08 14:39:17 UTC (rev 26170) +++ trunk/bibdesk/BDSKComplexStringEditor.m 2021-06-08 14:46:05 UTC (rev 26171) @@ -278,20 +278,3 @@ } @end - - -@implementation BDSKComplexStringCell - -- (void)editWithFrame:(NSRect)rect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)delegate event:(NSEvent *)event { - [super editWithFrame:rect inView:controlView editor:textObj delegate:delegate event:event]; - if ([[self formatter] respondsToSelector:@selector(attachComplexStringEditorForCell:)]) - [(BDSKComplexStringFormatter *)[self formatter] attachComplexStringEditorForCell:self]; -} - -- (void)selectWithFrame:(NSRect)rect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)delegate start:(NSInteger)selStart length:(NSInteger)selLength { - [super selectWithFrame:rect inView:controlView editor:textObj delegate:delegate start:selStart length:selLength]; - if ([[self formatter] respondsToSelector:@selector(attachComplexStringEditorForCell:)]) - [(BDSKComplexStringFormatter *)[self formatter] attachComplexStringEditorForCell:self]; -} - -@end Modified: trunk/bibdesk/BDSKComplexStringFormatter.h =================================================================== --- trunk/bibdesk/BDSKComplexStringFormatter.h 2021-06-08 14:39:17 UTC (rev 26170) +++ trunk/bibdesk/BDSKComplexStringFormatter.h 2021-06-08 14:46:05 UTC (rev 26171) @@ -49,6 +49,10 @@ @property (nonatomic, retain) BDSKMacroResolver *macroResolver; @property (nonatomic) BOOL editAsComplexString; -- (void)attachComplexStringEditorForCell:(NSTextFieldCell *)cell; +- (void)cellDidStartEditing:(NSTextFieldCell *)cell; @end + + +@interface BDSKComplexStringCell : NSTextFieldCell +@end Modified: trunk/bibdesk/BDSKComplexStringFormatter.m =================================================================== --- trunk/bibdesk/BDSKComplexStringFormatter.m 2021-06-08 14:39:17 UTC (rev 26170) +++ trunk/bibdesk/BDSKComplexStringFormatter.m 2021-06-08 14:46:05 UTC (rev 26171) @@ -54,17 +54,21 @@ self = [super init]; if (self) { editAsComplexString = NO; - [self setMacroResolver:aMacroResolver]; + macroResolver = [aMacroResolver retain]; } return self; } +- (id)copyWithZone:(NSZone *)zone { + return [[[self class] allocWithZone:zone] initWithMacroResolver:macroResolver]; +} + - (void)dealloc { // should never happen if ([complexStringEditor isAttached]) [complexStringEditor remove]; + BDSKDESTROY(complexStringEditor); BDSKDESTROY(macroResolver); - BDSKDESTROY(complexStringEditor); [super dealloc]; } @@ -134,7 +138,7 @@ #pragma mark Complex string editor -- (void)attachComplexStringEditorForCell:(NSTextFieldCell *)cell { +- (void)cellDidStartEditing:(NSTextFieldCell *)cell { if (editAsComplexString) { if (complexStringEditor == nil) complexStringEditor = [[BDSKComplexStringEditor alloc] initWithMacroResolver:macroResolver]; @@ -143,3 +147,20 @@ } @end + + +@implementation BDSKComplexStringCell + +- (void)editWithFrame:(NSRect)rect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)delegate event:(NSEvent *)event { + [super editWithFrame:rect inView:controlView editor:textObj delegate:delegate event:event]; + if ([[self formatter] respondsToSelector:@selector(cellDidStartEditing:)]) + [(BDSKComplexStringFormatter *)[self formatter] cellDidStartEditing:self]; +} + +- (void)selectWithFrame:(NSRect)rect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)delegate start:(NSInteger)selStart length:(NSInteger)selLength { + [super selectWithFrame:rect inView:controlView editor:textObj delegate:delegate start:selStart length:selLength]; + if ([[self formatter] respondsToSelector:@selector(cellDidStartEditing:)]) + [(BDSKComplexStringFormatter *)[self formatter] cellDidStartEditing:self]; +} + +@end Modified: trunk/bibdesk/BDSKEditorTextFieldCell.h =================================================================== --- trunk/bibdesk/BDSKEditorTextFieldCell.h 2021-06-08 14:39:17 UTC (rev 26170) +++ trunk/bibdesk/BDSKEditorTextFieldCell.h 2021-06-08 14:46:05 UTC (rev 26171) @@ -37,7 +37,7 @@ */ #import <Cocoa/Cocoa.h> -#import "BDSKComplexStringEditor.h" +#import "BDSKComplexStringFormatter.h" @interface BDSKEditorTextFieldCell : BDSKComplexStringCell { NSButtonCell *buttonCell; 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