Revision: 4352
http://skim-app.svn.sourceforge.net/skim-app/?rev=4352&view=rev
Author: hofman
Date: 2008-08-04 21:19:17 +0000 (Mon, 04 Aug 2008)
Log Message:
-----------
Move code to calculate line height to a separate category to avoid code
duplication.
Modified Paths:
--------------
trunk/SKOutlineView.m
trunk/SKTableView.m
trunk/Skim.xcodeproj/project.pbxproj
Added Paths:
-----------
trunk/NSLayoutManager_SKExtensions.h
trunk/NSLayoutManager_SKExtensions.m
Added: trunk/NSLayoutManager_SKExtensions.h
===================================================================
--- trunk/NSLayoutManager_SKExtensions.h (rev 0)
+++ trunk/NSLayoutManager_SKExtensions.h 2008-08-04 21:19:17 UTC (rev
4352)
@@ -0,0 +1,46 @@
+//
+// NSLayoutManager_SKExtensions.h
+// Skim
+//
+// Created by Christiaan Hofman on 8/4/08.
+/*
+ This software is Copyright (c) 2008
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <Cocoa/Cocoa.h>
+
+
[EMAIL PROTECTED] NSLayoutManager (SKExtensions)
+
++ (float)defaultViewLineHeightForFont:(NSFont *)theFont;
+
[EMAIL PROTECTED]
Added: trunk/NSLayoutManager_SKExtensions.m
===================================================================
--- trunk/NSLayoutManager_SKExtensions.m (rev 0)
+++ trunk/NSLayoutManager_SKExtensions.m 2008-08-04 21:19:17 UTC (rev
4352)
@@ -0,0 +1,53 @@
+//
+// NSLayoutManager_SKExtensions.m
+// Skim
+//
+// Created by Christiaan Hofman on 8/4/08.
+/*
+ This software is Copyright (c) 2008
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "NSLayoutManager_SKExtensions.h"
+
+
[EMAIL PROTECTED] NSLayoutManager (SKExtensions)
+
++ (float)defaultViewLineHeightForFont:(NSFont *)theFont {
+ static NSLayoutManager *layoutManager = nil;
+ if (layoutManager == nil) {
+ layoutManager = [[self alloc] init];
+ [layoutManager
setTypesetterBehavior:NSTypesetterBehavior_10_2_WithCompatibility];
+ }
+ return [layoutManager defaultLineHeightForFont:theFont];
+}
+
[EMAIL PROTECTED]
Modified: trunk/SKOutlineView.m
===================================================================
--- trunk/SKOutlineView.m 2008-08-04 20:54:03 UTC (rev 4351)
+++ trunk/SKOutlineView.m 2008-08-04 21:19:17 UTC (rev 4352)
@@ -39,6 +39,7 @@
#import "SKOutlineView.h"
#import "SKTypeSelectHelper.h"
#import "NSEvent_SKExtensions.h"
+#import "NSLayoutManager_SKExtensions.h"
@implementation SKOutlineView
@@ -191,19 +192,13 @@
}
- (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]];
+ [self setRowHeight:[NSLayoutManager defaultViewLineHeightForFont:font]];
[self noteHeightOfRowsWithIndexesChanged:[NSIndexSet
indexSetWithIndexesInRange:NSMakeRange(0, [self numberOfRows])]];
}
Modified: trunk/SKTableView.m
===================================================================
--- trunk/SKTableView.m 2008-08-04 20:54:03 UTC (rev 4351)
+++ trunk/SKTableView.m 2008-08-04 21:19:17 UTC (rev 4352)
@@ -39,6 +39,7 @@
#import "SKTableView.h"
#import "SKTypeSelectHelper.h"
#import "NSEvent_SKExtensions.h"
+#import "NSLayoutManager_SKExtensions.h"
@implementation SKTableView
@@ -162,19 +163,13 @@
}
- (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]];
+ [self setRowHeight:[NSLayoutManager defaultViewLineHeightForFont:font]];
[self noteHeightOfRowsWithIndexesChanged:[NSIndexSet
indexSetWithIndexesInRange:NSMakeRange(0, [self numberOfRows])]];
}
Modified: trunk/Skim.xcodeproj/project.pbxproj
===================================================================
--- trunk/Skim.xcodeproj/project.pbxproj 2008-08-04 20:54:03 UTC (rev
4351)
+++ trunk/Skim.xcodeproj/project.pbxproj 2008-08-04 21:19:17 UTC (rev
4352)
@@ -165,6 +165,7 @@
CEA182280C92E3300061A6D4 /* NSData_SKExtensions.m in Sources */
= {isa = PBXBuildFile; fileRef = CEA182260C92E3300061A6D4 /*
NSData_SKExtensions.m */; };
CEA1CD1B0C9864470061A6D4 /* Security.framework in Frameworks */
= {isa = PBXBuildFile; fileRef = CEA1CCE60C9864470061A6D4 /* Security.framework
*/; };
CEA1D6EA0C9984400061A6D4 /* SKTextWithIconCell.m in Sources */
= {isa = PBXBuildFile; fileRef = CEA1D6E80C9984400061A6D4 /*
SKTextWithIconCell.m */; };
+ CEA450F40E47A87500D161AD /* NSLayoutManager_SKExtensions.m in
Sources */ = {isa = PBXBuildFile; fileRef = CEA450F30E47A87500D161AD /*
NSLayoutManager_SKExtensions.m */; };
CEA575CE0B9206E60003D2E7 /* SKNoteOutlineView.m in Sources */ =
{isa = PBXBuildFile; fileRef = CEA575CD0B9206E60003D2E7 /* SKNoteOutlineView.m
*/; };
CEA575E50B9207B80003D2E7 /* SKThumbnailTableView.m in Sources
*/ = {isa = PBXBuildFile; fileRef = CEA575E40B9207B80003D2E7 /*
SKThumbnailTableView.m */; };
CEA575FD0B9208B60003D2E7 /* SKTocOutlineView.m in Sources */ =
{isa = PBXBuildFile; fileRef = CEA575FC0B9208B60003D2E7 /* SKTocOutlineView.m
*/; };
@@ -741,6 +742,8 @@
CEA1CCE60C9864470061A6D4 /* Security.framework */ = {isa =
PBXFileReference; lastKnownFileType = wrapper.framework; name =
Security.framework; path = /System/Library/Frameworks/Security.framework;
sourceTree = "<absolute>"; };
CEA1D6E70C9984400061A6D4 /* SKTextWithIconCell.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
SKTextWithIconCell.h; sourceTree = "<group>"; };
CEA1D6E80C9984400061A6D4 /* SKTextWithIconCell.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= SKTextWithIconCell.m; sourceTree = "<group>"; };
+ CEA450F20E47A87500D161AD /* NSLayoutManager_SKExtensions.h */ =
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h;
path = NSLayoutManager_SKExtensions.h; sourceTree = "<group>"; };
+ CEA450F30E47A87500D161AD /* NSLayoutManager_SKExtensions.m */ =
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType =
sourcecode.c.objc; path = NSLayoutManager_SKExtensions.m; sourceTree =
"<group>"; };
CEA575CC0B9206E60003D2E7 /* SKNoteOutlineView.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
SKNoteOutlineView.h; sourceTree = "<group>"; };
CEA575CD0B9206E60003D2E7 /* SKNoteOutlineView.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= SKNoteOutlineView.m; sourceTree = "<group>"; };
CEA575E30B9207B80003D2E7 /* SKThumbnailTableView.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
SKThumbnailTableView.h; sourceTree = "<group>"; };
@@ -1574,6 +1577,8 @@
CE34FFA70DFF58FB00A7FFE6 /*
NSEvent_SKExtensions.m */,
CECDC4FC0C5966A80026AAEC /*
NSImage_SKExtensions.h */,
CECDC4FD0C5966A80026AAEC /*
NSImage_SKExtensions.m */,
+ CEA450F20E47A87500D161AD /*
NSLayoutManager_SKExtensions.h */,
+ CEA450F30E47A87500D161AD /*
NSLayoutManager_SKExtensions.m */,
CE3400AA0E0034DF00A7FFE6 /*
NSMenu_SKExtensions.h */,
CE3400AB0E0034DF00A7FFE6 /*
NSMenu_SKExtensions.m */,
CE070EA00B89039700733CC8 /*
NSScrollView_SKExtensions.h */,
@@ -2125,6 +2130,7 @@
CE3364310E2761E9005F99E6 /* synctex_parser.m in
Sources */,
CE3366DF0E28BCFA005F99E6 /* SKPDFSyncRecord.m
in Sources */,
CE09FC3C0E3886C100BDF413 /* SKRuntime.m in
Sources */,
+ CEA450F40E47A87500D161AD /*
NSLayoutManager_SKExtensions.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
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 the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit