/usr/share/SuperCollider/HelpSource/Classes/QPenPrinter.schelp is in supercollider-common 1:3.8.0~repack-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | CLASS:: QPenPrinter
summary:: QPen PDF export and printing of vector graphics
categories:: GUI>Accessories
related:: Classes/Pen
DESCRIPTION::
QPenPrinter allows Pen to operate on a printer device. The graphics can be exported to PDF by using "print to file" as printer device.
CLASSMETHODS::
private:: qtClass
METHOD:: new
Create a new QPenPrinter object.
returns:: an instance of QPenPrinter
METHOD:: print
Convenience function to show a print dialog and print.
argument:: printFunc
A link::Classes/Function:: to be evaluated when the user presses "Print", with the printer object as Pen painter target.
See strong::aPrintFunc:: in link::#-print:: below.
argument:: cancelFunc
An optional link::Classes/Function:: to be evaluated if the user presses "Cancel".
INSTANCEMETHODS::
private:: init
subsection:: Printing
METHOD:: showDialog
Shows a Print Dialog to allow the user to configure the printer object. This is asynchronous and the method will return immediately.
When the user presses the "Print" button, strong::aOkFunc:: is called with this QPenPrinter object as argument.
argument:: aOkFunc
A link::Classes/Function:: to be evaluated when the user presses "Print".
argument:: aCancelFunc
An optional link::Classes/Function:: to be evaluated if the user presses "Cancel".
METHOD:: print
This method does the actual printing or PDF export. It evaluates strong::aPrintFunc:: with the printer object as Pen painter target. This QPenPrinter object is passed as the argument.
All the ordinary link::Classes/Pen:: commands can be used inside the function.
argument:: aPrintFunc
A link::Classes/Function:: to be evaluated to draw the graphics.
discussion::
If this method is called without configuring the printer object first, it will print on the default printer with default settings.
This method is typically called from within the strong::aOkFunc:: of link::#-showDialog:: above. After showDialog has configured the printer once, this method can be called multiple times to reuse the last printer configuration.
The point at (0@0) will coincide with the origin of link::#-pageRect::, which is offset by the page margins. So you don't need to translate the Pen.
METHOD:: newPage
Starts a new page. Typically called within the strong::aPrintFunc:: of link::#-print::.
subsection:: Properties
METHOD:: paperRect
Get the paper bounds.
returns:: a link::Classes/Rect::
METHOD:: pageRect
Get the page bounds, which is the printable area and usually smaller than link::#-paperRect:: due to margins.
returns:: a link::Classes/Rect::
discussion::
The strong::origin:: of the Rect is relative to the paper, and will be non-zero due to margins.
METHOD:: pageSize
Get the page size as a Size.
returns:: a link::Classes/Size::
discussion::
This can be used to scale the graphics to fit the page if the bounds of the graphics is known:
code::
x = penPrinter.pageSize.width / bounds.width;
Pen.scale(x,x);
// ... draw stuff here ...
::
subsection:: Page range
The methods below returns the page range selected by the user. Page number starts at 1. When both methods returns 0 it means "print all pages".
METHOD:: fromPage
Get the start page.
returns:: an link::Classes/Integer::
METHOD:: toPage
Get the end page.
returns:: an link::Classes/Integer::
EXAMPLES::
Simple usage:
code::
QPenPrinter.print {
// first page
Pen.moveTo(100@100);
Pen.lineTo(300@300);
Pen.stroke;
// second page
p.newPage;
Pen.addRect(p.pageSize.asRect);
Pen.stroke;
}
::
Keep the QPenPrinter object to save configuration state:
code::
p = QPenPrinter();
::
The code below can then be called multiple times:
code::
p.showDialog {
p.print {
// first page
Pen.moveTo(100@100);
Pen.lineTo(300@300);
Pen.stroke;
// second page
p.newPage;
Pen.addRect(p.pageSize.asRect);
Pen.stroke;
}
} {
"Printing cancelled!".postln;
};
::
|