#
# file external_templates
# This file is part of LyX, the document processor.
# Licence details can be found in the file COPYING.
#
# author Asger Alstrup Nielsen
# author Angus Leeming
# author Johnathan Burchill
#
# Full author contact details are available in file CREDITS.

# This file contains the definitions of those External Templates that are
# part of the official LyX distribution.
# Feel free to create your own External Templates, storing them in
# .lyx/external_templates


PreambleDef WarnNotFound
	%% Print a warning encased in an fbox.
	\def\lyxstripprefix#1>{}
	\newcommand{\warnNotFound}[1]{%
	        \def\lyxtempfilename{#1}%
	        \fbox{Could not find
	                \ttfamily\expandafter\lyxstripprefix\meaning\lyxtempfilename!}%
	        \typeout{Could not find \lyxtempfilename!}%
	}
PreambleDefEnd


PreambleDef InputOrWarn
	%% Input the file if it exists, using \input, else print a warning
	\newcommand{\inputOrWarn}[1]{%
	        \IfFileExists{#1}{\input{#1}}{\warnNotFound{#1}}}
PreambleDefEnd


Template RasterImage
	# By default, InsetExternal is displayed as a grey button
	# containing this text.
	GuiName "Bitmap: $$AbsOrRelPathParent$$Basename"
	# This text is used in the External dialog.
	# Provide enough information to explain to the user just
	# what the template can provide him with.
	HelpText
		A bitmap file.
	HelpTextEnd
	# ANY file type can be displayed as a RasterImage.
	# Specifically, LyX will attempt to interrogate the file itself
	# in order to deduce its format.
	InputFormat "*"
	# Globbing pattern used when browsing for a Raster image file.
	FileFilter "*.{gif,png,jpg,bmp,pbm,ppm,tga,tif,xpm,xbm}"
	# Set to "true" if the file represented by the template
	# must be generated by LyX.
	AutomaticProduction true
	# LyX has hard-coded support for these transformations
	Transform Rotate
	Transform Resize
	Transform Clip
	Transform Extra
	Format LaTeX
		TransformOption Rotate RotationLatexOption
		TransformOption Resize ResizeLatexOption
		TransformOption Clip   ClipLatexOption
		TransformOption Extra  ExtraOption
		Option Arg "[$$Extra,$$Rotate,$$Resize,$$Clip]"
		# This string is what is output to the LaTeX file.
		Product "\\includegraphics$$Arg{$$AbsOrRelPathMaster$$Basename}"
		UpdateFormat eps
		UpdateResult "$$AbsPath$$Basename.eps"
		Requirement "graphicx"
		ReferencedFile latex "$$AbsPath$$Basename.eps"
		ReferencedFile dvi   "$$AbsPath$$Basename.eps"
	FormatEnd
	Format PDFLaTeX
		TransformOption Rotate RotationLatexOption
		TransformOption Resize ResizeLatexOption
		TransformOption Clip   ClipLatexOption
		TransformOption Extra  ExtraOption
		Option Arg "[$$Extra,$$Rotate,$$Resize,$$Clip]"
		Product "\\includegraphics$$Arg{$$AbsOrRelPathMaster$$Basename}"
		UpdateFormat png
		UpdateResult "$$AbsPath$$Basename.png"
		Requirement "graphicx"
		ReferencedFile pdflatex "$$AbsPath$$Basename.png"
	FormatEnd
	Format Ascii
		Product "$$Contents(\"$$AbsPath$$Basename.asc\")"
		UpdateFormat asciiimage
		UpdateResult "$$AbsPath$$Basename.asc"
	FormatEnd
	Format DocBook
		Product "<graphic fileref=\"$$AbsOrRelPathMaster$$Basename.eps\"></graphic>"
		UpdateFormat eps
		UpdateResult "$$AbsPath$$Basename.eps"
		ReferencedFile docbook     "$$AbsPath$$Basename.eps"
		ReferencedFile docbook-xml "$$AbsPath$$Basename.eps"
	FormatEnd
	Format LinuxDoc
		Product "[Bitmap: $$FName]"
	FormatEnd
TemplateEnd


Template XFig
	GuiName "XFig: $$AbsOrRelPathParent$$Basename"
	HelpText
		An XFig figure.
	HelpTextEnd
	InputFormat fig
	FileFilter "*.fig"
	AutomaticProduction true
	Transform Rotate
	Transform Resize
	Format LaTeX
		TransformCommand Rotate RotationLatexCommand
		TransformCommand Resize ResizeLatexCommand
		Product "$$RotateFront$$ResizeFront\\input{$$AbsOrRelPathMaster$$Basename.pstex_t}$$ResizeBack$$RotateBack"
		UpdateFormat pstex
		UpdateResult "$$AbsPath$$Basename.pstex_t"
		Requirement "color"
		Requirement "graphicx"
		# Preamble WarnNotFound
		# Preamble InputOrWarn
		ReferencedFile latex "$$AbsOrRelPathMaster$$Basename.pstex_t"
		ReferencedFile latex "$$AbsPath$$Basename.eps"
		ReferencedFile dvi   "$$AbsPath$$Basename.eps"
	FormatEnd
	Format PDFLaTeX
		TransformCommand Rotate RotationLatexCommand
		TransformCommand Resize ResizeLatexCommand
		Product "$$RotateFront$$ResizeFront\\input{$$AbsOrRelPathMaster$$Basename.pdftex_t}$$ResizeBack$$RotateBack"
		UpdateFormat pdftex
		UpdateResult "$$AbsPath$$Basename.pdftex_t"
		Requirement "color"
		Requirement "graphicx"
		# Preamble WarnNotFound
		# Preamble InputOrWarn
		ReferencedFile pdflatex "$$AbsOrRelPathMaster$$Basename.pdftex_t"
		ReferencedFile pdflatex "$$AbsPath$$Basename.pdf"
	FormatEnd
	Format Ascii
		Product "$$Contents(\"$$AbsPath$$Basename.asc\")"
		UpdateFormat asciixfig
		UpdateResult "$$AbsPath$$Basename.asc"
	FormatEnd
	Format DocBook
		Product "<graphic fileref=\"$$AbsOrRelPathMaster$$Basename.eps\"></graphic>"
		UpdateFormat eps
		UpdateResult "$$AbsPath$$Basename.eps"
		ReferencedFile docbook     "$$AbsPath$$Basename.eps"
		ReferencedFile docbook-xml "$$AbsPath$$Basename.eps"
	FormatEnd
	Format LinuxDoc
		Product "[XFig: $$FName]"
	FormatEnd
TemplateEnd


Template ChessDiagram
	GuiName "Chess: $$AbsOrRelPathParent$$Basename"
	HelpText
		A chess position diagram.
		This template will use XBoard to edit the position.
		Use the 'File->Save Position' in XBoard to save
		the position that you want to display.
		Make sure to give it a '.fen' extension
		and remember to type in a relative path
		to the LyX document location.
		Within XBoard, use 'Edit->Edit Position'
		to enable general editing of the board.
		You might also check out the
		'Options->Test legality' option, and
		remember to middle and right click to
		insert new material in the board.
		In order for this to work, you have to
		put the bundled lyxskak.sty in a place
		that TeX will find it, and you will need
		to install the skak package from CTAN.
	HelpTextEnd
	InputFormat fen
	FileFilter "*.fen"
	AutomaticProduction true
	Format LaTeX
		Product "\\loadgame{$$AbsOrRelPathMaster$$Basename}\\showboard"
		Requirement "chess"
		ReferencedFile latex "$$AbsPath$$Basename$$Extension"
	FormatEnd
	Format PDFLaTeX
		Product "\\loadgame{$$AbsOrRelPathMaster$$Basename}\\showboard"
		Requirement "chess"
		ReferencedFile pdflatex "$$AbsPath$$Basename$$Extension"
	FormatEnd
	Format Ascii
		Product "$$Contents(\"$$AbsPath$$Basename.asc\")"
		UpdateFormat asciichess
		UpdateResult "$$AbsPath$$Basename.asc"
	FormatEnd
	Format DocBook
		Product "[Chess: $$AbsOrRelPathMaster$$Basename]"
	FormatEnd
	Format LinuxDoc
		Product "[Chess: $$FName]"
	FormatEnd
TemplateEnd


Template Date
	GuiName "Date"
	HelpText
		Today's date.
		Read 'info date' for more information.
	HelpTextEnd
	InputFormat date
	FileFilter "*"
	AutomaticProduction true
	Format LaTeX
		Product "$$Contents(\"$$Tempname\")"
		UpdateFormat dateout
		UpdateResult "$$Tempname"
	FormatEnd
	Format PDFLaTeX
		Product "$$Contents(\"$$Tempname\")"
		UpdateFormat dateout
		UpdateResult "$$Tempname"
	FormatEnd
	Format Ascii
		Product "$$Contents(\"$$Tempname\")"
		UpdateFormat dateout
		UpdateResult "$$Tempname"
	FormatEnd
	Format DocBook
		Product "$$Contents(\"$$Tempname\")"
		UpdateFormat dateout
		UpdateResult "$$Tempname"
	FormatEnd
	Format LinuxDoc
		Product "$$Contents(\"$$Tempname\")"
		UpdateFormat dateout
		UpdateResult "$$Tempname"
	FormatEnd
TemplateEnd
