Revision: 3097
          http://skim-app.svn.sourceforge.net/skim-app/?rev=3097&view=rev
Author:   hofman
Date:     2007-10-30 05:54:45 -0700 (Tue, 30 Oct 2007)

Log Message:
-----------
Add hidden default for font size used in text tables.

Modified Paths:
--------------
    trunk/SKFindTableView.m
    trunk/SKMainWindowController.m
    trunk/SKNoteOutlineView.m
    trunk/SKNotesDocument.m
    trunk/SKOutlineView.m
    trunk/SKTableView.m
    trunk/SKTocOutlineView.m

Modified: trunk/SKFindTableView.m
===================================================================
--- trunk/SKFindTableView.m     2007-10-30 11:54:58 UTC (rev 3096)
+++ trunk/SKFindTableView.m     2007-10-30 12:54:45 UTC (rev 3097)
@@ -47,6 +47,12 @@
     [super dealloc];
 }
 
+- (void)awakeFromNib {
+    NSNumber *fontSize = [[NSUserDefaults standardUserDefaults] 
objectForKey:@"SKTableFontSize"];
+    if (fontSize)
+        [self setFont:[NSFont systemFontOfSize:[fontSize floatValue]]];
+}
+
 - (void)removeTrackingRects {
     if (trackingRects) {
         CFIndex idx = CFArrayGetCount(trackingRects);

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2007-10-30 11:54:58 UTC (rev 3096)
+++ trunk/SKMainWindowController.m      2007-10-30 12:54:45 UTC (rev 3097)
@@ -3444,16 +3444,12 @@
 }
 
 - (float)outlineView:(NSOutlineView *)ov heightOfRowByItem:(id)item {
-    if ([ov isEqual:outlineView]) {
-        return [ov rowHeight];
-    } else if ([ov isEqual:noteOutlineView]) {
+    if ([ov isEqual:noteOutlineView]) {
         // the item is an opaque wrapper object used for binding. The actual 
note is is given by -observedeObject. I don't know of any alternative (read 
public) way to get the actual item
-        if ([item respondsToSelector:@selector(rowHeight)] == NO)
-            return 17.0;
-        else
+        if ([item respondsToSelector:@selector(rowHeight)])
             return [item rowHeight];
     }
-    return 17.0;
+    return [ov rowHeight];
 }
 
 - (BOOL)outlineView:(NSOutlineView *)ov canResizeRowByItem:(id)item {
@@ -3591,9 +3587,10 @@
 }
 
 - (void)autoSizeNoteRows:(id)sender {
+    float rowHeight = [noteOutlineView rowHeight];
     NSTableColumn *tableColumn = [noteOutlineView 
tableColumnWithIdentifier:@"note"];
     id cell = [tableColumn dataCell];
-    float width = NSWidth([cell drawingRectForBounds:NSMakeRect(0.0, 0.0, 
[tableColumn width] - 17.0, 17.0)]);
+    float width = NSWidth([cell drawingRectForBounds:NSMakeRect(0.0, 0.0, 
[tableColumn width] - 17.0, rowHeight)]);
     NSSize size = NSMakeSize(width, FLT_MAX);
     
     NSMutableArray *items = [NSMutableArray array];
@@ -3615,7 +3612,7 @@
         [cell setObjectValue:[item string]];
         NSAttributedString *attrString = [cell attributedStringValue];
         NSRect rect = [attrString boundingRectWithSize:size 
options:NSStringDrawingUsesLineFragmentOrigin];
-        [item setRowHeight:fmaxf(NSHeight(rect) + 3.0, 19.0)];
+        [item setRowHeight:fmaxf(NSHeight(rect) + 3.0, rowHeight + 2.0)];
         row = [noteOutlineView rowForItem:item];
         if (row != -1)
             [rowIndexes addIndex:row];
@@ -3733,7 +3730,7 @@
         else
             return fmaxf(32.0, fminf(cellSize.width, thumbSize.width) * 
thumbSize.height / thumbSize.width);
     }
-    return 17.0;
+    return [tv rowHeight];
 }
 
 - (void)tableView:(NSTableView *)tv deleteRowsWithIndexes:(NSIndexSet 
*)rowIndexes {

Modified: trunk/SKNoteOutlineView.m
===================================================================
--- trunk/SKNoteOutlineView.m   2007-10-30 11:54:58 UTC (rev 3096)
+++ trunk/SKNoteOutlineView.m   2007-10-30 12:54:45 UTC (rev 3097)
@@ -52,6 +52,9 @@
 
 - (void)awakeFromNib {
     [self noteTypeMenu]; // this sets the menu for the header view
+    NSNumber *fontSize = [[NSUserDefaults standardUserDefaults] 
objectForKey:@"SKTableFontSize"];
+    if (fontSize)
+        [self setFont:[NSFont systemFontOfSize:[fontSize floatValue]]];
 }
 
 - (BOOL)resizeRow:(int)row withEvent:(NSEvent *)theEvent {

Modified: trunk/SKNotesDocument.m
===================================================================
--- trunk/SKNotesDocument.m     2007-10-30 11:54:58 UTC (rev 3096)
+++ trunk/SKNotesDocument.m     2007-10-30 12:54:45 UTC (rev 3097)
@@ -145,7 +145,7 @@
                 [note setValue:contents forKey:@"contents"];
                 [contents release];
             }
-            [note setObject:[NSNumber numberWithFloat:19.0] 
forKey:@"rowHeight"];
+            [note setObject:[NSNumber numberWithFloat:[outlineView rowHeight] 
+ 2.0] forKey:@"rowHeight"];
             
             [newNotes addObject:note];
             [note release];
@@ -228,9 +228,10 @@
 }
 
 - (void)autoSizeNoteRows:(id)sender {
+    float rowHeight = [outlineView rowHeight];
     NSTableColumn *tableColumn = [outlineView 
tableColumnWithIdentifier:@"note"];
     id cell = [tableColumn dataCell];
-    float width = NSWidth([cell drawingRectForBounds:NSMakeRect(0.0, 0.0, 
[tableColumn width] - 17.0, 17.0)]);
+    float width = NSWidth([cell drawingRectForBounds:NSMakeRect(0.0, 0.0, 
[tableColumn width] - 17.0, rowHeight)]);
     NSSize size = NSMakeSize(width, FLT_MAX);
     
     NSMutableArray *items = [NSMutableArray array];
@@ -252,7 +253,7 @@
         [cell setObjectValue:[item valueForKey:@"string"]];
         NSAttributedString *attrString = [cell attributedStringValue];
         NSRect rect = [attrString boundingRectWithSize:size 
options:NSStringDrawingUsesLineFragmentOrigin];
-        [item setValue:[NSNumber numberWithFloat:fmaxf(NSHeight(rect) + 3.0, 
19.0)] forKey:@"rowHeight"];
+        [item setValue:[NSNumber numberWithFloat:fmaxf(NSHeight(rect) + 3.0, 
rowHeight + 2.0)] forKey:@"rowHeight"];
         row = [outlineView rowForItem:item];
         if (row != -1)
             [rowIndexes addIndex:row];
@@ -396,7 +397,7 @@
 
 - (float)outlineView:(NSOutlineView *)ov heightOfRowByItem:(id)item {
     NSNumber *heightNumber = [item valueForKey:@"rowHeight"];
-    return heightNumber ? [heightNumber floatValue] : 17.0;
+    return heightNumber ? [heightNumber floatValue] : [ov rowHeight];
 }
 
 - (void)outlineView:(NSOutlineView *)ov setHeightOfRow:(int)newHeight 
byItem:(id)item {

Modified: trunk/SKOutlineView.m
===================================================================
--- trunk/SKOutlineView.m       2007-10-30 11:54:58 UTC (rev 3096)
+++ trunk/SKOutlineView.m       2007-10-30 12:54:45 UTC (rev 3097)
@@ -186,4 +186,25 @@
         [[self dataSource] outlineView:self dragEndedWithOperation:operation];
 }
 
+- (NSFont *)font {
+    NSArray *tableColumns = [self tableColumns];
+    return [tableColumns count] ? [[(NSTableColumn *)[tableColumns 
objectAtIndex:0] dataCell] font] : nil;
+}
+
+- (void)setFont:(NSFont *)font {
+    static NSLayoutManager *layoutManager = nil;
+    if (layoutManager == nil) {
+        layoutManager = [[NSLayoutManager alloc] init];
+        [layoutManager 
setTypesetterBehavior:NSTypesetterBehavior_10_2_WithCompatibility];
+    }
+    
+    NSEnumerator *tcEnum = [[self tableColumns] objectEnumerator];
+    NSTableColumn *tc;
+    
+    while (tc = [tcEnum nextObject])
+        [[tc dataCell] setFont:font];
+    
+    [self setRowHeight:[layoutManager defaultLineHeightForFont:font]];
+}
+
 @end

Modified: trunk/SKTableView.m
===================================================================
--- trunk/SKTableView.m 2007-10-30 11:54:58 UTC (rev 3096)
+++ trunk/SKTableView.m 2007-10-30 12:54:45 UTC (rev 3097)
@@ -159,4 +159,25 @@
        return menu;
 }
 
+- (NSFont *)font {
+    NSArray *tableColumns = [self tableColumns];
+    return [tableColumns count] ? [[(NSTableColumn *)[tableColumns 
objectAtIndex:0] dataCell] font] : nil;
+}
+
+- (void)setFont:(NSFont *)font {
+    static NSLayoutManager *layoutManager = nil;
+    if (layoutManager == nil) {
+        layoutManager = [[NSLayoutManager alloc] init];
+        [layoutManager 
setTypesetterBehavior:NSTypesetterBehavior_10_2_WithCompatibility];
+    }
+    
+    NSEnumerator *tcEnum = [[self tableColumns] objectEnumerator];
+    NSTableColumn *tc;
+    
+    while (tc = [tcEnum nextObject])
+        [[tc dataCell] setFont:font];
+    
+    [self setRowHeight:[layoutManager defaultLineHeightForFont:font]];
+}
+
 @end

Modified: trunk/SKTocOutlineView.m
===================================================================
--- trunk/SKTocOutlineView.m    2007-10-30 11:54:58 UTC (rev 3096)
+++ trunk/SKTocOutlineView.m    2007-10-30 12:54:45 UTC (rev 3097)
@@ -49,6 +49,12 @@
     [super dealloc];
 }
 
+- (void)awakeFromNib {
+    NSNumber *fontSize = [[NSUserDefaults standardUserDefaults] 
objectForKey:@"SKTableFontSize"];
+    if (fontSize)
+        [self setFont:[NSFont systemFontOfSize:[fontSize floatValue]]];
+}
+
 - (NSColor *)backgroundColor {
     return [NSColor tableBackgroundColor];
 }


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
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to