/*
  docgen  Objective C Document Generator
  Copyright (C) 1995  Bill Bereza.
  
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
  
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
  
  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  
  Email:
  berezaw@river.it.gvsu.edu

  S-mail:
  Bill Bereza
  9526 Judson Rd.
  Ravenna, MI 49451-9427

  */
/* docgen	Objective C Document Generator
 * Copyright (c) 1994 Bill Bereza
 *
 * $Log:	RTFFormatter.m,v $
 * Revision 1.5  95/07/26  21:46:47  berezaw
 * changed definition of formatExtension
 * 
 * Revision 1.4  95/07/21  21:40:34  berezaw
 * *** empty log message ***
 * 
 * Revision 1.3  95/07/21  15:23:11  berezaw
 * *** empty log message ***
 * 
 * Revision 1.2  95/07/21  12:19:54  berezaw
 * *** empty log message ***
 * 
 * Revision 1.1  95/07/21  01:59:21  berezaw
 * Initial revision
 * 
 *
 *	$Id: RTFFormatter.m,v 1.5 95/07/26 21:46:47 berezaw Exp $
 */

#include "RTFFormatter.h"

@implementation RTFFormatter
/*
   This does some simple reverse-engineered RTF formatting.
   */

+(char *)fileExtension
{
	return "rtf";
}

// Generic formatting commands
-(int)changeFontSize:(int)to
{
	return [self writeFormat:"\n\\fs%d ", to];
}

-(int)putLine:(const char *)line
{
	return [self writeFormat:"%s\\\n", line];
}

-(int)putEof { return [self writeFormat: "}\n"]; }
-(int)makeBold { return [self writeFormat:"\n\\b "]; }
-(int)unBold { return [self writeFormat:"\n\\b0 "]; }
-(int)makeItalic { return [self writeFormat:"\n\\i "]; }
-(int)unItalic { return [self writeFormat:"\n\\i0 "]; }
-(int)changeFont:(int)to { return [self writeFormat:"\\f%d ", to]; }
-(int)makeUnderline { return [self writeFormat:"\n\\ul "]; }
-(int)unUnderline { return [self writeFormat:"\n\\ulnone "]; }

// <DocgenFormatting>
-(int)putConformHeader:(const char *)line
{
	[self writeFormat:"\\fs16 \\\n"];
	[self writeFormat:"\\f2\\b\\fs28 Conforms To:\n"];
	return [self writeFormat:"\\f0\\b0 \t%s \\\n", line];
}   

-(int)putMethodL1 { return [self writeFormat:"\\f2\\fs28\\b\\fi-380\\li2480 "]; }
-(int)putMethodL2 { return [self writeFormat:"\\f1\\b0\\fi-760\\li3240 "]; }
-(int)putHead
{
	[self writeFormat: "{\\rtf0\\ansi{\\fonttbl\\f0\\fnil Times-Roman;\\f2\\fswiss Helvetica;\\f1\\ftech Symbol;\\f3\\fmodern Ohlfs;}\n"];
	[self writeFormat: "\\paperw16220\n"];
	[self writeFormat: "\\paperh15040\n"];
	[self writeFormat: "\\margl120\n"];
	return [self writeFormat: "\\margr0\n"];
}

-(int)putCPHead { return [self writeFormat:"\\f0\\b0\\i0\\ulnone\\ql\\fs24\\fi0\\li0\\gray0\\fc0\\cf0\\up0\\dn0"]; }
-(int)putMethodDescription { return [self writeFormat:"\\\n\\f2\\b\\fs28 "]; }
-(int)putFont:(int)fn Char:(int)theChar
{
	return [self writeFormat:"\\f%d %c\n",fn, (char)theChar];
}

-(int)putStart
{
	[self writeFormat: "\\pard\\tx2480\\tx2860\\tx3240\\fs16\\li2100\\fc0\\cf0 \\\n\\\n\\\n"];
	return [self writeFormat: "\\pard\\f2\\b\\fs56\\li2100\\fc0\\cf0 "];
}

-(int)putInheritHeader
{
	[self writeFormat:"\\pard\\tx4880\\f0\\b0\\fs16\\fi-2780\\li4880\\fc0\\cf0 \\\n"];
	[self writeFormat:"\\\n\\\n\\\n"];
	return [self writeFormat:"\\f2\\b\\fs28 Inherits From:\t\n\\f0\\b0 "];
}

-(int)putInheritTail:(const char *)dec
{
	[self writeFormat:"\\fs16 \\\n"];
	[self writeFormat:"\\f2\\b\\fs28 Declared In:\n"];
	[self writeFormat:"\\f0\\b0 \t%s \\\n", dec];
	[self writeFormat:"\\f0\\fs16 \\\n"];
	[self writeFormat:"\\pard\\f2\\b\\li1360\\fc0\\cf0 \\\n"];
	[self writeFormat:"\\\n\\\n\\\n"];
	[self writeFormat:"\\fs36 Class Description\\\n"];
	[self writeFormat:"\\fs16 \\\n"];
	return [self writeFormat:"\\pard\\tx2480\\tx2860\\tx3240\\f0\\b0\\fs28\\li2100\\fc0\\cf0 "];
}

-(int)putCategoryHeader
{	
	[self writeFormat:"\\pard\\tx4880\\f0\\b0\\fs16\\fi-2780\\li4880\\fc0\\cf0 \\\n"];
	[self writeFormat:"\\\n\\\n\\\n"];
	return [self writeFormat:"\\f2\\b\\fs28 Category Of:\t\n\\f0\\b0 "];
}

-(int)putCategoryTail:(const char *)dec
{
	[self writeFormat:"\\fs16 \\\n"];
	[self writeFormat:"\\f2\\b\\fs28 Declared In:\n"];
	[self writeFormat:"\\f0\\b0 \t%s \\\n", dec];
	[self writeFormat:"\\f0\\fs16 \\\n"];
	
	[self writeFormat:"\\fs16 \\\n"];
	[self writeFormat:"\\pard\\f2\\b\\li1360\\fc0\\cf0 \\\n"];
	[self writeFormat:"\\\n\\\n"];
	[self writeFormat:"\\fs36 Category Description\\\n"];
	[self writeFormat:"\\fs16 \\\n"];
	return [self writeFormat:"\\pard\\tx2480\\tx2860\\tx3240\\f0\\b0\\fs28\\li2100\\fc0\\cf0 "];
}

-(int)putIHeader
{
	[self writeFormat:" \\\n\\pard\\f2\\b\\li1360\\fc0\\cf0 \\\n"];
	[self writeFormat:" \\\n \\\n \\\n"];
	[self writeFormat:"\\fs36 Instance Variables\\\n \\\n"];
	return [self writeFormat:"\\pard\\tx2860\\f0\\b0\\fs28\\li2100\\fc0\\cf0 "];
}

-(int)putMethodHeader:(const char *)kindof
{
	[self writeFormat:"\\pard\\f2\\b\\fs16\\li1360\\fc0\\cf0 \\\n"];
	[self writeFormat:"\\\n\\\n\\\n"];
	return [self writeFormat:"\\fs36 %s Methods\\\n", kindof];
}

-(int)putMethodType
{
	[self writeFormat:"\\fs16 \\\n"];
	[self writeFormat:"\\pard\\f2\\b\\li1360\\fc0\\cf0 \\\n"];
	[self writeFormat:"\\\n\\\n\\\n\\\n"];
	[self writeFormat:"\\fs36 Method Types\\\n"];
	[self writeFormat:"\\fs16 \\\n"];
	return [self writeFormat: "\\pard\\tx6140\\tx9660\\tx10180\\f0\\b0\\fs28\\fi-4040\\li6140\\fc0\\cf0 	\n"];
}

-(int)putIVarDescription
{
	[self writeFormat:"\\pard\\tx6140\\tx9660\\tx10180\\fs16\\fi-4040\\li6140\\fc0\\cf0 \\\n"];
	return [self writeFormat:"\\\n\\\n"];
}

@end
