From e0c22a9c7d1098733d1daa380939dba0b4ddc0a3 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sun, 4 Dec 2011 12:39:38 +1100 Subject: Documentation of prining on Cocoa and GTK+ 3. --- doc/ScintillaDoc.html | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'doc/ScintillaDoc.html') diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index c68fcc0fd..242f3788d 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -4574,10 +4574,17 @@ struct Sci_TextToFind {

Printing

-

On Windows SCI_FORMATRANGE can be used to draw the text onto a display context - which can include a printer display context. Printed output shows text styling as on the +

SCI_FORMATRANGE can be used to draw the text onto a display surface + which can include a printer display surface. Printed output shows text styling as on the screen, but it hides all margins except a line number margin. All special marker effects are removed and the selection and caret are hidden.

+ +

Different platforms use different display surface ID types to print on. On Windows, these are + HDCs., on GTK+ 3.x cairo_t *, + and on Cocoa CGContextRef is used.

+ +

SCI_FORMATRANGE is not supported on GTK+ 2.x.

+ SCI_FORMATRANGE(bool bDraw, Sci_RangeToFormat *pfr)
SCI_SETPRINTMAGNIFICATION(int @@ -4590,7 +4597,7 @@ struct Sci_TextToFind {

SCI_FORMATRANGE(bool bDraw, Sci_RangeToFormat *pfr)
- This call allows Windows users to render a range of text into a device context. If you use + This call renders a range of text into a device context. If you use this for printing, you will probably want to arrange a page header and footer; Scintilla does not do this for you. See SciTEWin::Print() in SciTEWinDlg.cxx for an example. Each use of this message renders a range of text into a rectangular area and returns @@ -4603,15 +4610,15 @@ struct Sci_TextToFind { struct Sci_Rectangle { int left; int top; int right; int bottom; }; struct Sci_RangeToFormat { - Sci_SurfaceID hdc; // The HDC (device context) we print to - Sci_SurfaceID hdcTarget; // The HDC we use for measuring (may be same as hdc) + Sci_SurfaceID hdc; // The Surface ID we print to + Sci_SurfaceID hdcTarget; // The Surface ID we use for measuring (may be same as hdc) Sci_Rectangle rc; // Rectangle in which to print Sci_Rectangle rcPage; // Physically printable page size Sci_CharacterRange chrg; // Range of characters to print }; -

hdc and hdcTarget should both be set to the device context handle +

On Windows, hdc and hdcTarget should both be set to the device context handle of the output device (usually a printer). If you print to a metafile these will not be the same as Windows metafiles (unlike extended metafiles) do not implement the full API for returning information. In this case, set hdcTarget to the screen DC.
@@ -4622,6 +4629,17 @@ struct Sci_RangeToFormat { chrg.cpMin and chrg.cpMax define the start position and maximum position of characters to output. All of each line within this character range is drawn.

+

On Cocoa, the surface IDs for printing (bDraw=1) should be the graphics port of the current context + ((CGContextRef) [[NSGraphicsContext currentContext] graphicsPort]) when the view's drawRect method is called. + The Surface IDs are not really used for measurement (bDraw=0) but can be set + to a bitmap context (created with CGBitmapContextCreate) to avoid runtime warnings.

+ +

On GTK+, the surface IDs to use can be found from the printing context with + gtk_print_context_get_cairo_context(context).

+ + chrg.cpMin and chrg.cpMax define the start position and maximum + position of characters to output. All of each line within this character range is drawn.

+

When printing, the most tedious part is always working out what the margins should be to allow for the non-printable area of the paper and printing a header and footer. If you look at the printing code in SciTE, you will find that most of it is taken up with this. The loop that -- cgit v1.2.3