From 2c0baccbe99f52c402d6c0f9882192477c9b5246 Mon Sep 17 00:00:00 2001 From: Johan Paulsson Date: Sat, 30 Nov 2013 19:32:09 -0800 Subject: osx gui: Added dragging of the preview pdf to other applications. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The preview area can be dragged as a pasteboard pdf to other applications rich text editor views. Notably, this means that small images can be made and emailed as PDFs. This is not dragging the PDFs as files so dragging to the finder for saving doesn’t work. --- tikzit/English.lproj/Preview.xib | 499 +++++--------------------------- tikzit/TikZiT.xcodeproj/project.pbxproj | 6 + tikzit/src/osx/DraggablePDFView.h | 28 ++ tikzit/src/osx/DraggablePDFView.m | 56 ++++ tikzit/src/osx/PreviewController.h | 3 +- 5 files changed, 162 insertions(+), 430 deletions(-) create mode 100644 tikzit/src/osx/DraggablePDFView.h create mode 100644 tikzit/src/osx/DraggablePDFView.m (limited to 'tikzit') diff --git a/tikzit/English.lproj/Preview.xib b/tikzit/English.lproj/Preview.xib index 46d3521..cb1e82c 100644 --- a/tikzit/English.lproj/Preview.xib +++ b/tikzit/English.lproj/Preview.xib @@ -1,429 +1,70 @@ - - - - 1050 - 11B26 - 1617 - 1138 - 566.00 - - 1617 - 518 - - - NSView - NSProgressIndicator - NSScrollView - NSWindowTemplate - NSTextView - PDFView - NSScroller - NSCustomObject - - - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.pdfkit.ibplugin - - - - - PreviewController - - - FirstResponder - - - NSApplication - - - 15 - 2 - {{196, 138}, {480, 380}} - 536870912 - Preview - NSWindow - - - - - 256 - - - - 18 - - NSFilenamesPboardType - - {480, 380} - - - 0 - NO - 0.47979798913002014 - YES - - - - -2147483374 - - - - 2304 - - - - 2322 - {478, 14} - - - - - - - - - - - - - - - 134 - - - - 478 - 1 - - - 12129 - 0 - - - 3 - MQA - - - - 6 - System - selectedTextBackgroundColor - - 3 - MC42NjY2NjY2NjY3AA - - - - 6 - System - selectedTextColor - - 3 - MAA - - - - - - - 1 - MCAwIDEAA - - - {8, -8} - 13 - - - - - - 1 - - 6 - {493, 10000000} - {223, 0} - - - - {{1, 1}, {478, 378}} - - - - - - - {4, 5} - - 12582912 - - - - - - TU0AKgAAAHCAFUqgBVKsAAAAwdVQUqwaEQeIRGJRGFlYqwWLQ+JxuOQpVRmEx2RROKwOQyOUQSPyaUym -SxqWyKXyeYxyZzWbSuJTScRCbz2Nz+gRKhUOfTqeUai0OSxiWTiBQSHSGFquGwekxyAgAAAOAQAAAwAA -AAEAEAAAAQEAAwAAAAEAEAAAAQIAAwAAAAIACAAIAQMAAwAAAAEABQAAAQYAAwAAAAEAAQAAAREABAAA -AAEAAAAIARIAAwAAAAEAAQAAARUAAwAAAAEAAgAAARYAAwAAAAEAEAAAARcABAAAAAEAAABnARwAAwAA -AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA - - - - - - 3 - MCAwAA - - - - 4 - - - - 256 - {{464, 1}, {15, 378}} - - - - - _doScroller: - 0.99248120300751874 - - - - -2147483392 - {{-100, -100}, {463, 15}} - - - - 1 - - _doScroller: - 1 - 0.94565218687057495 - - - {480, 380} - - - - 133138 - - - - - - - 1292 - - {{7, 342}, {32, 32}} - - - 28682 - 100 - - - {480, 380} - - - - - {{0, 0}, {1440, 878}} - {10000000000000, 10000000000000} - YES - - - - - - - window - - - - 4 - - - - pdfView - - - - 5 - - - - progressIndicator - - - - 7 - - - - errorText - - - - 12 - - - - errorTextView - - - - 13 - - - - - - 0 - - - - - - -2 - - - File's Owner - - - -1 - - - First Responder - - - -3 - - - Application - - - 1 - - - - - - - - 2 - - - - - - - - - - 3 - - - - - 6 - - - - - 8 - - - - - - - - - - 9 - - - - - 10 - - - - - 11 - - - - - - - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - {{162, 413}, {480, 380}} - - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.pdfkit.ibplugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - - - - - - 13 - - - - - PreviewController - NSWindowController - - NSTextView - NSScrollView - PDFView - NSProgressIndicator - - - - errorText - NSTextView - - - errorTextView - NSScrollView - - - pdfView - PDFView - - - progressIndicator - NSProgressIndicator - - - - IBProjectSource - ./Classes/PreviewController.h - - - - - 0 - IBCocoaFramework - - com.apple.InterfaceBuilder.CocoaPlugin.macosx - - - - com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 - - - YES - 3 - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tikzit/TikZiT.xcodeproj/project.pbxproj b/tikzit/TikZiT.xcodeproj/project.pbxproj index 01e63c7..8b4df9b 100644 --- a/tikzit/TikZiT.xcodeproj/project.pbxproj +++ b/tikzit/TikZiT.xcodeproj/project.pbxproj @@ -129,6 +129,7 @@ 7F6E2C8916B0091300BFE20D /* maths.m in Sources */ = {isa = PBXBuildFile; fileRef = 7F6E2C8716B0091300BFE20D /* maths.m */; }; 7F6E2C8A16B0096000BFE20D /* SupportDir.m in Sources */ = {isa = PBXBuildFile; fileRef = 55652DF813E1F2030023F4C6 /* SupportDir.m */; }; 7F6E2C8C16B00ABA00BFE20D /* SFBInspectors.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 55CA98D412EF8FCE008F0368 /* SFBInspectors.framework */; }; + 7F73438A184AC559002897D0 /* DraggablePDFView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7F734389184AC559002897D0 /* DraggablePDFView.m */; }; 7F781C1A16B5DE1400239826 /* ParseErrorView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7F781C1916B5DE1400239826 /* ParseErrorView.m */; }; 7F90E88616DD29600069EBCD /* NSString+Tikz.m in Sources */ = {isa = PBXBuildFile; fileRef = 7F90E88516DD29600069EBCD /* NSString+Tikz.m */; }; 7F90E88D16DD47540069EBCD /* PreferenceController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7F90E88B16DD47540069EBCD /* PreferenceController.m */; }; @@ -370,6 +371,8 @@ 55F9E04411FF54F000F5659E /* NSString+LatexConstants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSString+LatexConstants.m"; path = "src/common/NSString+LatexConstants.m"; sourceTree = ""; }; 55FF4E64116A401B000C22B4 /* libicucore.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libicucore.dylib; path = usr/lib/libicucore.dylib; sourceTree = SDKROOT; }; 7F6E2C8716B0091300BFE20D /* maths.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = maths.m; path = src/common/test/maths.m; sourceTree = ""; }; + 7F734388184AC559002897D0 /* DraggablePDFView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DraggablePDFView.h; path = src/osx/DraggablePDFView.h; sourceTree = ""; }; + 7F734389184AC559002897D0 /* DraggablePDFView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DraggablePDFView.m; path = src/osx/DraggablePDFView.m; sourceTree = ""; }; 7F781C1816B5DE1400239826 /* ParseErrorView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ParseErrorView.h; path = src/osx/ParseErrorView.h; sourceTree = ""; }; 7F781C1916B5DE1400239826 /* ParseErrorView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ParseErrorView.m; path = src/osx/ParseErrorView.m; sourceTree = ""; }; 7F90E88416DD29600069EBCD /* NSString+Tikz.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSString+Tikz.h"; path = "src/common/NSString+Tikz.h"; sourceTree = ""; }; @@ -573,6 +576,8 @@ 5573B8BF11D9FD1800B5DC5D /* Preview */ = { isa = PBXGroup; children = ( + 7F734388184AC559002897D0 /* DraggablePDFView.h */, + 7F734389184AC559002897D0 /* DraggablePDFView.m */, 5573B8C011D9FD3200B5DC5D /* PreviewController.h */, 5573B8C111D9FD3200B5DC5D /* PreviewController.m */, ); @@ -902,6 +907,7 @@ 558F18F7117B043C009863B2 /* AppDelegate.m in Sources */, 558F18F9117B043C009863B2 /* EdgeControlLayer.m in Sources */, 558F18FA117B043C009863B2 /* GraphicsView.m in Sources */, + 7F73438A184AC559002897D0 /* DraggablePDFView.m in Sources */, 558F18FB117B043C009863B2 /* Grid.m in Sources */, 558F18FC117B043C009863B2 /* NodeLayer.m in Sources */, 558F18FD117B043C009863B2 /* NodeSelectionLayer.m in Sources */, diff --git a/tikzit/src/osx/DraggablePDFView.h b/tikzit/src/osx/DraggablePDFView.h new file mode 100644 index 0000000..9e53c44 --- /dev/null +++ b/tikzit/src/osx/DraggablePDFView.h @@ -0,0 +1,28 @@ +// +// PreviewController.h +// TikZiT +// +// Copyright 2010 Aleks Kissinger. All rights reserved. +// +// +// This file is part of TikZiT. +// +// TikZiT 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 3 of the License, or +// (at your option) any later version. +// +// TikZiT 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 TikZiT. If not, see . +// + +#import + +@interface DraggablePDFView : PDFView + +@end diff --git a/tikzit/src/osx/DraggablePDFView.m b/tikzit/src/osx/DraggablePDFView.m new file mode 100644 index 0000000..ce57473 --- /dev/null +++ b/tikzit/src/osx/DraggablePDFView.m @@ -0,0 +1,56 @@ +// +// PreviewController.h +// TikZiT +// +// Copyright 2010 Aleks Kissinger. All rights reserved. +// +// +// This file is part of TikZiT. +// +// TikZiT 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 3 of the License, or +// (at your option) any later version. +// +// TikZiT 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 TikZiT. If not, see . +// + +#import "DraggablePDFView.h" + +@implementation DraggablePDFView + +- (id)initWithFrame:(NSRect)frame +{ + self = [super initWithFrame:frame]; + return self; +} + +- (void)drawRect:(NSRect)dirtyRect +{ + [super drawRect:dirtyRect]; +} + +- (void)mouseDown:(NSEvent *)theEvent +{ + NSPasteboard *pboard; + + NSRect pageBox = [[[self document] pageAtIndex:0] boundsForBox:kPDFDisplayBoxMediaBox]; + NSRect pageRect= [self convertRect:pageBox fromPage:[[self document] pageAtIndex:0]]; + + pboard = [NSPasteboard pasteboardWithName:NSDragPboard]; + [pboard declareTypes:[NSArray arrayWithObject:NSPasteboardTypePDF] owner:self]; + [pboard setData:[[self document] dataRepresentation] forType:NSPasteboardTypePDF]; + + [self dragImage:[[NSImage alloc] initWithData:[[self document] dataRepresentation]] at:pageRect.origin offset:pageRect.size + event:theEvent pasteboard:pboard source:self slideBack:YES]; + + return; +} + +@end diff --git a/tikzit/src/osx/PreviewController.h b/tikzit/src/osx/PreviewController.h index d6d855e..6c51a23 100644 --- a/tikzit/src/osx/PreviewController.h +++ b/tikzit/src/osx/PreviewController.h @@ -23,12 +23,13 @@ #import +#import "DraggablePDFView.h" @class PDFView; @class PreambleController; @interface PreviewController : NSWindowController { - IBOutlet PDFView *pdfView; + IBOutlet DraggablePDFView *pdfView; IBOutlet NSProgressIndicator *progressIndicator; IBOutlet NSScrollView *errorTextView; IBOutlet NSTextView *errorText; -- cgit v1.2.3