Fl_Printer Class Reference

Provides an OS-independent interface to printing under MSWindows and Mac OS X. More...

#include <Fl_Printer.H>

List of all members.

Public Member Functions

 Fl_Printer (void)
 The constructor.
int start_job (int pagecount, int *frompage=NULL, int *topage=NULL)
 Starts a print job.
int start_page (void)
 Starts a new printed page.
int printable_rect (int *x, int *y, int *w, int *h)
 Computes the origin and size of the printable area of the page.
void origin (int x, int y)
 Sets the position in page coordinates of the origin of graphics functions.
void origin (int *x, int *y)
 Computes the page coordinates of the current origin of graphics functions.
void scale (float scale_x, float scale_y)
 Changes the scaling of page coordinates.
void print_widget (Fl_Widget *widget, int delta_x=0, int delta_y=0)
 Draws the widget on the printed page.
int end_page (void)
 To be called at the end of each page.
void end_job (void)
 To be called at the end of a print job.


Detailed Description

Provides an OS-independent interface to printing under MSWindows and Mac OS X.

At present, this class is only implemented for MSWindows and Mac OS X. It allows to use all FLTK drawing, color, text, and clip functions, and to have them operate on printed page(s). There are two main ways to use it.

In both cases, begin by start_job(), start_page(), printable_rect() and origin() calls and finish by end_page() and end_job() calls.

Member Function Documentation

int Fl_Printer::end_page ( void   ) 

To be called at the end of each page.

Returns:
0 iff OK.

void Fl_Printer::origin ( int *  x,
int *  y 
)

Computes the page coordinates of the current origin of graphics functions.

Parameters:
[out] x If non-null, *x is set to the horizontal page offset of graphics origin.
[out] y Same as above, vertically.

void Fl_Printer::origin ( int  x,
int  y 
)

Sets the position in page coordinates of the origin of graphics functions.

Arguments should be expressed relatively to the result of a previous printable_rect() call. That is, printable_rect(&x, &y, &w, &h); origin(x, y); sets the graphics origin at the top left of the page printable area. Successive origin() calls don't combine their effects.

Parameters:
[in] x Horizontal position in page coordinates of the desired origin of graphics functions.
[in] y Same as above, vertically.

void Fl_Printer::print_widget ( Fl_Widget *  widget,
int  delta_x = 0,
int  delta_y = 0 
)

Draws the widget on the printed page.

The widget's position on the printed page is determined by a previous call to origin() and by the optional delta_x and delta_y arguments. Its dimensions are in points unless there was a previous call to scale().

Parameters:
[in] widget Any FLTK widget (e.g., standard, custom, window).
[in] delta_x Optional horizontal offset for positioning the widget relatively to the current origin of graphics functions.
[in] delta_y Same as above, vertically.

int Fl_Printer::printable_rect ( int *  x,
int *  y,
int *  w,
int *  h 
)

Computes the origin and size of the printable area of the page.

Values are in the same unit as that used by FLTK drawing functions, are unchanged by calls to origin(), but are changed by scale() calls. Values account for the user-selected paper type and print orientation.

Returns:
0 iff OK.

void Fl_Printer::scale ( float  scale_x,
float  scale_y 
)

Changes the scaling of page coordinates.

After a scale() call, do a printable_rect() call to get the new coordinates of the printable page area. Successive scale() calls don't combine their effects.

Parameters:
scale_x Horizontal dimensions of plot are multiplied by this quantity.
scale_y Same as above, vertically.

int Fl_Printer::start_job ( int  pagecount,
int *  frompage = NULL,
int *  topage = NULL 
)

Starts a print job.

Parameters:
[in] pagecount the total number of pages of the job
[out] frompage if non-null, *frompage is set to the first page the user wants printed
[out] topage if non-null, *topage is set to the last page the user wants printed
Returns:
0 iff OK

int Fl_Printer::start_page ( void   ) 

Starts a new printed page.

The page coordinates are initially in points, i.e., 1/72 inch, and with origin at the top left of the page or of the printable page area.

Returns:
0 iff OK


The documentation for this class was generated from the following file:

Generated on Sun Feb 7 09:03:10 2010 for FlPrinter by  doxygen 1.5.9