diff options
author | Bibiko <bibiko@eva.mpg.de> | 2011-01-28 11:54:24 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2011-01-28 11:54:24 +0000 |
commit | 060dc8cbdf8b6e60608e8111fe66f9c03c3af16b (patch) | |
tree | 9db3624003c22c9c02ad1581307056a7b73abf9f /Source | |
parent | ac804c2e6a6a4d0734e59d6fcd58933526b1452d (diff) | |
download | sequelpro-060dc8cbdf8b6e60608e8111fe66f9c03c3af16b.tar.gz sequelpro-060dc8cbdf8b6e60608e8111fe66f9c03c3af16b.tar.bz2 sequelpro-060dc8cbdf8b6e60608e8111fe66f9c03c3af16b.zip |
• improved print capability of the HTML output window
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPBundleHTMLOutputController.m | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/Source/SPBundleHTMLOutputController.m b/Source/SPBundleHTMLOutputController.m index 9fee7358..43ff1d1e 100644 --- a/Source/SPBundleHTMLOutputController.m +++ b/Source/SPBundleHTMLOutputController.m @@ -24,6 +24,7 @@ #import "SPBundleHTMLOutputController.h" #import "SPAlertSheets.h" +#import "SPPrintAccessory.h" @class WebScriptCallFrame; @@ -178,7 +179,49 @@ - (IBAction)printDocument:(id)sender { - [[[[webView mainFrame] frameView] documentView] print:sender]; + + NSPrintInfo *printInfo = [NSPrintInfo sharedPrintInfo]; + + NSSize paperSize = [printInfo paperSize]; + NSRect printableRect = [printInfo imageablePageBounds]; + + // Calculate page margins + CGFloat marginL = printableRect.origin.x; + CGFloat marginR = paperSize.width - (printableRect.origin.x + printableRect.size.width); + CGFloat marginB = printableRect.origin.y; + CGFloat marginT = paperSize.height - (printableRect.origin.y + printableRect.size.height); + + // Make sure margins are symetric and positive + CGFloat marginLR = MAX(0, MAX(marginL, marginR)); + CGFloat marginTB = MAX(0, MAX(marginT, marginB)); + + // Set the margins + [printInfo setLeftMargin:marginLR]; + [printInfo setRightMargin:marginLR]; + [printInfo setTopMargin:marginTB]; + [printInfo setBottomMargin:marginTB]; + + [printInfo setHorizontalPagination:NSFitPagination]; + [printInfo setVerticalPagination:NSFitPagination]; + [printInfo setVerticallyCentered:NO]; + + NSPrintOperation *op = [NSPrintOperation printOperationWithView:[[[webView mainFrame] frameView] documentView] printInfo:printInfo]; + + // Perform the print operation on a background thread + [op setCanSpawnSeparateThread:YES]; + + // Add the ability to select the orientation to print panel + NSPrintPanel *printPanel = [op printPanel]; + + [printPanel setOptions:[printPanel options] + NSPrintPanelShowsOrientation + NSPrintPanelShowsScaling + NSPrintPanelShowsPaperSize]; + + [op setPrintPanel:printPanel]; + + [op runOperationModalForWindow:[self window] + delegate:self + didRunSelector:nil + contextInfo:nil]; + } - (void)showSourceCode |