/*
 * Example for using EXTRACTFONT fonts...
 *
 * Compile with
 *    cc +l TEST.c
 *    cc +l SMALL.c
 *
 * Link with
 *    ln TEST.o SMALL.o -lc32
 */

#include <exec/types.h>
#include <graphics/gfxbase.h>
#include <intuition/intuition.h>
#include <intuition/intuitionbase.h>
#include <functions.h>
#include <stdio.h>

/* Font data */
extern	struct TextFont SmallFont;

struct	IntuitionBase	*IntuitionBase = 0;
struct	GfxBase		*GfxBase = 0;

struct	Window		*MainWindow = 0;
struct	RastPort	*MainRp = 0;

#define MYMODES1	MOUSEBUTTONS
#define ACTIVEMODE	MYMODES1

#define WMODES1		ACTIVATE|NOCAREREFRESH
#define WMODES2		RMBTRAP
#define WMODES		WMODES1|WMODES2

struct	NewWindow	NewWindow = {
	160, 50,		/* Left, Top Edge		*/
	320, 100,		/* Width, Height		*/
	0, 1,			/* DetailPen, BlockPen		*/
	ACTIVEMODE,		/* IDCMP Flags			*/
	WMODES, 		/* WINDOWFLAGS			*/
	NULL, 			/* User Gadgets			*/
	NULL,			/* Check Mark			*/
	NULL,			/* Title			*/
	NULL,			/* Screen			*/
	NULL,			/* SuperBitMap			*/
	0,0,0,0,		/* Min, Max Size		*/
	WBENCHSCREEN		/* Screen Type			*/
};

Initialize ()
{
	if (( GfxBase = (struct GfxBase *)OpenLibrary ("graphics.library", LIBRARY_VERSION)) == NULL)
		Quit ("Couldn't open graphics.library");

	if (( IntuitionBase = (struct IntuitionBase *)OpenLibrary ("intuition.library", LIBRARY_VERSION)) == NULL)
		Quit ("Couldn't open intuition.library");

	if (! (MainWindow = OpenWindow (&NewWindow)))
		Quit ("Couldn't open Window");

	MainRp = MainWindow->RPort;
}

Quit (message)
char	*message;
{
	if (MainWindow)		CloseWindow (MainWindow);
	if (IntuitionBase)	CloseLibrary ((struct Library *)IntuitionBase);
	if (GfxBase)		CloseLibrary (GfxBase);

	if (message)
		printf ("Error: %s\n", message);

	exit (0);
}

main ()
{
	Initialize ();

	SetFont (MainRp, &SmallFont);

	SetDrMd (MainRp, JAM1);
	SetAPen (MainRp, 1);

	Move (MainRp, 10, 10);
	Text (MainRp, "PRESS THE LEFT MOUSE BUTTON!", 28);

	WaitPort (MainWindow->UserPort);

	Quit (NULL);
}


