Revision: 3088
          http://skim-app.svn.sourceforge.net/skim-app/?rev=3088&view=rev
Author:   hofman
Date:     2007-10-29 03:10:10 -0700 (Mon, 29 Oct 2007)

Log Message:
-----------
Remove edit field from window when it is not on the layed out pages.

Modified Paths:
--------------
    trunk/SKPDFView.m

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2007-10-28 18:48:32 UTC (rev 3087)
+++ trunk/SKPDFView.m   2007-10-29 10:10:10 UTC (rev 3088)
@@ -126,7 +126,7 @@
 - (NSCursor *)cursorForEvent:(NSEvent *)theEvent;
 - (void)updateCursor;
 
-- (void)endEditingIfPageOutOfScope;
+- (void)relayoutEditField;
 
 @end
 
@@ -543,12 +543,12 @@
 
 - (void)setDisplayMode:(PDFDisplayMode)mode {
     [super setDisplayMode:mode];
-    [self endEditingIfPageOutOfScope];
+    [self relayoutEditField];
 }
 
 - (void)setDisplaysAsBook:(BOOL)asBook {
     [super setDisplaysAsBook:asBook];
-    [self endEditingIfPageOutOfScope];
+    [self relayoutEditField];
 }
 
 - (NSRect)currentSelectionRect {
@@ -1922,7 +1922,7 @@
         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 = [[NSTextField alloc] initWithFrame:editBounds];
         [editField setBackgroundColor:color];
         [editField setFont:[[NSFontManager sharedFontManager] convertFont:font 
toSize:[font pointSize] * [self scaleFactor]]];
         [editField setStringValue:[activeAnnotation contents]];
@@ -1942,6 +1942,7 @@
             [activeAnnotation setContents:[editField stringValue]];
         }
         [editField removeFromSuperview];
+        [editField release];
         editField = nil;
     }
 }
@@ -2132,7 +2133,7 @@
 }
 
 - (void)handlePageChangedNotification:(NSNotification *)notification {
-    [self endEditingIfPageOutOfScope];
+    [self relayoutEditField];
     if ([self toolMode] == SKSelectToolMode && NSIsEmptyRect(selectionRect) == 
NO)
         [self setNeedsDisplay:YES];
 }
@@ -3759,23 +3760,34 @@
     [[self cursorForEvent:event] set];
 }
 
-- (void)endEditingIfPageOutOfScope {
+- (void)relayoutEditField {
     if (editField) {
         PDFDisplayMode displayMode = [self displayMode];
         PDFPage *page = [activeAnnotation page];
         PDFPage *currentPage = [self currentPage];
+        BOOL isVisible = YES;
         if ([page isEqual:currentPage] == NO && displayMode != 
kPDFDisplaySinglePageContinuous && displayMode != kPDFDisplayTwoUpContinuous) {
-            int currentPageIndex = [currentPage pageIndex];
-            int facingPageIndex = -1;
             if (displayMode == kPDFDisplayTwoUp) {
+                int currentPageIndex = [currentPage pageIndex];
+                int facingPageIndex = currentPageIndex1;
                 if ([self displaysAsBook] == (BOOL)(currentPageIndex % 2))
-                    facingPageIndex = currentPageIndex + 1;
+                    facingPageIndex++;
                 else
-                    facingPageIndex = currentPageIndex - 1;
+                    facingPageIndex--;
+                if ([page pageIndex] != facingPageIndex)
+                    isVisible = NO;
+            } else {
+                isVisible = NO;
             }
-            if (facingPageIndex == -1 || facingPageIndex == (int)[[self 
document] pageCount] || [page isEqual:[[self document] 
pageAtIndex:facingPageIndex]] == NO)
-                [self endAnnotationEdit:self];
         }
+        if (isVisible) {
+            NSRect editBounds = [self convertRect:[self 
convertRect:[activeAnnotation bounds] fromPage:[activeAnnotation page]] 
toView:[self documentView]];
+            [editField setFrame:editBounds];
+            if ([editField superview] == nil)
+                [[self documentView] addSubview:editField];
+        } else if ([editField superview]) {
+            [editField removeFromSuperview];
+        }
     }
 }
 


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

Reply via email to