Revision: 2843
          http://skim-app.svn.sourceforge.net/skim-app/?rev=2843&view=rev
Author:   hofman
Date:     2007-09-07 11:18:54 -0700 (Fri, 07 Sep 2007)

Log Message:
-----------
Add contextual menu items to auto-size rows in the note table.

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

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2007-09-06 14:05:11 UTC (rev 2842)
+++ trunk/SKMainWindowController.m      2007-09-07 18:18:54 UTC (rev 2843)
@@ -3413,6 +3413,39 @@
     [pdfView setActiveAnnotation:nil];
 }
 
+- (void)autoSizeNoteRows:(id)sender {
+    NSTableColumn *tableColumn = [noteOutlineView 
tableColumnWithIdentifier:@"note"];
+    id cell = [tableColumn dataCell];
+    float width = NSWidth([cell drawingRectForBounds:NSMakeRect(0.0, 0.0, 
[tableColumn width], 17.0)]);
+    NSSize size = NSMakeSize(width, FLT_MAX);
+    
+    NSMutableArray *items = [NSMutableArray array];
+    id item = [sender representedObject];
+    
+    if (item) {
+        [items addObject:item];
+    } else {
+        [items addObjectsFromArray:[self notes]];
+        [items addObjectsFromArray:[[self notes] 
valueForKeyPath:@"@unionOfArrays.texts"]];
+    }
+    
+    int i, count = [items count];
+    NSMutableIndexSet *rowIndexes = [NSMutableIndexSet indexSet];
+    int row;
+    
+    for (i = 0; i < count; i++) {
+        item = [items objectAtIndex:i];
+        [cell setObjectValue:[item contents]];
+        NSAttributedString *attrString = [cell attributedStringValue];
+        NSRect rect = [attrString boundingRectWithSize:size 
options:NSStringDrawingUsesLineFragmentOrigin];
+        [item setRowHeight:fmaxf(NSHeight(rect) + 3.0, 19.0)];
+        row = [noteOutlineView rowForItem:item];
+        if (row != -1)
+            [rowIndexes addIndex:row];
+    }
+    [noteOutlineView noteHeightOfRowsWithIndexesChanged:rowIndexes];
+}
+
 - (NSMenu *)outlineView:(NSOutlineView *)ov menuForTableColumn:(NSTableColumn 
*)tableColumn item:(id)item {
     NSMenu *menu = nil;
     NSMenuItem *menuItem;
@@ -3445,6 +3478,13 @@
             [menuItem setTarget:self];
             [menuItem setRepresentedObject:annotation];
         }
+        if ([menu numberOfItems] > 0)
+            [menu addItem:[NSMenuItem separatorItem]];
+        menuItem = [menu addItemWithTitle:NSLocalizedString(@"Auto Size Row", 
@"Menu item title") action:@selector(autoSizeNoteRows:) keyEquivalent:@""];
+        [menuItem setTarget:self];
+        [menuItem setRepresentedObject:item];
+        menuItem = [menu addItemWithTitle:NSLocalizedString(@"Auto Size All", 
@"Menu item title") action:@selector(autoSizeNoteRows:) keyEquivalent:@""];
+        [menuItem setTarget:self];
     }
     return menu;
 }


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