comparison mac/dw.m @ 1234:bee6fc8119ec

Paper size reported on Mac height is for all pages... so divide height by the number of pages to get the single page size.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 17 Oct 2011 07:41:14 +0000
parents 75a773cdb626
children 9327f684c9b8
comparison
equal deleted inserted replaced
1233:365f92e85771 1234:bee6fc8119ec
9632 return result; 9632 return result;
9633 9633
9634 /* Figure out the printer/paper size */ 9634 /* Figure out the printer/paper size */
9635 pi = p->pi; 9635 pi = p->pi;
9636 size = [pi paperSize]; 9636 size = [pi paperSize];
9637
9637 /* Okay the size reported is really small... and everything 9638 /* Okay the size reported is really small... and everything
9638 * in Cocoa is scaled so ... multiply by 2 to get a better 9639 * in Cocoa is scaled so ... multiply by 2 to get a better
9639 * resolution but maintain the right aspect ratio. 9640 * resolution but maintain the right aspect ratio.
9640 */ 9641 */
9641 size.width *= 2; 9642 size.width *= 2;
9642 size.height *= 2; 9643 size.height *= 2;
9644
9645 /* Get the page range */
9646 settings = [pi PMPrintSettings];
9647 PMGetFirstPage(settings, &start);
9648 if(start > 0)
9649 start--;
9650 PMGetLastPage(settings, &end);
9651 PMSetPageRange(settings, 1, 1);
9652 PMSetFirstPage(settings, 1, true);
9653 PMSetLastPage(settings, 1, true);
9654 [pi updateFromPMPrintSettings];
9655
9656 /* Adjust the image size according to
9657 * the number of pages to be printed.
9658 */
9659 if((end - start) > 1)
9660 size.height /= (end - start);
9661
9643 /* Create an image view to print and a pixmap to draw into */ 9662 /* Create an image view to print and a pixmap to draw into */
9644 iv = [[NSImageView alloc] init]; 9663 iv = [[NSImageView alloc] init];
9645 pixmap = dw_pixmap_new(iv, (int)size.width, (int)size.height, 8); 9664 pixmap = dw_pixmap_new(iv, (int)size.width, (int)size.height, 8);
9646 rep = pixmap->image; 9665 rep = pixmap->image;
9647 pixmap2 = dw_pixmap_new(iv, (int)size.width, (int)size.height, 8); 9666 pixmap2 = dw_pixmap_new(iv, (int)size.width, (int)size.height, 8);
9663 * print info obtained from the panel in the last call. 9682 * print info obtained from the panel in the last call.
9664 */ 9683 */
9665 po = [NSPrintOperation printOperationWithView:iv printInfo:pi]; 9684 po = [NSPrintOperation printOperationWithView:iv printInfo:pi];
9666 [po setShowsPrintPanel:NO]; 9685 [po setShowsPrintPanel:NO];
9667 9686
9668 /* Get the page range */
9669 settings = [pi PMPrintSettings];
9670 PMGetFirstPage(settings, &start);
9671 if(start > 0)
9672 start--;
9673 PMGetLastPage(settings, &end);
9674 PMSetPageRange(settings, 1, 1);
9675 PMSetFirstPage(settings, 1, true);
9676 PMSetLastPage(settings, 1, true);
9677 [pi updateFromPMPrintSettings];
9678
9679 /* Cycle through each page */ 9687 /* Cycle through each page */
9680 for(x=start; x<end && p->drawfunc; x++) 9688 for(x=start; x<end && p->drawfunc; x++)
9681 { 9689 {
9682 /* Call the application's draw function */ 9690 /* Call the application's draw function */
9683 p->drawfunc(print, pixmap, x, p->drawdata); 9691 p->drawfunc(print, pixmap, x, p->drawdata);