Revision: 2881
http://skim-app.svn.sourceforge.net/skim-app/?rev=2881&view=rev
Author: hofman
Date: 2007-09-10 11:01:06 -0700 (Mon, 10 Sep 2007)
Log Message:
-----------
Hack to use the background color of a free text annotation for editing.
Modified Paths:
--------------
trunk/NSCell_SKExtensions.h
trunk/NSCell_SKExtensions.m
trunk/SKPDFView.m
Modified: trunk/NSCell_SKExtensions.h
===================================================================
--- trunk/NSCell_SKExtensions.h 2007-09-10 17:10:16 UTC (rev 2880)
+++ trunk/NSCell_SKExtensions.h 2007-09-10 18:01:06 UTC (rev 2881)
@@ -44,3 +44,18 @@
@interface NSCell (SKExtensions)
- (NSColor *)replacementHighlightColorWithFrame:(NSRect)cellFrame
inView:(NSView *)controlView;
@end
+
+
[EMAIL PROTECTED] NSTextFieldCell (SKExtensions)
+- (NSText *)replacementSetUpFieldEditorAttributes:(NSText *)textObj;
[EMAIL PROTECTED]
+
+
[EMAIL PROTECTED] NSTextField (SKExtensions)
+- (void)replacementSetDelegate:(id)delegate;
[EMAIL PROTECTED]
+
+
[EMAIL PROTECTED] NSObject (SKExtendedNSTextFieldDelegate)
+- (NSColor *)control:(NSControl *)control
backgroundColorForFieldEditor:(NSText *)textObj;
[EMAIL PROTECTED]
Modified: trunk/NSCell_SKExtensions.m
===================================================================
--- trunk/NSCell_SKExtensions.m 2007-09-10 17:10:16 UTC (rev 2880)
+++ trunk/NSCell_SKExtensions.m 2007-09-10 18:01:06 UTC (rev 2881)
@@ -40,6 +40,7 @@
#import "NSCell_SKExtensions.h"
#import "OBUtilities.h"
+#import "SKPDFView.h"
@implementation NSCell (SKExtensions)
@@ -58,3 +59,52 @@
}
@end
+
+
[EMAIL PROTECTED] NSTextFieldCell (SKExtensions)
+
+static IMP originalSetUpFieldEditorAttributes = NULL;
+
++ (void)load {
+ originalSetUpFieldEditorAttributes =
OBReplaceMethodImplementationWithSelector(self,
@selector(setUpFieldEditorAttributes:),
@selector(replacementSetUpFieldEditorAttributes:));
+}
+
+- (NSText *)replacementSetUpFieldEditorAttributes:(NSText *)textObj {
+ textObj = originalSetUpFieldEditorAttributes(self, _cmd, textObj);
+ if ([textObj respondsToSelector:@selector(setBackgroundColor:)] && [[self
controlView] respondsToSelector:@selector(setBackgroundColor:)] && [[self
controlView] respondsToSelector:@selector(delegate)]) {
+ id delegate = [(NSTextField *)[self controlView] delegate];
+ if ([delegate
respondsToSelector:@selector(control:backgroundColorForFieldEditor:)]) {
+ NSColor *color = [delegate control:(NSTextField *)[self
controlView] backgroundColorForFieldEditor:textObj];
+ if (color) {
+ [(NSTextField *)[self controlView] setBackgroundColor:color];
+ [(NSTextView *)textObj setBackgroundColor:color];
+ }
+ }
+ }
+ return textObj;
+}
+
[EMAIL PROTECTED]
+
+
[EMAIL PROTECTED] NSTextField (SKExtensions)
+
+static IMP originalSetDelegate = NULL;
+
++ (void)load {
+ originalSetDelegate = OBReplaceMethodImplementationWithSelector(self,
@selector(setDelegate:), @selector(replacementSetDelegate:));
+}
+
+- (void)replacementSetDelegate:(id)delegate {
+ originalSetDelegate(self, _cmd, delegate);
+ NSText *currentEditor = [self currentEditor];
+ if (currentEditor && [currentEditor
respondsToSelector:@selector(setBackgroundColor:)] && [delegate
respondsToSelector:@selector(control:backgroundColorForFieldEditor:)]) {
+ NSColor *color = [delegate control:self
backgroundColorForFieldEditor:currentEditor];
+ if (color) {
+ [(NSTextField *)self setBackgroundColor:color];
+ [(NSTextView *)currentEditor setBackgroundColor:color];
+ }
+ }
+}
+
[EMAIL PROTECTED]
Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m 2007-09-10 17:10:16 UTC (rev 2880)
+++ trunk/SKPDFView.m 2007-09-10 18:01:06 UTC (rev 2881)
@@ -1957,6 +1957,12 @@
return rv;
}
+- (NSColor *)control:(NSControl *)control
backgroundColorForFieldEditor:(NSText *)textObj {
+ if (editAnnotation)
+ return [activeAnnotation color];
+ return nil;
+}
+
- (void)selectNextActiveAnnotation:(id)sender {
PDFDocument *pdfDoc = [self document];
int numberOfPages = [pdfDoc pageCount];
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit