/*
**      Newton Developer Technical Support Sample Code
**
**      VariRoute, a Newton 2.0 routing example
**
**      by J. Christopher Bell, Newton Developer Technical Support
**
**      Copyright  1994-7 by Apple Computer, Inc.  All rights reserved.
** 
**      You may incorporate this sample code into your applications without
**      restriction.  This sample code has been provided "AS IS" and the
**      responsibility for its operation is 100% yours.  You are not
**      permitted to modify and redistribute the source as "DTS Sample Code."
**      If you are going to re-distribute the source, we require that you
**      make it clear in the source that the code was descended from
**      Apple-provided sample code, but that you've made changes.
*/

// kReflowWrapperFunc
//
// This is a wrapper function for using the Reflow function, which prepares and groups
// clEditView view templates for intelligent printing. It tries to keep graphics and 'clustered'
// objects together.
// 
// Arguments:
//   stepChildren: an array of clEditView view templates
//   fontSpec: the font to be used for printing. If nil, the default font will be used
//   box: the local coordinates of the destination view
//
// kReflowWrapperFunc returns an array of view templates (which may be different in number
// from the original because of grouping), that may contain slightly different values for viewFlags,
// viewJustify, and viewBounds slots. 
// 
// Note that there are some arguments to Reflow(...) that must be specific
// values, and they are provided in this wrapper function.
// 
// *** See the README.VariRoute file for more information on how to use it! ***

DefineGlobalConstant('kReflowWrapperFunc, func(editViewChildren, fontSpec, box)
	begin
		local reflowOptions := {
			unistyle: nil, // this should always be this value. Do not change it.
			graphicsGutter: 16,  // this should always be this value. Do not change it.
			textGutter: -16, // this should always be this value. Do not change it.
			viewLineSpacing: 30 // this should always be this value. Do not change it.
		};
		
		if fontSpec then
			reflowOptions.reflowFont := fontSpec;
		
		Reflow(editViewChildren, reflowOptions, RelBounds(0,0,0,0), box);
	end);
