//=============================================================================
//
//		Copyright (C) 1996-1997 by Paul S. McCarthy and Eric Sunshine.
//				Written by Paul S. McCarthy and Eric Sunshine.
//							All Rights Reserved.
//
//		This notice may not be removed from this source code.
//
//		This object is included in the MiscKit by permission from the authors
//		and its use is governed by the MiscKit license, found in the file
//		"License.rtf" in the MiscKit distribution.	Please refer to that file
//		for a list of all applicable permissions and restrictions.
//		
//=============================================================================
//-----------------------------------------------------------------------------
// MiscTableScrollPrint.M
//
//		Printing support for MiscTableScroll.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// $Id: MiscTableScrollPrint.M,v 1.2 97/02/11 19:22:42 sunshine Exp $
// $Log:		MiscTableScrollPrint.M,v $
// Revision 1.2	 97/02/11  19:22:42	 sunshine
// v123: Fixed bug: Delegate methods -tableScrollWillPrint: &
// -tableScroll:didPrint: were getting subverted when -printPSCode: was sent
// to first-responder (which is the MiscTableView, not the MiscTableScroll).
// Connecting Print... item to first-responder in IB can cause this.
// Was fixed by sending them in MiscTableViewPrint.M rather than here.
// 
// Revision 1.1	 96/10/24  22:48:40	 zarnuk
// TableScroll hook for printing.
//-----------------------------------------------------------------------------
#import "MiscTableScrollPrivate.h"
#import "MiscDelegateFlags.h"
#import "MiscTableView.h"
#import "MiscBorderView.h"

extern "Objective-C" {
#import <appkit/Application.h>
#import <appkit/PrintInfo.h>
#import <appkit/PrintPanel.h>
}


//=============================================================================
// IMPLEMENTATION
//=============================================================================
@implementation MiscTableScroll(Print)

- (id)getPageHeader						{ return pageHeader; }
- (id)getPageFooter						{ return pageFooter; }
- (void)setPageHeader:(id)obj			{ pageHeader = obj; }
- (void)setPageFooter:(id)obj			{ pageFooter = obj; }

- (MiscTablePrintInfo const*)getPrintInfo { return [tableView getPrintInfo]; }

//-----------------------------------------------------------------------------
// dumpPrintInfo
//-----------------------------------------------------------------------------
- (void)dumpPrintInfo
	{
	PrintInfo* pinfo = (PrintInfo*)[NXApp printInfo];
	fprintf( stderr, "printInfo=%p\n", pinfo );
	fprintf( stderr, "paperType:[%s]\n", [pinfo paperType] );

	NXRect const* const paperRect = [pinfo paperRect];
	if (paperRect != 0)
		fprintf( stderr, "paperRect:{{%g,%g},{%g,%g}}\n",
				paperRect->origin.x, paperRect->origin.y,
				paperRect->size.width, paperRect->size.height );
	else
		fprintf( stderr, "paperRect:(null pointer)\n" );

	float leftMargin;
	float rightMargin;
	float topMargin;
	float bottomMargin;
	[pinfo	getMarginLeft:&leftMargin
			right:&rightMargin
			top:&topMargin
			bottom:&bottomMargin
		];
	fprintf( stderr, "margins: left=%g right=%g top=%g bottom=%g\n",
				leftMargin, rightMargin, topMargin, bottomMargin );

	fprintf( stderr, "scalingFactor=%g\n", [pinfo scalingFactor] );
	fprintf( stderr, "orientation=%d\n", (int)[pinfo orientation] );
	fprintf( stderr, "isHorizCentered=%d\n", (int)[pinfo isHorizCentered] );
	fprintf( stderr, "isVertCentered=%d\n", (int)[pinfo isVertCentered] );
	fprintf( stderr, "horizPagination=%d\n", [pinfo horizPagination] );
	fprintf( stderr, "vertPagination=%d\n", [pinfo vertPagination] );
	fprintf( stderr, "outputFile=[%s]\n", [pinfo outputFile] );
	fprintf( stderr, "pageOrder=%d\n", (int)[pinfo pageOrder] );
	fprintf( stderr, "isAllPages=%d\n", (int)[pinfo isAllPages] );
	fprintf( stderr, "firstPage=%d\n", [pinfo firstPage] );
	fprintf( stderr, "lastPage=%d\n", [pinfo lastPage] );
	fprintf( stderr, "currentPage=%d\n", [pinfo currentPage] );
	fprintf( stderr, "copies=%d\n", [pinfo copies] );
	fprintf( stderr, "pagesPerSheet=%d\n", (int)[pinfo pagesPerSheet] );
	fprintf( stderr, "reversePageOrder=%d\n", (int)[pinfo reversePageOrder] );
	// There are also job features...
	}


//-----------------------------------------------------------------------------
// printPSCode:
//-----------------------------------------------------------------------------
- (id)printPSCode:(id)sender
	{
	return ([tableView printPSCode:sender] != 0 ? self : 0);
	}

@end
