/*	XGInline.cpp
 *
 *		A simple inline class which handles various common inline
 *	editing operations. Future versions of this will absorb more
 *	functionality out of the XGInlineEdit and XGInlinePopup classes
 */

/**********************************************************************

  YAAF is Copyright 1997-1999 by William Woody.

  Redistribution and use in source and binary forms, with or without 
  modification, are permitted provided that the following conditions 
  are met:

  Redistributions of source code must retain the above copyright notice, 
  this list of conditions and the following disclaimer.

  Neither the name of the copyright holder or other contributors may
  be used to promote products derived from this software without
  specific written prior permission.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
  SOFTWARE.
  
  Contact:   woody@alumni.caltech.edu
  Web page:  http://www.pandawave.com/yaaf/

**********************************************************************/

#include <XConfig.h>
#include <XInline.h>

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

XGInline *XGInline::gInline;

/************************************************************************/
/*																		*/
/*	Standard Classes													*/
/*																		*/
/************************************************************************/

/*$	XGInline::XGInline
 *
 *		Create me. This creates a blank inline object.
 */

XGInline::XGInline()
{
	fParentEvent = NULL;
	
	if (gInline) gInline->Close();
	gInline = this;
}

/*$	XGInline::~XGInline
 *
 *		Destroy me. This deletes this inline object.
 */

XGInline::~XGInline()
{
	if (gInline == this) gInline = NULL;
}

/************************************************************************/
/*																		*/
/*	Standard Classes													*/
/*																		*/
/************************************************************************/

/*$	XGInline::Close
 *
 *		If an inline object is currently open, this closes the inline
 *	object.
 */

void XGInline::Close()
{
	if (gInline) gInline->fParentEvent->SetFocus();
}

/*$	XGInline::CloseInline
 *
 *		If this view has an inline editor associated with me, this
 *	then closes the inline editor
 */

void XGInline::CloseInline(XGView *v)
{
	if (gInline) {
		if (gInline->fParentEvent == v) {
			gInline->Close();
		}
	}
}

