/*	XPrinter.h
 *
 *		This is the interface for printing. This handles a standard
 *	printing interface for both Windows and MacOS
 */

/**********************************************************************

  YAAF is Copyright 1997-1999 by William Woody.

  Redistribution and use in source and binary forms, with or without 
  modification, are permitted provided that the following conditions 
  are met:

  Redistributions of source code must retain the above copyright notice, 
  this list of conditions and the following disclaimer.

  Neither the name of the copyright holder or other contributors may
  be used to promote products derived from this software without
  specific written prior permission.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
  SOFTWARE.
  
  Contact:   woody@alumni.caltech.edu
  Web page:  http://www.pandawave.com/yaaf/

**********************************************************************/

#ifndef PandaWave_XPRINTER
#define PandaWave_XPRINTER

#include <XConfig.h>
#include <XView.h>

/************************************************************************/
/*																		*/
/*	Constants															*/
/*																		*/
/************************************************************************/

#define	KTPDefault				0x8000
#define KTPSquareResolution		0x0001
#define KTPMaxResolution		0x0002

/************************************************************************/
/*																		*/
/*	Default menu commands												*/
/*																		*/
/************************************************************************/

/*$	XGPrinter
 *
 *		This is a printer interface. And no, we can only have one of
 *	these at a time. This provides a simple interface for drawing
 *	onto a printer page.
 *
 *		To print, you would first run the PrintJob() method to find
 *	the parameters of the printing job. That routine will return the
 *	page count of the pages to actually print. Then, you would
 *	call the StartJob(), then StartPage() routines, and then
 *	create an XGDraw object to draw into. Once each page is drawn,
 *	you would call EndPage(), and when you are done with the entire
 *	job, call EndJob().
 *
 *		To determine if printing should be canceled, periodically
 *	call the GetCancelState() routine.
 *
 *		This currently does not work on X Windows.
 */

class XGPrinter {
	public:
								XGPrinter();
		virtual					~XGPrinter();
		
		/*
		 *	Current Page size settings
		 */
		
		XRect					PageSize();		// size of a page
		XRect					PrintSize();	// printing area in page
		XPoint					Resolution();	// Resolution of page
		
		/*
		 *	Set the resolution
		 */
		
		void					SetResolution(short);
		
		/*
		 *	Run the dialog boxes
		 */
		 
		bool					PageSetup();
		bool					PrintJob(short *, short *);
		
		/*
		 *	Printing core
		 */
		
		bool					StartJob(char *docname = NULL);
		void					EndJob();
		bool					StartPage();
		void					EndPage();
		bool					GetCancelState();
		
	private:

#if OPT_MACOS == 1
		void					OpenWindow(void);
		
		bool					fPrinter;
		THPrint					fHPrint;
		TPPrPort				fPort;
		WindowPtr				fWindow;
#endif

#if OPT_WINOS == 1
		HDC						fPrintDC;
		PRINTDLG				fPrintData;
#endif

	friend class XGDraw;
};

/************************************************************************/
/*																		*/
/*	Globals																*/
/*																		*/
/************************************************************************/

/*$	GPrinter
 *
 *		The global printer object. When printing, you would normally
 *	use this object rather than creating your own.
 */

extern XGPrinter	GPrinter;			/* The printer interface		*/


#endif // PandaWave_XPRINTER
