#include <intuition/intuition.h>
#include <workbench/workbench.h>


short PutProject(fname,tool,image,image2,tooltypes,stack)
char *fname;		 /* file name to save to */
char *tool;		 /* default tool */
struct Image *image;	 /* image for the Icon */
struct Image *image2;	 /* second image or NULL */
char **tooltypes;	 /* ToolTypes array */
long stack;		 /* stack size, zero for default */
{
long PutDiskObject();
/* This is a static copy of the DiskObject
 * structure that is used for the project. */
static struct DiskObject d0 =
{
WB_DISKMAGIC,		     /* do_Magic */
WB_DISKVERSION,   /* do_Version */

   {		  /* Gadget */
   0L,			      /* NextGadget */
   0,0, 		      /* LeftEdge TopEdge */
   0,0, 		      /* Width Height */
   GADGIMAGE,  /* Flags */
   RELVERIFY | GADGIMMEDIATE, /* Activation */
   BOOLGADGET,		      /* GadgetType */
   0L,			      /* GadgetRender */
   0L,			      /* SelectRender */
   0L,			      /* GadgetText */
   0L,			      /* MutualExclude */
   0L,			      /* SpecialInfo */
   0,			      /* GadgetID */
   0L,			      /* UserData */
   },
WBPROJECT,	  /* do_Type */
0L,		  /* do_DefaultTool */
0L,		  /* do_ToolTypes */
NO_ICON_POSITION, /* do_CurrentX */
NO_ICON_POSITION, /* do_CurrentY */
0L,		  /* do_DrawerData */
0L,		  /* do_ToolWindow */
0L,		  /* do_StackSize */
};

/* This is a private copy of the DiskObject
 * structure that is used to save the DiskObject. */
struct DiskObject d;
/* Private Image structure, it may be modified. */
struct Image i, i2;

/* Initialize local copies */
d= d0;
i = *image;

/* Now fill in the DiskObject with the specifics
 * for the application */
d.do_Gadget.Width = i.Width;
d.do_Gadget.Height = i.Height+1;
d.do_Gadget.GadgetRender = (APTR)&i;
if( image2 )
   {
   i2 = *image2;
   d.do_Gadget.Flags |= GADGHIMAGE;
   d.do_Gadget.SelectRender = (APTR)&i2;
   i2.Depth = 2;
   i2.PlanePick = 3;
   i2.PlaneOnOff = 0;
   i2.NextImage = 0L;
   }
else
   d.do_Gadget.Flags |= GADGBACKFILL;
i.Depth = 2;
i.PlanePick = 3;
i.PlaneOnOff = 0;
i.NextImage = 0L;
d.do_DefaultTool = tool;
d.do_ToolTypes = tooltypes;
d.do_StackSize = stack;

/* Save the disk object to the file */
if( !PutDiskObject(fname,&d) )
   return(1);
return(0);
}

