/******************************************************************************
 **
 **	C++ Class Library for the Amiga© system software.
 **
 **	Copyright (C) 1994 by Armin Vogt  **  EMail: armin@uni-paderborn.de
 **	All Rights Reserved.
 **
 **	$Source: apphome:APlusPlus/RCS/libsource/GadgetCV.cxx,v $
 **	$Revision: 1.3 $
 **	$Date: 1994/04/23 21:01:01 $
 **	$Author: Armin_Vogt $
 **
 ******************************************************************************/


extern "C" {
#ifdef __GNUG__
#include <inline/intuition.h>
#endif

#ifdef __SASC
#include <proto/intuition.h>
#endif
}
#include <APlusPlus/intuition/GadgetCV.h>


volatile static char rcs_id[] = "$Id: GadgetCV.cxx,v 1.3 1994/04/23 21:01:01 Armin_Vogt Exp Armin_Vogt $";


GWindow *GadgetCV::redrawSelfHomeWindow = NULL;

struct Gadget *GadgetCV::storeGadget(struct Gadget *gadget)
{
	IObject() = gadget;
	if (gadget) gadget->UserData = (APTR)this;
	return gadget;
}

struct Gadget *GadgetCV::getGT_Context()
{
	return getHomeWindow()->GT_last;
}

BOOL GadgetCV::forceActiveGadget(const IntuiMessageC *imsg)
{
	if (!(imsg->isFakeMsg()))
	{	
		getHomeWindow()->activeGadget = this;
		return TRUE;
	}
	else return FALSE;
}

GWindow *GadgetCV::getHomeWindow()
{	
	if (redrawSelfHomeWindow) return redrawSelfHomeWindow;
	else
	{
		GWindow *gwin;
	   if (gwin = (GWindow*)findRootOfKind(IOTYPE_GWINDOW))
			return gwin;
		else{ cerr << "Fatal error: no gwindow root!\n"; return NULL; }
	}
}
   
ULONG GadgetCV::getAttribute(Tag tag,ULONG& dataStore)
{
	return GraphicObject::getAttribute(tag,dataStore);
}


