Revision: 3087
http://skim-app.svn.sourceforge.net/skim-app/?rev=3087&view=rev
Author: hofman
Date: 2007-10-28 11:48:32 -0700 (Sun, 28 Oct 2007)
Log Message:
-----------
Also use our own textfield for editing text notes in Tiger. No need for hacks.
Modified Paths:
--------------
trunk/NSCell_SKExtensions.h
trunk/NSCell_SKExtensions.m
trunk/SKPDFView.h
trunk/SKPDFView.m
Modified: trunk/NSCell_SKExtensions.h
===================================================================
--- trunk/NSCell_SKExtensions.h 2007-10-28 18:29:29 UTC (rev 3086)
+++ trunk/NSCell_SKExtensions.h 2007-10-28 18:48:32 UTC (rev 3087)
@@ -44,18 +44,3 @@
@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-10-28 18:29:29 UTC (rev 3086)
+++ trunk/NSCell_SKExtensions.m 2007-10-28 18:48:32 UTC (rev 3087)
@@ -59,52 +59,3 @@
}
@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.h
===================================================================
--- trunk/SKPDFView.h 2007-10-28 18:29:29 UTC (rev 3086)
+++ trunk/SKPDFView.h 2007-10-28 18:48:32 UTC (rev 3087)
@@ -95,7 +95,6 @@
PDFAnnotation *activeAnnotation;
PDFAnnotation *highlightAnnotation;
- PDFAnnotationTextWidget *editAnnotation;
NSTextField *editField;
PDFSelection *wasSelection;
NSRect wasBounds;
Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m 2007-10-28 18:29:29 UTC (rev 3086)
+++ trunk/SKPDFView.m 2007-10-28 18:48:32 UTC (rev 3087)
@@ -192,7 +192,6 @@
readingBar = nil;
activeAnnotation = nil;
- editAnnotation = nil;
wasSelection = nil;
wasBounds = NSZeroRect;
wasStartPoint = NSZeroPoint;
@@ -220,9 +219,8 @@
name:SKAnnotationDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handlePageChangedNotification:)
name:PDFViewPageChangedNotification object:self];
- if (floor(NSAppKitVersionNumber) > 824)
- [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleScaleChangedNotification:)
-
name:PDFViewScaleChangedNotification object:self];
+ [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleScaleChangedNotification:)
+
name:PDFViewScaleChangedNotification object:self];
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self
forKeys:
[NSArray arrayWithObjects:SKReadingBarColorKey, SKReadingBarInvertKey,
nil]];
}
@@ -540,7 +538,7 @@
}
- (BOOL)isEditing {
- return editAnnotation != nil || editField != nil;
+ return editField != nil;
}
- (void)setDisplayMode:(PDFDisplayMode)mode {
@@ -1918,61 +1916,32 @@
} else if ([type isEqualToString:SKFreeTextString]) {
NSRect editBounds = [activeAnnotation bounds];
+ NSFont *font = [(PDFAnnotationFreeText *)activeAnnotation font];
+ NSColor *color = [activeAnnotation color];
+ float alpha = [color alphaComponent];
+ if (alpha < 1.0)
+ color = [[NSColor controlBackgroundColor]
blendedColorWithFraction:alpha ofColor:[color colorWithAlphaComponent:1.0]];
+ editBounds = [self convertRect:[self convertRect:editBounds
fromPage:[activeAnnotation page]] toView:[self documentView]];
+ editField = [[[NSTextField alloc] initWithFrame:editBounds]
autorelease];
+ [editField setBackgroundColor:color];
+ [editField setFont:[[NSFontManager sharedFontManager] convertFont:font
toSize:[font pointSize] * [self scaleFactor]]];
+ [editField setStringValue:[activeAnnotation contents]];
+ [editField setDelegate:self];
+ [[self documentView] addSubview:editField];
+ [editField selectText:self];
- if (floor(NSAppKitVersionNumber) <= 824) {
-
- editAnnotation = [[[PDFAnnotationTextWidget alloc]
initWithBounds:editBounds] autorelease];
- [editAnnotation setStringValue:[activeAnnotation contents]];
- if ([activeAnnotation respondsToSelector:@selector(font)])
- [editAnnotation setFont:[(PDFAnnotationFreeText
*)activeAnnotation font]];
- [[activeAnnotation page] addAnnotation:editAnnotation];
-
- // Start editing
- NSPoint location = [self convertPoint:[self
convertPoint:SKCenterPoint(editBounds) fromPage:[activeAnnotation page]]
toView:nil];
- NSEvent *theEvent = [NSEvent mouseEventWithType:NSLeftMouseDown
location:location modifierFlags:0 timestamp:0 windowNumber:[[self window]
windowNumber] context:nil eventNumber:0 clickCount:1 pressure:1.0];
- [super mouseDown:theEvent];
-
- } else {
-
- NSColor *color = [activeAnnotation color];
- float alpha = [color alphaComponent];
- if (alpha < 1.0)
- color = [[NSColor controlBackgroundColor]
blendedColorWithFraction:alpha ofColor:[color colorWithAlphaComponent:1.0]];
- editBounds = [self convertRect:[self convertRect:editBounds
fromPage:[activeAnnotation page]] toView:[self documentView]];
- editField = [[NSTextField alloc] initWithFrame:editBounds];
- [editField setBezeled:YES];
- [editField setBackgroundColor:color];
- if ([activeAnnotation respondsToSelector:@selector(font)]) {
- NSFont *font = [(PDFAnnotationFreeText *)activeAnnotation
font];
- [editField setFont:[[NSFontManager sharedFontManager]
convertFont:font toSize:[font pointSize] * [self scaleFactor]]];
- }
- [editField setStringValue:[activeAnnotation contents]];
- [editField setDelegate:self];
- [[self documentView] addSubview:editField];
- [editField selectText:self];
-
- }
}
}
- (void)endAnnotationEdit:(id)sender {
- if (editAnnotation) {
- if ([self respondsToSelector:@selector(removeAnnotationControl)])
- [self removeAnnotationControl]; // this removes the textfield from
the pdfview, need to do this before we remove the text widget
- if ([[editAnnotation stringValue] isEqualToString:[activeAnnotation
contents]] == NO) {
- [activeAnnotation setContents:[editAnnotation stringValue]];
- }
- [[editAnnotation page] removeAnnotation:editAnnotation];
- editAnnotation = nil;
- } else if (editField) {
+ if (editField) {
if ([[self window] firstResponder] == [editField currentEditor] &&
[[self window] makeFirstResponder:self] == NO)
[[self window] endEditingFor:nil];
if ([[editField stringValue] isEqualToString:[activeAnnotation
contents]] == NO) {
[activeAnnotation setContents:[editField stringValue]];
}
[editField removeFromSuperview];
- [editField release];
editField = nil;
}
}
@@ -1989,17 +1958,6 @@
return rv;
}
-- (NSColor *)control:(NSControl *)control
backgroundColorForFieldEditor:(NSText *)textObj {
- NSColor *color = nil;
- if ([self isEditing]) {
- color = [activeAnnotation color];
- float alpha = [color alphaComponent];
- if (alpha < 1.0)
- color = [[NSColor controlBackgroundColor]
blendedColorWithFraction:alpha ofColor:[color colorWithAlphaComponent:1.0]];
- }
- return color;
-}
-
- (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: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit