Implement printing

This commit is contained in:
Matthias Neeracher 2007-04-18 08:25:43 +00:00
parent 3312d2ecc0
commit 1839222754
2 changed files with 28 additions and 0 deletions

View File

@ -13,6 +13,7 @@
@class VLSheetWindow; @class VLSheetWindow;
@class VLPDFWindow; @class VLPDFWindow;
@class VLLogWindow; @class VLLogWindow;
@class PDFDocument;
@interface VLDocument : NSDocument @interface VLDocument : NSDocument
{ {
@ -34,6 +35,7 @@
VLLogWindow * logWin; VLLogWindow * logWin;
VLPDFWindow * pdfWin; VLPDFWindow * pdfWin;
VLKeyValueUndo* undo; VLKeyValueUndo* undo;
PDFDocument * printDoc;
} }
- (VLSong *) song; - (VLSong *) song;

View File

@ -11,11 +11,18 @@
#import "VLLilypondDocument.h" #import "VLLilypondDocument.h"
#import "VLMMADocument.h" #import "VLMMADocument.h"
#import "VLMIDIDocument.h" #import "VLMIDIDocument.h"
#import "VLPDFDocument.h"
#import "VLPDFWindow.h" #import "VLPDFWindow.h"
#import "VLLogWindow.h" #import "VLLogWindow.h"
#import "VLSheetWindow.h" #import "VLSheetWindow.h"
#import "VLSoundOut.h" #import "VLSoundOut.h"
#import <Quartz/Quartz.h>
@interface PDFDocument (PDFKitSecretsIKnow)
- (NSPrintOperation *)getPrintOperationForPrintInfo:(NSPrintInfo *)printInfo autoRotate:(BOOL)doRotate;
@end
@interface VLSongWrapper : NSObject { @interface VLSongWrapper : NSObject {
VLSong * wrappedSong; VLSong * wrappedSong;
} }
@ -87,6 +94,7 @@
@"", @"songGroove", @"", @"songGroove",
@"", @"songTempo", @"", @"songTempo",
nil]]; nil]];
printDoc = nil;
} }
return self; return self;
} }
@ -421,6 +429,24 @@
[pdfWin reloadPDF]; [pdfWin reloadPDF];
} }
- (NSPrintOperation *)printOperationWithSettings:(NSDictionary *)printSettings
error:(NSError **)outError
{
[self createTmpFileWithExtension:@"pdf" ofType:@"VLPDFType"];
[printDoc autorelease];
printDoc = [[PDFDocument alloc] initWithURL:[self fileURLWithExtension:@"pdf"]];
NSPrintOperation *printOperation = [printDoc getPrintOperationForPrintInfo:[self printInfo] autoRotate:NO];
// Specify that the print operation can run in a separate thread. This will cause the print progress panel to appear as a sheet on the document window.
[printOperation setCanSpawnSeparateThread:YES];
// Set any print settings that might have been specified in a Print Document Apple event.
[[[printOperation printInfo] dictionary] addEntriesFromDictionary:printSettings];
return printOperation;
}
- (IBAction) showLog:(id)sender - (IBAction) showLog:(id)sender
{ {
[[self logWin] showWindow:sender]; [[self logWin] showWindow:sender];