Permalink
Browse files

Import from Sourceforge.net

  • Loading branch information...
0 parents commit 75ac2e33f49ecf8ae30cfe52c906314043c4f543 @jfmoy committed Mar 3, 2010
Showing 328 changed files with 132,042 additions and 0 deletions.
@@ -0,0 +1,28 @@
+/*
+Smultron version 3.6b1, 2009-09-12
+Written by Peter Borg, pgw3@mac.com
+Find the latest version at http://smultron.sourceforge.net
+
+Copyright 2004-2009 Peter Borg
+
+Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
+*/
+
+#import <Cocoa/Cocoa.h>
+
+
+@interface NSImage (NSImageSmultron)
+
++ (NSArray *)iconsForPath:(NSString *)path;
+
++ (NSArray *)quickLookIconForPath:(NSString *)path;
+
++ (CIImage *)unsavedFilterForCIImage:(CIImage *)ciImage;
+
+//+ (NSBitmapImageRep *)unsavedIconBitmapRep:(NSBitmapImageRep *)bitmapImageRep;
+
+@end
@@ -0,0 +1,110 @@
+/*
+Smultron version 3.6b1, 2009-09-12
+Written by Peter Borg, pgw3@mac.com
+Find the latest version at http://smultron.sourceforge.net
+
+Copyright 2004-2009 Peter Borg
+
+Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
+*/
+
+#import "NSImage+Smultron.h"
+#import "SMLStandardHeader.h"
+#import "SMLVariousPerformer.h"
+
+@implementation NSImage (NSImageSmultron)
+
++ (NSArray *)iconsForPath:(NSString *)path
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ NSArray *iconsArray;
+ if ([[SMLDefaults valueForKey:@"UseQuickLookIcon"] boolValue] == YES) {
+ iconsArray = [NSImage quickLookIconForPath:path];
+ if (iconsArray != nil && [iconsArray count] > 0) {
+ [pool drain];
+ return iconsArray;
+ }
+ }
+
+ NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFile:path];
+
+ //NSImageRep *imageRep = [temporaryIcon bestRepresentationForRect:NSMakeRect(0.0, 0.0, 128, 128) context:nil hints:nil];
+//
+// unsigned char *bitmapData = [imageRep bitmapData];
+//
+// NSBitmapImageRep *imageRep2 = [NSBitmapImageRep imageRepWithData:[NSData dataWithBytes:bitmapData length:sizeof(bitmapData)]];
+
+ //NSSize iconSize = NSMakeSize([icon pixelsWide], [icon pixelsHigh]);
+ //NSImage *icon = [[NSImage alloc] initWithSize:iconSize];
+
+ //[icon addRepresentation:imageRep];
+
+ [icon setSize:NSMakeSize(ICON_MAX_SIZE, ICON_MAX_SIZE)]; // This makes sure that unsavedIcon will not get "fuzzy"
+
+ NSImage *unsavedIcon = [[NSImage alloc] initWithSize:[icon size]];
+ //Log(imageRep);
+ CIImage *ciImage = [CIImage imageWithData:[icon TIFFRepresentation]];
+ //Log(ciImage);
+ [unsavedIcon addRepresentation:[NSCIImageRep imageRepWithCIImage:[NSImage unsavedFilterForCIImage:ciImage]]];
+ [unsavedIcon setSize:NSMakeSize(ICON_MAX_SIZE, ICON_MAX_SIZE)];
+ [unsavedIcon setScalesWhenResized:YES];
+ iconsArray = [NSArray arrayWithObjects:icon, unsavedIcon, nil];
+ [pool drain];
+
+ return iconsArray;
+}
+
+
++ (NSArray *)quickLookIconForPath:(NSString *)path
+{
+ // Thanks to Matt Gemmel (http://mattgemmell.com/) for the basics of this code
+
+ NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES],(NSString *)kQLThumbnailOptionIconModeKey, nil];
+ CGImageRef imageRef = QLThumbnailImageCreate(kCFAllocatorDefault, (CFURLRef)[NSURL fileURLWithPath:path], CGSizeMake(ICON_MAX_SIZE, ICON_MAX_SIZE), (CFDictionaryRef)options);
+ NSMakeCollectable(imageRef);
+
+ if (imageRef != NULL) {
+ NSBitmapImageRep *bitmapImageRep = [[NSBitmapImageRep alloc] initWithCGImage:imageRef];
+
+ if (bitmapImageRep != nil) {
+
+ NSSize iconSize = NSMakeSize([bitmapImageRep pixelsWide], [bitmapImageRep pixelsHigh]);
+ NSImage *icon = [[NSImage alloc] initWithSize:iconSize];
+
+ [icon addRepresentation:bitmapImageRep];
+ NSImage *unsavedIcon = [[NSImage alloc] initWithSize:iconSize];
+ CIImage *ciImage = [[CIImage alloc] initWithBitmapImageRep:bitmapImageRep];
+ [unsavedIcon addRepresentation:[NSCIImageRep imageRepWithCIImage:[NSImage unsavedFilterForCIImage:ciImage]]];
+
+ [icon setScalesWhenResized:YES];
+ [unsavedIcon setScalesWhenResized:YES];
+
+ return [NSArray arrayWithObjects:icon, unsavedIcon, nil];
+ }
+ }
+
+ return nil;
+}
+
+
++ (CIImage *)unsavedFilterForCIImage:(CIImage *)ciImage
+{
+ CIFilter *filter1 = [CIFilter filterWithName:@"CIColorControls"];
+ [filter1 setDefaults];
+ [filter1 setValue:ciImage forKey:@"inputImage"];
+ [filter1 setValue:[NSNumber numberWithFloat:-0.1] forKey:@"inputBrightness"];
+
+ CIFilter *filter2 = [CIFilter filterWithName:@"CISepiaTone"];
+ [filter2 setDefaults];
+ [filter2 setValue:[filter1 valueForKey:@"outputImage"] forKey:@"inputImage"];
+ [filter2 setValue:[NSNumber numberWithFloat:0.9] forKey:@"inputIntensity"];
+
+ return [filter2 valueForKey:@"outputImage"];
+}
+
+
+@end
@@ -0,0 +1,26 @@
+/*
+Smultron version 3.6b1, 2009-09-12
+Written by Peter Borg, pgw3@mac.com
+Find the latest version at http://smultron.sourceforge.net
+
+Copyright 2004-2009 Peter Borg
+
+Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
+*/
+
+#import <Cocoa/Cocoa.h>
+
+
+@interface NSString (NSStringSmultron)
+
++ (NSString *)dateStringForDate:(NSCalendarDate *)date formatIndex:(NSInteger)index;
+
+- (NSArray *)divideCommandIntoArray;
+
+
+
+@end
@@ -0,0 +1,111 @@
+/*
+Smultron version 3.6b1, 2009-09-12
+Written by Peter Borg, pgw3@mac.com
+Find the latest version at http://smultron.sourceforge.net
+
+Copyright 2004-2009 Peter Borg
+
+Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
+*/
+
+#import "NSString+Smultron.h"
+
+#import "SMLStandardHeader.h"
+
+@implementation NSString (NSStringSmultron)
+
+
++ (NSString *)dateStringForDate:(NSCalendarDate *)date formatIndex:(NSInteger)index
+{
+ NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
+ [dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
+
+ if (index == 1) {
+ [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm Z"];
+ } else if (index == 2) {
+ [dateFormatter setDateStyle:NSDateFormatterShortStyle];
+ [dateFormatter setTimeStyle:NSDateFormatterShortStyle];
+ } else if (index == 3) {
+ [dateFormatter setDateStyle:NSDateFormatterMediumStyle];
+ [dateFormatter setTimeStyle:NSDateFormatterShortStyle];
+ } else if (index == 4) {
+ [dateFormatter setDateStyle:NSDateFormatterMediumStyle];
+ [dateFormatter setTimeStyle:NSDateFormatterMediumStyle];
+ } else if (index == 5) {
+ [dateFormatter setDateStyle:NSDateFormatterLongStyle];
+ [dateFormatter setTimeStyle:NSDateFormatterShortStyle];
+ } else if (index == 6) {
+ [dateFormatter setDateStyle:NSDateFormatterLongStyle];
+ [dateFormatter setTimeStyle:NSDateFormatterLongStyle];
+ } else if (index == 7) {
+ [dateFormatter setDateStyle:NSDateFormatterFullStyle];
+ [dateFormatter setTimeStyle:NSDateFormatterFullStyle];
+ } else if (index == 8) {
+ [dateFormatter setDateFormat:[SMLDefaults valueForKey:@"UserDateFormat"]];
+ } else {
+ [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm"];
+ }
+
+ return [dateFormatter stringFromDate:date];
+}
+
+
+- (NSArray *)divideCommandIntoArray
+{
+ if ([self rangeOfString:@"\""].location == NSNotFound && [self rangeOfString:@"'"].location == NSNotFound) {
+ return [self componentsSeparatedByString:@" "];
+ } else {
+ NSMutableArray *returnArray = [NSMutableArray array];
+ NSScanner *scanner = [NSScanner scannerWithString:self];
+ NSInteger location = 0;
+ NSInteger commandLength = [self length];
+ NSInteger beginning;
+ NSInteger savedBeginning = -1;
+ NSString *characterToScanFor;
+
+ while (location < commandLength) {
+ if (savedBeginning == -1) {
+ beginning = location;
+ } else {
+ beginning = savedBeginning;
+ savedBeginning = -1;
+ }
+ if ([self characterAtIndex:location] == '"') {
+ characterToScanFor = @"\"";
+ beginning++;
+ location++;
+ } else if ([self characterAtIndex:location] == '\'') {
+ characterToScanFor = @"'";
+ beginning++;
+ location++;
+ } else {
+ characterToScanFor = @" ";
+ }
+
+ [scanner setScanLocation:location];
+ if ([scanner scanUpToString:characterToScanFor intoString:nil]) {
+ if (![characterToScanFor isEqualToString:@" "] && [self characterAtIndex:([scanner scanLocation] - 1)] == '\\') {
+ location = [scanner scanLocation];
+ savedBeginning = beginning - 1;
+ continue;
+ }
+ location = [scanner scanLocation];
+ } else {
+ location = commandLength - 1;
+ }
+
+ [returnArray addObject:[self substringWithRange:NSMakeRange(beginning, location - beginning)]];
+ location++;
+ }
+ return (NSArray *)returnArray;
+ }
+}
+
+
+
+
+@end
@@ -0,0 +1,25 @@
+/*
+Smultron version 3.6b1, 2009-09-12
+Written by Peter Borg, pgw3@mac.com
+Find the latest version at http://smultron.sourceforge.net
+
+Copyright 2004-2009 Peter Borg
+
+Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
+*/
+
+#import <Cocoa/Cocoa.h>
+
+
+@interface NSToolbarItem (NSToolbarItemSmultron)
+
++ (NSToolbarItem *)createToolbarItemWithIdentifier:(NSString *)itemIdentifier name:(NSString *)name image:(NSImage *)image action:(SEL)selector tag:(NSInteger)tag target:(id)target;
+
++ (NSToolbarItem *)createPreferencesToolbarItemWithIdentifier:(NSString *)itemIdentifier name:(NSString *)name image:(NSImage *)image action:(SEL)selector target:(id)target;
+
++ (NSToolbarItem *)createSeachFieldToolbarItemWithIdentifier:(NSString *)itemIdentifier name:(NSString *)name view:(NSView *)view;
+@end
@@ -0,0 +1,87 @@
+/*
+Smultron version 3.6b1, 2009-09-12
+Written by Peter Borg, pgw3@mac.com
+Find the latest version at http://smultron.sourceforge.net
+
+Copyright 2004-2009 Peter Borg
+
+Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
+*/
+
+#import "NSToolbarItem+Smultron.h"
+
+
+@implementation NSToolbarItem (NSToolbarItemSmultron)
+
+
++ (NSToolbarItem *)createToolbarItemWithIdentifier:(NSString *)itemIdentifier name:(NSString *)name image:(NSImage *)image action:(SEL)selector tag:(NSInteger)tag target:(id)target
+{
+ NSToolbarItem *toolbarItem = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
+
+// [toolbarItem setLabel:name];
+// [toolbarItem setPaletteLabel:name];
+// [toolbarItem setToolTip:name];
+// [toolbarItem setTag:tag];
+//
+// [toolbarItem setImage:image];
+// [toolbarItem setTarget:target];
+// [toolbarItem setAction:selector];
+
+ NSRect toolbarItemRect = NSMakeRect(0.0, 0.0, 28.0, 27.0);
+
+ NSView *view = [[NSView alloc] initWithFrame:toolbarItemRect];
+ NSButton *button = [[NSButton alloc] initWithFrame:toolbarItemRect];
+ [button setBezelStyle:NSTexturedRoundedBezelStyle];
+ [button setTitle:@""];
+ [button setImage:image];
+ [button setTarget:target];
+ [button setAction:selector];
+ [[button cell] setImageScaling:NSImageScaleProportionallyDown];
+ [button setImagePosition:NSImageOnly];
+
+ [toolbarItem setLabel:name];
+ [toolbarItem setPaletteLabel:name];
+ [toolbarItem setToolTip:name];
+
+ [view addSubview:button];
+
+ [toolbarItem setTag:tag];
+ [toolbarItem setView:view];
+
+ return toolbarItem;
+}
+
+
++ (NSToolbarItem *)createPreferencesToolbarItemWithIdentifier:(NSString *)itemIdentifier name:(NSString *)name image:(NSImage *)image action:(SEL)selector target:(id)target
+{
+ NSToolbarItem *toolbarItem = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
+
+ [toolbarItem setLabel:name];
+ [toolbarItem setPaletteLabel:name];
+ [toolbarItem setToolTip:name];
+
+ [toolbarItem setImage:image];
+ [toolbarItem setTarget:target];
+ [toolbarItem setAction:selector];
+
+ return toolbarItem;
+}
+
+
++ (NSToolbarItem *)createSeachFieldToolbarItemWithIdentifier:(NSString *)itemIdentifier name:(NSString *)name view:(NSView *)view
+{
+ NSToolbarItem *toolbarItem = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
+ [toolbarItem setLabel:name];
+ [toolbarItem setToolTip:name];
+ [toolbarItem setPaletteLabel:name];
+ [toolbarItem setView:view];
+ [toolbarItem setMinSize:NSMakeSize(70, 32)];
+ [toolbarItem setMaxSize:NSMakeSize(200, 32)];
+
+ return toolbarItem;
+}
+@end
Oops, something went wrong.

0 comments on commit 75ac2e3

Please sign in to comment.