From: <ho...@us...> - 2008-10-31 13:30:24
|
Revision: 4901 http://skim-app.svn.sourceforge.net/skim-app/?rev=4901&view=rev Author: hofman Date: 2008-10-31 13:30:16 +0000 (Fri, 31 Oct 2008) Log Message: ----------- Use subclass of level indicator cell instead of method swizzling Modified Paths: -------------- trunk/MainWindow.nib/classes.nib trunk/MainWindow.nib/info.nib trunk/MainWindow.nib/keyedobjects.nib trunk/SKFindTableView.m trunk/Skim.xcodeproj/project.pbxproj Added Paths: ----------- trunk/SKLevelIndicatorCell.h trunk/SKLevelIndicatorCell.m Modified: trunk/MainWindow.nib/classes.nib =================================================================== --- trunk/MainWindow.nib/classes.nib 2008-10-30 23:21:13 UTC (rev 4900) +++ trunk/MainWindow.nib/classes.nib 2008-10-31 13:30:16 UTC (rev 4901) @@ -420,19 +420,19 @@ </dict> <dict> <key>CLASS</key> - <string>NSWindowController</string> + <string>NSMenu</string> <key>LANGUAGE</key> <string>ObjC</string> <key>SUPERCLASS</key> - <string>NSResponder</string> + <string>NSObject</string> </dict> <dict> <key>CLASS</key> - <string>NSMenu</string> + <string>NSWindowController</string> <key>LANGUAGE</key> <string>ObjC</string> <key>SUPERCLASS</key> - <string>NSObject</string> + <string>NSResponder</string> </dict> <dict> <key>ACTIONS</key> @@ -505,14 +505,6 @@ </dict> <dict> <key>CLASS</key> - <string>SKSegmentedControl</string> - <key>LANGUAGE</key> - <string>ObjC</string> - <key>SUPERCLASS</key> - <string>NSSegmentedControl</string> - </dict> - <dict> - <key>CLASS</key> <string>NSScrollView</string> <key>LANGUAGE</key> <string>ObjC</string> @@ -534,19 +526,19 @@ </dict> <dict> <key>CLASS</key> - <string>NSImageCell</string> + <string>SKSegmentedControl</string> <key>LANGUAGE</key> <string>ObjC</string> <key>SUPERCLASS</key> - <string>NSCell</string> + <string>NSSegmentedControl</string> </dict> <dict> <key>CLASS</key> - <string>NSSegmentedControl</string> + <string>NSImageCell</string> <key>LANGUAGE</key> <string>ObjC</string> <key>SUPERCLASS</key> - <string>NSControl</string> + <string>NSCell</string> </dict> <dict> <key>CLASS</key> @@ -557,6 +549,14 @@ <string>NSImageCell</string> </dict> <dict> + <key>CLASS</key> + <string>NSSegmentedControl</string> + <key>LANGUAGE</key> + <string>ObjC</string> + <key>SUPERCLASS</key> + <string>NSControl</string> + </dict> + <dict> <key>ACTIONS</key> <dict> <key>editBookmarks</key> @@ -736,6 +736,14 @@ </dict> <dict> <key>CLASS</key> + <string>SKLevelIndicatorCell</string> + <key>LANGUAGE</key> + <string>ObjC</string> + <key>SUPERCLASS</key> + <string>NSLevelIndicatorCell</string> + </dict> + <dict> + <key>CLASS</key> <string>NSResponder</string> <key>LANGUAGE</key> <string>ObjC</string> Modified: trunk/MainWindow.nib/info.nib =================================================================== --- trunk/MainWindow.nib/info.nib 2008-10-30 23:21:13 UTC (rev 4900) +++ trunk/MainWindow.nib/info.nib 2008-10-31 13:30:16 UTC (rev 4901) @@ -9,7 +9,9 @@ <key>IBOldestOS</key> <integer>4</integer> <key>IBOpenObjects</key> - <array/> + <array> + <integer>800</integer> + </array> <key>IBSystem Version</key> <string>9F33</string> <key>targetFramework</key> Modified: trunk/MainWindow.nib/keyedobjects.nib =================================================================== (Binary files differ) Modified: trunk/SKFindTableView.m =================================================================== --- trunk/SKFindTableView.m 2008-10-30 23:21:13 UTC (rev 4900) +++ trunk/SKFindTableView.m 2008-10-31 13:30:16 UTC (rev 4901) @@ -38,7 +38,6 @@ #import "SKFindTableView.h" #import "SKStringConstants.h" -#import "SKRuntime.h" @implementation SKFindTableView @@ -147,34 +146,3 @@ } @end - -#pragma mark - - -@interface NSLevelIndicatorCell (SKExtensions) -@end - -@implementation NSLevelIndicatorCell (SKExtensions) - -static void (*originalDrawWithFrameInView)(id, SEL, NSRect, id) = NULL; - -// Drawing does not restrict the clip, while in discrete style it heavily uses gaussian blur, leading to unacceptable slow drawing -// see <http://toxicsoftware.com/discrete-nslevelindicatorcell-too-slow/> -- (void)replacementDrawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { - BOOL drawDiscreteContinuous = ([self levelIndicatorStyle] == NSDiscreteCapacityLevelIndicatorStyle) && ((NSWidth(cellFrame) + 1.0) / [self maxValue] < 3.0); - if (drawDiscreteContinuous) - [self setLevelIndicatorStyle:NSContinuousCapacityLevelIndicatorStyle]; - [NSGraphicsContext saveGraphicsState]; - [[NSBezierPath bezierPathWithRect:cellFrame] addClip]; - originalDrawWithFrameInView(self, _cmd, cellFrame, controlView); - [NSGraphicsContext restoreGraphicsState]; - if (drawDiscreteContinuous) - [self setLevelIndicatorStyle:NSDiscreteCapacityLevelIndicatorStyle]; -} - -+ (void)load { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - originalDrawWithFrameInView = (void (*)(id, SEL, NSRect, id))SKReplaceInstanceMethodImplementationFromSelector(self, @selector(drawWithFrame:inView:), @selector(replacementDrawWithFrame:inView:)); - [pool release]; -} - -@end Added: trunk/SKLevelIndicatorCell.h =================================================================== --- trunk/SKLevelIndicatorCell.h (rev 0) +++ trunk/SKLevelIndicatorCell.h 2008-10-31 13:30:16 UTC (rev 4901) @@ -0,0 +1,43 @@ +// +// SKLevelIndicatorCell.h +// Skim +// +// Created by Christiaan Hofman on 10/31/08. +/* + This software is Copyright (c) 2007-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> + + +@interface SKLevelIndicatorCell : NSLevelIndicatorCell +@end Added: trunk/SKLevelIndicatorCell.m =================================================================== --- trunk/SKLevelIndicatorCell.m (rev 0) +++ trunk/SKLevelIndicatorCell.m 2008-10-31 13:30:16 UTC (rev 4901) @@ -0,0 +1,56 @@ +// +// SKLevelIndicatorCell.m +// Skim +// +// Created by Christiaan Hofman on 10/31/08. +/* + This software is Copyright (c) 2007-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 "SKLevelIndicatorCell.h" + + +@implementation SKLevelIndicatorCell + +- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { + BOOL drawDiscreteContinuous = ([self levelIndicatorStyle] == NSDiscreteCapacityLevelIndicatorStyle) && ((NSWidth(cellFrame) + 1.0) / [self maxValue] < 3.0); + if (drawDiscreteContinuous) + [self setLevelIndicatorStyle:NSContinuousCapacityLevelIndicatorStyle]; + [NSGraphicsContext saveGraphicsState]; + [[NSBezierPath bezierPathWithRect:cellFrame] addClip]; + [super drawWithFrame:cellFrame inView:controlView]; + [NSGraphicsContext restoreGraphicsState]; + if (drawDiscreteContinuous) + [self setLevelIndicatorStyle:NSDiscreteCapacityLevelIndicatorStyle]; +} + +@end Modified: trunk/Skim.xcodeproj/project.pbxproj =================================================================== --- trunk/Skim.xcodeproj/project.pbxproj 2008-10-30 23:21:13 UTC (rev 4900) +++ trunk/Skim.xcodeproj/project.pbxproj 2008-10-31 13:30:16 UTC (rev 4901) @@ -214,6 +214,7 @@ CECDDBAE0C5BB9600026AAEC /* SKFindTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = CECDDBAC0C5BB95F0026AAEC /* SKFindTableView.m */; }; CECF61FF0DB258D600587D96 /* SKFontWell.m in Sources */ = {isa = PBXBuildFile; fileRef = CECF61FE0DB258D600587D96 /* SKFontWell.m */; }; CED6A3120EADF37800E8CD11 /* NSImageCell_SKExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = CED6A3110EADF37800E8CD11 /* NSImageCell_SKExtensions.m */; }; + CEE0F5EB0EBB3DEC000A7A8C /* SKLevelIndicatorCell.m in Sources */ = {isa = PBXBuildFile; fileRef = CEE0F5EA0EBB3DEC000A7A8C /* SKLevelIndicatorCell.m */; }; CEE106150BCBB72C00BF2D3E /* SKNotesDocument.m in Sources */ = {isa = PBXBuildFile; fileRef = CEE106140BCBB72C00BF2D3E /* SKNotesDocument.m */; }; CEE176E40DBD5B0C00E6C317 /* PDFDisplayView_SKExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = CEE176E30DBD5B0C00E6C317 /* PDFDisplayView_SKExtensions.m */; }; CEE177960DBE140900E6C317 /* SKAccessibilityFauxUIElement.m in Sources */ = {isa = PBXBuildFile; fileRef = CEE177950DBE140900E6C317 /* SKAccessibilityFauxUIElement.m */; }; @@ -877,6 +878,8 @@ CED8D40B0D744D940028E3E2 /* Skim-Common.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "Skim-Common.xcconfig"; sourceTree = "<group>"; }; CED8D40C0D744D940028E3E2 /* Skim-Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "Skim-Debug.xcconfig"; sourceTree = "<group>"; }; CED8D40D0D744D940028E3E2 /* Skim-Release.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "Skim-Release.xcconfig"; sourceTree = "<group>"; }; + CEE0F5E90EBB3DEC000A7A8C /* SKLevelIndicatorCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKLevelIndicatorCell.h; sourceTree = "<group>"; }; + CEE0F5EA0EBB3DEC000A7A8C /* SKLevelIndicatorCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKLevelIndicatorCell.m; sourceTree = "<group>"; }; CEE106130BCBB72C00BF2D3E /* SKNotesDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKNotesDocument.h; sourceTree = "<group>"; }; CEE106140BCBB72C00BF2D3E /* SKNotesDocument.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKNotesDocument.m; sourceTree = "<group>"; }; CEE176E20DBD5B0C00E6C317 /* PDFDisplayView_SKExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PDFDisplayView_SKExtensions.h; sourceTree = "<group>"; }; @@ -1270,6 +1273,8 @@ CECDDBAC0C5BB95F0026AAEC /* SKFindTableView.m */, CECF61FD0DB258D600587D96 /* SKFontWell.h */, CECF61FE0DB258D600587D96 /* SKFontWell.m */, + CEE0F5E90EBB3DEC000A7A8C /* SKLevelIndicatorCell.h */, + CEE0F5EA0EBB3DEC000A7A8C /* SKLevelIndicatorCell.m */, CE4BC12D0C357A0300C2AF03 /* SKLineWell.h */, CE4BC12E0C357A0300C2AF03 /* SKLineWell.m */, CEA575CC0B9206E60003D2E7 /* SKNoteOutlineView.h */, @@ -2126,6 +2131,7 @@ CE7611650EA49D1400301E45 /* SKPrintableView.m in Sources */, CE51630B0EAB5A1A009FA237 /* SKSegmentedControl.m in Sources */, CED6A3120EADF37800E8CD11 /* NSImageCell_SKExtensions.m in Sources */, + CEE0F5EB0EBB3DEC000A7A8C /* SKLevelIndicatorCell.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |