From 20e2a56789fee97b67c41e3d16b5752dbe9f495b Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Thu, 27 May 2010 17:39:54 +0000 Subject: Rename CMImageView to SPImageView. --- Interfaces/English.lproj/FieldEditorSheet.xib | 58 ++++++------ Source/CMImageView.h | 42 --------- Source/CMImageView.m | 126 -------------------------- Source/SPImageView.h | 42 +++++++++ Source/SPImageView.m | 126 ++++++++++++++++++++++++++ Source/SPTextView.h | 2 +- Source/TableContent.m | 2 +- sequel-pro.xcodeproj/project.pbxproj | 12 +-- 8 files changed, 204 insertions(+), 206 deletions(-) delete mode 100644 Source/CMImageView.h delete mode 100644 Source/CMImageView.m create mode 100644 Source/SPImageView.h create mode 100644 Source/SPImageView.m diff --git a/Interfaces/English.lproj/FieldEditorSheet.xib b/Interfaces/English.lproj/FieldEditorSheet.xib index 56099439..218dcdd3 100644 --- a/Interfaces/English.lproj/FieldEditorSheet.xib +++ b/Interfaces/English.lproj/FieldEditorSheet.xib @@ -2,17 +2,16 @@ 1050 - 10B504 - 732 - 1038.2 - 437.00 + 10D573 + 762 + 1038.29 + 460.00 com.apple.InterfaceBuilder.CocoaPlugin - 732 + 762 YES - YES @@ -50,7 +49,7 @@ {3.40282e+38, 3.40282e+38} - + 4370 YES @@ -660,7 +659,6 @@ {667, 428} - {{0, 0}, {1280, 778}} {3.40282e+38, 3.40282e+38} @@ -1261,7 +1259,7 @@ com.apple.InterfaceBuilder.CocoaPlugin - CMImageView + SPImageView com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1304,26 +1302,6 @@ YES - - CMImageView - NSImageView - - delegate - id - - - IBProjectSource - Source/CMImageView.h - - - - CMImageView - NSImageView - - IBUserSource - - - NSObject @@ -1340,7 +1318,10 @@ NSObject - + + IBProjectSource + Source/CMImageView.h + NSObject @@ -1491,6 +1472,18 @@ Source/SPFieldEditorController.h + + SPImageView + NSImageView + + delegate + id + + + IBUserSource + + + YES @@ -1565,6 +1558,7 @@ 0 + IBCocoaFramework com.apple.InterfaceBuilder.CocoaPlugin.macosx @@ -1576,5 +1570,9 @@ YES ../../sequel-pro.xcodeproj 3 + + NSQuickLookTemplate + {19, 11} + diff --git a/Source/CMImageView.h b/Source/CMImageView.h deleted file mode 100644 index 84ffe041..00000000 --- a/Source/CMImageView.h +++ /dev/null @@ -1,42 +0,0 @@ -// -// $Id$ -// -// CMImageView.h -// sequel-pro -// -// Created by lorenz textor (lorenz@textor.ch) on Sat Sep 06 2003. -// Copyright (c) 2002-2003 Lorenz Textor. All rights reserved. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// More info at - -#import - -@interface NSObject (CMImageViewDelegate) - -- (void)processUpdatedImageData:(NSData *)data; -- (void)processPasteImageData; - -@end - -@interface CMImageView : NSImageView -{ - IBOutlet id delegate; -} - -- (BOOL)performDragOperation:(id )sender; - -@end diff --git a/Source/CMImageView.m b/Source/CMImageView.m deleted file mode 100644 index 32d60d13..00000000 --- a/Source/CMImageView.m +++ /dev/null @@ -1,126 +0,0 @@ -// -// $Id$ -// -// CMImageView.m -// sequel-pro -// -// Created by lorenz textor (lorenz@textor.ch) on Sat Sep 06 2003. -// Copyright (c) 2002-2003 Lorenz Textor. All rights reserved. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// More info at - -#import "CMImageView.h" - -@implementation CMImageView - -/* - * On a drag and drop, read in dragged files and convert dragged images before passing - * them to the delegate for further processing - */ -- (BOOL)performDragOperation:(id )sender -{ - id delegateForUse = nil; - - // If the delegate or the delegate's content instance doesn't implement processUpdatedImageData:, - // return the super's implementation - if (delegate) { - if ([delegate respondsToSelector:@selector(processUpdatedImageData:)]) { - delegateForUse = delegate; - } else if ( [delegate valueForKey:@"tableContentInstance"] - && [[delegate valueForKey:@"tableContentInstance"] respondsToSelector:@selector(processUpdatedImageData:)] ) { - delegateForUse = [delegate valueForKey:@"tableContentInstance"]; - } - } - if (!delegateForUse) { - return [super performDragOperation:sender]; - } - - // If a filename is available, attempt to read it and pass it to the delegate - if ([[[sender draggingPasteboard] propertyListForType:@"NSFilenamesPboardType"] count]) { - [delegateForUse processUpdatedImageData:[NSData dataWithContentsOfFile:[[[sender draggingPasteboard] propertyListForType:@"NSFilenamesPboardType"] objectAtIndex:0]]]; - return [super performDragOperation:sender]; - } - - // Otherwise, see if a dragged image is available via file contents or TIFF and pass to delegate - if ([[sender draggingPasteboard] dataForType:@"NSFileContentsPboardType"]) { - [delegateForUse processUpdatedImageData:[[sender draggingPasteboard] dataForType:@"NSFileContentsPboardType"]]; - return [super performDragOperation:sender]; - } - - // For dragged image representations (in TIFF format), convert to PNG data for compatibility - if ([[sender draggingPasteboard] dataForType:@"NSTIFFPboardType"]) { - NSData *pngData = nil; - NSBitmapImageRep *draggedImage = [[NSBitmapImageRep alloc] initWithData:[[sender draggingPasteboard] dataForType:@"NSTIFFPboardType"]]; - if (draggedImage) { - pngData = [draggedImage representationUsingType:NSPNGFileType properties:nil]; - [draggedImage release]; - } - if (pngData) { - [delegateForUse processUpdatedImageData:pngData]; - return [super performDragOperation:sender]; - } - } - - // For dragged image representations (in PICT format), convert to PNG data for compatibility - if ([[sender draggingPasteboard] dataForType:@"NSPICTPboardType"]) { - NSData *pngData = nil; - NSPICTImageRep *draggedImage = [[NSPICTImageRep alloc] initWithData:[[sender draggingPasteboard] dataForType:@"NSPICTPboardType"]]; - if (draggedImage) { - NSImage *convertImage = [[NSImage alloc] initWithSize:[draggedImage size]]; - [convertImage lockFocus]; - [draggedImage drawInRect:[draggedImage boundingBox]]; - NSBitmapImageRep *bitmapImageRep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:[draggedImage boundingBox]]; - if (bitmapImageRep) { - pngData = [bitmapImageRep representationUsingType:NSPNGFileType properties:nil]; - [bitmapImageRep release]; - } - [convertImage unlockFocus]; - [convertImage release]; - [draggedImage release]; - } - if (pngData) { - [delegateForUse processUpdatedImageData:pngData]; - return [super performDragOperation:sender]; - } - } - - // The image was not processed - return failure and clear image representation. - [delegateForUse processUpdatedImageData:nil]; - [self setImage:nil]; - return NO; -} - -- (void)paste:(id)sender -{ - // [super paste:sender]; - id delegateForUse = nil; - - // If the delegate or the delegate's content instance doesn't implement processUpdatedImageData:, - // return the super's implementation - if (delegate) { - if ([delegate respondsToSelector:@selector(processUpdatedImageData:)]) { - delegateForUse = delegate; - } else if ( [delegate valueForKey:@"tableContentInstance"] - && [[delegate valueForKey:@"tableContentInstance"] respondsToSelector:@selector(processUpdatedImageData:)] ) { - delegateForUse = [delegate valueForKey:@"tableContentInstance"]; - } - } - if (delegateForUse) - [delegateForUse processPasteImageData]; -} - -@end diff --git a/Source/SPImageView.h b/Source/SPImageView.h new file mode 100644 index 00000000..3576cf37 --- /dev/null +++ b/Source/SPImageView.h @@ -0,0 +1,42 @@ +// +// $Id$ +// +// SPImageView.h +// sequel-pro +// +// Created by lorenz textor (lorenz@textor.ch) on Sat Sep 06 2003. +// Copyright (c) 2002-2003 Lorenz Textor. All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// More info at + +#import + +@interface NSObject (SPImageViewDelegate) + +- (void)processUpdatedImageData:(NSData *)data; +- (void)processPasteImageData; + +@end + +@interface SPImageView : NSImageView +{ + IBOutlet id delegate; +} + +- (BOOL)performDragOperation:(id )sender; + +@end diff --git a/Source/SPImageView.m b/Source/SPImageView.m new file mode 100644 index 00000000..08f39980 --- /dev/null +++ b/Source/SPImageView.m @@ -0,0 +1,126 @@ +// +// $Id$ +// +// SPImageView.m +// sequel-pro +// +// Created by lorenz textor (lorenz@textor.ch) on Sat Sep 06 2003. +// Copyright (c) 2002-2003 Lorenz Textor. All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// More info at + +#import "SPImageView.h" + +@implementation SPImageView + +/* + * On a drag and drop, read in dragged files and convert dragged images before passing + * them to the delegate for further processing + */ +- (BOOL)performDragOperation:(id )sender +{ + id delegateForUse = nil; + + // If the delegate or the delegate's content instance doesn't implement processUpdatedImageData:, + // return the super's implementation + if (delegate) { + if ([delegate respondsToSelector:@selector(processUpdatedImageData:)]) { + delegateForUse = delegate; + } else if ( [delegate valueForKey:@"tableContentInstance"] + && [[delegate valueForKey:@"tableContentInstance"] respondsToSelector:@selector(processUpdatedImageData:)] ) { + delegateForUse = [delegate valueForKey:@"tableContentInstance"]; + } + } + if (!delegateForUse) { + return [super performDragOperation:sender]; + } + + // If a filename is available, attempt to read it and pass it to the delegate + if ([[[sender draggingPasteboard] propertyListForType:@"NSFilenamesPboardType"] count]) { + [delegateForUse processUpdatedImageData:[NSData dataWithContentsOfFile:[[[sender draggingPasteboard] propertyListForType:@"NSFilenamesPboardType"] objectAtIndex:0]]]; + return [super performDragOperation:sender]; + } + + // Otherwise, see if a dragged image is available via file contents or TIFF and pass to delegate + if ([[sender draggingPasteboard] dataForType:@"NSFileContentsPboardType"]) { + [delegateForUse processUpdatedImageData:[[sender draggingPasteboard] dataForType:@"NSFileContentsPboardType"]]; + return [super performDragOperation:sender]; + } + + // For dragged image representations (in TIFF format), convert to PNG data for compatibility + if ([[sender draggingPasteboard] dataForType:@"NSTIFFPboardType"]) { + NSData *pngData = nil; + NSBitmapImageRep *draggedImage = [[NSBitmapImageRep alloc] initWithData:[[sender draggingPasteboard] dataForType:@"NSTIFFPboardType"]]; + if (draggedImage) { + pngData = [draggedImage representationUsingType:NSPNGFileType properties:nil]; + [draggedImage release]; + } + if (pngData) { + [delegateForUse processUpdatedImageData:pngData]; + return [super performDragOperation:sender]; + } + } + + // For dragged image representations (in PICT format), convert to PNG data for compatibility + if ([[sender draggingPasteboard] dataForType:@"NSPICTPboardType"]) { + NSData *pngData = nil; + NSPICTImageRep *draggedImage = [[NSPICTImageRep alloc] initWithData:[[sender draggingPasteboard] dataForType:@"NSPICTPboardType"]]; + if (draggedImage) { + NSImage *convertImage = [[NSImage alloc] initWithSize:[draggedImage size]]; + [convertImage lockFocus]; + [draggedImage drawInRect:[draggedImage boundingBox]]; + NSBitmapImageRep *bitmapImageRep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:[draggedImage boundingBox]]; + if (bitmapImageRep) { + pngData = [bitmapImageRep representationUsingType:NSPNGFileType properties:nil]; + [bitmapImageRep release]; + } + [convertImage unlockFocus]; + [convertImage release]; + [draggedImage release]; + } + if (pngData) { + [delegateForUse processUpdatedImageData:pngData]; + return [super performDragOperation:sender]; + } + } + + // The image was not processed - return failure and clear image representation. + [delegateForUse processUpdatedImageData:nil]; + [self setImage:nil]; + return NO; +} + +- (void)paste:(id)sender +{ + // [super paste:sender]; + id delegateForUse = nil; + + // If the delegate or the delegate's content instance doesn't implement processUpdatedImageData:, + // return the super's implementation + if (delegate) { + if ([delegate respondsToSelector:@selector(processUpdatedImageData:)]) { + delegateForUse = delegate; + } else if ( [delegate valueForKey:@"tableContentInstance"] + && [[delegate valueForKey:@"tableContentInstance"] respondsToSelector:@selector(processUpdatedImageData:)] ) { + delegateForUse = [delegate valueForKey:@"tableContentInstance"]; + } + } + if (delegateForUse) + [delegateForUse processPasteImageData]; +} + +@end diff --git a/Source/SPTextView.h b/Source/SPTextView.h index 2964845a..f89bbc06 100644 --- a/Source/SPTextView.h +++ b/Source/SPTextView.h @@ -1,5 +1,5 @@ // -// $Id: CMTextView.h 2240 2010-05-23 21:44:59Z rowanb $ +// $Id$ // // SPTextView.h // sequel-pro diff --git a/Source/TableContent.m b/Source/TableContent.m index 723d107a..dee9e430 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -30,7 +30,7 @@ #import "TableSource.h" #import "SPTableInfo.h" #import "TablesList.h" -#import "CMImageView.h" +#import "SPImageView.h" #import "CMCopyTable.h" #import "SPDataCellFormatter.h" #import "SPTableData.h" diff --git a/sequel-pro.xcodeproj/project.pbxproj b/sequel-pro.xcodeproj/project.pbxproj index 43f14515..24a2a732 100644 --- a/sequel-pro.xcodeproj/project.pbxproj +++ b/sequel-pro.xcodeproj/project.pbxproj @@ -104,7 +104,7 @@ 17E6416C0EF01F37001BC333 /* ImageAndTextCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 17E641690EF01F37001BC333 /* ImageAndTextCell.m */; }; 17E641750EF01F80001BC333 /* SPKeychain.m in Sources */ = {isa = PBXBuildFile; fileRef = 17E641740EF01F80001BC333 /* SPKeychain.m */; }; 17E641820EF01FA8001BC333 /* CMCopyTable.m in Sources */ = {isa = PBXBuildFile; fileRef = 17E6417D0EF01FA8001BC333 /* CMCopyTable.m */; }; - 17E641830EF01FA8001BC333 /* CMImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 17E6417F0EF01FA8001BC333 /* CMImageView.m */; }; + 17E641830EF01FA8001BC333 /* SPImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 17E6417F0EF01FA8001BC333 /* SPImageView.m */; }; 17E641840EF01FA8001BC333 /* SPTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 17E641810EF01FA8001BC333 /* SPTextView.m */; }; 17E641C00EF02036001BC333 /* appicon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 17E6418C0EF02036001BC333 /* appicon.icns */; }; 17E641C10EF02036001BC333 /* clearconsole.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 17E6418D0EF02036001BC333 /* clearconsole.tiff */; }; @@ -537,8 +537,8 @@ 17E641740EF01F80001BC333 /* SPKeychain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPKeychain.m; sourceTree = ""; }; 17E6417C0EF01FA8001BC333 /* CMCopyTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CMCopyTable.h; sourceTree = ""; }; 17E6417D0EF01FA8001BC333 /* CMCopyTable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CMCopyTable.m; sourceTree = ""; }; - 17E6417E0EF01FA8001BC333 /* CMImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CMImageView.h; sourceTree = ""; }; - 17E6417F0EF01FA8001BC333 /* CMImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CMImageView.m; sourceTree = ""; }; + 17E6417E0EF01FA8001BC333 /* SPImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPImageView.h; sourceTree = ""; }; + 17E6417F0EF01FA8001BC333 /* SPImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPImageView.m; sourceTree = ""; }; 17E641800EF01FA8001BC333 /* SPTextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPTextView.h; sourceTree = ""; }; 17E641810EF01FA8001BC333 /* SPTextView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPTextView.m; sourceTree = ""; }; 17E6418C0EF02036001BC333 /* appicon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = appicon.icns; sourceTree = ""; }; @@ -1400,8 +1400,8 @@ children = ( 17E6417C0EF01FA8001BC333 /* CMCopyTable.h */, 17E6417D0EF01FA8001BC333 /* CMCopyTable.m */, - 17E6417E0EF01FA8001BC333 /* CMImageView.h */, - 17E6417F0EF01FA8001BC333 /* CMImageView.m */, + 17E6417E0EF01FA8001BC333 /* SPImageView.h */, + 17E6417F0EF01FA8001BC333 /* SPImageView.m */, 17E641800EF01FA8001BC333 /* SPTextView.h */, 17E641810EF01FA8001BC333 /* SPTextView.m */, 58C56EF30F438E120035701E /* SPDataCellFormatter.h */, @@ -2040,7 +2040,7 @@ 17E6416C0EF01F37001BC333 /* ImageAndTextCell.m in Sources */, 17E641750EF01F80001BC333 /* SPKeychain.m in Sources */, 17E641820EF01FA8001BC333 /* CMCopyTable.m in Sources */, - 17E641830EF01FA8001BC333 /* CMImageView.m in Sources */, + 17E641830EF01FA8001BC333 /* SPImageView.m in Sources */, 17E641840EF01FA8001BC333 /* SPTextView.m in Sources */, 58FEF16D0F23D66600518E8E /* SPSQLParser.m in Sources */, 1789343C0F30C1DD0097539A /* SPStringAdditions.m in Sources */, -- cgit v1.2.3