/*
**    GrabKEY
**
**        © 1996 by Timo C. Nentwig
**        All Rights Reserved !
**
**        Tcn@techbase.in-berlin.de
**
**
*/

/// #include

#include "gk_GST.h"
#include "gk_Protos.h"

///
/// proto

proto  BOOL    Grab    (const ULONG What, const ULONG Where);

///

/// Grab ()

	/*
	 *    FUNCTION    Grab something to somewhere.
	 *
	 *    NOTE        Values for <What>/<Where> in gk_GST.h
	 *
	 *    EXAMPLE     Grab (WINDOW, DEF_FILE);
	 *
	 */


BOOL
Grab (const ULONG What, const ULONG Where)
{

	Object   *Image = NULL;                // NULL is very important !

		// Load notification sound

	PlaySound (Set -> Sound . Start);

		// Get image

	if (GetImage (&Image, What))
	{

		switch (Where)
		{

				// Save to file

			case TO_FILE:

					// No output specified, open Requester

				if (StrEmpty (Set -> File . Path))
				{

					UBYTE    File [256];

					STRCPY (File, GetFile());

					if ( ! (StrEmpty (File)))
					{

						SaveImage (Image, File);

					}

				}
				else
				{

					SaveImage (Image, Set -> File . Path);

				}
				break;

				// Save to printer

			case TO_PRINTER:

				PrintImage (Image);
				break;

				// Save to clipboard

			case TO_CLIPBOARD:

				SaveClipboard (Image);
				break;

		}

			// Alright, dispose DT object

		DisposeDTObject (Image);

	}
	else
	{

		ErrorRequest ("OK", LocaleString (MSG_ERR_GETIMAGE));

	}

		// Load notification sound

	PlaySound (Set -> Sound . Done);

	return (FALSE);

}

///

