The Spool Library: 6 Page Size Control

Up: GEOS SDK TechDocs | Up | Prev: 5 Print Control Messages | Next: 7 Other Printing Components
MSG_PRINT_REPORT_PAGE_SIZE, SpoolSetDocSize(), MSG_PZC_GET_PAGE_SIZE, MSG_PZC_SET_PAGE_SIZE, 

Thanks to the Spooler, applications don't need to worry about what page size the user is working with. If a document is bigger than a printer's paper, then the Spooler will automatically tile the job onto as may sheets of paper as necessary. However, some applications will need to make the user decide on a page size. Page layout programs need to know what size page the user is working with. Spreadsheet programs need to make sure that cells aren't split in half by a page break.

Applications which ask the user to select a page size should incorporate a PageSizeControl into their generic tree. This generic control object provides a dialog box containing page setup choices for the user.

This dialog box contains UI allowing the user to specify what sort of paper the document is to be printed to: envelope, labels, or regular paper. The user may then specify a set of dimensions within that type; paper would have choices including letter sized, legal sized, and A4. The user can even set up a set of custom page dimensions.

Most applications which include a PageSizeControl will probably keep track of their own page size. In this case, use SpoolSetDocSize() to update the PageSizeControl's UI when changing the page size. When the user changes the paper size in the PageSizeControl, the control's output will receive a MSG_PRINT_REPORT_PAGE_SIZE .

Applications which do not keep track of the page size but want to include a PageSizeControl may do so. However, these applications will probably need to find out the page size at a specific time, not just receive notification every time the user changes the page size. This doesn't really fit the normal controller model, and in fact such applications are asking the PageSizeControl to act not like a controller, but like an ordinary piece of UI gadgetry. Setting the PZCA_ACT_LIKE_GADGET flag in the PageSizeControl's PZCI_attrs instance field will make the PageSizeControl act like a gadget.

If the PageSizeControl is to act as a controller, it must appear on the GenApplication's GAGCNLT_SELF_LOAD_OPTIONS GCN list, as does the PrintControl.

No matter how an application interacts with its PageSizeControl, it will work with the PageSizeReport structure.

  typedef struct {
	dword 			PSR_width;
	dword 			PSR_height;
	PageLayout 			PSR_layout;
	PCMarginParams 			PSR_margins;
} PageSizeReport;
 typedef WordFlags PageLayout;
  typedef enum {
	PT_PAPER,
	PT_UNUSED1, /* Unused type */
	PT_ENVELOPE,
	PT_UNUSED2, /* Unused type */
	PT_LABEL
} PageType;
/* Specifying a PageLayout is accomplished by 
 * OR-ing together the parts of the layout.
 * Exactly what those parts are depends on the 
 * PageType: */
/* Paper Layouts: 
 * 	(PT_PAPER | (PO_orient << 3) ) */
  typedef ByteEnum 				PaperOrientation;
#define PO_PORTRAIT 					0x00
#define PO_LANDSCAPE 					0x01
  typedef WordFlags 				PageLayoutPaper;
#define PLP_ORIENTATION 					0x0008
#define PLP_TYPE 					0x0004 /* PT_PAPER */
/* Envelope Layouts: 
 * (PT_ENVELOPE | (EP_path << 5) | (EO_ori << 3)) */
  typedef ByteEnum 				EnvelopePath;
#define EP_LEFT 					0x00
#define EP_CENTER 					0x01
#define EP_RIGHT 					0x02
  typedef ByteEnum 				EnvelopeOrientation;
#define EO_PORTAIT_LEFT 					0x00
#define EO_PORTAIT_RIGHT 					0x01
#define EO_LANDSCAPE_UP 					0x02
#define EO_LANDSCAPE_DOWN 					0x03
  typedef WordFlags 				PageLayoutEnvelope;
#define PLE_PATH 					0x0040
#define PLE_ORIENTATION 					0x0010
#define PLE_TYPE 					0x0004 /*PT_ENVELOPE*/
/* Label Layouts:
 * 	(PT_LABEL | (rows <<8) | (cols << 3)) */
  typedef WordFlags 				PageLayoutLabel;
#define PLL_ROWS 					0x7e00 /* # rows */
#define PLL_COLUMNS 					0x01f8 /* # cols */
#define 	PLL_TYPE 				0x0004 /* PT_LABEL */

Code Display 14-3 PageSizeControl Features

  typedef ByteFlags 	PageSizeControlFeatures;
/* The following flags may be combined with | and &:
	PSIZECF_MARGINS, 			( Set margin sizes )
	PSIZECF_CUSTOM_SIZE,			( Custom dimension ranges )
	PSIZECF_LAYOUT,
	PSIZECF_SIZE_LIST,
	PSIZECF_PAGE_TYPE 			( Choice of standard dimensions ) */
#define PSIZEC_DEFAULT_FEATURES (PSIZECF_PAGE_TYPE | PSIZECF_SIZE_LIST | \
		 		PSIZECF_LAYOUT | PSIZECF_CUSTOM_SIZE) 
MSG_PRINT_REPORT_PAGE_SIZE
void	MSG_PRINT_REPORT_PAGE_SIZE(
        PageSizeReport *psr);

The page size control's output object should have a handler for this message. The control will send this message whenever the user has changed the page size. The handler may wish to change the bounds of some appropriate object, store the new bounds somewhere, or take some other action.

Source: PageSizeControl object.

Destination: The GCI_output object.

Parameters: psr A pointer to a PageSizeReport structure containing the page type and size.

Return: Nothing.

Interception: The handler for this message should store the page size information. It may set the bounds of one or more visual objects.

 

In addition to the standard set of generic Control instance data, the Page Size control includes some of its own. This data, as you might expect, is largely concerned with paper size and setup. The fields are listed in Page Size Control Instance Data .

PageSizeControls use the PageLayout data structure to hold and pass layout information such as page orientation. One part of this structure gives the type of page being described: paper, envelope, or label. The other parts of the structure have different meanings depending on the type of page. For paper, the layout keeps track of the orientation. For envelopes, the structure contains both path and orientation information. For labels, this structure keeps track of how many labels are on the sheet in each direction; these numbers are bounded by MAXIMUM_LABELS_ACROSS and MAXIMUM_LABELS_DOWN.

Code Display 14-4 Page Size Control Instance Data

@instance PageSizeControlAttrs				PZCI_attrs = 0;
	/* Possible attributes:
	 * PZCA_ACT_LIKE_GADGET
	 * PZCA_PAPER_SIZE
	 * PZCA_INITIALIZE				*/
	/* Current page dimensions and type/layout */
@instance dword 			PZCI_width = 0;
@instance dword 			PZCI_height = 0;
@instance PageLayout 			PZCI_layout = 0;
@instance PCMarginParams			PZCI_margins = { 0, 0, 0, 0 };
/* The following vardata field is internal: */
@vardata  PageSizeControlMaxDimensions  TEMP_PAGE_SIZE_CONTROL_MAX_DIMENSIONS;
/* Its structure is defined: 
typedef struct {
 	dword  PZCMD_width; ( maximum width )
 	dword PZCMD_height; ( maximum height )
} PageSizeControlMaxDimensions; */
/* Attribute to allow applications to be made aware of every change made
 * to gadgetry in the PageSizeControl. This is especially useful for applications
 * that want to add UI that will be dependent upon the state of this
 * controller. No effort is made to eliminate the redundant output of data. */
@vardata  PageSizeControlChanges  ATTR_PAGE_SIZE_CONTROL_UI_CHANGES;
/* This field has structure:
	typedef struct {
	 optr  PSCC_destination; ( destination for message )
	 Message PSCC_message; ( message to be sent )
	}  PageSizeControlChanges; */
The message should follow the prototype: */
@prototype void PAGE_SIZE_UI_CHANGES_MSG(PageSizeReport _far *psr )
PZCI_width , PZCI_height
These integers represent the current page dimensions, measured in points. Note that these values may never go outside the bounds described by the constants MINIMUM_PAGE_WIDTH_VALUE , MINIMUM_PAGE_HEIGHT_VALUE, MAXIMUM_PAGE_WIDTH_VALUE , and MAXIMUM_PAGE_HEIGHT_VALUE.
PZCI_layout
This field contains a PageLayout structure describing the current page layout settings.
PZCI_margins
This field contains the page's margins.

The following messages allow applications to work with a PageSizeControl directly, like a regular UI gadget. There is one message which the PageSizeControl will send to its output, and several that any object may send to the controller.

Note that these messages are only useful if the PageSizeControl is operating in gadget mode (i.e. if its PZCA_ACT_LIKE_GADGET bit is set). Otherwise, the control's default behavior would override that requested by these messages.

The PageSizeControlAttrs record has the following flags:

PZCA_ACT_LIKE_GADGET
The PageSizeControl object will act like any other generic gadget and will not respond to normal controller notifications.
PZCA_PAPER_SIZE
The PageSizeControl object will display paper sizes instead of document sizes. Setting this would be very rare for applications.
PZCA_INITIALIZE
The PageSizeControl object will be initialized to system default values if PZCA_ACT_LIKE_GADGET is also set.
PZCA_LOAD_SAVE_OPTIONS
Allow the controller to load and save the user's options.
MSG_PZC_GET_PAGE_SIZE
void	MSG_PZC_GET_PAGE_SIZE(
        PageSizeReport		*psr);

This message returns the present page size in terms of width, height, and layout, stored in a PageSizeReport . Note that the PageSizeControl will be sending out a MSG_PRINT_REPORT_PAGE_SIZE every time the user applies changes to these values.

Only send this message if the PageSizeControl is operating in gadget mode.

Source: Unrestricted, as long as the PageSizeControl is in gadget mode.

Destination: PageSizeControl object.

Parameters: psr A pointer to a PageSizeReport structure in which the page size will be returned.

Return: The PageSizeReport structure pointed to by psr will be filled with the page information.

Interception: Unlikely.

MSG_PZC_SET_PAGE_SIZE
void 	MSG_PZC_SET_PAGE_SIZE(
        PageSizeReport *	psr);		

This message changes the current page size. It takes a PageSizeReport data structure containing the new dimensions and layout. The Apply trigger of a Page Size Control normally sends this message, passing the present user page size as arguments.

Only send this message if the PageSizeControl is operating in gadget mode.

Source: Unrestricted, as long as the PageSizeControl is in gadget mode.

Destination: PageSizeControl object.

Parameters: psr A pointer to a PageSizeReport structure containing page information.

Return: Nothing.

Interception: Unlikely.

MSG_PZC_SET_MAXIMUM_HEIGHT
void MSG_PZC_SET_MAXIMUM_HEIGHT(
        dword height);

Set the maximum height for a page.

Source: Anything.

Destination: PageSizeControl object.

Parameters: height Height, in points.

Return: Nothing.

Interception: Generally should not be intercepted.

MSG_PZC_SET_MAXIMUM_WIDTH
void MSG_PZC_SET_MAXIMUM_WIDTH(
        dword width);

Set the maximum width for a page.

Source: Anything.

Destination: PageSizeControl object.

Parameters: width Width, in points.

Return: Nothing.

Interception: Generally should not be intercepted.


Up: GEOS SDK TechDocs | Up | Prev: 5 Print Control Messages | Next: 7 Other Printing Components