/*	Inspector.cpp
 *
 *		Handles the routines which process the inspector window
 */

/*  YAAF Constructor - Rapid application development for YAAF
 *  Copyright (C) 1998 William Edward Woody
 *  
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2
 *  of the License, or (at your option) any later version.
 *  
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 *  02111-1307, USA.
 *  
 *  To contact the author, either e-mail me at woody@pandawave.com, 
 *	or write to
 *  
 *          William Edward Woody
 *          In Phase Consulting
 *          1545 Ard Eevin Avenue
 *          Glendale, CA 91202
 *
 *	Or visit us on the web at http://www.pandawave.com
 */

#include <XWindow.h>
#include "LayoutViews.h"
#include "Inspector.h"

/************************************************************************/
/*																		*/
/*	Globals																*/
/*																		*/
/************************************************************************/

XGWindow	*TInspectorForm::gInspector;

/************************************************************************/
/*																		*/
/*	Construction/Destruction											*/
/*																		*/
/************************************************************************/

/*	TInspectorForm::TInspectorForm
 *
 *		Make me
 */

TInspectorForm::TInspectorForm()
{
}

/*	TInspectorForm::~TInspectorForm
 *
 *		Kill me
 */

TInspectorForm::~TInspectorForm()
{
	gInspector = NULL;
}

/************************************************************************/
/*																		*/
/*	Inspection															*/
/*																		*/
/************************************************************************/

/*	TInspectorForm::OpenInspectorWindow
 *
 *		Open the inspector window
 */

void TInspectorForm::OpenInspectorWindow()
{
	TInspectorForm *form;
	
	if (gInspector) {
		gInspector->SelectWindow();
		return;
	}
	
	form = new TInspectorForm;
	gInspector = XGWindowFactory::CreateFromResource(133,NULL,form);
}

/*	TInspectorForm::CloseInspectorWindow
 *
 *		Close the inspector window
 */

void TInspectorForm::CloseInspectorWindow()
{
	if (gInspector) {
		delete gInspector;
		gInspector = NULL;
	}
}

/*	TInspectorForm::IsInspectorWindowOpen
 *
 *		Is the inspector window open?
 */

bool TInspectorForm::IsInspectorWindowOpen()
{
	if (gInspector) return true;
	return false;
}

/*	TInspectorForm::SetInspectorSelect
 *
 *		Set which item is selected in my inspector
 */

void TInspectorForm::SetInspectorSelect(TResDocument *doc, XGWindow *w, ViewItemDeclaration *item)
{
	TItemListView *i;
	
	if (gInspector) {
		i = dynamic_cast<TItemListView *>(gInspector->FindViewByID(2));
		if (i) {
			i->UpdateSelect(item,doc,w);
		}
	}
}

/*	TInspectorForm::UpdateInspector
 *
 *		Tells the inspector to update itself
 */

void TInspectorForm::UpdateInspector(TResDocument *doc, XGWindow *w, ViewItemDeclaration *item)
{
	TItemListView *i;
	
	if (gInspector) {
		i = dynamic_cast<TItemListView *>(gInspector->FindViewByID(2));
		if (i) {
			i->UpdateInspector(item,doc,w);
		}
	}
}

