Mercurial > dwindows
comparison mac/dw.m @ 1237:f8673299ec37
Ok if we setup the print information on Mac we get a better size...
and we don't need to do adjustments down the line.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 18 Oct 2011 06:28:43 +0000 |
parents | 46de4dbe710d |
children | 7ec60b650e5b |
comparison
equal
deleted
inserted
replaced
1236:46de4dbe710d | 1237:f8673299ec37 |
---|---|
9621 print->drawdata = drawdata; | 9621 print->drawdata = drawdata; |
9622 print->flags = flags; | 9622 print->flags = flags; |
9623 | 9623 |
9624 /* Get the page range */ | 9624 /* Get the page range */ |
9625 pi = [NSPrintInfo sharedPrintInfo]; | 9625 pi = [NSPrintInfo sharedPrintInfo]; |
9626 [pi setHorizontalPagination:NSFitPagination]; | |
9627 [pi setHorizontallyCentered:YES]; | |
9628 [pi setVerticalPagination:NSFitPagination]; | |
9629 [pi setVerticallyCentered:YES]; | |
9630 [pi setOrientation:NSLandscapeOrientation]; | |
9631 [pi setLeftMargin:0.0]; | |
9632 [pi setRightMargin:0.0]; | |
9633 [pi setTopMargin:0.0]; | |
9634 [pi setBottomMargin:0.0]; | |
9635 | |
9626 settings = [pi PMPrintSettings]; | 9636 settings = [pi PMPrintSettings]; |
9627 PMSetPageRange(settings, 1, pages); | 9637 PMSetPageRange(settings, 1, pages); |
9628 PMSetFirstPage(settings, 1, true); | 9638 PMSetFirstPage(settings, 1, true); |
9629 PMSetLastPage(settings, pages, true); | 9639 PMSetLastPage(settings, pages, true); |
9630 PMPrintSettingsSetJobName(settings, (CFStringRef)[NSString stringWithUTF8String:jobname]); | 9640 PMPrintSettingsSetJobName(settings, (CFStringRef)[NSString stringWithUTF8String:jobname]); |
9670 | 9680 |
9671 /* Figure out the printer/paper size */ | 9681 /* Figure out the printer/paper size */ |
9672 pi = p->pi; | 9682 pi = p->pi; |
9673 size = [pi paperSize]; | 9683 size = [pi paperSize]; |
9674 | 9684 |
9675 /* Okay the size reported is really small... and everything | |
9676 * in Cocoa is scaled so ... multiply by 2 to get a better | |
9677 * resolution but maintain the right aspect ratio. | |
9678 */ | |
9679 size.width *= 2; | |
9680 size.height *= 2; | |
9681 | |
9682 /* Get the page range */ | 9685 /* Get the page range */ |
9683 settings = [pi PMPrintSettings]; | 9686 settings = [pi PMPrintSettings]; |
9684 PMGetFirstPage(settings, &start); | 9687 PMGetFirstPage(settings, &start); |
9685 if(start > 0) | 9688 if(start > 0) |
9686 start--; | 9689 start--; |
9687 PMGetLastPage(settings, &end); | 9690 PMGetLastPage(settings, &end); |
9688 PMSetPageRange(settings, 1, 1); | 9691 PMSetPageRange(settings, 1, 1); |
9689 PMSetFirstPage(settings, 1, true); | 9692 PMSetFirstPage(settings, 1, true); |
9690 PMSetLastPage(settings, 1, true); | 9693 PMSetLastPage(settings, 1, true); |
9691 [pi updateFromPMPrintSettings]; | 9694 [pi updateFromPMPrintSettings]; |
9692 | |
9693 /* Adjust the image size according to | |
9694 * the number of pages to be printed. | |
9695 */ | |
9696 if((end - start) > 1) | |
9697 size.height /= (end - start); | |
9698 | 9695 |
9699 /* Create an image view to print and a pixmap to draw into */ | 9696 /* Create an image view to print and a pixmap to draw into */ |
9700 iv = [[NSImageView alloc] init]; | 9697 iv = [[NSImageView alloc] init]; |
9701 pixmap = dw_pixmap_new(iv, (int)size.width, (int)size.height, 8); | 9698 pixmap = dw_pixmap_new(iv, (int)size.width, (int)size.height, 8); |
9702 rep = pixmap->image; | 9699 rep = pixmap->image; |