Previous: Method printing parameters, Up: Printing whole methods



8.4.2 Using the printmethod object

Before printing a method using a printmethod object, two things must be set up: the object must be given a method to print, and the parameters for printing described in the previous section must be initialised.

The class has two constructors:

— Constructor: printmethod::printmethod (void);
— Constructor: printmethod::printmethod (const method& m);

These two constructors create a printmethod object. In the first case, no method is specified; a method will have to be given later, before anything can be printed. In the second case, a reference to the method m is stored for printing after the parameters have been set up.

After the object has been created, the method can be queried and changed with these functions:

— Function: const method& printmethod::get_method (void);

This returns the method referred to by this printmethod object.

— Function: void printmethod::set_method (const method& m);

This function stored a reference to the method m in the printmethod object, for subsequence printing.

The parameters for printing, described in the previous section, may be manipulated with several member functions.

— Function: void printmethod::defaults (void);

This function sets the parameters to default values, which relate to the method to be printed; so it should not be called before a method has been given to the printmethod object. Specifically, the parameters are set as follows:

— Function: void printmethod::fit_to_space (const dimension& width, const dimension& height, bool vgap_mode, float aspect);

This function scales and arranges the method to fit in the given space, as specified by width and height. The parameters which are calculated by this function are rows_per_column, columns_per_set, hgap, vgap, opt.style.size, opt.xspace and opt.yspace. Two possible layouts are possible: if vgap_mode is false, then only one column set is used, with each column containing a whole number of leads; if vgap_mode is true, then each column contains precisely one lead, and as many column sets as necessary are used. The effect of this is that, in the first case, the second lead appears below the first one; in the second case, the second lead appears to the right of the first one. The last argument aspect sets the ratio of opt.xspace to opt.yspace.

The chosen layout is that which, given the constraints specified, allows the largest of output.

— Function: float printmethod::total_width (void);
— Function: float printmethod::total_height (void);

These functions give the total width and height, respectively, in points of the printed output using the current parameters.