In this section:
Here is a simple program that uses the standard call-back GPRINTER_OPEN to respond to a button press and draws a diagonal line across the entire page. GPRINTER_OPEN creates a drawing surface and an additional call-back argument is used to contain code to draw to this surface.
INTEGER FUNCTION test()
Notice that the call to GET_GRAPHICAL_RESOLUTION@ will work for all types of drawing surfaces. This means that the same code can be used to generate graphics output to the screen and to the printer.
Notice also that by default the drawing surface for the printer uses VGA rather than RGB mode. So in this example, the colour for DRAW_LINE_BETWEEN@ is provided as a colour index (15 represents intense white in this program) rather than an RGB value. Normally RGB mode is preferred and this requires a prior call of USE_RGB_COLOURS@(0,.true.) (see the example in Using a metafile to print multiple copies).
By using open_printer@ etc., it is possible to have two drawing surfaces, one attached to the screen and the other to a graphics printer or plotter. In the following example one identifier is attached to a %gr (Graphics Region) region (a screen drawing surface) whilst a second identifier is attached to a graphics printer drawing surface.
As usual, open_printer@ generates a standard "Open Printer" dialog box from which the user selects a graphics printer or plotter. Subsequent calls to ClearWin+ drawing routines are written to this drawing surface and the output is generated when the ClearWin+ routine CLOSE_PRINTER@ or the routine NEW_PAGE@ is called.
• OPEN_PRINTER@ etc. may be used independently of winio@.
• In the above example, j and k can be used to test for the success of the associated function calls.
• Printer surfaces will use GDI+ features if they are turned on.
• PRINT_GRAPHICS@ will help manage printing.