Revision: 3941
          http://skim-app.svn.sourceforge.net/skim-app/?rev=3941&view=rev
Author:   hofman
Date:     2008-05-30 12:11:26 -0700 (Fri, 30 May 2008)

Log Message:
-----------
Add separate action, target, and state for left and right cell in status bar. 
Scroll note to visible in main window when clicking in status bar message of a 
note window.

Modified Paths:
--------------
    trunk/SKMainWindowController.m
    trunk/SKNoteWindowController.h
    trunk/SKNoteWindowController.m
    trunk/SKStatusBar.h
    trunk/SKStatusBar.m

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2008-05-30 16:05:13 UTC (rev 3940)
+++ trunk/SKMainWindowController.m      2008-05-30 19:11:26 UTC (rev 3941)
@@ -666,7 +666,7 @@
         else
            message = @"";
     } else {
-        if ([statusBar state] == NSOnState) {
+        if ([statusBar rightState] == NSOnState) {
             BOOL useMetric = [[[NSLocale currentLocale] 
objectForKey:NSLocaleUsesMetricSystem] boolValue];
             NSString *units = useMetric ? @"cm" : @"in";
             float factor = useMetric ? 0.035277778 : 0.013888889;
@@ -1986,8 +1986,8 @@
         [statusBar setAutoresizingMask:NSViewWidthSizable | NSViewMaxYMargin];
         [self updateLeftStatus];
         [self updateRightStatus];
-        [statusBar setAction:@selector(statusBarClicked:)];
-        [statusBar setTarget:self];
+        [statusBar setRightAction:@selector(statusBarClicked:)];
+        [statusBar setRightTarget:self];
     }
     [statusBar toggleBelowView:splitView offset:1.0];
     [[NSUserDefaults standardUserDefaults] setBool:[statusBar isVisible] 
forKey:SKShowStatusBarKey];

Modified: trunk/SKNoteWindowController.h
===================================================================
--- trunk/SKNoteWindowController.h      2008-05-30 16:05:13 UTC (rev 3940)
+++ trunk/SKNoteWindowController.h      2008-05-30 19:11:26 UTC (rev 3941)
@@ -70,6 +70,8 @@
 - (BOOL)forceOnTop;
 - (void)setForceOnTop:(BOOL)flag;
 
+- (void)statusBarClicked:(id)sender;
+
 - (BOOL)commitEditing;
 - (void)handleDocumentWillSaveNotification:(NSNotification *)notification;
 

Modified: trunk/SKNoteWindowController.m
===================================================================
--- trunk/SKNoteWindowController.m      2008-05-30 16:05:13 UTC (rev 3940)
+++ trunk/SKNoteWindowController.m      2008-05-30 19:11:26 UTC (rev 3941)
@@ -43,6 +43,7 @@
 #import "SKPDFAnnotationNote.h"
 #import "SKStatusBar.h"
 #import "SKPDFDocument.h"
+#import "SKPDFView.h"
 #import "NSWindowController_SKExtensions.h"
 #import "NSUserDefaultsController_SKExtensions.h"
 #import "SKStringConstants.h"
@@ -144,6 +145,9 @@
         [item setImage:noteIcons[[item tag]]];
     }
     
+    [statusBar setLeftAction:@selector(statusBarClicked:)];
+    [statusBar setLeftTarget:self];
+    
     [self updateStatusMessage];
     
     [self setWindowFrameAutosaveNameOrCascade:SKNoteWindowFrameAutosaveName];
@@ -207,6 +211,12 @@
     [[self window] setHidesOnDeactivate:keepOnTop || forceOnTop];
 }
 
+- (void)statusBarClicked:(id)sender {
+    SKPDFView *pdfView = [(SKPDFDocument *)[self document] pdfView];
+    [pdfView scrollAnnotationToVisible:note];
+    [pdfView setActiveAnnotation:note];
+}
+
 - (void)objectDidBeginEditing:(id)editor {
     if (CFArrayGetFirstIndexOfValue(editors, CFRangeMake(0, 
CFArrayGetCount(editors)), editor) == -1)
                CFArrayAppendValue((CFMutableArrayRef)editors, editor);         

Modified: trunk/SKStatusBar.h
===================================================================
--- trunk/SKStatusBar.h 2008-05-30 16:05:13 UTC (rev 3940)
+++ trunk/SKStatusBar.h 2008-05-30 19:11:26 UTC (rev 3941)
@@ -50,7 +50,6 @@
        id leftCell;
        id rightCell;
        NSProgressIndicator *progressIndicator;
-    int state;
     CGLayerRef layer;
 }
 
@@ -73,12 +72,30 @@
 - (NSAttributedString *)rightAttributedStringValue;
 - (void)setRightAttributedStringValue:(NSAttributedString *)object;
 
-- (NSFont *)font;
-- (void)setFont:(NSFont *)fontObject;
+- (SEL)leftAction;
+- (void)setLeftAction:(SEL)selector;
 
+- (id)leftTarget;
+- (void)setLeftTarget:(id)newTarget;
+
+- (SEL)rightAction;
+- (void)setRightAction:(SEL)selector;
+
+- (id)rightTarget;
+- (void)setRightTarget:(id)newTarget;
+
+- (int)leftState;
+- (void)setLeftState:(int)newState;
+
+- (int)rightState;
+- (void)setRightState:(int)newState;
+
 - (int)state;
 - (void)setState:(int)newState;
 
+- (NSFont *)font;
+- (void)setFont:(NSFont *)fontObject;
+
 - (NSProgressIndicator *)progressIndicator;
 
 - (SKProgressIndicatorStyle)progressIndicatorStyle;

Modified: trunk/SKStatusBar.m
===================================================================
--- trunk/SKStatusBar.m 2008-05-30 16:05:13 UTC (rev 3940)
+++ trunk/SKStatusBar.m 2008-05-30 19:11:26 UTC (rev 3941)
@@ -175,21 +175,24 @@
 }
 
 - (void)mouseDown:(NSEvent *)theEvent {
-    if ([[rightCell stringValue] length]) {
-        NSPoint mouseLoc = [self convertPoint:[theEvent locationInWindow] 
fromView:nil];
-        float width = [rightCell cellSize].width;
-        NSRect ignored, rect = [self bounds];
-        NSDivideRect([self bounds], &ignored, &rect, LEFT_MARGIN, NSMinXEdge);
-        NSDivideRect(rect, &ignored, &rect, RIGHT_MARGIN, NSMaxXEdge);
-        NSDivideRect(rect, &rect, &ignored, width, NSMaxXEdge);
-        if (NSPointInRect(mouseLoc, rect)) {
-            theEvent = [[self window] nextEventMatchingMask: 
NSLeftMouseUpMask];
-            mouseLoc = [self convertPoint:[theEvent locationInWindow] 
fromView:nil];
-            if (NSPointInRect(mouseLoc, rect)) {
-                state = state == NSOnState ? NSOffState : NSOnState;
-                [self sendAction:[rightCell action] to:[rightCell target]];
-            }
-        }
+    NSPoint mouseLoc = [self convertPoint:[theEvent locationInWindow] 
fromView:nil];
+    float leftWidth = [[leftCell stringValue] length] ? [leftCell 
cellSize].width : 0.0;
+    float rightWidth = [[rightCell stringValue] length] ? [rightCell 
cellSize].width : 0.0;
+    NSRect ignored, leftRect, rightRect, rect = [self bounds];
+    NSDivideRect(rect, &ignored, &rect, LEFT_MARGIN, NSMinXEdge);
+    NSDivideRect(rect, &ignored, &rect, RIGHT_MARGIN, NSMaxXEdge);
+    NSDivideRect(rect, &rightRect, &ignored, rightWidth, NSMaxXEdge);
+    NSDivideRect(rect, &leftRect, &ignored, leftWidth, NSMinXEdge);
+    if (NSPointInRect(mouseLoc, rightRect)) {
+        theEvent = [[self window] nextEventMatchingMask: NSLeftMouseUpMask];
+        mouseLoc = [self convertPoint:[theEvent locationInWindow] 
fromView:nil];
+        if (NSPointInRect(mouseLoc, rightRect))
+            [rightCell performClick:self];
+    } else if (NSPointInRect(mouseLoc, leftRect)) {
+        theEvent = [[self window] nextEventMatchingMask: NSLeftMouseUpMask];
+        mouseLoc = [self convertPoint:[theEvent locationInWindow] 
fromView:nil];
+        if (NSPointInRect(mouseLoc, leftRect))
+            [leftCell performClick:self];
     }
 }
 
@@ -241,30 +244,76 @@
        [self setNeedsDisplay:YES];
 }
 
-- (SEL)action {
+- (SEL)leftAction {
     return [rightCell action];
 }
 
-- (void)setAction:(SEL)selector {
+- (void)setLeftAction:(SEL)selector {
+    [leftCell setAction:selector];
+}
+
+- (id)leftTarget {
+    return [leftCell target];
+}
+
+- (void)setLeftTarget:(id)newTarget {
+    [leftCell setTarget:newTarget];
+}
+
+- (SEL)rightAction {
+    return [rightCell action];
+}
+
+- (void)setRightAction:(SEL)selector {
     [rightCell setAction:selector];
 }
 
-- (id)target {
+- (id)rightTarget {
     return [rightCell target];
 }
 
-- (void)setTarget:(id)newTarget {
+- (void)setRightTarget:(id)newTarget {
     [rightCell setTarget:newTarget];
 }
 
+- (SEL)action {
+    return [self rightAction];
+}
+
+- (void)setAction:(SEL)selector {
+    [self setRightAction:selector];
+}
+
+- (id)target {
+    return [self rightTarget];
+}
+
+- (void)setTarget:(id)newTarget {
+    [self setRightTarget:newTarget];
+}
+
+- (int)leftState {
+    return [leftCell state];
+}
+
+- (void)setLeftState:(int)newState {
+    [leftCell setState:newState];
+}
+
+- (int)rightState {
+    return [rightCell state];
+}
+
+- (void)setRightState:(int)newState {
+    [rightCell setState:newState];
+}
+
 - (int)state {
-    return state;
+    return [self rightState];
 }
 
 - (void)setState:(int)newState {
-    if (state != newState) {
-        state = newState;
-    }
+    [self setRightState:newState];
 }
 
 #pragma mark Progress indicator


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 2008.
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

Reply via email to