Revision: 6632
http://skim-app.svn.sourceforge.net/skim-app/?rev=6632&view=rev
Author: hofman
Date: 2010-07-18 11:06:48 +0000 (Sun, 18 Jul 2010)
Log Message:
-----------
consolidate code to get sub window controllers
Modified Paths:
--------------
trunk/NSWindowController_SKExtensions.h
trunk/NSWindowController_SKExtensions.m
trunk/SKMainWindowController.h
trunk/SKMainWindowController.m
trunk/SKMainWindowController_UI.m
trunk/SKSnapshotWindowController.m
Modified: trunk/NSWindowController_SKExtensions.h
===================================================================
--- trunk/NSWindowController_SKExtensions.h 2010-07-18 10:20:20 UTC (rev
6631)
+++ trunk/NSWindowController_SKExtensions.h 2010-07-18 11:06:48 UTC (rev
6632)
@@ -44,7 +44,6 @@
- (void)setWindowFrameAutosaveNameOrCascade:(NSString *)name;
- (BOOL)isNoteWindowController;
-- (BOOL)isSnapshotWindowController;
- (void)beginSheetModalForWindow:(NSWindow *)window;
- (void)beginSheetModalForWindow:(NSWindow *)window modalDelegate:(id)delegate
didEndSelector:(SEL)didEndSelector contextInfo:(void *)contextInfo;
Modified: trunk/NSWindowController_SKExtensions.m
===================================================================
--- trunk/NSWindowController_SKExtensions.m 2010-07-18 10:20:20 UTC (rev
6631)
+++ trunk/NSWindowController_SKExtensions.m 2010-07-18 11:06:48 UTC (rev
6632)
@@ -67,8 +67,6 @@
- (BOOL)isNoteWindowController { return NO; }
-- (BOOL)isSnapshotWindowController { return NO; }
-
- (void)didEndSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode
contextInfo:(void *)contextInfo {
NSInvocation *invocation = [(NSInvocation *)contextInfo autorelease];
if (invocation) {
Modified: trunk/SKMainWindowController.h
===================================================================
--- trunk/SKMainWindowController.h 2010-07-18 10:20:20 UTC (rev 6631)
+++ trunk/SKMainWindowController.h 2010-07-18 11:06:48 UTC (rev 6632)
@@ -212,6 +212,8 @@
- (void)showSnapshotsWithSetups:(NSArray *)setups;
- (void)showNote:(PDFAnnotation *)annotation;
+- (NSWindowController *)windowControllerForNote:(PDFAnnotation *)annotation;
+
@property (nonatomic, readonly) SKPDFView *pdfView;
@property (nonatomic, retain) PDFDocument *pdfDocument;
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2010-07-18 10:20:20 UTC (rev 6631)
+++ trunk/SKMainWindowController.m 2010-07-18 11:06:48 UTC (rev 6632)
@@ -1000,12 +1000,7 @@
- (void)removeObjectFromNotesAtIndex:(NSUInteger)theIndex {
PDFAnnotation *note = [notes objectAtIndex:theIndex];
- for (NSWindowController *wc in [[self document] windowControllers]) {
- if ([wc isNoteWindowController] && [[(SKNoteWindowController *)wc
note] isEqual:note]) {
- [[wc window] orderOut:self];
- break;
- }
- }
+ [[[self windowControllerForNote:note] window] orderOut:self];
if ([[note texts] count])
[rowHeights removeFloatForKey:[[note texts] lastObject]];
@@ -1292,6 +1287,13 @@
[pdfView setFrame:[[pdfView superview] bounds]];
}
+- (void)forceSubwindowsOnTop:(BOOL)flag {
+ for (NSWindowController *wc in [[self document] windowControllers]) {
+ if ([wc respondsToSelector:@selector(setForceOnTop:)])
+ [(id)wc setForceOnTop:flag];
+ }
+}
+
- (void)goFullScreen {
NSScreen *screen = [[self window] screen] ?: [NSScreen mainScreen]; // @@
screen: or should we use the main screen?
NSColor *backgroundColor = [self interactionMode] == SKPresentationMode ?
[NSColor blackColor] : [[NSUserDefaults standardUserDefaults]
colorForKey:SKFullScreenBackgroundColorKey];
@@ -1310,10 +1312,7 @@
[pdfView layoutDocumentView];
[pdfView setNeedsDisplay:YES];
- for (NSWindowController *wc in [[self document] windowControllers]) {
- if ([wc isNoteWindowController] || [wc isSnapshotWindowController])
- [(id)wc setForceOnTop:YES];
- }
+ [self forceSubwindowsOnTop:YES];
if (NO == [self interactionMode] == SKPresentationMode && [[NSUserDefaults
standardUserDefaults] boolForKey:SKBlankAllScreensInFullScreenKey] &&
[[NSScreen screens] count] > 1) {
if (nil == blankingWindows)
@@ -1507,10 +1506,7 @@
else
[self applyPDFSettings:savedNormalSetup];
- for (NSWindowController *wc in [[self document] windowControllers]) {
- if ([wc isNoteWindowController] || [wc isSnapshotWindowController])
- [(id)wc setForceOnTop:NO];
- }
+ [self forceSubwindowsOnTop:NO];
[fullScreenWindow setLevel:NSPopUpMenuWindowLevel];
@@ -2053,11 +2049,7 @@
}
- (void)showNote:(PDFAnnotation *)annotation {
- NSWindowController *wc = nil;
- for (wc in [[self document] windowControllers]) {
- if ([wc isNoteWindowController] && [(SKNoteWindowController *)wc note]
== annotation)
- break;
- }
+ NSWindowController *wc = [self windowControllerForNote:annotation];
if (wc == nil) {
wc = [[SKNoteWindowController alloc] initWithNote:annotation];
[(SKNoteWindowController *)wc setForceOnTop:[self interactionMode] !=
SKNormalMode];
@@ -2067,6 +2059,14 @@
[wc showWindow:self];
}
+- (NSWindowController *)windowControllerForNote:(PDFAnnotation *)annotation {
+ for (id wc in [[self document] windowControllers]) {
+ if ([wc isNoteWindowController] && [[wc note] isEqual:annotation])
+ return wc;
+ }
+ return nil;
+}
+
#pragma mark Observer registration
- (void)registerAsObserver {
Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m 2010-07-18 10:20:20 UTC (rev 6631)
+++ trunk/SKMainWindowController_UI.m 2010-07-18 11:06:48 UTC (rev 6632)
@@ -1593,12 +1593,7 @@
if ([[self selectedNotes] containsObject:annotation])
[rightSideController.noteOutlineView deselectAll:self];
- for (NSWindowController *wc in [[self document] windowControllers]) {
- if ([wc isNoteWindowController] && [(SKNoteWindowController *)wc
note] == annotation) {
- [wc close];
- break;
- }
- }
+ [[self windowControllerForNote:annotation] close];
mwcFlags.updatingNoteSelection = 1;
[[self mutableArrayValueForKey:NOTES_KEY] removeObject:annotation];
Modified: trunk/SKSnapshotWindowController.m
===================================================================
--- trunk/SKSnapshotWindowController.m 2010-07-18 10:20:20 UTC (rev 6631)
+++ trunk/SKSnapshotWindowController.m 2010-07-18 11:06:48 UTC (rev 6632)
@@ -111,8 +111,6 @@
return [NSString stringWithFormat:@"%@ %C %@", displayName,
EM_DASH_CHARACTER, [NSString stringWithFormat:NSLocalizedString(@"Page %@",
@""), [self pageLabel]]];
}
-- (BOOL)isSnapshotWindowController { return YES; }
-
- (void)setNeedsDisplayInRect:(NSRect)rect ofPage:(PDFPage *)page {
NSRect aRect = [pdfView convertRect:rect fromPage:page];
CGFloat scale = [pdfView scaleFactor];
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 Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit